00001 // $Header: /nfs/slac/g/glast/ground/cvs/gismo/gismo/GParticle.h,v 1.3 2000/01/17 23:37:18 burnett Exp $ 00002 // 00003 // 00004 // 00005 // This is the definition of the GParticle class. 00006 // 00007 // 00008 00009 #ifndef _GPARTICLE_H_ 00010 #define _GPARTICLE_H_ 00011 00012 #include "gismo/PData.h" 00013 #include "CLHEP/Vector/LorentzVector.h" 00014 class PDT; 00015 00016 #include "geometry/Point.h" 00017 00018 00020 00022 class GParticle: public HepLorentzVector { 00023 00024 public: 00025 00027 00032 GParticle(const char* name, float mass=-1); 00034 GParticle(long id, float mass=-1); 00036 GParticle(const PData * data,float mass=-1); 00037 00039 GParticle(const GParticle&); 00041 virtual ~GParticle(); 00042 00043 00045 double px() const; 00046 double py() const; 00047 double pz() const; 00048 double e() const; 00049 Vector momentum() const; 00050 double pTot()const; 00051 00053 double tx() const; 00054 double ty() const; 00055 double tz() const; 00056 Vector direction() const; 00057 00059 double mass() const; 00060 00061 HepBoolean hasPostionInfo() const; 00062 00064 double x0() const; 00065 double y0() const; 00066 double z0() const; 00067 Point productionVertex() const; 00068 00070 double x() const; 00071 double y() const; 00072 double z() const; 00073 Point position() const; 00074 Point decayVertex() const; 00075 GParticle& setPosition(const Point&); 00076 00077 00079 float t() const; 00080 00082 void setT(float); 00083 00085 float timeOfDecay() const; 00086 00087 00089 GParticle& setMomentum(const Vector &); 00090 00091 00093 00097 GParticle& setEnergy(float); 00098 00100 float eta()const; 00101 00103 void decayOnce(); 00104 00105 00107 virtual void printOn(std::ostream&)const; 00109 void printAll(std::ostream&)const; 00110 00112 const char* name()const; 00113 float charge()const; 00114 long idCode()const; 00115 float spin()const; 00116 double lifeTime()const; 00117 00119 const GParticle* parent()const; 00120 00122 int numChildren()const; 00123 00125 GParticle* child(int n)const; 00126 virtual GParticle* addChild(const PData* childData, float mass=-1); 00127 void removeChildren(); 00128 00130 void boost(const Vector&); 00131 00133 void scatterBy(double theta, double phi); 00134 00136 static void setPDT(PDT* thePDT); 00137 static PDT* thePDT(); 00138 00140 float GenerateTimeOfDecay(); 00141 00142 protected: 00143 const PData * pData; // pointer to particle table entry 00144 GParticle* addChild(GParticle *); 00145 void setE(float); 00146 void setMass(float); 00147 void setParent(GParticle*); 00148 00149 private: 00150 const GParticle* m_parent; // pointer to parent particle 00151 GParticle* m_first_child; // first of children (0 if none) 00152 GParticle* m_next_sibling; // next sibling (0 for last) 00153 00154 00155 float _mass; // actual mass 00156 00157 Point _r; 00158 float _time; 00159 // current position and time (lab frame), or a decay 00160 00161 static PDT* _thePDT; 00162 static const unsigned MAX_TRIES; 00163 }; 00164 // -----------------GParticle inlines-------------------------- 00165 inline std::ostream& operator<<(std::ostream& out, const GParticle& p) 00166 { 00167 p.printAll(out); 00168 return out; 00169 } 00170 inline std::ostream& operator<<(std::ostream& out, const GParticle* p) 00171 { 00172 p->printAll(out); 00173 return out; 00174 } 00175 00176 inline double 00177 GParticle::px()const{return HepLorentzVector::x();} 00178 inline double 00179 GParticle::py()const{return HepLorentzVector::y();} 00180 inline double 00181 GParticle::pz()const{return HepLorentzVector::z();} 00182 inline double 00183 GParticle::e()const{return HepLorentzVector::t();} 00184 inline void 00185 GParticle::setE(float e){HepLorentzVector::setT(e);} 00186 inline Vector 00187 GParticle::momentum()const{return Vector(*this);} 00188 00189 00190 inline double 00191 GParticle::x()const{return _r.x();} 00192 inline double 00193 GParticle::y()const{return _r.y();} 00194 inline double 00195 GParticle::z()const{return _r.z();} 00196 inline float 00197 GParticle::t()const{return _time;} 00198 inline void 00199 GParticle::setT(float t){_time=t;} 00200 inline Point 00201 GParticle::decayVertex() const{return _r;} 00202 00203 inline Point 00204 GParticle::position() const{return _r;} 00205 00206 inline GParticle& 00207 GParticle::setPosition(const Point& r){_r=r; return *this;} 00208 00209 inline double 00210 GParticle::x0()const{return m_parent->_r.x();} 00211 inline double 00212 GParticle::y0()const{return m_parent->_r.y();} 00213 inline double 00214 GParticle::z0()const{return m_parent->_r.z();} 00215 inline Point 00216 GParticle::productionVertex()const{return m_parent->_r;} 00217 inline double 00218 GParticle::tx()const{return x()/vect().mag();} 00219 inline double 00220 GParticle::ty()const{return y()/vect().mag();} 00221 inline double 00222 GParticle::tz()const{return z()/vect().mag();} 00223 inline Vector 00224 GParticle::direction()const{return vect().unit();} 00225 00226 00227 inline double 00228 GParticle::mass()const{return _mass;} 00229 00230 inline const char* 00231 GParticle::name()const {return pData->name();} 00232 00233 inline float 00234 GParticle::charge()const {return pData->charge();} 00235 00236 inline long 00237 GParticle::idCode()const {return pData->idCode();} 00238 00239 inline float 00240 GParticle::spin()const {return pData->spin();} 00241 00242 inline double 00243 GParticle::lifeTime()const {return pData->lifeTime();} 00244 00245 inline void 00246 GParticle::setPDT(PDT* thePDT){_thePDT = thePDT;} 00247 00248 inline PDT* 00249 GParticle::thePDT(){return _thePDT;} 00250 00251 inline float 00252 GParticle::eta()const{return vect().mag()/_mass;} 00253 00254 inline double 00255 GParticle::pTot()const{return vect().mag();} 00256 00257 00258 #endif // _GPARTICLE_H_ 00259 00260 00261 00262
1.2.3 written by Dimitri van Heesch,
© 1997-2000