1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file TrkCore.cpp |
3 |
|
|
* \author Elena Vannuccini |
4 |
|
|
*/ |
5 |
|
|
// ......................................................... |
6 |
|
|
// ROOT header files |
7 |
|
|
// ......................................................... |
8 |
|
|
#include <TTree.h> |
9 |
|
|
#include <TClassEdit.h> |
10 |
|
|
#include <TObject.h> |
11 |
|
|
#include <TList.h> |
12 |
|
|
#include <TSystem.h> |
13 |
|
|
#include <TSystemDirectory.h> |
14 |
|
|
#include <TString.h> |
15 |
|
|
#include <TFile.h> |
16 |
|
|
#include <TClass.h> |
17 |
|
|
#include <TCanvas.h> |
18 |
|
|
#include <TH1.h> |
19 |
|
|
#include <TH1F.h> |
20 |
|
|
#include <TH2D.h> |
21 |
|
|
#include <TLatex.h> |
22 |
|
|
#include <TPad.h> |
23 |
|
|
#include <TSQLServer.h> |
24 |
|
|
#include <TSQLRow.h> |
25 |
|
|
#include <TSQLResult.h> |
26 |
|
|
// ......................................................... |
27 |
|
|
// other general header files |
28 |
|
|
// ......................................................... |
29 |
|
|
#include <fstream> |
30 |
|
|
#include <iostream> |
31 |
|
|
// ......................................................... |
32 |
|
|
// files in the inc directory |
33 |
|
|
// ......................................................... |
34 |
|
|
#include <RunInfo.h> |
35 |
|
|
#include <GLTables.h> |
36 |
|
|
#include <TrkVerl2.h> |
37 |
|
|
#include <TrkProcess.h> |
38 |
pam-fi |
1.2 |
//#include <TrkStruct.h> |
39 |
mocchiut |
1.1 |
#include <TrkLevel2.h> |
40 |
pam-fi |
1.6 |
#include <TrkLevel1.h> |
41 |
mocchiut |
1.1 |
#include <TrkLevel0.h> |
42 |
|
|
// ......................................................... |
43 |
|
|
// YODA header files |
44 |
|
|
// ......................................................... |
45 |
|
|
#include <PamelaRun.h> |
46 |
pam-fi |
1.7 |
//#include <RegistryEvent.h> |
47 |
mocchiut |
1.1 |
#include <physics/tracker/TrackerEvent.h> |
48 |
|
|
#include <CalibTrk1Event.h> |
49 |
|
|
#include <CalibTrk2Event.h> |
50 |
pam-fi |
1.2 |
|
51 |
mocchiut |
1.1 |
// ......................................................... |
52 |
|
|
// namespaces |
53 |
|
|
// ......................................................... |
54 |
|
|
using namespace std; |
55 |
|
|
using namespace pamela; |
56 |
|
|
// ================================================================================ |
57 |
|
|
// |
58 |
|
|
// |
59 |
|
|
// ================================================================================ |
60 |
|
|
/** |
61 |
|
|
* \brief Tracker data reduction routine. |
62 |
|
|
* |
63 |
|
|
* It performs data reduction LEVEL0->LEVEL1->LEVEL2, producing LEVEL1 and or LEVEL2 output, in ROOT or HBOOK format. |
64 |
|
|
* Input parameters: |
65 |
|
|
* @param run id of the run to be processed (if run=0 a whole file is reprocessed) |
66 |
|
|
* @param dbc pointer to BD server |
67 |
|
|
* @param file1 output LEVEL1 file name (null if no LEVEL1 output is required) |
68 |
|
|
* @param file2 output LEVEL2 file name (null if no LEVEL2 output is required) |
69 |
|
|
* @param standalone (flag to run the program in standalone mode, that is without reading RunInfo) |
70 |
|
|
*/ |
71 |
|
|
//short int TrkCore(Int_t run, TSQLServer *dbc, TString file1, TString file2, Bool_t standalone) |
72 |
pam-fi |
1.7 |
int TrkCore(UInt_t run, TFile *f2, TSQLServer *dbc, int ncustom, char*vcustom[]) |
73 |
mocchiut |
1.1 |
{ |
74 |
|
|
// --------------------------- |
75 |
|
|
// Define some basic variables |
76 |
|
|
// --------------------------- |
77 |
|
|
|
78 |
|
|
TString filename = 0; |
79 |
|
|
TString trkcalibfile = 0; |
80 |
|
|
Int_t last_trk_calib_used = 0; |
81 |
pam-fi |
1.7 |
Long64_t nentries = 0LL; |
82 |
pam-fi |
1.2 |
|
83 |
mocchiut |
1.1 |
// LEVEL0 input |
84 |
|
|
TFile *f0 = 0; |
85 |
pam-fi |
1.2 |
TFile *f0_c = 0; |
86 |
mocchiut |
1.1 |
TTree *physicsTree = 0; |
87 |
pam-fi |
1.7 |
// TBranch *b_registry = 0; |
88 |
mocchiut |
1.1 |
TBranch *b_trk = 0; |
89 |
|
|
TBranch *b_header = 0; |
90 |
pam-fi |
1.7 |
// RegistryEvent *reg = 0; |
91 |
mocchiut |
1.1 |
EventHeader *header = 0; |
92 |
|
|
PscuHeader *pscu = 0; |
93 |
|
|
TrkLevel0 *l0_event = 0; |
94 |
|
|
// RunInfo |
95 |
|
|
ItoRunInfo *runinfo = 0; |
96 |
pam-fi |
1.7 |
TArrayI *runlist = 0; |
97 |
|
|
UInt_t from_run; |
98 |
|
|
UInt_t to_run; |
99 |
mocchiut |
1.1 |
Bool_t reprocessing = false; |
100 |
|
|
//LEVEL1 output - ROOT |
101 |
pam-fi |
1.7 |
// TFile *f1; |
102 |
|
|
// TTree *t_level1 = 0; |
103 |
pam-fi |
1.6 |
TrkLevel1 *l1_event = new TrkLevel1(); |
104 |
|
|
// TrkLevel2Ref *l2_ref = new TrkLevel2Ref(); |
105 |
mocchiut |
1.1 |
//LEVEL2 output - ROOT |
106 |
|
|
TTree *t_level2 = 0; |
107 |
|
|
TTree *t_clone = 0; |
108 |
|
|
TrkLevel2 *l2_event = new TrkLevel2(); |
109 |
|
|
TrkLevel2 *l2_clone = new TrkLevel2(); |
110 |
|
|
// ----------------------- |
111 |
|
|
// ----------------------- |
112 |
|
|
// Handle input parameters |
113 |
|
|
// (data) |
114 |
|
|
// |
115 |
|
|
// - open/create output files, determining the environment root/hbook from the estension |
116 |
|
|
// - create the level1/level2 tree+branch/nt-uple |
117 |
|
|
// ----------------------- |
118 |
|
|
// ----------------------- |
119 |
|
|
TrkProcess *p = new TrkProcess(run,f2); |
120 |
|
|
p->HandleCustomPar(ncustom,vcustom); |
121 |
pam-fi |
1.2 |
if( p->DebugMode() )p->Dump(); |
122 |
mocchiut |
1.1 |
|
123 |
|
|
// =================================== |
124 |
|
|
// Open/Create level1 output file |
125 |
|
|
// (NB output files other than LEVEL2 are |
126 |
|
|
// created in a separate folder) |
127 |
|
|
// =================================== |
128 |
pam-fi |
1.7 |
/* if(p->get1){ |
129 |
pam-fi |
1.6 |
if(p->ifroot1){ |
130 |
|
|
cout << endl << "Requested LEVEL1 output" << endl; |
131 |
pam-fi |
1.7 |
// Create NEW Tracker tree |
132 |
pam-fi |
1.6 |
t_level1 = new TTree("Clusters","PAMELA tracker level1 data "); |
133 |
|
|
t_level1->Branch("TrkLevel1","TrkLevel1",&l1_event); |
134 |
|
|
t_level1->SetDirectory(0); |
135 |
|
|
}else{ |
136 |
|
|
throw -299; |
137 |
|
|
}; |
138 |
pam-fi |
1.7 |
};*/ |
139 |
mocchiut |
1.1 |
// =================================== |
140 |
|
|
// Open/Create level2 output file |
141 |
|
|
// =================================== |
142 |
|
|
if(p->get2){ |
143 |
|
|
// if(p->ifroot2){ // root |
144 |
pam-fi |
1.6 |
//------------------------------------------- |
145 |
|
|
// read RunInfo |
146 |
|
|
//------------------------------------------- |
147 |
|
|
if(!(p->standalone)){ |
148 |
|
|
// Open "RunInfo" tree and get list of run |
149 |
|
|
runinfo = new ItoRunInfo(f2); |
150 |
|
|
char *trkversion = TrkInfo(false); |
151 |
|
|
int runinfo_error = runinfo->Update(run,"TRK",trkversion); |
152 |
|
|
if( runinfo_error ) throw runinfo_error; |
153 |
|
|
runlist = runinfo->GetRunList(); |
154 |
pam-fi |
1.7 |
reprocessing = runinfo->IsReprocessing();//???? |
155 |
pam-fi |
1.6 |
if(p->VerboseMode()){ |
156 |
|
|
cout << "#events "<< runinfo->GetFileEntries() << endl;// #events in the file |
157 |
|
|
cout << "#runs "<< runinfo->GetRunEntries() << endl;// #runs in the file |
158 |
|
|
cout << "1-st run "<< runlist->At(0) << endl; |
159 |
|
|
cout << "last run "<< runlist->At(runinfo->GetRunEntries()-1) << endl; |
160 |
|
|
cout << "1-st event "<< runinfo->GetFirstEntry() << endl;// first event of our run |
161 |
|
|
cout << "last event+1 "<< runinfo->GetLastEntry() << endl;// first event AFTER the last event of our run |
162 |
|
|
cout << "reprocessing "<< runinfo->IsReprocessing() << endl << endl; |
163 |
|
|
}; |
164 |
|
|
}; |
165 |
|
|
//------------------------------------------- |
166 |
|
|
// |
167 |
|
|
//------------------------------------------- |
168 |
|
|
// Take (if present) the old Tracker tree |
169 |
|
|
t_clone = (TTree*)f2->Get("Tracker"); |
170 |
|
|
if( t_clone != NULL ) t_clone->SetBranchAddress("TrkLevel2",&l2_clone); |
171 |
|
|
// Create NEW Tracker tree |
172 |
|
|
t_level2 = new TTree("Tracker","PAMELA tracker level2 data "); |
173 |
|
|
t_level2->Branch("TrkLevel2","TrkLevel2",&l2_event); |
174 |
pam-fi |
1.8 |
if(p->get1){ |
175 |
pam-fi |
1.7 |
if(p->VerboseMode())cout << endl << "Requested LEVEL1 output" << endl; |
176 |
pam-fi |
1.6 |
t_level2->Branch("TrkLevel1","TrkLevel1",&l1_event); |
177 |
|
|
t_level2->BranchRef(); |
178 |
pam-fi |
1.8 |
}; |
179 |
pam-fi |
1.7 |
}; |
180 |
mocchiut |
1.1 |
|
181 |
|
|
|
182 |
|
|
// ------------------------------------------- |
183 |
|
|
// define runs to be processed/reprocessed |
184 |
|
|
// ------------------------------------------- |
185 |
|
|
if(run == 0){ |
186 |
pam-fi |
1.7 |
// reprocessing ALL runs |
187 |
|
|
if(p->standalone)throw -298; // reprocessing not implemented |
188 |
|
|
from_run = runlist->At(0); |
189 |
|
|
to_run = runlist->At(runinfo->GetRunEntries()-1); |
190 |
mocchiut |
1.1 |
}else{ |
191 |
|
|
// processing/reprocessing ONE single run |
192 |
pam-fi |
1.7 |
from_run = run; |
193 |
|
|
to_run = run; |
194 |
mocchiut |
1.1 |
}; |
195 |
|
|
|
196 |
|
|
// |
197 |
|
|
// init "expiration date" of calibrations and parameters |
198 |
|
|
// |
199 |
pam-fi |
1.7 |
UInt_t pedsig_time =0; |
200 |
|
|
UInt_t B_time =0; |
201 |
|
|
UInt_t mip_time =0; |
202 |
|
|
UInt_t charge_time =0; |
203 |
|
|
UInt_t eta_time =0; |
204 |
|
|
UInt_t align_time =0; |
205 |
|
|
UInt_t mask_time =0; |
206 |
mocchiut |
1.1 |
// |
207 |
|
|
// init event counter |
208 |
|
|
// |
209 |
|
|
Int_t ev_count =0; |
210 |
|
|
// |
211 |
|
|
// create query-results objects |
212 |
|
|
// |
213 |
pam-fi |
1.7 |
GL_RUN q1 = GL_RUN(); |
214 |
mocchiut |
1.1 |
GL_TRK_CALIB q2 = GL_TRK_CALIB(); |
215 |
|
|
GL_ROOT q3 = GL_ROOT(); |
216 |
|
|
GL_PARAM q4 = GL_PARAM(); |
217 |
|
|
|
218 |
|
|
// ------------------------------------------------------------ |
219 |
|
|
// if reprocessing one run, copy all the events BEFORE the run |
220 |
|
|
// ------------------------------------------------------------ |
221 |
|
|
if( !(p->standalone) ){ |
222 |
pam-fi |
1.6 |
for(UInt_t i=0; i<runinfo->GetFirstEntry(); i++){ |
223 |
|
|
t_clone->GetEntry(i); |
224 |
|
|
*l2_event = *l2_clone; |
225 |
|
|
t_level2->Fill(); |
226 |
|
|
l2_event->Clear(); |
227 |
|
|
// COPY COPY COPY |
228 |
|
|
}; |
229 |
mocchiut |
1.1 |
}; |
230 |
|
|
// ------------------------------------------------------------ |
231 |
|
|
// ------------------------------------------------------------ |
232 |
|
|
// START LOOP OVER RUNS TO PROCESSED/REPROCESSED |
233 |
|
|
// ------------------------------------------------------------ |
234 |
|
|
// ------------------------------------------------------------ |
235 |
pam-fi |
1.7 |
for(UInt_t idRun = from_run; idRun <= to_run; idRun++){ |
236 |
mocchiut |
1.1 |
|
237 |
pam-fi |
1.2 |
if(p->VerboseMode()) cout << endl<<" ========================= Run: "<< idRun << endl; |
238 |
pam-fi |
1.7 |
UInt_t runheadtime = 0; |
239 |
|
|
UInt_t runtrailtime = 0; |
240 |
mocchiut |
1.1 |
UInt_t evfrom = 0; |
241 |
|
|
UInt_t evto = 0; |
242 |
pam-fi |
1.7 |
UInt_t nevents = 0; |
243 |
|
|
Int_t id_root_l0 =-1; |
244 |
mocchiut |
1.1 |
Int_t trk_calib_used = 0; |
245 |
pam-fi |
1.7 |
|
246 |
mocchiut |
1.1 |
if(p->standalone){ |
247 |
|
|
// ============================== |
248 |
|
|
// first query: retrieve run info |
249 |
|
|
// ============================== |
250 |
pam-fi |
1.7 |
if (q1.Query_GL_RUN(idRun,dbc) )throw -50; |
251 |
|
|
id_root_l0 = q1.ID_ROOT_L0; |
252 |
mocchiut |
1.1 |
runheadtime = q1.RUNHEADER_TIME; |
253 |
|
|
runtrailtime = q1.RUNTRAILER_TIME; |
254 |
pam-fi |
1.7 |
evfrom = q1.EV_FROM; |
255 |
|
|
evto = q1.EV_TO; |
256 |
|
|
nevents = q1.NEVENTS; |
257 |
|
|
trk_calib_used = q1.TRK_CALIB_USED; |
258 |
mocchiut |
1.1 |
}else{ |
259 |
|
|
// ============================== |
260 |
|
|
// get run info from RunInfo tree |
261 |
|
|
// ============================== |
262 |
pam-fi |
1.3 |
int runinfo_error = runinfo->GetRunInfo(idRun); |
263 |
pam-fi |
1.7 |
if( runinfo_error ) throw runinfo_error; |
264 |
|
|
id_root_l0 = runinfo->ID_ROOT_L0; |
265 |
mocchiut |
1.1 |
runheadtime = runinfo->RUNHEADER_TIME; |
266 |
|
|
runtrailtime = runinfo->RUNTRAILER_TIME; |
267 |
pam-fi |
1.7 |
evfrom = runinfo->EV_FROM; |
268 |
|
|
evto = runinfo->EV_TO; |
269 |
|
|
nevents = runinfo->NEVENTS; |
270 |
|
|
trk_calib_used = runinfo->TRK_CALIB_USED; |
271 |
mocchiut |
1.1 |
}; |
272 |
|
|
// |
273 |
pam-fi |
1.2 |
if(p->VerboseMode()){ |
274 |
pam-fi |
1.7 |
cout << "ROOT file ID "<< id_root_l0 << endl; |
275 |
mocchiut |
1.1 |
cout << "RunHeader time "<< runheadtime << endl; |
276 |
|
|
cout << "RunTrailer time "<< runtrailtime << endl; |
277 |
pam-fi |
1.7 |
cout << " from event "<< evfrom << endl; |
278 |
|
|
cout << " to event "<< evto << endl; |
279 |
|
|
cout << " num. events "<< nevents << endl; |
280 |
|
|
cout << "trk-calibration used "<< trk_calib_used << endl; |
281 |
mocchiut |
1.1 |
}; |
282 |
|
|
// ======================================================== |
283 |
|
|
// second query: search the LEVEL0 file that contains idRun |
284 |
|
|
// ======================================================== |
285 |
|
|
TString lastfilename = filename; |
286 |
pam-fi |
1.7 |
if( q3.Query_GL_ROOT(id_root_l0,dbc) )throw -51; |
287 |
mocchiut |
1.1 |
filename = q3.PATH + q3.NAME; |
288 |
|
|
// ======================================================== |
289 |
|
|
// Open the input LEVEL0 data file |
290 |
|
|
// ======================================================== |
291 |
|
|
if(filename.CompareTo(lastfilename)){ |
292 |
|
|
if(!lastfilename.IsNull())f0->Close(); |
293 |
|
|
//if( debug ) cout << "Opening LEVEL0 file: "<< filename << endl; |
294 |
pam-fi |
1.2 |
if(p->VerboseMode()) cout << "Opening LEVEL0 file: "<< filename << endl; |
295 |
|
|
FileStat_t t; |
296 |
|
|
if( gSystem->GetPathInfo(filename.Data(),t) )throw -6; |
297 |
mocchiut |
1.1 |
f0 = new TFile(filename); |
298 |
|
|
if ( !f0 ) throw -6; |
299 |
|
|
physicsTree = (TTree*)f0->Get("Physics"); if(!physicsTree) throw -7; |
300 |
|
|
b_header = physicsTree ->GetBranch("Header"); if(!b_header ) throw -8; |
301 |
pam-fi |
1.7 |
// b_registry = physicsTree ->GetBranch("Registry"); if(!b_registry ) throw -9; |
302 |
mocchiut |
1.1 |
b_trk = physicsTree ->GetBranch("Tracker"); if(!b_trk ) throw -203; |
303 |
|
|
physicsTree->SetBranchAddress("Tracker" ,&l0_event); |
304 |
pam-fi |
1.7 |
// physicsTree->SetBranchAddress("Registry",®); |
305 |
mocchiut |
1.1 |
physicsTree->SetBranchAddress("Header",&header); |
306 |
|
|
|
307 |
pam-fi |
1.7 |
nentries = physicsTree->GetEntries(); |
308 |
|
|
if ( nentries < 1 ) throw -11; |
309 |
|
|
if ( nentries < (evto+1)) throw -12; |
310 |
|
|
|
311 |
mocchiut |
1.1 |
}; |
312 |
|
|
|
313 |
pam-fi |
1.7 |
GL_TIMESYNC *dbtime = new GL_TIMESYNC(id_root_l0,"ID",dbc); |
314 |
|
|
|
315 |
mocchiut |
1.1 |
// ============================================================= |
316 |
pam-fi |
1.2 |
// retrieve calibration file needed to reduce data |
317 |
mocchiut |
1.1 |
// ============================================================= |
318 |
pam-fi |
1.2 |
// if run OBT is > last calibration "expiration date" |
319 |
|
|
// - search for new calibration packet |
320 |
|
|
// - load calibration parameters (full + truncated) |
321 |
pam-fi |
1.5 |
if(p->VerboseMode() )cout << "Full pedestals for cluster finding:"; |
322 |
pam-fi |
1.2 |
if(runheadtime > pedsig_time){ |
323 |
|
|
if( q2.Query_GL_TRK_CALIB(runheadtime,dbc) )throw -53; |
324 |
|
|
pedsig_time = q2.TO_TIME; |
325 |
pam-fi |
1.7 |
if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2) |
326 |
|
|
printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
327 |
|
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )throw -51; |
328 |
pam-fi |
1.5 |
trkcalibfile = q3.PATH + q3.NAME; |
329 |
|
|
if(p->VerboseMode()) cout << " >> Loading from LEVEL0 file: "<< trkcalibfile << endl; |
330 |
pam-fi |
1.2 |
if(trkcalibfile.CompareTo(filename)){ |
331 |
pam-fi |
1.5 |
FileStat_t t; |
332 |
|
|
if( gSystem->GetPathInfo(trkcalibfile.Data(),t) )throw -6; |
333 |
|
|
f0_c=new TFile(trkcalibfile); |
334 |
|
|
if ( !f0_c ) throw -6; |
335 |
pam-fi |
1.2 |
}else{ |
336 |
pam-fi |
1.5 |
f0_c = f0; |
337 |
pam-fi |
1.2 |
}; |
338 |
|
|
if(p->VerboseMode()) { |
339 |
pam-fi |
1.7 |
cout << " calibration entries "<< q2.EV_ROOT_CALIBTRK1 << " " << q2.EV_ROOT_CALIBTRK2; |
340 |
|
|
cout << " (from time "<< q2.FROM_TIME <<" to time "<< q2.TO_TIME <<")"<<endl; |
341 |
pam-fi |
1.2 |
}; |
342 |
pam-fi |
1.7 |
pedsigbad_.FillACalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
343 |
pam-fi |
1.5 |
}else{ |
344 |
|
|
if(p->VerboseMode() )cout<< " already loaded. "<< endl; |
345 |
pam-fi |
1.2 |
}; |
346 |
|
|
if( p->DebugMode() ) for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal[64][12][i] << endl; |
347 |
|
|
// ============================================================= |
348 |
|
|
// retrieve calibration file needed to uncompress data |
349 |
|
|
// ============================================================= |
350 |
|
|
// if the run was compressed using default calib |
351 |
|
|
// load truncated pedestals from default |
352 |
|
|
// otherwise reload them from on-line calibration |
353 |
|
|
if(p->VerboseMode() )cout << "Truncated pedestals for uncompression:"; |
354 |
mocchiut |
1.1 |
if(trk_calib_used==104 && last_trk_calib_used!=104){ |
355 |
|
|
|
356 |
pam-fi |
1.5 |
if(p->VerboseMode() )cout << " >> Loading default calibration " << endl; |
357 |
pam-fi |
1.7 |
if (q4.Query_GL_PARAM(runheadtime,7,dbc) )throw -52; |
358 |
pam-fi |
1.2 |
pedsigbad_.FillTCalibFrom(q4.PATH+q4.NAME); |
359 |
|
|
|
360 |
|
|
}else if( (trk_calib_used==1 | trk_calib_used==2) && last_trk_calib_used==104 ){ |
361 |
|
|
|
362 |
|
|
if(p->VerboseMode()) cout << ">> Re-loading on-line calibration " << endl; |
363 |
pam-fi |
1.7 |
pedsigbad_.FillTCalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
364 |
pam-fi |
1.2 |
}else{ |
365 |
|
|
if(p->VerboseMode()) cout << ">> Using on-line calibration " << endl; |
366 |
|
|
}; |
367 |
|
|
if( p->DebugMode() ) for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
368 |
|
|
last_trk_calib_used = trk_calib_used; |
369 |
|
|
|
370 |
mocchiut |
1.1 |
// ============================================================= |
371 |
|
|
// retrieve information about parameters to process LEVEL2 |
372 |
|
|
// ============================================================= |
373 |
|
|
// |
374 |
|
|
// magnetic field |
375 |
|
|
// |
376 |
pam-fi |
1.2 |
if(p->VerboseMode()) cout << "Loading parameter files : "<< endl; |
377 |
|
|
|
378 |
mocchiut |
1.1 |
if(runheadtime > B_time){ |
379 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,1,dbc) )throw -52; |
380 |
mocchiut |
1.1 |
B_time = q4.TO_TIME; |
381 |
|
|
l2_event->LoadField(q4.PATH+q4.NAME); |
382 |
pam-fi |
1.2 |
// l2_event->LoadField(q4.PATH+q4.NAME); |
383 |
mocchiut |
1.1 |
if(path_.error) throw -215; |
384 |
|
|
}; |
385 |
|
|
// |
386 |
|
|
// mip conversion parameters |
387 |
|
|
// |
388 |
|
|
if(runheadtime > mip_time){ |
389 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,2,dbc) )throw -52; |
390 |
mocchiut |
1.1 |
mip_time = q4.TO_TIME; |
391 |
|
|
path_.FillWith(q4.PATH+q4.NAME); |
392 |
|
|
readmipparam_(); |
393 |
|
|
if(path_.error) throw -212; |
394 |
|
|
}; |
395 |
|
|
// |
396 |
|
|
// charge correlation parameters |
397 |
|
|
// |
398 |
|
|
if(runheadtime > charge_time){ |
399 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,3,dbc) )throw -52; |
400 |
mocchiut |
1.1 |
charge_time = q4.TO_TIME; |
401 |
|
|
path_.FillWith(q4.PATH+q4.NAME); |
402 |
|
|
readchargeparam_(); |
403 |
|
|
if(path_.error) throw -213; |
404 |
|
|
}; |
405 |
|
|
// |
406 |
|
|
// eta p.f.a. parameters |
407 |
|
|
// |
408 |
|
|
if(runheadtime > eta_time){ |
409 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,4,dbc) )throw -52; |
410 |
mocchiut |
1.1 |
eta_time = q4.TO_TIME; |
411 |
|
|
path_.FillWith(q4.PATH+q4.NAME); |
412 |
|
|
readetaparam_(); |
413 |
|
|
if(path_.error) throw -214; |
414 |
|
|
}; |
415 |
|
|
// |
416 |
|
|
// alignment parameters |
417 |
|
|
// |
418 |
|
|
if(runheadtime > align_time){ |
419 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,5,dbc) )throw -52; |
420 |
mocchiut |
1.1 |
align_time = q4.TO_TIME; |
421 |
|
|
path_.FillWith(q4.PATH+q4.NAME); |
422 |
|
|
readalignparam_(); |
423 |
|
|
if(path_.error) throw -211; |
424 |
|
|
}; |
425 |
|
|
// |
426 |
|
|
// viking mask |
427 |
|
|
// |
428 |
|
|
if(runheadtime > mask_time){ |
429 |
pam-fi |
1.7 |
if( q4.Query_GL_PARAM(runheadtime,6,dbc) )throw -52; |
430 |
mocchiut |
1.1 |
mask_time = q4.TO_TIME; |
431 |
|
|
path_.FillWith(q4.PATH+q4.NAME); |
432 |
|
|
readvkmask_(); |
433 |
|
|
if(path_.error) throw -210; |
434 |
|
|
}; |
435 |
|
|
|
436 |
|
|
// |
437 |
|
|
// ==================================================== |
438 |
|
|
// start looping on events cointained in the data file |
439 |
|
|
// ==================================================== |
440 |
pam-fi |
1.7 |
for (UInt_t re = evfrom; re < evfrom+nevents; re++){ |
441 |
mocchiut |
1.1 |
|
442 |
|
|
ev_count++; |
443 |
|
|
|
444 |
pam-fi |
1.7 |
if ( p->DebugMode() && re%100 == 0 && re > 0 ) cout << "."; |
445 |
mocchiut |
1.1 |
|
446 |
pam-fi |
1.7 |
b_trk->GetEntry(re); |
447 |
|
|
b_header->GetEntry(re); |
448 |
|
|
pscu = header->GetPscuHeader(); |
449 |
|
|
|
450 |
|
|
if ( dbtime->DBabsTime(pscu->GetOrbitalTime()) > runtrailtime || dbtime->DBabsTime(pscu->GetOrbitalTime()) < runheadtime) { |
451 |
|
|
|
452 |
|
|
if (p->VerboseMode()) printf(" TrkCore - WARNING: event outside the run time window, skipping it\n"); |
453 |
|
|
|
454 |
|
|
}else{ |
455 |
|
|
|
456 |
|
|
p->ProcessEvent(l0_event); |
457 |
|
|
|
458 |
|
|
// ---------------- |
459 |
|
|
// LEVEL1 output |
460 |
|
|
// ---------------- |
461 |
|
|
if(p->get1){ |
462 |
|
|
if(p->ifroot1){ // root |
463 |
|
|
l1_event->Clear(); |
464 |
|
|
l1_event->SetFromLevel1Struct(&level1event_); |
465 |
|
|
// t_level1->Fill(); |
466 |
|
|
}else{ // hbook |
467 |
|
|
throw -299; |
468 |
|
|
}; |
469 |
|
|
}; |
470 |
|
|
// ---------------- |
471 |
|
|
// LEVEL2 output |
472 |
|
|
// ---------------- |
473 |
|
|
if(p->get2){ |
474 |
|
|
l2_event->Clear(); |
475 |
|
|
if(p->get1) l2_event->SetFromLevel2Struct(&level2event_,l1_event);//set references to level1 |
476 |
|
|
else l2_event->SetFromLevel2Struct(&level2event_); |
477 |
pam-fi |
1.10 |
// l2_event->Dump(); |
478 |
pam-fi |
1.7 |
t_level2->Fill(); |
479 |
pam-fi |
1.6 |
}; |
480 |
mocchiut |
1.1 |
}; |
481 |
|
|
}; // end loop on events |
482 |
pam-fi |
1.2 |
if(p->VerboseMode())cout << " >>> processed "<< ev_count <<" events"<< endl; |
483 |
pam-fi |
1.7 |
|
484 |
|
|
delete dbtime; |
485 |
|
|
|
486 |
|
|
}; // end loop on runs |
487 |
|
|
|
488 |
mocchiut |
1.1 |
// ------------------------------------------------------------ |
489 |
|
|
// if reprocessing one run, copy all the events AFTER the run |
490 |
|
|
// ------------------------------------------------------------ |
491 |
|
|
if( !(p->standalone) ){ |
492 |
|
|
for(UInt_t i=runinfo->GetLastEntry()+1; i<runinfo->GetFileEntries(); i++){ |
493 |
|
|
t_clone->GetEntry(i); |
494 |
|
|
*l2_event = *l2_clone; |
495 |
|
|
t_level2->Fill(); |
496 |
|
|
l2_event->Clear(); |
497 |
|
|
// COPY COPY COPY |
498 |
|
|
}; |
499 |
|
|
}; |
500 |
|
|
// --------------- |
501 |
|
|
// close the files |
502 |
|
|
// --------------- |
503 |
pam-fi |
1.8 |
// if(p->get1){ |
504 |
|
|
// if(p->ifroot1){ // root |
505 |
pam-fi |
1.7 |
// cout << "Creating file: "<<p->file1<< endl; |
506 |
|
|
// f1 = new TFile(p->file1,"RECREATE"); |
507 |
|
|
// t_level1->Write(); |
508 |
|
|
// if( f1->IsOpen() ) f1->Close(); |
509 |
|
|
// if( t_level1 )t_level1->Delete(); //delete new tree from memory |
510 |
pam-fi |
1.8 |
// |
511 |
|
|
// }else{ // hbook |
512 |
|
|
// } |
513 |
|
|
// cout << "Done."<<endl; |
514 |
|
|
// }; |
515 |
mocchiut |
1.1 |
if(p->get2){ |
516 |
|
|
// if(p->ifroot2){ // root |
517 |
pam-fi |
1.6 |
if( t_clone )t_clone->Delete("all");//delete old tree from file |
518 |
|
|
if( !(p->standalone) )runinfo->Close(); |
519 |
|
|
// gDirectory->pwd(); |
520 |
|
|
// gDirectory->ls(); |
521 |
|
|
f2->Write("Tracker"); |
522 |
|
|
if( t_level2 )t_level2->Delete(); //delete new tree from memory |
523 |
mocchiut |
1.1 |
|
524 |
|
|
// }else{ // hbook |
525 |
|
|
// } |
526 |
pam-fi |
1.6 |
}; |
527 |
|
|
|
528 |
|
|
if( f0->IsOpen() ) f0->Close(); |
529 |
pam-fi |
1.2 |
if( f0_c->IsOpen() )f0_c->Close(); |
530 |
pam-fi |
1.6 |
|
531 |
pam-fi |
1.10 |
l1_event->Delete(); |
532 |
|
|
l2_event->Delete(); |
533 |
|
|
l2_clone->Delete(); |
534 |
pam-fi |
1.2 |
|
535 |
|
|
return(p->ostatus); |
536 |
mocchiut |
1.1 |
} |
537 |
|
|
|