5 |
* WM dec 2008: Description of "GetdEdx" changed |
* WM dec 2008: Description of "GetdEdx" changed |
6 |
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
7 |
* PMTs higher than the saturation limit are not used for dEdx |
* PMTs higher than the saturation limit are not used for dEdx |
8 |
|
* WM apr 2009: bug found by Nicola in method "GetPaddlePlane" |
9 |
*/ |
*/ |
10 |
|
|
11 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
12 |
using namespace std; |
using namespace std; |
13 |
ClassImp(ToFPMT); |
ClassImp(ToFPMT); |
14 |
|
ClassImp(ToFdEdx); |
15 |
|
ClassImp(ToFGeom); |
16 |
ClassImp(ToFTrkVar); |
ClassImp(ToFTrkVar); |
17 |
ClassImp(ToFLevel2); |
ClassImp(ToFLevel2); |
18 |
|
|
21 |
adc = 0.; |
adc = 0.; |
22 |
tdc_tw = 0.; |
tdc_tw = 0.; |
23 |
tdc = 0.; |
tdc = 0.; |
24 |
|
l0flag_adc = 0.; |
25 |
|
l0flag_tdc = 0.; |
26 |
} |
} |
27 |
|
|
28 |
ToFPMT::ToFPMT(const ToFPMT &t){ |
ToFPMT::ToFPMT(const ToFPMT &t){ |
120 |
if(PMT)PMT->Delete(); //ELENA |
if(PMT)PMT->Delete(); //ELENA |
121 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
122 |
unpackError = 0; |
unpackError = 0; |
123 |
|
unpackWarning = 0; |
124 |
// |
// |
125 |
}; |
}; |
126 |
|
|
224 |
return npad; |
return npad; |
225 |
}; |
}; |
226 |
|
|
227 |
|
/** |
228 |
|
* Method to get the number of hit paddles on a ToF plane. |
229 |
|
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
230 |
|
*/ |
231 |
|
Int_t ToFLevel2::GetTrueNHitPaddles(Int_t plane){ |
232 |
|
Int_t npad=0; |
233 |
|
TClonesArray* Pmt = this->PMT; |
234 |
|
int paddle[24]; |
235 |
|
memset(paddle,0, 24*sizeof(int)); |
236 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { //loop per vedere quale TOF è colpito |
237 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
238 |
|
int pplane = -1; |
239 |
|
int ppaddle = -1; |
240 |
|
GetPMTPaddle(pmthit->pmt_id,pplane,ppaddle); |
241 |
|
if ( pplane == plane ) paddle[ppaddle]++; |
242 |
|
} |
243 |
|
for(int i=0;i<24;i++) if ( paddle[i]>0 ) npad++; |
244 |
|
|
245 |
|
return npad; |
246 |
|
}; |
247 |
|
|
248 |
//wm Nov 08 |
//wm Nov 08 |
249 |
//gf Apr 07 |
//gf Apr 07 |
250 |
/** |
/** |
259 |
* @param plane Plane index (0,1,2,3,4,5) |
* @param plane Plane index (0,1,2,3,4,5) |
260 |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
261 |
*/ |
*/ |
262 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
Float_t ToFLevel2::GetdEdx(ToFTrkVar *trk, Int_t plane, Int_t adcfl){ |
263 |
|
// printf("fiffi\n"); |
264 |
|
Float_t dedx = 0.; |
265 |
|
Float_t PadEdx =0.; |
266 |
|
Int_t SatWarning; |
267 |
|
Int_t pad=-1; |
268 |
|
// |
269 |
|
if(!trk) return 0; //ELENA |
270 |
|
// |
271 |
|
if ( trk->trkseqno == -1 ){ //standalone, only paddles along the track, or about... |
272 |
|
// printf("ciccio\n"); |
273 |
|
Float_t xleft=0; |
274 |
|
Float_t xright=0; |
275 |
|
Float_t yleft=0; |
276 |
|
Float_t yright=0; |
277 |
|
Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.}; |
278 |
|
Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.}; |
279 |
|
ToFTrkVar *t_tof = trk; |
280 |
|
|
281 |
|
xtof_temp[0]=t_tof->xtofpos[0]; |
282 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
283 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
284 |
|
ytof_temp[1]=t_tof->ytofpos[0]; |
285 |
|
|
286 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
287 |
|
ytof_temp[2]=t_tof->ytofpos[1]; |
288 |
|
xtof_temp[3]=t_tof->xtofpos[1]; |
289 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
290 |
|
|
291 |
|
xtof_temp[4]=t_tof->xtofpos[2]; |
292 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
293 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
294 |
|
ytof_temp[5]=t_tof->ytofpos[2]; |
295 |
|
|
296 |
|
if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){ |
297 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
298 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
299 |
|
}else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){ |
300 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
301 |
|
this->GetPaddleGeometry(0,(Int_t)log2(this->tof_j_flag[0]),xleft, xright, yleft, yright); |
302 |
|
xtof_temp[1]=xleft+2.55; |
303 |
|
}else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){ |
304 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
305 |
|
this->GetPaddleGeometry(1,(Int_t)log2(this->tof_j_flag[1]),xleft, xright, yleft, yright); |
306 |
|
ytof_temp[0]=yleft+2.75; |
307 |
|
} |
308 |
|
|
309 |
|
if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){ |
310 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
311 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
312 |
|
}else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){ |
313 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
314 |
|
this->GetPaddleGeometry(3,(Int_t)log2(this->tof_j_flag[3]),xleft, xright, yleft, yright); |
315 |
|
xtof_temp[2]=xleft+4.5; |
316 |
|
}else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){ |
317 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
318 |
|
this->GetPaddleGeometry(2,(Int_t)log2(this->tof_j_flag[2]),xleft, xright, yleft, yright); |
319 |
|
ytof_temp[3]=yleft+3.75; |
320 |
|
} |
321 |
|
|
322 |
|
if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){ |
323 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
324 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
325 |
|
}else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){ |
326 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
327 |
|
this->GetPaddleGeometry(4,(Int_t)log2(this->tof_j_flag[4]),xleft, xright, yleft, yright); |
328 |
|
xtof_temp[5]=xleft+3; |
329 |
|
}else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){ |
330 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
331 |
|
this->GetPaddleGeometry(5,(Int_t)log2(this->tof_j_flag[5]),xleft, xright, yleft, yright); |
332 |
|
ytof_temp[4]=yleft+2.5; |
333 |
|
} |
334 |
|
|
335 |
|
if ( (xtof_temp[0])> 17.85 && fabs(xtof_temp[0])<17.85+4. ) xtof_temp[0] =17.84; |
336 |
|
if ( (xtof_temp[1])> 17.85 && fabs(xtof_temp[1])<17.85+4. ) xtof_temp[1] =17.84; |
337 |
|
if ( (ytof_temp[0])> 13.75 && fabs(ytof_temp[0])<13.75+4. ) ytof_temp[0] =13.74; |
338 |
|
if ( (ytof_temp[1])> 13.75 && fabs(ytof_temp[1])<13.75+4. ) ytof_temp[1] =13.74; |
339 |
|
if ( (xtof_temp[0])< -17.85 && fabs(xtof_temp[0])>-(17.85+4.) ) xtof_temp[0] =-17.84; |
340 |
|
if ( (xtof_temp[1])< -17.85 && fabs(xtof_temp[1])>-(17.85+4.) ) xtof_temp[1] =-17.84; |
341 |
|
if ( (ytof_temp[0])< -13.75 && fabs(ytof_temp[0])>-(13.75+4.) ) ytof_temp[0] =-13.74; |
342 |
|
if ( (ytof_temp[1])< -13.75 && fabs(ytof_temp[1])>-(13.75+4.) ) ytof_temp[1] =-13.74; |
343 |
|
|
344 |
|
if ( (xtof_temp[2])> 4.5 && (xtof_temp[2])<4.5+4. ) xtof_temp[2] =4.4; |
345 |
|
if ( (xtof_temp[3])> 4.45 && (xtof_temp[3])<4.5+4. ) xtof_temp[3] =4.4; |
346 |
|
if ( (ytof_temp[2])> 3.75 && (ytof_temp[2])<3.75+4. ) ytof_temp[2] =3.74; |
347 |
|
if ( (ytof_temp[3])> 3.75 && (ytof_temp[3])<3.75+4. ) ytof_temp[3] =3.74; |
348 |
|
if ( (xtof_temp[2])< -4.5 && (xtof_temp[2])>-(4.5+4.) ) xtof_temp[2] =-4.4; |
349 |
|
if ( (xtof_temp[3])< -4.45 && (xtof_temp[3])>-(4.5+4.) ) xtof_temp[3] =-4.4; |
350 |
|
if ( (ytof_temp[2])< -3.75 && (ytof_temp[2])>-(3.75+4.) ) ytof_temp[2] =-3.74; |
351 |
|
if ( (ytof_temp[3])< -3.75 && (ytof_temp[3])>-(3.75+4.) ) ytof_temp[3] =-3.74; |
352 |
|
|
353 |
|
if ( (xtof_temp[4])> 6. && (xtof_temp[4])<6.+4. ) xtof_temp[2] =5.9; |
354 |
|
if ( (xtof_temp[5])> 6. && (xtof_temp[5])<6.+4. ) xtof_temp[3] =5.9; |
355 |
|
if ( (ytof_temp[4])> 5. && (ytof_temp[4])<5.+4. ) ytof_temp[2] =4.9; |
356 |
|
if ( (ytof_temp[5])> 5. && (ytof_temp[5])<5.+4. ) ytof_temp[3] =4.9; |
357 |
|
if ( (xtof_temp[4])< -6. && (xtof_temp[4])>-(6.+4.) ) xtof_temp[2] =-5.9; |
358 |
|
if ( (xtof_temp[5])< -6. && (xtof_temp[5])>-(6.+4.) ) xtof_temp[3] =-5.9; |
359 |
|
if ( (ytof_temp[4])< -5. && (ytof_temp[4])>-(5.+4.) ) ytof_temp[2] =-4.9; |
360 |
|
if ( (ytof_temp[5])< -5. && (ytof_temp[5])>-(5.+4.) ) ytof_temp[3] =-4.9; |
361 |
|
|
362 |
|
|
363 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
364 |
|
Int_t paddleid=ii; |
365 |
|
pad = GetPaddleid(plane,paddleid); |
366 |
|
Int_t IpaddleT=-1; |
367 |
|
IpaddleT=this->GetPaddleIdOfTrack(xtof_temp[plane],ytof_temp[plane], plane,0.0); |
368 |
|
// printf("SSS %i %i %f %f %f %f \n",IpaddleT,paddleid,xtof_temp[plane],ytof_temp[plane],t_tof->xtofpos[plane],t_tof->ytofpos[plane]); |
369 |
|
// if ( IpaddleT == paddleid || IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
370 |
|
if ( IpaddleT == paddleid || GetTrueNHitPaddles(plane) == 1 ){ |
371 |
|
//IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
372 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
373 |
|
dedx += PadEdx; |
374 |
|
} |
375 |
|
}; |
376 |
|
} else { |
377 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
378 |
|
Int_t paddleid=ii; |
379 |
|
pad = GetPaddleid(plane,paddleid); |
380 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
381 |
|
dedx += PadEdx; |
382 |
|
// printf("TTT %i %i %f\n",paddleid,plane,PadEdx); |
383 |
|
}; |
384 |
|
} |
385 |
|
// |
386 |
|
return(dedx); |
387 |
|
}; |
388 |
|
|
389 |
|
|
390 |
|
//wm Nov 08 |
391 |
|
//gf Apr 07 |
392 |
|
/** |
393 |
|
* Method to get the mean dEdx from a ToF layer - ATTENTION: |
394 |
|
* It will sum up the dEdx of all the paddles, but since by definition |
395 |
|
* only the paddle hitted by the track gets a dEdx value and the other |
396 |
|
* paddles are set to zero, the output is just the dEdx of the hitted |
397 |
|
* paddle in each layer! |
398 |
|
* The "adcfl" option is not very useful (an artificial dEdx is per |
399 |
|
* definition= 1 mip and not a real measurement), anyway left in the code |
400 |
|
* @param notrack Track Number |
401 |
|
* @param plane Plane index (0,1,2,3,4,5) |
402 |
|
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
403 |
|
*/ |
404 |
|
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
405 |
|
// printf("fiffi\n"); |
406 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
407 |
Float_t PadEdx =0.; |
Float_t PadEdx =0.; |
408 |
Int_t SatWarning; |
Int_t SatWarning; |
411 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
412 |
if(!trk) return 0; //ELENA |
if(!trk) return 0; //ELENA |
413 |
// |
// |
414 |
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
if ( trk->trkseqno == -1 ){ //standalone, only paddles along the track, or about... |
415 |
Int_t paddleid=ii; |
// printf("ciccio\n"); |
416 |
pad = GetPaddleid(plane,paddleid); |
Float_t xleft=0; |
417 |
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
Float_t xright=0; |
418 |
dedx += PadEdx; |
Float_t yleft=0; |
419 |
}; |
Float_t yright=0; |
420 |
|
Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.}; |
421 |
|
Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.}; |
422 |
|
ToFTrkVar *t_tof = trk; |
423 |
|
|
424 |
|
xtof_temp[0]=t_tof->xtofpos[0]; |
425 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
426 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
427 |
|
ytof_temp[1]=t_tof->ytofpos[0]; |
428 |
|
|
429 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
430 |
|
ytof_temp[2]=t_tof->ytofpos[1]; |
431 |
|
xtof_temp[3]=t_tof->xtofpos[1]; |
432 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
433 |
|
|
434 |
|
xtof_temp[4]=t_tof->xtofpos[2]; |
435 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
436 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
437 |
|
ytof_temp[5]=t_tof->ytofpos[2]; |
438 |
|
|
439 |
|
if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){ |
440 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
441 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
442 |
|
}else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){ |
443 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
444 |
|
this->GetPaddleGeometry(0,(Int_t)log2(this->tof_j_flag[0]),xleft, xright, yleft, yright); |
445 |
|
xtof_temp[1]=xleft+2.55; |
446 |
|
}else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){ |
447 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
448 |
|
this->GetPaddleGeometry(1,(Int_t)log2(this->tof_j_flag[1]),xleft, xright, yleft, yright); |
449 |
|
ytof_temp[0]=yleft+2.75; |
450 |
|
} |
451 |
|
|
452 |
|
if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){ |
453 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
454 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
455 |
|
}else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){ |
456 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
457 |
|
this->GetPaddleGeometry(3,(Int_t)log2(this->tof_j_flag[3]),xleft, xright, yleft, yright); |
458 |
|
xtof_temp[2]=xleft+4.5; |
459 |
|
}else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){ |
460 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
461 |
|
this->GetPaddleGeometry(2,(Int_t)log2(this->tof_j_flag[2]),xleft, xright, yleft, yright); |
462 |
|
ytof_temp[3]=yleft+3.75; |
463 |
|
} |
464 |
|
|
465 |
|
if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){ |
466 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
467 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
468 |
|
}else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){ |
469 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
470 |
|
this->GetPaddleGeometry(4,(Int_t)log2(this->tof_j_flag[4]),xleft, xright, yleft, yright); |
471 |
|
xtof_temp[5]=xleft+3; |
472 |
|
}else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){ |
473 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
474 |
|
this->GetPaddleGeometry(5,(Int_t)log2(this->tof_j_flag[5]),xleft, xright, yleft, yright); |
475 |
|
ytof_temp[4]=yleft+2.5; |
476 |
|
} |
477 |
|
|
478 |
|
if ( (xtof_temp[0])> 17.85 && fabs(xtof_temp[0])<17.85+4. ) xtof_temp[0] =17.84; |
479 |
|
if ( (xtof_temp[1])> 17.85 && fabs(xtof_temp[1])<17.85+4. ) xtof_temp[1] =17.84; |
480 |
|
if ( (ytof_temp[0])> 13.75 && fabs(ytof_temp[0])<13.75+4. ) ytof_temp[0] =13.74; |
481 |
|
if ( (ytof_temp[1])> 13.75 && fabs(ytof_temp[1])<13.75+4. ) ytof_temp[1] =13.74; |
482 |
|
if ( (xtof_temp[0])< -17.85 && fabs(xtof_temp[0])>-(17.85+4.) ) xtof_temp[0] =-17.84; |
483 |
|
if ( (xtof_temp[1])< -17.85 && fabs(xtof_temp[1])>-(17.85+4.) ) xtof_temp[1] =-17.84; |
484 |
|
if ( (ytof_temp[0])< -13.75 && fabs(ytof_temp[0])>-(13.75+4.) ) ytof_temp[0] =-13.74; |
485 |
|
if ( (ytof_temp[1])< -13.75 && fabs(ytof_temp[1])>-(13.75+4.) ) ytof_temp[1] =-13.74; |
486 |
|
|
487 |
|
if ( (xtof_temp[2])> 4.5 && (xtof_temp[2])<4.5+4. ) xtof_temp[2] =4.4; |
488 |
|
if ( (xtof_temp[3])> 4.45 && (xtof_temp[3])<4.5+4. ) xtof_temp[3] =4.4; |
489 |
|
if ( (ytof_temp[2])> 3.75 && (ytof_temp[2])<3.75+4. ) ytof_temp[2] =3.74; |
490 |
|
if ( (ytof_temp[3])> 3.75 && (ytof_temp[3])<3.75+4. ) ytof_temp[3] =3.74; |
491 |
|
if ( (xtof_temp[2])< -4.5 && (xtof_temp[2])>-(4.5+4.) ) xtof_temp[2] =-4.4; |
492 |
|
if ( (xtof_temp[3])< -4.45 && (xtof_temp[3])>-(4.5+4.) ) xtof_temp[3] =-4.4; |
493 |
|
if ( (ytof_temp[2])< -3.75 && (ytof_temp[2])>-(3.75+4.) ) ytof_temp[2] =-3.74; |
494 |
|
if ( (ytof_temp[3])< -3.75 && (ytof_temp[3])>-(3.75+4.) ) ytof_temp[3] =-3.74; |
495 |
|
|
496 |
|
if ( (xtof_temp[4])> 6. && (xtof_temp[4])<6.+4. ) xtof_temp[2] =5.9; |
497 |
|
if ( (xtof_temp[5])> 6. && (xtof_temp[5])<6.+4. ) xtof_temp[3] =5.9; |
498 |
|
if ( (ytof_temp[4])> 5. && (ytof_temp[4])<5.+4. ) ytof_temp[2] =4.9; |
499 |
|
if ( (ytof_temp[5])> 5. && (ytof_temp[5])<5.+4. ) ytof_temp[3] =4.9; |
500 |
|
if ( (xtof_temp[4])< -6. && (xtof_temp[4])>-(6.+4.) ) xtof_temp[2] =-5.9; |
501 |
|
if ( (xtof_temp[5])< -6. && (xtof_temp[5])>-(6.+4.) ) xtof_temp[3] =-5.9; |
502 |
|
if ( (ytof_temp[4])< -5. && (ytof_temp[4])>-(5.+4.) ) ytof_temp[2] =-4.9; |
503 |
|
if ( (ytof_temp[5])< -5. && (ytof_temp[5])>-(5.+4.) ) ytof_temp[3] =-4.9; |
504 |
|
|
505 |
|
|
506 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
507 |
|
Int_t paddleid=ii; |
508 |
|
pad = GetPaddleid(plane,paddleid); |
509 |
|
Int_t IpaddleT=-1; |
510 |
|
IpaddleT=this->GetPaddleIdOfTrack(xtof_temp[plane],ytof_temp[plane], plane,0.0); |
511 |
|
// printf("SSS %i %i %f %f %f %f \n",IpaddleT,paddleid,xtof_temp[plane],ytof_temp[plane],t_tof->xtofpos[plane],t_tof->ytofpos[plane]); |
512 |
|
// if ( IpaddleT == paddleid || IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
513 |
|
if ( IpaddleT == paddleid || GetTrueNHitPaddles(plane) == 1 ){ |
514 |
|
//IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
515 |
|
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
516 |
|
dedx += PadEdx; |
517 |
|
} |
518 |
|
}; |
519 |
|
} else { |
520 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
521 |
|
Int_t paddleid=ii; |
522 |
|
pad = GetPaddleid(plane,paddleid); |
523 |
|
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
524 |
|
dedx += PadEdx; |
525 |
|
// printf("TTT %i %i %f\n",paddleid,plane,PadEdx); |
526 |
|
}; |
527 |
|
} |
528 |
// |
// |
529 |
return(dedx); |
return(dedx); |
530 |
}; |
}; |
678 |
*/ |
*/ |
679 |
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
680 |
|
|
681 |
/* |
/* |
682 |
Float_t PMTsat[48] = { |
Float_t PMTsat[48] = { |
683 |
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
684 |
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
685 |
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
686 |
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
687 |
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
688 |
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
689 |
*/ |
*/ |
690 |
|
|
691 |
// new values from Napoli dec 2008 |
// new values from Napoli dec 2008 |
692 |
Float_t PMTsat[48] = { |
Float_t PMTsat[48] = { |
693 |
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
694 |
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
695 |
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
696 |
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
697 |
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
698 |
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
699 |
|
|
700 |
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
701 |
|
|
702 |
|
|
703 |
PadEdx = 0.; |
PadEdx = 0.; |
704 |
// SatWarning = 1000; |
// SatWarning = 1000; |
705 |
SatWarning = 0; // 0=good, increase for each bad PMT |
SatWarning = 0; // 0=good, increase for each bad PMT |
706 |
|
|
707 |
Float_t dEdx[48] = {0}; |
Float_t dEdx[48] = {0}; |
748 |
} |
} |
749 |
|
|
750 |
|
|
751 |
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
752 |
|
|
753 |
// Increase SatWarning Counter for each PMT>Sat |
// Increase SatWarning Counter for each PMT>Sat |
754 |
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
755 |
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
756 |
|
|
757 |
// if ADC > sat set dEdx=1000 |
// if ADC > sat set dEdx=1000 |
758 |
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
759 |
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
760 |
|
|
761 |
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
762 |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
763 |
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
764 |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
765 |
|
|
766 |
}; |
}; |
767 |
|
|
768 |
// |
// |
769 |
|
// wm Nov 08 revision - saturation values included |
770 |
|
/// gf Apr 07 |
771 |
|
/** |
772 |
|
* Method to get the dEdx from a given ToF paddle. |
773 |
|
* If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise |
774 |
|
* just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000 |
775 |
|
* @param notrack Track Number |
776 |
|
* @param Paddle index (0,1,...,23). |
777 |
|
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
778 |
|
* @param PadEdx dEdx from a given ToF paddle |
779 |
|
* @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000) |
780 |
|
*/ |
781 |
|
void ToFLevel2::GetdEdxPaddle(ToFTrkVar *trk, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
782 |
|
|
783 |
|
/* |
784 |
|
Float_t PMTsat[48] = { |
785 |
|
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
786 |
|
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
787 |
|
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
788 |
|
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
789 |
|
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
790 |
|
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
791 |
|
*/ |
792 |
|
|
793 |
|
// new values from Napoli dec 2008 |
794 |
|
Float_t PMTsat[48] = { |
795 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
796 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
797 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
798 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
799 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
800 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
801 |
|
|
802 |
|
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
803 |
|
|
804 |
|
|
805 |
|
PadEdx = 0.; |
806 |
|
// SatWarning = 1000; |
807 |
|
SatWarning = 0; // 0=good, increase for each bad PMT |
808 |
|
|
809 |
|
Float_t dEdx[48] = {0}; |
810 |
|
Int_t pmt_id = -1; |
811 |
|
Float_t adcraw[48]; |
812 |
|
// |
813 |
|
if(!trk) return; //ELENA |
814 |
|
// |
815 |
|
|
816 |
|
Int_t pmtleft=-1; |
817 |
|
Int_t pmtright=-1; |
818 |
|
GetPaddlePMT(paddleid, pmtleft, pmtright); |
819 |
|
|
820 |
|
adcraw[pmtleft] = 4095; |
821 |
|
adcraw[pmtright] = 4095; |
822 |
|
|
823 |
|
|
824 |
|
for (Int_t jj=0; jj<npmt(); jj++){ |
825 |
|
|
826 |
|
ToFPMT *pmt = GetToFPMT(jj); |
827 |
|
if(!pmt)break; //ELENA |
828 |
|
|
829 |
|
pmt_id = pmt->pmt_id; |
830 |
|
if(pmt_id==pmtleft){ |
831 |
|
adcraw[pmtleft] = pmt->adc; |
832 |
|
} |
833 |
|
|
834 |
|
if(pmt_id==pmtright){ |
835 |
|
adcraw[pmtright] = pmt->adc; |
836 |
|
} |
837 |
|
} |
838 |
|
|
839 |
|
|
840 |
|
for (Int_t i=0; i<trk->npmtadc; i++){ |
841 |
|
|
842 |
|
if((trk->adcflag).At(i)==0 || adcfl==100){ |
843 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = (trk->dedx).At(i); |
844 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = (trk->dedx).At(i); |
845 |
|
}else{ |
846 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = 0.; |
847 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = 0.; |
848 |
|
} |
849 |
|
} |
850 |
|
|
851 |
|
|
852 |
|
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
853 |
|
|
854 |
|
// Increase SatWarning Counter for each PMT>Sat |
855 |
|
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
856 |
|
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
857 |
|
|
858 |
|
// if ADC > sat set dEdx=1000 |
859 |
|
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
860 |
|
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
861 |
|
|
862 |
|
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
863 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
864 |
|
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
865 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
866 |
|
|
867 |
|
}; |
868 |
|
|
869 |
// gf Apr 07 |
// gf Apr 07 |
870 |
|
|
1264 |
return; |
return; |
1265 |
} |
} |
1266 |
|
|
1267 |
if(7<pad<14){ |
if((7<pad)&&(pad<14)){ |
1268 |
plane=1; |
plane=1; |
1269 |
paddle=pad-pads11; |
paddle=pad-pads11; |
1270 |
return; |
return; |
1271 |
} |
} |
1272 |
|
|
1273 |
if(13<pad<16){ |
if((13<pad)&&(pad<16)){ |
1274 |
plane=2; |
plane=2; |
1275 |
paddle=pad-pads11-pads12; |
paddle=pad-pads11-pads12; |
1276 |
return; |
return; |
1277 |
} |
} |
1278 |
|
|
1279 |
if(15<pad<18){ |
if((15<pad)&&(pad<18)){ |
1280 |
plane=3; |
plane=3; |
1281 |
paddle=pad-pads11-pads12-pads21; |
paddle=pad-pads11-pads12-pads21; |
1282 |
return; |
return; |
1283 |
} |
} |
1284 |
|
|
1285 |
if(17<pad<21){ |
if((17<pad)&&(pad<21)){ |
1286 |
plane=4; |
plane=4; |
1287 |
paddle=pad-pads11-pads12-pads21-pads22; |
paddle=pad-pads11-pads12-pads21-pads22; |
1288 |
return; |
return; |
1289 |
} |
} |
1290 |
|
|
1291 |
if(20<pad<24){ |
if((20<pad)&&(pad<24)){ |
1292 |
plane=5; |
plane=5; |
1293 |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
1294 |
return; |
return; |
1522 |
// |
// |
1523 |
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
1524 |
// |
// |
1525 |
|
printf("\n\n\n ERROR: NOT IMPLEMENTED ANYMORE, write Emiliano if you need this method (Emiliano.Mocchiutti@ts.infn.it) \n\n\n"); |
1526 |
|
return(-1); |
1527 |
|
// // |
1528 |
|
// // structures to communicate with F77 |
1529 |
|
// // |
1530 |
|
// extern struct ToFInput tofinput_; |
1531 |
|
// extern struct ToFOutput tofoutput_; |
1532 |
|
// // |
1533 |
|
// // DB connection |
1534 |
|
// // |
1535 |
|
// TString host; |
1536 |
|
// TString user; |
1537 |
|
// TString psw; |
1538 |
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
1539 |
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
1540 |
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
1541 |
|
// if ( !pamdbhost ) pamdbhost = ""; |
1542 |
|
// if ( !pamdbuser ) pamdbuser = ""; |
1543 |
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
1544 |
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
1545 |
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
1546 |
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
1547 |
|
// // |
1548 |
|
// // |
1549 |
|
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
1550 |
|
// if ( !dbc->IsConnected() ) return 1; |
1551 |
|
// stringstream myquery; |
1552 |
|
// myquery.str(""); |
1553 |
|
// myquery << "SET time_zone='+0:00'"; |
1554 |
|
// dbc->Query(myquery.str().c_str()); |
1555 |
|
// GL_PARAM *glparam = new GL_PARAM(); |
1556 |
|
// glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
1557 |
|
// trk->LoadField(glparam->PATH+glparam->NAME); |
1558 |
|
// // |
1559 |
|
// Bool_t defcal = true; |
1560 |
|
// Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
1561 |
|
// if ( error<0 ) { |
1562 |
|
// return(1); |
1563 |
|
// }; |
1564 |
|
// printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
1565 |
|
// if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
1566 |
|
// // |
1567 |
|
// Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
1568 |
|
// rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
1569 |
|
// // |
1570 |
|
// Int_t adc[4][12]; |
1571 |
|
// Int_t tdc[4][12]; |
1572 |
|
// Float_t tdcc[4][12]; |
1573 |
|
// // |
1574 |
|
// // process tof data |
1575 |
|
// // |
1576 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1577 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1578 |
|
// adc[kk][hh] = 4095; |
1579 |
|
// tdc[kk][hh] = 4095; |
1580 |
|
// tdcc[kk][hh] = 4095.; |
1581 |
|
// tofinput_.adc[hh][kk] = 4095; |
1582 |
|
// tofinput_.tdc[hh][kk] = 4095; |
1583 |
|
// }; |
1584 |
|
// }; |
1585 |
|
// Int_t ntrkentry = 0; |
1586 |
|
// Int_t npmtentry = 0; |
1587 |
|
// Int_t gg = 0; |
1588 |
|
// Int_t hh = 0; |
1589 |
|
// Int_t adcf[48]; |
1590 |
|
// memset(adcf, 0, 48*sizeof(Int_t)); |
1591 |
|
// Int_t tdcf[48]; |
1592 |
|
// memset(tdcf, 0, 48*sizeof(Int_t)); |
1593 |
|
// for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
1594 |
|
// ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
1595 |
|
// for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
1596 |
|
// if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
1597 |
|
// }; |
1598 |
|
// for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
1599 |
|
// if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
1600 |
|
// }; |
1601 |
|
// }; |
1602 |
|
// // |
1603 |
|
// for (Int_t pm=0; pm < this->npmt() ; pm++){ |
1604 |
|
// ToFPMT *pmt = this->GetToFPMT(pm); |
1605 |
|
// this->GetPMTIndex(pmt->pmt_id, gg, hh); |
1606 |
|
// if ( adcf[pmt->pmt_id] == 0 ){ |
1607 |
|
// tofinput_.adc[gg][hh] = (int)pmt->adc; |
1608 |
|
// adc[hh][gg] = (int)pmt->adc; |
1609 |
|
// }; |
1610 |
|
// if ( tdcf[pmt->pmt_id] == 0 ){ |
1611 |
|
// tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
1612 |
|
// tdc[hh][gg] = (int)pmt->tdc; |
1613 |
|
// }; |
1614 |
|
// tdcc[hh][gg] = (float)pmt->tdc_tw; |
1615 |
|
// // Int_t pppid = this->GetPMTid(hh,gg); |
1616 |
|
// // printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
1617 |
|
// }; |
1618 |
|
// // |
1619 |
|
// Int_t unpackError = this->unpackError; |
1620 |
|
// // |
1621 |
|
// for (Int_t hh=0; hh<5;hh++){ |
1622 |
|
// tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
1623 |
|
// }; |
1624 |
|
// // |
1625 |
|
// this->Clear(); |
1626 |
|
// // |
1627 |
|
// Int_t pmt_id = 0; |
1628 |
|
// ToFPMT *t_pmt = new ToFPMT(); |
1629 |
|
// if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
1630 |
|
// TClonesArray &tpmt = *this->PMT; |
1631 |
|
// ToFTrkVar *t_tof = new ToFTrkVar(); |
1632 |
|
// if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
1633 |
|
// TClonesArray &t = *this->ToFTrk; |
1634 |
|
// // |
1635 |
|
// // |
1636 |
|
// // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
1637 |
|
// // |
1638 |
|
// npmtentry = 0; |
1639 |
|
// // |
1640 |
|
// ntrkentry = 0; |
1641 |
|
// // |
1642 |
|
// // Calculate tracks informations from ToF alone |
1643 |
|
// // |
1644 |
|
// tofl2com(); |
1645 |
|
// // |
1646 |
|
// memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
1647 |
|
// // |
1648 |
|
// t_tof->trkseqno = -1; |
1649 |
|
// // |
1650 |
|
// // and now we must copy from the output structure to the level2 class: |
1651 |
|
// // |
1652 |
|
// t_tof->npmttdc = 0; |
1653 |
|
// // |
1654 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1655 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1656 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1657 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1658 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1659 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1660 |
|
// t_tof->npmttdc++; |
1661 |
|
// }; |
1662 |
|
// }; |
1663 |
|
// }; |
1664 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1665 |
|
// t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
1666 |
|
// } |
1667 |
|
// // |
1668 |
|
// t_tof->npmtadc = 0; |
1669 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1670 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1671 |
|
// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
1672 |
|
// t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
1673 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1674 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1675 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1676 |
|
// t_tof->npmtadc++; |
1677 |
|
// }; |
1678 |
|
// }; |
1679 |
|
// }; |
1680 |
|
// // |
1681 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1682 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1683 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1684 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1685 |
|
// // |
1686 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1687 |
|
// ntrkentry++; |
1688 |
|
// t_tof->Clear(); |
1689 |
|
// // |
1690 |
|
// // |
1691 |
|
// // |
1692 |
|
// t_pmt->Clear(); |
1693 |
|
// // |
1694 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1695 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1696 |
|
// // new WM |
1697 |
|
// if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1698 |
|
// // if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1699 |
|
// // |
1700 |
|
// t_pmt->pmt_id = this->GetPMTid(kk,hh); |
1701 |
|
// t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
1702 |
|
// t_pmt->adc = (Float_t)adc[kk][hh]; |
1703 |
|
// t_pmt->tdc = (Float_t)tdc[kk][hh]; |
1704 |
|
// // |
1705 |
|
// new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
1706 |
|
// npmtentry++; |
1707 |
|
// t_pmt->Clear(); |
1708 |
|
// }; |
1709 |
|
// }; |
1710 |
|
// }; |
1711 |
|
// // |
1712 |
|
// // Calculate track-related variables |
1713 |
|
// // |
1714 |
|
// if ( trk->ntrk() > 0 ){ |
1715 |
|
// // |
1716 |
|
// // We have at least one track |
1717 |
|
// // |
1718 |
|
// // |
1719 |
|
// // Run over tracks |
1720 |
|
// // |
1721 |
|
// for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
1722 |
|
// // |
1723 |
|
// TrkTrack *ptt = trk->GetStoredTrack(nt); |
1724 |
|
// // |
1725 |
|
// // Copy the alpha vector in the input structure |
1726 |
|
// // |
1727 |
|
// for (Int_t e = 0; e < 5 ; e++){ |
1728 |
|
// tofinput_.al_pp[e] = ptt->al[e]; |
1729 |
|
// }; |
1730 |
|
// // |
1731 |
|
// // Get tracker related variables for this track |
1732 |
|
// // |
1733 |
|
// toftrk(); |
1734 |
|
// // |
1735 |
|
// // Copy values in the class from the structure (we need to use a temporary class to store variables). |
1736 |
|
// // |
1737 |
|
// t_tof->npmttdc = 0; |
1738 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1739 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1740 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1741 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1742 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1743 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1744 |
|
// t_tof->npmttdc++; |
1745 |
|
// }; |
1746 |
|
// }; |
1747 |
|
// }; |
1748 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1749 |
|
// t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
1750 |
|
// }; |
1751 |
|
// // |
1752 |
|
// t_tof->npmtadc = 0; |
1753 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1754 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1755 |
|
// if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
1756 |
|
// t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
1757 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1758 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1759 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1760 |
|
// t_tof->npmtadc++; |
1761 |
|
// }; |
1762 |
|
// }; |
1763 |
|
// }; |
1764 |
|
// // |
1765 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1766 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1767 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1768 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1769 |
|
// // |
1770 |
|
// // Store the tracker track number in order to be sure to have shyncronized data during analysis |
1771 |
|
// // |
1772 |
|
// t_tof->trkseqno = nt; |
1773 |
|
// // |
1774 |
|
// // create a new object for this event with track-related variables |
1775 |
|
// // |
1776 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1777 |
|
// ntrkentry++; |
1778 |
|
// t_tof->Clear(); |
1779 |
|
// // |
1780 |
|
// }; // loop on all the tracks |
1781 |
|
// // |
1782 |
|
// this->unpackError = unpackError; |
1783 |
|
// if ( defcal ){ |
1784 |
|
// this->default_calib = 1; |
1785 |
|
// } else { |
1786 |
|
// this->default_calib = 0; |
1787 |
|
// }; |
1788 |
|
//}; |
1789 |
|
// return(0); |
1790 |
|
} |
1791 |
|
|
1792 |
|
bool ToFLevel2::bit(int decimal, char pos){ |
1793 |
|
return( (decimal>>pos)%2 ); |
1794 |
|
} |
1795 |
|
|
1796 |
|
bool ToFLevel2::checkPMT(TString givenpmt){ |
1797 |
|
TClonesArray* Pmt = this->PMT; |
1798 |
|
// printf(" ou %s entries %i \n",givenpmt.Data(),Pmt->GetEntries()); |
1799 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1800 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1801 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1802 |
|
// printf(" name %s \n",pmtname.Data()); |
1803 |
|
if ( !strcmp(pmtname.Data(),givenpmt.Data()) ) |
1804 |
|
return true; |
1805 |
|
} |
1806 |
|
// printf(" PMT %s missing \n",givenpmt.Data()); |
1807 |
|
return false; |
1808 |
|
} |
1809 |
|
|
1810 |
|
bool ToFLevel2::checkPMTpatternPMThit(TrigLevel2 *trg, int &pmtpattern, int &pmtnosignal){ |
1811 |
|
UInt_t *patterntrig = trg->patterntrig; |
1812 |
|
pmtpattern = 0; |
1813 |
|
pmtnosignal = 0; |
1814 |
|
bool good = true; |
1815 |
|
//S3 |
1816 |
|
if ( this->bit(patterntrig[2],0) ){ pmtpattern++; if ( !this->checkPMT("S31_1A")){ pmtnosignal++; good = false;}} |
1817 |
|
if ( this->bit(patterntrig[2],1) ){ pmtpattern++; if ( !this->checkPMT("S31_2A")){ pmtnosignal++; good = false;}} |
1818 |
|
if ( this->bit(patterntrig[2],2) ){ pmtpattern++; if ( !this->checkPMT("S31_3A")){ pmtnosignal++; good = false;}} |
1819 |
|
if ( this->bit(patterntrig[2],3) ){ pmtpattern++; if ( !this->checkPMT("S31_1B")){ pmtnosignal++; good = false;}} |
1820 |
|
if ( this->bit(patterntrig[2],4) ){ pmtpattern++; if ( !this->checkPMT("S31_2B")){ pmtnosignal++; good = false;}} |
1821 |
|
if ( this->bit(patterntrig[2],5) ){ pmtpattern++; if ( !this->checkPMT("S31_3B")){ pmtnosignal++; good = false;}} |
1822 |
|
if ( this->bit(patterntrig[2],6) ){ pmtpattern++; if ( !this->checkPMT("S32_1A")){ pmtnosignal++; good = false;}} |
1823 |
|
if ( this->bit(patterntrig[2],7) ){ pmtpattern++; if ( !this->checkPMT("S32_2A")){ pmtnosignal++; good = false;}} |
1824 |
|
if ( this->bit(patterntrig[2],8) ){ pmtpattern++; if ( !this->checkPMT("S32_3A")){ pmtnosignal++; good = false;}} |
1825 |
|
if ( this->bit(patterntrig[2],9) ){ pmtpattern++; if ( !this->checkPMT("S32_1B")){ pmtnosignal++; good = false;}} |
1826 |
|
if ( this->bit(patterntrig[2],10) ){ pmtpattern++; if ( !this->checkPMT("S32_2B")){ pmtnosignal++; good = false;}} |
1827 |
|
if ( this->bit(patterntrig[2],11) ){ pmtpattern++; if ( !this->checkPMT("S32_3B")){ pmtnosignal++; good = false;}} |
1828 |
|
//S2 |
1829 |
|
if ( this->bit(patterntrig[3],0) ){ pmtpattern++; if ( !this->checkPMT("S21_1A")){ pmtnosignal++; good = false;}} |
1830 |
|
if ( this->bit(patterntrig[3],1) ){ pmtpattern++; if ( !this->checkPMT("S21_2A")){ pmtnosignal++; good = false;}} |
1831 |
|
if ( this->bit(patterntrig[3],2) ){ pmtpattern++; if ( !this->checkPMT("S21_1B")){ pmtnosignal++; good = false;}} |
1832 |
|
if ( this->bit(patterntrig[3],3) ){ pmtpattern++; if ( !this->checkPMT("S21_2B")){ pmtnosignal++; good = false;}} |
1833 |
|
if ( this->bit(patterntrig[3],4) ){ pmtpattern++; if ( !this->checkPMT("S22_1A")){ pmtnosignal++; good = false;}} |
1834 |
|
if ( this->bit(patterntrig[3],5) ){ pmtpattern++; if ( !this->checkPMT("S22_2A")){ pmtnosignal++; good = false;}} |
1835 |
|
if ( this->bit(patterntrig[3],6) ){ pmtpattern++; if ( !this->checkPMT("S22_1B")){ pmtnosignal++; good = false;}} |
1836 |
|
if ( this->bit(patterntrig[3],7) ){ pmtpattern++; if ( !this->checkPMT("S22_2B")){ pmtnosignal++; good = false;}} |
1837 |
|
//S12 |
1838 |
|
if ( this->bit(patterntrig[4],0) ){ pmtpattern++; if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}} |
1839 |
|
if ( this->bit(patterntrig[4],1) ){ pmtpattern++; if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}} |
1840 |
|
if ( this->bit(patterntrig[4],2) ){ pmtpattern++; if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}} |
1841 |
|
if ( this->bit(patterntrig[4],3) ){ pmtpattern++; if ( !this->checkPMT("S12_4A")){ pmtnosignal++; good = false;}} |
1842 |
|
if ( this->bit(patterntrig[4],4) ){ pmtpattern++; if ( !this->checkPMT("S12_5A")){ pmtnosignal++; good = false;}} |
1843 |
|
if ( this->bit(patterntrig[4],5) ){ pmtpattern++; if ( !this->checkPMT("S12_6A")){ pmtnosignal++; good = false;}} |
1844 |
|
if ( this->bit(patterntrig[4],6) ){ pmtpattern++; if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}} |
1845 |
|
if ( this->bit(patterntrig[4],7) ){ pmtpattern++; if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}} |
1846 |
|
if ( this->bit(patterntrig[4],8) ){ pmtpattern++; if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}} |
1847 |
|
if ( this->bit(patterntrig[4],9) ){ pmtpattern++; if ( !this->checkPMT("S12_4B")){ pmtnosignal++; good = false;}} |
1848 |
|
if ( this->bit(patterntrig[4],10) ){ pmtpattern++; if ( !this->checkPMT("S12_5B")){ pmtnosignal++; good = false;}} |
1849 |
|
if ( this->bit(patterntrig[4],11) ){ pmtpattern++; if ( !this->checkPMT("S12_6B")){ pmtnosignal++; good = false;}} |
1850 |
|
//S11 |
1851 |
|
if ( this->bit(patterntrig[5],0) ){ pmtpattern++; if ( !this->checkPMT("S11_1A")){ pmtnosignal++; good = false;}} |
1852 |
|
if ( this->bit(patterntrig[5],1) ){ pmtpattern++; if ( !this->checkPMT("S11_2A")){ pmtnosignal++; good = false;}} |
1853 |
|
if ( this->bit(patterntrig[5],2) ){ pmtpattern++; if ( !this->checkPMT("S11_3A")){ pmtnosignal++; good = false;}} |
1854 |
|
if ( this->bit(patterntrig[5],3) ){ pmtpattern++; if ( !this->checkPMT("S11_4A")){ pmtnosignal++; good = false;}} |
1855 |
|
if ( this->bit(patterntrig[5],4) ){ pmtpattern++; if ( !this->checkPMT("S11_5A")){ pmtnosignal++; good = false;}} |
1856 |
|
if ( this->bit(patterntrig[5],5) ){ pmtpattern++; if ( !this->checkPMT("S11_6A")){ pmtnosignal++; good = false;}} |
1857 |
|
if ( this->bit(patterntrig[5],6) ){ pmtpattern++; if ( !this->checkPMT("S11_7A")){ pmtnosignal++; good = false;}} |
1858 |
|
if ( this->bit(patterntrig[5],7) ){ pmtpattern++; if ( !this->checkPMT("S11_8A")){ pmtnosignal++; good = false;}} |
1859 |
|
if ( this->bit(patterntrig[5],8) ){ pmtpattern++; if ( !this->checkPMT("S11_1B")){ pmtnosignal++; good = false;}} |
1860 |
|
if ( this->bit(patterntrig[5],9) ){ pmtpattern++; if ( !this->checkPMT("S11_2B")){ pmtnosignal++; good = false;}} |
1861 |
|
if ( this->bit(patterntrig[5],10) ){ pmtpattern++; if ( !this->checkPMT("S11_3B")){ pmtnosignal++; good = false;}} |
1862 |
|
if ( this->bit(patterntrig[5],11) ){ pmtpattern++; if ( !this->checkPMT("S11_4B")){ pmtnosignal++; good = false;}} |
1863 |
|
if ( this->bit(patterntrig[5],12) ){ pmtpattern++; if ( !this->checkPMT("S11_5B")){ pmtnosignal++; good = false;}} |
1864 |
|
if ( this->bit(patterntrig[5],13) ){ pmtpattern++; if ( !this->checkPMT("S11_6B")){ pmtnosignal++; good = false;}} |
1865 |
|
if ( this->bit(patterntrig[5],14) ){ pmtpattern++; if ( !this->checkPMT("S11_7B")){ pmtnosignal++; good = false;}} |
1866 |
|
if ( this->bit(patterntrig[5],15) ){ pmtpattern++; if ( !this->checkPMT("S11_8B")){ pmtnosignal++; good = false;}} |
1867 |
|
|
1868 |
|
return good; |
1869 |
|
} |
1870 |
|
|
1871 |
|
bool ToFLevel2::checkPMTpmttrig(TrigLevel2 *trg){ |
1872 |
|
// UInt_t *patterntrig = trg->patterntrig; |
1873 |
|
int rS11 = 0; |
1874 |
|
int rS12 = 0; |
1875 |
|
int rS21 = 0; |
1876 |
|
int rS22 = 0; |
1877 |
|
int rS31 = 0; |
1878 |
|
int rS32 = 0; |
1879 |
|
|
1880 |
|
// trigger configuration for the event from saved pmts |
1881 |
|
TClonesArray* Pmt = this->PMT; |
1882 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1883 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1884 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1885 |
|
if ( pmtname.Contains("S11") ) rS11++; |
1886 |
|
if ( pmtname.Contains("S12") ) rS12++; |
1887 |
|
if ( pmtname.Contains("S21") ) rS21++; |
1888 |
|
if ( pmtname.Contains("S22") ) rS22++; |
1889 |
|
if ( pmtname.Contains("S31") ) rS31++; |
1890 |
|
if ( pmtname.Contains("S32") ) rS32++; |
1891 |
|
} |
1892 |
|
int rTOF1 = (rS11 + rS12) * (rS21 + rS22) * (rS31 + rS32); |
1893 |
|
int rTOF2 = (rS11 * rS12) * (rS21 * rS22) * (rS31 * rS32); |
1894 |
|
|
1895 |
|
int rTOF3 = (rS21 + rS22) * (rS31 + rS32); |
1896 |
|
int rTOF4 = (rS21 * rS22) * (rS31 * rS32); |
1897 |
|
|
1898 |
|
int rTOF5 = rS12 * (rS21 * rS22); |
1899 |
|
|
1900 |
|
int rTOF6 = (rS11 + rS12) * (rS31 + rS32); |
1901 |
|
int rTOF7 = (rS11 * rS12) * (rS31 * rS32); |
1902 |
|
|
1903 |
|
|
1904 |
|
// trigger configuration of the run |
1905 |
|
bool TCTOF1 = false; |
1906 |
|
bool TCTOF2 = false; |
1907 |
|
bool TCTOF3 = false; |
1908 |
|
bool TCTOF4 = false; |
1909 |
|
bool TCTOF5 = false; |
1910 |
|
bool TCTOF6 = false; |
1911 |
|
bool TCTOF7 = false; |
1912 |
|
if ( trg->trigconf & (1<<0) ) TCTOF1 = true; |
1913 |
|
if ( trg->trigconf & (1<<1) ) TCTOF2 = true; |
1914 |
|
if ( trg->trigconf & (1<<2) ) TCTOF3 = true; |
1915 |
|
if ( trg->trigconf & (1<<3) ) TCTOF4 = true; |
1916 |
|
if ( trg->trigconf & (1<<4) ) TCTOF5 = true; |
1917 |
|
if ( trg->trigconf & (1<<5) ) TCTOF6 = true; |
1918 |
|
if ( trg->trigconf & (1<<6) ) TCTOF7 = true; |
1919 |
|
|
1920 |
|
// do patterntrig pmts match the trigger configuration? |
1921 |
|
bool pmtsconf_trigconf_match = true; |
1922 |
|
if ( rTOF1 == 0 && TCTOF1 ) pmtsconf_trigconf_match = false; |
1923 |
|
if ( rTOF2 == 0 && TCTOF2 ) pmtsconf_trigconf_match = false; |
1924 |
|
if ( rTOF3 == 0 && TCTOF3 ) pmtsconf_trigconf_match = false; |
1925 |
|
if ( rTOF4 == 0 && TCTOF4 ) pmtsconf_trigconf_match = false; |
1926 |
|
if ( rTOF5 == 0 && TCTOF5 ) pmtsconf_trigconf_match = false; |
1927 |
|
if ( rTOF6 == 0 && TCTOF6 ) pmtsconf_trigconf_match = false; |
1928 |
|
if ( rTOF7 == 0 && TCTOF7 ) pmtsconf_trigconf_match = false; |
1929 |
|
|
1930 |
|
return pmtsconf_trigconf_match; |
1931 |
|
} |
1932 |
|
|
1933 |
|
void ToFLevel2::printPMT(){ |
1934 |
|
TClonesArray* Pmt = this->PMT; |
1935 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1936 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1937 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1938 |
|
printf(" PMT hit: %s \n",pmtname.Data()); |
1939 |
|
} |
1940 |
|
} |
1941 |
|
|
1942 |
|
|
1943 |
|
ToFdEdx::ToFdEdx() |
1944 |
|
{ |
1945 |
|
memset(conn,0,12*sizeof(Bool_t)); |
1946 |
|
memset(ts,0,12*sizeof(UInt_t)); |
1947 |
|
memset(te,0,12*sizeof(UInt_t)); |
1948 |
|
eDEDXpmt = new TArrayF(48); |
1949 |
|
Define_PMTsat(); |
1950 |
|
Clear(); |
1951 |
|
} |
1952 |
|
|
1953 |
|
ToFdEdx::~ToFdEdx(){ |
1954 |
|
Clear(); |
1955 |
|
Delete(); |
1956 |
|
} |
1957 |
|
|
1958 |
|
void ToFdEdx::Delete(Option_t *option){ |
1959 |
|
if ( eDEDXpmt ){ |
1960 |
|
eDEDXpmt->Set(0); |
1961 |
|
if ( eDEDXpmt) delete eDEDXpmt; |
1962 |
|
} |
1963 |
|
} |
1964 |
|
|
1965 |
|
//------------------------------------------------------------------------ |
1966 |
|
void ToFdEdx::CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc) |
1967 |
|
{ |
1968 |
|
for(int i=0; i<12; i++){ |
1969 |
|
if(atime<=ts[i] || atime>te[i]){ |
1970 |
|
Int_t error=glparam->Query_GL_PARAM(atime,210+i,dbc); // parameters stored in DB in GL_PRAM table |
1971 |
|
if ( error<0 ) { |
1972 |
|
conn[i]=false; |
1973 |
|
ts[i]=0; |
1974 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1975 |
|
}; |
1976 |
|
if ( !error ){ |
1977 |
|
conn[i]=true; |
1978 |
|
ts[i]=glparam->FROM_TIME; |
1979 |
|
te[i]=glparam->TO_TIME; |
1980 |
|
} |
1981 |
|
if ( error>0 ){ |
1982 |
|
conn[i]=false; |
1983 |
|
ts[i]=glparam->TO_TIME; |
1984 |
|
TSQLResult *pResult; |
1985 |
|
TSQLRow *row; |
1986 |
|
TString query= Form("SELECT FROM_TIME FROM GL_PARAM WHERE TYPE=%i AND FROM_TIME>=%i ORDER BY FROM_TIME ASC LIMIT 1;",210+i,atime); |
1987 |
|
pResult=dbc->Query(query.Data()); |
1988 |
|
if(!pResult->GetRowCount()){ |
1989 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1990 |
|
}else{ |
1991 |
|
row=pResult->Next(); |
1992 |
|
te[i]=(UInt_t)atoll(row->GetField(0)); |
1993 |
|
} |
1994 |
|
} |
1995 |
|
// |
1996 |
|
|
1997 |
|
} |
1998 |
|
} |
1999 |
|
|
2000 |
|
} |
2001 |
|
//------------------------------------------------------------------------ |
2002 |
|
void ToFdEdx::Clear(Option_t *option) |
2003 |
|
{ |
2004 |
// |
// |
2005 |
// structures to communicate with F77 |
// Set arrays and initialize structure |
2006 |
// |
// eDEDXpmt.Set(48); eDEDXpmt.Reset(-1); // Set array size and reset structure |
2007 |
extern struct ToFInput tofinput_; |
eDEDXpmt->Set(48); eDEDXpmt->Reset(-1); // Set array size and reset structure |
|
extern struct ToFOutput tofoutput_; |
|
|
// |
|
|
// DB connection |
|
|
// |
|
|
TString host; |
|
|
TString user; |
|
|
TString psw; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
// |
|
|
// |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if ( !dbc->IsConnected() ) return 1; |
|
|
stringstream myquery; |
|
|
myquery.str(""); |
|
|
myquery << "SET time_zone='+0:00'"; |
|
|
dbc->Query(myquery.str().c_str()); |
|
|
GL_PARAM *glparam = new GL_PARAM(); |
|
|
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
|
|
trk->LoadField(glparam->PATH+glparam->NAME); |
|
|
// |
|
|
Bool_t defcal = true; |
|
|
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( error<0 ) { |
|
|
return(1); |
|
|
}; |
|
|
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
|
|
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
|
2008 |
// |
// |
2009 |
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
}; |
2010 |
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
|
2011 |
|
//------------------------------------------------------------------------ |
2012 |
|
void ToFdEdx::Print(Option_t *option) |
2013 |
|
{ |
2014 |
// |
// |
2015 |
Int_t adc[4][12]; |
printf("========================================================================\n"); |
2016 |
Int_t tdc[4][12]; |
|
2017 |
Float_t tdcc[4][12]; |
}; |
2018 |
// |
|
2019 |
// process tof data |
//------------------------------------------------------------------------ |
2020 |
// |
void ToFdEdx::Init(pamela::tof::TofEvent *tofl0) |
2021 |
for (Int_t hh=0; hh<12;hh++){ |
{ |
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
adc[kk][hh] = 4095; |
|
|
tdc[kk][hh] = 4095; |
|
|
tdcc[kk][hh] = 4095.; |
|
|
tofinput_.adc[hh][kk] = 4095; |
|
|
tofinput_.tdc[hh][kk] = 4095; |
|
|
}; |
|
|
}; |
|
|
Int_t ntrkentry = 0; |
|
|
Int_t npmtentry = 0; |
|
|
Int_t gg = 0; |
|
|
Int_t hh = 0; |
|
|
Int_t adcf[48]; |
|
|
memset(adcf, 0, 48*sizeof(Int_t)); |
|
|
Int_t tdcf[48]; |
|
|
memset(tdcf, 0, 48*sizeof(Int_t)); |
|
|
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
|
|
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
|
|
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
|
|
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
|
|
}; |
|
|
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
|
|
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
|
|
}; |
|
|
}; |
|
2022 |
// |
// |
2023 |
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
ToFLevel2 tf; |
2024 |
ToFPMT *pmt = this->GetToFPMT(pm); |
for (Int_t gg=0; gg<4;gg++){ |
2025 |
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
for (Int_t hh=0; hh<12;hh++){ |
2026 |
if ( adcf[pmt->pmt_id] == 0 ){ |
// tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh]; |
2027 |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
int mm = tf.GetPMTid(gg,hh); |
2028 |
adc[hh][gg] = (int)pmt->adc; |
adc[mm]= (0xFFF & tofl0->adc[gg][hh]); // EM, exclude warning bits |
2029 |
}; |
}; |
|
if ( tdcf[pmt->pmt_id] == 0 ){ |
|
|
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
|
|
tdc[hh][gg] = (int)pmt->tdc; |
|
|
}; |
|
|
tdcc[hh][gg] = (float)pmt->tdc_tw; |
|
|
// Int_t pppid = this->GetPMTid(hh,gg); |
|
|
// printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
|
2030 |
}; |
}; |
2031 |
|
|
2032 |
|
}; |
2033 |
|
|
2034 |
|
//------------------------------------------------------------------------ |
2035 |
|
void ToFdEdx::Init(Int_t gg, Int_t hh, Float_t adce) |
2036 |
|
{ |
2037 |
// |
// |
2038 |
Int_t unpackError = this->unpackError; |
ToFLevel2 tf; |
2039 |
// |
// for (Int_t gg=0; gg<4;gg++){ |
2040 |
for (Int_t hh=0; hh<5;hh++){ |
// for (Int_t hh=0; hh<12;hh++){ |
2041 |
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
int mm = tf.GetPMTid(gg,hh); |
2042 |
|
adc[mm]=adce; |
2043 |
|
|
2044 |
|
}; |
2045 |
|
//------------------------------------------------------------------------ |
2046 |
|
void ToFdEdx::Process(UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, Int_t exitat) |
2047 |
|
{ |
2048 |
|
bool debug = false; |
2049 |
|
if ( debug ) printf(" INSIDE TOFDEDX PROCESS \n"); |
2050 |
|
// the parameters should be already initialised by InitPar() |
2051 |
|
// printf(" in process \n"); |
2052 |
|
Clear(); |
2053 |
|
|
2054 |
|
// define angle: |
2055 |
|
double dx = xtr_tof[1] - xtr_tof[5]; |
2056 |
|
double dy = ytr_tof[0] - ytr_tof[4]; |
2057 |
|
double dr = sqrt(dx*dx+dy*dy); |
2058 |
|
double theta=atan(dr/76.81); |
2059 |
|
// |
2060 |
|
if ( xtr_tof[1] > 99. || xtr_tof[5] > 99. || ytr_tof[0] > 99. || ytr_tof[4] > 99. ) theta = 0.; |
2061 |
|
for (Int_t ii=0; ii<6; ii++){ |
2062 |
|
if ( xtr_tof[ii] > 99. ) xtr_tof[ii] = 0.; |
2063 |
|
if ( ytr_tof[ii] > 99. ) ytr_tof[ii] = 0.; |
2064 |
}; |
}; |
2065 |
// |
// |
2066 |
this->Clear(); |
if ( debug ) printf(" theta %f \n",theta); |
2067 |
|
if ( debug ) printf(" xtr_tof %.1f %.1f %.1f %.1f %.1f %.1f \n",xtr_tof[0],xtr_tof[1],xtr_tof[2],xtr_tof[3],xtr_tof[4],xtr_tof[5]); |
2068 |
|
if ( debug ) printf(" ytr_tof %.1f %.1f %.1f %.1f %.1f %.1f \n",ytr_tof[0],ytr_tof[1],ytr_tof[2],ytr_tof[3],ytr_tof[4],ytr_tof[5]); |
2069 |
|
//--------------------- TABLE OF PERIODS WITH HV PROBLEMS ---------------------------- |
2070 |
|
|
2071 |
|
int Aconn=conn[0]; // PMT 0,20,22,24 |
2072 |
|
int Bconn=conn[1]; // PMT 6,12,26,34 |
2073 |
|
int Cconn=conn[2]; // PMT 4,14,28,32 |
2074 |
|
int Dconn=conn[3]; // PMT 2,8,10,30 |
2075 |
|
int Econn=conn[4]; // PMT 42,43,44,47 |
2076 |
|
int Fconn=conn[5]; // PMT 7,19,23,27 |
2077 |
|
int Gconn=conn[6]; // PMT 3,11,25,33 |
2078 |
|
int Hconn=conn[7]; // PMT 1,9,13,21 |
2079 |
|
int Iconn=conn[8]; // PMT 5,29,31,35 |
2080 |
|
int Lconn=conn[9]; // PMT 37,40,45,46 |
2081 |
|
int Mconn=conn[10]; // PMT 15,16,17,18 |
2082 |
|
int Nconn=conn[11]; // PMT 36,38,39,41 |
2083 |
|
if( false ) cout << Gconn << Iconn << Lconn <<endl; // to avoid compilation warnings |
2084 |
|
|
2085 |
|
// printf(" size %i \n",eDEDXpmt.GetSize()); |
2086 |
|
for( int ii=0; ii<48; ii++ ) { |
2087 |
|
// |
2088 |
|
// eDEDXpmt.SetAt(-1.,ii); |
2089 |
|
// printf(" ii %i beta %f atime %u xtr 1 %f ytr 1 %f adc %f \n",ii,betamean,atime,xtr_tof[0],ytr_tof[0],adc[ii]); |
2090 |
|
if ( debug ) printf("II %i adc %f \n",ii,adc[ii]); |
2091 |
|
|
2092 |
|
if( adc[ii] >= 4095. ){ |
2093 |
|
// eDEDXpmt[ii] = 0.; |
2094 |
|
eDEDXpmt->AddAt(0.,ii); |
2095 |
|
if ( debug ) printf(" %i adc>4095 \n",ii); |
2096 |
|
continue; // EMILIANO |
2097 |
|
}; |
2098 |
|
|
2099 |
|
if( adc[ii] >= (PMTsat[ii]-5.) && adc[ii] < 4095. ){ |
2100 |
|
eDEDXpmt->AddAt(1000.,ii); |
2101 |
|
if ( debug ) printf(" %i adc> pmtsat && adc<4095 \n",ii); |
2102 |
|
continue; // EMILIANO |
2103 |
|
}; |
2104 |
|
|
2105 |
|
if( adc[ii] <= 0. ) { |
2106 |
|
eDEDXpmt->AddAt(1500.,ii); |
2107 |
|
if ( debug ) printf(" %i adc<=0 \n",ii); |
2108 |
|
continue; |
2109 |
|
}; |
2110 |
|
// |
2111 |
|
double adcpC = f_adcPC( adc[ii] ); // - adc conversion in pC |
2112 |
|
if ( exitat == 0 ){ |
2113 |
|
eDEDXpmt->AddAt((Float_t)adcpC,ii); |
2114 |
|
continue; |
2115 |
|
} |
2116 |
|
// printf(" e qua? \n"); |
2117 |
|
|
2118 |
|
double adccorr = adcpC*fabs(cos(theta)); |
2119 |
|
if ( debug ) printf(" adccorr %f \n",adccorr); |
2120 |
|
if(adccorr<=0.){ |
2121 |
|
if ( debug ) printf(" %i adccorr<=0 \n",ii); |
2122 |
|
// eDEDXpmt->AddAt((Float_t)adcpC,ii);//? |
2123 |
|
continue; |
2124 |
|
} |
2125 |
|
if ( exitat == 1 ){ |
2126 |
|
eDEDXpmt->AddAt((Float_t)adccorr,ii); |
2127 |
|
continue; |
2128 |
|
} |
2129 |
|
// printf(" e quo? \n"); |
2130 |
|
|
2131 |
|
// int standard=0; |
2132 |
|
int S115B_ok=0; |
2133 |
|
int S115B_break=0; |
2134 |
|
|
2135 |
|
if(atime<1158720000)S115B_ok=1; |
2136 |
|
else S115B_break=1; |
2137 |
|
|
2138 |
|
|
2139 |
|
//------------------------------------------------------------------------ |
2140 |
|
// printf(" e qui? \n"); |
2141 |
|
//---------------------------------------------------- Z reconstruction |
2142 |
|
|
2143 |
|
double adcHe, adcnorm, adclin, dEdx;//, Zeta; // EM GCC4.7 |
2144 |
|
|
2145 |
|
adcHe=-2; |
2146 |
|
adcnorm=-2; |
2147 |
|
adclin=-2; |
2148 |
|
dEdx=-2; |
2149 |
|
// Zeta=-2;//EM GCC4.7 |
2150 |
|
Double_t correction = 1.; |
2151 |
|
|
2152 |
|
if(Aconn==1 && (ii==0 || ii==20 || ii==22 || ii==24)){ |
2153 |
|
correction = 1.675; |
2154 |
|
} |
2155 |
|
else if(Bconn==1 && (ii==6 || ii==12 || ii==26 || ii==34)){ |
2156 |
|
correction = 2.482; |
2157 |
|
} |
2158 |
|
else if(Cconn==1 && (ii==4 || ii==14 || ii==28 || ii==32)){ |
2159 |
|
correction = 1.464; |
2160 |
|
} |
2161 |
|
else if(Dconn==1 && (ii==2 || ii==8 || ii==10 || ii==30)){ |
2162 |
|
correction = 1.995; |
2163 |
|
} |
2164 |
|
else if(Econn==1 && (ii==42 || ii==43 || ii==44 || ii==47)){ |
2165 |
|
correction = 1.273; |
2166 |
|
} |
2167 |
|
else if(Fconn==1 && (ii==7 || ii==19 || ii==23 || ii==27)){ |
2168 |
|
correction = 1.565; |
2169 |
|
} |
2170 |
|
else if(Mconn==1 && (ii==15 || ii==16 || ii==17 || ii==18)){ |
2171 |
|
correction = 1.565; |
2172 |
|
} |
2173 |
|
else if(Nconn==1 && (ii==36 || ii==38 || ii==39 || ii==41)){ |
2174 |
|
correction = 1.018; |
2175 |
|
} |
2176 |
|
else if(Hconn==1 && (ii==1 || ii==13 || ii==21 || (ii==9&&S115B_ok==1))){ |
2177 |
|
correction = 1.84; |
2178 |
|
} |
2179 |
|
else if(S115B_break==1 && ii==9 && Hconn==1){ |
2180 |
|
correction = 1.64; |
2181 |
|
} |
2182 |
|
else correction = 1.; |
2183 |
|
|
2184 |
|
if( ii==9 && S115B_break==1 ){ |
2185 |
|
adcHe = f_att5B( ytr_tof[0] )/correction; |
2186 |
|
} else { |
2187 |
|
adcHe = Get_adc_he(ii, xtr_tof, ytr_tof)/correction; |
2188 |
|
}; |
2189 |
|
if(adcHe<=0){ |
2190 |
|
if ( debug ) printf(" %i adcHe<=0 \n",ii); |
2191 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii); //? |
2192 |
|
continue; |
2193 |
|
} |
2194 |
|
if ( exitat == 2 ){ |
2195 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt(36.*(Float_t)adccorr/adcHe,ii); |
2196 |
|
else adclin = 4.*(Float_t)adccorr/adcHe; |
2197 |
|
continue; |
2198 |
|
} |
2199 |
|
|
2200 |
|
if(ii==9 && S115B_break==1) adcnorm = f_pos5B(adccorr); |
2201 |
|
else adcnorm = f_pos( (parPos[ii]), adccorr); |
2202 |
|
if(adcnorm<=0){ |
2203 |
|
if ( debug ) printf(" %i adcnorm<=0 \n",ii); |
2204 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii);//? |
2205 |
|
continue; |
2206 |
|
} |
2207 |
|
if ( debug ) printf(" adcnorm %f \n",adcnorm); |
2208 |
|
|
2209 |
|
if(ii==9 && S115B_break==1) adclin = 36.*adcnorm/adcHe; |
2210 |
|
else adclin = 4.*adcnorm/adcHe; |
2211 |
|
if ( debug ) printf(" adclin %f \n",adclin); |
2212 |
|
if(adclin<=0){ |
2213 |
|
if ( debug ) printf(" %i adclin<=0 \n",ii); |
2214 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii);//? |
2215 |
|
continue; |
2216 |
|
} |
2217 |
|
if ( exitat == 3 ){ |
2218 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt((Float_t)adclin,ii); |
2219 |
|
else eDEDXpmt->AddAt((Float_t)adclin,ii); |
2220 |
|
continue; |
2221 |
|
} |
2222 |
|
// |
2223 |
|
if ( betamean > 99. ){ |
2224 |
|
// eDEDXpmt.AddAt((Float_t)adclin,ii); |
2225 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
2226 |
|
// printf(" AAPMT IS %i dedx is %f vector is %f \n",ii,adclin,eDEDXpmt[ii]); |
2227 |
|
if ( debug ) printf(" %i betamean > 99 \n",ii); |
2228 |
|
continue; |
2229 |
|
}; |
2230 |
|
// |
2231 |
|
double dEdxHe=-2; |
2232 |
|
if(ii==9 && S115B_break==1){ |
2233 |
|
if( betamean <1. ) dEdxHe = f_BB5B( betamean ); |
2234 |
|
else dEdxHe = 33; |
2235 |
|
} else { |
2236 |
|
if( betamean <1. ) dEdxHe = f_BB( (parBBneg[ii]), betamean ); |
2237 |
|
else dEdxHe = parBBpos[ii]; |
2238 |
|
} |
2239 |
|
|
2240 |
|
if ( debug ) printf(" dEdxHe %f \n",dEdxHe); |
2241 |
|
|
2242 |
|
if(dEdxHe<=0){ |
2243 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
2244 |
|
if ( debug ) printf(" %i dEdxHe<=0 \n",ii); |
2245 |
|
continue; |
2246 |
|
}; |
2247 |
|
|
2248 |
|
if(ii==9 && S115B_break==1) dEdx = f_desatBB5B( adclin ); |
2249 |
|
else dEdx = f_desatBB((parDesatBB[ii]), adclin ); |
2250 |
|
|
2251 |
|
if(dEdx<=0){ |
2252 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
2253 |
|
if ( debug ) printf(" %i dEdx<=0 \n",ii); |
2254 |
|
continue; |
2255 |
|
}; |
2256 |
|
|
2257 |
|
if ( debug ) printf(" dEdx %f \n",dEdx); |
2258 |
|
eDEDXpmt->AddAt((Float_t)dEdx,ii); |
2259 |
|
// eDEDXpmt.AddAt((Float_t)dEdx,ii); |
2260 |
|
|
2261 |
|
// printf(" PMT IS %i dedx is %f vector is %f \n",ii,dEdx,eDEDXpmt[ii]); |
2262 |
|
|
2263 |
|
} //end loop on 48 PMT |
2264 |
|
|
2265 |
|
}; |
2266 |
|
|
2267 |
|
|
2268 |
|
//------------------------------------------------------------------------ |
2269 |
|
void ToFdEdx::Define_PMTsat() |
2270 |
|
{ |
2271 |
|
Float_t sat[48] = { |
2272 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
2273 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
2274 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
2275 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
2276 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
2277 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
2278 |
|
PMTsat.Set(48,sat); |
2279 |
|
} |
2280 |
|
|
2281 |
|
//------------------------------------------------------------------------ |
2282 |
|
void ToFdEdx::ReadParBBpos( const char *fname ) |
2283 |
|
{ |
2284 |
|
// printf("read %s\n",fname); |
2285 |
|
parBBpos.Set(48); |
2286 |
|
FILE *fattin = fopen( fname , "r" ); |
2287 |
|
for (int i=0; i<48; i++) { |
2288 |
|
int tid=0; |
2289 |
|
float tp; |
2290 |
|
if(fscanf(fattin,"%d %f", |
2291 |
|
&tid, &tp )!=2) break; |
2292 |
|
parBBpos[i]=tp; |
2293 |
|
} |
2294 |
|
fclose(fattin); |
2295 |
|
} |
2296 |
|
|
2297 |
|
//------------------------------------------------------------------------ |
2298 |
|
void ToFdEdx::ReadParDesatBB( const char *fname ) |
2299 |
|
{ |
2300 |
|
// printf("read %s\n",fname); |
2301 |
|
FILE *fattin = fopen( fname , "r" ); |
2302 |
|
for (int i=0; i<48; i++) { |
2303 |
|
int tid=0; |
2304 |
|
float tp[3]; |
2305 |
|
if(fscanf(fattin,"%d %f %f %f", |
2306 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
2307 |
|
parDesatBB[i].Set(3,tp); |
2308 |
|
} |
2309 |
|
fclose(fattin); |
2310 |
|
} |
2311 |
|
|
2312 |
|
|
2313 |
|
//------------------------------------------------------------------------ |
2314 |
|
void ToFdEdx::ReadParBBneg( const char *fname ) |
2315 |
|
|
2316 |
|
{ |
2317 |
|
// printf("read %s\n",fname); |
2318 |
|
FILE *fattin = fopen( fname , "r" ); |
2319 |
|
for (int i=0; i<48; i++) { |
2320 |
|
int tid=0; |
2321 |
|
float tp[3]; |
2322 |
|
if(fscanf(fattin,"%d %f %f %f", |
2323 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
2324 |
|
parBBneg[i].Set(3,tp); |
2325 |
|
} |
2326 |
|
fclose(fattin); |
2327 |
|
} |
2328 |
|
|
2329 |
|
//------------------------------------------------------------------------ |
2330 |
|
void ToFdEdx::ReadParPos( const char *fname ) |
2331 |
|
{ |
2332 |
|
// printf("read %s\n",fname); |
2333 |
|
FILE *fattin = fopen( fname , "r" ); |
2334 |
|
for (int i=0; i<48; i++) { |
2335 |
|
int tid=0; |
2336 |
|
float tp[4]; |
2337 |
|
if(fscanf(fattin,"%d %f %f %f %f", |
2338 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3])!=5) break; |
2339 |
|
parPos[i].Set(4,tp); |
2340 |
|
} |
2341 |
|
fclose(fattin); |
2342 |
|
} |
2343 |
|
|
2344 |
|
//------------------------------------------------------------------------ |
2345 |
|
void ToFdEdx::ReadParAtt( const char *fname ) |
2346 |
|
{ |
2347 |
|
// printf("read %s\n",fname); |
2348 |
|
FILE *fattin = fopen( fname , "r" ); |
2349 |
|
for (int i=0; i<48; i++) { |
2350 |
|
int tid=0; |
2351 |
|
float tp[6]; |
2352 |
|
if(fscanf(fattin,"%d %f %f %f %f %f %f", |
2353 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3], &tp[4], &tp[5] )!=7) break; |
2354 |
|
parAtt[i].Set(6,tp); |
2355 |
|
} |
2356 |
|
fclose(fattin); |
2357 |
|
} |
2358 |
|
|
2359 |
|
|
2360 |
|
|
2361 |
|
|
2362 |
|
|
2363 |
|
|
2364 |
|
double ToFdEdx::f_att( TArrayF &p, float x ) |
2365 |
|
{ |
2366 |
|
return |
2367 |
|
p[0] + |
2368 |
|
p[1]*x + |
2369 |
|
p[2]*x*x + |
2370 |
|
p[3]*x*x*x + |
2371 |
|
p[4]*x*x*x*x + |
2372 |
|
p[5]*x*x*x*x*x; |
2373 |
|
} |
2374 |
|
//------------------------------------------------------------------------ |
2375 |
|
double ToFdEdx::f_att5B( float x ) |
2376 |
|
{ |
2377 |
|
return |
2378 |
|
101.9409 + |
2379 |
|
6.643781*x + |
2380 |
|
0.2765518*x*x + |
2381 |
|
0.004617647*x*x*x + |
2382 |
|
0.0006195132*x*x*x*x + |
2383 |
|
0.00002813734*x*x*x*x*x; |
2384 |
|
} |
2385 |
|
|
2386 |
|
|
2387 |
|
double ToFdEdx::f_pos( TArrayF &p, float x ) |
2388 |
|
{ |
2389 |
|
return |
2390 |
|
p[0] + |
2391 |
|
p[1]*x + |
2392 |
|
p[2]*x*x + |
2393 |
|
p[3]*x*x*x; |
2394 |
|
} |
2395 |
|
|
2396 |
|
double ToFdEdx::f_pos5B( float x ) |
2397 |
|
{ |
2398 |
|
return |
2399 |
|
15.45132 + |
2400 |
|
0.8369721*x + |
2401 |
|
0.0005*x*x; |
2402 |
|
} |
2403 |
|
|
2404 |
|
|
2405 |
|
|
2406 |
|
double ToFdEdx::f_adcPC( float x ) |
2407 |
|
{ |
2408 |
|
return 28.12+0.6312*x-5.647e-05*x*x+3.064e-08*x*x*x; |
2409 |
|
} |
2410 |
|
|
2411 |
|
|
2412 |
|
float ToFdEdx::Get_adc_he( int id, float pl_x[6], float pl_y[6]) |
2413 |
|
{ |
2414 |
|
|
2415 |
// |
// |
2416 |
Int_t pmt_id = 0; |
// input: id - pmt [0:47} |
2417 |
ToFPMT *t_pmt = new ToFPMT(); |
// pl_x - coord x of the tof plane |
2418 |
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
// pl_y - coord y |
2419 |
TClonesArray &tpmt = *this->PMT; |
|
2420 |
ToFTrkVar *t_tof = new ToFTrkVar(); |
adc_he = 0; |
2421 |
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
if( eGeom.GetXY(id)==1 ) adc_he = f_att( (parAtt[id]), pl_x[eGeom.GetPlane(id)] ); |
2422 |
TClonesArray &t = *this->ToFTrk; |
if( eGeom.GetXY(id)==2 ) adc_he = f_att( (parAtt[id]), pl_y[eGeom.GetPlane(id)] ); |
2423 |
// |
return adc_he; |
2424 |
// |
} |
|
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
|
|
// |
|
|
npmtentry = 0; |
|
|
// |
|
|
ntrkentry = 0; |
|
|
// |
|
|
// Calculate tracks informations from ToF alone |
|
|
// |
|
|
tofl2com(); |
|
|
// |
|
|
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
|
|
// |
|
|
t_tof->trkseqno = -1; |
|
|
// |
|
|
// and now we must copy from the output structure to the level2 class: |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
|
|
} |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
// |
|
|
// |
|
|
t_pmt->Clear(); |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
// new WM |
|
|
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// |
|
|
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
|
|
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
|
|
t_pmt->adc = (Float_t)adc[kk][hh]; |
|
|
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
|
|
// |
|
|
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
|
|
npmtentry++; |
|
|
t_pmt->Clear(); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
// Calculate track-related variables |
|
|
// |
|
|
if ( trk->ntrk() > 0 ){ |
|
|
// |
|
|
// We have at least one track |
|
|
// |
|
|
// |
|
|
// Run over tracks |
|
|
// |
|
|
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
|
|
// |
|
|
TrkTrack *ptt = trk->GetStoredTrack(nt); |
|
|
// |
|
|
// Copy the alpha vector in the input structure |
|
|
// |
|
|
for (Int_t e = 0; e < 5 ; e++){ |
|
|
tofinput_.al_pp[e] = ptt->al[e]; |
|
|
}; |
|
|
// |
|
|
// Get tracker related variables for this track |
|
|
// |
|
|
toftrk(); |
|
|
// |
|
|
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
|
|
}; |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
|
|
// |
|
|
t_tof->trkseqno = nt; |
|
|
// |
|
|
// create a new object for this event with track-related variables |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
}; // loop on all the tracks |
|
|
// |
|
|
this->unpackError = unpackError; |
|
|
if ( defcal ){ |
|
|
this->default_calib = 1; |
|
|
} else { |
|
|
this->default_calib = 0; |
|
|
}; |
|
|
}; |
|
2425 |
|
|
2426 |
|
//------------------------------------------------------------------------ |
2427 |
|
double ToFdEdx::f_BB( TArrayF &p, float x ) |
2428 |
|
{ |
2429 |
|
return p[0]/(x*x)*(log(x*x/(1-x*x)) - p[1]*x*x - p[2]); |
2430 |
|
} |
2431 |
|
|
2432 |
|
//------------------------------------------------------------------------ |
2433 |
|
double ToFdEdx::f_BB5B( float x ) |
2434 |
|
{ |
2435 |
|
return 0.165797/(x*x)*(log(x*x/(1-x*x)) + 140.481*x*x + 52.9258); |
2436 |
|
} |
2437 |
|
//------------------------------------------------------------------------ |
2438 |
|
double ToFdEdx::f_desatBB( TArrayF &p, float x ) |
2439 |
|
{ |
2440 |
|
return |
2441 |
|
p[0] + |
2442 |
|
p[1]*x + |
2443 |
|
p[2]*x*x; |
2444 |
|
} |
2445 |
|
|
2446 |
return(0); |
//------------------------------------------------------------------------ |
2447 |
|
double ToFdEdx::f_desatBB5B( float x ) |
2448 |
|
{ |
2449 |
|
return |
2450 |
|
-2.4 + |
2451 |
|
0.75*x + |
2452 |
|
0.009*x*x; |
2453 |
} |
} |
2454 |
|
|