OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalWire.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalWire.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalWire
10 // The class of OPAL wire collimators.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalWire.h"
20 #include "Attributes/Attributes.h"
23 
24 // Class OpalWire
25 // ------------------------------------------------------------------------
26 
28  OpalElement(SIZE, "WIRE",
29  "The \"WIRE\" element defines a wire."),
30  parmatint_m(NULL) {
32  ("XSIZE", "Horizontal half-aperture in m");
34  ("YSIZE", "Vertical half-aperture in m");
36  ("XPOS", "Horizontal position in m");
38  ("YPOS", "Vertical position in m");
40  ("OUTFN", "Wire output filename");
41 
42  registerStringAttribute("OUTFN");
43  registerRealAttribute("XSIZE");
44  registerRealAttribute("YSIZE");
45  registerRealAttribute("XPOS");
46  registerRealAttribute("YPOS");
47 
49 
50  setElement((new CCollimatorRep("WIRE"))->makeAlignWrapper());
51 }
52 
53 
54 OpalWire::OpalWire(const std::string &name, OpalWire *parent):
55  OpalElement(name, parent),
56  parmatint_m(NULL) {
57  setElement((new CCollimatorRep(name))->makeAlignWrapper());
58 }
59 
60 
62  if(parmatint_m)
63  delete parmatint_m;
64 }
65 
66 
67 OpalWire *OpalWire::clone(const std::string &name) {
68  return new OpalWire(name, this);
69 }
70 
71 
74 
75  const CCollimatorRep *coll =
76  dynamic_cast<const CCollimatorRep *>(base.removeWrappers());
77  attributeRegistry["XSIZE"]->setReal(coll->getXsize());
78  attributeRegistry["YSIZE"]->setReal(coll->getYsize());
79 }
80 
81 
84 
85  CCollimatorRep *coll =
86  dynamic_cast<CCollimatorRep *>(getElement()->removeWrappers());
87  double length = Attributes::getReal(itsAttr[LENGTH]);
88  coll->setElementLength(length);
89  coll->setXsize(Attributes::getReal(itsAttr[XSIZE]));
90  coll->setYsize(Attributes::getReal(itsAttr[YSIZE]));
91  coll->setXpos(Attributes::getReal(itsAttr[XPOS]));
92  coll->setYpos(Attributes::getReal(itsAttr[YPOS]));
94  coll->setWire();
95 
100  }
101 
102  // Transmit "unknown" attributes.
104 }
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
ParticleMatterInteraction * parmatint_m
Definition: OpalWire.h:64
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
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.
Definition: OpalWire.cpp:72
virtual OpalWire * clone(const std::string &name)
Make clone.
Definition: OpalWire.cpp:67
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
void initParticleMatterInteractionHandler(ElementBase &element)
virtual ~OpalWire()
Definition: OpalWire.cpp:61
The ECOLLIMATOR element.
Definition: OpalWire.h:28
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.
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
virtual void update()
Update the embedded CLASSIC collimator.
Definition: OpalWire.cpp:82
const std::string name
OpalWire()
Exemplar constructor.
Definition: OpalWire.cpp:27
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