LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtParticle.hh (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 29 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 18 0.0 %

          Line data    Source code
       1             : //--------------------------------------------------------------------------
       2             : //
       3             : // Environment:
       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.
       7             : //
       8             : // Copyright Information: See EvtGen/COPYRIGHT
       9             : //      Copyright (C) 1998      Caltech, UCSB
      10             : //
      11             : // Module: EvtGen/EvtParticle.hh
      12             : //
      13             : // Description:Class to describe all particles
      14             : //
      15             : // Modification history:
      16             : //
      17             : //    DJL/RYD     Sept. 25, 1996         Module created
      18             : //
      19             : //------------------------------------------------------------------------
      20             : 
      21             : #ifndef EVTPARTICLE_HH
      22             : #define EVTPARTICLE_HH
      23             : 
      24             : //#include <iostream.h>
      25             : #include <assert.h>
      26             : #include "EvtGenBase/EvtVector4R.hh"
      27             : #include "EvtGenBase/EvtSpinDensity.hh"
      28             : #include "EvtGenBase/EvtId.hh"
      29             : #include "EvtGenBase/EvtSpinType.hh"
      30             : #include <string>
      31             : #include <vector>
      32             : 
      33             : class EvtDiracSpinor;
      34             : class EvtVector4C;
      35             : class EvtTensor4C;
      36             : class EvtStdHep;
      37             : class EvtSecondary;
      38             : class EvtRaritaSchwinger;
      39             : 
      40             : const int MAX_DAUG =100;
      41             : const int MAX_LEVEL=10;
      42             : const int MAX_TRIES=10000;
      43             : 
      44             : class EvtParticle{
      45             : 
      46             : public:
      47             : 
      48             :   /**
      49             :   * Default constructor.
      50             :   */  
      51             :   EvtParticle();
      52             : 
      53             :   /**
      54             :   * Destructor.
      55             :   */
      56             :   virtual ~EvtParticle();
      57             : 
      58             :   /**
      59             :   * Returns polarization vector in the parents restframe.
      60             :   */
      61             :   virtual EvtVector4C epsParent(int i) const; 
      62             : 
      63             :   /**
      64             :   * Returns polarization vector in the particles own restframe.
      65             :   */
      66             :   virtual EvtVector4C eps(int i) const; 
      67             : 
      68             : 
      69             :   /**
      70             :   * Returns polarization vector in the parents restframe for a photon.
      71             :   */
      72             :   virtual EvtVector4C epsParentPhoton(int i); 
      73             : 
      74             :   /**
      75             :   * Returns polarization vector in the particles own restframe for a photon.
      76             :   */
      77             :   virtual EvtVector4C epsPhoton(int i); 
      78             : 
      79             : 
      80             :   /**
      81             :   * Returns Dirac spinor in the parents restframe for a Dirac particle.
      82             :   */
      83             :   virtual EvtDiracSpinor spParent(int) const;
      84             : 
      85             :   /**
      86             :   * Returns Dirac spinor in the particles own restframe for a Dirac particle.
      87             :   */
      88             :   virtual EvtDiracSpinor sp(int) const;
      89             : 
      90             : 
      91             : 
      92             :   /**
      93             :   * Returns Dirac spinor in the parents restframe for a Neutrino particle.
      94             :   */
      95             :   virtual EvtDiracSpinor spParentNeutrino() const;
      96             : 
      97             :   /**
      98             :   * Returns Dirac spinor in the particles own restframe for a
      99             :   * Neutrino particle.
     100             :   */
     101             :   virtual EvtDiracSpinor spNeutrino() const;
     102             :   
     103             : 
     104             :   /**
     105             :   * Returns tensor in the parents restframe for a spin 2 particle.
     106             :   */
     107             :   virtual EvtTensor4C epsTensorParent(int i) const; 
     108             : 
     109             :   /**
     110             :   * Returns tensor in the particles own restframe for a spin 2 particle.
     111             :   */
     112             :   virtual EvtTensor4C epsTensor(int i) const; 
     113             :   
     114             :   /**
     115             :    * Returns Rarita-Schwinger spinor in the parents restframe for a 
     116             :    * Rarita-Schwinger particle.
     117             :    */
     118             :   virtual EvtRaritaSchwinger spRSParent(int) const;
     119             :   
     120             :   /**
     121             :    * Returns Rarita-Schwinger spinor in the particles own restframe for a 
     122             :    * Rarita-Schwinger particle.
     123             :    */
     124             :   virtual EvtRaritaSchwinger spRS(int) const;
     125             :   
     126             : 
     127             : 
     128             :   /**
     129             :   * Initialiaze particle with id and 4momentum.
     130             :   */ 
     131             :   virtual void init(EvtId part_n,const EvtVector4R& p4)=0;
     132             :   
     133             :   /**
     134             :   * Add another daughter to the particle
     135             :   */
     136             :   void addDaug(EvtParticle *node); 
     137             :   
     138             :   /**
     139             :   * Decay particle
     140             :   */
     141             :   void decay();
     142             : 
     143             :   /** 
     144             :   * Delete a decay chain
     145             :   */
     146             :   void deleteTree();
     147             :   void deleteDaughters(bool keepChannel=false);
     148             : 
     149             :   /**
     150             :   * Should only be used internally.
     151             :   */ 
     152             :   void setChannel( int i );
     153             :   
     154             :   /**
     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.
     158             :   */ 
     159             :   void makeDaughters(unsigned int ndaug,EvtId *id);
     160             : 
     161             :   /**
     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.
     165             :   */ 
     166             :   void makeDaughters(unsigned int ndaug, std::vector<EvtId> idVector);
     167             : 
     168             :   /**
     169             :   * Similar to the routine above except that here 
     170             :   * momentum is generated according to phase space 
     171             :   * daughters are filled with this momentum.
     172             :   */ 
     173             :   double initializePhaseSpace(unsigned int numdaughter,EvtId *daughters,
     174             :                               bool forceResetMasses=false,
     175             :                               double poleSize=-1., int whichTwo1=0, 
     176             :                               int whichTwo2=1); 
     177             :   
     178             :   /**
     179             :   * Get pointer the the i:th daugther.
     180             :   */  
     181             :   EvtParticle *getDaug(int i);
     182             : 
     183             :   /**
     184             :   * Iterates over the particles in a decay chain.
     185             :   */
     186             :   EvtParticle *nextIter(EvtParticle *rootOfTree=0);
     187             : 
     188             :   /**
     189             :   * Makes stdhep list
     190             :   */
     191             :   void makeStdHep(EvtStdHep& stdhep,
     192             :                  EvtSecondary& secondary,EvtId *stable_parent_ihep);
     193             :   void makeStdHep(EvtStdHep& stdhep);
     194             : 
     195             :   /**
     196             :   * Gets 4vector in the labframe, i.e., the frame in which the root
     197             :   * particles momentum is measured.
     198             :   */
     199             :   EvtVector4R getP4Lab() const;
     200             : 
     201             : 
     202             :   /**
     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.
     206             :   */
     207             :   EvtVector4R getP4LabBeforeFSR();
     208             :  
     209             :   /**
     210             :   * Gets 4vector in the particles restframe, i.e. this functiont will
     211             :   * return (m,0,0,0)
     212             :   */
     213             :   EvtVector4R getP4Restframe() const;
     214             : 
     215             :   /**
     216             :   * Returns the 4position of the particle in the lab frame.
     217             :   */
     218             :   EvtVector4R get4Pos() const;
     219             : 
     220             :   /**
     221             :   * Returns pointer to parent particle.
     222             :   */
     223             :   EvtParticle *getParent() const;
     224             :   
     225             :   /**
     226             :   * Makes partptr the idaug:th daugther.
     227             :   */ 
     228           0 :   void insertDaugPtr(int idaug,EvtParticle* partptr){ _daug[idaug]=partptr;
     229           0 :                                                  partptr->_parent=this; }
     230             :   /**
     231             :   * Returns mass of particle.
     232             :   */
     233             :   double mass() const;
     234             : 
     235             :   /**
     236             :   * Used internally to decide if first time particle is decayed.
     237             :   */
     238             :   int firstornot() const;
     239             :   void setFirstOrNot();
     240             :   void resetFirstOrNot();
     241             : 
     242             :   /**
     243             :   * Returns Id of particle.
     244             :   */
     245             :   EvtId getId() const;
     246             : 
     247             :   /**
     248             :   * Returns the PDG id of the particle
     249             :   */
     250             :   
     251             :   int getPDGId() const;
     252             : 
     253             :   /** 
     254             :   * Returns particle type.
     255             :   */
     256             : 
     257             :   EvtSpinType::spintype getSpinType() const;
     258             : 
     259             :   /**
     260             :   * Returns number of spin states of the particle.
     261             :   */
     262             :   int getSpinStates() const;
     263             : 
     264             :   /**
     265             :   * Returns 4momentum in parents restframe.
     266             :   */
     267             :   const EvtVector4R& getP4() const;
     268             : 
     269             :   /**
     270             :   * Sets the 4momentum in the parents restframe.
     271             :   */
     272             :   void setP4(const EvtVector4R& p4){
     273           0 :     _p=p4;
     274           0 :     _pBeforeFSR=p4;
     275           0 :   }
     276             : 
     277             :   void setP4WithFSR(const EvtVector4R& p4){
     278           0 :     _p=p4;
     279           0 :   }
     280             : 
     281             :   void setFSRP4toZero(){
     282           0 :     _pBeforeFSR.set(0.0,0.0,0.0,0.0);
     283           0 :   }
     284             : 
     285             :   /**
     286             :   * Retunrs the decay channel.
     287             :   */
     288             :   int getChannel() const;
     289             :   
     290             :   /**
     291             :   * Returns number of daugthers.
     292             :   */ 
     293             :   size_t getNDaug() const;
     294           0 :   void resetNDaug() {_ndaug=0; return;}
     295             : 
     296             :   /**
     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.
     300             :   */
     301             :   void printTree() const;
     302             : 
     303             :   void printTreeRec(unsigned int level) const;
     304             : 
     305             :   std::string treeStr() const;
     306             :   std::string treeStrRec(unsigned int level) const;
     307             : 
     308             :   /**
     309             :   * Prints information for the particle.
     310             :   */
     311             :   void printParticle() const;
     312             : 
     313             :   /**
     314             :   * Set lifetime of the particle in parents restframe.
     315             :   */  
     316             :   void setLifetime(double tau);
     317             :   
     318             :   /**
     319             :   * Generate lifetime according to pure exponential.
     320             :   */
     321             :   void setLifetime();
     322             : 
     323             :   /**
     324             :   * Returns the lifetime.
     325             :   */
     326             :   double getLifetime();
     327             : 
     328             :   /** 
     329             :   * Set diagonal spindensity matrix.
     330             :   */
     331             :   void setDiagonalSpinDensity();
     332             :   
     333             :   /** 
     334             :   * Set spindensity matrix for e+e- -> V
     335             :   */
     336             :   void setVectorSpinDensity(); 
     337             :   
     338             :   /**
     339             :   * Set forward spin density matrix.
     340             :   */
     341           0 :   void setSpinDensityForward(const EvtSpinDensity& rho){_rhoForward=rho;}
     342             : 
     343             :   /**
     344             :   * Set forward spin density matrix according to the density matrix
     345             :   * rho in the helicity amplitude basis.
     346             :   */
     347             :   void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho);
     348             :   void setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho,
     349             :                                           double alpha,
     350             :                                           double beta,
     351             :                                           double gamma);
     352             :   
     353             :   /**
     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
     357             :   * derived class.
     358             :   */
     359             :   virtual EvtSpinDensity rotateToHelicityBasis() const=0;
     360             :   virtual EvtSpinDensity rotateToHelicityBasis(double alpha,
     361             :                                                double beta,
     362             :                                                double gamma) const=0;
     363             : 
     364             :   /**
     365             :   * Get forward spin density matrix.
     366             :   */
     367           0 :   EvtSpinDensity getSpinDensityForward(){return _rhoForward;}
     368             : 
     369             :   /**
     370             :   * Set backward spin density matrix.
     371             :   */
     372           0 :   void setSpinDensityBackward(const EvtSpinDensity& rho){_rhoBackward=rho;}
     373             : 
     374             :   /**
     375             :   * Get backward spin density matrix.
     376             :   */
     377           0 :   EvtSpinDensity getSpinDensityBackward(){return _rhoBackward;}
     378             : 
     379             :   //Hacks will be removed when better solutions are thought of!
     380             :   //This is used to suppress use of random numbers when doing initialization
     381             :   //of some models.
     382           0 :   void noLifeTime() { _genlifetime=0; }
     383             : 
     384             :   //lange - April 29, 2002
     385           0 :   void setId(EvtId id) { _id=id;}
     386             :   void initDecay(bool useMinMass=false);
     387             :   bool generateMassTree();
     388             : 
     389             :   double compMassProb();
     390             : 
     391             :   //setMass will blow away any existing 4vector
     392           0 :   void setMass(double m) { _p=EvtVector4R(m,0.0,0.0,0.0);}
     393             : 
     394             :   //void setMixed() {_mix=true;}
     395             :   //void setUnMixed() {_mix=false;}
     396             :   //bool getMixed() {return _mix;}
     397             : 
     398             :   //void takeCConj() {report(Severity::Info,"EvtGen") << "should take conj\n";}
     399             : 
     400             :   //this means that the particle has gone through initDecay
     401             :   // and thus has a mass
     402           0 :   bool isInitialized() {return _isInit;}
     403           0 :   bool hasValidP4() {return _validP4;}
     404           0 :   bool isDecayed() {return _isDecayed;}
     405             : 
     406             : 
     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);
     412             : 
     413             :   // Return the name of the particle (from the EvtId number)
     414             :   std::string getName();
     415             :    
     416             : protected:
     417             : 
     418             :   void setp( double e, double px, double py, double pz) { 
     419           0 :     _p.set(e,px,py,pz); 
     420           0 :     _pBeforeFSR=_p;
     421           0 :   }
     422             : 
     423             :   void setp( const EvtVector4R& p4 ) { 
     424           0 :     _p =p4; 
     425           0 :     _pBeforeFSR=_p;
     426           0 :   }
     427             : 
     428             :   void setpart_num(EvtId particle_number ) { 
     429           0 :     assert(_channel==-10||
     430             :            _id.getId()==particle_number.getId()||
     431             :            _id.getId()==-1);
     432           0 :     _id = particle_number; 
     433           0 :   }
     434             :   bool           _validP4;
     435             : 
     436             : private:
     437             : 
     438             :   EvtParticle*   _daug[MAX_DAUG];
     439             :   size_t         _ndaug; 
     440             :   EvtParticle*   _parent;
     441             :   int            _channel; 
     442             :   int            _first;
     443             :   EvtId          _id;
     444             :   EvtVector4R    _p;
     445             :   EvtVector4R    _pBeforeFSR;
     446             :   double         _t;
     447             :   bool            _isInit;
     448             :   bool           _isDecayed;
     449             : 
     450             :   //bool _mix;
     451             : 
     452             :   EvtSpinDensity _rhoForward;
     453             :   EvtSpinDensity _rhoBackward;
     454             : 
     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);
     458             : 
     459             : 
     460             :   //This is a hack until things gets straightened out. (Ryd)
     461             :   int         _genlifetime;
     462             :   
     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);
     467             : 
     468             :   double *_decayProb;
     469             : 
     470             : };
     471             : 
     472             : #endif
     473             : 

Generated by: LCOV version 1.11