BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
ParticleID.h
Go to the documentation of this file.
1#ifndef ParticleID_ParticleID_H
2#define ParticleID_ParticleID_H
3
4//
5// ParticleID package: particle identification with combined info from
6// dE/dx, TOF, TOFQ ,Muc and Emc system.
7//
8// How to Use:
9// +++++++++++++++++++++++++++++++++++++++++
10// ParticleID *pid = 0;
11// for (int i = 0; i < ncharg; i++) {
12// if(pid) delete pid;
13// pid = new ParticleID(dstTrk);
14// pid->usePidSys(pid->useDedx() | pid->useTof1() | pid->useTof2() | ...);
15// pid->identify(pid->onlyPionKaon()); // pid->onlyPionKaonProton(), etc
16// pid->calculate();
17// if(!(pid->IsPidInfoValid())) continue;
18// // user's selections
19// }
20// if(pid) delete pid;
21// -----------------------------------------
22//
23// Author: K.L.He & L.L. Wang & Gang.Qin 01/07/2007, created
24//
25
27#include "ParticleID/DedxPID.h"
28#include "ParticleID/TofPID.h"
29#include "ParticleID/TofEPID.h"
30#include "ParticleID/TofQPID.h"
31#include "ParticleID/TofCPID.h"
33#include "ParticleID/EmcPID.h"
34#include "ParticleID/MucPID.h"
35
37
38 public:
39
40 static ParticleID *instance();
42
43 void init();
44 //
45 // PID info from each sub system
46 //
47 // Is Pid subsys info Valid
48 inline bool IsDedxInfoValid() const;
49 inline bool IsTofInfoValid() const;
50 inline bool IsTofEInfoValid() const;
51 inline bool IsTofQInfoValid() const;
52 inline bool IsTofCInfoValid() const;
53 inline bool IsTofCorrInfoValid() const;
54 inline bool IsEmcInfoValid() const;
55 inline bool IsMucInfoValid() const;
56 // get subsys Chi
57 inline double chiDedx(int n) const;
58 inline double chiTof(int n) const;
59 inline double chiTof1(int n) const;
60 inline double chiTof2(int n) const;
61 inline double chiTofE(int n) const;
62 inline double chiTofQ(int n) const;
63 inline double chiTofC(int n) const;
64 inline double chiTofCorr(int n) const;
65 inline double chiEmc(int n) const;
66 inline double chiMuc(int n) const;
67 // get subsys Prob
68 inline double probDedx(int n) const;
69 inline double probTof(int n) const;
70 inline double probTofE(int n) const;
71 inline double probTofQ(int n) const;
72 inline double probTofC(int n) const;
73 inline double probTofCorr(int n) const;
74 inline double probEmc(int n) const;
75 inline double probMuc(int n) const;
76 //huangb add
77// get the subsys Pdf
78 inline double pdfDedx(int n);
79 inline double pdfTof(int n);
80 inline double pdfTofE(int n);
81 inline double pdfTofQ(int n);
82 inline double pdfTofC(int n);
83 inline double pdfTofCorr(int n);
84 inline double pdfEmc(int n);
85 inline double pdfMuc(int n);
86
87
88 int getNhitCut() const {return m_nhitcut;}
89 void setNhitCut(const int nhitcuth = 5) {m_nhitcut = nhitcuth;}
90
91 // setMethod(methodProbability());
92 // setMethod(methodLikelihood());
93 // setMethod(methodNeuronNetwork());
94 void setMethod(const int method) {m_method = (m_method | method);}
95 // specify sub pid sys
96 // accessed by useDedx() | useTof1() | useTof2() | useTofE() | useTofQ() | useEmc()
97 void usePidSys(const int pidsys) {m_pidsys = (m_pidsys | pidsys);}
98 // identify pi/K accessed by onlyPionKaon() or onlyPion() | onlyKaon()
99 // identify pi/K/p accessed by onlyPionKaonProton() or onlyPion() | onlyKaon() | onlyProton()
100 // identify pi/K/e accessed by onlyPionKaonElectron() or onlyPion() | onlyKaon() | onlyElectron()
101 // identify pi/K/e/p accessed by all()
102 // identify muon accessed by onlyMuon()
103 void identify(const int pidcase) {m_pidcase = (m_pidcase | pidcase);}
104 // Calculation
105 void calculate();
106#ifdef BEAN
107 void calculate(int run); // BEAN: use this instead of calculate()
108#endif
109
110 // output of ParticleID
111
112 inline bool IsPidInfoValid() const;
113 double chi(int n) const {return m_chisq[n];}
114 double prob(int n) const { return m_prob[n];}
115 int ndof() const {return m_ndof;}
116 // huangb add
117 //---------------------------------------
118 double pdf(int n) const { return m_pdf[n];}
119 double lhf(int n) const {return m_likelihoodfraction[n];}
120
121 double probElectron() const {return m_prob[0];}
122 double probMuon() const {return m_prob[1];}
123 double probPion() const {return m_prob[2];}
124 double probKaon() const {return m_prob[3];}
125 double probProton() const {return m_prob[4];}
126 int discard() const {return m_discard;}
127 //huangb add
128 //-------------------------------------------------------
129 double pdfElectron() const {return m_pdf[0];}
130 double pdfMuon() const {return m_pdf[1];}
131 double pdfPion() const {return m_pdf[2];}
132 double pdfKaon() const {return m_pdf[3];}
133 double pdfProton() const {return m_pdf[4];}
134 // Neuron Network PID
135/* int neuronPID() const {return m_neuronPid;}
136 int neuronStat() const {return m_neuronStat;}
137 double neuronVal() const {return m_neuronVal;}
138 void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;}
139
140 void setNeuronPidCuts();
141*/
142 //tricks for nn
143 //int neuronPID() const {return m_neuronPid;}
144 int neuronStat() const {return IsPidInfoValid();}
145 double neuronVal() const {
146 if(lhf(0)>0.02) return 1.0;
147 if(lhf(1)>0.02) return 8.5;
148 if(lhf(2)>0.02) return 2.0;
149 if(lhf(3)>0.02) return 4.0;
150 if(lhf(4)>0.02) return 5.0;
151 }
152// void setCutEm_mu(double cut1, double cut2) {m_cut_em_mu[0]=cut1; m_cut_em_mu[1]=cut2;}
153 int ipmt() {
154 return m_tofcorrpid->ipmt();
155 }
156 double dt(int ipar, int ipmt) {
157 return m_tofcorrpid->dt(ipar, ipmt);
158 }
159 double dtCorr(int ipar, int ipmt) {
160 return m_tofcorrpid->dtCorr(ipar, ipmt);
161 }
162 double sigCorr(int ipar, int ipmt) {
163 return m_tofcorrpid->sigCorr(ipar, ipmt);
164 }
165 double chiCorr(int ipar, int ipmt) {
166 return m_tofcorrpid->chiCorr(ipar, ipmt);
167 }
168 double offset(int ipar) {
169 return m_tofcorrpid->offset(ipar);
170 }
171 double sigma(int ipar) {
172 return m_tofcorrpid->sigma(ipar);
173 }
174
175 protected:
176
179 // Neuron Network PID
181 private:
182
183 bool IsDedxInfoUsed() const {return ((m_pidsys & useDedx()) == useDedx());}
184 bool IsTofInfoUsed() const {return ((m_pidsys & useTof()) == useTof());}
185 bool IsTof1InfoUsed() const {return ((m_pidsys & useTof1()) == useTof1());}
186 bool IsTof2InfoUsed() const {return ((m_pidsys & useTof2()) == useTof2());}
187 bool IsTofEInfoUsed() const {return ((m_pidsys & useTofE()) == useTofE());}
188 bool IsTofQInfoUsed() const {return ((m_pidsys & useTofQ()) == useTofQ());}
189 bool IsTofCInfoUsed() const {return ((m_pidsys & useTofC()) == useTofC());}
190 bool IsTofCorrInfoUsed() const {return ((m_pidsys & useTofCorr()) == useTofCorr());}
191 bool IsEmcInfoUsed() const {return ((m_pidsys & useEmc()) == useEmc());}
192 bool IsMucInfoUsed() const {return ((m_pidsys & useMuc()) == useMuc());}
193
194 private:
195
196 DedxPID* m_dedxpid;
197 TofEPID* m_tofepid;
198 TofPID* m_tofpid;
199 TofQPID* m_tofqpid;
200 TofCPID* m_tofcpid;
201 TofCorrPID* m_tofcorrpid;
202 EmcPID* m_emcpid;
203 MucPID* m_mucpid;
204 double m_chisq[5];
205 double m_prob[5];
206 //huangb add
207 double m_pdf[5];
208 double m_likelihoodfraction[5];
209 double m_TotalLikelihood;
210
211 int m_nhitcut;
212 double m_chicut;
213 int m_ndof;
214 int m_pidsys;
215 int m_pidcase;
216 int m_method;
217 int m_discard;
218
219
220
221 private:
222 //constructor & desconstructor
223 ParticleID();
224 static ParticleID *m_pointer;
225
226};
227
228#include "ParticleID/ParticleID.icc"
229
230#endif
const Int_t n
int useTofCorr() const
int useTof2() const
int useTofE() const
int useTof() const
int useTofQ() const
int useDedx() const
int useTofC() const
int useTof1() const
int useEmc() const
int useMuc() const
double chiMuc(int n) const
double pdfEmc(int n)
int neuronPIDCalculation()
double dtCorr(int ipar, int ipmt)
Definition ParticleID.h:159
double probKaon() const
Definition ParticleID.h:124
double pdfTofC(int n)
void setMethod(const int method)
Definition ParticleID.h:94
int discard() const
Definition ParticleID.h:126
double probEmc(int n) const
double prob(int n) const
Definition ParticleID.h:114
double probTof(int n) const
double chiTof2(int n) const
int getNhitCut() const
Definition ParticleID.h:88
double chi(int n) const
Definition ParticleID.h:113
bool IsTofEInfoValid() const
double pdfProton() const
Definition ParticleID.h:133
bool IsEmcInfoValid() const
double pdfTofE(int n)
double pdfDedx(int n)
int LikelihoodCalculation()
double chiTofE(int n) const
double probTofCorr(int n) const
bool IsTofCorrInfoValid() const
double neuronVal() const
Definition ParticleID.h:145
bool IsTofCInfoValid() const
bool IsTofInfoValid() const
void identify(const int pidcase)
Definition ParticleID.h:103
double pdfPion() const
Definition ParticleID.h:131
double probMuon() const
Definition ParticleID.h:122
double probElectron() const
Definition ParticleID.h:121
int ndof() const
Definition ParticleID.h:115
void usePidSys(const int pidsys)
Definition ParticleID.h:97
double pdfTof(int n)
void setNhitCut(const int nhitcuth=5)
Definition ParticleID.h:89
double chiTofQ(int n) const
double probTofC(int n) const
bool IsTofQInfoValid() const
int particleIDCalculation()
static ParticleID * instance()
double probTofQ(int n) const
bool IsPidInfoValid() const
bool IsDedxInfoValid() const
double probDedx(int n) const
double dt(int ipar, int ipmt)
Definition ParticleID.h:156
double probPion() const
Definition ParticleID.h:123
double chiTofC(int n) const
double sigma(int ipar)
Definition ParticleID.h:171
int neuronStat() const
Definition ParticleID.h:144
double pdfMuc(int n)
double lhf(int n) const
Definition ParticleID.h:119
double chiCorr(int ipar, int ipmt)
Definition ParticleID.h:165
double chiTof1(int n) const
double pdfTofCorr(int n)
void calculate()
double chiEmc(int n) const
double pdfKaon() const
Definition ParticleID.h:132
void init()
double sigCorr(int ipar, int ipmt)
Definition ParticleID.h:162
double probProton() const
Definition ParticleID.h:125
bool IsMucInfoValid() const
double offset(int ipar)
Definition ParticleID.h:168
double pdfElectron() const
Definition ParticleID.h:129
double pdf(int n) const
Definition ParticleID.h:118
double chiTof(int n) const
double pdfMuon() const
Definition ParticleID.h:130
double probTofE(int n) const
double pdfTofQ(int n)
double chiTofCorr(int n) const
double probMuc(int n) const
double chiDedx(int n) const
double dtCorr(int ipar, int ipmt) const
Definition TofCorrPID.h:32
double chiCorr(int ipar, int ipmt) const
Definition TofCorrPID.h:34
double sigCorr(int ipar, int ipmt) const
Definition TofCorrPID.h:33
double sigma(int n) const
Definition TofCorrPID.h:27
double offset(int n) const
Definition TofCorrPID.h:26
double dt(int ipar, int ipmt) const
Definition TofCorrPID.h:31
int ipmt() const
Definition TofCorrPID.h:30