1 |
|
/** |
2 |
|
* \file ToFLevel2.cpp |
3 |
|
* \author Gianfranca DeRosa, Wolfgang Menn |
4 |
|
*/ |
5 |
|
|
6 |
#include <TObject.h> |
#include <TObject.h> |
7 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
8 |
#include <iostream> |
#include <iostream> |
15 |
pmt_id = 0; |
pmt_id = 0; |
16 |
adc = 0.; |
adc = 0.; |
17 |
tdc_tw = 0.; |
tdc_tw = 0.; |
18 |
|
tdc = 0.; |
19 |
} |
} |
20 |
|
|
21 |
ToFPMT::ToFPMT(const ToFPMT &t){ |
ToFPMT::ToFPMT(const ToFPMT &t){ |
22 |
pmt_id = t.pmt_id; |
pmt_id = t.pmt_id; |
23 |
adc = t.adc; |
adc = t.adc; |
24 |
tdc_tw = t.tdc_tw; |
tdc_tw = t.tdc_tw; |
25 |
|
tdc = t.tdc; |
26 |
} |
} |
27 |
|
|
28 |
void ToFPMT::Clear(){ |
void ToFPMT::Clear(Option_t *t){ |
29 |
pmt_id = 0; |
pmt_id = 0; |
30 |
adc = 0.; |
adc = 0.; |
31 |
tdc_tw = 0.; |
tdc_tw = 0.; |
32 |
|
tdc = 0.; |
33 |
} |
} |
34 |
|
|
35 |
|
|
48 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
49 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
50 |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
51 |
|
memset(xtr_tof, 0, 6*sizeof(Float_t)); |
52 |
|
memset(ytr_tof, 0, 6*sizeof(Float_t)); |
53 |
// |
// |
54 |
}; |
}; |
55 |
|
|
56 |
void ToFTrkVar::Clear() { |
void ToFTrkVar::Clear(Option_t *t) { |
57 |
trkseqno = 0; |
trkseqno = 0; |
58 |
npmttdc = 0; |
npmttdc = 0; |
59 |
npmtadc = 0; |
npmtadc = 0; |
66 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
67 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
68 |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
69 |
|
memset(xtr_tof, 0, 6*sizeof(Float_t)); |
70 |
|
memset(ytr_tof, 0, 6*sizeof(Float_t)); |
71 |
// |
// |
72 |
}; |
}; |
73 |
|
|
86 |
memcpy(beta,t.beta,sizeof(beta)); |
memcpy(beta,t.beta,sizeof(beta)); |
87 |
memcpy(xtofpos,t.xtofpos,sizeof(xtofpos)); |
memcpy(xtofpos,t.xtofpos,sizeof(xtofpos)); |
88 |
memcpy(ytofpos,t.ytofpos,sizeof(ytofpos)); |
memcpy(ytofpos,t.ytofpos,sizeof(ytofpos)); |
89 |
|
memcpy(xtr_tof,t.xtr_tof,sizeof(xtr_tof)); |
90 |
|
memcpy(ytr_tof,t.ytr_tof,sizeof(ytr_tof)); |
91 |
// |
// |
92 |
}; |
}; |
93 |
|
|
102 |
// |
// |
103 |
}; |
}; |
104 |
|
|
105 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Set(){//ELENA |
106 |
|
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
107 |
|
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
108 |
|
}//ELENA |
109 |
|
|
110 |
|
void ToFLevel2::Clear(Option_t *t){ |
111 |
// |
// |
112 |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
113 |
if(PMT)PMT->Delete(); //ELENA |
if(PMT)PMT->Delete(); //ELENA |
116 |
// |
// |
117 |
}; |
}; |
118 |
|
|
119 |
void ToFLevel2::Delete(){ //ELENA |
void ToFLevel2::Delete(Option_t *t){ //ELENA |
120 |
// |
// |
121 |
if(ToFTrk){ |
if(ToFTrk){ |
122 |
ToFTrk->Delete(); //ELENA |
ToFTrk->Delete(); //ELENA |
162 |
//-------------------------------------- |
//-------------------------------------- |
163 |
/** |
/** |
164 |
* Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5) |
* Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5) |
165 |
|
* @param Plane index (0,1,2,3,4,5). |
166 |
*/ |
*/ |
167 |
Int_t ToFLevel2::GetToFPlaneID(Int_t ip){ |
Int_t ToFLevel2::GetToFPlaneID(Int_t ip){ |
168 |
if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1; |
if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1; |
170 |
}; |
}; |
171 |
/** |
/** |
172 |
* Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32) |
* Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32) |
173 |
|
* @param plane Plane ID (11, 12, 21, 22, 31, 32) |
174 |
*/ |
*/ |
175 |
Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){ |
Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){ |
176 |
if( |
if( |
185 |
}; |
}; |
186 |
/** |
/** |
187 |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
188 |
* from both PMTs |
* from both PMTs. The method uses the "tof_j_flag" variable. |
189 |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
190 |
* @param paddle_id Paddle ID. |
* @param paddle_id Paddle ID. |
191 |
* @return 1 if the paddle was hit. |
* @return 1 if the paddle was hit. |
217 |
}; |
}; |
218 |
|
|
219 |
|
|
220 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
//gf Apr 07 |
221 |
|
/** |
222 |
|
* Method to get the mean dEdx from a given ToF plane. This current version |
223 |
|
* is just summing up all PMT signals, which will not give proper results, |
224 |
|
* and needs a revision. |
225 |
|
* @param notrack Track Number |
226 |
|
* @param plane Plane index (0,1,2,3,4,5) |
227 |
|
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
228 |
|
*/ |
229 |
|
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
230 |
|
|
231 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
232 |
Int_t ip = 0; |
Float_t PadEdx =0.; |
233 |
Int_t pmt_id = 0; |
Int_t SatWarning; |
234 |
Int_t pl = 0; |
Int_t pad=-1; |
|
if ( plane >= 6 ){ |
|
|
ip = GetToFPlaneIndex(plane); |
|
|
} else { |
|
|
ip = plane; |
|
|
}; |
|
235 |
// |
// |
236 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
237 |
if(!trk) return 0; //ELENA |
if(!trk) return 0; //ELENA |
238 |
// |
// |
239 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
240 |
// |
Int_t paddleid=ii; |
241 |
pmt_id = (trk->pmtadc).At(i); |
pad = GetPaddleid(plane,paddleid); |
242 |
// |
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
243 |
pl = GetPlaneIndex(pmt_id); |
dedx += PadEdx; |
|
// |
|
|
if ( pl == ip ){ |
|
|
// // --- patch --- |
|
|
// bool ISNULL=false; |
|
|
// for(Int_t im=0; im< this->npmt(); im++){ |
|
|
// if(this->GetToFPMT(im)->pmt_id == pmt_id && this->GetToFPMT(im)->adc == 4095){ |
|
|
// cout << " ToFLevel2::GetdEdx(Int_t,Int_t) --> **warning** ADC(PMT="<<pmt_id<<") = 4095"<<endl; |
|
|
// ISNULL=true; |
|
|
// } |
|
|
// } |
|
|
// // --- patch --- |
|
|
// dedx += (trk->dedx).At(i)*(Int_t)(!ISNULL); |
|
|
dedx += (trk->dedx).At(i); |
|
|
} |
|
|
// |
|
244 |
}; |
}; |
245 |
// |
// |
246 |
return(dedx); |
return(dedx); |
247 |
}; |
}; |
248 |
|
|
249 |
|
/** |
250 |
|
* Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix |
251 |
|
* with the time-walk corrected TDC values. |
252 |
|
* @param notrack Track Number |
253 |
|
* @param adc ADC_C matrix with dEdx values |
254 |
|
* @param tdc TDC matrix |
255 |
|
*/ |
256 |
void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){ |
void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){ |
257 |
// |
// |
258 |
for (Int_t aa=0; aa<4;aa++){ |
for (Int_t aa=0; aa<4;aa++){ |
293 |
}; |
}; |
294 |
|
|
295 |
|
|
296 |
|
/** |
297 |
|
* Method to get the plane index (0 - 5) for the PMT_ID as input |
298 |
|
* @param pmt_id PMT_ID (0 - 47) |
299 |
|
*/ |
300 |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
301 |
TString pmtname = GetPMTName(pmt_id); |
TString pmtname = GetPMTName(pmt_id); |
302 |
pmtname.Resize(3); |
pmtname.Resize(3); |
310 |
}; |
}; |
311 |
|
|
312 |
|
|
313 |
|
/** |
314 |
|
* Method to get the PMT_ID if the index (4,12) is given. We have 4 channels on |
315 |
|
* each of the 12 half-boards, this method decodes which PMT is cables to which |
316 |
|
* channel. |
317 |
|
* @param hh Channel |
318 |
|
* @param kk HalfBoard |
319 |
|
*/ |
320 |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
321 |
// |
// |
322 |
short tof[4][24] = { |
short tof[4][24] = { |
345 |
return ind; |
return ind; |
346 |
}; |
}; |
347 |
|
|
|
TString ToFLevel2::GetPMTName(Int_t ind){ |
|
|
|
|
|
TString pmtname = " "; |
|
|
|
|
|
TString photoS[48] = { |
|
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", "S11_4B", |
|
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", "S11_8B", |
|
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", "S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
|
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
|
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
|
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
|
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
|
|
}; |
|
|
|
|
|
|
|
|
pmtname = photoS[ind].Data(); |
|
|
|
|
|
return pmtname; |
|
|
}; |
|
|
|
|
348 |
|
|
349 |
|
/** |
350 |
|
* Method to get the PMT index if the PMT ID is given. This method is the |
351 |
|
* "reverse" of method "GetPMTid" |
352 |
|
* @param ind PMT_ID (0 - 47) |
353 |
|
* @param hb HalfBoard |
354 |
|
* @param ch Channel |
355 |
|
*/ |
356 |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
357 |
// |
// |
358 |
short tof[4][24] = { |
short tof[4][24] = { |
379 |
return; |
return; |
380 |
}; |
}; |
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
/// gf Apr 07 |
386 |
|
|
387 |
|
/** |
388 |
|
* Method to get the dEdx from a given ToF paddle. |
389 |
|
* @param notrack Track Number |
390 |
|
* @param Paddle index (0,1,...,23). |
391 |
|
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
392 |
|
* @param PadEdx dEdx from a given ToF paddle |
393 |
|
* @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000) |
394 |
|
*/ |
395 |
|
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
396 |
|
|
397 |
|
PadEdx = 0.; |
398 |
|
SatWarning = 1000; |
399 |
|
|
400 |
|
Float_t dEdx[48] = {0}; |
401 |
|
Int_t pmt_id = -1; |
402 |
|
Float_t adcraw[48]; |
403 |
|
// |
404 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
405 |
|
if(!trk) return; //ELENA |
406 |
|
// |
407 |
|
|
408 |
|
Int_t pmtleft=-1; |
409 |
|
Int_t pmtright=-1; |
410 |
|
GetPaddlePMT(paddleid, pmtleft, pmtright); |
411 |
|
|
412 |
|
adcraw[pmtleft] = 4095; |
413 |
|
adcraw[pmtright] = 4095; |
414 |
|
|
415 |
|
|
416 |
|
for (Int_t jj=0; jj<npmt(); jj++){ |
417 |
|
|
418 |
|
ToFPMT *pmt = GetToFPMT(jj); |
419 |
|
if(!pmt)break; //ELENA |
420 |
|
|
421 |
|
pmt_id = pmt->pmt_id; |
422 |
|
if(pmt_id==pmtleft){ |
423 |
|
adcraw[pmtleft] = pmt->adc; |
424 |
|
} |
425 |
|
|
426 |
|
if(pmt_id==pmtright){ |
427 |
|
adcraw[pmtright] = pmt->adc; |
428 |
|
} |
429 |
|
} |
430 |
|
|
431 |
|
for (Int_t i=0; i<trk->npmtadc; i++){ |
432 |
|
|
433 |
|
if((trk->adcflag).At(i)==0 || adcfl==100){ |
434 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = (trk->dedx).At(i); |
435 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = (trk->dedx).At(i); |
436 |
|
}else{ |
437 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = 0.; |
438 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = 0.; |
439 |
|
} |
440 |
|
} |
441 |
|
|
442 |
|
if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; |
443 |
|
|
444 |
|
if(dEdx[pmtleft]!=0 && dEdx[pmtright]!=0){ |
445 |
|
PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
446 |
|
} |
447 |
|
if(dEdx[pmtleft]==0 && dEdx[pmtright]!=0){ |
448 |
|
PadEdx = dEdx[pmtright]; |
449 |
|
} |
450 |
|
if(dEdx[pmtleft]!=0 && dEdx[pmtright]==0){ |
451 |
|
PadEdx = dEdx[pmtleft]; |
452 |
|
} |
453 |
|
|
454 |
|
return; |
455 |
|
}; |
456 |
|
// |
457 |
|
|
458 |
|
|
459 |
|
// gf Apr 07 |
460 |
|
|
461 |
|
/** |
462 |
|
* Method to get the PMT name (like "S11_1A") if the PMT_ID is given. |
463 |
|
* Indexes of corresponding plane, paddle and pmt are also given as output. |
464 |
|
* @param ind PMT_ID (0 - 47) |
465 |
|
* @param iplane plane index (0 - 5) |
466 |
|
* @param ipaddle paddle index (relative to the plane) |
467 |
|
* @param ipmt pmt index (0(A), 1(B)) |
468 |
|
*/ |
469 |
|
TString ToFLevel2::GetPMTName(Int_t ind, Int_t &iplane, Int_t &ipaddle,Int_t &ipmt){ |
470 |
|
|
471 |
|
TString pmtname = " "; |
472 |
|
|
473 |
|
TString photoS[48] = { |
474 |
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", |
475 |
|
"S11_4B", |
476 |
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", |
477 |
|
"S11_8B", |
478 |
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", |
479 |
|
"S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
480 |
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
481 |
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
482 |
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
483 |
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
484 |
|
}; |
485 |
|
|
486 |
|
|
487 |
|
pmtname = photoS[ind].Data(); |
488 |
|
|
489 |
|
TString ss = pmtname(1,2); |
490 |
|
iplane = (int)(atoi(ss.Data())/10)*2-3+atoi(ss.Data())%10; |
491 |
|
ss = pmtname(4); |
492 |
|
ipaddle = atoi(ss.Data())-1 ; |
493 |
|
if( pmtname.Contains("A") )ipmt=0; |
494 |
|
if( pmtname.Contains("B") )ipmt=1; |
495 |
|
|
496 |
|
return pmtname; |
497 |
|
}; |
498 |
|
/** |
499 |
|
* Method to get the PMT name (like "S11_1A") if the PMT_ID is given |
500 |
|
* @param ind PMT_ID (0 - 47) |
501 |
|
*/ |
502 |
|
TString ToFLevel2::GetPMTName(Int_t ind){ |
503 |
|
|
504 |
|
Int_t iplane = -1; |
505 |
|
Int_t ipaddle = -1; |
506 |
|
Int_t ipmt = -1; |
507 |
|
return GetPMTName(ind,iplane,ipaddle,ipmt); |
508 |
|
|
509 |
|
}; |
510 |
|
|
511 |
|
|
512 |
|
// gf Apr 07 |
513 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
514 |
|
|
515 |
|
Double_t xt,yt,xl,xh,yl,yh; |
516 |
|
|
517 |
|
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
518 |
|
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
519 |
|
Float_t tof21_y[2] = { 3.75,-3.75}; |
520 |
|
Float_t tof22_x[2] = { -4.5,4.5}; |
521 |
|
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
522 |
|
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
523 |
|
|
524 |
|
// S11 8 paddles 33.0 x 5.1 cm |
525 |
|
// S12 6 paddles 40.8 x 5.5 cm |
526 |
|
// S21 2 paddles 18.0 x 7.5 cm |
527 |
|
// S22 2 paddles 15.0 x 9.0 cm |
528 |
|
// S31 3 paddles 15.0 x 6.0 cm |
529 |
|
// S32 3 paddles 18.0 x 5.0 cm |
530 |
|
|
531 |
|
Int_t paddleidoftrack=-1; |
532 |
|
// |
533 |
|
|
534 |
|
//--- S11 ------ |
535 |
|
|
536 |
|
if(plane==0){ |
537 |
|
xt = xtr; |
538 |
|
yt = ytr; |
539 |
|
paddleidoftrack=-1; |
540 |
|
yl = -33.0/2. ; |
541 |
|
yh = 33.0/2. ; |
542 |
|
if ((yt>yl)&&(yt<yh)) { |
543 |
|
for (Int_t i1=0; i1<8;i1++){ |
544 |
|
xl = tof11_x[i1] - (5.1-0.4)/2. ; |
545 |
|
xh = tof11_x[i1] + (5.1-0.4)/2. ; |
546 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
547 |
|
} |
548 |
|
} |
549 |
|
} |
550 |
|
// cout<<"S11 "<<paddleidoftrack[0]<<"\n"; |
551 |
|
|
552 |
|
//--- S12 ------- |
553 |
|
if(plane==1){ |
554 |
|
xt = xtr; |
555 |
|
yt = ytr; |
556 |
|
paddleidoftrack=-1; |
557 |
|
xl = -40.8/2. ; |
558 |
|
xh = 40.8/2. ; |
559 |
|
|
560 |
|
if ((xt>xl)&&(xt<xh)) { |
561 |
|
for (Int_t i1=0; i1<6;i1++){ |
562 |
|
yl = tof12_y[i1] - (5.5-0.4)/2. ; |
563 |
|
yh = tof12_y[i1] + (5.5-0.4)/2. ; |
564 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
565 |
|
} |
566 |
|
} |
567 |
|
} |
568 |
|
|
569 |
|
//--- S21 ------ |
570 |
|
|
571 |
|
if(plane==2){ |
572 |
|
xt = xtr; |
573 |
|
yt = ytr; |
574 |
|
paddleidoftrack=-1; |
575 |
|
xl = -18./2. ; |
576 |
|
xh = 18./2. ; |
577 |
|
|
578 |
|
if ((xt>xl)&&(xt<xh)) { |
579 |
|
for (Int_t i1=0; i1<2;i1++){ |
580 |
|
yl = tof21_y[i1] - (7.5-0.4)/2. ; |
581 |
|
yh = tof21_y[i1] + (7.5-0.4)/2. ; |
582 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
583 |
|
} |
584 |
|
} |
585 |
|
} |
586 |
|
|
587 |
|
//--- S22 ------ |
588 |
|
if(plane==3){ |
589 |
|
xt = xtr; |
590 |
|
yt = ytr; |
591 |
|
paddleidoftrack=-1; |
592 |
|
yl = -15./2. ; |
593 |
|
yh = 15./2. ; |
594 |
|
|
595 |
|
if ((yt>yl)&&(yt<yh)) { |
596 |
|
for (Int_t i1=0; i1<2;i1++){ |
597 |
|
xl = tof22_x[i1] - (9.0-0.4)/2. ; |
598 |
|
xh = tof22_x[i1] + (9.0-0.4)/2. ; |
599 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
600 |
|
} |
601 |
|
} |
602 |
|
} |
603 |
|
|
604 |
|
//--- S31 ------ |
605 |
|
if(plane==4){ |
606 |
|
xt = xtr; |
607 |
|
yt = ytr; |
608 |
|
paddleidoftrack=-1; |
609 |
|
yl = -15.0/2. ; |
610 |
|
yh = 15.0/2. ; |
611 |
|
|
612 |
|
if ((yt>yl)&&(yt<yh)) { |
613 |
|
for (Int_t i1=0; i1<3;i1++){ |
614 |
|
xl = tof31_x[i1] - (6.0-0.4)/2. ; |
615 |
|
xh = tof31_x[i1] + (6.0-0.4)/2. ; |
616 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
617 |
|
} |
618 |
|
} |
619 |
|
} |
620 |
|
|
621 |
|
//--- S32 ------ |
622 |
|
if(plane==5){ |
623 |
|
xt = xtr; |
624 |
|
yt = ytr; |
625 |
|
paddleidoftrack=-1; |
626 |
|
xl = -18.0/2. ; |
627 |
|
xh = 18.0/2. ; |
628 |
|
|
629 |
|
if ((xt>xl)&&(xt<xh)) { |
630 |
|
for (Int_t i1=0; i1<3;i1++){ |
631 |
|
yl = tof32_y[i1] - (5.0-0.4)/2. ; |
632 |
|
yh = tof32_y[i1] + (5.0-0.4)/2. ; |
633 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
634 |
|
} |
635 |
|
} |
636 |
|
} |
637 |
|
|
638 |
|
return paddleidoftrack; |
639 |
|
|
640 |
|
} |
641 |
|
|
642 |
|
// |
643 |
|
|
644 |
|
// gf Apr 07 |
645 |
|
|
646 |
|
void ToFLevel2::GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle){ |
647 |
|
|
648 |
|
plane = GetPlaneIndex(pmt_id); |
649 |
|
|
650 |
|
if(plane == 0){ |
651 |
|
if(pmt_id==0 || pmt_id==1)paddle=0; |
652 |
|
if(pmt_id==2 || pmt_id==3)paddle=1; |
653 |
|
if(pmt_id==4 || pmt_id==5)paddle=2; |
654 |
|
if(pmt_id==6 || pmt_id==7)paddle=3; |
655 |
|
if(pmt_id==8 || pmt_id==9)paddle=4; |
656 |
|
if(pmt_id==10 || pmt_id==11)paddle=5; |
657 |
|
if(pmt_id==12 || pmt_id==13)paddle=6; |
658 |
|
if(pmt_id==14 || pmt_id==15)paddle=7; |
659 |
|
} |
660 |
|
|
661 |
|
if(plane == 1){ |
662 |
|
if(pmt_id==16 || pmt_id==17)paddle=0; |
663 |
|
if(pmt_id==18 || pmt_id==19)paddle=1; |
664 |
|
if(pmt_id==20 || pmt_id==21)paddle=2; |
665 |
|
if(pmt_id==22 || pmt_id==23)paddle=3; |
666 |
|
if(pmt_id==24 || pmt_id==25)paddle=4; |
667 |
|
if(pmt_id==26 || pmt_id==27)paddle=5; |
668 |
|
} |
669 |
|
|
670 |
|
if(plane == 2){ |
671 |
|
if(pmt_id==28 || pmt_id==29)paddle=0; |
672 |
|
if(pmt_id==30 || pmt_id==31)paddle=1; |
673 |
|
} |
674 |
|
|
675 |
|
if(plane == 3){ |
676 |
|
if(pmt_id==32 || pmt_id==33)paddle=0; |
677 |
|
if(pmt_id==34 || pmt_id==35)paddle=1; |
678 |
|
} |
679 |
|
|
680 |
|
if(plane == 4){ |
681 |
|
if(pmt_id==36 || pmt_id==37)paddle=0; |
682 |
|
if(pmt_id==38 || pmt_id==39)paddle=1; |
683 |
|
if(pmt_id==40 || pmt_id==41)paddle=2; |
684 |
|
} |
685 |
|
|
686 |
|
if(plane == 5){ |
687 |
|
if(pmt_id==42 || pmt_id==43)paddle=0; |
688 |
|
if(pmt_id==44 || pmt_id==45)paddle=1; |
689 |
|
if(pmt_id==46 || pmt_id==47)paddle=2; |
690 |
|
} |
691 |
|
return; |
692 |
|
} |
693 |
|
|
694 |
|
// |
695 |
|
|
696 |
|
// gf Apr 07 |
697 |
|
|
698 |
|
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
699 |
|
pmtleft=paddle*2; |
700 |
|
pmtright= pmtleft+1; |
701 |
|
return; |
702 |
|
} |
703 |
|
|
704 |
|
// |
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
// // gf Apr 07 |
709 |
|
|
710 |
|
void ToFLevel2::GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright){ |
711 |
|
|
712 |
|
Int_t i1; |
713 |
|
|
714 |
|
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
715 |
|
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
716 |
|
Float_t tof21_y[2] = { 3.75,-3.75}; |
717 |
|
Float_t tof22_x[2] = { -4.5,4.5}; |
718 |
|
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
719 |
|
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
720 |
|
|
721 |
|
// S11 8 paddles 33.0 x 5.1 cm |
722 |
|
// S12 6 paddles 40.8 x 5.5 cm |
723 |
|
// S21 2 paddles 18.0 x 7.5 cm |
724 |
|
// S22 2 paddles 15.0 x 9.0 cm |
725 |
|
// S31 3 paddles 15.0 x 6.0 cm |
726 |
|
// S32 3 paddles 18.0 x 5.0 cm |
727 |
|
|
728 |
|
if(plane==0) |
729 |
|
{ |
730 |
|
for (i1=0; i1<8;i1++){ |
731 |
|
if(i1 == paddle){ |
732 |
|
xleft = tof11_x[i1] - 5.1/2.; |
733 |
|
xright = tof11_x[i1] + 5.1/2.; |
734 |
|
yleft = -33.0/2.; |
735 |
|
yright = 33.0/2.; |
736 |
|
} |
737 |
|
} |
738 |
|
} |
739 |
|
|
740 |
|
if(plane==1) |
741 |
|
{ |
742 |
|
for (i1=0; i1<6;i1++){ |
743 |
|
if(i1 == paddle){ |
744 |
|
xleft = -40.8/2.; |
745 |
|
xright = 40.8/2.; |
746 |
|
yleft = tof12_y[i1] - 5.5/2.; |
747 |
|
yright = tof12_y[i1] + 5.5/2.; |
748 |
|
} |
749 |
|
} |
750 |
|
} |
751 |
|
|
752 |
|
if(plane==2) |
753 |
|
{ |
754 |
|
for (i1=0; i1<2;i1++){ |
755 |
|
if(i1 == paddle){ |
756 |
|
xleft = -18./2.; |
757 |
|
xright = 18./2.; |
758 |
|
yleft = tof21_y[i1] - 7.5/2.; |
759 |
|
yright = tof21_y[i1] + 7.5/2.; |
760 |
|
} |
761 |
|
} |
762 |
|
} |
763 |
|
|
764 |
|
if(plane==3) |
765 |
|
{ |
766 |
|
for (i1=0; i1<2;i1++){ |
767 |
|
if(i1 == paddle){ |
768 |
|
xleft = tof22_x[i1] - 9.0/2.; |
769 |
|
xright = tof22_x[i1] + 9.0/2.; |
770 |
|
yleft = -15./2.; |
771 |
|
yright = 15./2.; |
772 |
|
} |
773 |
|
} |
774 |
|
} |
775 |
|
|
776 |
|
|
777 |
|
if(plane==4) |
778 |
|
{ |
779 |
|
for (i1=0; i1<3;i1++){ |
780 |
|
if(i1 == paddle){ |
781 |
|
xleft = tof31_x[i1] - 6.0/2.; |
782 |
|
xright = tof31_x[i1] + 6.0/2.; |
783 |
|
yleft = -15./2.; |
784 |
|
yright = 15./2.; |
785 |
|
} |
786 |
|
} |
787 |
|
} |
788 |
|
|
789 |
|
if(plane==5) |
790 |
|
{ |
791 |
|
for (i1=0; i1<3;i1++){ |
792 |
|
if(i1 == paddle){ |
793 |
|
xleft = -18.0/2.; |
794 |
|
xright = 18.0/2.; |
795 |
|
yleft = tof32_y[i1] - 5.0/2.; |
796 |
|
yright = tof32_y[i1] + 5.0/2.; |
797 |
|
} |
798 |
|
} |
799 |
|
} |
800 |
|
return; |
801 |
|
} |
802 |
|
|
803 |
|
// gf Apr 07 |
804 |
|
/** |
805 |
|
* Method to get the paddle index (0,...23) if the plane ID and the paddle id in the plane is given. |
806 |
|
* This method is the |
807 |
|
* "reverse" of method "GetPaddlePlane" |
808 |
|
* @param plane (0 - 5) |
809 |
|
* @param paddle (plane=0, paddle = 0,...5) |
810 |
|
* @param padid (0 - 23) |
811 |
|
*/ |
812 |
|
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
813 |
|
{ |
814 |
|
Int_t padid=-1; |
815 |
|
Int_t pads[6]={8,6,2,2,3,3}; |
816 |
|
|
817 |
|
int somma=0; |
818 |
|
int np=plane; |
819 |
|
for(Int_t j=0; j<np; j++){ |
820 |
|
somma+=pads[j]; |
821 |
|
} |
822 |
|
padid=paddle+somma; |
823 |
|
return padid; |
824 |
|
} |
825 |
|
|
826 |
|
|
827 |
|
// gf Apr 07 |
828 |
|
/** |
829 |
|
* Method to get the plane ID and the paddle id in the plane if the paddle index (0,...23) is given. |
830 |
|
* This method is the |
831 |
|
* "reverse" of method "GetPaddleid" |
832 |
|
* @param pad (0 - 23) |
833 |
|
* @param plane (0 - 5) |
834 |
|
* @param paddle (plane=0, paddle = 0,...5) |
835 |
|
*/ |
836 |
|
void ToFLevel2::GetPaddlePlane(Int_t pad, Int_t &plane, Int_t &paddle) |
837 |
|
{ |
838 |
|
|
839 |
|
Int_t pads11=8; |
840 |
|
Int_t pads12=6; |
841 |
|
Int_t pads21=2; |
842 |
|
Int_t pads22=2; |
843 |
|
Int_t pads31=3; |
844 |
|
// Int_t pads32=3; |
845 |
|
|
846 |
|
if(pad<8){ |
847 |
|
plane=0; |
848 |
|
paddle=pad; |
849 |
|
return; |
850 |
|
} |
851 |
|
|
852 |
|
if(7<pad<14){ |
853 |
|
plane=1; |
854 |
|
paddle=pad-pads11; |
855 |
|
return; |
856 |
|
} |
857 |
|
|
858 |
|
if(13<pad<16){ |
859 |
|
plane=2; |
860 |
|
paddle=pad-pads11-pads12; |
861 |
|
return; |
862 |
|
} |
863 |
|
|
864 |
|
if(15<pad<18){ |
865 |
|
plane=3; |
866 |
|
paddle=pad-pads11-pads12-pads21; |
867 |
|
return; |
868 |
|
} |
869 |
|
|
870 |
|
if(17<pad<21){ |
871 |
|
plane=4; |
872 |
|
paddle=pad-pads11-pads12-pads21-pads22; |
873 |
|
return; |
874 |
|
} |
875 |
|
|
876 |
|
if(20<pad<24){ |
877 |
|
plane=5; |
878 |
|
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
879 |
|
return; |
880 |
|
} |
881 |
|
|
882 |
|
} |
883 |
|
|
884 |
|
|
885 |
|
Int_t ToFLevel2::GetNPaddle(Int_t plane){ |
886 |
|
|
887 |
|
Int_t npaddle=-1; |
888 |
|
|
889 |
|
Int_t pads11=8; |
890 |
|
Int_t pads12=6; |
891 |
|
Int_t pads21=2; |
892 |
|
Int_t pads22=2; |
893 |
|
Int_t pads31=3; |
894 |
|
Int_t pads32=3; |
895 |
|
|
896 |
|
if(plane==0)npaddle=pads11; |
897 |
|
if(plane==1)npaddle=pads12; |
898 |
|
if(plane==2)npaddle=pads21; |
899 |
|
if(plane==3)npaddle=pads22; |
900 |
|
if(plane==4)npaddle=pads31; |
901 |
|
if(plane==5)npaddle=pads32; |
902 |
|
|
903 |
|
return npaddle; |
904 |
|
|
905 |
|
} |
906 |
|
|
907 |
|
/// wm feb 08 |
908 |
|
|
909 |
|
/** |
910 |
|
* Method to calculate Beta from the 12 single measurements |
911 |
|
* we check the individual weights for artificial TDC values, then calculate |
912 |
|
* am mean beta for the first time. In a second step we loop again through |
913 |
|
* the single measurements, checking for the residual from the mean |
914 |
|
* The cut on the residual reject measurements > "x"-sigma. A chi2 value is |
915 |
|
* calculated, furthermore a "quality" value by adding the weights which |
916 |
|
* are finally used. If all measurements are taken, "quality" will be = 22.47. |
917 |
|
* A chi2 cut around 3-4 and a quality-cut > 20 is needed for clean beta |
918 |
|
* measurements like antiprotons etc. |
919 |
|
* The Level2 output is derived in the fortran routines using: 10.,10.,20. |
920 |
|
* @param notrack Track Number |
921 |
|
* @param cut on residual: difference between single measurement and mean |
922 |
|
* @param cut on "quality" |
923 |
|
* @param cut on chi2 |
924 |
|
*/ |
925 |
|
|
926 |
|
Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){ |
927 |
|
|
928 |
|
// cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl; |
929 |
|
|
930 |
|
Float_t bxx = 100.; |
931 |
|
// |
932 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
933 |
|
if(!trk) return 0; //ELENA |
934 |
|
|
935 |
|
|
936 |
|
Float_t chi2,xhelp,beta_mean; |
937 |
|
Float_t w_i[12],quality,sw,sxw,res,betachi,beta_mean_inv; |
938 |
|
Float_t b[12],tdcfl; |
939 |
|
Int_t pmt_id,pmt_plane; |
940 |
|
|
941 |
|
for (Int_t i=0; i<12; i++){ |
942 |
|
b[i] = trk->beta[i]; |
943 |
|
} |
944 |
|
|
945 |
|
|
946 |
|
//======================================================================== |
947 |
|
//--- Find out ToF layers with artificial TDC values & fill vector --- |
948 |
|
//======================================================================== |
949 |
|
|
950 |
|
Float_t w_il[6]; |
951 |
|
|
952 |
|
for (Int_t jj=0; jj<6;jj++) { |
953 |
|
w_il[jj] = 1000.; |
954 |
|
} |
955 |
|
|
956 |
|
|
957 |
|
for (Int_t i=0; i<trk->npmttdc; i++){ |
958 |
|
// |
959 |
|
pmt_id = (trk->pmttdc).At(i); |
960 |
|
pmt_plane = GetPlaneIndex(pmt_id); |
961 |
|
tdcfl = (trk->tdcflag).At(i); |
962 |
|
if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag |
963 |
|
}; |
964 |
|
|
965 |
|
//======================================================================== |
966 |
|
//--- Set weights for the 12 measurements using information for top and bottom: |
967 |
|
//--- if no measurements: weight = set to very high value=> not used |
968 |
|
//--- top or bottom artificial: weight*sqrt(2) |
969 |
|
//--- top and bottom artificial: weight*sqrt(2)*sqrt(2) |
970 |
|
//======================================================================== |
971 |
|
|
972 |
|
Int_t itop[12] = {0,0,1,1,2,2,3,3,0,0,1,1}; |
973 |
|
Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,3}; |
974 |
|
|
975 |
|
xhelp= 1E09; |
976 |
|
|
977 |
|
for (Int_t jj=0; jj<12;jj++) { |
978 |
|
if (jj<4) xhelp = 0.11; // S1-S3 |
979 |
|
if ((jj>3)&&(jj<8)) xhelp = 0.18; // S2-S3 |
980 |
|
if (jj>7) xhelp = 0.28; // S1-S2 |
981 |
|
if ((w_il[itop[jj]] == 1000.) && (w_il[ibot[jj]] == 1000.)) xhelp = 1E09; |
982 |
|
if ((w_il[itop[jj]] == 1) || (w_il[ibot[jj]] == 1.)) xhelp = xhelp*1.414 ; |
983 |
|
if ((w_il[itop[jj]] == 1) && (w_il[ibot[jj]] == 1.)) xhelp = xhelp*2. ; |
984 |
|
|
985 |
|
w_i[jj] = 1./xhelp; |
986 |
|
} |
987 |
|
|
988 |
|
|
989 |
|
//======================================================================== |
990 |
|
//--- Calculate mean beta for the first time ----------------------------- |
991 |
|
//--- We are using "1/beta" since its error is gaussian ------------------ |
992 |
|
//======================================================================== |
993 |
|
|
994 |
|
Int_t icount=0; |
995 |
|
sw=0.; |
996 |
|
sxw=0.; |
997 |
|
beta_mean=100.; |
998 |
|
|
999 |
|
for (Int_t jj=0; jj<12;jj++){ |
1000 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)) |
1001 |
|
{ |
1002 |
|
icount= icount+1; |
1003 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
1004 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
1005 |
|
|
1006 |
|
} |
1007 |
|
} |
1008 |
|
|
1009 |
|
if (icount>0) beta_mean=1./(sxw/sw); |
1010 |
|
beta_mean_inv = 1./beta_mean; |
1011 |
|
|
1012 |
|
//======================================================================== |
1013 |
|
//--- Calculate beta for the second time, use residuals of the single |
1014 |
|
//--- measurements to get a chi2 value |
1015 |
|
//======================================================================== |
1016 |
|
|
1017 |
|
icount=0; |
1018 |
|
sw=0.; |
1019 |
|
sxw=0.; |
1020 |
|
betachi = 100.; |
1021 |
|
chi2 = 0.; |
1022 |
|
quality=0.; |
1023 |
|
|
1024 |
|
|
1025 |
|
for (Int_t jj=0; jj<12;jj++){ |
1026 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)&&(w_i[jj]>0.01)) { |
1027 |
|
res = beta_mean_inv - (1./b[jj]) ; |
1028 |
|
if (fabs(res*w_i[jj])<resmax) {; |
1029 |
|
chi2 = chi2 + pow((res*w_i[jj]),2) ; |
1030 |
|
icount= icount+1; |
1031 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
1032 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
1033 |
|
} |
1034 |
|
} |
1035 |
|
} |
1036 |
|
quality = sqrt(sw) ; |
1037 |
|
|
1038 |
|
if (icount==0) chi2 = 1000.; |
1039 |
|
if (icount>0) chi2 = chi2/(icount) ; |
1040 |
|
if (icount>0) betachi=1./(sxw/sw); |
1041 |
|
|
1042 |
|
bxx = 100.; |
1043 |
|
if ((chi2 < chi2cut)&&(quality>qualitycut)) bxx = betachi; |
1044 |
|
// |
1045 |
|
return(bxx); |
1046 |
|
}; |
1047 |
|
|
1048 |
|
|
1049 |
|
//////////////////////////////////////////////////// |
1050 |
|
//////////////////////////////////////////////////// |
1051 |
|
|
1052 |
|
|
1053 |
|
|
1054 |
/** |
/** |
1055 |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
1056 |
*/ |
*/ |
1081 |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
1082 |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
1083 |
} |
} |
1084 |
|
for(Int_t i=0;i<6;i++){ |
1085 |
|
l2->xtr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtr_tof[i]; |
1086 |
|
l2->ytr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytr_tof[i]; |
1087 |
|
} |
1088 |
} |
} |
1089 |
} //ELENA |
} //ELENA |
1090 |
|
|