29 |
#include <stdlib.h> |
#include <stdlib.h> |
30 |
#include <math.h> |
#include <math.h> |
31 |
// |
// |
32 |
|
// RunInfo header |
33 |
|
// |
34 |
|
#include <RunInfo.h> |
35 |
|
#include <GLTables.h> |
36 |
|
// |
37 |
// YODA headers |
// YODA headers |
38 |
// |
// |
39 |
#include <PamelaRun.h> |
#include <PamelaRun.h> |
43 |
#include <CalibS4Event.h> |
#include <CalibS4Event.h> |
44 |
#include <physics/S4/S4Event.h> |
#include <physics/S4/S4Event.h> |
45 |
//#include <yodaUtility.h> |
//#include <yodaUtility.h> |
46 |
// |
|
|
// RunInfo header |
|
|
// |
|
|
#include <RunInfo.h> |
|
|
#include <GLTables.h> |
|
47 |
// |
// |
48 |
// This program headers |
// This program headers |
49 |
// |
// |
73 |
// |
// |
74 |
GL_S4_CALIB *glS4calib = new GL_S4_CALIB(); |
GL_S4_CALIB *glS4calib = new GL_S4_CALIB(); |
75 |
// |
// |
76 |
|
if ( !dbc->IsConnected() ) throw -504; |
77 |
glS4calib->Query_GL_S4_CALIB(atime, dbc); |
glS4calib->Query_GL_S4_CALIB(atime, dbc); |
78 |
// |
// |
79 |
GL_ROOT *glroot = new GL_ROOT(); |
GL_ROOT *glroot = new GL_ROOT(); |
80 |
|
if ( !dbc->IsConnected() ) throw -504; |
81 |
glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); |
glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); |
82 |
// |
// |
83 |
stringstream ftmpname; |
stringstream ftmpname; |
199 |
// |
// |
200 |
// variables needed to reprocess data |
// variables needed to reprocess data |
201 |
// |
// |
202 |
|
Long64_t maxsize = 10000000000LL; |
203 |
|
TTree::SetMaxTreeSize(maxsize); |
204 |
|
// |
205 |
TString S4version; |
TString S4version; |
206 |
ItoRunInfo *runinfo = 0; |
ItoRunInfo *runinfo = 0; |
207 |
TArrayI *runlist = 0; |
TArrayI *runlist = 0; |
347 |
// |
// |
348 |
// tree exists, we are reprocessing data. Are we reprocessing a single run or all the file? |
// tree exists, we are reprocessing data. Are we reprocessing a single run or all the file? |
349 |
// |
// |
350 |
|
S4trclone->SetAutoSave(900000000000000LL); |
351 |
reproc = true; |
reproc = true; |
352 |
// |
// |
353 |
// update versioning information |
// update versioning information |
392 |
// |
// |
393 |
file->cd(); |
file->cd(); |
394 |
S4tr = new TTree("S4-new","PAMELA Level2 S4 data"); |
S4tr = new TTree("S4-new","PAMELA Level2 S4 data"); |
395 |
|
S4tr->SetAutoSave(900000000000000LL); |
396 |
S4tr->Branch("S4Level2","S4Level2",&s4); |
S4tr->Branch("S4Level2","S4Level2",&s4); |
397 |
// |
// |
398 |
if ( reproc && !reprocall ){ |
if ( reproc && !reprocall ){ |
401 |
// |
// |
402 |
tempfile = new TFile(tempname.str().c_str(),"READ"); |
tempfile = new TFile(tempname.str().c_str(),"READ"); |
403 |
S4trclone = (TTree*)tempfile->Get("S4-old"); |
S4trclone = (TTree*)tempfile->Get("S4-old"); |
404 |
|
S4trclone->SetAutoSave(900000000000000LL); |
405 |
S4trclone->SetBranchAddress("S4Level2",&s4clone); |
S4trclone->SetBranchAddress("S4Level2",&s4clone); |
406 |
// |
// |
407 |
if ( nobefrun > 0 ){ |
if ( nobefrun > 0 ){ |
460 |
sgnl = 0; |
sgnl = 0; |
461 |
}; |
}; |
462 |
// |
// |
463 |
// now you can access that variables using the RunInfo class this way runinfo->ID_REG_RUN |
// now you can access that variables using the RunInfo class this way runinfo->ID_ROOT_L0 |
464 |
// |
// |
465 |
if ( runinfo->ID_ROOT_L0 == 0 ){ |
if ( runinfo->ID_ROOT_L0 == 0 ){ |
466 |
if ( debug ) printf("\n S4 - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun); |
if ( debug ) printf("\n S4 - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun); |
470 |
// |
// |
471 |
// prepare the timesync for the db |
// prepare the timesync for the db |
472 |
// |
// |
473 |
|
if ( !dbc->IsConnected() ) throw -504; |
474 |
dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc); |
dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc); |
475 |
// |
// |
476 |
// Search in the DB the path and name of the LEVEL0 file to be processed. |
// Search in the DB the path and name of the LEVEL0 file to be processed. |
477 |
// |
// |
478 |
|
if ( !dbc->IsConnected() ) throw -504; |
479 |
glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc); |
glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc); |
480 |
// |
// |
481 |
ftmpname.str(""); |
ftmpname.str(""); |
536 |
goto closeandexit; |
goto closeandexit; |
537 |
}; |
}; |
538 |
// |
// |
539 |
if ( runinfo->NEVENTS > nevents-1 ) { |
if ( runinfo->EV_TO > nevents-1 ) { |
540 |
if ( debug ) printf(" S4 - ERROR: too few entries in the S4 tree\n"); |
if ( debug ) printf(" S4 - ERROR: too few entries in the S4 tree\n"); |
541 |
l0File->Close(); |
l0File->Close(); |
542 |
code = -12; |
code = -12; |
584 |
// |
// |
585 |
s4->Clear(); |
s4->Clear(); |
586 |
l0S4->GetEntry(re); |
l0S4->GetEntry(re); |
587 |
if (l0s4e->unpackError == 1) continue; |
if (l0s4e->unpackError == 0){ |
588 |
s4->S4adc = l0s4e->S4_DATA; |
s4->S4adc = l0s4e->S4_DATA; |
589 |
|
// |
590 |
|
if ((l0s4e->S4_DATA) > 31 ){ |
591 |
|
s4->S4calibrated = ParamFit0*((l0s4e->S4_DATA)-32)+ParamFit1; |
592 |
|
}else{ |
593 |
|
s4->S4calibrated = 0; |
594 |
|
} |
595 |
|
}; |
596 |
// |
// |
597 |
if ((l0s4e->S4_DATA) > 31 ){ |
s4->unpackError = l0s4e->unpackError; |
|
s4->S4calibrated = ParamFit0*((l0s4e->S4_DATA)-32)+ParamFit1; |
|
|
}else{ |
|
|
s4->S4calibrated = 0; |
|
|
} |
|
598 |
// |
// |
599 |
S4tr->Fill(); |
S4tr->Fill(); |
600 |
// |
// |