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::Set(){//ELENA |
92 |
|
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
93 |
|
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
94 |
|
}//ELENA |
95 |
|
|
96 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Clear(){ |
97 |
// |
// |
98 |
ToFTrk->Clear(); |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
99 |
PMT->Clear(); |
if(PMT)PMT->Delete(); //ELENA |
100 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
101 |
|
unpackError = 0; |
102 |
// |
// |
103 |
}; |
}; |
104 |
|
|
105 |
|
void ToFLevel2::Delete(){ //ELENA |
106 |
|
// |
107 |
|
if(ToFTrk){ |
108 |
|
ToFTrk->Delete(); //ELENA |
109 |
|
delete ToFTrk; //ELENA |
110 |
|
} |
111 |
|
if(PMT){ |
112 |
|
PMT->Delete(); //ELENA |
113 |
|
delete PMT; //ELENA |
114 |
|
} //ELENA |
115 |
|
// |
116 |
|
}; //ELENA |
117 |
|
|
118 |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
119 |
// |
// |
120 |
if(itrk >= ntrk()){ |
if(itrk >= ntrk()){ |
123 |
return(NULL); |
return(NULL); |
124 |
} |
} |
125 |
// |
// |
126 |
|
if(!ToFTrk)return 0; //ELENA |
127 |
TClonesArray &t = *(ToFTrk); |
TClonesArray &t = *(ToFTrk); |
128 |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
129 |
return toftrack; |
return toftrack; |
137 |
return(NULL); |
return(NULL); |
138 |
} |
} |
139 |
// |
// |
140 |
|
if(!PMT)return 0; //ELENA |
141 |
TClonesArray &t = *(PMT); |
TClonesArray &t = *(PMT); |
142 |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
143 |
return tofpmt; |
return tofpmt; |
168 |
else return -1; |
else return -1; |
169 |
}; |
}; |
170 |
/** |
/** |
171 |
* 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 |
172 |
|
* from both PMTs |
173 |
* @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). |
174 |
* @param paddle_id Paddle ID. |
* @param paddle_id Paddle ID. |
175 |
* @return 1 if the paddle was hit. |
* @return 1 if the paddle was hit. |
202 |
|
|
203 |
|
|
204 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
205 |
|
|
206 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
207 |
Int_t ip = 0; |
Int_t ip = 0; |
208 |
Int_t pmt_id = 0; |
Int_t pmt_id = 0; |
214 |
}; |
}; |
215 |
// |
// |
216 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
217 |
|
if(!trk) return 0; //ELENA |
218 |
// |
// |
219 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
220 |
// |
// |
222 |
// |
// |
223 |
pl = GetPlaneIndex(pmt_id); |
pl = GetPlaneIndex(pmt_id); |
224 |
// |
// |
225 |
if ( pl == ip ) dedx += (trk->dedx).At(i); |
if ( pl == ip ){ |
226 |
|
// // --- patch --- |
227 |
|
// bool ISNULL=false; |
228 |
|
// for(Int_t im=0; im< this->npmt(); im++){ |
229 |
|
// if(this->GetToFPMT(im)->pmt_id == pmt_id && this->GetToFPMT(im)->adc == 4095){ |
230 |
|
// cout << " ToFLevel2::GetdEdx(Int_t,Int_t) --> **warning** ADC(PMT="<<pmt_id<<") = 4095"<<endl; |
231 |
|
// ISNULL=true; |
232 |
|
// } |
233 |
|
// } |
234 |
|
// // --- patch --- |
235 |
|
// dedx += (trk->dedx).At(i)*(Int_t)(!ISNULL); |
236 |
|
dedx += (trk->dedx).At(i); |
237 |
|
} |
238 |
// |
// |
239 |
}; |
}; |
240 |
// |
// |
256 |
Int_t kk = 0; |
Int_t kk = 0; |
257 |
// |
// |
258 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
259 |
|
if(!trk)return; //ELENA |
260 |
// |
// |
261 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
262 |
// |
// |
263 |
pmt_id = (trk->pmtadc).At(i); |
pmt_id = (trk->pmtadc).At(i); |
264 |
// |
// |
265 |
GetPMTIndex(pmt_id,hh,kk); |
GetPMTIndex(pmt_id,hh,kk); |
266 |
adc[hh][kk] = (trk->dedx).At(i); |
adc[kk][hh] = (trk->dedx).At(i); |
267 |
// |
// |
268 |
}; |
}; |
269 |
// |
// |
270 |
for (Int_t i=0; i<npmt(); i++){ |
for (Int_t i=0; i<npmt(); i++){ |
271 |
// |
// |
272 |
ToFPMT *pmt = GetToFPMT(i); |
ToFPMT *pmt = GetToFPMT(i); |
273 |
|
if(!pmt)break; //ELENA |
274 |
// |
// |
275 |
GetPMTIndex(pmt->pmt_id,hh,kk); |
GetPMTIndex(pmt->pmt_id,hh,kk); |
276 |
// |
// |
277 |
tdc[hh][kk] = pmt->tdc_tw; |
tdc[kk][hh] = pmt->tdc_tw; |
278 |
// |
// |
279 |
}; |
}; |
280 |
// |
// |
345 |
}; |
}; |
346 |
|
|
347 |
|
|
348 |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t hb, Int_t ch){ |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
349 |
// |
// |
350 |
short tof[4][24] = { |
short tof[4][24] = { |
351 |
{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}, |
358 |
while (k < 24){ |
while (k < 24){ |
359 |
Int_t j = 0; |
Int_t j = 0; |
360 |
while (j < 2){ |
while (j < 2){ |
361 |
|
/* tofEvent->tdc[ch][hb] */ |
|
/* tofEvent->tdc[ch][hb] */ |
|
|
|
|
362 |
if( ind == 2*k + j ){ |
if( ind == 2*k + j ){ |
363 |
ch = tof[2*j][k] - 1; |
ch = tof[2*j][k] - 1; |
364 |
hb = tof[2*j + 1][k] - 1; |
hb = tof[2*j + 1][k] - 1; |
365 |
break; |
return; |
366 |
}; |
}; |
367 |
j++; |
j++; |
368 |
}; |
}; |
370 |
}; |
}; |
371 |
return; |
return; |
372 |
}; |
}; |
373 |
|
|
374 |
|
/** |
375 |
|
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
376 |
|
*/ |
377 |
|
void ToFLevel2::GetLevel2Struct(cToFLevel2 *l2) const{ |
378 |
|
|
379 |
|
for(Int_t i=0;i<6;i++) |
380 |
|
l2->tof_j_flag[i]=tof_j_flag[i]; |
381 |
|
|
382 |
|
if(ToFTrk){ //ELENA |
383 |
|
l2->ntoftrk = ToFTrk->GetEntries(); |
384 |
|
for(Int_t j=0;j<l2->ntoftrk;j++){ |
385 |
|
l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno; |
386 |
|
l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc; |
387 |
|
for(Int_t i=0;i<l2->npmttdc[j];i++){ |
388 |
|
l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i); |
389 |
|
l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006 |
390 |
|
} |
391 |
|
for(Int_t i=0;i<13;i++) |
392 |
|
l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i]; |
393 |
|
|
394 |
|
l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc; |
395 |
|
for(Int_t i=0;i<l2->npmtadc[j];i++){ |
396 |
|
l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i); |
397 |
|
l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006 |
398 |
|
l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i); |
399 |
|
} |
400 |
|
for(Int_t i=0;i<3;i++){ |
401 |
|
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
402 |
|
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
403 |
|
} |
404 |
|
} |
405 |
|
} //ELENA |
406 |
|
|
407 |
|
if(PMT){ //ELENA |
408 |
|
l2->npmt = PMT->GetEntries(); |
409 |
|
for(Int_t j=0;j<l2->npmt;j++){ |
410 |
|
l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id; |
411 |
|
l2->adc[j] =((ToFPMT*)PMT->At(j))->adc; |
412 |
|
l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw; |
413 |
|
} |
414 |
|
} //ELENA |
415 |
|
} |