BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
Tof1PID.cxx
Go to the documentation of this file.
1#include <cmath>
2#include "TMath.h"
3
5
6#ifndef BEAN
11#else
12#include "TofHitStatus.h"
13#endif
14
15Tof1PID * Tof1PID::m_pointer = 0;
17 if(!m_pointer) m_pointer = new Tof1PID();
18 return m_pointer;
19}
20
21Tof1PID::Tof1PID():ParticleIDBase() {
22 m_pars[0]= -0.208289;
23 m_pars[1]= 1.63092;
24 m_pars[2]= -0.0733139;
25 m_pars[3]= 1.02385;
26 m_pars[4]= 0.00145052;
27 m_pars[5]= -1.72471e-06;
28 m_pars[6]= 5.92726e-10;
29 m_pars[7]= -0.0645428;
30 m_pars[8]= -0.00143637;
31 m_pars[9]= -0.133817;
32 m_pars[10]= 0.0101188;
33 m_pars[11]= -5.07622;
34 m_pars[12]= 5.31472;
35 m_pars[13]= -0.443142;
36 m_pars[14]= -12.1083;
37
38}
39
41 for(int i = 0; i < 5; i++) {
42 m_chi[i] = 99.0;
43 m_prob[i] = -1.0;
44 m_sigma[i] = 1;
45 m_offset[i] = 99.0;
46 }
47 m_chimin = 99.;
48 m_pdfmin = 99.;
49 m_ndof = 0;
50 m_mass2 = -999;
51 m_ph1 = -99;
52 m_zhit1 = -99;
53}
54
56 if(particleIDCalculation() == 0) m_ndof=1;
57}
58
60 int irc = -1;
61
62 EvtRecTrack* recTrk = PidTrk();
63 if(!(recTrk->isMdcTrackValid())) return irc;
64 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
65 double ptrk = mdcTrk->p();
66 double charge = mdcTrk->charge();
67 // double cost = cos(mdcTrk->theta());
68 if(!(recTrk->isTofTrackValid())) return irc;
69
70#ifndef BEAN
71 SmartRefVector<RecTofTrack> tofTrk = recTrk->tofTrack();
72 SmartRefVector<RecTofTrack>::iterator it;//=tofTrk.begin();
73#else
74 const std::vector<TTofTrack* >& tofTrk = recTrk->tofTrack();
75 std::vector<TTofTrack* >::const_iterator it;//=tofTrk.begin();
76#endif
77
78 TofHitStatus *hitst = new TofHitStatus;
79 std::vector<int> tof1count;
80 int goodtof1trk=0;
81 for(it = tofTrk.begin(); it!=tofTrk.end(); it++,goodtof1trk++) {
82 unsigned int st = (*it)->status();
83 hitst->setStatus(st);
84 if( !(hitst->is_barrel()) ) continue;
85 if( !(hitst->is_counter()) ) continue;
86 if( hitst->layer()==1 ) tof1count.push_back(goodtof1trk);
87 }
88 delete hitst;
89 if(tof1count.size()!=1) return irc;//not tof2 track or more than 1 tracks
90 it = tofTrk.begin()+tof1count[0];
91 double tof = (*it)->tof();
92 m_tof1 = tof;
93 // int qual = (*it)->quality();
94 // if(qual != 1) return irc;
95 int cntr = (*it)->tofID();
96 double path = ((*it)->path())*10.0;//the unit from mm to cm
97 m_path1 = path;
98 m_ph1 = (*it)->ph(); //no change
99 m_zhit1 = ((*it)->zrhit())*10;//the unit from mm to cm
100 double beta2 = path*path/velc()/velc()/tof/tof;
101 m_mass2 = ptrk * ptrk * (1/beta2 -1);
102 if ((m_mass2>20)||(m_mass2<-1)) return irc;
103 if(tof <=0 ) return irc;
104 double chitemp = 99.;
105 double pdftemp = 0;
106 double sigma_tmp= (*it)->sigma(0);
107 for(int i = 0; i < 5; i++) {
108
109 m_offset[i] = tof - (*it)->texp(i)-(*it)->toffset(i);//- offsetTof1(i, cntr, ptrk, m_zhit1, m_ph1,charge);
110 if(sigma_tmp!=0) {
111 m_sigma[i] = 1.2*sigma_tmp;
112 if(i<2) m_sigma[i]=sigma_tmp;
113 }
114 else m_sigma[i]=sigmaTof1(i, cntr,ptrk,m_zhit1, m_ph1,charge);
115 m_chi[i] = m_offset[i]/m_sigma[i];
116
117 if(fabs(m_chi[i]) < chitemp) chitemp = fabs(m_chi[i]);
118 double ppp = pdfCalculate(m_chi[i],1);
119 if(fabs(ppp) > pdftemp) pdftemp = fabs(ppp);
120 }
121 m_chimin = chitemp;
122 m_pdfmin = pdftemp;
123 if(pdftemp < pdfCalculate(pdfMinSigmaCut(),1)) return irc;
124 if(fabs(m_chimin) > chiMinCut()) return irc;
125 for(int i = 0; i < 5; i++) {
126 m_prob[i] = probCalculate(m_chi[i]*m_chi[i], 1);
127 }
128 irc = 0;
129 return irc;
130}
131
132
133//
134// TOF endcap: Correction routines
135//
136
137double Tof1PID::offsetTof1(int n, int cntr, double ptrk, double z, double ph1,double charge) {
138 double offset;
139 // double gb = ptrk/xmass(n);
140 double betagamma;
141 switch(n) {
142
143 case 0: { // Electron
144 offset = 0.0;
145 return offset;
146 }
147
148 case 1: { // Muon
149 offset = 0.0;
150 return offset;
151 }
152
153 case 2: { // Pion
154 betagamma=ptrk/139.57;
155 break;
156 }
157 case 3: { // Kaon
158 betagamma=ptrk/493.68;
159 break;
160 }
161
162 case 4: { // Proton
163 betagamma=ptrk/938.27;
164 break;
165 }
166
167 default: {
168 offset = 0.0;
169 return offset;
170 }
171 break;
172 }
173 double Q = ph1;
174 z=z/1000.0;
175 double beta = betagamma / TMath::Sqrt(1 + betagamma*betagamma);
176 double Q0 = sampleQ0(betagamma,beta);
177 double func[15]= {0.};
178 func[0]=1.;
179 func[1]=1./sqrt(Q);
180 func[2]=z/sqrt(Q);
181 func[3]=z*z/sqrt(Q);
182 func[4]=Q;
183 func[5]=Q*Q;
184 func[6]=Q*Q*Q;
185 func[7]=1./(0.84*0.84+z*z);
186 func[8]=z;
187 func[9]=z*z;
188 func[10]=z*z*z;
189 func[11]=1./sqrt(Q0);
190 func[12]=z/sqrt(Q0);
191 func[13]=z*z/sqrt(Q0);
192 func[14]=z*z*z/sqrt(Q0);
193 offset=0.;
194 for(int i=0; i<15; i++) {
195 offset+= m_pars[i]*func[i];
196 }
197
198 return offset;
199}
200
201double Tof1PID::sigmaTof1(int n, int cntr, double ptrk, double ztof, double ph,double charge) {
202 double sigma;
203 // double gb = ptrk/xmass(n);
204 double cosz = cos(ztof/1000.0);
205
206 switch(n) {
207
208 case 0: { // Electron
209 sigma = 0.132405-0.135638*cosz+0.105528*cosz*cosz;
210 break;
211 }
212
213 case 1: { // Muon
214 sigma = 0.164057 -0.199648*cosz+ 0.139481*cosz*cosz;
215 break;
216 }
217
218 case 2: { // Pion
219 sigma = 0.132943-0.0996678*cosz+0.0785578*cosz*cosz;
220 break;
221 }
222 case 3: { // Kaon
223 sigma = 0.146572 -0.124672*cosz+0.0920656*cosz*cosz;
224 break;
225 }
226
227 case 4: { // Proton
228 sigma = 0.1513 -0.0806081*cosz+0.0607409*cosz*cosz;
229 break;
230 }
231
232 default:
233 sigma = 0.100;
234 break;
235 }
236 sigma = 0.110;
237 //sigma = 1.0;
238 return sigma;
239}
240
241
242double Tof1PID::sampleQ0(double betagamma,double beta) {
243 double val = 0.261/ TMath::Power(beta, 1.96) *( 5.43- TMath::Power(beta, 1.96) -TMath::Log(1.12 + TMath::Power(1/betagamma, 0.386)));
244 return val*100.;
245}
double cos(const BesAngle a)
Definition: BesAngle.h:213
const Int_t n
const int charge() const
Definition: DstMdcTrack.h:53
const double p() const
Definition: DstMdcTrack.h:58
SmartRefVector< RecTofTrack > tofTrack()
Definition: EvtRecTrack.h:57
bool isTofTrackValid()
Definition: EvtRecTrack.h:46
bool isMdcTrackValid()
Definition: EvtRecTrack.h:43
RecMdcTrack * mdcTrack()
Definition: EvtRecTrack.h:53
double chiMinCut() const
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
double pdfMinSigmaCut() const
static std::string path
double sampleQ0(double betagamma, double beta)
Definition: Tof1PID.cxx:242
double sigma(int n) const
Definition: Tof1PID.h:27
double offsetTof1(int n, int cntr, double ptrk, double ztof, double m_ph1, double charge)
Definition: Tof1PID.cxx:137
int particleIDCalculation()
Definition: Tof1PID.cxx:59
void calculate()
Definition: Tof1PID.cxx:55
void init()
Definition: Tof1PID.cxx:40
static Tof1PID * instance()
Definition: Tof1PID.cxx:16
double sigmaTof1(int n, int cntr, double ptrk, double ztof, double m_ph1, double charge)
Definition: Tof1PID.cxx:201
double offset(int n) const
Definition: Tof1PID.h:26
double ph1() const
Definition: Tof1PID.h:30
bool is_barrel() const
Definition: TofHitStatus.h:26
unsigned int layer() const
Definition: TofHitStatus.h:28
void setStatus(unsigned int status)
bool is_counter() const
Definition: TofHitStatus.h:24