1 //--------------------------------------------------------------------------
4 // This software is part of the EvtGen package developed jointly
5 // for the BaBar and CLEO collaborations. If you use all or part
6 // of it, please give an appropriate acknowledgement.
8 // Copyright Information: See EvtGen/COPYRIGHT
9 // Copyright (C) 1998 Caltech, UCSB
11 // Module: EvtGen/EvtParticle.hh
13 // Description:Class to describe all particles
15 // Modification history:
17 // DJL/RYD Sept. 25, 1996 Module created
19 //------------------------------------------------------------------------
21 #ifndef EVTPARTICLE_HH
22 #define EVTPARTICLE_HH
24 //#include <iostream.h>
26 #include "EvtGenBase/EvtVector4R.hh"
27 #include "EvtGenBase/EvtSpinDensity.hh"
28 #include "EvtGenBase/EvtId.hh"
29 #include "EvtGenBase/EvtSpinType.hh"
38 class EvtRaritaSchwinger;
40 const int MAX_DAUG =100;
41 const int MAX_LEVEL=10;
42 const int MAX_TRIES=10000;
49 * Default constructor.
56 virtual ~EvtParticle();
59 * Returns polarization vector in the parents restframe.
61 virtual EvtVector4C epsParent(int i) const;
64 * Returns polarization vector in the particles own restframe.
66 virtual EvtVector4C eps(int i) const;
70 * Returns polarization vector in the parents restframe for a photon.
72 virtual EvtVector4C epsParentPhoton(int i);
75 * Returns polarization vector in the particles own restframe for a photon.
77 virtual EvtVector4C epsPhoton(int i);
81 * Returns Dirac spinor in the parents restframe for a Dirac particle.
83 virtual EvtDiracSpinor spParent(int) const;
86 * Returns Dirac spinor in the particles own restframe for a Dirac particle.
88 virtual EvtDiracSpinor sp(int) const;
93 * Returns Dirac spinor in the parents restframe for a Neutrino particle.
95 virtual EvtDiracSpinor spParentNeutrino() const;
98 * Returns Dirac spinor in the particles own restframe for a
101 virtual EvtDiracSpinor spNeutrino() const;
105 * Returns tensor in the parents restframe for a spin 2 particle.
107 virtual EvtTensor4C epsTensorParent(int i) const;
110 * Returns tensor in the particles own restframe for a spin 2 particle.
112 virtual EvtTensor4C epsTensor(int i) const;
115 * Returns Rarita-Schwinger spinor in the parents restframe for a
116 * Rarita-Schwinger particle.
118 virtual EvtRaritaSchwinger spRSParent(int) const;
121 * Returns Rarita-Schwinger spinor in the particles own restframe for a
122 * Rarita-Schwinger particle.
124 virtual EvtRaritaSchwinger spRS(int) const;
129 * Initialiaze particle with id and 4momentum.
131 virtual void init(EvtId part_n,const EvtVector4R& p4)=0;
134 * Add another daughter to the particle
136 void addDaug(EvtParticle *node);
144 * Delete a decay chain
147 void deleteDaughters(bool keepChannel=false);
150 * Should only be used internally.
152 void setChannel( int i );
155 * Creates the daughters in the list of ids and
156 * adds them to the parent. Note that momentum
157 * is left uninitialized, this is _only_ creation.
159 void makeDaughters(unsigned int ndaug,EvtId *id);
162 * Creates the daughters in the list of ids and
163 * adds them to the parent. Note that momentum
164 * is left uninitialized, this is _only_ creation.
166 void makeDaughters(unsigned int ndaug, std::vector<EvtId> idVector);
169 * Similar to the routine above except that here
170 * momentum is generated according to phase space
171 * daughters are filled with this momentum.
173 double initializePhaseSpace(unsigned int numdaughter,EvtId *daughters,
174 bool forceResetMasses=false,
175 double poleSize=-1., int whichTwo1=0,
179 * Get pointer the the i:th daugther.
181 EvtParticle *getDaug(int i);
184 * Iterates over the particles in a decay chain.
186 EvtParticle *nextIter(EvtParticle *rootOfTree=0);
191 void makeStdHep(EvtStdHep& stdhep,
192 EvtSecondary& secondary,EvtId *stable_parent_ihep);
193 void makeStdHep(EvtStdHep& stdhep);
196 * Gets 4vector in the labframe, i.e., the frame in which the root
197 * particles momentum is measured.
199 EvtVector4R getP4Lab() const;
203 * Gets 4vector in the labframe for the 4-momentum befor FSR was
204 * generated in the parents decay. The lab frame is where the root
205 * particles momentum is measured.
207 EvtVector4R getP4LabBeforeFSR();
210 * Gets 4vector in the particles restframe, i.e. this functiont will
213 EvtVector4R getP4Restframe() const;
216 * Returns the 4position of the particle in the lab frame.
218 EvtVector4R get4Pos() const;
221 * Returns pointer to parent particle.
223 EvtParticle *getParent() const;
226 * Makes partptr the idaug:th daugther.
228 void insertDaugPtr(int idaug,EvtParticle* partptr){ _daug[idaug]=partptr;
229 partptr->_parent=this; }
231 * Returns mass of particle.
236 * Used internally to decide if first time particle is decayed.
238 int firstornot() const;
239 void setFirstOrNot();
240 void resetFirstOrNot();
243 * Returns Id of particle.
248 * Returns the PDG id of the particle
251 int getPDGId() const;
254 * Returns particle type.
257 EvtSpinType::spintype getSpinType() const;
260 * Returns number of spin states of the particle.
262 int getSpinStates() const;
265 * Returns 4momentum in parents restframe.
267 const EvtVector4R& getP4() const;
270 * Sets the 4momentum in the parents restframe.
272 void setP4(const EvtVector4R& p4){
277 void setP4WithFSR(const EvtVector4R& p4){
281 void setFSRP4toZero(){
282 _pBeforeFSR.set(0.0,0.0,0.0,0.0);
286 * Retunrs the decay channel.
288 int getChannel() const;
291 * Returns number of daugthers.
293 size_t getNDaug() const;
294 void resetNDaug() {_ndaug=0; return;}
297 * Prints out the particle "tree" of a given particle. The
298 * tree consists of all daughters (and their daughters, etc)
299 * and their properties.
301 void printTree() const;
303 void printTreeRec(unsigned int level) const;
305 std::string treeStr() const;
306 std::string treeStrRec(unsigned int level) const;
309 * Prints information for the particle.
311 void printParticle() const;
314 * Set lifetime of the particle in parents restframe.
316 void setLifetime(double tau);
319 * Generate lifetime according to pure exponential.
324 * Returns the lifetime.
326 double getLifetime();
329 * Set diagonal spindensity matrix.
331 void setDiagonalSpinDensity();
334 * Set spindensity matrix for e+e- -> V
336 void setVectorSpinDensity();
339 * Set forward spin density matrix.
341 void setSpinDensityForward(const EvtSpinDensity& rho){_rhoForward=rho;}
344 * Set forward spin density matrix according to the density matrix
345 * rho in the helicity amplitude basis.
347 void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho);
348 void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho,
354 * Returns a rotation matrix need to rotate the basis state
355 * to the helicity basis. The EvtSpinDensity matrix is just use
356 * as a matrix here. This function is to be implemented in each
359 virtual EvtSpinDensity rotateToHelicityBasis() const=0;
360 virtual EvtSpinDensity rotateToHelicityBasis(double alpha,
362 double gamma) const=0;
365 * Get forward spin density matrix.
367 EvtSpinDensity getSpinDensityForward(){return _rhoForward;}
370 * Set backward spin density matrix.
372 void setSpinDensityBackward(const EvtSpinDensity& rho){_rhoBackward=rho;}
375 * Get backward spin density matrix.
377 EvtSpinDensity getSpinDensityBackward(){return _rhoBackward;}
379 //Hacks will be removed when better solutions are thought of!
380 //This is used to suppress use of random numbers when doing initialization
382 void noLifeTime() { _genlifetime=0; }
384 //lange - April 29, 2002
385 void setId(EvtId id) { _id=id;}
386 void initDecay(bool useMinMass=false);
387 bool generateMassTree();
389 double compMassProb();
391 //setMass will blow away any existing 4vector
392 void setMass(double m) { _p=EvtVector4R(m,0.0,0.0,0.0);}
394 //void setMixed() {_mix=true;}
395 //void setUnMixed() {_mix=false;}
396 //bool getMixed() {return _mix;}
398 //void takeCConj() {report(INFO,"EvtGen") << "should take conj\n";}
400 //this means that the particle has gone through initDecay
401 // and thus has a mass
402 bool isInitialized() {return _isInit;}
403 bool hasValidP4() {return _validP4;}
404 bool isDecayed() {return _isDecayed;}
407 // decay prob - only relevent if already decayed
408 // and is a scalar particle
409 // returned is a double* that should be prob/probMax
410 double* decayProb() {return _decayProb;}
411 void setDecayProb( double p);
413 // Return the name of the particle (from the EvtId number)
414 std::string getName();
418 void setp( double e, double px, double py, double pz) {
423 void setp( const EvtVector4R& p4 ) {
428 void setpart_num(EvtId particle_number ) {
429 assert(_channel==-10||
430 _id.getId()==particle_number.getId()||
432 _id = particle_number;
438 EvtParticle* _daug[MAX_DAUG];
440 EvtParticle* _parent;
445 EvtVector4R _pBeforeFSR;
452 EvtSpinDensity _rhoForward;
453 EvtSpinDensity _rhoBackward;
455 void makeStdHepRec(int firstparent,int lastparent,EvtStdHep& stdhep,
456 EvtSecondary& secondary,EvtId *stable_parent_ihep);
457 void makeStdHepRec(int firstparent,int lastparent,EvtStdHep& stdhep);
460 //This is a hack until things gets straightened out. (Ryd)
463 //should never be used, therefor is private.
464 //these does _not_ have an implementation
465 EvtParticle& operator=(const EvtParticle& p);
466 EvtParticle(const EvtParticle& p);