CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
PhaseSpace.cc
Go to the documentation of this file.
1
#include "
CLHEP/GenericFunctions/PhaseSpace.hh
"
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
//------------------------------------------------//
19
class
PhaseSpace::Component::Clockwork
{
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
53
Genfun::Variable
PhaseSpace::Component::operator[]
(
unsigned
int
i)
const
{
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
62
PhaseSpace::~PhaseSpace
()
63
{
64
}
65
66
const
PhaseSpace::Component
&
PhaseSpace::coordinates
()
const
{
67
return
_coordinates;
68
}
69
70
const
PhaseSpace::Component
&
PhaseSpace::momenta
()
const
{
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
}
Generated on Mon May 6 2013 04:04:11 for CLHEP by
1.8.1.2