44 |
extern "C" int toftrk(); |
extern "C" int toftrk(); |
45 |
///extern "C" int toftrk(float); |
///extern "C" int toftrk(float); |
46 |
#define rdtofcal rdtofcal_ |
#define rdtofcal rdtofcal_ |
47 |
extern "C" int rdtofcal(char [], int *); |
//extern "C" int rdtofcal(char [], int *); |
48 |
|
extern "C" int rdtofcal(const char *, int *); |
49 |
|
|
50 |
using namespace std; |
using namespace std; |
51 |
|
|
184 |
}; |
}; |
185 |
// |
// |
186 |
tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data()); |
tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data()); |
187 |
|
printf(" Reading Attenuation file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
188 |
|
|
189 |
// |
// |
190 |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table |
191 |
if ( error<0 ) { |
if ( error<0 ) { |
193 |
}; |
}; |
194 |
// |
// |
195 |
tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data()); |
tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data()); |
196 |
|
printf(" Reading desaturation1 file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
197 |
|
|
198 |
// |
// |
199 |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table |
200 |
if ( error<0 ) { |
if ( error<0 ) { |
202 |
}; |
}; |
203 |
// |
// |
204 |
tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data()); |
tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data()); |
205 |
|
printf(" Reading BBneg file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
206 |
|
|
207 |
// |
// |
208 |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table |
209 |
if ( error<0 ) { |
if ( error<0 ) { |
211 |
}; |
}; |
212 |
// |
// |
213 |
tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data()); |
tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data()); |
214 |
|
printf(" Reading BBpos file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
215 |
|
|
216 |
// |
// |
217 |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table |
218 |
if ( error<0 ) { |
if ( error<0 ) { |
220 |
}; |
}; |
221 |
// |
// |
222 |
tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data()); |
tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data()); |
223 |
|
printf(" Reading desaturation2 file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
224 |
|
|
225 |
tofdedx->CheckConnectors(pam_event->GetRunInfo()->RUNHEADER_TIME,glparam,dbc); |
tofdedx->CheckConnectors(pam_event->GetRunInfo()->RUNHEADER_TIME,glparam,dbc); |
226 |
|
|
227 |
|
|
|
|
|
228 |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
229 |
if ( error<0 ) { |
if ( error<0 ) { |
230 |
return(1); |
return(1); |
234 |
// |
// |
235 |
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
236 |
// |
// |
237 |
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
TString pippo=(glparam->PATH+glparam->NAME).Data(); |
238 |
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
//Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
239 |
|
//rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
240 |
|
Int_t nlen = (Int_t)pippo.Length(); |
241 |
|
rdtofcal(pippo.Data(),&nlen); |
242 |
// |
// |
243 |
|
|
244 |
|
tofdedx->Clear(); |
245 |
|
|
246 |
}; |
}; |
247 |
// |
// |
248 |
|
|
252 |
//--- Define absolute time |
//--- Define absolute time |
253 |
UInt_t tabs=pam_event->GetOrbitalInfo()->absTime; |
UInt_t tabs=pam_event->GetOrbitalInfo()->absTime; |
254 |
|
|
255 |
if ( !(iev%1000) ) printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev); |
if ( !(iev%100000) ) printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev); |
256 |
|
|
257 |
//================================================================== |
//================================================================== |
258 |
Float_t dedx_corr_m[2000][48],dedx_corr[48]; |
Float_t dedx_corr_m[2000][48];//,dedx_corr[48]; |
259 |
Double_t mtime[2000],t1,t2,tm; |
Double_t mtime[2000],t1,t2,tm; |
260 |
Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
// Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2; |
261 |
|
Float_t yhelp1,yhelp2; |
262 |
Float_t xmean1,xwidth1; |
Float_t xmean1,xwidth1; |
263 |
|
|
264 |
Int_t ical,ii,j,jj; |
Int_t ical=0; |
265 |
|
Int_t ii,j,jj; |
266 |
|
|
267 |
if (iev==0) { |
if (iev==0) { |
268 |
|
|
276 |
printf(" READING NEW CALIBRATION FILE: %s \n",CALIBF.Data()); |
printf(" READING NEW CALIBRATION FILE: %s \n",CALIBF.Data()); |
277 |
|
|
278 |
ifstream fin(CALIBF.Data()); |
ifstream fin(CALIBF.Data()); |
279 |
|
//cout << "topolino" << endl; |
280 |
while (! fin.eof()) { |
while (! fin.eof()) { |
281 |
fin>>t1>>tm>>t2; |
fin>>t1>>tm>>t2; |
282 |
// cout<<jj<<" "<<tm<<endl; |
//cout<<jj<<" "<<tm<<endl; |
283 |
cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
//cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl; |
284 |
mtime[jj]=tm; |
mtime[jj]=tm; |
285 |
for (ii=0; ii<48;ii++) { |
for (ii=0; ii<48;ii++) { |
286 |
fin>>j>>xmean1>>xwidth1; |
fin>>j>>xmean1>>xwidth1; |
290 |
// printf(" kk %i \n",jj); |
// printf(" kk %i \n",jj); |
291 |
} |
} |
292 |
// printf(" 1ical %i \n",ical); |
// printf(" 1ical %i \n",ical); |
293 |
|
//cout << "pippo" << endl; |
294 |
fin.close(); |
fin.close(); |
295 |
|
|
296 |
|
|
299 |
ical = ical+1; |
ical = ical+1; |
300 |
} |
} |
301 |
// ical = ical-1; |
// ical = ical-1; |
302 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
//cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
303 |
} // if iev==0... |
} // if iev==0... |
304 |
|
|
305 |
//================================================================== |
//================================================================== |
317 |
ical = ical+1; |
ical = ical+1; |
318 |
} |
} |
319 |
// ical = ical-1; |
// ical = ical-1; |
320 |
cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
//cout<<"abs time "<<tabs<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl; |
321 |
}; |
}; |
322 |
|
|
323 |
// printf(" 2ical %i \n",ical); |
// printf(" 2ical %i \n",ical); |
325 |
//== interpolate betwen time limits |
//== interpolate betwen time limits |
326 |
//================================================================== |
//================================================================== |
327 |
|
|
328 |
thelp1 = mtime[ical]; |
// thelp1 = mtime[ical]; |
329 |
thelp2 = mtime[ical+1]; |
// thelp2 = mtime[ical+1]; |
330 |
|
|
331 |
for (ii=0; ii<48;ii++) { |
for (ii=0; ii<48;ii++) { |
332 |
yhelp1 = fabs(dedx_corr_m[ical][ii]); |
yhelp1 = fabs(dedx_corr_m[ical][ii]); |
335 |
yhelp2 = fabs(dedx_corr_m[ical+1][ii]); |
yhelp2 = fabs(dedx_corr_m[ical+1][ii]); |
336 |
// yhelp2 = 6.; |
// yhelp2 = 6.; |
337 |
if ( yhelp2 < 0.1 ) yhelp2 = 4.; |
if ( yhelp2 < 0.1 ) yhelp2 = 4.; |
338 |
slope = (yhelp2-yhelp1)/(thelp2-thelp1); |
// slope = (yhelp2-yhelp1)/(thelp2-thelp1); |
339 |
inter = yhelp1 - slope*thelp1; |
// inter = yhelp1 - slope*thelp1; |
340 |
dedx_corr[ii] = slope*tabs + inter; |
// dedx_corr[ii] = slope*tabs + inter; |
341 |
// if (ii==0) cout<<thelp1<<" "<<thelp2<<" "<<tabs<<" "<<yhelp1<<" "<<yhelp2<<" "<<dedx_corr[0]<<endl; |
// if (ii==0) cout<<thelp1<<" "<<thelp2<<" "<<tabs<<" "<<yhelp1<<" "<<yhelp2<<" "<<dedx_corr[0]<<endl; |
342 |
} |
} |
343 |
|
|
529 |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
530 |
tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); |
tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); |
531 |
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 !!!! |
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 !!!! |
532 |
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
533 |
|
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*dedx_corr[pmt_id]/4.),t_tof->npmtadc);//annullo wolfrizzazione |
534 |
|
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)),t_tof->npmtadc);//annullo wolfrizzazione |
535 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
536 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
537 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
652 |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
653 |
IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); |
IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); |
654 |
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){ |
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){ |
655 |
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
656 |
|
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*dedx_corr[pmt_id]/4.),t_tof->npmtadc);//annullo wolfrizzazione |
657 |
|
t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)),t_tof->npmtadc);//annullo wolfrizzazione |
658 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
659 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
660 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |