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_sigma[i] = 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_sigma[i] = p0+p1/0.05; }
194 else { m_sigma[i] = p0+p1/
p[i]; }
195 }
196 m_chiCorr[i][0] = m_dtCorr[i][0]/m_sigCorr[i][0];
197 }
198 }
199 }
200 if( counter && cluster ) {
202 for( unsigned int i=0; i<5; i++ ) {
203 if( ((*it)->texp(i))>0.0 ) {
204 if( barrel ) {
205 m_offset[i] = m_dtCorr[i][
ipmt];
206 m_sigma[i] = m_sigCorr[i][
ipmt];
207 }
208 else {
209 m_offset[i] = m_dtCorr[i][0];
210 m_sigma[i] = m_sigCorr[i][0];
211 }
212 }
213 }
214 }
215 }
216 else {
217 if( counter ) {
219 for( unsigned int i=0; i<5; i++ ) {
220 double offset = (*it)->toffset(i);
221 double texp = (*it)->texp(i);
222 if( texp<0.0 ) continue;
224 if( barrel ) {
227 m_sigCorr[i][
ipmt] =
sigmaTof( i,
charge, barrel, layer+3, &tofid[0], &zrhit[0], betaGamma[i] );
228 m_chiCorr[i][
ipmt] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
229 }
230 else {
231 if( ismrpc ) {
234
235 int strip = (*it)->strip();
236 double p0, p1;
237 if( strip<0 || strip>11 ) { m_sigma[i] = 0.065; }
238 else {
239 if( strip==0 ) { p0=0.16; p1=0.0; }
240 else if( strip==1 ) { p0=0.051094; p1=0.019467; }
241 else if( strip==2 ) { p0=0.056019; p1=0.012964; }
242 else if( strip==3 ) { p0=0.043901; p1=0.015933; }
243 else if( strip==4 ) { p0=0.049750; p1=0.010473; }
244 else if( strip==5 ) { p0=0.048345; p1=0.008545; }
245 else if( strip==6 ) { p0=0.046518; p1=0.009038; }
246 else if( strip==7 ) { p0=0.048803; p1=0.007251; }
247 else if( strip==8 ) { p0=0.047523; p1=0.008434; }
248 else if( strip==9 ) { p0=0.042187; p1=0.010307; }
249 else if( strip==10 ) { p0=0.050337; p1=0.005951; }
250 else if( strip==11 ) { p0=0.054740; p1=0.005629; }
251 if(
p[i]<0.05 ) { m_sigma[i] = p0+p1/0.05; }
252 else { m_sigma[i] = p0+p1/
p[i]; }
253 }
254 m_chiCorr[i][0] = m_dtCorr[i][0]/m_sigCorr[i][0];
255 }
256 else {
257 cout << "ParticleID: TofCorr::particleIDCalculation: Endcap Scintillator TOF have more than one end!!!" << endl;
258 }
259 }
260 }
261 if( cluster ) {
263 for( unsigned int i=0; i<5; i++ ) {
264 if( ((*it)->texp(i))>0.0 ) {
265 if( barrel ) {
266 m_offset[i] = m_dtCorr[i][
ipmt];
267 m_sigma[i] = m_sigCorr[i][
ipmt];
268 }
269 else {
270 m_offset[i] = m_dtCorr[i][0];
271 m_sigma[i] = m_sigCorr[i][0];
272 }
273 }
274 }
275 }
276 else {
278 }
279 }
280 else {
281 if( cluster ) {
283 for( unsigned int i=0; i<5; i++ ) {
284 double offset = (*it)->toffset(i);
285 double texp = (*it)->texp(i);
286 if( texp<0.0 ) continue;
289 m_dtCorr[i][
ipmt] =
offsetTof( i, tofid[0], tofid[1], zrhit[0], zrhit[1], betaGamma[i],
charge,
dt );
291 m_chiCorr[i][
ipmt] = m_dtCorr[i][
ipmt]/m_sigCorr[i][
ipmt];
292 }
293 if( signal[0] && signal[1] ) {
294 m_ipmt = 6;
295 for( unsigned int i=0; i<5; i++ ) {
296 m_offset[i] = m_dtCorr[i][
ipmt];
297 m_sigma[i] = m_sigCorr[i][
ipmt];
298 }
299 }
300 else if( signal[0] && !signal[1] ) {
301 m_ipmt = 4;
302 for( unsigned int i=0; i<5; i++ ) {
303 m_offset[i] = m_dtCorr[i][4];
304 m_sigma[i] = m_sigCorr[i][4];
305 }
306 }
307 else if( !signal[0] && signal[1] ) {
308 m_ipmt = 5;
309 for( unsigned int i=0; i<5; i++ ) {
310 m_offset[i] = m_dtCorr[i][5];
311 m_sigma[i] = m_sigCorr[i][5];
312 }
313 }
314 else return irc;
315 }
316 }
317 }
318 }
319
320
321 double pdftemp = 0;
322 for( unsigned int i=0; i<5; i++ ) {
323 m_chi[i] = m_offset[i]/m_sigma[i];
324 if( m_chi[i]<0. && m_chi[i]>m_chimin ) { m_chimin = m_chi[i]; }
325 if( m_chi[i]>0. && m_chi[i]<m_chimax ) { m_chimax = m_chi[i]; }
327 if( fabs(ppp) > pdftemp) { pdftemp = fabs(ppp); }
328 }
329
330 m_pdfmin = pdftemp;
332 if( ( m_chimin > -90.0 && (0-m_chimin)>
chiMinCut() ) && ( m_chimax < 90.0 && m_chimax>
chiMaxCut() ) )
return irc;
333 for(int i = 0; i < 5; i++) {
335 }
336
337 irc = 0;
338 return irc;
339}
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)