OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
OpalStripper.cpp
Go to the documentation of this file.
1 //
2 // Class OpalStripper
3 // The Stripper element
4 //
5 // Copyright (c) 2011, Jianjun Yang, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // Copyright (c) 2014, 2017-2018, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // Implemented as part of the PhD thesis
10 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects"
11 // and the paper
12 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects:
13 // Model, implementation, and application"
14 // (https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.13.064201)
15 //
16 // This file is part of OPAL.
17 //
18 // OPAL is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
25 //
26 #include "Elements/OpalStripper.h"
28 #include "Attributes/Attributes.h"
30 #include "Physics/Physics.h"
31 #include "Physics/Units.h"
32 
33 
35  OpalElement(SIZE, "STRIPPER",
36  "The \"STRIPPER\" element defines a Stripper.") {
37 
39  ("XSTART", " Start of x coordinate [mm]");
41  ("XEND", " End of x coordinate, [mm]");
43  ("YSTART", "Start of y coordinate, [mm]");
45  ("YEND", "End of y coordinate, [mm]");
47  ("WIDTH", "Width of the stripper [mm], NOT used");
49  ("OPCHARGE", "Charge number of the outcome particle");
51  ("OPMASS", "Mass of the outcome particle [GeV/c^2]");
53  ("OPYIELD", "Yield (Particle number of the outcome particle) per income particle");
55  ("STOP", "Option Whether stop tracking at the stripper. Default: true", true);
56 
58 
59  setElement(new StripperRep("STRIPPER"));
60 }
61 
62 
63 OpalStripper::OpalStripper(const std::string &name, OpalStripper *parent):
64  OpalElement(name, parent) {
65  setElement(new StripperRep(name));
66 }
67 
68 
70 {}
71 
72 
73 OpalStripper *OpalStripper::clone(const std::string &name) {
74  return new OpalStripper(name, this);
75 }
76 
77 
80 
81  StripperRep *strp = dynamic_cast<StripperRep *>(getElement());
82 
83  double xstart = Units::mm2m * Attributes::getReal(itsAttr[XSTART]);
84  double xend = Units::mm2m * Attributes::getReal(itsAttr[XEND]);
85  double ystart = Units::mm2m * Attributes::getReal(itsAttr[YSTART]);
86  double yend = Units::mm2m * Attributes::getReal(itsAttr[YEND]);
87 
88  double length = Attributes::getReal(itsAttr[LENGTH]);
89  double opcharge = Attributes::getReal(itsAttr[OPCHARGE]);
90  double opmass = Attributes::getReal(itsAttr[OPMASS]);
91  double opyield = Attributes::getReal(itsAttr[OPYIELD]);
92  bool stop = Attributes::getBool(itsAttr[STOP]);
93 
94  strp->setElementLength(length);
95  strp->setDimensions(xstart, xend, ystart, yend);
96  strp->setOPCharge(opcharge);
97  strp->setOPMass(opmass);
98  strp->setOPYield(opyield);
99  strp->setStop(stop);
101 
102  // Transmit "unknown" attributes.
104 }
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
virtual ~OpalStripper()
void setStop(bool stopflag)
Definition: Stripper.cpp:78
void setOPCharge(double charge)
Member variable access.
Definition: Stripper.cpp:66
void setOPMass(double mass)
Definition: Stripper.cpp:70
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
virtual void update()
Update the embedded CLASSIC septum.
virtual OpalStripper * clone(const std::string &name)
Make clone.
constexpr double mm2m
Definition: Units.h:29
void setOutputFN(std::string fn)
Set output filename.
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setOPYield(double yield)
Definition: Stripper.cpp:74
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const