CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

PhaseSpace.cc
Go to the documentation of this file.
2 #include <vector>
3 
4 // Three classes are defined here:
5 
6 // 1) Classical::PhaseSpace::Component::Clockwork
7 // 2) Classical::PhaseSpace::Component
8 // 2) Classical::PhaseSpace
9 
10 
11 namespace Classical {
12 
13  //------------------------------------------------//
14  // //
15  // 1. Classical::PhaseSpace::Component::Clockwork //
16  // This class just holds variables: //
17  // //
18  //------------------------------------------------//
20 
21  public:
22 
23  // Constructor:
24  Clockwork(){};
25 
26  // Destructor
27  ~Clockwork () { for (size_t i=0;i<functions.size();i++) delete functions [i];}
28 
29  //
30  std::vector<const Genfun::Variable *> functions;
31 
32  };
33 
34  //------------------------------------------------//
35  // //
36  // 2. Classical::PhaseSpace::Component //
37  // This class gives access to the variables that //
38  // make up the coordinates and momenta. //
39  // //
40  //------------------------------------------------//
41 
42  PhaseSpace::Component::Component(unsigned int NDIM, bool isMomenta) : c(new Clockwork()) {
43  for (unsigned int i=0;i<NDIM;i++) {
44  int offset= isMomenta ? NDIM:0;
45  c->functions.push_back(new Genfun::Variable(i+offset, 2*NDIM));
46  }
47  }
48 
49  PhaseSpace::Component::~Component() {
50  delete c;
51  }
52 
54  return *(c->functions[i]);
55  }
56 
57  PhaseSpace::PhaseSpace(unsigned int NDIM):
58  _coordinates(NDIM,false),_momenta(NDIM,true),_q0(NDIM),_p0(NDIM),DIM(NDIM)
59  {
60  }
61 
63  {
64  }
65 
67  return _coordinates;
68  }
69 
71  return _momenta;
72  }
73 
74 
75  void PhaseSpace::start (const Genfun::Variable & v, double value){
76  unsigned int index =v.index();
77  if (index<DIM) {
78  _q0[index] = value;
79  }
80  else
81  {
82  _p0[index-DIM] = value;
83  }
84  }
85 
86 
87  double PhaseSpace::startValue(const Genfun::Variable & v) const {
88  unsigned int index =v.index();
89  if (index<DIM) {
90  return _q0[index];
91  }
92  else
93  {
94  return _p0[index-DIM];
95  }
96  }
97 
98  unsigned int PhaseSpace::dim() const {
99  return DIM;
100  }
101 }
unsigned int dim() const
Definition: PhaseSpace.cc:98
Genfun::Variable operator[](unsigned int i) const
Definition: PhaseSpace.cc:53
std::vector< const Genfun::Variable * > functions
Definition: PhaseSpace.cc:30
double startValue(const Genfun::Variable &component) const
Definition: PhaseSpace.cc:87
PhaseSpace(unsigned int NDIM)
Definition: PhaseSpace.cc:57
unsigned int index() const
Definition: Variable.cc:34
const Component & momenta() const
Definition: PhaseSpace.cc:70
void start(const Genfun::Variable &variable, double value)
Definition: PhaseSpace.cc:75
const Component & coordinates() const
Definition: PhaseSpace.cc:66