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?** |
148 |
for(ULong64_t iev=0; iev<nevents; iev++){ |
for(ULong64_t iev=0; iev<nevents; iev++){ |
149 |
|
|
150 |
|
|
151 |
//================================================================== |
//================================================================== |
152 |
|
|
153 |
|
|
154 |
// for(ULong64_t iev=0; iev<50; iev++){ |
// for(ULong64_t iev=0; iev<50; iev++){ |
169 |
// 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); |
170 |
mysrun = myrun; |
mysrun = myrun; |
171 |
// |
// |
172 |
Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,204,dbc); // parameters stored in DB in GL_PRAM table |
177 |
|
if ( error<0 ) { |
178 |
|
return(1); |
179 |
|
}; |
180 |
|
// |
181 |
|
tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data()); |
182 |
|
|
183 |
|
// |
184 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table |
185 |
|
if ( error<0 ) { |
186 |
|
return(1); |
187 |
|
}; |
188 |
|
// |
189 |
|
tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data()); |
190 |
|
|
191 |
|
// |
192 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table |
193 |
|
if ( error<0 ) { |
194 |
|
return(1); |
195 |
|
}; |
196 |
|
// |
197 |
|
tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data()); |
198 |
|
|
199 |
|
// |
200 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table |
201 |
|
if ( error<0 ) { |
202 |
|
return(1); |
203 |
|
}; |
204 |
|
// |
205 |
|
tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data()); |
206 |
|
|
207 |
|
// |
208 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table |
209 |
|
if ( error<0 ) { |
210 |
|
return(1); |
211 |
|
}; |
212 |
|
// |
213 |
|
tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data()); |
214 |
|
|
215 |
|
|
216 |
|
tofdedx->CheckConnectors(pam_event->GetRunInfo()->RUNHEADER_TIME,glparam,dbc); |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
221 |
if ( error<0 ) { |
if ( error<0 ) { |
222 |
return(1); |
return(1); |
223 |
}; |
}; |
233 |
// |
// |
234 |
|
|
235 |
|
|
236 |
//================================================================ |
//================================================================ |
237 |
//================================================================== |
//================================================================== |
238 |
//--- Define absolute time |
//--- Define absolute time |
239 |
Float_t tabs=pam_event->GetOrbitalInfo()->absTime; |
UInt_t tabs=pam_event->GetOrbitalInfo()->absTime; |
240 |
|
|
241 |
//================================================================== |
printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev); |
242 |
Float_t dedx_corr_m[2000][48],dedx_corr[48]; |
|
243 |
Double_t mtime[2000],t1,t2,tm; |
//================================================================== |
244 |
Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
Float_t dedx_corr_m[2000][48],dedx_corr[48]; |
245 |
Float_t xmean1,xwidth1; |
Double_t mtime[2000],t1,t2,tm; |
246 |
|
Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
247 |
Int_t ical,ii,j,jj; |
Float_t xmean1,xwidth1; |
248 |
|
|
249 |
if (iev==0) { |
Int_t ical,ii,j,jj; |
250 |
|
|
251 |
ical=0; // counter set to zero if first-time reading |
if (iev==0) { |
252 |
|
|
253 |
//----------------------------------------------------------- |
ical=0; // counter set to zero if first-time reading |
254 |
// Here I read the dEdx_korr parameters |
|
255 |
//----------------------------------------------------------- |
//----------------------------------------------------------- |
256 |
|
// Here I read the dEdx_korr parameters |
257 |
jj=0; |
//----------------------------------------------------------- |
258 |
|
|
259 |
ifstream fin("adcmonitor.7th.100k.cut.dat"); |
jj=0; |
260 |
|
|
261 |
while (! fin.eof()) { |
ifstream fin(CALIBF.Data()); |
262 |
fin>>t1>>tm>>t2; |
|
263 |
//cout<<jj<<" "<<tm<<endl; |
while (! fin.eof()) { |
264 |
cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
fin>>t1>>tm>>t2; |
265 |
mtime[jj]=tm; |
// cout<<jj<<" "<<tm<<endl; |
266 |
for (ii=0; ii<48;ii++) { |
cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
267 |
fin>>j>>xmean1>>xwidth1; |
mtime[jj]=tm; |
268 |
dedx_corr_m[jj][ii]=xmean1; |
for (ii=0; ii<48;ii++) { |
269 |
} |
fin>>j>>xmean1>>xwidth1; |
270 |
jj=jj+1; |
dedx_corr_m[jj][ii]=xmean1; |
271 |
} |
} |
272 |
|
jj=jj+1; |
273 |
fin.close(); |
// printf(" kk %i \n",jj); |
274 |
|
} |
275 |
|
// printf(" 1ical %i \n",ical); |
276 |
while (tabs > mtime[ical]) { |
|
277 |
ical = ical+1; |
fin.close(); |
278 |
} |
|
279 |
ical = ical-1; |
|
280 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
while (tabs<mtime[ical] || tabs > mtime[ical+1]) { |
281 |
} // if iev==0... |
// printf(" ical %i \n",ical); |
282 |
|
ical = ical+1; |
283 |
//================================================================== |
} |
284 |
//== End of first time reading & filling the array |
// ical = ical-1; |
285 |
//================================================================== |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
286 |
|
} // if iev==0... |
287 |
//================================================================== |
|
288 |
//== if time is outside time limits: |
//================================================================== |
289 |
//================================================================== |
//== End of first time reading & filling the array |
290 |
|
//================================================================== |
291 |
if (tabs<mtime[ical] || tabs>mtime[ical+1]) { |
|
292 |
cout<<"Checking Time Limits!"<<endl; |
//================================================================== |
293 |
ical=0; |
//== if time is outside time limits: |
294 |
while (tabs > mtime[ical]) { |
//================================================================== |
295 |
ical = ical+1; |
|
296 |
} |
if (tabs<mtime[ical] || tabs>mtime[ical+1]) { |
297 |
ical = ical-1; |
cout<<"Checking Time Limits!"<<endl; |
298 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
ical=0; |
299 |
}; |
while (tabs > mtime[ical+1] || tabs<mtime[ical]) { |
300 |
|
ical = ical+1; |
301 |
//================================================================== |
} |
302 |
//== interpolate betwen time limits |
// ical = ical-1; |
303 |
//================================================================== |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
304 |
|
}; |
|
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; |
|
|
} |
|
305 |
|
|
306 |
//================================================================ |
// printf(" 2ical %i \n",ical); |
307 |
//================================================================ |
//================================================================== |
308 |
|
//== interpolate betwen time limits |
309 |
|
//================================================================== |
310 |
|
|
311 |
|
thelp1 = mtime[ical]; |
312 |
|
thelp2 = mtime[ical+1]; |
313 |
|
|
314 |
|
for (ii=0; ii<48;ii++) { |
315 |
|
yhelp1 = dedx_corr_m[ical][ii]; |
316 |
|
// yhelp1 = 6.; |
317 |
|
if ( yhelp1 < 0.1 ) yhelp1 = 6.; |
318 |
|
yhelp2 = dedx_corr_m[ical+1][ii]; |
319 |
|
// yhelp2 = 6.; |
320 |
|
if ( yhelp2 < 0.1 ) yhelp2 = 6.; |
321 |
|
slope = (yhelp2-yhelp1)/(thelp2-thelp1); |
322 |
|
inter = yhelp1 - slope*thelp1; |
323 |
|
dedx_corr[ii] = slope*tabs + inter; |
324 |
|
// if (ii==0) cout<<thelp1<<" "<<thelp2<<" "<<tabs<<" "<<yhelp1<<" "<<yhelp2<<" "<<dedx_corr[0]<<endl; |
325 |
|
} |
326 |
|
|
327 |
|
//================================================================ |
328 |
|
//================================================================ |
329 |
|
// printf("cpippo \n"); |
330 |
|
|
331 |
// process tof data |
// process tof data |
332 |
// |
// |
333 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
334 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
335 |
adc[kk][hh] = 4095; |
adc[kk][hh] = 4095; |
336 |
tdc[kk][hh] = 4095; |
tdc[kk][hh] = 4095; |
337 |
tdcc[kk][hh] = 4095.; |
tdcc[kk][hh] = 4095.; |
338 |
tofinput_.adc[hh][kk] = 4095; |
tofinput_.adc[hh][kk] = 4095; |
339 |
tofinput_.tdc[hh][kk] = 4095; |
tofinput_.tdc[hh][kk] = 4095; |
340 |
}; |
}; |
341 |
}; |
}; |
342 |
// memset(adc, 0, 12*4*sizeof(Int_t)); |
// memset(adc, 0, 12*4*sizeof(Int_t)); |
343 |
// memset(tdc, 0, 12*4*sizeof(Int_t)); |
// memset(tdc, 0, 12*4*sizeof(Int_t)); |
344 |
Int_t gg = 0; |
Int_t gg = 0; |
345 |
Int_t hh = 0; |
Int_t hh = 0; |
346 |
Int_t adcf[48]; |
Int_t adcf[48]; |
350 |
for (Int_t pm=0; pm < tofl2->ntrk() ; pm++){ |
for (Int_t pm=0; pm < tofl2->ntrk() ; pm++){ |
351 |
ToFTrkVar *ttf = tofl2->GetToFTrkVar(pm); |
ToFTrkVar *ttf = tofl2->GetToFTrkVar(pm); |
352 |
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
353 |
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
354 |
}; |
}; |
355 |
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
356 |
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
357 |
}; |
}; |
358 |
}; |
}; |
359 |
// |
// |
361 |
ToFPMT *pmt = tofl2->GetToFPMT(pm); |
ToFPMT *pmt = tofl2->GetToFPMT(pm); |
362 |
tofl2->GetPMTIndex(pmt->pmt_id, gg, hh); |
tofl2->GetPMTIndex(pmt->pmt_id, gg, hh); |
363 |
if ( adcf[pmt->pmt_id] == 0 ){ |
if ( adcf[pmt->pmt_id] == 0 ){ |
364 |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
365 |
adc[hh][gg] = (int)pmt->adc; |
adc[hh][gg] = (int)pmt->adc; |
366 |
}; |
}; |
367 |
if ( tdcf[pmt->pmt_id] == 0 ){ |
if ( tdcf[pmt->pmt_id] == 0 ){ |
368 |
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
369 |
tdc[hh][gg] = (int)pmt->tdc; |
tdc[hh][gg] = (int)pmt->tdc; |
370 |
}; |
}; |
371 |
tdcc[hh][gg] = (float)pmt->tdc_tw; |
tdcc[hh][gg] = (float)pmt->tdc_tw; |
372 |
// Int_t pppid = tof->GetPMTid(hh,gg); |
// Int_t pppid = tof->GetPMTid(hh,gg); |
373 |
// 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); |
374 |
}; |
}; |
375 |
|
for (Int_t hh=0; hh<12;hh++){ |
376 |
|
for (Int_t kk=0; kk<4;kk++){ |
377 |
// for (Int_t pm=0; pm <48 ; pm++){ |
tofdedx->Init(kk,hh,adc[kk][hh]); |
378 |
// tof->GetPMTIndex(pm, gg, hh); |
}; |
379 |
// tofinput_.tdc[hh][gg] = (int)500.; |
}; |
380 |
// tofinput_.adc[hh][gg] = (int)500.; |
// for (Int_t pm=0; pm <48 ; pm++){ |
381 |
// tdc[hh][gg] = (int)500.; |
// tof->GetPMTIndex(pm, gg, hh); |
382 |
// adc[hh][gg] = (int)500.; |
// tofinput_.tdc[hh][gg] = (int)500.; |
383 |
// // printf(" hh %i gg %i tdc %f adc %f \n",hh,gg,pmt->tdc,pmt->adc); |
// tofinput_.adc[hh][gg] = (int)500.; |
384 |
// }; |
// tdc[hh][gg] = (int)500.; |
385 |
|
// adc[hh][gg] = (int)500.; |
386 |
|
// // printf(" hh %i gg %i tdc %f adc %f \n",hh,gg,pmt->tdc,pmt->adc); |
387 |
|
// }; |
388 |
// |
// |
389 |
for (Int_t hh=0; hh<5;hh++){ |
for (Int_t hh=0; hh<5;hh++){ |
390 |
tofinput_.patterntrig[hh]=pam_event->GetTrigLevel2()->patterntrig[hh]; |
tofinput_.patterntrig[hh]=pam_event->GetTrigLevel2()->patterntrig[hh]; |
432 |
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
433 |
} |
} |
434 |
// |
// |
435 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
436 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
437 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
438 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
439 |
|
{ |
440 |
|
Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; |
441 |
|
Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; |
442 |
|
tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
443 |
|
} |
444 |
t_tof->npmtadc = 0; |
t_tof->npmtadc = 0; |
445 |
|
|
446 |
|
|
447 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
448 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
449 |
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
pmt_id = tof->GetPMTid(kk,hh); |
450 |
// t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO |
if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. ){ |
451 |
pmt_id = tof->GetPMTid(kk,hh); |
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc); |
|
t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
|
452 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
453 |
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
454 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
455 |
}; |
}; |
456 |
}; |
}; |
457 |
}; |
}; |
458 |
|
// for (Int_t hh=0; hh<12;hh++){ |
459 |
|
// for (Int_t kk=0; kk<4;kk++){ |
460 |
|
// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
461 |
|
// // t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO |
462 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
463 |
|
// t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
464 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
465 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
466 |
|
// t_tof->npmtadc++; |
467 |
|
// }; |
468 |
|
// }; |
469 |
|
// }; |
470 |
// |
// |
471 |
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)); |
|
472 |
// |
// |
473 |
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
474 |
ntrkentry++; |
ntrkentry++; |
480 |
// |
// |
481 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
482 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
483 |
// new WM |
// new WM |
484 |
// 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 ){ |
485 |
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 ){ |
486 |
// |
// |
487 |
t_pmt->pmt_id = tof->GetPMTid(kk,hh); |
t_pmt->pmt_id = tof->GetPMTid(kk,hh); |
518 |
// Get tracker related variables for this track |
// Get tracker related variables for this track |
519 |
// |
// |
520 |
toftrk(); |
toftrk(); |
521 |
// toftrk(thelp); |
// toftrk(thelp); |
522 |
// |
// |
523 |
// 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). |
524 |
// |
// |
537 |
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
538 |
}; |
}; |
539 |
// |
// |
540 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
541 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
542 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
543 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
544 |
|
// |
545 |
|
tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof); |
546 |
t_tof->npmtadc = 0; |
t_tof->npmtadc = 0; |
547 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
548 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
549 |
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
pmt_id = tof->GetPMTid(kk,hh); |
550 |
// t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO |
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. ){ |
551 |
pmt_id = tof->GetPMTid(kk,hh); |
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc); |
|
t_tof->dedx.AddAt((tofoutput_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
|
552 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
553 |
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 |
554 |
|
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]); |
555 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
556 |
}; |
}; |
557 |
|
|
558 |
}; |
}; |
559 |
}; |
}; |
560 |
|
// t_tof->npmtadc = 0; |
561 |
|
// for (Int_t hh=0; hh<12;hh++){ |
562 |
|
// for (Int_t kk=0; kk<4;kk++){ |
563 |
|
// if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
564 |
|
// // t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO |
565 |
|
// pmt_id = tof->GetPMTid(kk,hh); |
566 |
|
// t_tof->dedx.AddAt((tofoutput_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO |
567 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
568 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
569 |
|
// t_tof->npmtadc++; |
570 |
|
// }; |
571 |
|
// }; |
572 |
|
// }; |
573 |
// |
// |
574 |
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)); |
|
575 |
// |
// |
576 |
// 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 |
577 |
// |
// |
626 |
|
|
627 |
void usage(){ |
void usage(){ |
628 |
|
|
629 |
cout << "------------------------------------------------------------"<<endl; |
cout << "------------------------------------------------------------"<<endl; |
630 |
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"; |
631 |
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 "; |
632 |
cout << "USAGE:"<<endl; |
cout << "USAGE:"<<endl; |
633 |
cout << "-processDir DIR - Level2 data directory \n"; |
cout << "-processDir DIR - Level2 data directory \n"; |
634 |
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"; |
635 |
cout << "-outputFile PATH - name of the output file \n"; |
cout << "-outputFile PATH - name of the output file \n"; |
636 |
cout << "-NumEvents XXX - number of events to be analysed \n"; |
cout << "-calibFile PATH+NAME - name of the calibration file \n"; |
637 |
cout << "--debug, -g - debug mode \n"; |
cout << "-NumEvents XXX - number of events to be analysed \n"; |
638 |
cout << "--help, -h - print this help \n"; |
cout << "--debug, -g - debug mode \n"; |
639 |
cout << "-options [ options ] - options: \n"; |
cout << "--help, -h - print this help \n"; |
640 |
cout << " fillHistos --> create an output file with histograms \n"; |
cout << "-options [ options ] - options: \n"; |
641 |
cout << " fillTree --> create an output file with trees storing the selected events \n "; |
cout << " fillHistos --> create an output file with histograms \n"; |
642 |
cout << " +(-)ALL --> inlcude(exclude) all trees and branches \n " ; |
cout << " fillTree --> create an output file with trees storing the selected events \n "; |
643 |
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 " ; |
644 |
cout << "------------------------------------------------------------"<<endl; |
cout << " +(-)TRK1 +(-)TRK2 +(-)CAL1 +(-)CAL2 +(-)TOF +(-)TRG +(-)ND +(-)S4 +(-)ORB --> inlcude(exclude) trees and branches \n" ; |
645 |
|
cout << "------------------------------------------------------------"<<endl; |
646 |
} |
} |
647 |
// |
// |
648 |
int HandleInputPar(int argc, char **argv){ |
int HandleInputPar(int argc, char **argv){ |
649 |
|
|
650 |
if(argc>1){ |
if(argc>1){ |
651 |
|
|
652 |
if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") ){ |
if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") ){ |
653 |
usage(); |
usage(); |
654 |
return(1); |
return(1); |
655 |
}; |
}; |
656 |
// ----------------------- |
// ----------------------- |
657 |
// Read input parameters |
// Read input parameters |
658 |
// ----------------------- |
// ----------------------- |
659 |
DIR = gSystem->WorkingDirectory(); |
DIR = gSystem->WorkingDirectory(); |
660 |
LIST = ""; |
LIST = ""; |
661 |
OUTF = "myfile"; |
OUTF = "myfile"; |
662 |
OPTIONS = "+AUTO -TOF"; |
OPTIONS = "+AUTO -TOF"; |
663 |
|
|
664 |
for (int i = 1; i < argc; i++){ |
for (int i = 1; i < argc; i++){ |
665 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
666 |
if (!strcmp(argv[i], "-processDir")){ |
if (!strcmp(argv[i], "-processDir")){ |
667 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
668 |
DIR = argv[i]; |
DIR = argv[i]; |
669 |
cout << "processDir "<<DIR<<endl; |
cout << "processDir "<<DIR<<endl; |
670 |
continue; |
continue; |
671 |
} |
} |
672 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
673 |
else if (!strcmp(argv[i], "-processList")){ |
else if (!strcmp(argv[i], "-processList")){ |
674 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
675 |
LIST = argv[i]; |
LIST = argv[i]; |
676 |
cout << "processList "<<LIST<<endl; |
cout << "processList "<<LIST<<endl; |
677 |
continue; |
continue; |
678 |
} |
} |
679 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
680 |
else if (!strcmp(argv[i], "-outputFile")){ |
else if (!strcmp(argv[i], "-outputFile")){ |
681 |
if (++i >= argc) throw -1; |
if (++i >= argc) throw -1; |
682 |
OUTF = argv[i]; |
OUTF = argv[i]; |
683 |
cout << "outputFile "<<OUTF<<endl; |
cout << "outputFile "<<OUTF<<endl; |
684 |
continue; |
continue; |
685 |
} |
} |
686 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
687 |
else if (!strcmp(argv[i], "-options")){ |
// -----------------------------------------------------// |
688 |
if (++i >= argc) throw -1; |
else if (!strcmp(argv[i], "-calibFile")){ |
689 |
OPTIONS = argv[i]; |
if (++i >= argc) throw -1; |
690 |
if( OPTIONS.Contains("[") ){ |
CALIBF = argv[i]; |
691 |
do{ |
cout << "calibFile "<<CALIBF<<endl; |
692 |
if (++i >= argc) throw -1; |
continue; |
693 |
OPTIONS.Append(argv[i]); |
} |
694 |
}while(!OPTIONS.Contains("]")); |
// -----------------------------------------------------// |
695 |
}else cout << "wrong option format --> ignoring " << endl; |
else if (!strcmp(argv[i], "-options")){ |
696 |
} |
if (++i >= argc) throw -1; |
697 |
else{ |
OPTIONS = argv[i]; |
698 |
cout << "Unidentified input parameter. Ignored."<< endl; |
if( OPTIONS.Contains("[") ){ |
699 |
}; |
do{ |
700 |
}; |
if (++i >= argc) throw -1; |
701 |
}else{ |
OPTIONS.Append(argv[i]); |
702 |
usage(); |
}while(!OPTIONS.Contains("]")); |
703 |
return(1); |
}else cout << "wrong option format --> ignoring " << endl; |
704 |
|
} |
705 |
|
else{ |
706 |
|
cout << "Unidentified input parameter. Ignored."<< endl; |
707 |
|
}; |
708 |
}; |
}; |
709 |
// ----------------------- |
}else{ |
710 |
// Check input parameters |
usage(); |
711 |
// ----------------------- |
return(1); |
712 |
|
}; |
713 |
|
// ----------------------- |
714 |
|
// Check input parameters |
715 |
|
// ----------------------- |
716 |
|
|
717 |
|
|
718 |
return(0); |
return(0); |
719 |
|
|
720 |
}; |
}; |
721 |
// |
// |
723 |
int main(int argc, char **argv) |
int main(int argc, char **argv) |
724 |
{ |
{ |
725 |
|
|
726 |
if( HandleInputPar(argc,argv) )return(1); |
if( HandleInputPar(argc,argv) )return(1); |
727 |
|
|
728 |
cout << "OPTIONS "<<OPTIONS<<endl; |
cout << "OPTIONS "<<OPTIONS<<endl; |
729 |
Loop(DIR,LIST,OPTIONS); |
Loop(DIR,LIST,OPTIONS); |
730 |
|
|
731 |
cout << "Back to main - end"<<endl; |
cout << "Back to main - end"<<endl; |
732 |
|
|
733 |
return 0; |
return 0; |
734 |
|
|
735 |
}; |
}; |
736 |
|
|