OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalBeamStripping.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalBeamStripping.cpp,v $
3 // ------------------------------------------------------------------------
4 // Copyright: see Copyright.readme
5 // ------------------------------------------------------------------------
6 //
7 // Class: OpalBeamStripping
8 // The class of OPAL Cyclotron beam stripping.
9 //
10 // ------------------------------------------------------------------------
11 // $Date: 2018/11 $
12 // $Author: PedroCalvo$
13 // ------------------------------------------------------------------------
14 
15 #include "Attributes/Attributes.h"
18 #include "Physics/Physics.h"
20 
21 using Physics::pi;
22 
23 // Class OpalBeamStripping
24 // ------------------------------------------------------------------------
25 
27  OpalElement(SIZE, "BEAMSTRIPPING",
28  "The \"BEAMSTRIPPING\" element defines a beam stripping interaction"),
29  parmatint_m(NULL) {
31  ("PRESSURE", " Pressure in the accelerator, [mbar]");
33  ("TEMPERATURE", " Temperature of the accelerator, [K]");
35  ("PMAPFN", "Filename for the Pressure fieldmap");
37  ("PSCALE", "Scale factor for the P-field", 1.0);
39  ("GAS", "The composition of residual gas");
41  ("STOP", "Option Whether stop tracking after beam stripping. Default: true", true);
42 
43  registerRealAttribute("PRESSURE");
44  registerRealAttribute("TEMPERATURE");
45  registerStringAttribute("PMAPFN");
46  registerRealAttribute("PSCALE");
48 
50 
51  setElement((new BeamStrippingRep("BEAMSTRIPPING"))->makeAlignWrapper());
52 }
53 
54 
56  OpalElement(name, parent),
57  parmatint_m(NULL) {
58  setElement((new BeamStrippingRep(name))->makeAlignWrapper());
59 }
60 
61 
63  delete parmatint_m;
64 }
65 
66 
68  return new OpalBeamStripping(name, this);
69 }
70 
71 
74 }
75 
76 
79 
80  BeamStrippingRep *bstp =
81  dynamic_cast<BeamStrippingRep *>(getElement()->removeWrappers());
82 
83  double pressure = Attributes::getReal(itsAttr[PRESSURE]);
84  double temperature = Attributes::getReal(itsAttr[TEMPERATURE]);
85  std::string pmap = Attributes::getString(itsAttr[PMAPFN]);
86  double pscale = Attributes::getReal(itsAttr[PSCALE]);
87  bool stop = Attributes::getBool(itsAttr[STOP]);
88  std::string gas = Attributes::getString(itsAttr[GAS]);
89 
90  bstp->setPressure(pressure);
91  bstp->setTemperature(temperature);
92  bstp->setPressureMapFN(pmap);
93  bstp->setPScale(pscale);
94  bstp->setStop(stop);
95  bstp->setResidualGas(gas);
96 
101  }
102 
103  // Transmit "unknown" attributes.
105 }
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
Interface for basic beam line object.
Definition: ElementBase.h:128
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.
ParticleMatterInteraction * parmatint_m
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Representation for a beam stripping.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:66
virtual void update()
Update the embedded CLASSIC beam stripping.
ParticleMatterInteractionHandler * handler_m
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
constexpr double pi
The value of .
Definition: Physics.h:31
void initParticleMatterInteractionHandler(ElementBase &element)
void setPScale(double ps)
void setStop(bool stopflag)
Base class for all beam line elements.
Definition: OpalElement.h:41
void setTemperature(double temperature)
void setPressureMapFN(std::string pmapfn)
OpalBeamStripping()
Exemplar constructor.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
void setPressure(double pressure)
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual OpalBeamStripping * clone(const std::string &name)
Make clone.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
The BEAMSTRIPPING element.
void setResidualGas(std::string gas)
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:56
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
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