57 |
TString OUTF; |
TString OUTF; |
58 |
TString LIST; |
TString LIST; |
59 |
TString OPTIONS; |
TString OPTIONS; |
60 |
|
TString CALIBF; |
61 |
|
|
62 |
PamLevel2 *pam_event = NULL; |
PamLevel2 *pam_event = NULL; |
63 |
|
|
73 |
// read input file/list |
// read input file/list |
74 |
// -------------------- |
// -------------------- |
75 |
pam_event = new PamLevel2(ddir,list,options); |
pam_event = new PamLevel2(ddir,list,options); |
76 |
|
pam_event->SetSELLI(2); |
77 |
TTree::SetMaxTreeSize(1000*Long64_t(2000000000)); |
TTree::SetMaxTreeSize(1000*Long64_t(2000000000)); |
78 |
// |
// |
79 |
TString outfile_t =0; |
TString outfile_t = ""; |
80 |
outfile_t = OUTF; |
outfile_t = OUTF; |
81 |
outfile_t.Append("b.root"); |
outfile_t.Append(".root"); |
82 |
TFile *outft = (TFile*)gROOT->FindObject(outfile_t); |
TFile *outft = (TFile*)gROOT->FindObject(outfile_t); |
83 |
if (outft) outft->Close(); |
if (outft) outft->Close(); |
84 |
outft = new TFile(outfile_t,"RECREATE"); |
outft = new TFile(outfile_t,"RECREATE"); |
90 |
// |
// |
91 |
outft->cd(); |
outft->cd(); |
92 |
ToFLevel2 *tof = new ToFLevel2(); |
ToFLevel2 *tof = new ToFLevel2(); |
93 |
|
ToFdEdx *tofdedx = new ToFdEdx(); |
94 |
TTree *toft = new TTree("ToF","PAMELA Level2 ToF data"); |
TTree *toft = new TTree("ToF","PAMELA Level2 ToF data"); |
95 |
toft->SetAutoSave(900000000000000LL); |
toft->SetAutoSave(900000000000000LL); |
96 |
tof->Set();//ELENA **TEMPORANEO?** |
tof->Set();//ELENA **TEMPORANEO?** |
100 |
// |
// |
101 |
Int_t ntrkentry = 0; |
Int_t ntrkentry = 0; |
102 |
Int_t npmtentry = 0; |
Int_t npmtentry = 0; |
103 |
|
Float_t xleft=0; |
104 |
|
Float_t xright=0; |
105 |
|
Float_t yleft=0; |
106 |
|
Float_t yright=0; |
107 |
// |
// |
108 |
ULong64_t nevents = pam_event->GetEntries(); |
ULong64_t nevents = pam_event->GetEntries(); |
109 |
printf("\n\n Running on %llu events \n\n",nevents); |
printf("\n\n Running on %llu events \n\n",nevents); |
152 |
for(ULong64_t iev=0; iev<nevents; iev++){ |
for(ULong64_t iev=0; iev<nevents; iev++){ |
153 |
|
|
154 |
|
|
155 |
//================================================================== |
//================================================================== |
156 |
|
|
157 |
|
|
158 |
// for(ULong64_t iev=0; iev<50; iev++){ |
// for(ULong64_t iev=0; iev<50; iev++){ |
173 |
// printf(" rhtime %u myrun %i mysrun %i \n",pam_event->GetRunInfo()->RUNHEADER_TIME,(int)myrun,(int)mysrun); |
// printf(" rhtime %u myrun %i mysrun %i \n",pam_event->GetRunInfo()->RUNHEADER_TIME,(int)myrun,(int)mysrun); |
174 |
mysrun = myrun; |
mysrun = myrun; |
175 |
// |
// |
176 |
Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,204,dbc); // parameters stored in DB in GL_PRAM table |
181 |
|
if ( error<0 ) { |
182 |
|
return(1); |
183 |
|
}; |
184 |
|
// |
185 |
|
tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data()); |
186 |
|
|
187 |
|
// |
188 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table |
189 |
|
if ( error<0 ) { |
190 |
|
return(1); |
191 |
|
}; |
192 |
|
// |
193 |
|
tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data()); |
194 |
|
|
195 |
|
// |
196 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table |
197 |
|
if ( error<0 ) { |
198 |
|
return(1); |
199 |
|
}; |
200 |
|
// |
201 |
|
tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data()); |
202 |
|
|
203 |
|
// |
204 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table |
205 |
|
if ( error<0 ) { |
206 |
|
return(1); |
207 |
|
}; |
208 |
|
// |
209 |
|
tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data()); |
210 |
|
|
211 |
|
// |
212 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table |
213 |
|
if ( error<0 ) { |
214 |
|
return(1); |
215 |
|
}; |
216 |
|
// |
217 |
|
tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data()); |
218 |
|
|
219 |
|
|
220 |
|
tofdedx->CheckConnectors(pam_event->GetRunInfo()->RUNHEADER_TIME,glparam,dbc); |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
225 |
if ( error<0 ) { |
if ( error<0 ) { |
226 |
return(1); |
return(1); |
227 |
}; |
}; |
237 |
// |
// |
238 |
|
|
239 |
|
|
240 |
//================================================================ |
//================================================================ |
241 |
//================================================================== |
//================================================================== |
242 |
//--- Define absolute time |
//--- Define absolute time |
243 |
Float_t tabs=pam_event->GetOrbitalInfo()->absTime; |
UInt_t tabs=pam_event->GetOrbitalInfo()->absTime; |
244 |
|
|
245 |
//================================================================== |
if ( !(iev%1000) ) printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev); |
246 |
Float_t dedx_corr_m[2000][48],dedx_corr[48]; |
|
247 |
Double_t mtime[2000],t1,t2,tm; |
//================================================================== |
248 |
Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
Float_t dedx_corr_m[2000][48],dedx_corr[48]; |
249 |
Float_t xmean1,xwidth1; |
Double_t mtime[2000],t1,t2,tm; |
250 |
|
Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
251 |
Int_t ical,ii,j,jj; |
Float_t xmean1,xwidth1; |
252 |
|
|
253 |
if (iev==0) { |
Int_t ical,ii,j,jj; |
254 |
|
|
255 |
ical=0; // counter set to zero if first-time reading |
if (iev==0) { |
256 |
|
|
257 |
//----------------------------------------------------------- |
ical=0; // counter set to zero if first-time reading |
258 |
// Here I read the dEdx_korr parameters |
|
259 |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
260 |
|
// Here I read the dEdx_korr parameters |
261 |
jj=0; |
//----------------------------------------------------------- |
262 |
|
|
263 |
ifstream fin("adcmonitor.7th.100k.cut.dat"); |
jj=0; |
264 |
|
printf(" READING NEW CALIBRATION FILE: %s \n",CALIBF.Data()); |
265 |
while (! fin.eof()) { |
|
266 |
fin>>t1>>tm>>t2; |
ifstream fin(CALIBF.Data()); |
267 |
//cout<<jj<<" "<<tm<<endl; |
|
268 |
cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
while (! fin.eof()) { |
269 |
mtime[jj]=tm; |
fin>>t1>>tm>>t2; |
270 |
for (ii=0; ii<48;ii++) { |
// cout<<jj<<" "<<tm<<endl; |
271 |
fin>>j>>xmean1>>xwidth1; |
cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
272 |
dedx_corr_m[jj][ii]=xmean1; |
mtime[jj]=tm; |
273 |
} |
for (ii=0; ii<48;ii++) { |
274 |
jj=jj+1; |
fin>>j>>xmean1>>xwidth1; |
275 |
} |
dedx_corr_m[jj][ii]=xmean1; |
276 |
|
} |
277 |
fin.close(); |
jj=jj+1; |
278 |
|
// printf(" kk %i \n",jj); |
279 |
|
} |
280 |
while (tabs > mtime[ical]) { |
// printf(" 1ical %i \n",ical); |
281 |
ical = ical+1; |
|
282 |
} |
fin.close(); |
283 |
ical = ical-1; |
|
284 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
|
285 |
} // if iev==0... |
while (tabs<mtime[ical] || tabs > mtime[ical+1]) { |
286 |
|
// printf(" ical %i \n",ical); |
287 |
//================================================================== |
ical = ical+1; |
288 |
//== End of first time reading & filling the array |
} |
289 |
//================================================================== |
// ical = ical-1; |
290 |
|
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
291 |
//================================================================== |
} // if iev==0... |
292 |
//== if time is outside time limits: |
|
293 |
//================================================================== |
//================================================================== |
294 |
|
//== End of first time reading & filling the array |
295 |
if (tabs<mtime[ical] || tabs>mtime[ical+1]) { |
//================================================================== |
296 |
cout<<"Checking Time Limits!"<<endl; |
|
297 |
ical=0; |
//================================================================== |
298 |
while (tabs > mtime[ical]) { |
//== if time is outside time limits: |
299 |
ical = ical+1; |
//================================================================== |
300 |
} |
|
301 |
ical = ical-1; |
if (tabs<mtime[ical] || tabs>mtime[ical+1]) { |
302 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
cout<<"Checking Time Limits!"<<endl; |
303 |
}; |
ical=0; |
304 |
|
while (tabs > mtime[ical+1] || tabs<mtime[ical]) { |
305 |
//================================================================== |
ical = ical+1; |
306 |
//== interpolate betwen time limits |
} |
307 |
//================================================================== |
// ical = ical-1; |
308 |
|
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
309 |
thelp1 = mtime[ical]; |
}; |
|
thelp2 = mtime[ical+1]; |
|
|
|
|
|
for (ii=0; ii<48;ii++) { |
|
|
yhelp1 = dedx_corr_m[ical][ii]; |
|
|
yhelp2 = dedx_corr_m[ical+1][ii]; |
|
|
slope = (yhelp2-yhelp1)/(thelp2-thelp1); |
|
|
inter = yhelp1 - slope*thelp1; |
|
|
dedx_corr[ii] = slope*tabs + inter; |
|
|
// if (ii==0) cout<<thelp1<<" "<<thelp2<<" "<<tabs<<" "<<yhelp1<<" "<<yhelp2<<" "<<dedx_corr[0]<<endl; |
|
|
} |
|
310 |
|
|
311 |
//================================================================ |
// printf(" 2ical %i \n",ical); |
312 |
//================================================================ |
//================================================================== |
313 |
|
//== interpolate betwen time limits |
314 |
|
//================================================================== |
315 |
|
|
316 |
|
thelp1 = mtime[ical]; |
317 |
|
thelp2 = mtime[ical+1]; |
318 |
|
|
319 |
|
for (ii=0; ii<48;ii++) { |
320 |
|
yhelp1 = fabs(dedx_corr_m[ical][ii]); |
321 |
|
// yhelp1 = 6.; |
322 |
|
if ( yhelp1 < 0.1 ) yhelp1 = 4.; |
323 |
|
yhelp2 = fabs(dedx_corr_m[ical+1][ii]); |
324 |
|
// yhelp2 = 6.; |
325 |
|
if ( yhelp2 < 0.1 ) yhelp2 = 4.; |
326 |
|
slope = (yhelp2-yhelp1)/(thelp2-thelp1); |
327 |
|
inter = yhelp1 - slope*thelp1; |
328 |
|
dedx_corr[ii] = slope*tabs + inter; |
329 |
|
// if (ii==0) cout<<thelp1<<" "<<thelp2<<" "<<tabs<<" "<<yhelp1<<" "<<yhelp2<<" "<<dedx_corr[0]<<endl; |
330 |
|
} |
331 |
|
|
332 |
|
//================================================================ |
333 |
|
//================================================================ |
334 |
|
// printf("cpippo \n"); |
335 |
|
|
336 |
// process tof data |
// process tof data |
337 |
// |
// |
338 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
339 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
340 |
adc[kk][hh] = 4095; |
adc[kk][hh] = 4095; |
341 |
tdc[kk][hh] = 4095; |
tdc[kk][hh] = 4095; |
342 |
tdcc[kk][hh] = 4095.; |
tdcc[kk][hh] = 4095.; |
343 |
tofinput_.adc[hh][kk] = 4095; |
tofinput_.adc[hh][kk] = 4095; |
344 |
tofinput_.tdc[hh][kk] = 4095; |
tofinput_.tdc[hh][kk] = 4095; |
345 |
}; |
}; |
346 |
}; |
}; |
347 |
// memset(adc, 0, 12*4*sizeof(Int_t)); |
// memset(adc, 0, 12*4*sizeof(Int_t)); |
348 |
// memset(tdc, 0, 12*4*sizeof(Int_t)); |
// memset(tdc, 0, 12*4*sizeof(Int_t)); |
349 |
Int_t gg = 0; |
Int_t gg = 0; |
350 |
Int_t hh = 0; |
Int_t hh = 0; |
351 |
Int_t adcf[48]; |
Int_t adcf[48]; |
355 |
for (Int_t pm=0; pm < tofl2->ntrk() ; pm++){ |
for (Int_t pm=0; pm < tofl2->ntrk() ; pm++){ |
356 |
ToFTrkVar *ttf = tofl2->GetToFTrkVar(pm); |
ToFTrkVar *ttf = tofl2->GetToFTrkVar(pm); |
357 |
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
358 |
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
359 |
}; |
}; |
360 |
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
361 |
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
362 |
}; |
}; |
363 |
}; |
}; |
364 |
// |
// |
366 |
ToFPMT *pmt = tofl2->GetToFPMT(pm); |
ToFPMT *pmt = tofl2->GetToFPMT(pm); |
367 |
tofl2->GetPMTIndex(pmt->pmt_id, gg, hh); |
tofl2->GetPMTIndex(pmt->pmt_id, gg, hh); |
368 |
if ( adcf[pmt->pmt_id] == 0 ){ |
if ( adcf[pmt->pmt_id] == 0 ){ |
369 |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
370 |
adc[hh][gg] = (int)pmt->adc; |
adc[hh][gg] = (int)pmt->adc; |
371 |
}; |
}; |
372 |
if ( tdcf[pmt->pmt_id] == 0 ){ |
if ( tdcf[pmt->pmt_id] == 0 ){ |
373 |
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
374 |
tdc[hh][gg] = (int)pmt->tdc; |
tdc[hh][gg] = (int)pmt->tdc; |
375 |
}; |
}; |
376 |
tdcc[hh][gg] = (float)pmt->tdc_tw; |
tdcc[hh][gg] = (float)pmt->tdc_tw; |
377 |
// Int_t pppid = tof->GetPMTid(hh,gg); |
// Int_t pppid = tof->GetPMTid(hh,gg); |
378 |
// 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); |
// 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); |
379 |
}; |
}; |
380 |
|
for (Int_t hh=0; hh<12;hh++){ |
381 |
|
for (Int_t kk=0; kk<4;kk++){ |
382 |
// for (Int_t pm=0; pm <48 ; pm++){ |
tofdedx->Init(kk,hh,adc[kk][hh]); |
383 |
// tof->GetPMTIndex(pm, gg, hh); |
}; |
384 |
// tofinput_.tdc[hh][gg] = (int)500.; |
}; |
385 |
// tofinput_.adc[hh][gg] = (int)500.; |
// for (Int_t pm=0; pm <48 ; pm++){ |
386 |
// tdc[hh][gg] = (int)500.; |
// tof->GetPMTIndex(pm, gg, hh); |
387 |
// adc[hh][gg] = (int)500.; |
// tofinput_.tdc[hh][gg] = (int)500.; |
388 |
// // printf(" hh %i gg %i tdc %f adc %f \n",hh,gg,pmt->tdc,pmt->adc); |
// tofinput_.adc[hh][gg] = (int)500.; |
389 |
// }; |
// tdc[hh][gg] = (int)500.; |
390 |
|
// adc[hh][gg] = (int)500.; |
391 |
|
// // printf(" hh %i gg %i tdc %f adc %f \n",hh,gg,pmt->tdc,pmt->adc); |
392 |
|
// }; |
393 |
// |
// |
394 |
for (Int_t hh=0; hh<5;hh++){ |
for (Int_t hh=0; hh<5;hh++){ |
395 |
tofinput_.patterntrig[hh]=pam_event->GetTrigLevel2()->patterntrig[hh]; |
tofinput_.patterntrig[hh]=pam_event->GetTrigLevel2()->patterntrig[hh]; |
437 |
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
438 |
} |
} |
439 |
// |
// |
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
|
|
// t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO |
|
|
pmt_id = tof->GetPMTid(kk,hh); |
|
|
t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
440 |
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
441 |
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
442 |
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
443 |
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
444 |
// |
// { |
445 |
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
// Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; |
446 |
ntrkentry++; |
// Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; |
447 |
t_tof->Clear(); |
// tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
448 |
// |
// } |
449 |
// |
// t_tof->npmtadc = 0; |
450 |
// |
|
451 |
t_pmt->Clear(); |
|
452 |
// |
// for (Int_t hh=0; hh<12;hh++){ |
453 |
|
// for (Int_t kk=0; kk<4;kk++){ |
454 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
455 |
|
// if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. ){ |
456 |
|
// t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc); |
457 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
458 |
|
// t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
459 |
|
// t_tof->npmtadc++; |
460 |
|
// }; |
461 |
|
// }; |
462 |
|
// }; |
463 |
|
{ |
464 |
|
|
465 |
|
Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.}; |
466 |
|
Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.}; |
467 |
|
|
468 |
|
if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){ |
469 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
470 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
471 |
|
}else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){ |
472 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
473 |
|
tof->GetPaddleGeometry(0,(Int_t)log2(tof->tof_j_flag[0]),xleft, xright, yleft, yright); |
474 |
|
xtof_temp[1]=xleft+2.55; |
475 |
|
}else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){ |
476 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
477 |
|
tof->GetPaddleGeometry(1,(Int_t)log2(tof->tof_j_flag[1]),xleft, xright, yleft, yright); |
478 |
|
ytof_temp[0]=yleft+2.75; |
479 |
|
} |
480 |
|
|
481 |
|
if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){ |
482 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
483 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
484 |
|
}else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){ |
485 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
486 |
|
tof->GetPaddleGeometry(3,(Int_t)log2(tof->tof_j_flag[3]),xleft, xright, yleft, yright); |
487 |
|
xtof_temp[2]=xleft+4.5; |
488 |
|
}else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){ |
489 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
490 |
|
tof->GetPaddleGeometry(2,(Int_t)log2(tof->tof_j_flag[2]),xleft, xright, yleft, yright); |
491 |
|
ytof_temp[3]=yleft+3.75; |
492 |
|
} |
493 |
|
|
494 |
|
if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){ |
495 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
496 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
497 |
|
}else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){ |
498 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
499 |
|
tof->GetPaddleGeometry(4,(Int_t)log2(tof->tof_j_flag[4]),xleft, xright, yleft, yright); |
500 |
|
xtof_temp[5]=xleft+3; |
501 |
|
}else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){ |
502 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
503 |
|
tof->GetPaddleGeometry(5,(Int_t)log2(tof->tof_j_flag[5]),xleft, xright, yleft, yright); |
504 |
|
ytof_temp[4]=yleft+2.5; |
505 |
|
} |
506 |
|
// Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; |
507 |
|
// Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; |
508 |
|
// tofdedx->Process(atime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
509 |
|
tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
510 |
|
t_tof->npmtadc = 0; |
511 |
|
for (Int_t hh=0; hh<12;hh++){ |
512 |
|
for (Int_t kk=0; kk<4;kk++){ |
513 |
|
pmt_id = tof->GetPMTid(kk,hh); |
514 |
|
Int_t Iplane=-1; |
515 |
|
Int_t Ipaddle=-1; |
516 |
|
// Int_t IpaddleT=-1; |
517 |
|
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
518 |
|
tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); |
519 |
|
if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. &&((xtof_temp[Iplane]>=xleft&&xtof_temp[Iplane]<=xright) || (ytof_temp[Iplane]>=yleft&&ytof_temp[Iplane]<=yright)) ){ //attenzione:qui va inserito un controllo sulla traccia tof o sulle variabili di posizione !!!! |
520 |
|
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
521 |
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
522 |
|
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
523 |
|
t_tof->npmtadc++; |
524 |
|
}; |
525 |
|
}; |
526 |
|
}; |
527 |
|
}; |
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
// for (Int_t hh=0; hh<12;hh++){ |
539 |
|
// for (Int_t kk=0; kk<4;kk++){ |
540 |
|
// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
541 |
|
// // t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO |
542 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
543 |
|
// t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
544 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
545 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
546 |
|
// t_tof->npmtadc++; |
547 |
|
// }; |
548 |
|
// }; |
549 |
|
// }; |
550 |
|
// |
551 |
|
|
552 |
|
// |
553 |
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
554 |
|
ntrkentry++; |
555 |
|
t_tof->Clear(); |
556 |
|
// |
557 |
|
// |
558 |
|
// |
559 |
|
t_pmt->Clear(); |
560 |
|
// |
561 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
562 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
563 |
// new WM |
// new WM |
564 |
// if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
// if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
565 |
if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
566 |
// |
// |
567 |
t_pmt->pmt_id = tof->GetPMTid(kk,hh); |
t_pmt->pmt_id = tof->GetPMTid(kk,hh); |
594 |
for (Int_t e = 0; e < 5 ; e++){ |
for (Int_t e = 0; e < 5 ; e++){ |
595 |
tofinput_.al_pp[e] = ptt->al[e]; |
tofinput_.al_pp[e] = ptt->al[e]; |
596 |
}; |
}; |
597 |
|
|
598 |
|
// new input for 9th reduction: tracker dEdx |
599 |
|
tofinput_.trkmip = ptt->GetDEDX(); |
600 |
|
|
601 |
// |
// |
602 |
// Get tracker related variables for this track |
// Get tracker related variables for this track |
603 |
// |
// |
604 |
toftrk(); |
toftrk(); |
605 |
// toftrk(thelp); |
// toftrk(thelp); |
606 |
// |
// |
607 |
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
608 |
// |
// |
621 |
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
622 |
}; |
}; |
623 |
// |
// |
624 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
625 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
626 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
627 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
628 |
|
// |
629 |
|
tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof); |
630 |
t_tof->npmtadc = 0; |
t_tof->npmtadc = 0; |
631 |
|
|
632 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
633 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
634 |
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
pmt_id = tof->GetPMTid(kk,hh); |
635 |
// t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO |
Int_t Iplane=-1; |
636 |
pmt_id = tof->GetPMTid(kk,hh); |
Int_t Ipaddle=-1; |
637 |
t_tof->dedx.AddAt((tofoutput_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
Int_t IpaddleT=-1; |
638 |
|
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
639 |
|
IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); |
640 |
|
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){ |
641 |
|
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
642 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
643 |
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
644 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
645 |
}; |
}; |
646 |
|
|
647 |
}; |
}; |
648 |
}; |
}; |
649 |
|
|
650 |
|
|
651 |
|
// for (Int_t hh=0; hh<12;hh++){ |
652 |
|
// for (Int_t kk=0; kk<4;kk++){ |
653 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
654 |
|
// if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. ){ |
655 |
|
// t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc); |
656 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
657 |
|
// t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
658 |
|
// printf(" nt %i npmtadc %i dedx %f dedx corr %f\n",nt,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),dedx_corr[pmt_id]); |
659 |
|
// t_tof->npmtadc++; |
660 |
|
// }; |
661 |
|
|
662 |
|
// }; |
663 |
|
// }; |
664 |
|
// t_tof->npmtadc = 0; |
665 |
|
// for (Int_t hh=0; hh<12;hh++){ |
666 |
|
// for (Int_t kk=0; kk<4;kk++){ |
667 |
|
// if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
668 |
|
// // t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO |
669 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
670 |
|
// t_tof->dedx.AddAt((tofoutput_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
671 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
672 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
673 |
|
// t_tof->npmtadc++; |
674 |
|
// }; |
675 |
|
// }; |
676 |
|
// }; |
677 |
// |
// |
678 |
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
679 |
// |
// |
680 |
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
681 |
// |
// |
730 |
|
|
731 |
void usage(){ |
void usage(){ |
732 |
|
|
733 |
cout << "------------------------------------------------------------"<<endl; |
cout << "------------------------------------------------------------"<<endl; |
734 |
cout << "Loop over events (on one or more Level2-files), applying some selection cuts (defined in My-Selection.cpp), \n"; |
cout << "Loop over events (on one or more Level2-files), applying some selection cuts (defined in My-Selection.cpp), \n"; |
735 |
cout << "creating output histograms (defined in My-Histos.cpp) and/or trees with selected events. \n \n "; |
cout << "creating output histograms (defined in My-Histos.cpp) and/or trees with selected events. \n \n "; |
736 |
cout << "USAGE:"<<endl; |
cout << "USAGE:"<<endl; |
737 |
cout << "-processDir DIR - Level2 data directory \n"; |
cout << "-processDir DIR - Level2 data directory \n"; |
738 |
cout << "-processList LIST - list of files (.txt) or single file (.root) to be analysed \n"; |
cout << "-processList LIST - list of files (.txt) or single file (.root) to be analysed \n"; |
739 |
cout << "-outputFile PATH - name of the output file \n"; |
cout << "-outputFile PATH - name of the output file \n"; |
740 |
cout << "-NumEvents XXX - number of events to be analysed \n"; |
cout << "-calibFile PATH+NAME - name of the calibration file \n"; |
741 |
cout << "--debug, -g - debug mode \n"; |
cout << "-NumEvents XXX - number of events to be analysed \n"; |
742 |
cout << "--help, -h - print this help \n"; |
cout << "--debug, -g - debug mode \n"; |
743 |
cout << "-options [ options ] - options: \n"; |
cout << "--help, -h - print this help \n"; |
744 |
cout << " fillHistos --> create an output file with histograms \n"; |
cout << "-options [ options ] - options: \n"; |
745 |
cout << " fillTree --> create an output file with trees storing the selected events \n "; |
cout << " fillHistos --> create an output file with histograms \n"; |
746 |
cout << " +(-)ALL --> inlcude(exclude) all trees and branches \n " ; |
cout << " fillTree --> create an output file with trees storing the selected events \n "; |
747 |
cout << " +(-)TRK1 +(-)TRK2 +(-)CAL1 +(-)CAL2 +(-)TOF +(-)TRG +(-)ND +(-)S4 +(-)ORB --> inlcude(exclude) trees and branches \n" ; |
cout << " +(-)ALL --> inlcude(exclude) all trees and branches \n " ; |
748 |
cout << "------------------------------------------------------------"<<endl; |
cout << " +(-)TRK1 +(-)TRK2 +(-)CAL1 +(-)CAL2 +(-)TOF +(-)TRG +(-)ND +(-)S4 +(-)ORB --> inlcude(exclude) trees and branches \n" ; |
749 |
|
cout << "------------------------------------------------------------"<<endl; |
750 |
} |
} |
751 |
// |
// |
752 |
int HandleInputPar(int argc, char **argv){ |
int HandleInputPar(int argc, char **argv){ |
753 |
|
|
754 |
if(argc>1){ |
if(argc>1){ |
755 |
|
|
756 |
if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") ){ |
if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") ){ |
757 |
usage(); |
usage(); |
758 |
return(1); |
return(1); |
759 |
}; |
}; |
760 |
// ----------------------- |
// ----------------------- |
761 |
// Read input parameters |
// Read input parameters |
762 |
// ----------------------- |
// ----------------------- |
763 |
DIR = gSystem->WorkingDirectory(); |
DIR = gSystem->WorkingDirectory(); |
764 |
LIST = ""; |
LIST = ""; |
765 |
OUTF = "myfile"; |
OUTF = "myfile"; |
766 |
OPTIONS = "+AUTO -TOF"; |
OPTIONS = "+AUTO -TOF"; |
767 |
|
|
768 |
for (int i = 1; i < argc; i++){ |
for (int i = 1; i < argc; i++){ |
769 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
770 |
if (!strcmp(argv[i], "-processDir")){ |
if (!strcmp(argv[i], "-processDir")){ |
771 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
772 |
DIR = argv[i]; |
DIR = argv[i]; |
773 |
cout << "processDir "<<DIR<<endl; |
cout << "processDir "<<DIR<<endl; |
774 |
continue; |
continue; |
775 |
} |
} |
776 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
777 |
else if (!strcmp(argv[i], "-processList")){ |
else if (!strcmp(argv[i], "-processList")){ |
778 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
779 |
LIST = argv[i]; |
LIST = argv[i]; |
780 |
cout << "processList "<<LIST<<endl; |
cout << "processList "<<LIST<<endl; |
781 |
continue; |
continue; |
782 |
} |
} |
783 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
784 |
else if (!strcmp(argv[i], "-outputFile")){ |
else if (!strcmp(argv[i], "-outputFile")){ |
785 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
786 |
OUTF = argv[i]; |
OUTF = argv[i]; |
787 |
cout << "outputFile "<<OUTF<<endl; |
cout << "outputFile "<<OUTF<<endl; |
788 |
continue; |
continue; |
789 |
} |
} |
790 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
791 |
else if (!strcmp(argv[i], "-options")){ |
// -----------------------------------------------------// |
792 |
if (++i >= argc) throw -1; |
else if (!strcmp(argv[i], "-calibFile")){ |
793 |
OPTIONS = argv[i]; |
if (++i >= argc) throw -1; |
794 |
if( OPTIONS.Contains("[") ){ |
CALIBF = gSystem->ExpandPathName(argv[i]); |
795 |
do{ |
cout << "calibFile "<<CALIBF<<endl; |
796 |
if (++i >= argc) throw -1; |
continue; |
797 |
OPTIONS.Append(argv[i]); |
} |
798 |
}while(!OPTIONS.Contains("]")); |
// -----------------------------------------------------// |
799 |
}else cout << "wrong option format --> ignoring " << endl; |
else if (!strcmp(argv[i], "-options")){ |
800 |
} |
if (++i >= argc) throw -1; |
801 |
else{ |
OPTIONS = argv[i]; |
802 |
cout << "Unidentified input parameter. Ignored."<< endl; |
if( OPTIONS.Contains("[") ){ |
803 |
}; |
do{ |
804 |
}; |
if (++i >= argc) throw -1; |
805 |
}else{ |
OPTIONS.Append(argv[i]); |
806 |
usage(); |
}while(!OPTIONS.Contains("]")); |
807 |
return(1); |
}else cout << "wrong option format --> ignoring " << endl; |
808 |
|
} |
809 |
|
else{ |
810 |
|
cout << "Unidentified input parameter. Ignored."<< endl; |
811 |
|
}; |
812 |
}; |
}; |
813 |
// ----------------------- |
}else{ |
814 |
// Check input parameters |
usage(); |
815 |
// ----------------------- |
return(1); |
816 |
|
}; |
817 |
|
// ----------------------- |
818 |
|
// Check input parameters |
819 |
|
// ----------------------- |
820 |
|
|
821 |
|
|
822 |
return(0); |
return(0); |
823 |
|
|
824 |
}; |
}; |
825 |
// |
// |
827 |
int main(int argc, char **argv) |
int main(int argc, char **argv) |
828 |
{ |
{ |
829 |
|
|
830 |
if( HandleInputPar(argc,argv) )return(1); |
if( HandleInputPar(argc,argv) )return(1); |
831 |
|
|
832 |
cout << "OPTIONS "<<OPTIONS<<endl; |
cout << "OPTIONS "<<OPTIONS<<endl; |
833 |
Loop(DIR,LIST,OPTIONS); |
Loop(DIR,LIST,OPTIONS); |
834 |
|
|
835 |
cout << "Back to main - end"<<endl; |
cout << "Back to main - end"<<endl; |
836 |
|
|
837 |
return 0; |
return 0; |
838 |
|
|
839 |
}; |
}; |
840 |
|
|