/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/MdcRecoUtil/Pdt.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: Pdt.h,v 1.3 2009/12/23 02:59:56 zhangy Exp $
00004 //
00005 // Description:
00006 //      Searchable Particle Lists for BaBar
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Author List:
00012 //      John LoSecco            Original Author
00013 //      Zhang Yao(zhangyao@ihep.ac.cn)
00014 //      Anders Ryd              Reimplemented using RW hash tables
00015 //
00016 // Copyright Information:
00017 //      Copyright (C) 1998      The University of Notre Dame
00018 // 
00019 // History:
00020 //      Migration for BESIII MDC
00021 //
00022 //------------------------------------------------------------------------
00023 //
00024 // Based on Pdt.h by Luca Lista
00025 //
00026 // See Also
00027 //     PdtbEntry, DecayMode
00028 
00029 #ifndef PDT_HH
00030 #define PDT_HH
00031 
00032 #include "MdcRecoUtil/PdtLund.h"
00033 #include "MdcRecoUtil/PdtGeant.h"
00034 #include "MdcRecoUtil/PdtPid.h"
00035 #include "MdcRecoUtil/PdtEntry.h"
00036 #include <string>
00037 #include <map>
00038 
00039 //Hash size, should atleast be a prime and 
00040 //of about the same size as the number of particles
00041 #define PdtHashSize 503
00042 
00043 //typedef PdtEntry* PdtEntryPtr;
00044 
00045 #include <iosfwd>
00046 
00047 template < class T > class AstStringMap;
00048 
00049 class Pdt {
00050 
00051 public:
00052   // return PDT entry pointer given the particle id or name
00053   static PdtEntry* lookup(const std::string& name);
00054   static PdtEntry* lookup(PdtLund::LundType id);
00055   static PdtEntry* lookup(PdtGeant::GeantType id);
00056   static PdtEntry* lookup(PdtPdg::PdgType id);
00057   static PdtEntry* lookup(PdtPid::PidType id, int charge=-1);
00058   static PdtEntry* lookup(PdtPid::PidNeutralType id,int charge=0);
00059   //
00060   // LL:  the following method is suggested by Gautier, but I think 
00061   // LL:  could not be completely safe.
00062    // LL:  I suggest to use lookup(pdtId(int id), int charge) in replacement. 
00063   // 
00064   //  static PdtEntry* lookup(int id, int charge=-1); 
00065 
00066   //lange Feb 11,2003
00067   static bool sameOrConj( PdtLund::LundType id1, PdtLund::LundType id2);
00068   static bool sameOrConj( PdtPdg::PdgType id1, PdtPdg::PdgType id2);
00069   static bool sameOrConj( PdtEntry *id1, PdtEntry *id2);
00070 
00071   // GHM 05/19/99 : get the conjugate of a PdtEntry
00072   static const PdtEntry* conjugate( const PdtEntry* );
00073   
00074   // get mass value 
00075   static float mass(PdtLund::LundType id)      { return lookup(id)->mass(); }
00076   static float mass(PdtGeant::GeantType id)    { return lookup(id)->mass(); }
00077   static float mass(PdtPid::PidType id)        { return lookup(id)->mass();}
00078   static float mass(PdtPid::PidNeutralType id) { return lookup(id)->mass();}
00079   static float mass(const char* name)          { return lookup(name)->mass(); }
00080 
00081   // get width value 
00082   static float width(PdtLund::LundType id)     { return lookup(id)->width(); }
00083   static float width(PdtGeant::GeantType id)   { return lookup(id)->width(); }
00084   static float width(PdtPid::PidType id)       { return lookup(id)->width(); }
00085   static float width(PdtPid::PidNeutralType id) { return lookup(id)->width(); }
00086   static float width(const char* name)         { return lookup(name)->width(); }
00087 
00088   // get lifetime value 
00089   static float lifetime(PdtLund::LundType id)  { return lookup(id)->lifetime(); }
00090   static float lifetime(PdtGeant::GeantType id){ return lookup(id)->lifetime(); }
00091   static float lifetime(PdtPid::PidType id)    { return lookup(id)->lifetime(); }
00092   static float lifetime(PdtPid::PidNeutralType id) { return lookup(id)->lifetime(); }
00093   static float lifetime(const char* name)      { return lookup(name)->lifetime(); }
00094 
00095   // get spin value 
00096   static float spin(PdtLund::LundType id)      { return lookup(id)->spin(); }
00097   static float spin(PdtGeant::GeantType id)    { return lookup(id)->spin(); }
00098   static float spin(PdtPid::PidType id)        { return lookup(id)->spin(); }
00099   static float spin(PdtPid::PidNeutralType id) { return lookup(id)->spin(); }
00100   static float spin(const char* name)          { return lookup(name)->spin(); }
00101   
00102   // get charge. Not available for Pid code 
00103   static float charge(PdtLund::LundType id)    { return lookup(id)->charge(); }
00104   static float charge(PdtGeant::GeantType id)  { return lookup(id)->charge(); }
00105   static float charge(const char* name)        { return lookup(name)->charge(); }
00106 
00107   // get antiparticle code
00108   static PdtLund::LundType antiCode(PdtLund::LundType);
00109 
00110   // read the MC++ input file
00111   static void readMCppTable(std::string filenm);
00112 
00113   // remove all the entries
00114   static void deleteAll();
00115 
00116   // print the particle table
00117   static void printOn( std::ostream & );
00118   
00119   // create an entry for a particle that is its own antiparticle
00120   static void addParticle(const char* pname, PdtLund::LundType id,
00121                           float spin, float charge, float mass, float width=0.0,
00122                           float cut = 0.0
00123                           );
00124   static void addParticle(const char* pname, PdtGeant::GeantType id,
00125                           float spin, float charge, float mass, float width=0.0,
00126                           float cut = 0.0
00127                           );
00128   
00129   static void addDecay(const char* pname, float bf,
00130                        const char* child1, const char* child2=0, 
00131                        const char* child3=0, const char* child4=0, 
00132                        const char* child5=0
00133                        );
00134   
00135   static void addDecay(PdtLund::LundType id, float bf,
00136                        PdtLund::LundType child1, 
00137                        PdtLund::LundType child2=PdtLund::null, 
00138                        PdtLund::LundType child3=PdtLund::null,
00139                        PdtLund::LundType child4=PdtLund::null, 
00140                        PdtLund::LundType child5=PdtLund::null
00141                        );
00142   
00143   // code conversions from Lund and Geant id
00144   static PdtLund::LundType   lundId (const PdtGeant::GeantType);
00145   static PdtLund::LundType   lundId (const PdtPdg::PdgType);
00146   static PdtLund::LundType   lundId (const PdtPid::PidType, int charge = -1);
00147   static PdtLund::LundType   lundId (const PdtPid::PidNeutralType, int charge = 0);
00148 
00149   static PdtPdg::PdgType     pdgId  (const PdtLund::LundType);
00150   static PdtPdg::PdgType     pdgId  (const PdtPid::PidType pid, int charge = -1)
00151     { return pdgId(lundId(pid, charge)); }
00152   static PdtPdg::PdgType     pdgId  (const PdtPid::PidNeutralType pid, int charge = 0)
00153     { return pdgId(lundId(pid, charge)); }
00154   static PdtPdg::PdgType     pdgPid (const PdtGeant::GeantType geant)
00155     { return pdgId(lundId(geant)); }
00156 
00157   static PdtGeant::GeantType geantId(const PdtLund::LundType);
00158   static PdtGeant::GeantType geantId(const PdtPid::PidType, int charge = -1);
00159   static PdtGeant::GeantType geantId(const PdtPid::PidNeutralType, int charge = 0);
00160   static PdtGeant::GeantType geantId(const PdtPdg::PdgType pdg)
00161     { return geantId(lundId(pdg)); }
00162 
00163   static PdtPid::PidType     pidId  (const PdtLund::LundType);
00164   static PdtPid::PidType     pidId  (const PdtGeant::GeantType);
00165   static PdtPid::PidType     pidId  (const PdtPdg::PdgType pdg)
00166     { return pidId(lundId(pdg)); }
00167   static PdtPid::PidNeutralType     pidNeutId  (const PdtLund::LundType);
00168   static PdtPid::PidNeutralType     pidNeutId  (const PdtGeant::GeantType);
00169   static PdtPid::PidNeutralType     pidNeutId  (const PdtPdg::PdgType pdg)
00170     { return pidNeutId(lundId(pdg)); }
00171 
00172   // conversions from Pid code need the charge as an extra argument
00173 
00174   // conversions from integer, useful in "for" cycles and to load
00175   // from FORTRAN common blocks. Example:
00176   // int i;
00177   // for (i = PdtPid::electron; i <= PdtPid::proton; i++)
00178   //   { PdtEntry* pdt = Pdt::lookup(Pdt::pidId(i)); }
00179   // 
00180   static PdtLund::LundType   lundId (const int id) { return (PdtLund::LundType) id; }; 
00181   static PdtGeant::GeantType geantId(const int id) { return (PdtGeant::GeantType) id; }; 
00182   static PdtPid::PidType     pidId  (const int id) { return (PdtPid::PidType) id; }; 
00183   static PdtPid::PidNeutralType     pidNeutId (const int id) { return (PdtPid::PidNeutralType) id; };
00184   static PdtPdg::PdgType     pdgId  (const int id) { return (PdtPdg::PdgType) id; };
00185 
00186 
00187 
00188 private:
00189   
00190   //Hash tables for looking up particles
00191   static  std::map<int,PdtEntry*>* _entries; //By pdt number
00192   static  AstStringMap< PdtEntry >* _entriesn;  //By name
00193   static  std::map<int,PdtEntry*>* _entriesg;  //By geant number
00194   static  std::map<int,PdtEntry*>* _entriesl;  //By lund number
00195   //Pid type is too small to bother. 
00196 
00197   //hash functions for particle numbers and name
00198   static unsigned PdtNumHash(const int& num);
00199   static unsigned PdtNameHash(const std::string& c);
00200   
00201   //cache common particles for fast access
00202   static PdtEntry* _positiveEntries[5];
00203   static PdtEntry* _negativeEntries[5];
00204   static PdtEntry* _neutralEntries[5];
00205   
00206 };
00207   
00208 #endif
00209 
00210 
00211 
00212 

Generated on Tue Nov 29 23:13:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7