CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 #include "CLHEP/GenericFunctions/PhaseSpace.hh" 00002 #include <vector> 00003 00004 // Three classes are defined here: 00005 00006 // 1) Classical::PhaseSpace::Component::Clockwork 00007 // 2) Classical::PhaseSpace::Component 00008 // 2) Classical::PhaseSpace 00009 00010 00011 namespace Classical { 00012 00013 //------------------------------------------------// 00014 // // 00015 // 1. Classical::PhaseSpace::Component::Clockwork // 00016 // This class just holds variables: // 00017 // // 00018 //------------------------------------------------// 00019 class PhaseSpace::Component::Clockwork { 00020 00021 public: 00022 00023 // Constructor: 00024 Clockwork(){}; 00025 00026 // Destructor 00027 ~Clockwork () { for (size_t i=0;i<functions.size();i++) delete functions [i];} 00028 00029 // 00030 std::vector<const Genfun::Variable *> functions; 00031 00032 }; 00033 00034 //------------------------------------------------// 00035 // // 00036 // 2. Classical::PhaseSpace::Component // 00037 // This class gives access to the variables that // 00038 // make up the coordinates and momenta. // 00039 // // 00040 //------------------------------------------------// 00041 00042 PhaseSpace::Component::Component(unsigned int NDIM, bool isMomenta) : c(new Clockwork()) { 00043 for (unsigned int i=0;i<NDIM;i++) { 00044 int offset= isMomenta ? NDIM:0; 00045 c->functions.push_back(new Genfun::Variable(i+offset, 2*NDIM)); 00046 } 00047 } 00048 00049 PhaseSpace::Component::~Component() { 00050 delete c; 00051 } 00052 00053 Genfun::Variable PhaseSpace::Component::operator[] (unsigned int i) const { 00054 return *(c->functions[i]); 00055 } 00056 00057 PhaseSpace::PhaseSpace(unsigned int NDIM): 00058 _coordinates(NDIM,false),_momenta(NDIM,true),_q0(NDIM),_p0(NDIM),DIM(NDIM) 00059 { 00060 } 00061 00062 PhaseSpace::~PhaseSpace() 00063 { 00064 } 00065 00066 const PhaseSpace::Component & PhaseSpace::coordinates() const { 00067 return _coordinates; 00068 } 00069 00070 const PhaseSpace::Component & PhaseSpace::momenta() const { 00071 return _momenta; 00072 } 00073 00074 00075 void PhaseSpace::start (const Genfun::Variable & v, double value){ 00076 unsigned int index =v.index(); 00077 if (index<DIM) { 00078 _q0[index] = value; 00079 } 00080 else 00081 { 00082 _p0[index-DIM] = value; 00083 } 00084 } 00085 00086 00087 double PhaseSpace::startValue(const Genfun::Variable & v) const { 00088 unsigned int index =v.index(); 00089 if (index<DIM) { 00090 return _q0[index]; 00091 } 00092 else 00093 { 00094 return _p0[index-DIM]; 00095 } 00096 } 00097 00098 unsigned int PhaseSpace::dim() const { 00099 return DIM; 00100 } 00101 }