BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
SimplePIDSvc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: PID for psi(3770) data *
3 * Package: SimplePIDSvc *
4 * File: SimplePIDSvc.h $v8 2013/11/12$ *
5 * Authors: *
6 * Chunlei LIU, chl56@andrew.cmu.edu *
7 * Tian MA, mat@ihep.ac.cn *
8 * *
9 *****************************************************************************/
10
11#ifndef SIMPLE_PID_SVC_H
12#define SIMPLE_PID_SVC_H
13
14#include "GaudiKernel/IDataProviderSvc.h"
15#include "GaudiKernel/Service.h"
16
17#include "EvtRecEvent/EvtRecTrack.h"
18#include "SimplePIDSvc/ISimplePIDSvc.h"
19#include "TFile.h"
20#include "TH1D.h"
21#include "TH2D.h"
22
23class IDataProviderSvc;
24template <class TYPE> class CnvFactory;
25
26// class SimplePIDSvc : public Service, virtual public ISimplePIDSvc
27class SimplePIDSvc : public extends<Service, ISimplePIDSvc> {
28 friend class CnvFactory<SimplePIDSvc>;
29
30public:
31 SimplePIDSvc( const std::string& name, ISvcLocator* svcLoc );
32 virtual ~SimplePIDSvc();
33
34 virtual StatusCode initialize();
35 virtual StatusCode finalize();
36 // virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
37
38 void setdedxminchi( double x ) { m_dedx_chi_cut = x; }
39 void settofminchi( double x ) { m_tof_chi_cut = x; }
40 void seteidratio( double x ) { m_eid_ratio = x; }
41 void preparePID( EvtRecTrack* track );
42 bool iselectron( bool emc = true );
43 bool ispion();
44 bool iskaon();
45 // probabilities (dE/dx + TOF)
46 double probElectron() { return m_prob[0]; }
47 double probMuon() { return m_prob[1]; }
48 double probPion() { return m_prob[2]; }
49 double probKaon() { return m_prob[3]; }
50 double probProton() { return m_prob[4]; }
51
52 double getdEdxChi( int i ) { return m_dedx_chi[i]; }
53 double getTOFChi( int i ) { return m_tof_chi[i]; }
54 double getEmcLikelihood( int i ) { return m_emc_likelihood[i]; }
55 double getChi2( int i );
56
57 // get TOF&EMC info for internal test & check
58 double getTofDt( int m, int n ) { return m_tof_dt[m][n]; }
59 double getTofPh( int n ) { return m_tof_ph[n]; }
60 double getTofZR( int n ) { return m_tof_zr[n]; }
61 int getTofCounter( int n ) { return m_tof_counter[n]; }
62 int getTofBarrel() { return m_tof_barrel; }
63 double getEmcE() { return m_emc_e; }
64 double getEmcE13() { return m_emc_e13; }
65 double getEmcE35() { return m_emc_e35; }
66 double getEmcLatMoment() { return m_emc_lat; }
67 double getEmcSecMoment() { return m_emc_sec; }
68 double getElectronLikelihood() { return m_lh_electron; }
69
70private:
71 int getRunIdx( int run_no );
72 int findBin( double* a, int length, double value );
73 void loadDedxInfo( EvtRecTrack* track );
74 void loadTOFInfo( EvtRecTrack* track );
75 void loadEMCInfo( EvtRecTrack* track );
76 void loadHistogram();
77 void dedxCorrection();
78 void tofBarrelCorrection();
79 void tofEndcapCorrection();
80 void calprob();
81 bool calEMCLikelihood();
82
83 void dedxSecondCorrection();
84 void tofBarrelSecondCorrection();
85 void tofEndcapSecondCorrection();
86 void loadSecondPar();
87
88 // variables in job_options
89 bool m_dedx_corr;
90 bool m_tof_corr;
91 double m_dedx_chi_cut;
92 double m_tof_chi_cut;
93 double m_eid_ratio;
94
95 IDataProviderSvc* eventSvc_;
96 int m_run; // run number
97
98 bool m_dedx_only[5];
99 double m_p[5];
100 double m_cost[5];
101 int m_charge[5];
102 double m_betagamma[5];
103
104 // TOF info
105 double m_tof_dt[8][5];
106 double m_tof_ph[8];
107 double m_tof_zr[2];
108 int m_tof_counter[2];
109 volatile int m_tof_barrel;
110 // EMC info
111 double m_emc_e;
112 double m_emc_eop[5];
113 double m_emc_e13;
114 double m_emc_e35;
115 double m_emc_sec;
116 double m_emc_lat;
117
118 // chisquares & probilites for each hypothesis
119 double m_dedx_chi[5];
120 double m_tof_chi[5];
121 double m_emc_likelihood[5];
122 double m_prob[5];
123 double m_lh_electron;
124
125 // dedx correction histogram
126 // (p, m)
127 // p: 0-electron 1-k,pi
128 // m: 0-10 data, 1-11 data, 2-10 mc, 3-11 mc
129 TH2D* h_dedx_p_offset[2][4];
130 TH2D* h_dedx_p_sigma[2][4];
131 TH2D* h_dedx_m_offset[2][4];
132 TH2D* h_dedx_m_sigma[2][4];
133
134 // tof barrel correction histogram
135 // (p, m, n)
136 // p: 0-electron 1-k,pi
137 // m: 0-10 data, 1-11 data, 2-10 mc, 3-11 mc
138 // n: 0-inner east, 1-inner west, 2-outer east, 3-outer west
139 TH1D* h_tof_p_q_offset[2][4][4];
140 TH1D* h_tof_p_q_sigma[2][4][4];
141 TH1D* h_tof_m_q_offset[2][4][4];
142 TH1D* h_tof_m_q_sigma[2][4][4];
143 TH2D* h_tof_p_bgcost_offset[2][4][4];
144 TH2D* h_tof_p_bgcost_sigma[2][4][4];
145 TH2D* h_tof_m_bgcost_offset[2][4][4];
146 TH2D* h_tof_m_bgcost_sigma[2][4][4];
147
148 TH2D* h_tof_p_wgt[2][4][15][5];
149 TH2D* h_tof_m_wgt[2][4][15][5];
150 TH2D* h_tof_p_final_offset[2][4][15];
151 TH2D* h_tof_p_final_sigma[2][4][15];
152 TH2D* h_tof_m_final_offset[2][4][15];
153 TH2D* h_tof_m_final_sigma[2][4][15];
154
155 // tof endcap correction histogram
156 // (p, m, n)
157 // p: 0-electron 1-k,pi
158 // m: 0-10 data, 1-11 data, 2-10 mc, 3-11 mc
159 // n: 0-east, 1-west
160 TH1D* h_tofec_p_q_offset[2][4][2];
161 TH1D* h_tofec_p_q_sigma[2][4][2];
162 TH1D* h_tofec_m_q_offset[2][4][2];
163 TH1D* h_tofec_m_q_sigma[2][4][2];
164 TH1D* h_tofec_p_bg_offset[2][4][2];
165 TH1D* h_tofec_p_bg_sigma[2][4][2];
166 TH1D* h_tofec_m_bg_offset[2][4][2];
167 TH1D* h_tofec_m_bg_sigma[2][4][2];
168 TH1D* h_tofec_p_cost_offset[2][4][2];
169 TH1D* h_tofec_p_cost_sigma[2][4][2];
170 TH1D* h_tofec_m_cost_offset[2][4][2];
171 TH1D* h_tofec_m_cost_sigma[2][4][2];
172
173 // emc histogram
174 // (p, q, m, n)
175 // p: 0-electron, 1-pion, 2-kaon
176 // q: 0-10 data, 1-11 data, 2-10 mc, 3-11 mc
177 // m: 15 momentum-bin
178 // n: 25 cost-bin
179 TH1D* h_emc_ep[3][4][15][25];
180 TH1D* h_emc_e35[3][4][15][25];
181
182 // TFiles
183 TFile* f_dedx[2][4];
184 TFile* f_tof_q[2][4];
185 TFile* f_tof_bgcost[2][4];
186 TFile* f_tof_wgt[2][4];
187 TFile* f_tof_final[2][4];
188 TFile* f_tofec_q[2][4];
189 TFile* f_tofec_bg[2][4];
190 TFile* f_tofec_cost[2][4];
191 TFile* f_emc[3][4];
192
193 // Extended from 6 to 9 by Yijia Zeng for round 16 data
194 // Extended from 9 to 12 by Yijia Zeng for round 17 data
195 double m_gaussion_mean[12][4][10];
196 double m_gaussion_sigma[12][4][10];
197 double m_gaussion_sigmab[12][4][10];
198};
199
200#endif // SIMPLE_PID_SVC_H
const Int_t n
NTuple::Item< double > m_p
double probPion()
void settofminchi(double x)
int getTofCounter(int n)
int getTofBarrel()
SimplePIDSvc(const std::string &name, ISvcLocator *svcLoc)
double probProton()
double getdEdxChi(int i)
virtual ~SimplePIDSvc()
void seteidratio(double x)
double getEmcE()
double getEmcSecMoment()
double getChi2(int i)
void preparePID(EvtRecTrack *track)
void setdedxminchi(double x)
double getTofPh(int n)
double probMuon()
double getEmcLikelihood(int i)
virtual StatusCode initialize()
double getEmcE35()
double getEmcLatMoment()
double getTofDt(int m, int n)
bool iselectron(bool emc=true)
double getEmcE13()
double getElectronLikelihood()
double getTofZR(int n)
virtual StatusCode finalize()
double probKaon()
double getTOFChi(int i)
double probElectron()