OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalCCollimator.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalCCollimator.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalCCollimator
10 // The class of OPAL Cyclotron collimators.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann, Jianjun Yang $
16 //
17 // ------------------------------------------------------------------------
18 
20 #include "Attributes/Attributes.h"
23 #include "Physics/Physics.h"
24 
25 using Physics::pi;
26 
27 // Class OpalCCollimator
28 // ------------------------------------------------------------------------
29 
31  OpalElement(SIZE, "CCOLLIMATOR",
32  "The \"CCOLLIMATOR\" element defines a rectangular-shape cyclotron collimator"),
33  parmatint_m(NULL) {
35  ("XSTART", " Start of x coordinate [mm]");
37  ("XEND", " End of x coordinate, [mm]");
39  ("YSTART", "Start of y coordinate, [mm]");
41  ("YEND", "End of y coordinate, [mm]");
43  ("ZSTART", "Start of vertical coordinate, [mm], default value: -100",-100.0);
45  ("ZEND", "End of vertical coordinate, [mm], default value: 100", 100.0);
47  ("WIDTH", "Width of the collimator [mm]");
49  ("OUTFN", "Output filename");
50 
51  registerRealAttribute("XSTART");
52  registerRealAttribute("XEND");
53  registerRealAttribute("YSTART");
54  registerRealAttribute("YEND");
55  registerRealAttribute("ZSTART");
56  registerRealAttribute("ZEND");
57  registerRealAttribute("WIDTH");
58  registerStringAttribute("OUTFN");
59 
61 
62  setElement((new CCollimatorRep("CCOLLIMATOR"))->makeAlignWrapper());
63 }
64 
65 
67  OpalElement(name, parent),
68  parmatint_m(NULL) {
69  setElement((new CCollimatorRep(name))->makeAlignWrapper());
70 }
71 
72 
74  if(parmatint_m)
75  delete parmatint_m;
76 }
77 
78 
80  return new OpalCCollimator(name, this);
81 }
82 
83 
86 }
87 
88 
91 
92  CCollimatorRep *coll =
93  dynamic_cast<CCollimatorRep *>(getElement()->removeWrappers());
94  double length = Attributes::getReal(itsAttr[LENGTH]);
95  double xstart = Attributes::getReal(itsAttr[XSTART]);
96  double xend = Attributes::getReal(itsAttr[XEND]);
97  double ystart = Attributes::getReal(itsAttr[YSTART]);
98  double yend = Attributes::getReal(itsAttr[YEND]);
99  double zstart = Attributes::getReal(itsAttr[ZSTART]);
100  double zend = Attributes::getReal(itsAttr[ZEND]);
101  double width = Attributes::getReal(itsAttr[WIDTH]);
102  coll->setElementLength(length);
103  coll->setDimensions(xstart, xend, ystart, yend, zstart, zend, width);
105 
110  }
111 
112  // Transmit "unknown" attributes.
114 }
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
Representation for a collimator.
virtual ElementBase * removeWrappers()
Return the design element.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual ~OpalCCollimator()
The CCOLLIMATOR element.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
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)
virtual void update()
Update the embedded CLASSIC collimator.
Base class for all beam line elements.
Definition: OpalElement.h:41
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
OpalCCollimator()
Exemplar constructor.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
const std::string name
void setDimensions(double xstart, double xend, double ystart, double yend, double zstart, double zend, double width)
Set dimensions and consistency checks.
virtual OpalCCollimator * clone(const std::string &name)
Make clone.
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
void setOutputFN(std::string fn)
Set output filename.
ParticleMatterInteraction * parmatint_m
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