67 {
68 int irc=-1;
69
75
76#ifndef BEAN
77 SmartRefVector<RecTofTrack> tofTrk = recTrk->
tofTrack();
78 SmartRefVector<RecTofTrack>::iterator it;
79#else
80 const std::vector<TTofTrack* >& tofTrk = recTrk->
tofTrack();
81 std::vector<TTofTrack* >::const_iterator it;
82#endif
83
86
87 double p[5], betaGamma[5];
89 for( int i=0; i<5; i++ ) {
90 if( i==0 ) {
92 }
93 else if( i==1 ) {
95 }
96 else if( i==2 ) {
98 }
99 else if( i==3 ) {
101 }
102 else if( i==4 ) {
104 }
105#ifndef BEAN
106 HepLorentzVector ptrk = kalTrk->
p4();
107#else
108 HepLorentzVector ptrk = kalTrk->
p4(
xmass(i) );
109#endif
111 betaGamma[i] =
p[i]/
xmass(i);
112 }
113
114 double zrhit[2];
118
119 int tofid[2] = { -9, -9 };
120
121 m_ipmt = -1;
122 bool readFile = false;
123 bool signal[2] = { false, false };
125 for( it = tofTrk.begin(); it!=tofTrk.end(); it++ ) {
126 unsigned int st = (*it)->status();
128 if( hitst->
is_raw() )
return irc;
130 bool ismrpc = hitst->
is_mrpc();
131 if( !barrel && !ismrpc ) { zrhit[0] = extTrk->
tof1Position().rho(); }
135 int layer = hitst->
layer();
136 tofid[layer-1] = (*it)->tofID();
138 double tof = (*it)->tof();
139 unsigned int ipmt = 0;
140 if( readout ) {
141
142
143 if( barrel ) {
ipmt = ( ( st & 0xC0 ) >> 5 ) + ( ( ( st ^ 0x20 ) & 0x20 ) >> 5 ) - 2; }
144 else {
145 if( !ismrpc ) {
146 if( tofid[0]<=47 ) {
ipmt = 7; }
148 }
149 else {
150 if( tofid[0]<=35 ) {
ipmt = 7; }
152 }
153 }
154
155 for( unsigned int i=0; i<5; i++ ) {
156 double offset = (*it)->toffset(i);
157 double texp = (*it)->texp(i);
158 if( texp<0.0 ) continue;
160 if( barrel ) {
164 m_chiCorr[i][
ipmt] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
165 }
166 else {
167 if( !ismrpc ) {
170 m_sigCorr[i][0] =
sigmaTof( i,
charge, barrel,
ipmt, &tofid[0], &zrhit[0], betaGamma[i] );
171 m_chiCorr[i][0] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
172 }
173 else {
176
177 int strip = (*it)->strip();
178 double p0, p1;
179 if( strip<0 || strip>11 ) { m_sigCorr[i][0] = 0.065; }
180 else {
181 if( strip==0 ) { p0=0.16; p1=0.0; }
182 else if( strip==1 ) { p0=0.051094; p1=0.019467; }
183 else if( strip==2 ) { p0=0.056019; p1=0.012964; }
184 else if( strip==3 ) { p0=0.043901; p1=0.015933; }
185 else if( strip==4 ) { p0=0.049750; p1=0.010473; }
186 else if( strip==5 ) { p0=0.048345; p1=0.008545; }
187 else if( strip==6 ) { p0=0.046518; p1=0.009038; }
188 else if( strip==7 ) { p0=0.048803; p1=0.007251; }
189 else if( strip==8 ) { p0=0.047523; p1=0.008434; }
190 else if( strip==9 ) { p0=0.042187; p1=0.010307; }
191 else if( strip==10 ) { p0=0.050337; p1=0.005951; }
192 else if( strip==11 ) { p0=0.054740; p1=0.005629; }
193 if(
p[i]<0.05 ) { m_sigCorr[i][0] = p0+p1/0.05; }
194 else { m_sigCorr[i][0] = p0+p1/
p[i]; }
195 }
196 if( i==4 ) { m_sigCorr[i][0] = 1.5*m_sigCorr[i][0]; }
197 m_chiCorr[i][0] = m_dtCorr[i][0]/m_sigCorr[i][0];
198 }
199 }
200 }
201 if( counter && cluster ) {
203 for( unsigned int i=0; i<5; i++ ) {
204 if( ((*it)->texp(i))>0.0 ) {
205 if( barrel ) {
206 m_offset[i] = m_dtCorr[i][
ipmt];
207 m_sigma[i] = m_sigCorr[i][
ipmt];
208 }
209 else {
210 m_offset[i] = m_dtCorr[i][0];
211 m_sigma[i] = m_sigCorr[i][0];
212 }
213 }
214 }
215 }
216 }
217 else {
218 if( counter ) {
220 for( unsigned int i=0; i<5; i++ ) {
221 double offset = (*it)->toffset(i);
222 double texp = (*it)->texp(i);
223 if( texp<0.0 ) continue;
225 if( barrel ) {
228 m_sigCorr[i][
ipmt] =
sigmaTof( i,
charge, barrel, layer+3, &tofid[0], &zrhit[0], betaGamma[i] );
229 m_chiCorr[i][
ipmt] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
230 }
231 else {
232 if( ismrpc ) {
235
236 int strip = (*it)->strip();
237 double p0, p1;
238 if( strip<0 || strip>11 ) { m_sigCorr[i][0] = 0.065; }
239 else {
240 if( strip==0 ) { p0=0.16; p1=0.0; }
241 else if( strip==1 ) { p0=0.051094; p1=0.019467; }
242 else if( strip==2 ) { p0=0.056019; p1=0.012964; }
243 else if( strip==3 ) { p0=0.043901; p1=0.015933; }
244 else if( strip==4 ) { p0=0.049750; p1=0.010473; }
245 else if( strip==5 ) { p0=0.048345; p1=0.008545; }
246 else if( strip==6 ) { p0=0.046518; p1=0.009038; }
247 else if( strip==7 ) { p0=0.048803; p1=0.007251; }
248 else if( strip==8 ) { p0=0.047523; p1=0.008434; }
249 else if( strip==9 ) { p0=0.042187; p1=0.010307; }
250 else if( strip==10 ) { p0=0.050337; p1=0.005951; }
251 else if( strip==11 ) { p0=0.054740; p1=0.005629; }
252 if(
p[i]<0.05 ) { m_sigCorr[i][0] = p0+p1/0.05; }
253 else { m_sigCorr[i][0] = p0+p1/
p[i]; }
254 }
255 if( i==4 ) { m_sigCorr[i][0] = 1.5*m_sigCorr[i][0]; }
256 m_chiCorr[i][0] = m_dtCorr[i][0]/m_sigCorr[i][0];
257 }
258 else {
259 cout << "ParticleID: TofCorr::particleIDCalculation: Endcap Scintillator TOF have more than one end!!!" << endl;
260 }
261 }
262 }
263 if( cluster ) {
265 for( unsigned int i=0; i<5; i++ ) {
266 if( ((*it)->texp(i))>0.0 ) {
267 if( barrel ) {
268 m_offset[i] = m_dtCorr[i][
ipmt];
269 m_sigma[i] = m_sigCorr[i][
ipmt];
270 }
271 else {
272 m_offset[i] = m_dtCorr[i][0];
273 m_sigma[i] = m_sigCorr[i][0];
274 }
275 }
276 }
277 }
278 else {
280 }
281 }
282 else {
283 if( cluster ) {
285 for( unsigned int i=0; i<5; i++ ) {
286 double offset = (*it)->toffset(i);
287 double texp = (*it)->texp(i);
288 if( texp<0.0 ) continue;
291 m_dtCorr[i][
ipmt] =
offsetTof( i, tofid[0], tofid[1], zrhit[0], zrhit[1], betaGamma[i],
charge,
dt );
293 m_chiCorr[i][
ipmt] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
294 }
295 if( signal[0] && signal[1] ) {
296 m_ipmt = 6;
297 for( unsigned int i=0; i<5; i++ ) {
298 m_offset[i] = m_dtCorr[i][
ipmt];
299 m_sigma[i] = m_sigCorr[i][
ipmt];
300 }
301 }
302 else if( signal[0] && !signal[1] ) {
303 m_ipmt = 4;
304 for( unsigned int i=0; i<5; i++ ) {
305 m_offset[i] = m_dtCorr[i][4];
306 m_sigma[i] = m_sigCorr[i][4];
307 }
308 }
309 else if( !signal[0] && signal[1] ) {
310 m_ipmt = 5;
311 for( unsigned int i=0; i<5; i++ ) {
312 m_offset[i] = m_dtCorr[i][5];
313 m_sigma[i] = m_sigCorr[i][5];
314 }
315 }
316 else return irc;
317 }
318 }
319 }
320 }
321 delete hitst;
322
323 double pdftemp = 0;
324 for( unsigned int i=0; i<5; i++ ) {
325 m_chi[i] = m_offset[i]/m_sigma[i];
326 if( m_chi[i]<0. && m_chi[i]>m_chimin ) { m_chimin = m_chi[i]; }
327 if( m_chi[i]>0. && m_chi[i]<m_chimax ) { m_chimax = m_chi[i]; }
329 if( fabs(ppp) > pdftemp) { pdftemp = fabs(ppp); }
330 }
331
332 m_pdfmin = pdftemp;
334 if( ( m_chimin > -90.0 && (0-m_chimin)>
chiMinCut() ) && ( m_chimax < 90.0 && m_chimax>
chiMaxCut() ) )
return irc;
335 for(int i = 0; i < 5; i++) {
337 }
338
339 irc = 0;
340 return irc;
341}
const Hep3Vector tof1Position() const
const Hep3Vector tof2Position() const
static void setPidType(PidType pidType)
const HepLorentzVector p4() const
bool isMdcKalTrackValid()
SmartRefVector< RecTofTrack > tofTrack()
RecMdcKalTrack * mdcKalTrack()
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
double offset(int n) const
double sigmaTof(unsigned int ispecies, int charge, bool barrel, unsigned int ipmt, int tofid[2], double zrhit[2], double betaGamma)
double offsetTof(unsigned int ispecies, bool barrel, unsigned int ipmt, double betaGamma, int charge, double zrhit, double dt)
bool correlationCheck(unsigned int ipmt)
unsigned int layer() const
void setStatus(unsigned int status)