OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
TrackStart.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: TrackStart.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: TrackStart
10 // The class for the OPAL START command.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:47 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Track/TrackStart.h"
20 #include "Attributes/Attributes.h"
21 #include "Track/Track.h"
23 
24 
25 // Class TrackStart
26 // ------------------------------------------------------------------------
27 
28 // The attributes of class TrackStart.
29 namespace {
30  enum {
31  X, // The initial horizontal position in m.
32  Y, // The initial vertical position in m.
33  T, // The initial longitudinal position in m.
34  PX, // The initial horizontal momentum in rad.
35  PY, // The initial vertical momentum in rad.
36  PT, // The initial longitudinal momentum in rad.
37  SIZE
38  };
39 }
40 
41 
43  Action(SIZE, "START",
44  "The \"START\" sub-command defines one particle for tracking "
45  "through the given lattice.") {
47  ("X", "Initial horizontal position in m");
49  ("PX", "Initial horizontal momentum in 1");
51  ("Y", "Initial horizontal position in m");
53  ("PY", "Initial horizontal momentum in 1");
55  ("T", "Initial horizontal position in m");
57  ("PT", "Initial horizontal momentum in 1");
58 
60 }
61 
62 
63 TrackStart::TrackStart(const std::string &name, TrackStart *parent):
64  Action(name, parent)
65 {}
66 
67 
69 {}
70 
71 
72 TrackStart *TrackStart::clone(const std::string &name) {
73  return new TrackStart(name, this);
74 }
75 
76 
78  double x = Attributes::getReal(itsAttr[X]);
79  double y = Attributes::getReal(itsAttr[Y]);
80  double t = Attributes::getReal(itsAttr[T]);
81  double px = Attributes::getReal(itsAttr[PX]);
82  double py = Attributes::getReal(itsAttr[PY]);
83  double pt = Attributes::getReal(itsAttr[PT]);
84  Track::block->bunch->push_back(OpalParticle(x, px, y, py, t, pt));
85 }
virtual TrackStart * clone(const std::string &name)
Make clone.
Definition: TrackStart.cpp:72
virtual ~TrackStart()
Definition: TrackStart.cpp:68
Definition: rbendmap.h:8
The START command.
Definition: TrackStart.h:28
Definition: rbendmap.h:8
The base class for all OPAL actions.
Definition: Action.h:30
Definition: rbendmap.h:8
Definition: rbendmap.h:8
void push_back(OpalParticle p)
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
static Track * block
The block of track data.
Definition: Track.h:63
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
Definition: Track.h:49
TrackStart()
Exemplar constructor.
Definition: TrackStart.cpp:42
const std::string name
virtual void execute()
Execute the command.
Definition: TrackStart.cpp:77
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
Definition: rbendmap.h:8
OpalParticle position.
Definition: OpalParticle.h:38
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
Definition: rbendmap.h:8