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 |
mocchiut |
1.49 |
TrkLevel2 *l2_event_nuclei = NULL; // EM bug new TrkLevel2(); |
118 |
mocchiut |
1.47 |
// EM TrkLevel2 *l2_clone_nuclei = new TrkLevel2(); |
119 |
pam-fi |
1.13 |
//LEVEL1 output - ROOT |
120 |
pam-ts |
1.46 |
TrkLevel1 *l1_event = new TrkLevel1(); |
121 |
mocchiut |
1.49 |
TrkLevel1 *l1_event_nuclei = NULL; // EM, bug new TrkLevel1(); |
122 |
pam-fi |
1.15 |
TrkHough *lh_event = new TrkHough(); |
123 |
mocchiut |
1.42 |
|
124 |
pam-fi |
1.45 |
//Extended tracking: |
125 |
|
|
TTree *t_cal = NULL; |
126 |
|
|
TTree *t_tof = NULL; |
127 |
|
|
ExtTrkingAlg *trkAlg = NULL; |
128 |
pam-ts |
1.46 |
ExtTrkingAlg *trkAlg_nuclei = NULL; |
129 |
pam-fi |
1.45 |
TClonesArray *trk_array = NULL; |
130 |
pam-ts |
1.46 |
TClonesArray *trk_array_nuclei = NULL; |
131 |
|
|
|
132 |
pam-fi |
1.45 |
CaloLevel1 *cl1 = NULL; |
133 |
|
|
ToFLevel2 *tl2 = NULL; |
134 |
pam-ts |
1.46 |
|
135 |
|
|
typedef struct { |
136 |
|
|
|
137 |
|
|
Int_t nTrk; |
138 |
|
|
Int_t nTrkNuc; |
139 |
|
|
Int_t nTrkExt; |
140 |
|
|
Int_t nTrkExtNuc; |
141 |
|
|
|
142 |
|
|
Int_t nCl; |
143 |
|
|
Int_t nClCut; |
144 |
|
|
|
145 |
|
|
Float_t tTrk; |
146 |
|
|
Float_t tTrkExt; |
147 |
|
|
Float_t tTrkNuc; |
148 |
|
|
|
149 |
|
|
} TrkWatch; |
150 |
|
|
TrkWatch trkWatch; |
151 |
|
|
TTree *tWatch = NULL; |
152 |
|
|
|
153 |
pam-ts |
1.48 |
Int_t extAlgFlag=0; |
154 |
pam-ts |
1.46 |
|
155 |
|
|
|
156 |
|
|
|
157 |
mocchiut |
1.43 |
/* |
158 |
mocchiut |
1.42 |
// EM: how to use CaloLevel1 data inside tracker core routine, example: |
159 |
|
|
TTree *T = (TTree*)f2->Get("Calorimeter"); |
160 |
|
|
if ( T ){ |
161 |
|
|
CaloStrip *cs = new CaloStrip(false); |
162 |
|
|
CaloLevel1 *cl1 = new CaloLevel1(); |
163 |
|
|
T->SetBranchAddress("CaloLevel1",&cl1); |
164 |
|
|
// |
165 |
|
|
for (Int_t i=0; i < T->GetEntries(); i++){ |
166 |
|
|
T->GetEntry(i); |
167 |
|
|
Bool_t OK = false; |
168 |
|
|
Int_t k = 0; |
169 |
|
|
Int_t view = 0; |
170 |
|
|
Int_t plane = 0; |
171 |
|
|
Int_t strip = 0; |
172 |
|
|
Float_t mip = 0.; |
173 |
|
|
Float_t ene[2][22][96]; |
174 |
|
|
memset (ene,0,sizeof(Float_t)*2*22*96); |
175 |
|
|
// |
176 |
|
|
while ( k < cl1->istrip ){ |
177 |
|
|
mip = cl1->DecodeEstrip(k,view,plane,strip); |
178 |
|
|
// if ( view==0 && plane==18 ) mip = 0.; // 9thRED - set to zero signals from plane 18X |
179 |
|
|
// |
180 |
|
|
ene[view][plane][strip] = mip; |
181 |
|
|
k++; |
182 |
|
|
}; |
183 |
|
|
// check 5 |
184 |
|
|
Float_t totX = 0.; |
185 |
|
|
Float_t totY = 0.; |
186 |
|
|
Float_t posX = 0.; |
187 |
|
|
Float_t posY = 0.; |
188 |
|
|
Int_t minYstrip = 100; |
189 |
|
|
Int_t maxYstrip = -1; |
190 |
|
|
// calculate baricenter strip on first x and y planes |
191 |
|
|
for (Int_t j = 0; j<2; j++){ |
192 |
|
|
for (Int_t i = 0; i<96; i++){ |
193 |
|
|
totX += ene[0][j][i]; |
194 |
|
|
totY += ene[1][j][i]; |
195 |
|
|
if ( j==0 && ene[1][0][i]>0. && i > maxYstrip ) maxYstrip = i; |
196 |
|
|
if ( j==0 && ene[1][0][i]>0. && i < minYstrip ) minYstrip = i; |
197 |
|
|
posX += (float)i*ene[0][j][i]; |
198 |
|
|
posY += (float)i*ene[1][j][i]; |
199 |
|
|
} |
200 |
|
|
} |
201 |
|
|
// |
202 |
|
|
// printf(" totX %f totY %f maxYstrip %i minYstrip %i \n",totX,totY,maxYstrip,minYstrip); |
203 |
|
|
Int_t bariX = 0; |
204 |
|
|
Int_t bariY = 0; |
205 |
|
|
if ( totX>0. && totY > 0.){ |
206 |
|
|
// printf(" totX %f totY %f \n",totX,totY); |
207 |
|
|
posX /= totX; |
208 |
|
|
posY /= totY; |
209 |
|
|
bariX = (int)(posX); |
210 |
|
|
bariY = (int)(posY); |
211 |
|
|
Int_t minX = bariX - 10; |
212 |
|
|
Int_t maxX = bariX + 10; |
213 |
|
|
Int_t minY = bariY - 10; |
214 |
|
|
Int_t maxY = bariY + 10; |
215 |
|
|
if ( minX < 0 ) minX = 0; |
216 |
|
|
if ( minY < 0 ) minY = 0; |
217 |
|
|
if ( maxX > 95 ) maxX = 95; |
218 |
|
|
if ( maxY > 95 ) maxY = 95; |
219 |
|
|
totX = 0.; |
220 |
|
|
totY = 0.; |
221 |
|
|
Float_t parX = 0.; |
222 |
|
|
Float_t parY = 0.; |
223 |
|
|
|
224 |
|
|
for (Int_t j = 0; j<3; j++){ |
225 |
|
|
for (Int_t i = 0; i<96; i++){ |
226 |
|
|
totX += ene[0][j][i]; |
227 |
|
|
|
228 |
|
|
|
229 |
|
|
totY += ene[1][j][i]; |
230 |
|
|
if ( i>=minX && i<=maxX){ |
231 |
|
|
parX += ene[0][j][i]; |
232 |
|
|
} |
233 |
|
|
if ( i>=minY && i<=maxY){ |
234 |
|
|
parY += ene[1][j][i]; |
235 |
|
|
} |
236 |
|
|
} |
237 |
|
|
} |
238 |
|
|
// printf(" bariX %i bariY %i minX %i maxX %i minY %i maxY %i fractionX %f fractionY %f \n",bariX,bariY,minX,maxX,minY,maxY,parX/totX,parY/totY); |
239 |
|
|
|
240 |
|
|
if ( parX/totX > 0.65 && parY/totY > 0.75 ) OK = true; // less strict cut on the X due to possible bremsstrhalung double showers |
241 |
|
|
// if ( OK ) printf(" CHECK5 PASSED\n"); |
242 |
|
|
} |
243 |
|
|
|
244 |
|
|
// check 1 |
245 |
|
|
if ( totY > 0. && abs(maxYstrip-minYstrip)<10 ){ |
246 |
|
|
posY /= totY; |
247 |
|
|
bariY = (int)(posY); |
248 |
|
|
Float_t ntotX = 0.; |
249 |
|
|
Float_t ntotY = 0.; |
250 |
|
|
for (Int_t j = 0; j<2; j++){ |
251 |
|
|
for (Int_t i = 0; i<96; i++){ |
252 |
|
|
ntotX += ene[0][j][i]; |
253 |
|
|
if ( j > 0 ) ntotY += ene[1][j][i]; |
254 |
|
|
} |
255 |
|
|
} |
256 |
|
|
if ( ntotX < 0.3 && ntotY < 0.3 ){ |
257 |
|
|
OK = true; |
258 |
|
|
// printf(" CHECK1 PASSED\n"); |
259 |
|
|
} |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
if ( OK ){ |
263 |
|
|
printf("%i: event is good! \n",i); |
264 |
|
|
cs->Set(1,0,bariY); |
265 |
|
|
printf(" Y0 hit strip coordinates: X %f Y %f Z %f \n",cs->GetX(),cs->GetY(),cs->GetZ()); |
266 |
|
|
} |
267 |
|
|
} |
268 |
|
|
T->Delete(); |
269 |
|
|
} |
270 |
|
|
// end EM |
271 |
mocchiut |
1.43 |
// EM: how to use ToF data inside tracker core routine, example: |
272 |
|
|
T = (TTree*)f2->Get("ToF"); |
273 |
|
|
if ( T ){ |
274 |
|
|
ToFLevel2 *tl2 = new ToFLevel2(); |
275 |
|
|
T->SetBranchAddress("ToFLevel2",&tl2); |
276 |
|
|
// |
277 |
|
|
for (Int_t i=0; i < T->GetEntries(); i++){ |
278 |
|
|
T->GetEntry(i); |
279 |
|
|
printf("%i GetPaddleIdOfTrack(-2.4,5.6,2) %i HitPaddle(2,0) %i \n",i,tl2->GetPaddleIdOfTrack(-24.,5.6,2),tl2->HitPaddle(2,0)); |
280 |
|
|
} |
281 |
|
|
T->Delete(); |
282 |
|
|
} |
283 |
|
|
// END EM |
284 |
|
|
*/ |
285 |
mocchiut |
1.42 |
|
286 |
mocchiut |
1.1 |
// ----------------------- |
287 |
|
|
// ----------------------- |
288 |
|
|
// Handle input parameters |
289 |
|
|
// (data) |
290 |
|
|
// |
291 |
|
|
// - open/create output files, determining the environment root/hbook from the estension |
292 |
|
|
// - create the level1/level2 tree+branch/nt-uple |
293 |
|
|
// ----------------------- |
294 |
|
|
// ----------------------- |
295 |
|
|
TrkProcess *p = new TrkProcess(run,f2); |
296 |
pam-fi |
1.26 |
if( p->HandleCustomPar(ncustom,vcustom) )return(p->ostatus);; |
297 |
pam-fi |
1.25 |
if( TrkParams::VerboseMode() )p->Dump(); |
298 |
pam-ts |
1.46 |
// p->Dump(); |
299 |
mocchiut |
1.1 |
|
300 |
|
|
// =================================== |
301 |
|
|
// Open/Create level2 output file |
302 |
|
|
// =================================== |
303 |
|
|
if(p->get2){ |
304 |
pam-fi |
1.13 |
//------------------------------------------- |
305 |
|
|
// read RunInfo |
306 |
|
|
//------------------------------------------- |
307 |
|
|
if(!(p->standalone)){ |
308 |
|
|
// Open "RunInfo" tree and get list of run |
309 |
|
|
runinfo = new ItoRunInfo(f2); |
310 |
|
|
char *trkversion = TrkInfo(false); |
311 |
|
|
int runinfo_error = runinfo->Update(run,"TRK",trkversion); |
312 |
|
|
if( runinfo_error ) throw runinfo_error; |
313 |
|
|
runlist = runinfo->GetRunList(); |
314 |
mocchiut |
1.44 |
// reprocessing = runinfo->IsReprocessing();//???? |
315 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
316 |
pam-fi |
1.13 |
cout << "#events "<< runinfo->GetFileEntries() << endl;// #events in the file |
317 |
|
|
cout << "#runs "<< runinfo->GetRunEntries() << endl;// #runs in the file |
318 |
|
|
cout << "1-st run "<< runlist->At(0) << endl; |
319 |
|
|
cout << "last run "<< runlist->At(runinfo->GetRunEntries()-1) << endl; |
320 |
|
|
cout << "1-st event "<< runinfo->GetFirstEntry() << endl;// first event of our run |
321 |
|
|
cout << "last event+1 "<< runinfo->GetLastEntry() << endl;// first event AFTER the last event of our run |
322 |
mocchiut |
1.44 |
// cout << "reprocessing "<< runinfo->IsReprocessing() << endl << endl; |
323 |
pam-fi |
1.13 |
}; |
324 |
|
|
}; |
325 |
|
|
//------------------------------------------- |
326 |
|
|
// |
327 |
pam-ts |
1.46 |
//------------------------------------------- |
328 |
pam-fi |
1.13 |
// Take (if present) the old Tracker tree |
329 |
|
|
t_clone = (TTree*)f2->Get("Tracker"); |
330 |
|
|
if( t_clone != NULL ) t_clone->SetBranchAddress("TrkLevel2",&l2_clone); |
331 |
pam-ts |
1.46 |
|
332 |
pam-fi |
1.13 |
// Create NEW Tracker tree |
333 |
|
|
t_level2 = new TTree("Tracker","PAMELA tracker level2 data "); |
334 |
pam-fi |
1.21 |
l2_event->Set(); // ****NBNBNBN***** |
335 |
pam-fi |
1.13 |
t_level2->Branch("TrkLevel2","TrkLevel2",&l2_event); |
336 |
pam-ts |
1.46 |
|
337 |
pam-fi |
1.13 |
if(p->get1){ |
338 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())cout << endl << "Requested LEVEL1 output" << endl; |
339 |
pam-fi |
1.21 |
l1_event->Set(); // ****NBNBNBN***** |
340 |
pam-fi |
1.13 |
t_level2->Branch("TrkLevel1","TrkLevel1",&l1_event); |
341 |
pam-fi |
1.16 |
} |
342 |
|
|
if(p->geth){ |
343 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())cout << endl << "Requested Hough-Transform output" << endl; |
344 |
pam-fi |
1.16 |
t_level2->Branch("TrkHough","TrkHough",&lh_event); |
345 |
pam-fi |
1.7 |
}; |
346 |
pam-ts |
1.46 |
if(p->getn){ |
347 |
|
|
if(TrkParams::VerboseMode())cout << endl << "Requested nuclei-algorythm output" << endl; |
348 |
|
|
if(!l2_event_nuclei)l2_event_nuclei = new TrkLevel2(); |
349 |
mocchiut |
1.49 |
if(!l1_event_nuclei)l1_event_nuclei = new TrkLevel1(); // EM bug |
350 |
pam-ts |
1.46 |
l2_event_nuclei->Set(); // ****NBNBNBN***** |
351 |
|
|
t_level2->Branch("TrackNuclei",l2_event_nuclei->GetPointerToTrackArray()); |
352 |
|
|
|
353 |
|
|
} |
354 |
|
|
// ========================================================= |
355 |
|
|
// extended tracking algorythm output |
356 |
|
|
// ========================================================= |
357 |
|
|
if(p->gete){ |
358 |
|
|
trkAlg = new ExtTrkingAlg(p->extAlgID);// create the algorythm |
359 |
|
|
trk_array = trkAlg->GetTrackArray(); // get the track array |
360 |
|
|
if(!trk_array)throw -206; |
361 |
|
|
t_level2->Branch("RecoveredTrack",trkAlg->GetPointerToTrackArray());// put it in a branch |
362 |
|
|
if(p->getn){ |
363 |
mocchiut |
1.49 |
if(TrkParams::VerboseMode())cout << endl << "Requested extended nuclei-algorythm output" << endl; |
364 |
pam-ts |
1.46 |
trkAlg_nuclei = new ExtTrkingAlg(p->extAlgID);// create the algorythm for nuclei |
365 |
|
|
trk_array_nuclei = trkAlg_nuclei->GetTrackArray();// get the track array |
366 |
|
|
if(!trk_array_nuclei)throw -206; |
367 |
|
|
t_level2->Branch("RecoveredTrackNuclei",trkAlg_nuclei->GetPointerToTrackArray()); // put it in a branch |
368 |
|
|
} |
369 |
pam-ts |
1.48 |
t_level2->Branch("extAlgFlag",&extAlgFlag,"extAlgFlag/I"); |
370 |
|
|
// ------------------------ |
371 |
pam-ts |
1.46 |
// calorimeter and tof tree |
372 |
pam-ts |
1.48 |
// ------------------------ |
373 |
pam-ts |
1.46 |
t_cal = (TTree*)f2->Get("Calorimeter"); |
374 |
|
|
if(!t_cal)throw -206; |
375 |
|
|
cl1 = new CaloLevel1(); |
376 |
|
|
t_cal->SetBranchAddress("CaloLevel1",&cl1); |
377 |
|
|
|
378 |
|
|
|
379 |
|
|
t_tof = (TTree*)f2->Get("ToF"); |
380 |
|
|
if(!t_tof)throw -206; |
381 |
|
|
tl2 = new ToFLevel2(); |
382 |
|
|
t_tof->SetBranchAddress("ToFLevel2",&tl2); |
383 |
|
|
|
384 |
|
|
} |
385 |
|
|
if(p->watch){ |
386 |
|
|
|
387 |
|
|
// f2->cd(); |
388 |
|
|
tWatch = new TTree("TrkWatch"," Tracking timing info"); |
389 |
|
|
|
390 |
|
|
tWatch->Branch("nCl",&trkWatch.nCl,"nCl/I"); |
391 |
|
|
tWatch->Branch("nClCut",&trkWatch.nClCut,"nClCut/I"); |
392 |
|
|
|
393 |
|
|
tWatch->Branch("nTrk",&trkWatch.nTrk,"nTrk/I"); |
394 |
|
|
tWatch->Branch("nTrkExt",&trkWatch.nTrkExt,"nTrkExt/I"); |
395 |
|
|
tWatch->Branch("nTrkNuc",&trkWatch.nTrkNuc,"nTrkNuc/I"); |
396 |
|
|
tWatch->Branch("nTrkExtNuc",&trkWatch.nTrkExtNuc,"nTrkExtExt/I"); |
397 |
|
|
|
398 |
|
|
tWatch->Branch("tTrk",&trkWatch.tTrk,"tTrk/F"); |
399 |
|
|
tWatch->Branch("tTrkExt",&trkWatch.tTrkExt,"tTrkExt/F"); |
400 |
|
|
tWatch->Branch("tTrkNuc",&trkWatch.tTrkNuc,"tTrkNuc/F"); |
401 |
|
|
|
402 |
|
|
|
403 |
|
|
} |
404 |
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
pam-fi |
1.13 |
}; |
409 |
pam-fi |
1.45 |
|
410 |
pam-ts |
1.46 |
|
411 |
pam-fi |
1.45 |
|
412 |
mocchiut |
1.1 |
|
413 |
|
|
// ------------------------------------------- |
414 |
|
|
// define runs to be processed/reprocessed |
415 |
|
|
// ------------------------------------------- |
416 |
|
|
if(run == 0){ |
417 |
pam-fi |
1.13 |
// reprocessing ALL runs |
418 |
|
|
if(p->standalone)throw -298; // reprocessing not implemented |
419 |
|
|
from_run = runlist->At(0); |
420 |
|
|
to_run = runlist->At(runinfo->GetRunEntries()-1); |
421 |
mocchiut |
1.1 |
}else{ |
422 |
|
|
// processing/reprocessing ONE single run |
423 |
pam-fi |
1.13 |
from_run = run; |
424 |
|
|
to_run = run; |
425 |
mocchiut |
1.1 |
}; |
426 |
|
|
|
427 |
|
|
// |
428 |
|
|
// init event counter |
429 |
|
|
// |
430 |
|
|
Int_t ev_count =0; |
431 |
|
|
// |
432 |
|
|
// create query-results objects |
433 |
|
|
// |
434 |
pam-fi |
1.7 |
GL_RUN q1 = GL_RUN(); |
435 |
mocchiut |
1.1 |
GL_TRK_CALIB q2 = GL_TRK_CALIB(); |
436 |
|
|
GL_ROOT q3 = GL_ROOT(); |
437 |
|
|
GL_PARAM q4 = GL_PARAM(); |
438 |
|
|
|
439 |
|
|
// ------------------------------------------------------------ |
440 |
|
|
// if reprocessing one run, copy all the events BEFORE the run |
441 |
|
|
// ------------------------------------------------------------ |
442 |
|
|
if( !(p->standalone) ){ |
443 |
pam-fi |
1.13 |
for(UInt_t i=0; i<runinfo->GetFirstEntry(); i++){ |
444 |
mocchiut |
1.37 |
if ( t_clone->GetEntry(i) <= 0 ) throw -36;// EM |
445 |
pam-ts |
1.46 |
// COPY COPY COPY |
446 |
pam-fi |
1.13 |
*l2_event = *l2_clone; |
447 |
|
|
t_level2->Fill(); |
448 |
|
|
l2_event->Clear(); |
449 |
|
|
}; |
450 |
mocchiut |
1.1 |
}; |
451 |
|
|
// ------------------------------------------------------------ |
452 |
|
|
// ------------------------------------------------------------ |
453 |
pam-fi |
1.25 |
// START LOOP OVER RUNS TO PROCESS/REPROCESS |
454 |
mocchiut |
1.1 |
// ------------------------------------------------------------ |
455 |
|
|
// ------------------------------------------------------------ |
456 |
pam-fi |
1.7 |
for(UInt_t idRun = from_run; idRun <= to_run; idRun++){ |
457 |
mocchiut |
1.1 |
|
458 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()) cout << endl<<" ========================= Run: "<< idRun << endl; |
459 |
pam-fi |
1.7 |
UInt_t runheadtime = 0; |
460 |
|
|
UInt_t runtrailtime = 0; |
461 |
pam-fi |
1.32 |
UInt_t runheadobt = 0; |
462 |
|
|
UInt_t runtrailobt = 0; |
463 |
mocchiut |
1.41 |
UInt_t abstime = 0; |
464 |
mocchiut |
1.1 |
UInt_t evfrom = 0; |
465 |
|
|
UInt_t evto = 0; |
466 |
pam-fi |
1.7 |
UInt_t nevents = 0; |
467 |
|
|
Int_t id_root_l0 =-1; |
468 |
mocchiut |
1.1 |
Int_t trk_calib_used = 0; |
469 |
pam-fi |
1.7 |
|
470 |
mocchiut |
1.31 |
TString host = glt->CGetHost(); // EMILIANO |
471 |
|
|
TString user = glt->CGetUser(); // EMILIANO |
472 |
|
|
TString psw = glt->CGetPsw(); // EMILIANO |
473 |
|
|
// TString host = "mysql://localhost/pamelaprod"; |
474 |
|
|
// TString user = "anonymous"; |
475 |
|
|
// TString psw = ""; |
476 |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
477 |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
478 |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
479 |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
480 |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
481 |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
482 |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
483 |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
484 |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
485 |
mocchiut |
1.29 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
486 |
mocchiut |
1.31 |
stringstream myquery; // EMILIANO |
487 |
|
|
myquery.str(""); // EMILIANO |
488 |
|
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
489 |
mocchiut |
1.39 |
delete dbc->Query(myquery.str().c_str()); // EMILIANO |
490 |
mocchiut |
1.1 |
if(p->standalone){ |
491 |
|
|
// ============================== |
492 |
|
|
// first query: retrieve run info |
493 |
|
|
// ============================== |
494 |
pam-fi |
1.7 |
if (q1.Query_GL_RUN(idRun,dbc) )throw -50; |
495 |
|
|
id_root_l0 = q1.ID_ROOT_L0; |
496 |
mocchiut |
1.1 |
runheadtime = q1.RUNHEADER_TIME; |
497 |
|
|
runtrailtime = q1.RUNTRAILER_TIME; |
498 |
pam-fi |
1.32 |
runheadobt = q1.RUNHEADER_OBT; |
499 |
|
|
runtrailobt = q1.RUNTRAILER_OBT; |
500 |
pam-fi |
1.7 |
evfrom = q1.EV_FROM; |
501 |
|
|
evto = q1.EV_TO; |
502 |
pam-fi |
1.13 |
nevents = q1.NEVENTS; |
503 |
|
|
trk_calib_used = q1.TRK_CALIB_USED; |
504 |
mocchiut |
1.1 |
}else{ |
505 |
|
|
// ============================== |
506 |
|
|
// get run info from RunInfo tree |
507 |
|
|
// ============================== |
508 |
pam-fi |
1.3 |
int runinfo_error = runinfo->GetRunInfo(idRun); |
509 |
pam-fi |
1.7 |
if( runinfo_error ) throw runinfo_error; |
510 |
|
|
id_root_l0 = runinfo->ID_ROOT_L0; |
511 |
mocchiut |
1.1 |
runheadtime = runinfo->RUNHEADER_TIME; |
512 |
|
|
runtrailtime = runinfo->RUNTRAILER_TIME; |
513 |
pam-fi |
1.32 |
runheadobt = runinfo->RUNHEADER_OBT; |
514 |
|
|
runtrailobt = runinfo->RUNTRAILER_OBT; |
515 |
pam-fi |
1.7 |
evfrom = runinfo->EV_FROM; |
516 |
|
|
evto = runinfo->EV_TO; |
517 |
pam-fi |
1.13 |
nevents = runinfo->NEVENTS; |
518 |
|
|
trk_calib_used = runinfo->TRK_CALIB_USED; |
519 |
pam-fi |
1.24 |
|
520 |
mocchiut |
1.1 |
}; |
521 |
pam-fi |
1.24 |
|
522 |
mocchiut |
1.1 |
// |
523 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
524 |
pam-fi |
1.7 |
cout << "ROOT file ID "<< id_root_l0 << endl; |
525 |
mocchiut |
1.1 |
cout << "RunHeader time "<< runheadtime << endl; |
526 |
|
|
cout << "RunTrailer time "<< runtrailtime << endl; |
527 |
pam-fi |
1.7 |
cout << " from event "<< evfrom << endl; |
528 |
|
|
cout << " to event "<< evto << endl; |
529 |
pam-fi |
1.24 |
cout << " num. events "<< nevents << endl; |
530 |
|
|
cout << "trk-calibration used "<< trk_calib_used << endl; |
531 |
mocchiut |
1.1 |
}; |
532 |
|
|
// ======================================================== |
533 |
|
|
// second query: search the LEVEL0 file that contains idRun |
534 |
|
|
// ======================================================== |
535 |
|
|
TString lastfilename = filename; |
536 |
pam-fi |
1.7 |
if( q3.Query_GL_ROOT(id_root_l0,dbc) )throw -51; |
537 |
mocchiut |
1.1 |
filename = q3.PATH + q3.NAME; |
538 |
|
|
// ======================================================== |
539 |
|
|
// Open the input LEVEL0 data file |
540 |
|
|
// ======================================================== |
541 |
|
|
if(filename.CompareTo(lastfilename)){ |
542 |
|
|
if(!lastfilename.IsNull())f0->Close(); |
543 |
|
|
//if( debug ) cout << "Opening LEVEL0 file: "<< filename << endl; |
544 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()) cout << "Opening LEVEL0 file: "<< filename << endl; |
545 |
pam-fi |
1.2 |
FileStat_t t; |
546 |
|
|
if( gSystem->GetPathInfo(filename.Data(),t) )throw -6; |
547 |
mocchiut |
1.39 |
if ( f0 ) f0->Close(); |
548 |
mocchiut |
1.1 |
f0 = new TFile(filename); |
549 |
|
|
if ( !f0 ) throw -6; |
550 |
|
|
physicsTree = (TTree*)f0->Get("Physics"); if(!physicsTree) throw -7; |
551 |
|
|
b_header = physicsTree ->GetBranch("Header"); if(!b_header ) throw -8; |
552 |
|
|
b_trk = physicsTree ->GetBranch("Tracker"); if(!b_trk ) throw -203; |
553 |
pam-fi |
1.22 |
l0_event->Set(); |
554 |
|
|
physicsTree->SetBranchAddress("Tracker" ,l0_event->GetPointerToTrackerEvent()); |
555 |
mocchiut |
1.1 |
physicsTree->SetBranchAddress("Header",&header); |
556 |
|
|
|
557 |
pam-fi |
1.7 |
nentries = physicsTree->GetEntries(); |
558 |
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 |
559 |
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 |
560 |
|
|
// 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 |
561 |
|
|
// the condition ( nentries < (evto+1) ) is satisfied and DV exit with error even if the error is only in the DB. |
562 |
pam-fi |
1.7 |
|
563 |
mocchiut |
1.1 |
}; |
564 |
|
|
|
565 |
pam-fi |
1.7 |
GL_TIMESYNC *dbtime = new GL_TIMESYNC(id_root_l0,"ID",dbc); |
566 |
|
|
|
567 |
pam-fi |
1.24 |
|
568 |
|
|
// ============================================================= |
569 |
|
|
// retrieve information about parameters to process LEVEL2 |
570 |
|
|
// ============================================================= |
571 |
|
|
|
572 |
mocchiut |
1.41 |
TrkParams::Set(runinfo->GetGL_RUN(),dbc); |
573 |
|
|
for(int i=0; i<p->npar; i++){ |
574 |
|
|
if(TrkParams::VerboseMode())cout<<" ((( force parameters from input path )))"<<endl; |
575 |
|
|
TrkParams::Set(p->parpath[i],p->partype[i]); |
576 |
|
|
} |
577 |
pam-fi |
1.25 |
|
578 |
mocchiut |
1.41 |
TrkParams::Load(); |
579 |
|
|
if( !TrkParams::IsLoaded() )throw -52; |
580 |
pam-fi |
1.24 |
|
581 |
|
|
// ============================================================= |
582 |
|
|
// retrieve calibration file needed to reduce data |
583 |
|
|
// ============================================================= |
584 |
|
|
|
585 |
|
|
TrkParams::SetCalib(runinfo->GetGL_RUN(),dbc); |
586 |
|
|
TrkParams::LoadCalib( ); |
587 |
|
|
if( !TrkParams::CalibIsLoaded() )throw -53; |
588 |
|
|
|
589 |
pam-fi |
1.11 |
TBenchmark *reduction = new TBenchmark(); |
590 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode())reduction->Start("reduction"); |
591 |
pam-fi |
1.11 |
Int_t ntrk=0; |
592 |
mocchiut |
1.1 |
// ==================================================== |
593 |
|
|
// start looping on events cointained in the data file |
594 |
|
|
// ==================================================== |
595 |
mocchiut |
1.41 |
if ( TrkParams::GetSimuFlag() ){ |
596 |
|
|
abstime = runheadtime; |
597 |
|
|
} else { |
598 |
|
|
if(dbc){ |
599 |
|
|
dbc->Close(); |
600 |
|
|
delete dbc; |
601 |
|
|
} |
602 |
|
|
} |
603 |
|
|
|
604 |
pam-fi |
1.32 |
for (UInt_t re = evfrom+min(p->nskip,nevents); re < evfrom+nevents; re++){ |
605 |
mocchiut |
1.49 |
|
606 |
mocchiut |
1.1 |
ev_count++; |
607 |
pam-fi |
1.32 |
|
608 |
pam-fi |
1.45 |
// |
609 |
|
|
// NBNB check if events are aligned!!!!!!!!!!! |
610 |
|
|
// |
611 |
|
|
|
612 |
|
|
|
613 |
|
|
if(p->gete){ |
614 |
|
|
int iev = 0; |
615 |
|
|
int jumped = 0; |
616 |
|
|
iev = runinfo->GetFirstEntry() + (re - evfrom -jumped); |
617 |
|
|
if ( t_cal->GetEntry(iev) <= 0 ) throw -36;//EV |
618 |
|
|
if ( t_tof->GetEntry(iev) <= 0 ) throw -36;//EV |
619 |
|
|
} |
620 |
mocchiut |
1.49 |
|
621 |
pam-fi |
1.25 |
// if ( TrkParams::DebugMode() && re%100 == 0 && re > 0 ) cout << "."; |
622 |
mocchiut |
1.1 |
|
623 |
mocchiut |
1.37 |
if ( b_trk->GetEntry(re) <= 0 ) throw -36;//EM |
624 |
|
|
if ( b_header->GetEntry(re) <= 0 ) throw -36;//EM |
625 |
pam-fi |
1.13 |
pscu = header->GetPscuHeader(); |
626 |
mocchiut |
1.49 |
|
627 |
mocchiut |
1.41 |
// ============================================================= |
628 |
|
|
// The following 6 lines have been moved here by VALERIO. |
629 |
|
|
if(TrkParams::GetSimuFlag()){ |
630 |
|
|
abstime = runheadtime + (int) floor(0.03*(re-evfrom)); //If simulated data we need to assign a fake abstime. 30ms between each event. |
631 |
|
|
if(TrkParams::VerboseMode())cout << "Event: " << re-evfrom << " - Attempting to retrieve Mask Info for abstime=" << abstime << endl; |
632 |
|
|
if(!TrkParams::Set(runinfo->GetGL_RUN(),dbc,6,abstime))throw -52; // Setting to load mask (VALERIO) |
633 |
|
|
TrkParams::Load(6); |
634 |
|
|
if( !TrkParams::IsLoaded() )throw -52; |
635 |
|
|
if(TrkParams::VerboseMode())cout << "Mask Info for abstime=" << abstime << " retrieved" << endl; |
636 |
|
|
} |
637 |
|
|
|
638 |
pam-fi |
1.25 |
if( TrkParams::DebugMode() )cout << ">>> "<<ev_count-1<<" @ OBT "<<pscu->GetOrbitalTime()<<endl; |
639 |
pam-fi |
1.23 |
|
640 |
mocchiut |
1.35 |
if ( dbtime->DBabsTime(pscu->GetOrbitalTime()) > (runtrailtime+1) || dbtime->DBabsTime(pscu->GetOrbitalTime()) < (runheadtime-1)) { |
641 |
pam-fi |
1.7 |
|
642 |
pam-fi |
1.25 |
if (TrkParams::VerboseMode()){ |
643 |
pam-fi |
1.14 |
printf(" TrkCore - WARNING: event outside the run time window, skipping it\n"); |
644 |
pam-fi |
1.32 |
cout << " OBT "<<pscu->GetOrbitalTime()<<" RUN "<<runheadobt<<"-"<<runtrailobt<<" ABS-time "<<dbtime->DBabsTime(pscu->GetOrbitalTime())<<" RUN "<<runheadtime<<"-"<<runtrailtime<<endl; |
645 |
pam-fi |
1.14 |
}; |
646 |
pam-fi |
1.13 |
}else{ |
647 |
pam-fi |
1.25 |
if ( TrkParams::DebugMode() ) |
648 |
pam-fi |
1.23 |
printf("\n-------------------------------\nevent %d\n",re-evfrom); |
649 |
pam-fi |
1.16 |
|
650 |
pam-ts |
1.46 |
//============================================= |
651 |
|
|
// EVENT PROCESSING |
652 |
|
|
//============================================= |
653 |
|
|
TStopwatch w; |
654 |
|
|
// cout << " START --------------------------------------------------------------------------"<<endl; |
655 |
|
|
w.Start(); |
656 |
|
|
|
657 |
|
|
// ------------------ |
658 |
|
|
// default tracking |
659 |
|
|
// ------------------ |
660 |
|
|
p->ProcessEvent(l0_event);//call f77 routine |
661 |
|
|
|
662 |
|
|
w.Stop(); |
663 |
|
|
// cout << " STOP default "<<w.CpuTime()<<" s"<<endl; |
664 |
|
|
trkWatch.tTrk = (float) w.CpuTime(); |
665 |
pam-fi |
1.7 |
|
666 |
pam-fi |
1.13 |
// ---------------- |
667 |
|
|
// HOUGH output |
668 |
|
|
// ---------------- |
669 |
|
|
if(p->geth){ |
670 |
|
|
if(p->ifrooth){ // root |
671 |
pam-fi |
1.23 |
lh_event->Delete(); |
672 |
|
|
lh_event->SetFromHoughStruct(&houghevent_); |
673 |
pam-fi |
1.13 |
}else{ // hbook |
674 |
|
|
throw -299; |
675 |
|
|
}; |
676 |
|
|
}; |
677 |
pam-ts |
1.46 |
|
678 |
|
|
// // ---------------- |
679 |
|
|
// // LEVEL2 output |
680 |
|
|
// // ---------------- |
681 |
|
|
l2_event->Clear(); |
682 |
|
|
if(p->get1){ |
683 |
|
|
l2_event->SetFromLevel2Struct(&level2event_,l1_event);//set references to level1 |
684 |
|
|
}else{ |
685 |
|
|
l2_event->SetFromLevel2Struct(&level2event_); |
686 |
|
|
} |
687 |
|
|
|
688 |
|
|
if( l2_event->ntrk()>0 )ntrk++; |
689 |
|
|
if(TrkParams::VerboseMode())l2_event->Dump(); |
690 |
|
|
|
691 |
pam-ts |
1.48 |
|
692 |
|
|
//---------------------------------------------- |
693 |
|
|
// verify conditions to apply extended algorythm |
694 |
|
|
//---------------------------------------------- |
695 |
|
|
bool APPLY_EXTENDED = false; |
696 |
|
|
if( |
697 |
|
|
p->gete && |
698 |
|
|
true){ |
699 |
|
|
|
700 |
|
|
|
701 |
|
|
if(l2_event->ntrk()==0){ |
702 |
|
|
APPLY_EXTENDED = true; |
703 |
|
|
extAlgFlag = 0; |
704 |
|
|
} |
705 |
|
|
if(p->gete_ncheck>0 && ev_count%p->gete_ncheck==0){ |
706 |
|
|
APPLY_EXTENDED = true; |
707 |
|
|
extAlgFlag = 1; |
708 |
mocchiut |
1.49 |
if(l2_event->ntrk()==0) extAlgFlag = 2; // EM make it easier to recognize events with no standard tracks AND forced extended algorithm |
709 |
pam-ts |
1.48 |
} |
710 |
|
|
|
711 |
|
|
} |
712 |
|
|
|
713 |
pam-ts |
1.46 |
w.Start(); |
714 |
|
|
|
715 |
pam-fi |
1.45 |
// ------------------ |
716 |
|
|
// extended-tracking |
717 |
|
|
// ------------------ |
718 |
pam-ts |
1.48 |
// if(p->gete){ |
719 |
|
|
if(APPLY_EXTENDED){ |
720 |
pam-ts |
1.46 |
|
721 |
|
|
l1_event->Clear(); |
722 |
|
|
l1_event->SetFromLevel1Struct(true); |
723 |
|
|
|
724 |
|
|
trkAlg->Clear(); |
725 |
|
|
|
726 |
pam-ts |
1.48 |
// //---------------------------- |
727 |
|
|
// // check conditions |
728 |
|
|
// //---------------------------- |
729 |
|
|
// if( |
730 |
|
|
// l2_event->ntrk()==0 && |
731 |
|
|
// l1_event->nclstr()<24 && |
732 |
|
|
// true){ |
733 |
pam-ts |
1.46 |
|
734 |
pam-ts |
1.48 |
trkAlg->SetDebug(false); |
735 |
|
|
trkAlg->SetTrkLevel2(l2_event); |
736 |
|
|
trkAlg->SetTrkLevel1(l1_event); |
737 |
|
|
trkAlg->SetCaloLevel1(cl1); |
738 |
|
|
trkAlg->SetToFLevel2(tl2); |
739 |
|
|
// trkAlg->Dump(); |
740 |
|
|
trkAlg->ProcessEvent(); |
741 |
mocchiut |
1.49 |
|
742 |
pam-ts |
1.48 |
// } |
743 |
pam-ts |
1.46 |
} |
744 |
|
|
|
745 |
|
|
w.Stop(); |
746 |
|
|
// cout << " STOP extended "<<w.CpuTime()<<" s"<<endl; |
747 |
|
|
trkWatch.tTrkExt = (float) w.CpuTime(); |
748 |
|
|
|
749 |
|
|
|
750 |
|
|
w.Start(); |
751 |
|
|
if(p->getn){ |
752 |
|
|
|
753 |
|
|
l1_event_nuclei->Set(l1_event,5.,0.2);//apply a cut |
754 |
|
|
l1_event_nuclei->GetLevel1Struct();//from cleaned l1 object, to f77 common |
755 |
|
|
l1_event_nuclei->ProcessEvent(); // default routine |
756 |
|
|
l2_event_nuclei->SetFromLevel2Struct(); // from f77 common to l2 object |
757 |
pam-ts |
1.48 |
|
758 |
pam-ts |
1.46 |
trkAlg_nuclei->Clear(); |
759 |
pam-ts |
1.48 |
|
760 |
|
|
if(APPLY_EXTENDED){ |
761 |
|
|
// if(p->gete){ |
762 |
|
|
|
763 |
|
|
// if( |
764 |
|
|
// l2_event_nuclei->ntrk()==0 && |
765 |
|
|
// l1_event_nuclei->nclstr()<24 && |
766 |
|
|
// true){ |
767 |
|
|
|
768 |
|
|
trkAlg_nuclei->SetDebug(false); |
769 |
|
|
trkAlg_nuclei->SetTrkLevel2( l2_event_nuclei ); |
770 |
|
|
trkAlg_nuclei->SetTrkLevel1( l1_event_nuclei );//cleaned level1 |
771 |
|
|
trkAlg_nuclei->SetCaloLevel1( cl1 ); |
772 |
|
|
trkAlg_nuclei->SetToFLevel2( tl2 ); |
773 |
|
|
trkAlg_nuclei->ProcessEvent(); |
774 |
|
|
// } |
775 |
pam-ts |
1.46 |
} |
776 |
|
|
} |
777 |
|
|
|
778 |
|
|
w.Stop(); |
779 |
|
|
// cout << " STOP nuclei "<<w.CpuTime()<<" s"<<endl; |
780 |
|
|
trkWatch.tTrkNuc = (float) w.CpuTime(); |
781 |
pam-fi |
1.45 |
|
782 |
pam-ts |
1.46 |
// ---------------- |
783 |
|
|
// LEVEL1 output |
784 |
|
|
// ---------------- |
785 |
|
|
|
786 |
|
|
if(p->get1 ){ |
787 |
|
|
l1_event->Clear(); |
788 |
|
|
l1_event->SetFromLevel1Struct(p->full1);//get l1 object from f77 common |
789 |
|
|
} |
790 |
mocchiut |
1.49 |
|
791 |
|
|
// EM: bug, check if object exists before using it... |
792 |
|
|
trkWatch.nCl = (l1_event ? l1_event->nclstr() :0); |
793 |
|
|
trkWatch.nClCut = (l1_event_nuclei ? l1_event_nuclei->nclstr() :0); |
794 |
pam-fi |
1.45 |
|
795 |
mocchiut |
1.49 |
trkWatch.nTrk = (l2_event ? l2_event->GetNTracks() :0); |
796 |
|
|
trkWatch.nTrkNuc = (l2_event_nuclei ? l2_event_nuclei->GetNTracks() :0); |
797 |
pam-fi |
1.45 |
|
798 |
pam-ts |
1.46 |
trkWatch.nTrkExt = ( trkAlg ? trkAlg->GetTrackArray()->GetEntries() : 0); |
799 |
|
|
trkWatch.nTrkExtNuc = ( trkAlg_nuclei ? trkAlg_nuclei->GetTrackArray()->GetEntries() : 0); |
800 |
|
|
|
801 |
|
|
///////////////////// |
802 |
|
|
// ==== FILL ===== // |
803 |
|
|
///////////////////// |
804 |
mocchiut |
1.49 |
// cout << " FILL "<<endl; |
805 |
pam-ts |
1.46 |
t_level2->Fill(); |
806 |
|
|
|
807 |
|
|
if(tWatch)tWatch->Fill(); |
808 |
pam-fi |
1.45 |
|
809 |
pam-fi |
1.13 |
}; |
810 |
mocchiut |
1.1 |
}; // end loop on events |
811 |
pam-fi |
1.25 |
if(TrkParams::VerboseMode()){ |
812 |
pam-fi |
1.13 |
cout << " >>> processed "<< ev_count <<" events"<< endl; |
813 |
|
|
if(ev_count)cout << ntrk << " events with at least one track ("<<(Int_t)(100*ntrk/ev_count)<<"%)\n"; |
814 |
|
|
reduction->Show("reduction"); |
815 |
pam-fi |
1.11 |
} |
816 |
|
|
delete reduction; |
817 |
pam-fi |
1.7 |
|
818 |
|
|
delete dbtime; |
819 |
|
|
|
820 |
pam-fi |
1.13 |
}; // end loop on runs |
821 |
|
|
|
822 |
|
|
|
823 |
mocchiut |
1.1 |
// ------------------------------------------------------------ |
824 |
|
|
// if reprocessing one run, copy all the events AFTER the run |
825 |
|
|
// ------------------------------------------------------------ |
826 |
|
|
if( !(p->standalone) ){ |
827 |
|
|
for(UInt_t i=runinfo->GetLastEntry()+1; i<runinfo->GetFileEntries(); i++){ |
828 |
mocchiut |
1.37 |
if ( t_clone->GetEntry(i) <= 0 ) throw -36;//EM |
829 |
mocchiut |
1.1 |
*l2_event = *l2_clone; |
830 |
pam-ts |
1.46 |
// COPY COPY COPY |
831 |
mocchiut |
1.1 |
t_level2->Fill(); |
832 |
|
|
l2_event->Clear(); |
833 |
|
|
}; |
834 |
|
|
}; |
835 |
|
|
// --------------- |
836 |
|
|
// close the files |
837 |
|
|
// --------------- |
838 |
|
|
if(p->get2){ |
839 |
pam-ts |
1.46 |
f2->cd(); |
840 |
|
|
// if(tWatch){ |
841 |
|
|
// if(tWatch)f2->Write("TrkWatch",TObject::kOverwrite); |
842 |
|
|
// } |
843 |
|
|
// f2->Write("Tracker", TObject::kOverwrite); |
844 |
|
|
if( t_level2 )t_level2->Write(); |
845 |
|
|
if( t_level2 )t_level2->Delete(); //delete new tree from memory |
846 |
|
|
|
847 |
mocchiut |
1.40 |
if( t_clone )t_clone->Delete("all");//delete old tree from file |
848 |
pam-fi |
1.13 |
if( !(p->standalone) )runinfo->Close(); |
849 |
pam-ts |
1.46 |
if(tWatch)tWatch->Write(); |
850 |
pam-fi |
1.13 |
|
851 |
|
|
}; |
852 |
pam-ts |
1.46 |
|
853 |
pam-fi |
1.45 |
|
854 |
pam-fi |
1.24 |
if(f0) if(f0->IsOpen()) f0->Close(); |
855 |
pam-ts |
1.46 |
|
856 |
pam-fi |
1.13 |
l1_event->Delete(); |
857 |
|
|
l2_event->Delete(); |
858 |
|
|
l2_clone->Delete(); |
859 |
pam-fi |
1.2 |
|
860 |
pam-fi |
1.45 |
|
861 |
pam-fi |
1.2 |
return(p->ostatus); |
862 |
mocchiut |
1.1 |
} |
863 |
|
|
|