BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
Tof2PID.cxx
Go to the documentation of this file.
1#include <cmath>
2#include "TMath.h"
3
4#include "ParticleID/Tof2PID.h"
5
6#ifndef BEAN
7#include "EvtRecEvent/EvtRecTrack.h"
8#include "MdcRecEvent/RecMdcTrack.h"
9#include "TofRecEvent/RecTofTrack.h"
10#include "DstEvent/TofHitStatus.h"
11#else
12#include "TofHitStatus.h"
13#endif
14
15Tof2PID * Tof2PID::m_pointer = 0;
16
18 if(!m_pointer) m_pointer = new Tof2PID();
19 return m_pointer;
20}
21
22
23Tof2PID::Tof2PID():ParticleIDBase() {
24 m_pars[0]=-0.237207;
25 m_pars[1]= 1.90436;
26 m_pars[2]= -0.210625;
27 m_pars[3]= 0.664667;
28 m_pars[4]= 0.00165226;
29 m_pars[5]= -1.86503e-06;
30 m_pars[6]= 6.07045e-10;
31 m_pars[7]=-0.0882228;
32 m_pars[8]= 0.0125708;
33 m_pars[9]= -0.117157;
34 m_pars[10]= 0.00252878;
35 m_pars[11]= 0.254343;
36 m_pars[12]= -5.74886;
37 m_pars[13]= 5.20507;
38 m_pars[14]= 1.86515;
39
40}
41
43
44 for(int i = 0; i < 5; i++) {
45 m_chi[i] = 99.0;
46 m_prob[i] = -1.0;
47 m_sigma[i] = 1.0;
48 m_offset[i] =99.0;
49 }
50 m_chimin = 99.;
51 m_pdfmin =99.;
52 m_ndof = 0;
53 m_mass2 = -999;
54 m_ph2 = -99;
55 m_zhit2 = -99;
56}
57
59 if(particleIDCalculation() == 0) m_ndof=1;
60}
61
63 int irc = -1;
64 EvtRecTrack* recTrk = PidTrk();
65 if(!(recTrk->isMdcTrackValid())) return irc;
66 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
67
68 double ptrk = mdcTrk->p();
69 // double cost = cos(mdcTrk->theta());
70 double charge = mdcTrk->charge();
71
72 if(!(recTrk->isTofTrackValid())) return irc;
73
74#ifndef BEAN
75 SmartRefVector<RecTofTrack> tofTrk = recTrk->tofTrack();
76 SmartRefVector<RecTofTrack>::iterator it;//=tofTrk.begin();
77#else
78 const std::vector<TTofTrack* >& tofTrk = recTrk->tofTrack();
79 std::vector<TTofTrack* >::const_iterator it;//=tofTrk.begin();
80#endif
81
82 TofHitStatus *hitst = new TofHitStatus;
83 std::vector<int> tof2count;
84 int goodtof2trk=0;
85 for(it = tofTrk.begin(); it!=tofTrk.end(); it++,goodtof2trk++) {
86 unsigned int st = (*it)->status();
87 hitst->setStatus(st);
88
89 if( !(hitst->is_barrel()) ) continue;
90 if( !(hitst->is_counter()) ) continue;
91 if( hitst->layer()==2 ) tof2count.push_back(goodtof2trk);
92 }
93 delete hitst;
94
95 if(tof2count.size()!=1) return irc;//not tof2 track or more than 1 tracks
96 it = tofTrk.begin()+tof2count[0];
97 double tof = (*it)->tof();
98 m_tof2 = tof;
99
100 if(tof <=0 ) return irc;
101 // int qual = (*it)->quality();
102 // if(qual != 1) return irc;
103 int cntr = (*it)->tofID();
104 double path = ((*it)->path())*10.0;//the unit from mm to cm
105
106 m_path2 = path;
107 // m_path2 = path;
108 // fix the bugs the 6.0.0, He K.L.
109 // double path = tofTrk->getPath1();
110 //
111 m_ph2 = (*it)->ph();
112 m_zhit2 = ((*it)->zrhit())*10; //the unit from mm to cm
113
114 double beta2 = path*path/velc()/velc()/tof/tof;
115 m_mass2 = ptrk * ptrk * (1/beta2 -1);
116 if ((m_mass2>20)||(m_mass2<-1)) return irc;
117
118 double chitemp = 99.;
119 double pdftemp = 0;
120 double sig_tmp = (*it)->sigma(0);
121 for(int i = 0; i < 5; i++) {
122 m_offset[i] = tof - (*it)->texp(i)-(*it)->toffset(i);//- offsetTof1(i, cntr, ptrk, m_zhit1, m_ph1,charge);
123 if(sig_tmp!=0) {
124 m_sigma[i] = 1.2*sig_tmp;
125 if(i<2) m_sigma[i]=sig_tmp;
126 }
127 else m_sigma[i]= sigmaTof2(i, cntr,ptrk,m_zhit2, m_ph2,charge);
128 m_chi[i] = m_offset[i]/m_sigma[i];
129 if(fabs(m_chi[i]) < chitemp) chitemp = fabs(m_chi[i]);
130 double ppp = pdfCalculate(m_chi[i],1);
131 if(fabs(ppp) > pdftemp) pdftemp = fabs(ppp);
132 }
133 // if(ptrk<0.65) m_chi[2]=m_chi[3];
134 m_chimin = chitemp;
135 m_pdfmin = pdftemp;
136 if(pdftemp < pdfCalculate(pdfMinSigmaCut(),1)) return irc;
137 if(fabs(m_chimin) > chiMinCut()) return irc;
138
139 // calculate prob
140
141 for(int i = 0; i < 5; i++) {
142 m_prob[i] = probCalculate(m_chi[i]*m_chi[i], 1);
143 }
144 irc = 0;
145 return irc;
146}
147
148
149//
150// TOF endcap: Correction routines
151//
152
153double Tof2PID::offsetTof2(int n, int cntr, double ptrk, double z, double ph,double charge) {
154 double offset;
155 // double gb = ptrk/xmass(n);
156 double betagamma;
157 switch(n) {
158
159 case 0: { // Electron
160 offset = 0.0;
161 return offset;
162 }
163
164 case 1: { // Muon
165 offset = 0.0;
166 return offset;
167 }
168
169 case 2: { // Pion
170 betagamma=ptrk/139.57;
171 break;
172 }
173 case 3: { // Kaon
174 betagamma=ptrk/493.68;
175 break;
176 }
177
178 case 4: { // Proton
179 betagamma=ptrk/938.27;
180 break;
181 }
182
183 default: {
184 offset = 0.0;
185 return offset;
186 }
187 break;
188 }
189 z=z/1000.0;
190 double Q = ph;
191 double beta = betagamma / TMath::Sqrt(1 + betagamma*betagamma);
192 double Q0 = sampleQ0(betagamma,beta);
193 double func[15]= {0.};
194 func[0]=1.;
195 func[1]=1./sqrt(Q);
196 func[2]=z/sqrt(Q);
197 func[3]=z*z/sqrt(Q);
198 func[4]=Q;
199 func[5]=Q*Q;
200 func[6]=Q*Q*Q;
201 func[7]=1./(0.89*0.89+z*z);
202 func[8]=z;
203 func[9]=z*z;
204 func[10]=z*z*z;
205 func[11]=1./sqrt(Q0);
206 func[12]=z/sqrt(Q0);
207 func[13]=z*z/sqrt(Q0);
208 func[14]=z*z*z/sqrt(Q0);
209 offset=0.;
210 for(int i=0; i<15; i++) {
211 offset+= m_pars[i]*func[i];
212 }
213
214 return offset;
215}
216
217double Tof2PID::sigmaTof2(int n, int cntr, double ptrk, double ztof, double ph,double charge) {
218 double sigma;
219 // double gb = ptrk/xmass(n);
220 double cosz = cos(ztof/1000.0);
221 // double phtemp=ph;
222 switch(n) {
223
224 case 0: { // Electron
225 sigma = 0.115816 -0.0933215*cosz+ 0.0788252*cosz*cosz;
226 break;
227 }
228
229 case 1: { // Muon
230 sigma = 0.121536 -0.0935898*cosz+0.0748771*cosz*cosz;
231 break;
232 }
233
234 case 2: { // Pion
235 sigma = 0.106882-0.0147375*cosz+0.027491*cosz*cosz;
236 break;
237 }
238 case 3: { // Kaon
239 sigma =0.106882 -0.0147375*cosz +0.027491 *cosz*cosz;
240 break;
241 }
242
243 case 4: { // Proton
244 sigma = 0.168489 -0.131762*cosz+ 0.105708*cosz*cosz;
245 break;
246 }
247
248 default:
249 sigma = 0.100;
250 break;
251 }
252 sigma = 0.110;
253 //sigma = 1.0;
254 return sigma;
255}
256
257
258double Tof2PID::sampleQ0(double betagamma,double beta) {
259 double p1 = 0.261;
260 double p2 = 5.43;
261 double p3 = 1.12;
262 double p4 = 1.96;
263 double p5 = 0.386;
264 double val = p1 / TMath::Power(beta, p4) *
265 ( p2- TMath::Power(beta, p4) -
266 TMath::Log(p3 + TMath::Power(1/betagamma, p5)));
267
268 return val*100.;
269}
270
const Int_t n
double cos(const BesAngle a)
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
double sigmaTof2(int n, int cntr, double ptrk, double ztof, double m_ph2, double charge)
Definition: Tof2PID.cxx:217
static Tof2PID * instance()
Definition: Tof2PID.cxx:17
void init()
Definition: Tof2PID.cxx:42
double sampleQ0(double betagamma, double beta)
Definition: Tof2PID.cxx:258
int particleIDCalculation()
Definition: Tof2PID.cxx:62
void calculate()
Definition: Tof2PID.cxx:58
double offsetTof2(int n, int cntr, double ptrk, double ztof, double m_ph2, double charge)
Definition: Tof2PID.cxx:153
void setStatus(unsigned int status)