OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalStripper.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalStripper.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalStripper
10 // The class of OPAL Strippers.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2011/07/08 08:16:01 $
15 // $Author: Jianjun Yang $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalStripper.h"
21 #include "Attributes/Attributes.h"
23 #include "Physics/Physics.h"
24 
25 
26 // Class OpalStripper
27 // ------------------------------------------------------------------------
28 
30  OpalElement(SIZE, "STRIPPER",
31  "The \"STRIPPER\" element defines a Stripper.") {
32 
34  ("XSTART", " Start of x coordinate [mm]");
36  ("XEND", " End of x coordinate, [mm]");
38  ("YSTART", "Start of y coordinate, [mm]");
40  ("YEND", "End of y coordinate, [mm]");
42  ("WIDTH", "Width of the stripper [mm], NOT used");
44  ("OPCHARGE", "Charge number of the outcome particle");
46  ("OPMASS", "Mass of the outcome particle [GeV/c^2]");
48  ("OPYIELD", "Yield (Particle number of the outcome particle) per income particle");
50  ("STOP", "Option Whether stop tracking at the stripper. Default: true", true);
52  ("OUTFN", "Output filename");
53 
54  registerRealAttribute("XSTART");
55  registerRealAttribute("XEND");
56  registerRealAttribute("YSTART");
57  registerRealAttribute("YEND");
58  registerRealAttribute("WIDTH");
59  registerRealAttribute("OPCHARGE");
60  registerRealAttribute("OPMASS");
61  registerRealAttribute("OPYIELD");
62  registerStringAttribute("OUTFN");
63 
65 
66  setElement((new StripperRep("STRIPPER"))->makeAlignWrapper());
67 }
68 
69 
70 OpalStripper::OpalStripper(const std::string &name, OpalStripper *parent):
71  OpalElement(name, parent) {
72  setElement((new StripperRep(name))->makeAlignWrapper());
73 }
74 
75 
77 {}
78 
79 
80 OpalStripper *OpalStripper::clone(const std::string &name) {
81  return new OpalStripper(name, this);
82 }
83 
84 
87 
88 }
89 
90 
93 
94  StripperRep *strp =dynamic_cast<StripperRep *>(getElement()->removeWrappers());
95  double length = Attributes::getReal(itsAttr[LENGTH]);
96  double xstart = Attributes::getReal(itsAttr[XSTART]);
97  double xend = Attributes::getReal(itsAttr[XEND]);
98  double ystart = Attributes::getReal(itsAttr[YSTART]);
99  double yend = Attributes::getReal(itsAttr[YEND]);
100  double opcharge = Attributes::getReal(itsAttr[OPCHARGE]);
101  double opmass = Attributes::getReal(itsAttr[OPMASS]);
102  double opyield = Attributes::getReal(itsAttr[OPYIELD]);
103  bool stop = Attributes::getBool(itsAttr[STOP]);
104 
105  strp->setElementLength(length);
106  strp->setDimensions(xstart, xend, ystart, yend);
107  strp->setOPCharge(opcharge);
108  strp->setOPMass(opmass);
109  strp->setOPYield(opyield);
110  strp->setStop(stop);
112 
113  // Transmit "unknown" attributes.
115 }
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
void setOPCharge(double charge)
Member variable access.
Definition: Stripper.cpp:39
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
virtual ElementBase * removeWrappers()
Return the design element.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
void setOPYield(double yield)
Definition: Stripper.cpp:47
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
void setStop(bool stopflag)
Definition: Stripper.cpp:51
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:66
void setOPMass(double mass)
Definition: Stripper.cpp:43
Base class for all beam line elements.
Definition: OpalElement.h:41
virtual OpalStripper * clone(const std::string &name)
Make clone.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual ~OpalStripper()
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:56
The Stripper element.
Definition: OpalStripper.h:28
const std::string name
Representation for Stripper.
Definition: StripperRep.h:31
virtual void update()
Update the embedded CLASSIC septum.
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
void setOutputFN(std::string fn)
Set output filename.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.