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"
37 class EvtRaritaSchwinger;
39 const int MAX_DAUG =100;
40 const int MAX_LEVEL=10;
41 const int MAX_TRIES=10000;
48 * Default constructor.
55 virtual ~EvtParticle();
58 * Returns polarization vector in the parents restframe.
60 virtual EvtVector4C epsParent(int i) const;
63 * Returns polarization vector in the particles own restframe.
65 virtual EvtVector4C eps(int i) const;
69 * Returns polarization vector in the parents restframe for a photon.
71 virtual EvtVector4C epsParentPhoton(int i);
74 * Returns polarization vector in the particles own restframe for a photon.
76 virtual EvtVector4C epsPhoton(int i);
80 * Returns Dirac spinor in the parents restframe for a Dirac particle.
82 virtual EvtDiracSpinor spParent(int) const;
85 * Returns Dirac spinor in the particles own restframe for a Dirac particle.
87 virtual EvtDiracSpinor sp(int) const;
92 * Returns Dirac spinor in the parents restframe for a Neutrino particle.
94 virtual EvtDiracSpinor spParentNeutrino() const;
97 * Returns Dirac spinor in the particles own restframe for a
100 virtual EvtDiracSpinor spNeutrino() const;
104 * Returns tensor in the parents restframe for a spin 2 particle.
106 virtual EvtTensor4C epsTensorParent(int i) const;
109 * Returns tensor in the particles own restframe for a spin 2 particle.
111 virtual EvtTensor4C epsTensor(int i) const;
114 * Returns Rarita-Schwinger spinor in the parents restframe for a
115 * Rarita-Schwinger particle.
117 virtual EvtRaritaSchwinger spRSParent(int) const;
120 * Returns Rarita-Schwinger spinor in the particles own restframe for a
121 * Rarita-Schwinger particle.
123 virtual EvtRaritaSchwinger spRS(int) const;
128 * Initialiaze particle with id and 4momentum.
130 virtual void init(EvtId part_n,const EvtVector4R& p4)=0;
133 * Add another daughter to the particle
135 void addDaug(EvtParticle *node);
143 * Delete a decay chain
146 void deleteDaughters(bool keepChannel=false);
149 * Should only be used internally.
151 void setChannel( int i );
154 * Creates the daughters in the list of ids and
155 * adds them to the parent. Note that momentum
156 * is left uninitialized, this is _only_ creation.
158 void makeDaughters(unsigned int ndaug,EvtId *id);
161 * Similar to the routine above except that here
162 * momentum is generated according to phase space
163 * daughters are filled with this momentum.
165 double initializePhaseSpace(unsigned int numdaughter,EvtId *daughters,
166 bool forceResetMasses=false,
167 double poleSize=-1., int whichTwo1=0,
171 * Get pointer the the i:th daugther.
173 EvtParticle *getDaug(int i);
176 * Iterates over the particles in a decay chain.
178 EvtParticle *nextIter(EvtParticle *rootOfTree=0);
183 void makeStdHep(EvtStdHep& stdhep,
184 EvtSecondary& secondary,EvtId *stable_parent_ihep);
185 void makeStdHep(EvtStdHep& stdhep);
188 * Gets 4vector in the labframe, i.e., the frame in which the root
189 * particles momentum is measured.
191 EvtVector4R getP4Lab() const;
195 * Gets 4vector in the labframe for the 4-momentum befor FSR was
196 * generated in the parents decay. The lab frame is where the root
197 * particles momentum is measured.
199 EvtVector4R getP4LabBeforeFSR();
202 * Gets 4vector in the particles restframe, i.e. this functiont will
205 EvtVector4R getP4Restframe() const;
208 * Returns the 4position of the particle in the lab frame.
210 EvtVector4R get4Pos() const;
213 * Returns pointer to parent particle.
215 EvtParticle *getParent() const;
218 * Makes partptr the idaug:th daugther.
220 void insertDaugPtr(int idaug,EvtParticle* partptr){ _daug[idaug]=partptr;
221 partptr->_parent=this; }
223 * Returns mass of particle.
228 * Used internally to decide if first time particle is decayed.
230 int firstornot() const;
231 void setFirstOrNot();
232 void resetFirstOrNot();
235 * Returns Id of particle.
240 * Returns particle type.
243 EvtSpinType::spintype getSpinType() const;
246 * Returns number of spin states of the particle.
248 int getSpinStates() const;
251 * Returns 4momentum in parents restframe.
253 const EvtVector4R& getP4() const;
256 * Sets the 4momentum in the parents restframe.
258 void setP4(const EvtVector4R& p4){
263 void setP4WithFSR(const EvtVector4R& p4){
267 void setFSRP4toZero(){
268 _pBeforeFSR.set(0.0,0.0,0.0,0.0);
272 * Retunrs the decay channel.
274 int getChannel() const;
277 * Returns number of daugthers.
279 size_t getNDaug() const;
280 void resetNDaug() {_ndaug=0; return;}
283 * Prints out the particle "tree" of a given particle. The
284 * tree consists of all daughters (and their daughters, etc)
285 * and their properties.
287 void printTree() const;
289 void printTreeRec(unsigned int level) const;
291 std::string treeStr() const;
292 std::string treeStrRec(unsigned int level) const;
295 * Prints information for the particle.
297 void printParticle() const;
300 * Set lifetime of the particle in parents restframe.
302 void setLifetime(double tau);
305 * Generate lifetime according to pure exponential.
310 * Returns the lifetime.
312 double getLifetime();
315 * Set diagonal spindensity matrix.
317 void setDiagonalSpinDensity();
320 * Set spindensity matrix for e+e- -> V
322 void setVectorSpinDensity();
325 * Set forward spin density matrix.
327 void setSpinDensityForward(const EvtSpinDensity& rho){_rhoForward=rho;}
330 * Set forward spin density matrix according to the density matrix
331 * rho in the helicity amplitude basis.
333 void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho);
334 void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho,
340 * Returns a rotation matrix need to rotate the basis state
341 * to the helicity basis. The EvtSpinDensity matrix is just use
342 * as a matrix here. This function is to be implemented in each
345 virtual EvtSpinDensity rotateToHelicityBasis() const=0;
346 virtual EvtSpinDensity rotateToHelicityBasis(double alpha,
348 double gamma) const=0;
351 * Get forward spin density matrix.
353 EvtSpinDensity getSpinDensityForward(){return _rhoForward;}
356 * Set backward spin density matrix.
358 void setSpinDensityBackward(const EvtSpinDensity& rho){_rhoBackward=rho;}
361 * Get backward spin density matrix.
363 EvtSpinDensity getSpinDensityBackward(){return _rhoBackward;}
365 //Hacks will be removed when better solutions are thought of!
366 //This is used to suppress use of random numbers when doing initialization
368 void noLifeTime() { _genlifetime=0; }
370 //lange - April 29, 2002
371 void setId(EvtId id) { _id=id;}
372 void initDecay(bool useMinMass=false);
373 void generateMassTree();
375 double compMassProb();
377 //setMass will blow away any existing 4vector
378 void setMass(double m) { _p=EvtVector4R(m,0.0,0.0,0.0);}
380 //void setMixed() {_mix=true;}
381 //void setUnMixed() {_mix=false;}
382 //bool getMixed() {return _mix;}
384 //void takeCConj() {report(INFO,"EvtGen") << "should take conj\n";}
386 //this means that the particle has gone through initDecay
387 // and thus has a mass
388 bool isInitialized() {return _isInit;}
389 bool hasValidP4() {return _validP4;}
390 bool isDecayed() {return _isDecayed;}
393 // decay prob - only relevent if already decayed
394 // and is a scalar particle
395 // returned is a double* that should be prob/probMax
396 double* decayProb() {return _decayProb;}
397 void setDecayProb( double p);
402 void setp( double e, double px, double py, double pz) {
407 void setp( const EvtVector4R& p4 ) {
412 void setpart_num(EvtId particle_number ) {
413 assert(_channel==-10||
414 _id.getId()==particle_number.getId()||
416 _id = particle_number;
422 EvtParticle* _daug[MAX_DAUG];
424 EvtParticle* _parent;
429 EvtVector4R _pBeforeFSR;
436 EvtSpinDensity _rhoForward;
437 EvtSpinDensity _rhoBackward;
439 void makeStdHepRec(int firstparent,int lastparent,EvtStdHep& stdhep,
440 EvtSecondary& secondary,EvtId *stable_parent_ihep);
441 void makeStdHepRec(int firstparent,int lastparent,EvtStdHep& stdhep);
444 //This is a hack until things gets straightened out. (Ryd)
447 //should never be used, therefor is private.
448 //these does _not_ have an implementation
449 EvtParticle& operator=(const EvtParticle& p);
450 EvtParticle(const EvtParticle& p);