1 |
/** |
/** |
2 |
* \file ToFLevel2.cpp |
* \file ToFLevel2.cpp |
3 |
* \author Gianfranca DeRosa, Wolfgang Menn |
* \author Gianfranca DeRosa, Wolfgang Menn |
4 |
|
* |
5 |
|
* WM dec 2008: Description of "GetdEdx" changed |
6 |
|
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
7 |
|
* PMTs higher than the saturation limit are not used for dEdx |
8 |
|
* WM apr 2009: bug found by Nicola in method "GetPaddlePlane" |
9 |
*/ |
*/ |
10 |
|
|
|
#include <TObject.h> |
|
11 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
|
#include <iostream> |
|
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){ |
113 |
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
114 |
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
115 |
}//ELENA |
}//ELENA |
116 |
|
//-------------------------------------- |
117 |
|
// |
118 |
|
// |
119 |
|
//-------------------------------------- |
120 |
|
void ToFLevel2::SetTrackArray(TClonesArray *track){//ELENA |
121 |
|
if(track && strcmp(track->GetClass()->GetName(),"ToFTrkVar")==0){ |
122 |
|
if(ToFTrk)ToFTrk->Clear("C"); |
123 |
|
ToFTrk = track; |
124 |
|
} |
125 |
|
} |
126 |
|
|
127 |
void ToFLevel2::Clear(Option_t *t){ |
void ToFLevel2::Clear(Option_t *t){ |
128 |
// |
// |
130 |
if(PMT)PMT->Delete(); //ELENA |
if(PMT)PMT->Delete(); //ELENA |
131 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
132 |
unpackError = 0; |
unpackError = 0; |
133 |
|
unpackWarning = 0; |
134 |
// |
// |
135 |
}; |
}; |
136 |
|
|
161 |
return toftrack; |
return toftrack; |
162 |
} |
} |
163 |
|
|
164 |
|
/** |
165 |
|
* Retrieves the tof track matching the seqno-th tracker stored track. |
166 |
|
* |
167 |
|
*/ |
168 |
|
ToFTrkVar *ToFLevel2::GetToFStoredTrack(int seqno){ |
169 |
|
|
170 |
|
if( ntrk()==0 ){ |
171 |
|
printf("ToFLevel2::GetToFStoredTrack(int) : requested tracker SeqNo %i but no ToFrimeter tracks are stored\n",seqno); |
172 |
|
return NULL; |
173 |
|
}; |
174 |
|
|
175 |
|
ToFTrkVar *c = 0; |
176 |
|
Int_t it_tof=0; |
177 |
|
|
178 |
|
do { |
179 |
|
c = GetToFTrkVar(it_tof); |
180 |
|
it_tof++; |
181 |
|
} while( c && seqno != c->trkseqno && it_tof < ntrk()); |
182 |
|
|
183 |
|
if(!c || seqno != c->trkseqno){ |
184 |
|
c = 0; |
185 |
|
if(seqno!=-1 ) printf("ToFLevel2::GetToFStoredTrack(int) : requested tracker SeqNo %i does not match ToFrimeter stored tracks\n",seqno); |
186 |
|
}; |
187 |
|
return c; |
188 |
|
|
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit){ |
ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit){ |
193 |
// |
// |
194 |
if(ihit >= npmt()){ |
if(ihit >= npmt()){ |
252 |
false) return true; |
false) return true; |
253 |
else return false; |
else return false; |
254 |
}; |
}; |
255 |
|
|
256 |
/** |
/** |
257 |
* Method to get the number of hit paddles on a ToF plane. |
* Strict method to get the number of hit paddles on a ToF plane. |
258 |
|
* The method uses "HitPaddle" which checks if there is a TDC signal |
259 |
|
* from both PMTs. |
260 |
* @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). |
261 |
*/ |
*/ |
262 |
Int_t ToFLevel2::GetNHitPaddles(Int_t plane){ |
Int_t ToFLevel2::GetNHitPaddles(Int_t plane){ |
265 |
return npad; |
return npad; |
266 |
}; |
}; |
267 |
|
|
268 |
|
/** |
269 |
|
* Optional method to get the number of hit paddles on a ToF plane. |
270 |
|
* The method does NOT check if there is a signal from both PMTs, it only |
271 |
|
* checks if there is some PMT signal in a paddle |
272 |
|
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
273 |
|
*/ |
274 |
|
Int_t ToFLevel2::GetTrueNHitPaddles(Int_t plane){ |
275 |
|
Int_t npad=0; |
276 |
|
TClonesArray* Pmt = this->PMT; |
277 |
|
int paddle[24]; |
278 |
|
memset(paddle,0, 24*sizeof(int)); |
279 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { //loop per vedere quale TOF è colpito |
280 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
281 |
|
int pplane = -1; |
282 |
|
int ppaddle = -1; |
283 |
|
GetPMTPaddle(pmthit->pmt_id,pplane,ppaddle); |
284 |
|
if ( pplane == plane ) paddle[ppaddle]++; |
285 |
|
} |
286 |
|
for(int i=0;i<24;i++) if ( paddle[i]>0 ) npad++; |
287 |
|
|
288 |
|
return npad; |
289 |
|
}; |
290 |
|
|
291 |
|
//new, wm Feb 15 |
292 |
|
//wm Nov 08 |
293 |
//gf Apr 07 |
//gf Apr 07 |
294 |
/** |
/** |
295 |
* Method to get the mean dEdx from a given ToF plane. This current version |
* Method to get the mean dEdx from a ToF layer |
296 |
* is just summing up all PMT signals, which will not give proper results, |
* By definition there should be PMTs with dEdx values only in one paddle of a layer |
297 |
* and needs a revision. |
* (the paddle hitted by the track), this method looks for the hitted paddle |
298 |
|
* and gives the mean dEdx of that paddle as the output |
299 |
|
* The method was modified for the "ToF-standalone" part in february 2015 |
300 |
|
* The "adcfl" option is not very useful (an artificial dEdx is per |
301 |
|
* definition= 1 mip and not a real measurement), anyway left in the code |
302 |
* @param notrack Track Number |
* @param notrack Track Number |
303 |
* @param plane Plane index (0,1,2,3,4,5) |
* @param plane Plane index (0,1,2,3,4,5) |
304 |
* @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; ) |
305 |
*/ |
*/ |
306 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
307 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
308 |
|
return this->GetdEdx(trk, plane, adcfl); |
309 |
|
} |
310 |
|
|
311 |
|
//new, wm Feb 15 |
312 |
|
//wm Nov 08 |
313 |
|
//gf Apr 07 |
314 |
|
/** |
315 |
|
* Method to get the mean dEdx from a ToF layer |
316 |
|
* By definition there should be PMTs with dEdx values only in one paddle of a layer |
317 |
|
* (the paddle hitted by the track), this method looks for the hitted paddle |
318 |
|
* and gives the mean dEdx of that paddle as the output |
319 |
|
* The method was modified for the "ToF-standalone" part in february 2015 |
320 |
|
* The "adcfl" option is not very useful (an artificial dEdx is per |
321 |
|
* definition= 1 mip and not a real measurement), anyway left in the code |
322 |
|
* @param trk Pointer to TofTrkVar class |
323 |
|
* @param plane Plane index (0,1,2,3,4,5) |
324 |
|
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
325 |
|
*/ |
326 |
|
Float_t ToFLevel2::GetdEdx(ToFTrkVar *trk, Int_t plane, Int_t adcfl){ |
327 |
|
|
328 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
329 |
Float_t PadEdx =0.; |
Float_t PadEdx =0.; |
330 |
Int_t SatWarning; |
Int_t SatWarning; |
331 |
Int_t pad=-1; |
Int_t pad=-1; |
332 |
// |
// |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
|
333 |
if(!trk) return 0; //ELENA |
if(!trk) return 0; //ELENA |
334 |
// |
// |
335 |
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
// ToF standalone part |
|
Int_t paddleid=ii; |
|
|
pad = GetPaddleid(plane,paddleid); |
|
|
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
|
|
dedx += PadEdx; |
|
|
}; |
|
336 |
// |
// |
337 |
|
if ( trk->trkseqno == -1 ){ |
338 |
|
|
339 |
|
// ToFTrkVar *t_tof = trk; |
340 |
|
|
341 |
|
// Find the hitted paddle (two good TDC values) using the tof_j_flag (from tofl2com.for) |
342 |
|
|
343 |
|
Int_t Ipaddle=-1; |
344 |
|
// if tof_j_flag == 0: no paddle was hitted. Otherwise decode tof_j_flag to get the paddle |
345 |
|
if (this->tof_j_flag[plane] > 0) Ipaddle = (Int_t)log2(this->tof_j_flag[plane]) ; |
346 |
|
|
347 |
|
Ipaddle = (Int_t)log2(this->tof_j_flag[plane]) ; |
348 |
|
|
349 |
|
// Get the dEdx of this paddle using "GetdEdxPaddle" |
350 |
|
if (Ipaddle>-1) { |
351 |
|
Int_t pad = GetPaddleid(plane,Ipaddle); |
352 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
353 |
|
dedx = PadEdx; |
354 |
|
} |
355 |
|
|
356 |
|
// If there was no correct hitted paddle, but there was one (and only one) paddle with some |
357 |
|
// PMT entries in the PMT-class (found with "GetTrueNHitPaddles", use the dEdx of this paddle |
358 |
|
|
359 |
|
if ((Ipaddle<0) && (GetTrueNHitPaddles(plane)==1)) { |
360 |
|
// find the paddle by looping over the paddles in each layer |
361 |
|
// since GetTrueNHitPaddles==1 this is OK |
362 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
363 |
|
Int_t paddleid=ii; |
364 |
|
Int_t pad = GetPaddleid(plane,paddleid); |
365 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
366 |
|
dedx += PadEdx; |
367 |
|
} |
368 |
|
} |
369 |
|
} else { |
370 |
|
// track dependent dEdx: simple, there will be only one paddle hitted in each layer |
371 |
|
// so just loop over the paddles in each layer |
372 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
373 |
|
Int_t paddleid=ii; |
374 |
|
pad = GetPaddleid(plane,paddleid); |
375 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
376 |
|
dedx += PadEdx; |
377 |
|
} |
378 |
|
} |
379 |
|
// |
380 |
return(dedx); |
return(dedx); |
381 |
}; |
} |
382 |
|
|
383 |
/** |
/** |
384 |
* Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix |
* Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix |
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
// wm Nov 08 revision - saturation values included |
519 |
/// gf Apr 07 |
/// gf Apr 07 |
|
|
|
520 |
/** |
/** |
521 |
* Method to get the dEdx from a given ToF paddle. |
* Method to get the dEdx from a given ToF paddle. |
522 |
|
* If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise |
523 |
|
* just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000 |
524 |
* @param notrack Track Number |
* @param notrack Track Number |
525 |
* @param Paddle index (0,1,...,23). |
* @param Paddle index (0,1,...,23). |
526 |
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
529 |
*/ |
*/ |
530 |
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){ |
531 |
|
|
532 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
533 |
|
this->GetdEdxPaddle(trk, paddleid, adcfl, PadEdx, SatWarning); |
534 |
|
|
535 |
|
}; |
536 |
|
|
537 |
|
// |
538 |
|
// wm Nov 08 revision - saturation values included |
539 |
|
/// gf Apr 07 |
540 |
|
/** |
541 |
|
* Method to get the dEdx from a given ToF paddle. |
542 |
|
* If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise |
543 |
|
* just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000 |
544 |
|
* @param notrack Track Number |
545 |
|
* @param Paddle index (0,1,...,23). |
546 |
|
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
547 |
|
* @param PadEdx dEdx from a given ToF paddle |
548 |
|
* @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000) |
549 |
|
*/ |
550 |
|
void ToFLevel2::GetdEdxPaddle(ToFTrkVar *trk, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
551 |
|
|
552 |
|
/* |
553 |
|
Float_t PMTsat[48] = { |
554 |
|
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
555 |
|
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
556 |
|
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
557 |
|
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
558 |
|
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
559 |
|
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
560 |
|
*/ |
561 |
|
|
562 |
|
// new values from Napoli dec 2008 |
563 |
|
Float_t PMTsat[48] = { |
564 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
565 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
566 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
567 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
568 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
569 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
570 |
|
|
571 |
|
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
572 |
|
|
573 |
|
|
574 |
PadEdx = 0.; |
PadEdx = 0.; |
575 |
SatWarning = 1000; |
// SatWarning = 1000; |
576 |
|
SatWarning = 0; // 0=good, increase for each bad PMT |
577 |
|
|
578 |
Float_t dEdx[48] = {0}; |
Float_t dEdx[48] = {0}; |
579 |
Int_t pmt_id = -1; |
Int_t pmt_id = -1; |
580 |
Float_t adcraw[48]; |
Float_t adcraw[48]; |
581 |
// |
// |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
|
582 |
if(!trk) return; //ELENA |
if(!trk) return; //ELENA |
583 |
// |
// |
584 |
|
|
604 |
adcraw[pmtright] = pmt->adc; |
adcraw[pmtright] = pmt->adc; |
605 |
} |
} |
606 |
} |
} |
607 |
|
|
608 |
|
|
609 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
610 |
|
|
617 |
} |
} |
618 |
} |
} |
619 |
|
|
620 |
if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; |
|
621 |
|
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
622 |
if(dEdx[pmtleft]!=0 && dEdx[pmtright]!=0){ |
|
623 |
PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
// Increase SatWarning Counter for each PMT>Sat |
624 |
} |
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
625 |
if(dEdx[pmtleft]==0 && dEdx[pmtright]!=0){ |
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
626 |
PadEdx = dEdx[pmtright]; |
|
627 |
} |
// if ADC > sat set dEdx=1000 |
628 |
if(dEdx[pmtleft]!=0 && dEdx[pmtright]==0){ |
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
629 |
PadEdx = dEdx[pmtleft]; |
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
630 |
} |
|
631 |
|
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
632 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
633 |
|
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
634 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
635 |
|
|
|
return; |
|
636 |
}; |
}; |
|
// |
|
|
|
|
637 |
|
|
638 |
// gf Apr 07 |
// gf Apr 07 |
639 |
|
|
687 |
|
|
688 |
}; |
}; |
689 |
|
|
690 |
|
// wm jun 08 |
|
// gf Apr 07 |
|
691 |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
692 |
|
return GetPaddleIdOfTrack(xtr ,ytr ,plane, 0.4); |
693 |
|
} |
694 |
|
|
695 |
|
// gf Apr 07 |
696 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin){ |
697 |
|
|
698 |
Double_t xt,yt,xl,xh,yl,yh; |
Double_t xt,yt,xl,xh,yl,yh; |
699 |
|
|
700 |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
724 |
yh = 33.0/2. ; |
yh = 33.0/2. ; |
725 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
726 |
for (Int_t i1=0; i1<8;i1++){ |
for (Int_t i1=0; i1<8;i1++){ |
727 |
xl = tof11_x[i1] - (5.1-0.4)/2. ; |
xl = tof11_x[i1] - (5.1-margin)/2. ; |
728 |
xh = tof11_x[i1] + (5.1-0.4)/2. ; |
xh = tof11_x[i1] + (5.1-margin)/2. ; |
729 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
730 |
} |
} |
731 |
} |
} |
742 |
|
|
743 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
744 |
for (Int_t i1=0; i1<6;i1++){ |
for (Int_t i1=0; i1<6;i1++){ |
745 |
yl = tof12_y[i1] - (5.5-0.4)/2. ; |
yl = tof12_y[i1] - (5.5-margin)/2. ; |
746 |
yh = tof12_y[i1] + (5.5-0.4)/2. ; |
yh = tof12_y[i1] + (5.5-margin)/2. ; |
747 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
748 |
} |
} |
749 |
} |
} |
760 |
|
|
761 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
762 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
763 |
yl = tof21_y[i1] - (7.5-0.4)/2. ; |
yl = tof21_y[i1] - (7.5-margin)/2. ; |
764 |
yh = tof21_y[i1] + (7.5-0.4)/2. ; |
yh = tof21_y[i1] + (7.5-margin)/2. ; |
765 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
766 |
} |
} |
767 |
} |
} |
777 |
|
|
778 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
779 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
780 |
xl = tof22_x[i1] - (9.0-0.4)/2. ; |
xl = tof22_x[i1] - (9.0-margin)/2. ; |
781 |
xh = tof22_x[i1] + (9.0-0.4)/2. ; |
xh = tof22_x[i1] + (9.0-margin)/2. ; |
782 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
783 |
} |
} |
784 |
} |
} |
794 |
|
|
795 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
796 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
797 |
xl = tof31_x[i1] - (6.0-0.4)/2. ; |
xl = tof31_x[i1] - (6.0-margin)/2. ; |
798 |
xh = tof31_x[i1] + (6.0-0.4)/2. ; |
xh = tof31_x[i1] + (6.0-margin)/2. ; |
799 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
800 |
} |
} |
801 |
} |
} |
811 |
|
|
812 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
813 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
814 |
yl = tof32_y[i1] - (5.0-0.4)/2. ; |
yl = tof32_y[i1] - (5.0-margin)/2. ; |
815 |
yh = tof32_y[i1] + (5.0-0.4)/2. ; |
yh = tof32_y[i1] + (5.0-margin)/2. ; |
816 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
817 |
} |
} |
818 |
} |
} |
879 |
// gf Apr 07 |
// gf Apr 07 |
880 |
|
|
881 |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
882 |
|
pmtleft=paddle*2; |
883 |
if(paddle==0){ |
pmtright= pmtleft+1; |
|
pmtleft=0; |
|
|
pmtright=1; |
|
|
} |
|
|
|
|
|
if(paddle==1){ |
|
|
pmtleft=2; |
|
|
pmtright=3; |
|
|
} |
|
|
|
|
|
if(paddle==2){ |
|
|
pmtleft=4; |
|
|
pmtright=5; |
|
|
} |
|
|
|
|
|
if(paddle==3){ |
|
|
pmtleft=6; |
|
|
pmtright=7; |
|
|
} |
|
|
|
|
|
if(paddle==4){ |
|
|
pmtleft=8; |
|
|
pmtright=9; |
|
|
} |
|
|
|
|
|
if(paddle==5){ |
|
|
pmtleft=10; |
|
|
pmtright=11; |
|
|
} |
|
|
|
|
|
if(paddle==6){ |
|
|
pmtleft=12; |
|
|
pmtright=13; |
|
|
} |
|
|
|
|
|
if(paddle==7){ |
|
|
pmtleft=14; |
|
|
pmtright=15; |
|
|
} |
|
|
|
|
|
if(paddle==8){ |
|
|
pmtleft=16; |
|
|
pmtright=17; |
|
|
} |
|
|
|
|
|
if(paddle==9){ |
|
|
pmtleft=18; |
|
|
pmtright=19; |
|
|
} |
|
|
|
|
|
if(paddle==10){ |
|
|
pmtleft=20; |
|
|
pmtright=21; |
|
|
} |
|
|
|
|
|
if(paddle==11){ |
|
|
pmtleft=22; |
|
|
pmtright=23; |
|
|
} |
|
|
|
|
|
if(paddle==12){ |
|
|
pmtleft=24; |
|
|
pmtright=25; |
|
|
} |
|
|
|
|
|
if(paddle==13){ |
|
|
pmtleft=26; |
|
|
pmtright=27; |
|
|
} |
|
|
|
|
|
if(paddle==14){ |
|
|
pmtleft=28; |
|
|
pmtright=29; |
|
|
} |
|
|
|
|
|
if(paddle==15){ |
|
|
pmtleft=30; |
|
|
pmtright=31; |
|
|
} |
|
|
|
|
|
if(paddle==16){ |
|
|
pmtleft=32; |
|
|
pmtright=33; |
|
|
} |
|
|
|
|
|
if(paddle==17){ |
|
|
pmtleft=34; |
|
|
pmtright=35; |
|
|
} |
|
|
|
|
|
if(paddle==18){ |
|
|
pmtleft=36; |
|
|
pmtright=37; |
|
|
} |
|
|
|
|
|
if(paddle==19){ |
|
|
pmtleft=38; |
|
|
pmtright=39; |
|
|
} |
|
|
|
|
|
if(paddle==20){ |
|
|
pmtleft=40; |
|
|
pmtright=41; |
|
|
} |
|
|
|
|
|
if(paddle==21){ |
|
|
pmtleft=42; |
|
|
pmtright=43; |
|
|
} |
|
|
|
|
|
if(paddle==22){ |
|
|
pmtleft=44; |
|
|
pmtright=45; |
|
|
} |
|
|
|
|
|
if(paddle==23){ |
|
|
pmtleft=46; |
|
|
pmtright=47; |
|
|
} |
|
|
|
|
884 |
return; |
return; |
885 |
} |
} |
886 |
|
|
994 |
*/ |
*/ |
995 |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
996 |
{ |
{ |
|
|
|
997 |
Int_t padid=-1; |
Int_t padid=-1; |
998 |
Int_t pads11=8; |
Int_t pads[6]={8,6,2,2,3,3}; |
|
Int_t pads12=6; |
|
|
Int_t pads21=2; |
|
|
Int_t pads22=2; |
|
|
Int_t pads31=3; |
|
|
// Int_t pads32=3; |
|
|
|
|
|
|
|
|
if(plane == 0){ |
|
|
padid=paddle; |
|
|
} |
|
|
|
|
|
if(plane == 1){ |
|
|
padid=pads11+paddle; |
|
|
} |
|
|
|
|
|
if(plane == 2){ |
|
|
padid=pads11+pads12+paddle; |
|
|
} |
|
|
|
|
|
if(plane == 3){ |
|
|
padid=pads11+pads12+pads21+paddle; |
|
|
} |
|
999 |
|
|
1000 |
if(plane == 4){ |
int somma=0; |
1001 |
padid=pads11+pads12+pads21+pads22+paddle; |
int np=plane; |
1002 |
|
for(Int_t j=0; j<np; j++){ |
1003 |
|
somma+=pads[j]; |
1004 |
} |
} |
1005 |
|
padid=paddle+somma; |
|
if(plane == 5){ |
|
|
padid=pads11+pads12+pads21+pads22+pads31+paddle; |
|
|
} |
|
|
|
|
1006 |
return padid; |
return padid; |
1007 |
|
|
1008 |
} |
} |
1033 |
return; |
return; |
1034 |
} |
} |
1035 |
|
|
1036 |
if(7<pad<14){ |
if((7<pad)&&(pad<14)){ |
1037 |
plane=1; |
plane=1; |
1038 |
paddle=pad-pads11; |
paddle=pad-pads11; |
1039 |
return; |
return; |
1040 |
} |
} |
1041 |
|
|
1042 |
if(13<pad<16){ |
if((13<pad)&&(pad<16)){ |
1043 |
plane=2; |
plane=2; |
1044 |
paddle=pad-pads11-pads12; |
paddle=pad-pads11-pads12; |
1045 |
return; |
return; |
1046 |
} |
} |
1047 |
|
|
1048 |
if(15<pad<18){ |
if((15<pad)&&(pad<18)){ |
1049 |
plane=3; |
plane=3; |
1050 |
paddle=pad-pads11-pads12-pads21; |
paddle=pad-pads11-pads12-pads21; |
1051 |
return; |
return; |
1052 |
} |
} |
1053 |
|
|
1054 |
if(17<pad<21){ |
if((17<pad)&&(pad<21)){ |
1055 |
plane=4; |
plane=4; |
1056 |
paddle=pad-pads11-pads12-pads21-pads22; |
paddle=pad-pads11-pads12-pads21-pads22; |
1057 |
return; |
return; |
1058 |
} |
} |
1059 |
|
|
1060 |
if(20<pad<24){ |
if((20<pad)&&(pad<24)){ |
1061 |
plane=5; |
plane=5; |
1062 |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
1063 |
return; |
return; |
1282 |
} |
} |
1283 |
} //ELENA |
} //ELENA |
1284 |
} |
} |
1285 |
|
|
1286 |
|
|
1287 |
|
// |
1288 |
|
// Reprocessing tool // Emiliano 08/04/07 |
1289 |
|
// |
1290 |
|
Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){ |
1291 |
|
// |
1292 |
|
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
1293 |
|
// |
1294 |
|
printf("\n\n\n ERROR: NOT IMPLEMENTED ANYMORE, write Emiliano if you need this method (Emiliano.Mocchiutti@ts.infn.it) \n\n\n"); |
1295 |
|
return(-1); |
1296 |
|
// // |
1297 |
|
// // structures to communicate with F77 |
1298 |
|
// // |
1299 |
|
// extern struct ToFInput tofinput_; |
1300 |
|
// extern struct ToFOutput tofoutput_; |
1301 |
|
// // |
1302 |
|
// // DB connection |
1303 |
|
// // |
1304 |
|
// TString host; |
1305 |
|
// TString user; |
1306 |
|
// TString psw; |
1307 |
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
1308 |
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
1309 |
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
1310 |
|
// if ( !pamdbhost ) pamdbhost = ""; |
1311 |
|
// if ( !pamdbuser ) pamdbuser = ""; |
1312 |
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
1313 |
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
1314 |
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
1315 |
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
1316 |
|
// // |
1317 |
|
// // |
1318 |
|
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
1319 |
|
// if ( !dbc->IsConnected() ) return 1; |
1320 |
|
// stringstream myquery; |
1321 |
|
// myquery.str(""); |
1322 |
|
// myquery << "SET time_zone='+0:00';"; |
1323 |
|
// dbc->Query(myquery.str().c_str()); |
1324 |
|
// delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
1325 |
|
// GL_PARAM *glparam = new GL_PARAM(); |
1326 |
|
// glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
1327 |
|
// trk->LoadField(glparam->PATH+glparam->NAME); |
1328 |
|
// // |
1329 |
|
// Bool_t defcal = true; |
1330 |
|
// Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
1331 |
|
// if ( error<0 ) { |
1332 |
|
// return(1); |
1333 |
|
// }; |
1334 |
|
// printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
1335 |
|
// if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
1336 |
|
// // |
1337 |
|
// Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
1338 |
|
// rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
1339 |
|
// // |
1340 |
|
// Int_t adc[4][12]; |
1341 |
|
// Int_t tdc[4][12]; |
1342 |
|
// Float_t tdcc[4][12]; |
1343 |
|
// // |
1344 |
|
// // process tof data |
1345 |
|
// // |
1346 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1347 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1348 |
|
// adc[kk][hh] = 4095; |
1349 |
|
// tdc[kk][hh] = 4095; |
1350 |
|
// tdcc[kk][hh] = 4095.; |
1351 |
|
// tofinput_.adc[hh][kk] = 4095; |
1352 |
|
// tofinput_.tdc[hh][kk] = 4095; |
1353 |
|
// }; |
1354 |
|
// }; |
1355 |
|
// Int_t ntrkentry = 0; |
1356 |
|
// Int_t npmtentry = 0; |
1357 |
|
// Int_t gg = 0; |
1358 |
|
// Int_t hh = 0; |
1359 |
|
// Int_t adcf[48]; |
1360 |
|
// memset(adcf, 0, 48*sizeof(Int_t)); |
1361 |
|
// Int_t tdcf[48]; |
1362 |
|
// memset(tdcf, 0, 48*sizeof(Int_t)); |
1363 |
|
// for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
1364 |
|
// ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
1365 |
|
// for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
1366 |
|
// if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
1367 |
|
// }; |
1368 |
|
// for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
1369 |
|
// if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
1370 |
|
// }; |
1371 |
|
// }; |
1372 |
|
// // |
1373 |
|
// for (Int_t pm=0; pm < this->npmt() ; pm++){ |
1374 |
|
// ToFPMT *pmt = this->GetToFPMT(pm); |
1375 |
|
// this->GetPMTIndex(pmt->pmt_id, gg, hh); |
1376 |
|
// if ( adcf[pmt->pmt_id] == 0 ){ |
1377 |
|
// tofinput_.adc[gg][hh] = (int)pmt->adc; |
1378 |
|
// adc[hh][gg] = (int)pmt->adc; |
1379 |
|
// }; |
1380 |
|
// if ( tdcf[pmt->pmt_id] == 0 ){ |
1381 |
|
// tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
1382 |
|
// tdc[hh][gg] = (int)pmt->tdc; |
1383 |
|
// }; |
1384 |
|
// tdcc[hh][gg] = (float)pmt->tdc_tw; |
1385 |
|
// // Int_t pppid = this->GetPMTid(hh,gg); |
1386 |
|
// // 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); |
1387 |
|
// }; |
1388 |
|
// // |
1389 |
|
// Int_t unpackError = this->unpackError; |
1390 |
|
// // |
1391 |
|
// for (Int_t hh=0; hh<5;hh++){ |
1392 |
|
// tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
1393 |
|
// }; |
1394 |
|
// // |
1395 |
|
// this->Clear(); |
1396 |
|
// // |
1397 |
|
// Int_t pmt_id = 0; |
1398 |
|
// ToFPMT *t_pmt = new ToFPMT(); |
1399 |
|
// if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
1400 |
|
// TClonesArray &tpmt = *this->PMT; |
1401 |
|
// ToFTrkVar *t_tof = new ToFTrkVar(); |
1402 |
|
// if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
1403 |
|
// TClonesArray &t = *this->ToFTrk; |
1404 |
|
// // |
1405 |
|
// // |
1406 |
|
// // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
1407 |
|
// // |
1408 |
|
// npmtentry = 0; |
1409 |
|
// // |
1410 |
|
// ntrkentry = 0; |
1411 |
|
// // |
1412 |
|
// // Calculate tracks informations from ToF alone |
1413 |
|
// // |
1414 |
|
// tofl2com(); |
1415 |
|
// // |
1416 |
|
// memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
1417 |
|
// // |
1418 |
|
// t_tof->trkseqno = -1; |
1419 |
|
// // |
1420 |
|
// // and now we must copy from the output structure to the level2 class: |
1421 |
|
// // |
1422 |
|
// t_tof->npmttdc = 0; |
1423 |
|
// // |
1424 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1425 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1426 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1427 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1428 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1429 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1430 |
|
// t_tof->npmttdc++; |
1431 |
|
// }; |
1432 |
|
// }; |
1433 |
|
// }; |
1434 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1435 |
|
// t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
1436 |
|
// } |
1437 |
|
// // |
1438 |
|
// t_tof->npmtadc = 0; |
1439 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1440 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1441 |
|
// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
1442 |
|
// t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
1443 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1444 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1445 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1446 |
|
// t_tof->npmtadc++; |
1447 |
|
// }; |
1448 |
|
// }; |
1449 |
|
// }; |
1450 |
|
// // |
1451 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1452 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1453 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1454 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1455 |
|
// // |
1456 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1457 |
|
// ntrkentry++; |
1458 |
|
// t_tof->Clear(); |
1459 |
|
// // |
1460 |
|
// // |
1461 |
|
// // |
1462 |
|
// t_pmt->Clear(); |
1463 |
|
// // |
1464 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1465 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1466 |
|
// // new WM |
1467 |
|
// if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1468 |
|
// // if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1469 |
|
// // |
1470 |
|
// t_pmt->pmt_id = this->GetPMTid(kk,hh); |
1471 |
|
// t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
1472 |
|
// t_pmt->adc = (Float_t)adc[kk][hh]; |
1473 |
|
// t_pmt->tdc = (Float_t)tdc[kk][hh]; |
1474 |
|
// // |
1475 |
|
// new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
1476 |
|
// npmtentry++; |
1477 |
|
// t_pmt->Clear(); |
1478 |
|
// }; |
1479 |
|
// }; |
1480 |
|
// }; |
1481 |
|
// // |
1482 |
|
// // Calculate track-related variables |
1483 |
|
// // |
1484 |
|
// if ( trk->ntrk() > 0 ){ |
1485 |
|
// // |
1486 |
|
// // We have at least one track |
1487 |
|
// // |
1488 |
|
// // |
1489 |
|
// // Run over tracks |
1490 |
|
// // |
1491 |
|
// for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
1492 |
|
// // |
1493 |
|
// TrkTrack *ptt = trk->GetStoredTrack(nt); |
1494 |
|
// // |
1495 |
|
// // Copy the alpha vector in the input structure |
1496 |
|
// // |
1497 |
|
// for (Int_t e = 0; e < 5 ; e++){ |
1498 |
|
// tofinput_.al_pp[e] = ptt->al[e]; |
1499 |
|
// }; |
1500 |
|
// // |
1501 |
|
// // Get tracker related variables for this track |
1502 |
|
// // |
1503 |
|
// toftrk(); |
1504 |
|
// // |
1505 |
|
// // Copy values in the class from the structure (we need to use a temporary class to store variables). |
1506 |
|
// // |
1507 |
|
// t_tof->npmttdc = 0; |
1508 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1509 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1510 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1511 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1512 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1513 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1514 |
|
// t_tof->npmttdc++; |
1515 |
|
// }; |
1516 |
|
// }; |
1517 |
|
// }; |
1518 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1519 |
|
// t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
1520 |
|
// }; |
1521 |
|
// // |
1522 |
|
// t_tof->npmtadc = 0; |
1523 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1524 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1525 |
|
// if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
1526 |
|
// t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
1527 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1528 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1529 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1530 |
|
// t_tof->npmtadc++; |
1531 |
|
// }; |
1532 |
|
// }; |
1533 |
|
// }; |
1534 |
|
// // |
1535 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1536 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1537 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1538 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1539 |
|
// // |
1540 |
|
// // Store the tracker track number in order to be sure to have shyncronized data during analysis |
1541 |
|
// // |
1542 |
|
// t_tof->trkseqno = nt; |
1543 |
|
// // |
1544 |
|
// // create a new object for this event with track-related variables |
1545 |
|
// // |
1546 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1547 |
|
// ntrkentry++; |
1548 |
|
// t_tof->Clear(); |
1549 |
|
// // |
1550 |
|
// }; // loop on all the tracks |
1551 |
|
// // |
1552 |
|
// this->unpackError = unpackError; |
1553 |
|
// if ( defcal ){ |
1554 |
|
// this->default_calib = 1; |
1555 |
|
// } else { |
1556 |
|
// this->default_calib = 0; |
1557 |
|
// }; |
1558 |
|
//}; |
1559 |
|
// return(0); |
1560 |
|
} |
1561 |
|
|
1562 |
|
bool ToFLevel2::bit(int decimal, char pos){ |
1563 |
|
return( (decimal>>pos)%2 ); |
1564 |
|
} |
1565 |
|
|
1566 |
|
bool ToFLevel2::checkPMT(TString givenpmt){ |
1567 |
|
TClonesArray* Pmt = this->PMT; |
1568 |
|
// printf(" ou %s entries %i \n",givenpmt.Data(),Pmt->GetEntries()); |
1569 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1570 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1571 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1572 |
|
// printf(" name %s \n",pmtname.Data()); |
1573 |
|
if ( !strcmp(pmtname.Data(),givenpmt.Data()) ) |
1574 |
|
return true; |
1575 |
|
} |
1576 |
|
// printf(" PMT %s missing \n",givenpmt.Data()); |
1577 |
|
return false; |
1578 |
|
} |
1579 |
|
|
1580 |
|
bool ToFLevel2::checkPMTpatternPMThit(TrigLevel2 *trg, int &pmtpattern, int &pmtnosignal){ |
1581 |
|
UInt_t *patterntrig = trg->patterntrig; |
1582 |
|
pmtpattern = 0; |
1583 |
|
pmtnosignal = 0; |
1584 |
|
bool good = true; |
1585 |
|
//S3 |
1586 |
|
if ( this->bit(patterntrig[2],0) ){ pmtpattern++; if ( !this->checkPMT("S31_1A")){ pmtnosignal++; good = false;}} |
1587 |
|
if ( this->bit(patterntrig[2],1) ){ pmtpattern++; if ( !this->checkPMT("S31_2A")){ pmtnosignal++; good = false;}} |
1588 |
|
if ( this->bit(patterntrig[2],2) ){ pmtpattern++; if ( !this->checkPMT("S31_3A")){ pmtnosignal++; good = false;}} |
1589 |
|
if ( this->bit(patterntrig[2],3) ){ pmtpattern++; if ( !this->checkPMT("S31_1B")){ pmtnosignal++; good = false;}} |
1590 |
|
if ( this->bit(patterntrig[2],4) ){ pmtpattern++; if ( !this->checkPMT("S31_2B")){ pmtnosignal++; good = false;}} |
1591 |
|
if ( this->bit(patterntrig[2],5) ){ pmtpattern++; if ( !this->checkPMT("S31_3B")){ pmtnosignal++; good = false;}} |
1592 |
|
if ( this->bit(patterntrig[2],6) ){ pmtpattern++; if ( !this->checkPMT("S32_1A")){ pmtnosignal++; good = false;}} |
1593 |
|
if ( this->bit(patterntrig[2],7) ){ pmtpattern++; if ( !this->checkPMT("S32_2A")){ pmtnosignal++; good = false;}} |
1594 |
|
if ( this->bit(patterntrig[2],8) ){ pmtpattern++; if ( !this->checkPMT("S32_3A")){ pmtnosignal++; good = false;}} |
1595 |
|
if ( this->bit(patterntrig[2],9) ){ pmtpattern++; if ( !this->checkPMT("S32_1B")){ pmtnosignal++; good = false;}} |
1596 |
|
if ( this->bit(patterntrig[2],10) ){ pmtpattern++; if ( !this->checkPMT("S32_2B")){ pmtnosignal++; good = false;}} |
1597 |
|
if ( this->bit(patterntrig[2],11) ){ pmtpattern++; if ( !this->checkPMT("S32_3B")){ pmtnosignal++; good = false;}} |
1598 |
|
//S2 |
1599 |
|
if ( this->bit(patterntrig[3],0) ){ pmtpattern++; if ( !this->checkPMT("S21_1A")){ pmtnosignal++; good = false;}} |
1600 |
|
if ( this->bit(patterntrig[3],1) ){ pmtpattern++; if ( !this->checkPMT("S21_2A")){ pmtnosignal++; good = false;}} |
1601 |
|
if ( this->bit(patterntrig[3],2) ){ pmtpattern++; if ( !this->checkPMT("S21_1B")){ pmtnosignal++; good = false;}} |
1602 |
|
if ( this->bit(patterntrig[3],3) ){ pmtpattern++; if ( !this->checkPMT("S21_2B")){ pmtnosignal++; good = false;}} |
1603 |
|
if ( this->bit(patterntrig[3],4) ){ pmtpattern++; if ( !this->checkPMT("S22_1A")){ pmtnosignal++; good = false;}} |
1604 |
|
if ( this->bit(patterntrig[3],5) ){ pmtpattern++; if ( !this->checkPMT("S22_2A")){ pmtnosignal++; good = false;}} |
1605 |
|
if ( this->bit(patterntrig[3],6) ){ pmtpattern++; if ( !this->checkPMT("S22_1B")){ pmtnosignal++; good = false;}} |
1606 |
|
if ( this->bit(patterntrig[3],7) ){ pmtpattern++; if ( !this->checkPMT("S22_2B")){ pmtnosignal++; good = false;}} |
1607 |
|
//S12 |
1608 |
|
if ( this->bit(patterntrig[4],0) ){ pmtpattern++; if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}} |
1609 |
|
if ( this->bit(patterntrig[4],1) ){ pmtpattern++; if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}} |
1610 |
|
if ( this->bit(patterntrig[4],2) ){ pmtpattern++; if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}} |
1611 |
|
if ( this->bit(patterntrig[4],3) ){ pmtpattern++; if ( !this->checkPMT("S12_4A")){ pmtnosignal++; good = false;}} |
1612 |
|
if ( this->bit(patterntrig[4],4) ){ pmtpattern++; if ( !this->checkPMT("S12_5A")){ pmtnosignal++; good = false;}} |
1613 |
|
if ( this->bit(patterntrig[4],5) ){ pmtpattern++; if ( !this->checkPMT("S12_6A")){ pmtnosignal++; good = false;}} |
1614 |
|
if ( this->bit(patterntrig[4],6) ){ pmtpattern++; if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}} |
1615 |
|
if ( this->bit(patterntrig[4],7) ){ pmtpattern++; if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}} |
1616 |
|
if ( this->bit(patterntrig[4],8) ){ pmtpattern++; if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}} |
1617 |
|
if ( this->bit(patterntrig[4],9) ){ pmtpattern++; if ( !this->checkPMT("S12_4B")){ pmtnosignal++; good = false;}} |
1618 |
|
if ( this->bit(patterntrig[4],10) ){ pmtpattern++; if ( !this->checkPMT("S12_5B")){ pmtnosignal++; good = false;}} |
1619 |
|
if ( this->bit(patterntrig[4],11) ){ pmtpattern++; if ( !this->checkPMT("S12_6B")){ pmtnosignal++; good = false;}} |
1620 |
|
//S11 |
1621 |
|
if ( this->bit(patterntrig[5],0) ){ pmtpattern++; if ( !this->checkPMT("S11_1A")){ pmtnosignal++; good = false;}} |
1622 |
|
if ( this->bit(patterntrig[5],1) ){ pmtpattern++; if ( !this->checkPMT("S11_2A")){ pmtnosignal++; good = false;}} |
1623 |
|
if ( this->bit(patterntrig[5],2) ){ pmtpattern++; if ( !this->checkPMT("S11_3A")){ pmtnosignal++; good = false;}} |
1624 |
|
if ( this->bit(patterntrig[5],3) ){ pmtpattern++; if ( !this->checkPMT("S11_4A")){ pmtnosignal++; good = false;}} |
1625 |
|
if ( this->bit(patterntrig[5],4) ){ pmtpattern++; if ( !this->checkPMT("S11_5A")){ pmtnosignal++; good = false;}} |
1626 |
|
if ( this->bit(patterntrig[5],5) ){ pmtpattern++; if ( !this->checkPMT("S11_6A")){ pmtnosignal++; good = false;}} |
1627 |
|
if ( this->bit(patterntrig[5],6) ){ pmtpattern++; if ( !this->checkPMT("S11_7A")){ pmtnosignal++; good = false;}} |
1628 |
|
if ( this->bit(patterntrig[5],7) ){ pmtpattern++; if ( !this->checkPMT("S11_8A")){ pmtnosignal++; good = false;}} |
1629 |
|
if ( this->bit(patterntrig[5],8) ){ pmtpattern++; if ( !this->checkPMT("S11_1B")){ pmtnosignal++; good = false;}} |
1630 |
|
if ( this->bit(patterntrig[5],9) ){ pmtpattern++; if ( !this->checkPMT("S11_2B")){ pmtnosignal++; good = false;}} |
1631 |
|
if ( this->bit(patterntrig[5],10) ){ pmtpattern++; if ( !this->checkPMT("S11_3B")){ pmtnosignal++; good = false;}} |
1632 |
|
if ( this->bit(patterntrig[5],11) ){ pmtpattern++; if ( !this->checkPMT("S11_4B")){ pmtnosignal++; good = false;}} |
1633 |
|
if ( this->bit(patterntrig[5],12) ){ pmtpattern++; if ( !this->checkPMT("S11_5B")){ pmtnosignal++; good = false;}} |
1634 |
|
if ( this->bit(patterntrig[5],13) ){ pmtpattern++; if ( !this->checkPMT("S11_6B")){ pmtnosignal++; good = false;}} |
1635 |
|
if ( this->bit(patterntrig[5],14) ){ pmtpattern++; if ( !this->checkPMT("S11_7B")){ pmtnosignal++; good = false;}} |
1636 |
|
if ( this->bit(patterntrig[5],15) ){ pmtpattern++; if ( !this->checkPMT("S11_8B")){ pmtnosignal++; good = false;}} |
1637 |
|
|
1638 |
|
return good; |
1639 |
|
} |
1640 |
|
|
1641 |
|
bool ToFLevel2::checkPMTpmttrig(TrigLevel2 *trg){ |
1642 |
|
// UInt_t *patterntrig = trg->patterntrig; |
1643 |
|
int rS11 = 0; |
1644 |
|
int rS12 = 0; |
1645 |
|
int rS21 = 0; |
1646 |
|
int rS22 = 0; |
1647 |
|
int rS31 = 0; |
1648 |
|
int rS32 = 0; |
1649 |
|
|
1650 |
|
// trigger configuration for the event from saved pmts |
1651 |
|
TClonesArray* Pmt = this->PMT; |
1652 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1653 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1654 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1655 |
|
if ( pmtname.Contains("S11") ) rS11++; |
1656 |
|
if ( pmtname.Contains("S12") ) rS12++; |
1657 |
|
if ( pmtname.Contains("S21") ) rS21++; |
1658 |
|
if ( pmtname.Contains("S22") ) rS22++; |
1659 |
|
if ( pmtname.Contains("S31") ) rS31++; |
1660 |
|
if ( pmtname.Contains("S32") ) rS32++; |
1661 |
|
} |
1662 |
|
int rTOF1 = (rS11 + rS12) * (rS21 + rS22) * (rS31 + rS32); |
1663 |
|
int rTOF2 = (rS11 * rS12) * (rS21 * rS22) * (rS31 * rS32); |
1664 |
|
|
1665 |
|
int rTOF3 = (rS21 + rS22) * (rS31 + rS32); |
1666 |
|
int rTOF4 = (rS21 * rS22) * (rS31 * rS32); |
1667 |
|
|
1668 |
|
int rTOF5 = rS12 * (rS21 * rS22); |
1669 |
|
|
1670 |
|
int rTOF6 = (rS11 + rS12) * (rS31 + rS32); |
1671 |
|
int rTOF7 = (rS11 * rS12) * (rS31 * rS32); |
1672 |
|
|
1673 |
|
|
1674 |
|
// trigger configuration of the run |
1675 |
|
bool TCTOF1 = false; |
1676 |
|
bool TCTOF2 = false; |
1677 |
|
bool TCTOF3 = false; |
1678 |
|
bool TCTOF4 = false; |
1679 |
|
bool TCTOF5 = false; |
1680 |
|
bool TCTOF6 = false; |
1681 |
|
bool TCTOF7 = false; |
1682 |
|
if ( trg->trigconf & (1<<0) ) TCTOF1 = true; |
1683 |
|
if ( trg->trigconf & (1<<1) ) TCTOF2 = true; |
1684 |
|
if ( trg->trigconf & (1<<2) ) TCTOF3 = true; |
1685 |
|
if ( trg->trigconf & (1<<3) ) TCTOF4 = true; |
1686 |
|
if ( trg->trigconf & (1<<4) ) TCTOF5 = true; |
1687 |
|
if ( trg->trigconf & (1<<5) ) TCTOF6 = true; |
1688 |
|
if ( trg->trigconf & (1<<6) ) TCTOF7 = true; |
1689 |
|
|
1690 |
|
// do patterntrig pmts match the trigger configuration? |
1691 |
|
bool pmtsconf_trigconf_match = true; |
1692 |
|
if ( rTOF1 == 0 && TCTOF1 ) pmtsconf_trigconf_match = false; |
1693 |
|
if ( rTOF2 == 0 && TCTOF2 ) pmtsconf_trigconf_match = false; |
1694 |
|
if ( rTOF3 == 0 && TCTOF3 ) pmtsconf_trigconf_match = false; |
1695 |
|
if ( rTOF4 == 0 && TCTOF4 ) pmtsconf_trigconf_match = false; |
1696 |
|
if ( rTOF5 == 0 && TCTOF5 ) pmtsconf_trigconf_match = false; |
1697 |
|
if ( rTOF6 == 0 && TCTOF6 ) pmtsconf_trigconf_match = false; |
1698 |
|
if ( rTOF7 == 0 && TCTOF7 ) pmtsconf_trigconf_match = false; |
1699 |
|
|
1700 |
|
return pmtsconf_trigconf_match; |
1701 |
|
} |
1702 |
|
|
1703 |
|
void ToFLevel2::printPMT(){ |
1704 |
|
TClonesArray* Pmt = this->PMT; |
1705 |
|
for(int i=0; i<Pmt->GetEntries(); i++) { |
1706 |
|
ToFPMT* pmthit = (ToFPMT*)Pmt->At(i); |
1707 |
|
TString pmtname = this->GetPMTName(pmthit->pmt_id); |
1708 |
|
printf(" PMT hit: %s \n",pmtname.Data()); |
1709 |
|
} |
1710 |
|
} |
1711 |
|
|
1712 |
|
|
1713 |
|
ToFdEdx::ToFdEdx() |
1714 |
|
{ |
1715 |
|
memset(conn,0,12*sizeof(Bool_t)); |
1716 |
|
memset(ts,0,12*sizeof(UInt_t)); |
1717 |
|
memset(te,0,12*sizeof(UInt_t)); |
1718 |
|
eDEDXpmt = new TArrayF(48); |
1719 |
|
Define_PMTsat(); |
1720 |
|
Clear(); |
1721 |
|
} |
1722 |
|
|
1723 |
|
ToFdEdx::~ToFdEdx(){ |
1724 |
|
Clear(); |
1725 |
|
Delete(); |
1726 |
|
} |
1727 |
|
|
1728 |
|
void ToFdEdx::Delete(Option_t *option){ |
1729 |
|
if ( eDEDXpmt ){ |
1730 |
|
eDEDXpmt->Set(0); |
1731 |
|
if ( eDEDXpmt) delete eDEDXpmt; |
1732 |
|
} |
1733 |
|
} |
1734 |
|
|
1735 |
|
//------------------------------------------------------------------------ |
1736 |
|
void ToFdEdx::CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc) |
1737 |
|
{ |
1738 |
|
for(int i=0; i<12; i++){ |
1739 |
|
if(atime<=ts[i] || atime>te[i]){ |
1740 |
|
Int_t error=glparam->Query_GL_PARAM(atime,210+i,dbc); // parameters stored in DB in GL_PRAM table |
1741 |
|
if ( error<0 ) { |
1742 |
|
conn[i]=false; |
1743 |
|
ts[i]=0; |
1744 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1745 |
|
}; |
1746 |
|
if ( !error ){ |
1747 |
|
conn[i]=true; |
1748 |
|
ts[i]=glparam->FROM_TIME; |
1749 |
|
te[i]=glparam->TO_TIME; |
1750 |
|
} |
1751 |
|
if ( error>0 ){ |
1752 |
|
conn[i]=false; |
1753 |
|
ts[i]=glparam->TO_TIME; |
1754 |
|
TSQLResult *pResult; |
1755 |
|
TSQLRow *row; |
1756 |
|
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); |
1757 |
|
pResult=dbc->Query(query.Data()); |
1758 |
|
if(!pResult->GetRowCount()){ |
1759 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1760 |
|
}else{ |
1761 |
|
row=pResult->Next(); |
1762 |
|
te[i]=(UInt_t)atoll(row->GetField(0)); |
1763 |
|
} |
1764 |
|
} |
1765 |
|
// |
1766 |
|
|
1767 |
|
} |
1768 |
|
} |
1769 |
|
|
1770 |
|
} |
1771 |
|
//------------------------------------------------------------------------ |
1772 |
|
void ToFdEdx::Clear(Option_t *option) |
1773 |
|
{ |
1774 |
|
// |
1775 |
|
// Set arrays and initialize structure |
1776 |
|
// eDEDXpmt.Set(48); eDEDXpmt.Reset(-1); // Set array size and reset structure |
1777 |
|
eDEDXpmt->Set(48); eDEDXpmt->Reset(-1); // Set array size and reset structure |
1778 |
|
// |
1779 |
|
}; |
1780 |
|
|
1781 |
|
//------------------------------------------------------------------------ |
1782 |
|
void ToFdEdx::Print(Option_t *option) |
1783 |
|
{ |
1784 |
|
// |
1785 |
|
printf("========================================================================\n"); |
1786 |
|
|
1787 |
|
}; |
1788 |
|
|
1789 |
|
//------------------------------------------------------------------------ |
1790 |
|
void ToFdEdx::Init(pamela::tof::TofEvent *tofl0) |
1791 |
|
{ |
1792 |
|
// |
1793 |
|
ToFLevel2 tf; |
1794 |
|
for (Int_t gg=0; gg<4;gg++){ |
1795 |
|
for (Int_t hh=0; hh<12;hh++){ |
1796 |
|
// tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh]; |
1797 |
|
int mm = tf.GetPMTid(gg,hh); |
1798 |
|
adc[mm]= (0xFFF & tofl0->adc[gg][hh]); // EM, exclude warning bits |
1799 |
|
}; |
1800 |
|
}; |
1801 |
|
|
1802 |
|
}; |
1803 |
|
|
1804 |
|
//------------------------------------------------------------------------ |
1805 |
|
void ToFdEdx::Init(Int_t gg, Int_t hh, Float_t adce) |
1806 |
|
{ |
1807 |
|
// |
1808 |
|
ToFLevel2 tf; |
1809 |
|
// for (Int_t gg=0; gg<4;gg++){ |
1810 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1811 |
|
int mm = tf.GetPMTid(gg,hh); |
1812 |
|
adc[mm]=adce; |
1813 |
|
|
1814 |
|
}; |
1815 |
|
//------------------------------------------------------------------------ |
1816 |
|
void ToFdEdx::Process(UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, Int_t exitat) |
1817 |
|
{ |
1818 |
|
bool debug = false; |
1819 |
|
if ( debug ) printf(" INSIDE TOFDEDX PROCESS \n"); |
1820 |
|
// the parameters should be already initialised by InitPar() |
1821 |
|
// printf(" in process \n"); |
1822 |
|
Clear(); |
1823 |
|
|
1824 |
|
// define angle: |
1825 |
|
double dx = xtr_tof[1] - xtr_tof[5]; |
1826 |
|
double dy = ytr_tof[0] - ytr_tof[4]; |
1827 |
|
double dr = sqrt(dx*dx+dy*dy); |
1828 |
|
double theta=atan(dr/76.81); |
1829 |
|
// |
1830 |
|
if ( xtr_tof[1] > 99. || xtr_tof[5] > 99. || ytr_tof[0] > 99. || ytr_tof[4] > 99. ) theta = 0.; |
1831 |
|
for (Int_t ii=0; ii<6; ii++){ |
1832 |
|
if ( xtr_tof[ii] > 99. ) xtr_tof[ii] = 0.; |
1833 |
|
if ( ytr_tof[ii] > 99. ) ytr_tof[ii] = 0.; |
1834 |
|
}; |
1835 |
|
// |
1836 |
|
if ( debug ) printf(" theta %f \n",theta); |
1837 |
|
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]); |
1838 |
|
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]); |
1839 |
|
//--------------------- TABLE OF PERIODS WITH HV PROBLEMS ---------------------------- |
1840 |
|
|
1841 |
|
int Aconn=conn[0]; // PMT 0,20,22,24 |
1842 |
|
int Bconn=conn[1]; // PMT 6,12,26,34 |
1843 |
|
int Cconn=conn[2]; // PMT 4,14,28,32 |
1844 |
|
int Dconn=conn[3]; // PMT 2,8,10,30 |
1845 |
|
int Econn=conn[4]; // PMT 42,43,44,47 |
1846 |
|
int Fconn=conn[5]; // PMT 7,19,23,27 |
1847 |
|
int Gconn=conn[6]; // PMT 3,11,25,33 |
1848 |
|
int Hconn=conn[7]; // PMT 1,9,13,21 |
1849 |
|
int Iconn=conn[8]; // PMT 5,29,31,35 |
1850 |
|
int Lconn=conn[9]; // PMT 37,40,45,46 |
1851 |
|
int Mconn=conn[10]; // PMT 15,16,17,18 |
1852 |
|
int Nconn=conn[11]; // PMT 36,38,39,41 |
1853 |
|
if( false ) cout << Gconn << Iconn << Lconn <<endl; // to avoid compilation warnings |
1854 |
|
|
1855 |
|
// printf(" size %i \n",eDEDXpmt.GetSize()); |
1856 |
|
for( int ii=0; ii<48; ii++ ) { |
1857 |
|
// |
1858 |
|
// eDEDXpmt.SetAt(-1.,ii); |
1859 |
|
// 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]); |
1860 |
|
if ( debug ) printf("II %i adc %f \n",ii,adc[ii]); |
1861 |
|
|
1862 |
|
if( adc[ii] >= 4095. ){ |
1863 |
|
// eDEDXpmt[ii] = 0.; |
1864 |
|
eDEDXpmt->AddAt(0.,ii); |
1865 |
|
if ( debug ) printf(" %i adc>4095 \n",ii); |
1866 |
|
continue; // EMILIANO |
1867 |
|
}; |
1868 |
|
|
1869 |
|
if( adc[ii] >= (PMTsat[ii]-5.) && adc[ii] < 4095. ){ |
1870 |
|
eDEDXpmt->AddAt(1000.,ii); |
1871 |
|
if ( debug ) printf(" %i adc> pmtsat && adc<4095 \n",ii); |
1872 |
|
continue; // EMILIANO |
1873 |
|
}; |
1874 |
|
|
1875 |
|
if( adc[ii] <= 0. ) { |
1876 |
|
eDEDXpmt->AddAt(1500.,ii); |
1877 |
|
if ( debug ) printf(" %i adc<=0 \n",ii); |
1878 |
|
continue; |
1879 |
|
}; |
1880 |
|
// |
1881 |
|
double adcpC = f_adcPC( adc[ii] ); // - adc conversion in pC |
1882 |
|
if ( exitat == 0 ){ |
1883 |
|
eDEDXpmt->AddAt((Float_t)adcpC,ii); |
1884 |
|
continue; |
1885 |
|
} |
1886 |
|
// printf(" e qua? \n"); |
1887 |
|
|
1888 |
|
double adccorr = adcpC*fabs(cos(theta)); |
1889 |
|
if ( debug ) printf(" adccorr %f \n",adccorr); |
1890 |
|
if(adccorr<=0.){ |
1891 |
|
if ( debug ) printf(" %i adccorr<=0 \n",ii); |
1892 |
|
// eDEDXpmt->AddAt((Float_t)adcpC,ii);//? |
1893 |
|
continue; |
1894 |
|
} |
1895 |
|
if ( exitat == 1 ){ |
1896 |
|
eDEDXpmt->AddAt((Float_t)adccorr,ii); |
1897 |
|
continue; |
1898 |
|
} |
1899 |
|
// printf(" e quo? \n"); |
1900 |
|
|
1901 |
|
// int standard=0; |
1902 |
|
int S115B_ok=0; |
1903 |
|
int S115B_break=0; |
1904 |
|
|
1905 |
|
if(atime<1158720000)S115B_ok=1; |
1906 |
|
else S115B_break=1; |
1907 |
|
|
1908 |
|
|
1909 |
|
//------------------------------------------------------------------------ |
1910 |
|
// printf(" e qui? \n"); |
1911 |
|
//---------------------------------------------------- Z reconstruction |
1912 |
|
|
1913 |
|
double adcHe, adcnorm, adclin, dEdx;//, Zeta; // EM GCC4.7 |
1914 |
|
|
1915 |
|
adcHe=-2; |
1916 |
|
adcnorm=-2; |
1917 |
|
adclin=-2; |
1918 |
|
dEdx=-2; |
1919 |
|
// Zeta=-2;//EM GCC4.7 |
1920 |
|
Double_t correction = 1.; |
1921 |
|
|
1922 |
|
if(Aconn==1 && (ii==0 || ii==20 || ii==22 || ii==24)){ |
1923 |
|
correction = 1.675; |
1924 |
|
} |
1925 |
|
else if(Bconn==1 && (ii==6 || ii==12 || ii==26 || ii==34)){ |
1926 |
|
correction = 2.482; |
1927 |
|
} |
1928 |
|
else if(Cconn==1 && (ii==4 || ii==14 || ii==28 || ii==32)){ |
1929 |
|
correction = 1.464; |
1930 |
|
} |
1931 |
|
else if(Dconn==1 && (ii==2 || ii==8 || ii==10 || ii==30)){ |
1932 |
|
correction = 1.995; |
1933 |
|
} |
1934 |
|
else if(Econn==1 && (ii==42 || ii==43 || ii==44 || ii==47)){ |
1935 |
|
correction = 1.273; |
1936 |
|
} |
1937 |
|
else if(Fconn==1 && (ii==7 || ii==19 || ii==23 || ii==27)){ |
1938 |
|
correction = 1.565; |
1939 |
|
} |
1940 |
|
else if(Mconn==1 && (ii==15 || ii==16 || ii==17 || ii==18)){ |
1941 |
|
correction = 1.565; |
1942 |
|
} |
1943 |
|
else if(Nconn==1 && (ii==36 || ii==38 || ii==39 || ii==41)){ |
1944 |
|
correction = 1.018; |
1945 |
|
} |
1946 |
|
else if(Hconn==1 && (ii==1 || ii==13 || ii==21 || (ii==9&&S115B_ok==1))){ |
1947 |
|
correction = 1.84; |
1948 |
|
} |
1949 |
|
else if(S115B_break==1 && ii==9 && Hconn==1){ |
1950 |
|
correction = 1.64; |
1951 |
|
} |
1952 |
|
else correction = 1.; |
1953 |
|
|
1954 |
|
if( ii==9 && S115B_break==1 ){ |
1955 |
|
adcHe = f_att5B( ytr_tof[0] )/correction; |
1956 |
|
} else { |
1957 |
|
adcHe = Get_adc_he(ii, xtr_tof, ytr_tof)/correction; |
1958 |
|
}; |
1959 |
|
if(adcHe<=0){ |
1960 |
|
if ( debug ) printf(" %i adcHe<=0 \n",ii); |
1961 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii); //? |
1962 |
|
continue; |
1963 |
|
} |
1964 |
|
if ( exitat == 2 ){ |
1965 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt(36.*(Float_t)adccorr/adcHe,ii); |
1966 |
|
else adclin = 4.*(Float_t)adccorr/adcHe; |
1967 |
|
continue; |
1968 |
|
} |
1969 |
|
|
1970 |
|
if(ii==9 && S115B_break==1) adcnorm = f_pos5B(adccorr); |
1971 |
|
else adcnorm = f_pos( (parPos[ii]), adccorr); |
1972 |
|
if(adcnorm<=0){ |
1973 |
|
if ( debug ) printf(" %i adcnorm<=0 \n",ii); |
1974 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii);//? |
1975 |
|
continue; |
1976 |
|
} |
1977 |
|
if ( debug ) printf(" adcnorm %f \n",adcnorm); |
1978 |
|
|
1979 |
|
if(ii==9 && S115B_break==1) adclin = 36.*adcnorm/adcHe; |
1980 |
|
else adclin = 4.*adcnorm/adcHe; |
1981 |
|
if ( debug ) printf(" adclin %f \n",adclin); |
1982 |
|
if(adclin<=0){ |
1983 |
|
if ( debug ) printf(" %i adclin<=0 \n",ii); |
1984 |
|
// eDEDXpmt->AddAt((Float_t)adccorr,ii);//? |
1985 |
|
continue; |
1986 |
|
} |
1987 |
|
if ( exitat == 3 ){ |
1988 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt((Float_t)adclin,ii); |
1989 |
|
else eDEDXpmt->AddAt((Float_t)adclin,ii); |
1990 |
|
continue; |
1991 |
|
} |
1992 |
|
// |
1993 |
|
if ( betamean > 99. ){ |
1994 |
|
// eDEDXpmt.AddAt((Float_t)adclin,ii); |
1995 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
1996 |
|
// printf(" AAPMT IS %i dedx is %f vector is %f \n",ii,adclin,eDEDXpmt[ii]); |
1997 |
|
if ( debug ) printf(" %i betamean > 99 \n",ii); |
1998 |
|
continue; |
1999 |
|
}; |
2000 |
|
// |
2001 |
|
double dEdxHe=-2; |
2002 |
|
if(ii==9 && S115B_break==1){ |
2003 |
|
if( betamean <1. ) dEdxHe = f_BB5B( betamean ); |
2004 |
|
else dEdxHe = 33; |
2005 |
|
} else { |
2006 |
|
if( betamean <1. ) dEdxHe = f_BB( (parBBneg[ii]), betamean ); |
2007 |
|
else dEdxHe = parBBpos[ii]; |
2008 |
|
} |
2009 |
|
|
2010 |
|
if ( debug ) printf(" dEdxHe %f \n",dEdxHe); |
2011 |
|
|
2012 |
|
if(dEdxHe<=0){ |
2013 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
2014 |
|
if ( debug ) printf(" %i dEdxHe<=0 \n",ii); |
2015 |
|
continue; |
2016 |
|
}; |
2017 |
|
|
2018 |
|
if(ii==9 && S115B_break==1) dEdx = f_desatBB5B( adclin ); |
2019 |
|
else dEdx = f_desatBB((parDesatBB[ii]), adclin ); |
2020 |
|
|
2021 |
|
if(dEdx<=0){ |
2022 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
2023 |
|
if ( debug ) printf(" %i dEdx<=0 \n",ii); |
2024 |
|
continue; |
2025 |
|
}; |
2026 |
|
|
2027 |
|
if ( debug ) printf(" dEdx %f \n",dEdx); |
2028 |
|
eDEDXpmt->AddAt((Float_t)dEdx,ii); |
2029 |
|
// eDEDXpmt.AddAt((Float_t)dEdx,ii); |
2030 |
|
|
2031 |
|
// printf(" PMT IS %i dedx is %f vector is %f \n",ii,dEdx,eDEDXpmt[ii]); |
2032 |
|
|
2033 |
|
} //end loop on 48 PMT |
2034 |
|
|
2035 |
|
}; |
2036 |
|
|
2037 |
|
|
2038 |
|
//------------------------------------------------------------------------ |
2039 |
|
void ToFdEdx::Define_PMTsat() |
2040 |
|
{ |
2041 |
|
Float_t sat[48] = { |
2042 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
2043 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
2044 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
2045 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
2046 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
2047 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
2048 |
|
PMTsat.Set(48,sat); |
2049 |
|
} |
2050 |
|
|
2051 |
|
//------------------------------------------------------------------------ |
2052 |
|
void ToFdEdx::ReadParBBpos( const char *fname ) |
2053 |
|
{ |
2054 |
|
// printf("read %s\n",fname); |
2055 |
|
parBBpos.Set(48); |
2056 |
|
FILE *fattin = fopen( fname , "r" ); |
2057 |
|
for (int i=0; i<48; i++) { |
2058 |
|
int tid=0; |
2059 |
|
float tp; |
2060 |
|
if(fscanf(fattin,"%d %f", |
2061 |
|
&tid, &tp )!=2) break; |
2062 |
|
parBBpos[i]=tp; |
2063 |
|
} |
2064 |
|
fclose(fattin); |
2065 |
|
} |
2066 |
|
|
2067 |
|
//------------------------------------------------------------------------ |
2068 |
|
void ToFdEdx::ReadParDesatBB( const char *fname ) |
2069 |
|
{ |
2070 |
|
// printf("read %s\n",fname); |
2071 |
|
FILE *fattin = fopen( fname , "r" ); |
2072 |
|
for (int i=0; i<48; i++) { |
2073 |
|
int tid=0; |
2074 |
|
float tp[3]; |
2075 |
|
if(fscanf(fattin,"%d %f %f %f", |
2076 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
2077 |
|
parDesatBB[i].Set(3,tp); |
2078 |
|
} |
2079 |
|
fclose(fattin); |
2080 |
|
} |
2081 |
|
|
2082 |
|
|
2083 |
|
//------------------------------------------------------------------------ |
2084 |
|
void ToFdEdx::ReadParBBneg( const char *fname ) |
2085 |
|
|
2086 |
|
{ |
2087 |
|
// printf("read %s\n",fname); |
2088 |
|
FILE *fattin = fopen( fname , "r" ); |
2089 |
|
for (int i=0; i<48; i++) { |
2090 |
|
int tid=0; |
2091 |
|
float tp[3]; |
2092 |
|
if(fscanf(fattin,"%d %f %f %f", |
2093 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
2094 |
|
parBBneg[i].Set(3,tp); |
2095 |
|
} |
2096 |
|
fclose(fattin); |
2097 |
|
} |
2098 |
|
|
2099 |
|
//------------------------------------------------------------------------ |
2100 |
|
void ToFdEdx::ReadParPos( const char *fname ) |
2101 |
|
{ |
2102 |
|
// printf("read %s\n",fname); |
2103 |
|
FILE *fattin = fopen( fname , "r" ); |
2104 |
|
for (int i=0; i<48; i++) { |
2105 |
|
int tid=0; |
2106 |
|
float tp[4]; |
2107 |
|
if(fscanf(fattin,"%d %f %f %f %f", |
2108 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3])!=5) break; |
2109 |
|
parPos[i].Set(4,tp); |
2110 |
|
} |
2111 |
|
fclose(fattin); |
2112 |
|
} |
2113 |
|
|
2114 |
|
//------------------------------------------------------------------------ |
2115 |
|
void ToFdEdx::ReadParAtt( const char *fname ) |
2116 |
|
{ |
2117 |
|
// printf("read %s\n",fname); |
2118 |
|
FILE *fattin = fopen( fname , "r" ); |
2119 |
|
for (int i=0; i<48; i++) { |
2120 |
|
int tid=0; |
2121 |
|
float tp[6]; |
2122 |
|
if(fscanf(fattin,"%d %f %f %f %f %f %f", |
2123 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3], &tp[4], &tp[5] )!=7) break; |
2124 |
|
parAtt[i].Set(6,tp); |
2125 |
|
} |
2126 |
|
fclose(fattin); |
2127 |
|
} |
2128 |
|
|
2129 |
|
|
2130 |
|
|
2131 |
|
|
2132 |
|
|
2133 |
|
|
2134 |
|
double ToFdEdx::f_att( TArrayF &p, float x ) |
2135 |
|
{ |
2136 |
|
return |
2137 |
|
p[0] + |
2138 |
|
p[1]*x + |
2139 |
|
p[2]*x*x + |
2140 |
|
p[3]*x*x*x + |
2141 |
|
p[4]*x*x*x*x + |
2142 |
|
p[5]*x*x*x*x*x; |
2143 |
|
} |
2144 |
|
//------------------------------------------------------------------------ |
2145 |
|
double ToFdEdx::f_att5B( float x ) |
2146 |
|
{ |
2147 |
|
return |
2148 |
|
101.9409 + |
2149 |
|
6.643781*x + |
2150 |
|
0.2765518*x*x + |
2151 |
|
0.004617647*x*x*x + |
2152 |
|
0.0006195132*x*x*x*x + |
2153 |
|
0.00002813734*x*x*x*x*x; |
2154 |
|
} |
2155 |
|
|
2156 |
|
|
2157 |
|
double ToFdEdx::f_pos( TArrayF &p, float x ) |
2158 |
|
{ |
2159 |
|
return |
2160 |
|
p[0] + |
2161 |
|
p[1]*x + |
2162 |
|
p[2]*x*x + |
2163 |
|
p[3]*x*x*x; |
2164 |
|
} |
2165 |
|
|
2166 |
|
double ToFdEdx::f_pos5B( float x ) |
2167 |
|
{ |
2168 |
|
return |
2169 |
|
15.45132 + |
2170 |
|
0.8369721*x + |
2171 |
|
0.0005*x*x; |
2172 |
|
} |
2173 |
|
|
2174 |
|
|
2175 |
|
|
2176 |
|
double ToFdEdx::f_adcPC( float x ) |
2177 |
|
{ |
2178 |
|
return 28.12+0.6312*x-5.647e-05*x*x+3.064e-08*x*x*x; |
2179 |
|
} |
2180 |
|
|
2181 |
|
|
2182 |
|
float ToFdEdx::Get_adc_he( int id, float pl_x[6], float pl_y[6]) |
2183 |
|
{ |
2184 |
|
|
2185 |
|
// |
2186 |
|
// input: id - pmt [0:47} |
2187 |
|
// pl_x - coord x of the tof plane |
2188 |
|
// pl_y - coord y |
2189 |
|
|
2190 |
|
adc_he = 0; |
2191 |
|
if( eGeom.GetXY(id)==1 ) adc_he = f_att( (parAtt[id]), pl_x[eGeom.GetPlane(id)] ); |
2192 |
|
if( eGeom.GetXY(id)==2 ) adc_he = f_att( (parAtt[id]), pl_y[eGeom.GetPlane(id)] ); |
2193 |
|
return adc_he; |
2194 |
|
} |
2195 |
|
|
2196 |
|
//------------------------------------------------------------------------ |
2197 |
|
double ToFdEdx::f_BB( TArrayF &p, float x ) |
2198 |
|
{ |
2199 |
|
return p[0]/(x*x)*(log(x*x/(1-x*x)) - p[1]*x*x - p[2]); |
2200 |
|
} |
2201 |
|
|
2202 |
|
//------------------------------------------------------------------------ |
2203 |
|
double ToFdEdx::f_BB5B( float x ) |
2204 |
|
{ |
2205 |
|
return 0.165797/(x*x)*(log(x*x/(1-x*x)) + 140.481*x*x + 52.9258); |
2206 |
|
} |
2207 |
|
//------------------------------------------------------------------------ |
2208 |
|
double ToFdEdx::f_desatBB( TArrayF &p, float x ) |
2209 |
|
{ |
2210 |
|
return |
2211 |
|
p[0] + |
2212 |
|
p[1]*x + |
2213 |
|
p[2]*x*x; |
2214 |
|
} |
2215 |
|
|
2216 |
|
//------------------------------------------------------------------------ |
2217 |
|
double ToFdEdx::f_desatBB5B( float x ) |
2218 |
|
{ |
2219 |
|
return |
2220 |
|
-2.4 + |
2221 |
|
0.75*x + |
2222 |
|
0.009*x*x; |
2223 |
|
} |
2224 |
|
|