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