32 |
npmtadc = 0; |
npmtadc = 0; |
33 |
pmttdc = TArrayI(48); |
pmttdc = TArrayI(48); |
34 |
pmtadc = TArrayI(48); |
pmtadc = TArrayI(48); |
35 |
|
tdcflag = TArrayI(48); // gf: 30 Nov 2006 |
36 |
|
adcflag = TArrayI(48); // gf: 30 Nov 2006 |
37 |
dedx = TArrayF(48); |
dedx = TArrayF(48); |
38 |
// |
// |
39 |
// |
// |
49 |
npmtadc = 0; |
npmtadc = 0; |
50 |
pmttdc.Reset(); |
pmttdc.Reset(); |
51 |
pmtadc.Reset(); |
pmtadc.Reset(); |
52 |
|
tdcflag.Reset(); // gf: 30 Nov 2006 |
53 |
|
adcflag.Reset(); // gf: 30 Nov 2006 |
54 |
dedx.Reset(); |
dedx.Reset(); |
55 |
// |
// |
56 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
67 |
npmtadc = t.npmtadc; |
npmtadc = t.npmtadc; |
68 |
(t.pmttdc).Copy(pmttdc); |
(t.pmttdc).Copy(pmttdc); |
69 |
(t.pmtadc).Copy(pmtadc); |
(t.pmtadc).Copy(pmtadc); |
70 |
|
(t.tdcflag).Copy(tdcflag); // gf: 30 Nov 2006 |
71 |
|
(t.adcflag).Copy(adcflag); // gf: 30 Nov 2006 |
72 |
(t.dedx).Copy(dedx); |
(t.dedx).Copy(dedx); |
73 |
// |
// |
74 |
memcpy(beta,t.beta,sizeof(beta)); |
memcpy(beta,t.beta,sizeof(beta)); |
79 |
|
|
80 |
ToFLevel2::ToFLevel2() { |
ToFLevel2::ToFLevel2() { |
81 |
// |
// |
82 |
PMT = new TClonesArray("ToFPMT",12); |
// PMT = new TClonesArray("ToFPMT",12); //ELENA |
83 |
ToFTrk = new TClonesArray("ToFTrkVar",2); |
// ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
84 |
|
PMT = 0; //ELENA |
85 |
|
ToFTrk = 0; //ELENA |
86 |
|
// |
87 |
|
this->Clear(); |
88 |
// |
// |
|
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
|
89 |
}; |
}; |
90 |
|
|
91 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Clear(){ |
92 |
// |
// |
93 |
ToFTrk->Clear(); |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
94 |
PMT->Clear(); |
if(PMT)PMT->Delete(); //ELENA |
95 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
96 |
|
unpackError = 0; |
97 |
// |
// |
98 |
}; |
}; |
99 |
|
|
100 |
|
void ToFLevel2::Delete(){ //ELENA |
101 |
|
// |
102 |
|
if(ToFTrk){ |
103 |
|
ToFTrk->Delete(); //ELENA |
104 |
|
delete ToFTrk; //ELENA |
105 |
|
} |
106 |
|
if(PMT){ |
107 |
|
PMT->Delete(); //ELENA |
108 |
|
delete PMT; //ELENA |
109 |
|
} //ELENA |
110 |
|
// |
111 |
|
}; //ELENA |
112 |
|
|
113 |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
114 |
// |
// |
115 |
if(itrk >= ntrk()){ |
if(itrk >= ntrk()){ |
118 |
return(NULL); |
return(NULL); |
119 |
} |
} |
120 |
// |
// |
121 |
|
if(!ToFTrk)return 0; //ELENA |
122 |
TClonesArray &t = *(ToFTrk); |
TClonesArray &t = *(ToFTrk); |
123 |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
124 |
return toftrack; |
return toftrack; |
132 |
return(NULL); |
return(NULL); |
133 |
} |
} |
134 |
// |
// |
135 |
|
if(!PMT)return 0; //ELENA |
136 |
TClonesArray &t = *(PMT); |
TClonesArray &t = *(PMT); |
137 |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
138 |
return tofpmt; |
return tofpmt; |
163 |
else return -1; |
else return -1; |
164 |
}; |
}; |
165 |
/** |
/** |
166 |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal from both PMTs |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
167 |
|
* from both PMTs |
168 |
* @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). |
169 |
* @param paddle_id Paddle ID. |
* @param paddle_id Paddle ID. |
170 |
* @return 1 if the paddle was hit. |
* @return 1 if the paddle was hit. |
197 |
|
|
198 |
|
|
199 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
200 |
|
|
201 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
202 |
Int_t ip = 0; |
Int_t ip = 0; |
203 |
Int_t pmt_id = 0; |
Int_t pmt_id = 0; |
209 |
}; |
}; |
210 |
// |
// |
211 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
212 |
|
if(!trk) return 0; //ELENA |
213 |
// |
// |
214 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
215 |
// |
// |
217 |
// |
// |
218 |
pl = GetPlaneIndex(pmt_id); |
pl = GetPlaneIndex(pmt_id); |
219 |
// |
// |
220 |
if ( pl == ip ) dedx += (trk->dedx).At(i); |
if ( pl == ip ){ |
221 |
|
// // --- patch --- |
222 |
|
// bool ISNULL=false; |
223 |
|
// for(Int_t im=0; im< this->npmt(); im++){ |
224 |
|
// if(this->GetToFPMT(im)->pmt_id == pmt_id && this->GetToFPMT(im)->adc == 4095){ |
225 |
|
// cout << " ToFLevel2::GetdEdx(Int_t,Int_t) --> **warning** ADC(PMT="<<pmt_id<<") = 4095"<<endl; |
226 |
|
// ISNULL=true; |
227 |
|
// } |
228 |
|
// } |
229 |
|
// // --- patch --- |
230 |
|
// dedx += (trk->dedx).At(i)*(Int_t)(!ISNULL); |
231 |
|
dedx += (trk->dedx).At(i); |
232 |
|
} |
233 |
// |
// |
234 |
}; |
}; |
235 |
// |
// |
251 |
Int_t kk = 0; |
Int_t kk = 0; |
252 |
// |
// |
253 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
254 |
|
if(!trk)return; //ELENA |
255 |
// |
// |
256 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
257 |
// |
// |
258 |
pmt_id = (trk->pmtadc).At(i); |
pmt_id = (trk->pmtadc).At(i); |
259 |
// |
// |
260 |
GetPMTIndex(pmt_id,hh,kk); |
GetPMTIndex(pmt_id,hh,kk); |
261 |
adc[hh][kk] = (trk->dedx).At(i); |
adc[kk][hh] = (trk->dedx).At(i); |
262 |
// |
// |
263 |
}; |
}; |
264 |
// |
// |
265 |
for (Int_t i=0; i<npmt(); i++){ |
for (Int_t i=0; i<npmt(); i++){ |
266 |
// |
// |
267 |
ToFPMT *pmt = GetToFPMT(i); |
ToFPMT *pmt = GetToFPMT(i); |
268 |
|
if(!pmt)break; //ELENA |
269 |
// |
// |
270 |
GetPMTIndex(pmt->pmt_id,hh,kk); |
GetPMTIndex(pmt->pmt_id,hh,kk); |
271 |
// |
// |
272 |
tdc[hh][kk] = pmt->tdc_tw; |
tdc[kk][hh] = pmt->tdc_tw; |
273 |
// |
// |
274 |
}; |
}; |
275 |
// |
// |
340 |
}; |
}; |
341 |
|
|
342 |
|
|
343 |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t hb, Int_t ch){ |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
344 |
// |
// |
345 |
short tof[4][24] = { |
short tof[4][24] = { |
346 |
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
353 |
while (k < 24){ |
while (k < 24){ |
354 |
Int_t j = 0; |
Int_t j = 0; |
355 |
while (j < 2){ |
while (j < 2){ |
356 |
|
/* tofEvent->tdc[ch][hb] */ |
|
/* tofEvent->tdc[ch][hb] */ |
|
|
|
|
357 |
if( ind == 2*k + j ){ |
if( ind == 2*k + j ){ |
358 |
ch = tof[2*j][k] - 1; |
ch = tof[2*j][k] - 1; |
359 |
hb = tof[2*j + 1][k] - 1; |
hb = tof[2*j + 1][k] - 1; |
360 |
break; |
return; |
361 |
}; |
}; |
362 |
j++; |
j++; |
363 |
}; |
}; |
365 |
}; |
}; |
366 |
return; |
return; |
367 |
}; |
}; |
368 |
|
|
369 |
|
/** |
370 |
|
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
371 |
|
*/ |
372 |
|
void ToFLevel2::GetLevel2Struct(cToFLevel2 *l2) const{ |
373 |
|
|
374 |
|
for(Int_t i=0;i<6;i++) |
375 |
|
l2->tof_j_flag[i]=tof_j_flag[i]; |
376 |
|
|
377 |
|
if(ToFTrk){ //ELENA |
378 |
|
l2->ntoftrk = ToFTrk->GetEntries(); |
379 |
|
for(Int_t j=0;j<l2->ntoftrk;j++){ |
380 |
|
l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno; |
381 |
|
l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc; |
382 |
|
for(Int_t i=0;i<l2->npmttdc[j];i++){ |
383 |
|
l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i); |
384 |
|
l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006 |
385 |
|
} |
386 |
|
for(Int_t i=0;i<13;i++) |
387 |
|
l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i]; |
388 |
|
|
389 |
|
l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc; |
390 |
|
for(Int_t i=0;i<l2->npmtadc[j];i++){ |
391 |
|
l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i); |
392 |
|
l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006 |
393 |
|
l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i); |
394 |
|
} |
395 |
|
for(Int_t i=0;i<3;i++){ |
396 |
|
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
397 |
|
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
398 |
|
} |
399 |
|
} |
400 |
|
} //ELENA |
401 |
|
|
402 |
|
if(PMT){ //ELENA |
403 |
|
l2->npmt = PMT->GetEntries(); |
404 |
|
for(Int_t j=0;j<l2->npmt;j++){ |
405 |
|
l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id; |
406 |
|
l2->adc[j] =((ToFPMT*)PMT->At(j))->adc; |
407 |
|
l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw; |
408 |
|
} |
409 |
|
} //ELENA |
410 |
|
} |