OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalDrift.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalDrift.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalDrift
10 // The class of OPAL drift spaces.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalDrift.h"
21 #include "Attributes/Attributes.h"
22 #include "BeamlineCore/DriftRep.h"
23 #include "Structure/OpalWake.h"
25 
26 // Class OpalDrift
27 // ------------------------------------------------------------------------
28 
30  OpalElement(SIZE, "DRIFT",
31  "The \"DRIFT\" element defines a drift space."),
32  owk_m(NULL),
33  parmatint_m(NULL),
34  obgeo_m(NULL) {
35  // CKR: the following 3 lines are redundant: OpalElement does this already!
36  // they prevent drift from working properly
37  //
38  // itsAttr[LENGTH] = Attributes::makeReal
39  // ("LENGTH", "Drift length");
40 
41  // registerRealAttribute("LENGTH");
43  ("GEOMETRY", "BoundaryGeometry for Drifts");
44 
46  ("NSLICES",
47  "The number of slices/ steps for this element in Map Tracking", 1);
48 
49 
50  registerStringAttribute("GEOMETRY");
51  registerRealAttribute("NSLICES");
53 
54  setElement(new DriftRep("DRIFT"));
55 }
56 
57 
58 OpalDrift::OpalDrift(const std::string &name, OpalDrift *parent):
59  OpalElement(name, parent),
60  owk_m(NULL),
61  parmatint_m(NULL),
62  obgeo_m(NULL) {
63  setElement(new DriftRep(name));
64 }
65 
66 
68  if(owk_m)
69  delete owk_m;
70  if(parmatint_m)
71  delete parmatint_m;
72  if(obgeo_m)
73  delete obgeo_m;
74 }
75 
76 
77 OpalDrift *OpalDrift::clone(const std::string &name) {
78  return new OpalDrift(name, this);
79 }
80 
81 
82 bool OpalDrift::isDrift() const {
83  return true;
84 }
85 
86 
89 
90  DriftRep *drf = static_cast<DriftRep *>(getElement());
93  if(itsAttr[WAKEF] && owk_m == NULL) {
94  owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
95  owk_m->initWakefunction(*drf);
96  drf->setWake(owk_m->wf_m);
97  }
98 
103  }
104  if(itsAttr[GEOMETRY] && obgeo_m == NULL) {
106  if(obgeo_m) {
108  }
109  }
110 
111  // Transmit "unknown" attributes.
113 }
virtual bool isDrift() const
Test for drift.
Definition: OpalDrift.cpp:82
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
WakeFunction * wf_m
Definition: OpalWake.h:65
virtual OpalDrift * clone(const std::string &name)
Make clone.
Definition: OpalDrift.cpp:77
virtual ~OpalDrift()
Definition: OpalDrift.cpp:67
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
ParticleMatterInteraction * parmatint_m
Definition: OpalDrift.h:66
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
void initWakefunction(ElementBase &element)
Definition: OpalWake.cpp:157
ParticleMatterInteractionHandler * handler_m
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
virtual void setBoundaryGeometry(BoundaryGeometry *geo)
void initParticleMatterInteractionHandler(ElementBase &element)
virtual void update()
Update the embedded CLASSIC drift.
Definition: OpalDrift.cpp:87
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:136
OpalDrift()
Exemplar constructor.
Definition: OpalDrift.cpp:29
static BoundaryGeometry * find(const std::string &name)
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)
BoundaryGeometry * obgeo_m
Definition: OpalDrift.h:67
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
const std::string name
void setNSlices(const std::size_t &nSlices)
Definition: Drift.cpp:63
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
OpalWake * owk_m
Definition: OpalDrift.h:65
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
Representation for a drift space.
Definition: DriftRep.h:32
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