00001 #ifndef ParticleID_ParticleID_H 00002 #define ParticleID_ParticleID_H 00003 00004 // 00005 // ParticleID package: particle identification with combined info from 00006 // dE/dx, TOF, TOFQ ,Muc and Emc system. 00007 // 00008 // How to Use: 00009 // +++++++++++++++++++++++++++++++++++++++++ 00010 // ParticleID *pid = 0; 00011 // for (int i = 0; i < ncharg; i++) { 00012 // if(pid) delete pid; 00013 // pid = new ParticleID(dstTrk); 00014 // pid->usePidSys(pid->useDedx() | pid->useTof1() | pid->useTof2() | ...); 00015 // pid->identify(pid->onlyPionKaon()); // pid->onlyPionKaonProton(), etc 00016 // pid->calculate(); 00017 // if(!(pid->IsPidInfoValid())) continue; 00018 // // user's selections 00019 // } 00020 // if(pid) delete pid; 00021 // ----------------------------------------- 00022 // 00023 // Author: K.L.He & L.L. Wang & Gang.Qin 01/07/2007, created 00024 // 00025 00026 #include "ParticleID/ParticleIDBase.h" 00027 #include "ParticleID/DedxPID.h" 00028 #include "ParticleID/TofPID.h" 00029 #include "ParticleID/TofEPID.h" 00030 #include "ParticleID/TofQPID.h" 00031 #include "ParticleID/TofCPID.h" 00032 #include "ParticleID/EmcPID.h" 00033 #include "ParticleID/MucPID.h" 00034 //#include "EvtRecEvent/EvtRecTrack.h" 00035 00036 class ParticleID : public ParticleIDBase{ 00037 00038 public: 00039 00040 static ParticleID *instance(); 00041 ~ParticleID(); 00042 00043 void init(); 00044 // 00045 // PID info from each sub system 00046 // 00047 // Is Pid subsys info Valid 00048 inline bool IsDedxInfoValid() const; 00049 inline bool IsTofInfoValid() const; 00050 inline bool IsTofEInfoValid() const; 00051 inline bool IsTofQInfoValid() const; 00052 inline bool IsTofCInfoValid() const; 00053 inline bool IsEmcInfoValid() const; 00054 inline bool IsMucInfoValid() const; 00055 // get subsys Chi 00056 inline double chiDedx(int n) const; 00057 inline double chiTof(int n) const; 00058 inline double chiTof1(int n) const; 00059 inline double chiTof2(int n) const; 00060 inline double chiTofE(int n) const; 00061 inline double chiTofQ(int n) const; 00062 inline double chiTofC(int n) const; 00063 inline double chiEmc(int n) const; 00064 inline double chiMuc(int n) const; 00065 // get subsys Prob 00066 inline double probDedx(int n) const; 00067 inline double probTof(int n) const; 00068 inline double probTofE(int n) const; 00069 inline double probTofQ(int n) const; 00070 inline double probTofC(int n) const; 00071 inline double probEmc(int n) const; 00072 inline double probMuc(int n) const; 00073 //huangb add 00074 // get the subsys Pdf 00075 inline double pdfDedx(int n); 00076 inline double pdfTof(int n); 00077 inline double pdfTofE(int n); 00078 inline double pdfTofQ(int n); 00079 inline double pdfTofC(int n); 00080 inline double pdfEmc(int n); 00081 inline double pdfMuc(int n); 00082 00083 00084 int getNhitCut() const {return m_nhitcut;} 00085 void setNhitCut(const int nhitcuth = 5) {m_nhitcut = nhitcuth;} 00086 00087 // setMethod(methodProbability()); 00088 // setMethod(methodLikelihood()); 00089 // setMethod(methodNeuronNetwork()); 00090 void setMethod(const int method) {m_method = (m_method | method);} 00091 // specify sub pid sys 00092 // accessed by useDedx() | useTof1() | useTof2() | useTofE() | useTofQ() | useEmc() 00093 void usePidSys(const int pidsys) {m_pidsys = (m_pidsys | pidsys);} 00094 // identify pi/K accessed by onlyPionKaon() or onlyPion() | onlyKaon() 00095 // identify pi/K/p accessed by onlyPionKaonProton() or onlyPion() | onlyKaon() | onlyProton() 00096 // identify pi/K/e accessed by onlyPionKaonElectron() or onlyPion() | onlyKaon() | onlyElectron() 00097 // identify pi/K/e/p accessed by all() 00098 // identify muon accessed by onlyMuon() 00099 void identify(const int pidcase) {m_pidcase = (m_pidcase | pidcase);} 00100 // Calculation 00101 void calculate(); 00102 00103 // output of ParticleID 00104 00105 inline bool IsPidInfoValid() const; 00106 double chi(int n) const {return m_chisq[n];} 00107 double prob(int n) const { return m_prob[n];} 00108 int ndof() const {return m_ndof;} 00109 // huangb add 00110 //--------------------------------------- 00111 double pdf(int n) const { return m_pdf[n];} 00112 double lhf(int n) const {return m_likelihoodfraction[n];} 00113 00114 double probElectron() const {return m_prob[0];} 00115 double probMuon() const {return m_prob[1];} 00116 double probPion() const {return m_prob[2];} 00117 double probKaon() const {return m_prob[3];} 00118 double probProton() const {return m_prob[4];} 00119 int discard() const {return m_discard;} 00120 //huangb add 00121 //------------------------------------------------------- 00122 double pdfElectron() const {return m_pdf[0];} 00123 double pdfMuon() const {return m_pdf[1];} 00124 double pdfPion() const {return m_pdf[2];} 00125 double pdfKaon() const {return m_pdf[3];} 00126 double pdfProton() const {return m_pdf[4];} 00127 // Neuron Network PID 00128 /* int neuronPID() const {return m_neuronPid;} 00129 int neuronStat() const {return m_neuronStat;} 00130 double neuronVal() const {return m_neuronVal;} 00131 void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;} 00132 00133 void setNeuronPidCuts(); 00134 */ 00135 //tricks for nn 00136 //int neuronPID() const {return m_neuronPid;} 00137 int neuronStat() const {return IsPidInfoValid();} 00138 double neuronVal() const { 00139 if(lhf(0)>0.02) return 1.0; 00140 if(lhf(1)>0.02) return 8.5; 00141 if(lhf(2)>0.02) return 2.0; 00142 if(lhf(3)>0.02) return 4.0; 00143 if(lhf(4)>0.02) return 5.0; 00144 } 00145 // void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;} 00146 00147 protected: 00148 00149 int particleIDCalculation(); 00150 int LikelihoodCalculation(); 00151 // Neuron Network PID 00152 int neuronPIDCalculation(); 00153 private: 00154 00155 bool IsDedxInfoUsed() const {return ((m_pidsys & useDedx()) == useDedx());} 00156 bool IsTofInfoUsed() const {return ((m_pidsys & useTof()) == useTof());} 00157 bool IsTof1InfoUsed() const {return ((m_pidsys & useTof1()) == useTof1());} 00158 bool IsTof2InfoUsed() const {return ((m_pidsys & useTof2()) == useTof2());} 00159 bool IsTofEInfoUsed() const {return ((m_pidsys & useTofE()) == useTofE());} 00160 bool IsTofQInfoUsed() const {return ((m_pidsys & useTofQ()) == useTofQ());} 00161 bool IsTofCInfoUsed() const {return ((m_pidsys & useTofC()) == useTofC());} 00162 bool IsEmcInfoUsed() const {return ((m_pidsys & useEmc()) == useEmc());} 00163 bool IsMucInfoUsed() const {return ((m_pidsys & useMuc()) == useMuc());} 00164 00165 private: 00166 00167 DedxPID* m_dedxpid; 00168 TofEPID* m_tofepid; 00169 TofPID* m_tofpid; 00170 TofQPID* m_tofqpid; 00171 TofCPID* m_tofcpid; 00172 EmcPID* m_emcpid; 00173 MucPID* m_mucpid; 00174 double m_chisq[5]; 00175 double m_prob[5]; 00176 //huangb add 00177 double m_pdf[5]; 00178 double m_likelihoodfraction[5]; 00179 double m_TotalLikelihood; 00180 00181 int m_nhitcut; 00182 double m_chicut; 00183 int m_ndof; 00184 int m_pidsys; 00185 int m_pidcase; 00186 int m_method; 00187 int m_discard; 00188 00189 00190 00191 private: 00192 //constructor & desconstructor 00193 ParticleID(); 00194 static ParticleID *m_pointer; 00195 00196 }; 00197 00198 #include "ParticleID/ParticleID.icc" 00199 00200 #endif