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> |
37 |
npmtadc = 0; |
npmtadc = 0; |
38 |
pmttdc = TArrayI(48); |
pmttdc = TArrayI(48); |
39 |
pmtadc = TArrayI(48); |
pmtadc = TArrayI(48); |
40 |
|
tdcflag = TArrayI(48); // gf: 30 Nov 2006 |
41 |
|
adcflag = TArrayI(48); // gf: 30 Nov 2006 |
42 |
dedx = TArrayF(48); |
dedx = TArrayF(48); |
43 |
// |
// |
44 |
// |
// |
54 |
npmtadc = 0; |
npmtadc = 0; |
55 |
pmttdc.Reset(); |
pmttdc.Reset(); |
56 |
pmtadc.Reset(); |
pmtadc.Reset(); |
57 |
|
tdcflag.Reset(); // gf: 30 Nov 2006 |
58 |
|
adcflag.Reset(); // gf: 30 Nov 2006 |
59 |
dedx.Reset(); |
dedx.Reset(); |
60 |
// |
// |
61 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
72 |
npmtadc = t.npmtadc; |
npmtadc = t.npmtadc; |
73 |
(t.pmttdc).Copy(pmttdc); |
(t.pmttdc).Copy(pmttdc); |
74 |
(t.pmtadc).Copy(pmtadc); |
(t.pmtadc).Copy(pmtadc); |
75 |
|
(t.tdcflag).Copy(tdcflag); // gf: 30 Nov 2006 |
76 |
|
(t.adcflag).Copy(adcflag); // gf: 30 Nov 2006 |
77 |
(t.dedx).Copy(dedx); |
(t.dedx).Copy(dedx); |
78 |
// |
// |
79 |
memcpy(beta,t.beta,sizeof(beta)); |
memcpy(beta,t.beta,sizeof(beta)); |
84 |
|
|
85 |
ToFLevel2::ToFLevel2() { |
ToFLevel2::ToFLevel2() { |
86 |
// |
// |
87 |
PMT = new TClonesArray("ToFPMT",12); |
// PMT = new TClonesArray("ToFPMT",12); //ELENA |
88 |
ToFTrk = new TClonesArray("ToFTrkVar",2); |
// ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
89 |
|
PMT = 0; //ELENA |
90 |
|
ToFTrk = 0; //ELENA |
91 |
|
// |
92 |
|
this->Clear(); |
93 |
// |
// |
|
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
|
94 |
}; |
}; |
95 |
|
|
96 |
|
void ToFLevel2::Set(){//ELENA |
97 |
|
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
98 |
|
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
99 |
|
}//ELENA |
100 |
|
|
101 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Clear(){ |
102 |
// |
// |
103 |
ToFTrk->Clear(); |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
104 |
PMT->Clear(); |
if(PMT)PMT->Delete(); //ELENA |
105 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
106 |
|
unpackError = 0; |
107 |
// |
// |
108 |
}; |
}; |
109 |
|
|
110 |
|
void ToFLevel2::Delete(){ //ELENA |
111 |
|
// |
112 |
|
if(ToFTrk){ |
113 |
|
ToFTrk->Delete(); //ELENA |
114 |
|
delete ToFTrk; //ELENA |
115 |
|
} |
116 |
|
if(PMT){ |
117 |
|
PMT->Delete(); //ELENA |
118 |
|
delete PMT; //ELENA |
119 |
|
} //ELENA |
120 |
|
// |
121 |
|
}; //ELENA |
122 |
|
|
123 |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
124 |
// |
// |
125 |
if(itrk >= ntrk()){ |
if(itrk >= ntrk()){ |
128 |
return(NULL); |
return(NULL); |
129 |
} |
} |
130 |
// |
// |
131 |
|
if(!ToFTrk)return 0; //ELENA |
132 |
TClonesArray &t = *(ToFTrk); |
TClonesArray &t = *(ToFTrk); |
133 |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
134 |
return toftrack; |
return toftrack; |
142 |
return(NULL); |
return(NULL); |
143 |
} |
} |
144 |
// |
// |
145 |
|
if(!PMT)return 0; //ELENA |
146 |
TClonesArray &t = *(PMT); |
TClonesArray &t = *(PMT); |
147 |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
148 |
return tofpmt; |
return tofpmt; |
173 |
else return -1; |
else return -1; |
174 |
}; |
}; |
175 |
/** |
/** |
176 |
* 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 |
177 |
|
* from both PMTs |
178 |
* @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). |
179 |
* @param paddle_id Paddle ID. |
* @param paddle_id Paddle ID. |
180 |
* @return 1 if the paddle was hit. |
* @return 1 if the paddle was hit. |
206 |
}; |
}; |
207 |
|
|
208 |
|
|
209 |
|
/** |
210 |
|
* Method to get the mean dEdx from a given ToF plane |
211 |
|
* @param notrack Track Number |
212 |
|
* @param plane Plane index (0,1,2,3,4,5). |
213 |
|
*/ |
214 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
215 |
|
|
216 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
217 |
Int_t ip = 0; |
Int_t ip = 0; |
218 |
Int_t pmt_id = 0; |
Int_t pmt_id = 0; |
224 |
}; |
}; |
225 |
// |
// |
226 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
227 |
|
if(!trk) return 0; //ELENA |
228 |
// |
// |
229 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
230 |
// |
// |
232 |
// |
// |
233 |
pl = GetPlaneIndex(pmt_id); |
pl = GetPlaneIndex(pmt_id); |
234 |
// |
// |
235 |
if ( pl == ip ) dedx += (trk->dedx).At(i); |
if ( pl == ip ) dedx += (trk->dedx).At(i); |
236 |
// |
// |
237 |
}; |
}; |
238 |
// |
// |
240 |
}; |
}; |
241 |
|
|
242 |
|
|
243 |
|
/** |
244 |
|
* Method to fill the ADC_C (dEdx) and TDC matrix (4,12) |
245 |
|
* @param notrack Track Number |
246 |
|
* @param adc ADC_C matrix with dEdx values |
247 |
|
* @param tdc TDC matrix |
248 |
|
*/ |
249 |
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]){ |
250 |
// |
// |
251 |
for (Int_t aa=0; aa<4;aa++){ |
for (Int_t aa=0; aa<4;aa++){ |
260 |
Int_t kk = 0; |
Int_t kk = 0; |
261 |
// |
// |
262 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
263 |
|
if(!trk)return; //ELENA |
264 |
// |
// |
265 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
266 |
// |
// |
274 |
for (Int_t i=0; i<npmt(); i++){ |
for (Int_t i=0; i<npmt(); i++){ |
275 |
// |
// |
276 |
ToFPMT *pmt = GetToFPMT(i); |
ToFPMT *pmt = GetToFPMT(i); |
277 |
|
if(!pmt)break; //ELENA |
278 |
// |
// |
279 |
GetPMTIndex(pmt->pmt_id,hh,kk); |
GetPMTIndex(pmt->pmt_id,hh,kk); |
280 |
// |
// |
286 |
}; |
}; |
287 |
|
|
288 |
|
|
289 |
|
/** |
290 |
|
* Method to get the plane index (0 - 5) for the PMT_ID as input |
291 |
|
* @param pmt_id PMT_ID (0 - 47) |
292 |
|
*/ |
293 |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
294 |
TString pmtname = GetPMTName(pmt_id); |
TString pmtname = GetPMTName(pmt_id); |
295 |
pmtname.Resize(3); |
pmtname.Resize(3); |
302 |
return(-1); |
return(-1); |
303 |
}; |
}; |
304 |
|
|
305 |
|
/** |
306 |
|
* Method to get the PMT_ID if the index (4,12) is given |
307 |
|
* @param hh Channel |
308 |
|
* @param kk HalfBoard |
309 |
|
*/ |
310 |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
311 |
// |
// |
312 |
short tof[4][24] = { |
short tof[4][24] = { |
335 |
return ind; |
return ind; |
336 |
}; |
}; |
337 |
|
|
338 |
|
/** |
339 |
|
* Method to get the PMT name (like "S11_1A") if the PMT_ID is given |
340 |
|
* @param ind PMT_ID (0 - 47) |
341 |
|
*/ |
342 |
TString ToFLevel2::GetPMTName(Int_t ind){ |
TString ToFLevel2::GetPMTName(Int_t ind){ |
343 |
|
|
344 |
TString pmtname = " "; |
TString pmtname = " "; |
359 |
return pmtname; |
return pmtname; |
360 |
}; |
}; |
361 |
|
|
362 |
|
/** |
363 |
|
* Method to get the PMT index if the PMT ID is given |
364 |
|
* @param ind PMT_ID (0 - 47) |
365 |
|
* @param hb HalfBoard |
366 |
|
* @param ch Channel |
367 |
|
*/ |
368 |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
369 |
// |
// |
370 |
short tof[4][24] = { |
short tof[4][24] = { |
399 |
for(Int_t i=0;i<6;i++) |
for(Int_t i=0;i<6;i++) |
400 |
l2->tof_j_flag[i]=tof_j_flag[i]; |
l2->tof_j_flag[i]=tof_j_flag[i]; |
401 |
|
|
402 |
l2->ntoftrk = ToFTrk->GetEntries(); |
if(ToFTrk){ //ELENA |
403 |
for(Int_t j=0;j<l2->ntoftrk;j++){ |
l2->ntoftrk = ToFTrk->GetEntries(); |
404 |
l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno; |
for(Int_t j=0;j<l2->ntoftrk;j++){ |
405 |
l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc; |
l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno; |
406 |
for(Int_t i=0;i<l2->npmttdc[j];i++) |
l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc; |
407 |
l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i); |
for(Int_t i=0;i<l2->npmttdc[j];i++){ |
408 |
for(Int_t i=0;i<13;i++) |
l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i); |
409 |
l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i]; |
l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006 |
410 |
|
} |
411 |
l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc; |
for(Int_t i=0;i<13;i++) |
412 |
for(Int_t i=0;i<l2->npmtadc[j];i++){ |
l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i]; |
413 |
l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i); |
|
414 |
l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i); |
l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc; |
415 |
} |
for(Int_t i=0;i<l2->npmtadc[j];i++){ |
416 |
for(Int_t i=0;i<3;i++){ |
l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i); |
417 |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006 |
418 |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i); |
419 |
} |
} |
420 |
} |
for(Int_t i=0;i<3;i++){ |
421 |
|
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
422 |
|
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
423 |
|
} |
424 |
|
} |
425 |
|
} //ELENA |
426 |
|
|
427 |
l2->npmt = PMT->GetEntries(); |
if(PMT){ //ELENA |
428 |
for(Int_t j=0;j<l2->npmt;j++){ |
l2->npmt = PMT->GetEntries(); |
429 |
l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id; |
for(Int_t j=0;j<l2->npmt;j++){ |
430 |
l2->adc[j] =((ToFPMT*)PMT->At(j))->adc; |
l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id; |
431 |
l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw; |
l2->adc[j] =((ToFPMT*)PMT->At(j))->adc; |
432 |
} |
l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw; |
433 |
|
} |
434 |
|
} //ELENA |
435 |
} |
} |