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 |
pam-fi |
1.11 |
#include <TBenchmark.h> |
27 |
pam-ts |
1.46 |
#include <TStopwatch.h> |
28 |
pam-fi |
1.11 |
|
29 |
mocchiut |
1.1 |
// ......................................................... |
30 |
|
|
// other general header files |
31 |
|
|
// ......................................................... |
32 |
|
|
#include <fstream> |
33 |
|
|
#include <iostream> |
34 |
|
|
// ......................................................... |
35 |
|
|
// files in the inc directory |
36 |
|
|
// ......................................................... |
37 |
|
|
#include <RunInfo.h> |
38 |
|
|
#include <GLTables.h> |
39 |
|
|
#include <TrkVerl2.h> |
40 |
|
|
#include <TrkProcess.h> |
41 |
pam-fi |
1.2 |
//#include <TrkStruct.h> |
42 |
mocchiut |
1.1 |
#include <TrkLevel2.h> |
43 |
pam-fi |
1.6 |
#include <TrkLevel1.h> |
44 |
mocchiut |
1.1 |
#include <TrkLevel0.h> |
45 |
pam-fi |
1.15 |
#include <TrkHough.h> |
46 |
mocchiut |
1.1 |
// ......................................................... |
47 |
|
|
// YODA header files |
48 |
|
|
// ......................................................... |
49 |
|
|
#include <PamelaRun.h> |
50 |
pam-fi |
1.7 |
//#include <RegistryEvent.h> |
51 |
mocchiut |
1.1 |
#include <physics/tracker/TrackerEvent.h> |
52 |
|
|
#include <CalibTrk1Event.h> |
53 |
|
|
#include <CalibTrk2Event.h> |
54 |
mocchiut |
1.42 |
// |
55 |
mocchiut |
1.43 |
// Calorimeter level1 class header and definitions |
56 |
mocchiut |
1.42 |
// |
57 |
|
|
#include <CaloLevel1.h> //EM |
58 |
mocchiut |
1.43 |
// |
59 |
|
|
// ToF level2 class header and definitions |
60 |
|
|
// |
61 |
|
|
#include <ToFLevel2.h> //EM |
62 |
pam-fi |
1.45 |
// |
63 |
|
|
// Extended tracking |
64 |
|
|
// |
65 |
|
|
#include <ExtTrkingAlg.h> //EV |
66 |
pam-fi |
1.2 |
|
67 |
mocchiut |
1.1 |
// ......................................................... |
68 |
|
|
// namespaces |
69 |
|
|
// ......................................................... |
70 |
|
|
using namespace std; |
71 |
|
|
using namespace pamela; |
72 |
|
|
// ================================================================================ |
73 |
|
|
// |
74 |
|
|
// |
75 |
|
|
// ================================================================================ |
76 |
|
|
/** |
77 |
|
|
* \brief Tracker data reduction routine. |
78 |
|
|
* |
79 |
|
|
* It performs data reduction LEVEL0->LEVEL1->LEVEL2, producing LEVEL1 and or LEVEL2 output, in ROOT or HBOOK format. |
80 |
|
|
* Input parameters: |
81 |
|
|
* @param run id of the run to be processed (if run=0 a whole file is reprocessed) |
82 |
|
|
* @param dbc pointer to BD server |
83 |
|
|
* @param file1 output LEVEL1 file name (null if no LEVEL1 output is required) |
84 |
|
|
* @param file2 output LEVEL2 file name (null if no LEVEL2 output is required) |
85 |
|
|
* @param standalone (flag to run the program in standalone mode, that is without reading RunInfo) |
86 |
|
|
*/ |
87 |
|
|
//short int TrkCore(Int_t run, TSQLServer *dbc, TString file1, TString file2, Bool_t standalone) |
88 |
mocchiut |
1.31 |
//int TrkCore(UInt_t run, TFile *f2, TSQLServer *dbc, int ncustom, char*vcustom[]) // EMILIANO |
89 |
|
|
int TrkCore(UInt_t run, TFile *f2, GL_TABLES *glt, int ncustom, char*vcustom[]) // EMILIANO |
90 |
mocchiut |
1.1 |
{ |
91 |
|
|
// --------------------------- |
92 |
|
|
// Define some basic variables |
93 |
|
|
// --------------------------- |
94 |
|
|
|
95 |
pizzolot |
1.36 |
TString filename = ""; |
96 |
pam-fi |
1.7 |
Long64_t nentries = 0LL; |
97 |
pam-fi |
1.2 |
|
98 |
mocchiut |
1.1 |
// LEVEL0 input |
99 |
|
|
TFile *f0 = 0; |
100 |
|
|
TTree *physicsTree = 0; |
101 |
|
|
TBranch *b_trk = 0; |
102 |
|
|
TBranch *b_header = 0; |
103 |
|
|
EventHeader *header = 0; |
104 |
|
|
PscuHeader *pscu = 0; |
105 |
pam-fi |
1.22 |
TrkLevel0 *l0_event = new TrkLevel0(); |
106 |
mocchiut |
1.1 |
// RunInfo |
107 |
|
|
ItoRunInfo *runinfo = 0; |
108 |
pam-fi |
1.7 |
TArrayI *runlist = 0; |
109 |
|
|
UInt_t from_run; |
110 |
|
|
UInt_t to_run; |
111 |
mocchiut |
1.44 |
// Bool_t reprocessing = false; // EM GCC 4.7 |
112 |
mocchiut |
1.1 |
//LEVEL2 output - ROOT |
113 |
|
|
TTree *t_level2 = 0; |
114 |
|
|
TTree *t_clone = 0; |
115 |
|
|
TrkLevel2 *l2_event = new TrkLevel2(); |
116 |
|
|
TrkLevel2 *l2_clone = new TrkLevel2(); |
117 |
pam-ts |
1.52 |
|
118 |
mocchiut |
1.49 |
TrkLevel2 *l2_event_nuclei = NULL; // EM bug new TrkLevel2(); |
119 |
mocchiut |
1.47 |
// EM TrkLevel2 *l2_clone_nuclei = new TrkLevel2(); |
120 |
pam-fi |
1.13 |
//LEVEL1 output - ROOT |
121 |
pam-ts |
1.46 |
TrkLevel1 *l1_event = new TrkLevel1(); |
122 |
mocchiut |
1.49 |
TrkLevel1 *l1_event_nuclei = NULL; // EM, bug new TrkLevel1(); |
123 |
pam-fi |
1.15 |
TrkHough *lh_event = new TrkHough(); |
124 |
mocchiut |
1.42 |
|
125 |
pam-fi |
1.45 |
//Extended tracking: |
126 |
|
|
TTree *t_cal = NULL; |
127 |
|
|
TTree *t_tof = NULL; |
128 |
|
|
ExtTrkingAlg *trkAlg = NULL; |
129 |
pam-ts |
1.46 |
ExtTrkingAlg *trkAlg_nuclei = NULL; |
130 |
pam-fi |
1.45 |
TClonesArray *trk_array = NULL; |
131 |
pam-ts |
1.46 |
TClonesArray *trk_array_nuclei = NULL; |
132 |
|
|
|
133 |
pam-fi |
1.45 |
CaloLevel1 *cl1 = NULL; |
134 |
|
|
ToFLevel2 *tl2 = NULL; |
135 |
pam-ts |
1.46 |
|
136 |
|
|
typedef struct { |
137 |
|
|
|
138 |
|
|
Int_t nTrk; |
139 |
|
|
Int_t nTrkNuc; |
140 |
|
|
Int_t nTrkExt; |
141 |
|
|
Int_t nTrkExtNuc; |
142 |
|
|
|
143 |
|
|
Int_t nCl; |
144 |
|
|
Int_t nClCut; |
145 |
|
|
|
146 |
|
|
Float_t tTrk; |
147 |
|
|
Float_t tTrkExt; |
148 |
|
|
Float_t tTrkNuc; |
149 |
|
|
|
150 |
pam-ts |
1.52 |
|
151 |
|
|
void Dump(){ |
152 |
|
|
cout <<" nTrk"<<setw(5)<<nTrk ; |
153 |
|
|
cout <<" nTrkNuc"<<setw(5)<<nTrkNuc ; |
154 |
|
|
cout <<" nTrkExt"<<setw(5)<< nTrkExt; |
155 |
|
|
cout <<" nTrkExtNuc"<<setw(5)<<nTrkExtNuc ; |
156 |
|
|
cout <<" nCl"<<setw(5)<<nCl ; |
157 |
|
|
cout <<" nClCut"<<setw(5)<<nClCut ; |
158 |
|
|
cout <<" tTrk"<<setw(15)<<tTrk ; |
159 |
|
|
cout <<" tTrkExt"<<setw(15)<<tTrkExt; |
160 |
|
|
cout <<" tTrkNuc"<<setw(15)<<tTrkNuc ; |
161 |
|
|
cout << endl; |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
|
165 |
pam-ts |
1.46 |
} TrkWatch; |
166 |
|
|
TrkWatch trkWatch; |
167 |
|
|
TTree *tWatch = NULL; |
168 |
|
|
|
169 |
pam-ts |
1.48 |
Int_t extAlgFlag=0; |
170 |
pam-ts |
1.46 |
|
171 |
mocchiut |
1.1 |
// ----------------------- |
172 |
|
|
// ----------------------- |
173 |
|
|
// Handle input parameters |
174 |
|
|
// (data) |
175 |
|
|
// |
176 |
|
|
// - open/create output files, determining the environment root/hbook from the estension |
177 |
|
|
// - create the level1/level2 tree+branch/nt-uple |
178 |
|
|
// ----------------------- |
179 |
|
|
// ----------------------- |
180 |
|
|
TrkProcess *p = new TrkProcess(run,f2); |
181 |
pam-fi |
1.26 |
if( p->HandleCustomPar(ncustom,vcustom) )return(p->ostatus);; |
182 |
pam-fi |
1.25 |
if( TrkParams::VerboseMode() )p->Dump(); |
183 |
pam-ts |
1.46 |
// p->Dump(); |
184 |
mocchiut |
1.1 |
|
185 |
|
|
// =================================== |
186 |
|
|
// Open/Create level2 output file |
187 |
|
|
// =================================== |
188 |
|
|
if(p->get2){ |
189 |
pam-fi |
1.13 |
//------------------------------------------- |
190 |
|
|
// read RunInfo |
191 |
|
|
//------------------------------------------- |
192 |
|
|
if(!(p->standalone)){ |
193 |
|
|
// Open "RunInfo" tree and get list of run |
194 |
|
|
runinfo = new ItoRunInfo(f2); |
195 |
|
|
char *trkversion = TrkInfo(false); |
196 |
mocchiut |
1.57 |
int runinfo_error = runinfo->Update(run,"TRK",trkversion); // EMQUI |
197 |
pam-fi |
1.13 |
if( runinfo_error ) throw runinfo_error; |
198 |
|
|
runlist = runinfo->GetRunList(); |
199 |
mocchiut |
1.44 |
// reprocessing = runinfo->IsReprocessing();//???? |
200 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
201 |
pam-fi |
1.13 |
cout << "#events "<< runinfo->GetFileEntries() << endl;// #events in the file |
202 |
|
|
cout << "#runs "<< runinfo->GetRunEntries() << endl;// #runs in the file |
203 |
|
|
cout << "1-st run "<< runlist->At(0) << endl; |
204 |
|
|
cout << "last run "<< runlist->At(runinfo->GetRunEntries()-1) << endl; |
205 |
|
|
cout << "1-st event "<< runinfo->GetFirstEntry() << endl;// first event of our run |
206 |
|
|
cout << "last event+1 "<< runinfo->GetLastEntry() << endl;// first event AFTER the last event of our run |
207 |
mocchiut |
1.44 |
// cout << "reprocessing "<< runinfo->IsReprocessing() << endl << endl; |
208 |
pam-fi |
1.13 |
}; |
209 |
|
|
}; |
210 |
|
|
//------------------------------------------- |
211 |
|
|
// |
212 |
pam-ts |
1.46 |
//------------------------------------------- |
213 |
pam-fi |
1.13 |
// Take (if present) the old Tracker tree |
214 |
|
|
t_clone = (TTree*)f2->Get("Tracker"); |
215 |
mocchiut |
1.51 |
if( t_clone != NULL ){ |
216 |
|
|
t_clone->SetBranchAddress("TrkLevel2",&l2_clone); |
217 |
mocchiut |
1.53 |
// t_clone->SetMaxVirtualSize(2500000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
218 |
mocchiut |
1.51 |
t_clone->SetAutoSave(900000000000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
219 |
|
|
} |
220 |
pam-ts |
1.46 |
|
221 |
pam-fi |
1.13 |
// Create NEW Tracker tree |
222 |
mocchiut |
1.50 |
t_level2 = new TTree("Tracker-new","PAMELA tracker level2 data "); |
223 |
mocchiut |
1.53 |
// t_level2->SetMaxVirtualSize(2500000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
224 |
mocchiut |
1.51 |
t_level2->SetAutoSave(900000000000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
225 |
pam-fi |
1.21 |
l2_event->Set(); // ****NBNBNBN***** |
226 |
pam-fi |
1.13 |
t_level2->Branch("TrkLevel2","TrkLevel2",&l2_event); |
227 |
pam-ts |
1.46 |
|
228 |
pam-fi |
1.13 |
if(p->get1){ |
229 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())cout << endl << "Requested LEVEL1 output" << endl; |
230 |
mocchiut |
1.51 |
l1_event->Set(); // ****NBNBNBN***** |
231 |
pam-fi |
1.13 |
t_level2->Branch("TrkLevel1","TrkLevel1",&l1_event); |
232 |
pam-fi |
1.16 |
} |
233 |
|
|
if(p->geth){ |
234 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())cout << endl << "Requested Hough-Transform output" << endl; |
235 |
pam-fi |
1.16 |
t_level2->Branch("TrkHough","TrkHough",&lh_event); |
236 |
pam-fi |
1.7 |
}; |
237 |
pam-ts |
1.46 |
if(p->getn){ |
238 |
|
|
if(TrkParams::VerboseMode())cout << endl << "Requested nuclei-algorythm output" << endl; |
239 |
|
|
if(!l2_event_nuclei)l2_event_nuclei = new TrkLevel2(); |
240 |
mocchiut |
1.49 |
if(!l1_event_nuclei)l1_event_nuclei = new TrkLevel1(); // EM bug |
241 |
pam-ts |
1.46 |
l2_event_nuclei->Set(); // ****NBNBNBN***** |
242 |
|
|
t_level2->Branch("TrackNuclei",l2_event_nuclei->GetPointerToTrackArray()); |
243 |
|
|
|
244 |
|
|
} |
245 |
|
|
// ========================================================= |
246 |
|
|
// extended tracking algorythm output |
247 |
|
|
// ========================================================= |
248 |
|
|
if(p->gete){ |
249 |
pam-ts |
1.52 |
|
250 |
mocchiut |
1.54 |
if(TrkParams::VerboseMode()) cout <<"Creating extended tracking algorythm "<<p->extAlgID<<endl; |
251 |
pam-ts |
1.46 |
trkAlg = new ExtTrkingAlg(p->extAlgID);// create the algorythm |
252 |
|
|
trk_array = trkAlg->GetTrackArray(); // get the track array |
253 |
|
|
if(!trk_array)throw -206; |
254 |
|
|
t_level2->Branch("RecoveredTrack",trkAlg->GetPointerToTrackArray());// put it in a branch |
255 |
|
|
if(p->getn){ |
256 |
mocchiut |
1.49 |
if(TrkParams::VerboseMode())cout << endl << "Requested extended nuclei-algorythm output" << endl; |
257 |
pam-ts |
1.46 |
trkAlg_nuclei = new ExtTrkingAlg(p->extAlgID);// create the algorythm for nuclei |
258 |
|
|
trk_array_nuclei = trkAlg_nuclei->GetTrackArray();// get the track array |
259 |
|
|
if(!trk_array_nuclei)throw -206; |
260 |
|
|
t_level2->Branch("RecoveredTrackNuclei",trkAlg_nuclei->GetPointerToTrackArray()); // put it in a branch |
261 |
|
|
} |
262 |
pam-ts |
1.48 |
t_level2->Branch("extAlgFlag",&extAlgFlag,"extAlgFlag/I"); |
263 |
|
|
// ------------------------ |
264 |
pam-ts |
1.46 |
// calorimeter and tof tree |
265 |
pam-ts |
1.48 |
// ------------------------ |
266 |
pam-ts |
1.46 |
t_cal = (TTree*)f2->Get("Calorimeter"); |
267 |
|
|
if(!t_cal)throw -206; |
268 |
|
|
cl1 = new CaloLevel1(); |
269 |
|
|
t_cal->SetBranchAddress("CaloLevel1",&cl1); |
270 |
mocchiut |
1.51 |
t_cal->SetAutoSave(900000000000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
271 |
mocchiut |
1.53 |
// t_cal->SetMaxVirtualSize(2500000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
272 |
pam-ts |
1.46 |
|
273 |
|
|
|
274 |
|
|
t_tof = (TTree*)f2->Get("ToF"); |
275 |
|
|
if(!t_tof)throw -206; |
276 |
|
|
tl2 = new ToFLevel2(); |
277 |
|
|
t_tof->SetBranchAddress("ToFLevel2",&tl2); |
278 |
mocchiut |
1.51 |
t_tof->SetAutoSave(900000000000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
279 |
mocchiut |
1.53 |
// t_tof->SetMaxVirtualSize(2500000000LL); // EM residual Tracker-new tree in level2 files when NEVENTS is big |
280 |
pam-ts |
1.46 |
|
281 |
|
|
} |
282 |
|
|
if(p->watch){ |
283 |
|
|
|
284 |
|
|
// f2->cd(); |
285 |
|
|
tWatch = new TTree("TrkWatch"," Tracking timing info"); |
286 |
|
|
|
287 |
|
|
tWatch->Branch("nCl",&trkWatch.nCl,"nCl/I"); |
288 |
|
|
tWatch->Branch("nClCut",&trkWatch.nClCut,"nClCut/I"); |
289 |
|
|
|
290 |
|
|
tWatch->Branch("nTrk",&trkWatch.nTrk,"nTrk/I"); |
291 |
|
|
tWatch->Branch("nTrkExt",&trkWatch.nTrkExt,"nTrkExt/I"); |
292 |
|
|
tWatch->Branch("nTrkNuc",&trkWatch.nTrkNuc,"nTrkNuc/I"); |
293 |
|
|
tWatch->Branch("nTrkExtNuc",&trkWatch.nTrkExtNuc,"nTrkExtExt/I"); |
294 |
|
|
|
295 |
|
|
tWatch->Branch("tTrk",&trkWatch.tTrk,"tTrk/F"); |
296 |
|
|
tWatch->Branch("tTrkExt",&trkWatch.tTrkExt,"tTrkExt/F"); |
297 |
|
|
tWatch->Branch("tTrkNuc",&trkWatch.tTrkNuc,"tTrkNuc/F"); |
298 |
|
|
|
299 |
|
|
|
300 |
|
|
} |
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
pam-fi |
1.13 |
}; |
306 |
pam-fi |
1.45 |
|
307 |
pam-ts |
1.46 |
|
308 |
pam-fi |
1.45 |
|
309 |
mocchiut |
1.1 |
|
310 |
|
|
// ------------------------------------------- |
311 |
|
|
// define runs to be processed/reprocessed |
312 |
|
|
// ------------------------------------------- |
313 |
|
|
if(run == 0){ |
314 |
pam-fi |
1.13 |
// reprocessing ALL runs |
315 |
|
|
if(p->standalone)throw -298; // reprocessing not implemented |
316 |
|
|
from_run = runlist->At(0); |
317 |
|
|
to_run = runlist->At(runinfo->GetRunEntries()-1); |
318 |
mocchiut |
1.1 |
}else{ |
319 |
|
|
// processing/reprocessing ONE single run |
320 |
pam-fi |
1.13 |
from_run = run; |
321 |
|
|
to_run = run; |
322 |
mocchiut |
1.1 |
}; |
323 |
|
|
|
324 |
|
|
// |
325 |
|
|
// init event counter |
326 |
|
|
// |
327 |
|
|
Int_t ev_count =0; |
328 |
mocchiut |
1.57 |
Int_t pr_count =0; |
329 |
mocchiut |
1.1 |
// |
330 |
|
|
// create query-results objects |
331 |
|
|
// |
332 |
pam-fi |
1.7 |
GL_RUN q1 = GL_RUN(); |
333 |
mocchiut |
1.1 |
GL_TRK_CALIB q2 = GL_TRK_CALIB(); |
334 |
|
|
GL_ROOT q3 = GL_ROOT(); |
335 |
|
|
GL_PARAM q4 = GL_PARAM(); |
336 |
|
|
|
337 |
|
|
// ------------------------------------------------------------ |
338 |
|
|
// if reprocessing one run, copy all the events BEFORE the run |
339 |
|
|
// ------------------------------------------------------------ |
340 |
|
|
if( !(p->standalone) ){ |
341 |
mocchiut |
1.50 |
if(TrkParams::VerboseMode()) cout << " Reprocessing one run: "<<run<< endl; |
342 |
pam-fi |
1.13 |
for(UInt_t i=0; i<runinfo->GetFirstEntry(); i++){ |
343 |
mocchiut |
1.37 |
if ( t_clone->GetEntry(i) <= 0 ) throw -36;// EM |
344 |
pam-ts |
1.46 |
// COPY COPY COPY |
345 |
pam-fi |
1.13 |
*l2_event = *l2_clone; |
346 |
|
|
t_level2->Fill(); |
347 |
|
|
l2_event->Clear(); |
348 |
|
|
}; |
349 |
mocchiut |
1.1 |
}; |
350 |
|
|
// ------------------------------------------------------------ |
351 |
|
|
// ------------------------------------------------------------ |
352 |
pam-fi |
1.25 |
// START LOOP OVER RUNS TO PROCESS/REPROCESS |
353 |
mocchiut |
1.1 |
// ------------------------------------------------------------ |
354 |
|
|
// ------------------------------------------------------------ |
355 |
pam-fi |
1.7 |
for(UInt_t idRun = from_run; idRun <= to_run; idRun++){ |
356 |
mocchiut |
1.1 |
|
357 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()) cout << endl<<" ========================= Run: "<< idRun << endl; |
358 |
pam-fi |
1.7 |
UInt_t runheadtime = 0; |
359 |
|
|
UInt_t runtrailtime = 0; |
360 |
pam-fi |
1.32 |
UInt_t runheadobt = 0; |
361 |
|
|
UInt_t runtrailobt = 0; |
362 |
mocchiut |
1.41 |
UInt_t abstime = 0; |
363 |
mocchiut |
1.1 |
UInt_t evfrom = 0; |
364 |
|
|
UInt_t evto = 0; |
365 |
pam-fi |
1.7 |
UInt_t nevents = 0; |
366 |
|
|
Int_t id_root_l0 =-1; |
367 |
mocchiut |
1.1 |
Int_t trk_calib_used = 0; |
368 |
pam-fi |
1.7 |
|
369 |
mocchiut |
1.31 |
TString host = glt->CGetHost(); // EMILIANO |
370 |
|
|
TString user = glt->CGetUser(); // EMILIANO |
371 |
|
|
TString psw = glt->CGetPsw(); // EMILIANO |
372 |
|
|
// TString host = "mysql://localhost/pamelaprod"; |
373 |
|
|
// TString user = "anonymous"; |
374 |
|
|
// TString psw = ""; |
375 |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
376 |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
377 |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
378 |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
379 |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
380 |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
381 |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
382 |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
383 |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
384 |
mocchiut |
1.29 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
385 |
mocchiut |
1.31 |
stringstream myquery; // EMILIANO |
386 |
|
|
myquery.str(""); // EMILIANO |
387 |
mocchiut |
1.58 |
myquery << "SET time_zone='+0:00';"; // EMILIANO |
388 |
mocchiut |
1.39 |
delete dbc->Query(myquery.str().c_str()); // EMILIANO |
389 |
mocchiut |
1.58 |
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';");// EM |
390 |
mocchiut |
1.1 |
if(p->standalone){ |
391 |
|
|
// ============================== |
392 |
|
|
// first query: retrieve run info |
393 |
|
|
// ============================== |
394 |
pam-fi |
1.7 |
if (q1.Query_GL_RUN(idRun,dbc) )throw -50; |
395 |
|
|
id_root_l0 = q1.ID_ROOT_L0; |
396 |
mocchiut |
1.1 |
runheadtime = q1.RUNHEADER_TIME; |
397 |
|
|
runtrailtime = q1.RUNTRAILER_TIME; |
398 |
pam-fi |
1.32 |
runheadobt = q1.RUNHEADER_OBT; |
399 |
|
|
runtrailobt = q1.RUNTRAILER_OBT; |
400 |
pam-fi |
1.7 |
evfrom = q1.EV_FROM; |
401 |
|
|
evto = q1.EV_TO; |
402 |
pam-fi |
1.13 |
nevents = q1.NEVENTS; |
403 |
|
|
trk_calib_used = q1.TRK_CALIB_USED; |
404 |
mocchiut |
1.1 |
}else{ |
405 |
|
|
// ============================== |
406 |
|
|
// get run info from RunInfo tree |
407 |
|
|
// ============================== |
408 |
pam-fi |
1.3 |
int runinfo_error = runinfo->GetRunInfo(idRun); |
409 |
pam-fi |
1.7 |
if( runinfo_error ) throw runinfo_error; |
410 |
|
|
id_root_l0 = runinfo->ID_ROOT_L0; |
411 |
mocchiut |
1.1 |
runheadtime = runinfo->RUNHEADER_TIME; |
412 |
|
|
runtrailtime = runinfo->RUNTRAILER_TIME; |
413 |
pam-fi |
1.32 |
runheadobt = runinfo->RUNHEADER_OBT; |
414 |
|
|
runtrailobt = runinfo->RUNTRAILER_OBT; |
415 |
pam-fi |
1.7 |
evfrom = runinfo->EV_FROM; |
416 |
|
|
evto = runinfo->EV_TO; |
417 |
pam-fi |
1.13 |
nevents = runinfo->NEVENTS; |
418 |
|
|
trk_calib_used = runinfo->TRK_CALIB_USED; |
419 |
pam-fi |
1.24 |
|
420 |
mocchiut |
1.1 |
}; |
421 |
pam-fi |
1.24 |
|
422 |
mocchiut |
1.1 |
// |
423 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
424 |
pam-fi |
1.7 |
cout << "ROOT file ID "<< id_root_l0 << endl; |
425 |
mocchiut |
1.1 |
cout << "RunHeader time "<< runheadtime << endl; |
426 |
|
|
cout << "RunTrailer time "<< runtrailtime << endl; |
427 |
pam-fi |
1.7 |
cout << " from event "<< evfrom << endl; |
428 |
|
|
cout << " to event "<< evto << endl; |
429 |
pam-fi |
1.24 |
cout << " num. events "<< nevents << endl; |
430 |
|
|
cout << "trk-calibration used "<< trk_calib_used << endl; |
431 |
mocchiut |
1.1 |
}; |
432 |
|
|
// ======================================================== |
433 |
|
|
// second query: search the LEVEL0 file that contains idRun |
434 |
|
|
// ======================================================== |
435 |
|
|
TString lastfilename = filename; |
436 |
pam-fi |
1.7 |
if( q3.Query_GL_ROOT(id_root_l0,dbc) )throw -51; |
437 |
mocchiut |
1.1 |
filename = q3.PATH + q3.NAME; |
438 |
|
|
// ======================================================== |
439 |
|
|
// Open the input LEVEL0 data file |
440 |
|
|
// ======================================================== |
441 |
|
|
if(filename.CompareTo(lastfilename)){ |
442 |
|
|
if(!lastfilename.IsNull())f0->Close(); |
443 |
|
|
//if( debug ) cout << "Opening LEVEL0 file: "<< filename << endl; |
444 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()) cout << "Opening LEVEL0 file: "<< filename << endl; |
445 |
pam-fi |
1.2 |
FileStat_t t; |
446 |
|
|
if( gSystem->GetPathInfo(filename.Data(),t) )throw -6; |
447 |
mocchiut |
1.39 |
if ( f0 ) f0->Close(); |
448 |
mocchiut |
1.1 |
f0 = new TFile(filename); |
449 |
|
|
if ( !f0 ) throw -6; |
450 |
|
|
physicsTree = (TTree*)f0->Get("Physics"); if(!physicsTree) throw -7; |
451 |
|
|
b_header = physicsTree ->GetBranch("Header"); if(!b_header ) throw -8; |
452 |
|
|
b_trk = physicsTree ->GetBranch("Tracker"); if(!b_trk ) throw -203; |
453 |
pam-fi |
1.22 |
l0_event->Set(); |
454 |
|
|
physicsTree->SetBranchAddress("Tracker" ,l0_event->GetPointerToTrackerEvent()); |
455 |
mocchiut |
1.1 |
physicsTree->SetBranchAddress("Header",&header); |
456 |
|
|
|
457 |
pam-fi |
1.7 |
nentries = physicsTree->GetEntries(); |
458 |
mocchiut |
1.34 |
if ( nentries < 1 && nevents ) throw -11; // EMILIANO: go on if the file is empty, why not? in principle we should not have any event to process but if the case the next line will take care of exiting; exit only if the file is empty but nevents is not zero |
459 |
mocchiut |
1.33 |
if ( nentries < (evto+1) && nevents > 0 ) throw -12; // EMILIANO: if NEVENTS = 0 and the file is empty everything is ok but due to a mistake in the |
460 |
|
|
// variable EV_TO type (UInt_t instead of Int_t) that we don't want to change to avoid changing a lot of code, evto becomes inf hence |
461 |
|
|
// the condition ( nentries < (evto+1) ) is satisfied and DV exit with error even if the error is only in the DB. |
462 |
pam-fi |
1.7 |
|
463 |
mocchiut |
1.1 |
}; |
464 |
|
|
|
465 |
pam-fi |
1.7 |
GL_TIMESYNC *dbtime = new GL_TIMESYNC(id_root_l0,"ID",dbc); |
466 |
|
|
|
467 |
pam-fi |
1.24 |
|
468 |
|
|
// ============================================================= |
469 |
|
|
// retrieve information about parameters to process LEVEL2 |
470 |
|
|
// ============================================================= |
471 |
|
|
|
472 |
mocchiut |
1.41 |
TrkParams::Set(runinfo->GetGL_RUN(),dbc); |
473 |
|
|
for(int i=0; i<p->npar; i++){ |
474 |
|
|
if(TrkParams::VerboseMode())cout<<" ((( force parameters from input path )))"<<endl; |
475 |
|
|
TrkParams::Set(p->parpath[i],p->partype[i]); |
476 |
|
|
} |
477 |
pam-fi |
1.25 |
|
478 |
mocchiut |
1.41 |
TrkParams::Load(); |
479 |
|
|
if( !TrkParams::IsLoaded() )throw -52; |
480 |
pam-fi |
1.24 |
|
481 |
|
|
// ============================================================= |
482 |
|
|
// retrieve calibration file needed to reduce data |
483 |
|
|
// ============================================================= |
484 |
|
|
|
485 |
|
|
TrkParams::SetCalib(runinfo->GetGL_RUN(),dbc); |
486 |
|
|
TrkParams::LoadCalib( ); |
487 |
|
|
if( !TrkParams::CalibIsLoaded() )throw -53; |
488 |
|
|
|
489 |
pam-fi |
1.11 |
TBenchmark *reduction = new TBenchmark(); |
490 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())reduction->Start("reduction"); |
491 |
pam-fi |
1.11 |
Int_t ntrk=0; |
492 |
mocchiut |
1.1 |
// ==================================================== |
493 |
|
|
// start looping on events cointained in the data file |
494 |
|
|
// ==================================================== |
495 |
mocchiut |
1.41 |
if ( TrkParams::GetSimuFlag() ){ |
496 |
|
|
abstime = runheadtime; |
497 |
|
|
} else { |
498 |
|
|
if(dbc){ |
499 |
|
|
dbc->Close(); |
500 |
|
|
delete dbc; |
501 |
|
|
} |
502 |
|
|
} |
503 |
|
|
|
504 |
mocchiut |
1.55 |
ev_count =0; // EM, ev_count must be cleared before processing a run (to be consistent when/if reprocessing) |
505 |
mocchiut |
1.57 |
pr_count =0; |
506 |
mocchiut |
1.55 |
|
507 |
pam-fi |
1.32 |
for (UInt_t re = evfrom+min(p->nskip,nevents); re < evfrom+nevents; re++){ |
508 |
mocchiut |
1.49 |
|
509 |
mocchiut |
1.1 |
ev_count++; |
510 |
pam-fi |
1.32 |
|
511 |
pam-fi |
1.45 |
// |
512 |
|
|
// NBNB check if events are aligned!!!!!!!!!!! |
513 |
|
|
// |
514 |
|
|
|
515 |
mocchiut |
1.57 |
/* if(p->gete){ 10RED BUG: unsync with calo and tof... |
516 |
pam-fi |
1.45 |
int iev = 0; |
517 |
|
|
int jumped = 0; |
518 |
|
|
iev = runinfo->GetFirstEntry() + (re - evfrom -jumped); |
519 |
|
|
if ( t_cal->GetEntry(iev) <= 0 ) throw -36;//EV |
520 |
|
|
if ( t_tof->GetEntry(iev) <= 0 ) throw -36;//EV |
521 |
mocchiut |
1.57 |
} // EMI AAAAGGH COSI` NO! |
522 |
|
|
*/ |
523 |
pam-fi |
1.25 |
// if ( TrkParams::DebugMode() && re%100 == 0 && re > 0 ) cout << "."; |
524 |
mocchiut |
1.1 |
|
525 |
mocchiut |
1.37 |
if ( b_trk->GetEntry(re) <= 0 ) throw -36;//EM |
526 |
|
|
if ( b_header->GetEntry(re) <= 0 ) throw -36;//EM |
527 |
pam-fi |
1.13 |
pscu = header->GetPscuHeader(); |
528 |
mocchiut |
1.49 |
|
529 |
mocchiut |
1.41 |
// ============================================================= |
530 |
|
|
// The following 6 lines have been moved here by VALERIO. |
531 |
|
|
if(TrkParams::GetSimuFlag()){ |
532 |
|
|
abstime = runheadtime + (int) floor(0.03*(re-evfrom)); //If simulated data we need to assign a fake abstime. 30ms between each event. |
533 |
|
|
if(TrkParams::VerboseMode())cout << "Event: " << re-evfrom << " - Attempting to retrieve Mask Info for abstime=" << abstime << endl; |
534 |
|
|
if(!TrkParams::Set(runinfo->GetGL_RUN(),dbc,6,abstime))throw -52; // Setting to load mask (VALERIO) |
535 |
|
|
TrkParams::Load(6); |
536 |
|
|
if( !TrkParams::IsLoaded() )throw -52; |
537 |
|
|
if(TrkParams::VerboseMode())cout << "Mask Info for abstime=" << abstime << " retrieved" << endl; |
538 |
|
|
} |
539 |
|
|
|
540 |
pam-fi |
1.25 |
if( TrkParams::DebugMode() )cout << ">>> "<<ev_count-1<<" @ OBT "<<pscu->GetOrbitalTime()<<endl; |
541 |
pam-fi |
1.23 |
|
542 |
mocchiut |
1.35 |
if ( dbtime->DBabsTime(pscu->GetOrbitalTime()) > (runtrailtime+1) || dbtime->DBabsTime(pscu->GetOrbitalTime()) < (runheadtime-1)) { |
543 |
pam-fi |
1.7 |
|
544 |
pam-fi |
1.25 |
if (TrkParams::VerboseMode()){ |
545 |
pam-fi |
1.14 |
printf(" TrkCore - WARNING: event outside the run time window, skipping it\n"); |
546 |
pam-fi |
1.32 |
cout << " OBT "<<pscu->GetOrbitalTime()<<" RUN "<<runheadobt<<"-"<<runtrailobt<<" ABS-time "<<dbtime->DBabsTime(pscu->GetOrbitalTime())<<" RUN "<<runheadtime<<"-"<<runtrailtime<<endl; |
547 |
pam-fi |
1.14 |
}; |
548 |
pam-fi |
1.13 |
}else{ |
549 |
pam-fi |
1.25 |
if ( TrkParams::DebugMode() ) |
550 |
pam-fi |
1.23 |
printf("\n-------------------------------\nevent %d\n",re-evfrom); |
551 |
pam-fi |
1.16 |
|
552 |
mocchiut |
1.57 |
if(p->gete){ // must stay here to avoid losing sync with calo and tof in case of skipped events outside time window |
553 |
|
|
int iev = 0; |
554 |
mocchiut |
1.58 |
iev = runinfo->GetFirstEntry() + pr_count; |
555 |
mocchiut |
1.57 |
if ( t_cal->GetEntry(iev) <= 0 ){ |
556 |
mocchiut |
1.58 |
if (TrkParams::VerboseMode()) printf(" %i %i %i %i \n",iev,runinfo->GetFirstEntry(), pr_count ,evfrom); |
557 |
|
|
if ( TrkParams::VerboseMode() ) printf("\n missing calorimeter entry! \n"); |
558 |
mocchiut |
1.57 |
throw -36;//EV |
559 |
|
|
} |
560 |
|
|
if ( t_tof->GetEntry(iev) <= 0 ){ |
561 |
mocchiut |
1.58 |
if (TrkParams::VerboseMode()) printf(" %i %i %i %i \n",iev,runinfo->GetFirstEntry(), pr_count ,evfrom); |
562 |
|
|
if ( TrkParams::VerboseMode() ) printf("\n missing tof entry! \n"); |
563 |
mocchiut |
1.57 |
throw -36;//EV |
564 |
|
|
} |
565 |
|
|
} |
566 |
|
|
pr_count++; |
567 |
pam-ts |
1.46 |
//============================================= |
568 |
|
|
// EVENT PROCESSING |
569 |
|
|
//============================================= |
570 |
|
|
TStopwatch w; |
571 |
pam-ts |
1.52 |
// cout << " -------------------------------------------------------------------------"<<endl; |
572 |
pam-ts |
1.46 |
|
573 |
pam-ts |
1.52 |
// ---------------------------------------------- |
574 |
pam-ts |
1.46 |
// default tracking |
575 |
pam-ts |
1.52 |
// ---------------------------------------------- |
576 |
|
|
if(tWatch)w.Start(); |
577 |
|
|
|
578 |
pam-ts |
1.46 |
p->ProcessEvent(l0_event);//call f77 routine |
579 |
|
|
|
580 |
pam-ts |
1.52 |
if(tWatch)w.Stop(); |
581 |
|
|
if(tWatch)trkWatch.tTrk = (float) w.CpuTime(); |
582 |
|
|
// if(tWatch)cout << " t."<<trkWatch.tTrk<<endl; |
583 |
|
|
|
584 |
pam-fi |
1.7 |
|
585 |
pam-ts |
1.52 |
// // ---------------- |
586 |
|
|
// // LEVEL1 output |
587 |
|
|
// // ---------------- |
588 |
|
|
l1_event->Clear(); |
589 |
|
|
l1_event->SetFromLevel1Struct(); |
590 |
|
|
|
591 |
pam-fi |
1.13 |
// ---------------- |
592 |
|
|
// HOUGH output |
593 |
|
|
// ---------------- |
594 |
|
|
if(p->geth){ |
595 |
|
|
if(p->ifrooth){ // root |
596 |
pam-fi |
1.23 |
lh_event->Delete(); |
597 |
|
|
lh_event->SetFromHoughStruct(&houghevent_); |
598 |
pam-fi |
1.13 |
}else{ // hbook |
599 |
|
|
throw -299; |
600 |
|
|
}; |
601 |
|
|
}; |
602 |
pam-ts |
1.46 |
|
603 |
|
|
// // ---------------- |
604 |
|
|
// // LEVEL2 output |
605 |
|
|
// // ---------------- |
606 |
|
|
l2_event->Clear(); |
607 |
|
|
if(p->get1){ |
608 |
|
|
l2_event->SetFromLevel2Struct(&level2event_,l1_event);//set references to level1 |
609 |
|
|
}else{ |
610 |
|
|
l2_event->SetFromLevel2Struct(&level2event_); |
611 |
|
|
} |
612 |
|
|
|
613 |
|
|
if( l2_event->ntrk()>0 )ntrk++; |
614 |
|
|
if(TrkParams::VerboseMode())l2_event->Dump(); |
615 |
|
|
|
616 |
pam-ts |
1.48 |
|
617 |
|
|
//---------------------------------------------- |
618 |
|
|
// verify conditions to apply extended algorythm |
619 |
|
|
//---------------------------------------------- |
620 |
|
|
bool APPLY_EXTENDED = false; |
621 |
mocchiut |
1.55 |
extAlgFlag = 0; // EM: this is the standard situation, extAlgFlag must be set to zero here. It does not garantuee you have an extended track, it just states |
622 |
|
|
// that if there were no standard tracks the extended algorithm is used. If not cleared and if there is at least one standard track |
623 |
|
|
// extAlgFlag retains the previous value that could be DIFFERENT from zero if the previous event was a check event... |
624 |
pam-ts |
1.48 |
if( |
625 |
mocchiut |
1.55 |
p->gete && //input flag set |
626 |
pam-ts |
1.48 |
true){ |
627 |
|
|
|
628 |
pam-ts |
1.52 |
// regular condition for extended processing |
629 |
|
|
if(l2_event->ntrk()==0){ |
630 |
pam-ts |
1.48 |
APPLY_EXTENDED = true; |
631 |
mocchiut |
1.55 |
extAlgFlag = 1; // EM: meaning of extAlgFlag changed: 0 if not used, 1 if used, 2 if used for cross-check, 3 used for cross-check and no std tracks |
632 |
pam-ts |
1.48 |
} |
633 |
pam-ts |
1.52 |
// extended algorythm applied for cross-check |
634 |
pam-ts |
1.48 |
if(p->gete_ncheck>0 && ev_count%p->gete_ncheck==0){ |
635 |
|
|
APPLY_EXTENDED = true; |
636 |
mocchiut |
1.55 |
extAlgFlag = 2; // EM read above |
637 |
|
|
if(l2_event->ntrk()==0) extAlgFlag = 3; // EM make it easier to recognize events with no standard tracks AND forced extended algorithm // EM read above |
638 |
pam-ts |
1.48 |
} |
639 |
|
|
|
640 |
|
|
} |
641 |
|
|
|
642 |
pam-ts |
1.59 |
// cout << re<<" ev_count "<<ev_count<<" apply extended "<<APPLY_EXTENDED<<" flag "<<extAlgFlag<<endl; |
643 |
pam-ts |
1.52 |
|
644 |
|
|
if(tWatch)w.Start(); |
645 |
pam-ts |
1.46 |
|
646 |
pam-fi |
1.45 |
// ------------------ |
647 |
|
|
// extended-tracking |
648 |
|
|
// ------------------ |
649 |
pam-ts |
1.52 |
trkAlg->Clear(); |
650 |
pam-ts |
1.48 |
if(APPLY_EXTENDED){ |
651 |
pam-ts |
1.46 |
|
652 |
pam-ts |
1.48 |
// //---------------------------- |
653 |
|
|
// // check conditions |
654 |
|
|
// //---------------------------- |
655 |
|
|
// if( |
656 |
|
|
// l2_event->ntrk()==0 && |
657 |
|
|
// l1_event->nclstr()<24 && |
658 |
|
|
// true){ |
659 |
pam-ts |
1.46 |
|
660 |
pam-ts |
1.48 |
trkAlg->SetDebug(false); |
661 |
|
|
trkAlg->SetTrkLevel2(l2_event); |
662 |
|
|
trkAlg->SetTrkLevel1(l1_event); |
663 |
|
|
trkAlg->SetCaloLevel1(cl1); |
664 |
|
|
trkAlg->SetToFLevel2(tl2); |
665 |
|
|
// trkAlg->Dump(); |
666 |
|
|
trkAlg->ProcessEvent(); |
667 |
mocchiut |
1.49 |
|
668 |
pam-ts |
1.48 |
// } |
669 |
pam-ts |
1.46 |
} |
670 |
|
|
|
671 |
pam-ts |
1.52 |
if(tWatch)w.Stop(); |
672 |
|
|
if(tWatch)trkWatch.tTrkExt = (float) w.CpuTime(); |
673 |
|
|
// if(tWatch)cout << " t."<<trkWatch.tTrkExt<<endl; |
674 |
pam-ts |
1.46 |
|
675 |
|
|
|
676 |
|
|
if(p->getn){ |
677 |
|
|
|
678 |
pam-ts |
1.52 |
if(tWatch)w.Start(); |
679 |
|
|
|
680 |
|
|
l1_event_nuclei->Clear(); |
681 |
pam-ts |
1.46 |
l1_event_nuclei->Set(l1_event,5.,0.2);//apply a cut |
682 |
|
|
l1_event_nuclei->GetLevel1Struct();//from cleaned l1 object, to f77 common |
683 |
|
|
l1_event_nuclei->ProcessEvent(); // default routine |
684 |
pam-ts |
1.52 |
l2_event_nuclei->Clear(); |
685 |
pam-ts |
1.46 |
l2_event_nuclei->SetFromLevel2Struct(); // from f77 common to l2 object |
686 |
pam-ts |
1.48 |
|
687 |
pam-ts |
1.52 |
|
688 |
pam-ts |
1.46 |
trkAlg_nuclei->Clear(); |
689 |
pam-ts |
1.52 |
|
690 |
pam-ts |
1.48 |
if(APPLY_EXTENDED){ |
691 |
|
|
|
692 |
|
|
trkAlg_nuclei->SetDebug(false); |
693 |
|
|
trkAlg_nuclei->SetTrkLevel2( l2_event_nuclei ); |
694 |
|
|
trkAlg_nuclei->SetTrkLevel1( l1_event_nuclei );//cleaned level1 |
695 |
|
|
trkAlg_nuclei->SetCaloLevel1( cl1 ); |
696 |
|
|
trkAlg_nuclei->SetToFLevel2( tl2 ); |
697 |
|
|
trkAlg_nuclei->ProcessEvent(); |
698 |
pam-ts |
1.46 |
} |
699 |
|
|
|
700 |
pam-ts |
1.52 |
if(tWatch)w.Stop(); |
701 |
|
|
if(tWatch)trkWatch.tTrkNuc = (float) w.CpuTime(); |
702 |
|
|
// if(tWatch)cout << " t."<<trkWatch.tTrkNuc<<endl; |
703 |
pam-fi |
1.45 |
|
704 |
pam-ts |
1.46 |
} |
705 |
mocchiut |
1.49 |
|
706 |
pam-fi |
1.45 |
|
707 |
pam-ts |
1.52 |
// if( l1_event->nclstr() > 15 && trkAlg->GetTrackArray()->GetEntries()>0){ |
708 |
|
|
|
709 |
|
|
// if(l1_event)cout<<" std n.cl "<<l1_event->nclstr(); |
710 |
|
|
// if(l2_event)cout<<" n.tr "<<l2_event->GetNTracks() ; |
711 |
|
|
// if(trkAlg)cout<<" ext "<<trkAlg->GetTrackArray()->GetEntries(); |
712 |
|
|
// cout<<endl; |
713 |
|
|
|
714 |
|
|
// trkAlg->SetDebug(true); |
715 |
|
|
// trkAlg->CheckEvent(); |
716 |
|
|
// trkAlg->SetDebug(false); |
717 |
|
|
|
718 |
pam-fi |
1.45 |
|
719 |
pam-ts |
1.52 |
// } |
720 |
|
|
|
721 |
|
|
// if( l1_event_nuclei->nclstr() <3 && trkAlg_nuclei->GetTrackArray()->GetEntries()>0){ |
722 |
|
|
// if(l1_event_nuclei)cout<<" nuc n.cl "<<l1_event_nuclei->nclstr(); |
723 |
|
|
// if(l2_event_nuclei)cout<<" n.tr "<<l2_event_nuclei->GetNTracks() ; |
724 |
|
|
// if(trkAlg_nuclei)cout<<" ext "<<trkAlg_nuclei->GetTrackArray()->GetEntries(); |
725 |
|
|
// cout<<endl; |
726 |
|
|
// trkAlg_nuclei->SetDebug(true); |
727 |
|
|
// trkAlg_nuclei->CheckEvent(); |
728 |
|
|
// trkAlg_nuclei->SetDebug(false); |
729 |
|
|
// } |
730 |
pam-ts |
1.46 |
|
731 |
|
|
///////////////////// |
732 |
|
|
// ==== FILL ===== // |
733 |
|
|
///////////////////// |
734 |
|
|
t_level2->Fill(); |
735 |
|
|
|
736 |
pam-ts |
1.52 |
if(tWatch){ |
737 |
|
|
|
738 |
|
|
trkWatch.nCl = (l1_event ? l1_event->nclstr() :0); |
739 |
|
|
trkWatch.nClCut = (l1_event_nuclei ? l1_event_nuclei->nclstr() :0); |
740 |
|
|
|
741 |
|
|
|
742 |
|
|
trkWatch.nTrk = (l2_event ? l2_event->GetNTracks() :0); |
743 |
|
|
trkWatch.nTrkNuc = (l2_event_nuclei ? l2_event_nuclei->GetNTracks() :0); |
744 |
|
|
|
745 |
|
|
trkWatch.nTrkExt = ( trkAlg ? trkAlg->GetTrackArray()->GetEntries() : 0); |
746 |
|
|
trkWatch.nTrkExtNuc = ( trkAlg_nuclei ? trkAlg_nuclei->GetTrackArray()->GetEntries() : 0); |
747 |
|
|
|
748 |
|
|
if(TrkParams::VerboseMode())trkWatch.Dump(); |
749 |
|
|
|
750 |
|
|
|
751 |
|
|
tWatch->Fill(); |
752 |
|
|
} |
753 |
pam-fi |
1.45 |
|
754 |
pam-fi |
1.13 |
}; |
755 |
mocchiut |
1.1 |
}; // end loop on events |
756 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
757 |
pam-fi |
1.13 |
cout << " >>> processed "<< ev_count <<" events"<< endl; |
758 |
|
|
if(ev_count)cout << ntrk << " events with at least one track ("<<(Int_t)(100*ntrk/ev_count)<<"%)\n"; |
759 |
|
|
reduction->Show("reduction"); |
760 |
pam-fi |
1.11 |
} |
761 |
|
|
delete reduction; |
762 |
pam-fi |
1.7 |
|
763 |
|
|
delete dbtime; |
764 |
|
|
|
765 |
pam-fi |
1.13 |
}; // end loop on runs |
766 |
|
|
|
767 |
|
|
|
768 |
mocchiut |
1.1 |
// ------------------------------------------------------------ |
769 |
|
|
// if reprocessing one run, copy all the events AFTER the run |
770 |
|
|
// ------------------------------------------------------------ |
771 |
|
|
if( !(p->standalone) ){ |
772 |
mocchiut |
1.50 |
if(TrkParams::VerboseMode()) cout << " Reprocessing one run: "<<run<< " copy all events AFTER the run"<< endl; |
773 |
mocchiut |
1.1 |
for(UInt_t i=runinfo->GetLastEntry()+1; i<runinfo->GetFileEntries(); i++){ |
774 |
mocchiut |
1.37 |
if ( t_clone->GetEntry(i) <= 0 ) throw -36;//EM |
775 |
mocchiut |
1.1 |
*l2_event = *l2_clone; |
776 |
pam-ts |
1.46 |
// COPY COPY COPY |
777 |
mocchiut |
1.1 |
t_level2->Fill(); |
778 |
|
|
l2_event->Clear(); |
779 |
|
|
}; |
780 |
|
|
}; |
781 |
|
|
// --------------- |
782 |
|
|
// close the files |
783 |
|
|
// --------------- |
784 |
|
|
if(p->get2){ |
785 |
mocchiut |
1.50 |
if(TrkParams::VerboseMode()) cout << " Writing and closing the files, t_level2 "<< t_level2<< endl; |
786 |
pam-ts |
1.46 |
f2->cd(); |
787 |
|
|
// if(tWatch){ |
788 |
|
|
// if(tWatch)f2->Write("TrkWatch",TObject::kOverwrite); |
789 |
|
|
// } |
790 |
|
|
// f2->Write("Tracker", TObject::kOverwrite); |
791 |
mocchiut |
1.50 |
// if( t_level2 )t_level2->Write(); |
792 |
|
|
|
793 |
|
|
if( t_clone )t_clone->Delete("all");//delete old tree from file |
794 |
|
|
|
795 |
|
|
if( t_level2 )t_level2->SetName("Tracker"); |
796 |
|
|
if( t_level2 )t_level2->Write("Tracker",TObject::kOverwrite); |
797 |
pam-ts |
1.46 |
if( t_level2 )t_level2->Delete(); //delete new tree from memory |
798 |
|
|
|
799 |
pam-fi |
1.13 |
if( !(p->standalone) )runinfo->Close(); |
800 |
pam-ts |
1.46 |
if(tWatch)tWatch->Write(); |
801 |
pam-fi |
1.13 |
|
802 |
|
|
}; |
803 |
pam-ts |
1.46 |
|
804 |
pam-fi |
1.45 |
|
805 |
pam-fi |
1.24 |
if(f0) if(f0->IsOpen()) f0->Close(); |
806 |
pam-ts |
1.46 |
|
807 |
pam-fi |
1.13 |
l1_event->Delete(); |
808 |
|
|
l2_event->Delete(); |
809 |
|
|
l2_clone->Delete(); |
810 |
pam-fi |
1.2 |
|
811 |
pam-fi |
1.45 |
|
812 |
pam-fi |
1.2 |
return(p->ostatus); |
813 |
mocchiut |
1.1 |
} |
814 |
|
|
|