CLHEP/HepPDT/ParticleDataT.hh

00001 // $Id: ParticleDataT.hh,v 1.6 2002/04/18 20:15:23 garren Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 // ParticleDataT.hh
00005 // Author: Lynn Garren
00006 //
00007 // This is a base class for particle data information
00008 // ----------------------------------------------------------------------
00009 #ifndef PARTICLEDATAT_HH
00010 #define PARTICLEDATAT_HH
00011 
00012 #include "CLHEP/config/CLHEP.h"
00013 #include <algorithm>    // swap()
00014 
00015 #include "CLHEP/HepPDT/ParticleID.hh"
00016 #include "CLHEP/HepPDT/Measurement.hh"
00017 #include "CLHEP/HepPDT/SpinState.hh"
00018 #include "CLHEP/HepPDT/ResonanceStructure.hh"
00019 #include "CLHEP/HepPDT/TempParticleData.hh"
00020 #include "CLHEP/HepPDT/DecayChannelT.hh"
00021 
00022 namespace HepPDT {
00023 
00028 template< class Config >
00029 class ParticleDataT {
00030 
00031 public:
00032   // --- useful typedef's
00033   //
00034   typedef  typename Config::CPD          CPD;
00035   typedef  typename Config::PT           PT;
00036 
00037   typedef  typename Config::ParticleData ParticleData;
00038   typedef  typename Config::DecayData    DecayData;
00039   typedef  typename Config::DecayChannel DecayChannel;
00040 
00041   typedef  typename Config::CPDID        CPDID;
00042   typedef  typename Config::DDID         DDID;
00043 
00044   // ---  birth/death:
00045   //
00046   inline ParticleDataT( const CPDID & cpdid, const DDID & ddid );
00047   inline ~ParticleDataT();
00048 
00049   // ---  copying:
00050   //
00051   inline void  swap( ParticleDataT<Config> & other );
00052   inline ParticleDataT( const ParticleDataT<Config> & orig );
00053   inline ParticleDataT& operator = ( const ParticleDataT<Config> & rhs );
00054 
00055   // ---  ParticleData accessors:
00056   //
00057   const std::string &         name()        const { return itsCPDID->name();      }
00058   ParticleID                  ID()          const { return itsCPDID->ID();        }
00059   int                         pid( )        const { return itsCPDID->ID().pid(); }
00060   double                      charge()      const { return itsCPDID->charge();    }
00061   double                      color()       const { return itsCPDID->color();     }
00062   SpinState                   spin()        const { return itsCPDID->spin();      }
00063   Measurement                 mass()        const { return itsCPDID->mass(); }
00064   Measurement                 totalWidth()  const { return itsCPDID->totalWidth();  }
00065   Measurement                 lifetime()    const { return itsCPDID->lifetime();  }
00066   int                         numConstituents() const { return itsCPDID->numConstituents(); }
00067   inline Constituent          constituent( unsigned int i ) const 
00068                                            { return itsCPDID->constituent(i); }
00069   inline ParticleID           constituentParticle( unsigned int i ) const
00070                                             { return itsCPDID->constituentParticle(i); }
00071   ResonanceStructure const *  resonance()   const { return itsCPDID->resonance(); }
00072 
00073   // --- ParticleData booleans:
00074   //
00075   bool isMeson( )   const  { return itsCPDID->isMeson(); }
00076   bool isBaryon( )  const  { return itsCPDID->isBaryon(); }
00077   bool isDiQuark( ) const  { return itsCPDID->isDiQuark(); }
00078   bool isHadron( )  const  { return itsCPDID->isHadron(); }
00079   bool isLepton( )  const  { return itsCPDID->isLepton(); }
00080   bool isNucleus( ) const  { return itsCPDID->isNucleus(); }
00081   bool hasUp()      const  { return itsCPDID->hasUp();      }
00082   bool hasDown()    const  { return itsCPDID->hasDown();    }
00083   bool hasStrange() const  { return itsCPDID->hasStrange(); }
00084   bool hasCharm()   const  { return itsCPDID->hasCharm();   }
00085   bool hasBottom()  const  { return itsCPDID->hasBottom();  }
00086   bool hasTop()     const  { return itsCPDID->hasTop();     }
00087 
00088   // ---  ParticleData mutators:
00089   //
00090   void  setCharge( double chg )            { itsCPDID->setCharge(chg); }
00091   void  setColor( double col )             { itsCPDID->setColor(col); }
00092   void  setSpin( SpinState const & spin )  { itsCPDID->setSpin(spin); }
00093   void  addConstituent( Constituent c )    { itsCPDID->addConstituent(c); }
00094 
00095   // ---  DecayData accessors:
00096   //
00097   int                  numDecayChannels() const { return itsDDID->size(); }
00098   bool                 isStable()         const { return itsDDID->isStable(); }
00099   DecayChannelT<Config>  channel( int i )    const { return itsDDID->channel(i); }
00100 
00101   // ---  decay methods:
00102   //
00103   bool  decay( int i, const PT & parent, std::vector<PT> & daughters );
00104   bool  decay( double rdm, const PT & parent, std::vector<PT> & daughters );
00105 
00106   // ---  DecayData mutators:
00107   //
00108   void  appendMode( DecayChannel const & dcp)  { itsDDID->appendMode(dcp); }
00109 
00110   // ---  accessors:
00111   //
00112   DDID   getDecayData()            const { return itsDDID; }
00113   CPDID  getCommonParticleData()   const { return itsCPDID; }
00114   
00115   inline void write( std::ostream & os ) const;
00116 
00117   // ---  booleans:
00118   //
00119   //bool  operator <  ( ParticleDataT<Config> const & other ) const;
00120   //bool  operator == ( ParticleDataT<Config> const & other ) const;
00121   
00122   // ---  mutator:
00123   //
00124   void  setDecayData( DDID dd )  { itsDDID = dd; }
00125 
00126 private:
00127 
00128   // ---  class-specific data:
00129   //
00130   CPDID  itsCPDID;      // pointer/iterator to ParticleData
00131   DDID   itsDDID;       // pointer/iterator to DecayData
00132 
00133   // default constructor not allowed
00134   ParticleDataT( );
00135 
00136 };  // ParticleDataT
00137 
00138 template< class Config >
00139 inline
00140 void  swap( ParticleDataT<Config> & first, ParticleDataT<Config> & second ) {
00141   first.swap( second );
00142 }
00143 
00144 }       // HepPDT
00145 
00146 #include "CLHEP/HepPDT/ParticleDataT.icc"
00147 
00148 #endif // PARTICLEDATAT_HH

Class Library for High Energy Physics (version 1.8)