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/TofCorrPID.h" 00033 #include "ParticleID/EmcPID.h" 00034 #include "ParticleID/MucPID.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 IsTofCorrInfoValid() const; 00054 inline bool IsEmcInfoValid() const; 00055 inline bool IsMucInfoValid() const; 00056 // get subsys Chi 00057 inline double chiDedx(int n) const; 00058 inline double chiTof(int n) const; 00059 inline double chiTof1(int n) const; 00060 inline double chiTof2(int n) const; 00061 inline double chiTofE(int n) const; 00062 inline double chiTofQ(int n) const; 00063 inline double chiTofC(int n) const; 00064 inline double chiTofCorr(int n) const; 00065 inline double chiEmc(int n) const; 00066 inline double chiMuc(int n) const; 00067 // get subsys Prob 00068 inline double probDedx(int n) const; 00069 inline double probTof(int n) const; 00070 inline double probTofE(int n) const; 00071 inline double probTofQ(int n) const; 00072 inline double probTofC(int n) const; 00073 inline double probTofCorr(int n) const; 00074 inline double probEmc(int n) const; 00075 inline double probMuc(int n) const; 00076 //huangb add 00077 // get the subsys Pdf 00078 inline double pdfDedx(int n); 00079 inline double pdfTof(int n); 00080 inline double pdfTofE(int n); 00081 inline double pdfTofQ(int n); 00082 inline double pdfTofC(int n); 00083 inline double pdfTofCorr(int n); 00084 inline double pdfEmc(int n); 00085 inline double pdfMuc(int n); 00086 00087 00088 int getNhitCut() const {return m_nhitcut;} 00089 void setNhitCut(const int nhitcuth = 5) {m_nhitcut = nhitcuth;} 00090 00091 // setMethod(methodProbability()); 00092 // setMethod(methodLikelihood()); 00093 // setMethod(methodNeuronNetwork()); 00094 void setMethod(const int method) {m_method = (m_method | method);} 00095 // specify sub pid sys 00096 // accessed by useDedx() | useTof1() | useTof2() | useTofE() | useTofQ() | useEmc() 00097 void usePidSys(const int pidsys) {m_pidsys = (m_pidsys | pidsys);} 00098 // identify pi/K accessed by onlyPionKaon() or onlyPion() | onlyKaon() 00099 // identify pi/K/p accessed by onlyPionKaonProton() or onlyPion() | onlyKaon() | onlyProton() 00100 // identify pi/K/e accessed by onlyPionKaonElectron() or onlyPion() | onlyKaon() | onlyElectron() 00101 // identify pi/K/e/p accessed by all() 00102 // identify muon accessed by onlyMuon() 00103 void identify(const int pidcase) {m_pidcase = (m_pidcase | pidcase);} 00104 // Calculation 00105 void calculate(); 00106 #ifdef BEAN 00107 void calculate(int run); // BEAN: use this instead of calculate() 00108 #endif 00109 00110 // output of ParticleID 00111 00112 inline bool IsPidInfoValid() const; 00113 double chi(int n) const {return m_chisq[n];} 00114 double prob(int n) const { return m_prob[n];} 00115 int ndof() const {return m_ndof;} 00116 // huangb add 00117 //--------------------------------------- 00118 double pdf(int n) const { return m_pdf[n];} 00119 double lhf(int n) const {return m_likelihoodfraction[n];} 00120 00121 double probElectron() const {return m_prob[0];} 00122 double probMuon() const {return m_prob[1];} 00123 double probPion() const {return m_prob[2];} 00124 double probKaon() const {return m_prob[3];} 00125 double probProton() const {return m_prob[4];} 00126 int discard() const {return m_discard;} 00127 //huangb add 00128 //------------------------------------------------------- 00129 double pdfElectron() const {return m_pdf[0];} 00130 double pdfMuon() const {return m_pdf[1];} 00131 double pdfPion() const {return m_pdf[2];} 00132 double pdfKaon() const {return m_pdf[3];} 00133 double pdfProton() const {return m_pdf[4];} 00134 // Neuron Network PID 00135 /* int neuronPID() const {return m_neuronPid;} 00136 int neuronStat() const {return m_neuronStat;} 00137 double neuronVal() const {return m_neuronVal;} 00138 void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;} 00139 00140 void setNeuronPidCuts(); 00141 */ 00142 //tricks for nn 00143 //int neuronPID() const {return m_neuronPid;} 00144 int neuronStat() const {return IsPidInfoValid();} 00145 double neuronVal() const { 00146 if(lhf(0)>0.02) return 1.0; 00147 if(lhf(1)>0.02) return 8.5; 00148 if(lhf(2)>0.02) return 2.0; 00149 if(lhf(3)>0.02) return 4.0; 00150 if(lhf(4)>0.02) return 5.0; 00151 } 00152 // void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;} 00153 int ipmt() { 00154 return m_tofcorrpid->ipmt(); 00155 } 00156 double dt(int ipar, int ipmt) { 00157 return m_tofcorrpid->dt(ipar, ipmt); 00158 } 00159 double dtCorr(int ipar, int ipmt) { 00160 return m_tofcorrpid->dtCorr(ipar, ipmt); 00161 } 00162 double sigCorr(int ipar, int ipmt) { 00163 return m_tofcorrpid->sigCorr(ipar, ipmt); 00164 } 00165 double chiCorr(int ipar, int ipmt) { 00166 return m_tofcorrpid->chiCorr(ipar, ipmt); 00167 } 00168 double offset(int ipar) { 00169 return m_tofcorrpid->offset(ipar); 00170 } 00171 double sigma(int ipar) { 00172 return m_tofcorrpid->sigma(ipar); 00173 } 00174 00175 protected: 00176 00177 int particleIDCalculation(); 00178 int LikelihoodCalculation(); 00179 // Neuron Network PID 00180 int neuronPIDCalculation(); 00181 private: 00182 00183 bool IsDedxInfoUsed() const {return ((m_pidsys & useDedx()) == useDedx());} 00184 bool IsTofInfoUsed() const {return ((m_pidsys & useTof()) == useTof());} 00185 bool IsTof1InfoUsed() const {return ((m_pidsys & useTof1()) == useTof1());} 00186 bool IsTof2InfoUsed() const {return ((m_pidsys & useTof2()) == useTof2());} 00187 bool IsTofEInfoUsed() const {return ((m_pidsys & useTofE()) == useTofE());} 00188 bool IsTofQInfoUsed() const {return ((m_pidsys & useTofQ()) == useTofQ());} 00189 bool IsTofCInfoUsed() const {return ((m_pidsys & useTofC()) == useTofC());} 00190 bool IsTofCorrInfoUsed() const {return ((m_pidsys & useTofCorr()) == useTofCorr());} 00191 bool IsEmcInfoUsed() const {return ((m_pidsys & useEmc()) == useEmc());} 00192 bool IsMucInfoUsed() const {return ((m_pidsys & useMuc()) == useMuc());} 00193 00194 private: 00195 00196 DedxPID* m_dedxpid; 00197 TofEPID* m_tofepid; 00198 TofPID* m_tofpid; 00199 TofQPID* m_tofqpid; 00200 TofCPID* m_tofcpid; 00201 TofCorrPID* m_tofcorrpid; 00202 EmcPID* m_emcpid; 00203 MucPID* m_mucpid; 00204 double m_chisq[5]; 00205 double m_prob[5]; 00206 //huangb add 00207 double m_pdf[5]; 00208 double m_likelihoodfraction[5]; 00209 double m_TotalLikelihood; 00210 00211 int m_nhitcut; 00212 double m_chicut; 00213 int m_ndof; 00214 int m_pidsys; 00215 int m_pidcase; 00216 int m_method; 00217 int m_discard; 00218 00219 00220 00221 private: 00222 //constructor & desconstructor 00223 ParticleID(); 00224 static ParticleID *m_pointer; 00225 00226 }; 00227 00228 #include "ParticleID/ParticleID.icc" 00229 00230 #endif