1 |
pam-fi |
1.1 |
#include <PamLevel2.h> |
2 |
|
|
//-------------------------------------- |
3 |
|
|
// |
4 |
|
|
// |
5 |
|
|
//-------------------------------------- |
6 |
|
|
/** |
7 |
|
|
* Default constructor |
8 |
|
|
*/ |
9 |
|
|
PamTrack::PamTrack(){ |
10 |
pam-fi |
1.13 |
trk_track = 0; |
11 |
|
|
calo_track = 0; |
12 |
|
|
tof_track = 0; |
13 |
|
|
candeleteobj = 0; |
14 |
mocchiut |
1.46 |
pscore = 0; |
15 |
|
|
iscore = 0; |
16 |
pam-fi |
1.1 |
}; |
17 |
|
|
//-------------------------------------- |
18 |
|
|
// |
19 |
|
|
// |
20 |
|
|
//-------------------------------------- |
21 |
|
|
/** |
22 |
|
|
* Constructor |
23 |
|
|
*/ |
24 |
|
|
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){ |
25 |
pam-fi |
1.13 |
|
26 |
|
|
trk_track = 0; |
27 |
|
|
calo_track = 0; |
28 |
|
|
tof_track = 0; |
29 |
|
|
// if(t)trk_track = new TrkTrack(*t); |
30 |
|
|
// if(c)calo_track = new CaloTrkVar(*c); |
31 |
|
|
// if(o)tof_track = new ToFTrkVar(*o); |
32 |
|
|
if(t)trk_track = t; |
33 |
|
|
if(c)calo_track = c; |
34 |
|
|
if(o)tof_track = o; |
35 |
|
|
candeleteobj = 0; |
36 |
|
|
|
37 |
pam-fi |
1.1 |
}; |
38 |
pam-fi |
1.13 |
PamTrack::PamTrack(const PamTrack& track){ |
39 |
|
|
|
40 |
|
|
TrkTrack *t = track.trk_track; |
41 |
|
|
CaloTrkVar *c = track.calo_track; |
42 |
|
|
ToFTrkVar *o = track.tof_track; |
43 |
|
|
|
44 |
|
|
trk_track = 0; |
45 |
|
|
calo_track = 0; |
46 |
|
|
tof_track = 0; |
47 |
|
|
if(t)trk_track = new TrkTrack(*t); |
48 |
|
|
if(c)calo_track = new CaloTrkVar(*c); |
49 |
|
|
if(o)tof_track = new ToFTrkVar(*o); |
50 |
|
|
candeleteobj = 1; |
51 |
|
|
|
52 |
|
|
} |
53 |
|
|
void PamTrack::Clear(){ |
54 |
pam-fi |
1.1 |
|
55 |
pam-fi |
1.13 |
// cout << "PamTrack::Clear() "<<candeleteobj<<endl; |
56 |
|
|
if(candeleteobj){ |
57 |
|
|
if(trk_track) trk_track->TrkTrack::Clear(); |
58 |
|
|
if(calo_track) calo_track->CaloTrkVar::Clear();//??? |
59 |
|
|
if(tof_track) tof_track->ToFTrkVar::Clear();//??? |
60 |
|
|
}else{ |
61 |
|
|
trk_track = 0; |
62 |
|
|
calo_track = 0; |
63 |
|
|
tof_track = 0; |
64 |
|
|
} |
65 |
mocchiut |
1.46 |
pscore = 0; |
66 |
|
|
iscore = 0; |
67 |
|
|
|
68 |
pam-fi |
1.13 |
} |
69 |
|
|
void PamTrack::Delete(){ |
70 |
|
|
// cout << "PamTrack::Delete() "<<candeleteobj<<endl; |
71 |
|
|
if(candeleteobj){ |
72 |
|
|
if(trk_track) { |
73 |
|
|
trk_track->TrkTrack::Clear(); |
74 |
|
|
delete trk_track; |
75 |
|
|
} |
76 |
|
|
if(calo_track){ |
77 |
|
|
calo_track->CaloTrkVar::Clear();//??? |
78 |
|
|
delete calo_track; |
79 |
|
|
} |
80 |
|
|
if(tof_track){ |
81 |
|
|
tof_track->ToFTrkVar::Clear();//??? |
82 |
|
|
delete tof_track; |
83 |
|
|
} |
84 |
|
|
}else{ |
85 |
|
|
Clear(); |
86 |
|
|
} |
87 |
|
|
} |
88 |
pam-fi |
1.1 |
//-------------------------------------- |
89 |
|
|
// |
90 |
|
|
// |
91 |
|
|
//-------------------------------------- |
92 |
|
|
/** |
93 |
mocchiut |
1.35 |
* Default Constructor |
94 |
pam-fi |
1.1 |
*/ |
95 |
|
|
PamLevel2::PamLevel2(){ |
96 |
mocchiut |
1.35 |
Initialize(); |
97 |
|
|
}; |
98 |
|
|
|
99 |
|
|
/** |
100 |
|
|
* Constructor with given dir, list and detectors |
101 |
|
|
*/ |
102 |
|
|
PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){ |
103 |
|
|
Initialize(); |
104 |
|
|
GetPamTree(GetListOfLevel2Files(ddir,list),detlist); |
105 |
|
|
GetRunTree(GetListOfLevel2Files(ddir,list)); |
106 |
|
|
}; |
107 |
|
|
|
108 |
|
|
/** |
109 |
|
|
* Constructor with given dir and list |
110 |
|
|
*/ |
111 |
|
|
PamLevel2::PamLevel2(TString ddir,TString list){ |
112 |
|
|
Initialize(); |
113 |
|
|
GetPamTree(GetListOfLevel2Files(ddir,list),""); |
114 |
|
|
GetRunTree(GetListOfLevel2Files(ddir,list)); |
115 |
|
|
}; |
116 |
|
|
|
117 |
|
|
|
118 |
|
|
void PamLevel2::Initialize(){ |
119 |
pam-fi |
1.2 |
|
120 |
pam-fi |
1.20 |
h0_obj = 0; |
121 |
|
|
trk0_obj = 0; |
122 |
mocchiut |
1.30 |
calo0_obj = 0; |
123 |
pam-fi |
1.20 |
|
124 |
pam-fi |
1.13 |
trk2_obj = 0; |
125 |
|
|
trk1_obj = 0; |
126 |
|
|
trkh_obj = 0; |
127 |
|
|
calo1_obj = 0; |
128 |
|
|
calo2_obj = 0; |
129 |
|
|
tof_obj = 0; |
130 |
|
|
trig_obj = 0; |
131 |
|
|
s4_obj = 0; |
132 |
|
|
nd_obj = 0; |
133 |
|
|
ac_obj = 0; |
134 |
|
|
orb_obj = 0; |
135 |
|
|
|
136 |
|
|
run_obj = 0;//new GL_RUN(); |
137 |
mocchiut |
1.15 |
soft_obj = 0;// Emiliano |
138 |
pam-fi |
1.33 |
irun = -1LL; |
139 |
|
|
runfirstentry = 0LL; |
140 |
|
|
runlastentry = 0LL; |
141 |
pam-fi |
1.9 |
|
142 |
pam-fi |
1.20 |
l0_file = NULL; |
143 |
|
|
l0_tree = NULL; |
144 |
|
|
iroot = -1; |
145 |
|
|
dbc = 0; |
146 |
mocchiut |
1.30 |
|
147 |
|
|
prevshift = 0; |
148 |
pam-fi |
1.20 |
|
149 |
|
|
run_tree = NULL; |
150 |
|
|
run_tree_clone = NULL; |
151 |
|
|
sel_tree = NULL; |
152 |
|
|
sel_tree_clone = NULL; |
153 |
|
|
|
154 |
pam-fi |
1.33 |
irunentry = -1LL; |
155 |
pam-fi |
1.20 |
pam_tree = NULL; |
156 |
|
|
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
157 |
|
|
|
158 |
pam-fi |
1.45 |
totdltime[0] = 0LL; |
159 |
|
|
totdltime[1] = 0LL; |
160 |
|
|
|
161 |
pam-fi |
1.20 |
host = "mysql://localhost/pamelaprod"; |
162 |
|
|
user = "anonymous"; |
163 |
|
|
psw = ""; |
164 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
165 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
166 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
167 |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
168 |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
169 |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
170 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
171 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
172 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
173 |
|
|
|
174 |
|
|
|
175 |
pam-fi |
1.9 |
|
176 |
pam-fi |
1.13 |
// sorted_tracks = 0;//new TRefArray(); |
177 |
pam-fi |
1.6 |
|
178 |
pam-fi |
1.20 |
CAL0 = false; |
179 |
pam-fi |
1.9 |
CAL1 = true; |
180 |
pam-fi |
1.8 |
CAL2 = true; |
181 |
|
|
TRK2 = true; |
182 |
|
|
TRK1 = false; |
183 |
|
|
TRKh = false; |
184 |
pam-fi |
1.20 |
TRKh = false; |
185 |
|
|
TRG = true; |
186 |
|
|
TOF = true; |
187 |
|
|
TOF0 = false; |
188 |
|
|
S4 = true; |
189 |
|
|
ND = true; |
190 |
|
|
AC = true; |
191 |
|
|
ORB = true; |
192 |
pam-fi |
1.6 |
|
193 |
pam-fi |
1.20 |
RUN = true; |
194 |
|
|
|
195 |
|
|
SELLI = -1; |
196 |
pam-fi |
1.8 |
|
197 |
pam-fi |
1.43 |
ISGP = false; |
198 |
|
|
|
199 |
pam-fi |
1.13 |
tsorted=0; |
200 |
|
|
timage=0; |
201 |
mocchiut |
1.37 |
|
202 |
|
|
howtosort = "+CAL+TOF"; |
203 |
|
|
//howtosort = "+TOF"; |
204 |
|
|
sortthr = 100.; |
205 |
pam-fi |
1.13 |
|
206 |
pam-fi |
1.2 |
}; |
207 |
|
|
/** |
208 |
pam-fi |
1.13 |
* Delete the event (act as Dtor) |
209 |
pam-fi |
1.2 |
*/ |
210 |
pam-fi |
1.13 |
void PamLevel2::Delete(){ |
211 |
|
|
|
212 |
|
|
if(run_obj)delete run_obj; |
213 |
mocchiut |
1.15 |
if(soft_obj)delete soft_obj; //Emiliano |
214 |
pam-fi |
1.13 |
|
215 |
|
|
// cout << "void PamLevel2::Clear()"<<endl; |
216 |
pam-fi |
1.20 |
if(h0_obj) delete h0_obj; |
217 |
|
|
if(trk0_obj) delete trk0_obj; |
218 |
mocchiut |
1.30 |
if(calo0_obj) delete calo0_obj; |
219 |
pam-fi |
1.13 |
if(trk1_obj) delete trk1_obj; |
220 |
|
|
if(trk2_obj) delete trk2_obj; |
221 |
|
|
if(trkh_obj) delete trkh_obj; |
222 |
|
|
if(calo1_obj)delete calo1_obj; |
223 |
|
|
if(calo2_obj)delete calo2_obj; |
224 |
|
|
if(tof_obj) delete tof_obj; |
225 |
|
|
if(trig_obj) delete trig_obj; |
226 |
|
|
if(s4_obj) delete s4_obj; |
227 |
|
|
if(nd_obj) delete nd_obj; |
228 |
|
|
if(ac_obj) delete ac_obj; |
229 |
|
|
if(orb_obj) delete orb_obj; |
230 |
|
|
|
231 |
|
|
if(tsorted){ |
232 |
|
|
tsorted->Delete(); |
233 |
|
|
delete tsorted; |
234 |
|
|
} |
235 |
|
|
if(timage){ |
236 |
|
|
timage->Delete(); |
237 |
|
|
delete timage; |
238 |
|
|
} |
239 |
pam-fi |
1.20 |
|
240 |
|
|
if(dbc){ |
241 |
|
|
dbc->Close(); |
242 |
|
|
delete dbc; |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
if(l0_file)l0_file->Close(); |
246 |
mocchiut |
1.35 |
// if(pam_tree)pam_tree->Delete();; |
247 |
|
|
|
248 |
|
|
if ( pam_tree ){ |
249 |
|
|
// |
250 |
|
|
// we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... |
251 |
|
|
// |
252 |
|
|
TList *temp = pam_tree->GetListOfFriends(); |
253 |
|
|
TList *contents = new TList; // create chain friend list |
254 |
|
|
contents->SetOwner(); |
255 |
|
|
TIter next(temp); |
256 |
|
|
TChain *questo = 0; |
257 |
|
|
while ( (questo = (TChain*) next()) ){ |
258 |
|
|
TString name = questo->GetName(); |
259 |
|
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
260 |
|
|
}; |
261 |
|
|
// |
262 |
|
|
// deleting the main chain |
263 |
|
|
// |
264 |
|
|
pam_tree->Delete(); |
265 |
|
|
// |
266 |
|
|
// deleting the friends... |
267 |
|
|
// |
268 |
|
|
TIter next2(contents); |
269 |
|
|
TChain *questa = 0; |
270 |
|
|
while ( questa = (TChain*)next2() ){ |
271 |
|
|
TString name = questa->GetName(); |
272 |
|
|
questa->Delete(); |
273 |
|
|
questa=NULL; |
274 |
|
|
}; |
275 |
|
|
// |
276 |
|
|
}; |
277 |
|
|
pam_tree = NULL; |
278 |
|
|
|
279 |
pam-fi |
1.20 |
if(run_tree)run_tree->Delete();; |
280 |
|
|
if(sel_tree)sel_tree->Delete();; |
281 |
|
|
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
282 |
|
|
if(run_tree_clone)run_tree_clone->Delete();; |
283 |
|
|
if(sel_tree_clone)sel_tree_clone->Delete();; |
284 |
|
|
|
285 |
|
|
|
286 |
pam-fi |
1.2 |
}; |
287 |
pam-fi |
1.13 |
|
288 |
pam-fi |
1.2 |
/** |
289 |
pam-fi |
1.13 |
* Clear the event (NB! does not deallocate objects) |
290 |
pam-fi |
1.2 |
*/ |
291 |
|
|
void PamLevel2::Clear(){ |
292 |
pam-fi |
1.3 |
|
293 |
pam-fi |
1.13 |
// cout << "void PamLevel2::Clear()"<<endl; |
294 |
mocchiut |
1.15 |
|
295 |
|
|
// |
296 |
mocchiut |
1.17 |
// This method is called once for every entry but RunInfo and SoftInfo do not change until the next run so we cannot clear them here unless we don't |
297 |
|
|
// want to load them for each event even if they are the same... |
298 |
|
|
// |
299 |
mocchiut |
1.15 |
// if(run_obj)delete run_obj; |
300 |
mocchiut |
1.17 |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
301 |
|
|
// if(soft_obj) soft_obj->Clear(); |
302 |
pam-fi |
1.13 |
|
303 |
pam-fi |
1.20 |
if(h0_obj) h0_obj->Clear(); |
304 |
pam-fi |
1.33 |
// if(trk0_obj) trk0_obj->Clear(); |
305 |
pam-fi |
1.13 |
if(trk1_obj) trk1_obj->Clear(); |
306 |
mocchiut |
1.35 |
if(trk2_obj) trk2_obj->Clear(); |
307 |
pam-fi |
1.13 |
if(trkh_obj) trkh_obj->Clear(); |
308 |
pam-fi |
1.40 |
if(calo0_obj) calo0_obj->Clear(); |
309 |
pam-fi |
1.13 |
if(calo1_obj)calo1_obj->Clear(); |
310 |
|
|
if(calo2_obj)calo2_obj->Clear(); |
311 |
|
|
if(tof_obj) tof_obj->Clear(); |
312 |
|
|
if(trig_obj) trig_obj->Clear(); |
313 |
|
|
if(s4_obj) s4_obj->Clear(); |
314 |
|
|
if(nd_obj) nd_obj->Clear(); |
315 |
|
|
if(ac_obj) ac_obj->Clear(); |
316 |
|
|
if(orb_obj) orb_obj->Clear(); |
317 |
pam-fi |
1.6 |
|
318 |
pam-fi |
1.13 |
// if(sorted_tracks)sorted_tracks->Clear(); |
319 |
|
|
// sorted_tracks.Clear(); |
320 |
|
|
|
321 |
|
|
if(tsorted){ |
322 |
|
|
tsorted->Delete(); |
323 |
|
|
} |
324 |
|
|
if(timage){ |
325 |
|
|
timage->Delete(); |
326 |
|
|
} |
327 |
mocchiut |
1.35 |
}; |
328 |
|
|
|
329 |
|
|
void PamLevel2::Reset(){ |
330 |
|
|
// |
331 |
|
|
// First of all clear everything |
332 |
|
|
// |
333 |
|
|
Clear(); |
334 |
|
|
// |
335 |
|
|
// close and reset chains and pointers |
336 |
|
|
// |
337 |
|
|
if ( pam_tree ){ |
338 |
|
|
// |
339 |
|
|
// we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... |
340 |
|
|
// |
341 |
|
|
TList *temp = pam_tree->GetListOfFriends(); |
342 |
|
|
TList *contents = new TList; // create chain friend list |
343 |
|
|
contents->SetOwner(); |
344 |
|
|
TIter next(temp); |
345 |
|
|
TChain *questo = 0; |
346 |
|
|
while ( (questo = (TChain*) next()) ){ |
347 |
|
|
TString name = questo->GetName(); |
348 |
|
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
349 |
|
|
}; |
350 |
|
|
// |
351 |
|
|
// deleting the main chain |
352 |
|
|
// |
353 |
|
|
pam_tree->Delete(); |
354 |
|
|
// |
355 |
|
|
// deleting the friends... |
356 |
|
|
// |
357 |
|
|
TIter next2(contents); |
358 |
|
|
TChain *questa = 0; |
359 |
|
|
while ( questa = (TChain*)next2() ){ |
360 |
|
|
TString name = questa->GetName(); |
361 |
|
|
questa->Delete(); |
362 |
|
|
questa=NULL; |
363 |
|
|
}; |
364 |
|
|
// |
365 |
|
|
}; |
366 |
|
|
pam_tree = NULL; |
367 |
|
|
// |
368 |
|
|
if(run_tree)run_tree->Delete();; |
369 |
|
|
run_tree = NULL; |
370 |
|
|
if(sel_tree)sel_tree->Delete();; |
371 |
|
|
sel_tree = NULL; |
372 |
|
|
// |
373 |
|
|
// Close file |
374 |
|
|
// |
375 |
|
|
if(l0_file)l0_file->Close("R"); |
376 |
|
|
l0_file = NULL; |
377 |
|
|
// |
378 |
|
|
h0_obj = 0; |
379 |
|
|
trk0_obj = 0; |
380 |
|
|
calo0_obj = 0; |
381 |
|
|
// |
382 |
|
|
trk2_obj = 0; |
383 |
|
|
trk1_obj = 0; |
384 |
|
|
trkh_obj = 0; |
385 |
|
|
calo1_obj = 0; |
386 |
|
|
calo2_obj = 0; |
387 |
|
|
tof_obj = 0; |
388 |
|
|
trig_obj = 0; |
389 |
|
|
s4_obj = 0; |
390 |
|
|
nd_obj = 0; |
391 |
|
|
ac_obj = 0; |
392 |
|
|
orb_obj = 0; |
393 |
|
|
// |
394 |
|
|
// Reset run pointers |
395 |
|
|
// |
396 |
|
|
run_obj = 0;//new GL_RUN(); |
397 |
|
|
soft_obj = 0;// Emiliano |
398 |
|
|
irun = -1; |
399 |
|
|
runfirstentry = 0ULL; |
400 |
|
|
runlastentry = 0ULL; |
401 |
|
|
// |
402 |
pam-fi |
1.45 |
totdltime[0] = 0LL; |
403 |
|
|
totdltime[1] = 0LL; |
404 |
|
|
// |
405 |
pam-fi |
1.1 |
}; |
406 |
pam-fi |
1.2 |
|
407 |
mocchiut |
1.38 |
Bool_t PamLevel2::IsGood(){ |
408 |
|
|
Bool_t goodev=true; |
409 |
|
|
// if(trk2_obj && trk2_obj->UnpackError() != 0 ) goodev = false; |
410 |
|
|
if(calo2_obj && calo2_obj->good != 1) goodev = false; |
411 |
|
|
if(tof_obj && tof_obj->unpackError != 0) goodev = false; |
412 |
|
|
if(trig_obj && trig_obj->unpackError != 0) goodev = false; |
413 |
|
|
if(s4_obj && s4_obj->unpackError != 0) goodev = false; |
414 |
|
|
if(nd_obj && nd_obj->unpackError != 0) goodev = false; |
415 |
|
|
if(ac_obj && ac_obj->unpackError != 255) goodev = false; |
416 |
|
|
// if(orb_obj) |
417 |
|
|
return goodev; |
418 |
|
|
}; |
419 |
pam-fi |
1.2 |
|
420 |
pam-fi |
1.1 |
//-------------------------------------- |
421 |
|
|
// |
422 |
|
|
// |
423 |
|
|
//-------------------------------------- |
424 |
pam-fi |
1.9 |
void *PamLevel2::GetPointerTo(const char* c ){ |
425 |
|
|
|
426 |
|
|
TString objname = c; |
427 |
pam-fi |
1.13 |
|
428 |
|
|
if(!objname.CompareTo("TrkLevel1")) { |
429 |
pam-fi |
1.14 |
if(!trk1_obj){ |
430 |
|
|
trk1_obj = new TrkLevel1(); |
431 |
|
|
trk1_obj->Set(); |
432 |
|
|
} |
433 |
pam-fi |
1.13 |
return &trk1_obj; |
434 |
|
|
}; |
435 |
|
|
if(!objname.CompareTo("TrkLevel2")) { |
436 |
pam-fi |
1.14 |
if(!trk2_obj){ |
437 |
|
|
trk2_obj = new TrkLevel2(); |
438 |
|
|
trk2_obj->Set(); |
439 |
|
|
} |
440 |
pam-fi |
1.13 |
return &trk2_obj; |
441 |
|
|
}; |
442 |
|
|
if(!objname.CompareTo("TrkHough")) { |
443 |
|
|
if(!trkh_obj) trkh_obj = new TrkHough(); |
444 |
|
|
return &trkh_obj; |
445 |
|
|
}; |
446 |
|
|
if(!objname.CompareTo("CaloLevel1")) { |
447 |
|
|
if(!calo1_obj) calo1_obj = new CaloLevel1(); |
448 |
|
|
return &calo1_obj; |
449 |
|
|
}; |
450 |
|
|
if(!objname.CompareTo("CaloLevel2")) { |
451 |
pam-fi |
1.14 |
if(!calo2_obj){ |
452 |
|
|
calo2_obj = new CaloLevel2(); |
453 |
|
|
calo2_obj->Set(); |
454 |
|
|
}; |
455 |
pam-fi |
1.13 |
return &calo2_obj; |
456 |
|
|
}; |
457 |
|
|
if(!objname.CompareTo("ToFLevel2")) { |
458 |
pam-fi |
1.14 |
if(!tof_obj){ |
459 |
|
|
tof_obj = new ToFLevel2(); |
460 |
|
|
tof_obj->Set(); |
461 |
|
|
} |
462 |
pam-fi |
1.13 |
return &tof_obj; |
463 |
|
|
}; |
464 |
|
|
if(!objname.CompareTo("TrigLevel2")) { |
465 |
|
|
if(!trig_obj) trig_obj = new TrigLevel2(); |
466 |
|
|
return &trig_obj; |
467 |
|
|
}; |
468 |
|
|
if(!objname.CompareTo("S4Level2")) { |
469 |
|
|
if(!s4_obj) s4_obj = new S4Level2(); |
470 |
|
|
return &s4_obj; |
471 |
|
|
}; |
472 |
|
|
if(!objname.CompareTo("NDLevel2")) { |
473 |
|
|
if(!nd_obj) nd_obj = new NDLevel2(); |
474 |
|
|
return &nd_obj; |
475 |
|
|
}; |
476 |
|
|
if(!objname.CompareTo("AcLevel2")) { |
477 |
|
|
if(!ac_obj) ac_obj = new AcLevel2(); |
478 |
|
|
return &ac_obj; |
479 |
|
|
}; |
480 |
|
|
if(!objname.CompareTo("OrbitalInfo")){ |
481 |
|
|
if(!orb_obj) orb_obj = new OrbitalInfo(); |
482 |
|
|
return &orb_obj; |
483 |
|
|
}; |
484 |
|
|
|
485 |
pam-fi |
1.9 |
if(!objname.CompareTo("RunInfo"))return &run_obj; |
486 |
mocchiut |
1.15 |
|
487 |
|
|
if(!objname.CompareTo("SoftInfo"))return &soft_obj; // Emiliano |
488 |
|
|
|
489 |
pam-fi |
1.9 |
return NULL; |
490 |
|
|
}; |
491 |
|
|
//-------------------------------------- |
492 |
|
|
// |
493 |
|
|
// |
494 |
|
|
//-------------------------------------- |
495 |
pam-fi |
1.1 |
/** |
496 |
pam-fi |
1.3 |
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
497 |
|
|
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
498 |
|
|
*/ |
499 |
|
|
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
500 |
pam-fi |
1.13 |
|
501 |
|
|
if( !calo2_obj )return 0; |
502 |
|
|
|
503 |
|
|
if( calo2_obj->CaloLevel2::ntrk()==0 ){ |
504 |
pam-fi |
1.6 |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
505 |
|
|
return NULL; |
506 |
|
|
}; |
507 |
|
|
|
508 |
|
|
CaloTrkVar *c = 0; |
509 |
|
|
Int_t it_calo=0; |
510 |
|
|
|
511 |
|
|
do{ |
512 |
pam-fi |
1.13 |
c = calo2_obj->CaloLevel2::GetCaloTrkVar(it_calo); |
513 |
pam-fi |
1.6 |
it_calo++; |
514 |
pam-fi |
1.13 |
} while( c && seqno != c->trkseqno && it_calo < calo2_obj->CaloLevel2::ntrk()); |
515 |
pam-fi |
1.6 |
|
516 |
|
|
if(!c || seqno != c->trkseqno){ |
517 |
|
|
c = 0; |
518 |
|
|
if(seqno!=-1)cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match Calorimeter stored tracks"<<endl; |
519 |
|
|
}; |
520 |
|
|
return c; |
521 |
|
|
|
522 |
pam-fi |
1.3 |
}; |
523 |
|
|
//-------------------------------------- |
524 |
|
|
// |
525 |
|
|
// |
526 |
|
|
//-------------------------------------- |
527 |
|
|
/** |
528 |
|
|
* Retrieves the ToF track matching the seqno-th tracker stored track. |
529 |
|
|
* (If seqno = -1 retrieves the tracker-independent tof track) |
530 |
|
|
*/ |
531 |
|
|
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
532 |
|
|
|
533 |
pam-fi |
1.13 |
if( !tof_obj )return 0; |
534 |
|
|
|
535 |
|
|
if( tof_obj->ToFLevel2::ntrk()==0 ){ |
536 |
pam-fi |
1.6 |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
537 |
|
|
return NULL; |
538 |
|
|
}; |
539 |
|
|
|
540 |
|
|
ToFTrkVar *c = 0; |
541 |
|
|
Int_t it_tof=0; |
542 |
|
|
|
543 |
|
|
do{ |
544 |
pam-fi |
1.13 |
c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); |
545 |
pam-fi |
1.6 |
it_tof++; |
546 |
pam-fi |
1.13 |
} while( c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); |
547 |
pam-fi |
1.6 |
|
548 |
|
|
if(!c || seqno != c->trkseqno){ |
549 |
|
|
c = 0; |
550 |
|
|
if(seqno!=-1)cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match ToF stored tracks"<<endl; |
551 |
|
|
}; |
552 |
|
|
return c; |
553 |
|
|
|
554 |
pam-fi |
1.3 |
}; |
555 |
|
|
|
556 |
|
|
//-------------------------------------- |
557 |
|
|
// |
558 |
|
|
// |
559 |
|
|
//-------------------------------------- |
560 |
|
|
/** |
561 |
|
|
* Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. |
562 |
|
|
*/ |
563 |
|
|
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
564 |
pam-fi |
1.13 |
|
565 |
|
|
cout <<"PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** "<<endl; |
566 |
|
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
567 |
|
|
|
568 |
pam-fi |
1.6 |
CaloTrkVar *c = 0; |
569 |
|
|
ToFTrkVar *o = 0; |
570 |
|
|
|
571 |
pam-fi |
1.8 |
if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo()); |
572 |
pam-fi |
1.6 |
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
573 |
|
|
|
574 |
pam-fi |
1.3 |
// if(t && c && o)track = new PamTrack(t,c,o); |
575 |
pam-fi |
1.6 |
PamTrack *track = new PamTrack(t,c,o); |
576 |
|
|
|
577 |
|
|
return track; |
578 |
pam-fi |
1.3 |
|
579 |
|
|
}; |
580 |
|
|
//-------------------------------------- |
581 |
|
|
// |
582 |
|
|
// |
583 |
|
|
//-------------------------------------- |
584 |
|
|
/** |
585 |
pam-fi |
1.1 |
* Retrieves the it-th stored track. |
586 |
|
|
* It override TrkLevel2::GetTrack(int it). |
587 |
|
|
* @param itrk Track number, ranging from 0 to GetNTracks(). |
588 |
|
|
*/ |
589 |
|
|
|
590 |
|
|
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
591 |
|
|
|
592 |
pam-fi |
1.13 |
cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl; |
593 |
|
|
cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl; |
594 |
|
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
595 |
pam-fi |
1.6 |
PamTrack *track = 0; |
596 |
|
|
|
597 |
pam-fi |
1.13 |
if( itrk >=0 && itrk < trk2_obj->TrkLevel2::ntrk() ){ |
598 |
pam-fi |
1.3 |
|
599 |
pam-fi |
1.13 |
TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); |
600 |
pam-fi |
1.6 |
track = GetPamTrackAlong(t); |
601 |
pam-fi |
1.2 |
|
602 |
pam-fi |
1.13 |
|
603 |
|
|
|
604 |
pam-fi |
1.6 |
}else{ |
605 |
pam-fi |
1.13 |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
606 |
pam-fi |
1.6 |
}; |
607 |
|
|
|
608 |
|
|
return track; |
609 |
|
|
|
610 |
pam-fi |
1.1 |
} |
611 |
|
|
//-------------------------------------- |
612 |
|
|
// |
613 |
mocchiut |
1.37 |
|
614 |
|
|
/** |
615 |
|
|
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. Left here as backward compatibility method. |
616 |
|
|
**/ |
617 |
|
|
void PamLevel2::SortTracks(TString how){ |
618 |
|
|
printf(" WARNING! obsolete, use SortTracks() and SetSortingMethod(TString) instead! \n Setting sorting method to %s \n",how.Data()); |
619 |
|
|
howtosort = how; |
620 |
|
|
SortTracks(); |
621 |
|
|
}; |
622 |
|
|
|
623 |
pam-fi |
1.1 |
// |
624 |
|
|
//-------------------------------------- |
625 |
|
|
/** |
626 |
pam-fi |
1.3 |
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. |
627 |
|
|
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
628 |
|
|
* Sorting cryteria: |
629 |
pam-fi |
1.8 |
* TRK: lower chi**2 |
630 |
pam-fi |
1.3 |
* CAL: lower Y spatial residual on the first calorimeter plane |
631 |
|
|
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
632 |
|
|
* The default sorting cryterium is "TOF+CAL". |
633 |
|
|
* |
634 |
|
|
* The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how). |
635 |
pam-fi |
1.1 |
*/ |
636 |
mocchiut |
1.37 |
void PamLevel2::SortTracks(){ |
637 |
|
|
TString how = howtosort; |
638 |
pam-fi |
1.1 |
|
639 |
mocchiut |
1.46 |
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
640 |
mocchiut |
1.37 |
if( !trk2_obj ){ |
641 |
|
|
cout << "void PamLevel2::SortTracks(): TrkLevel2 not loaded !!!"; |
642 |
|
|
return; |
643 |
|
|
}; |
644 |
|
|
// cout << "call SortTracs() "<<endl; |
645 |
pam-fi |
1.4 |
//Save current Object count |
646 |
mocchiut |
1.37 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
647 |
pam-fi |
1.9 |
|
648 |
mocchiut |
1.37 |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
649 |
pam-fi |
1.13 |
|
650 |
mocchiut |
1.37 |
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
651 |
|
|
// sorted_tracks->Clear(); |
652 |
|
|
// sorted_tracks.Clear(); |
653 |
pam-fi |
1.13 |
|
654 |
mocchiut |
1.37 |
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
655 |
|
|
tsorted->Delete(); |
656 |
|
|
TClonesArray &ttsorted = *tsorted; |
657 |
|
|
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
658 |
|
|
timage->Delete(); |
659 |
|
|
TClonesArray &ttimage = *timage; |
660 |
pam-fi |
1.13 |
|
661 |
|
|
|
662 |
pam-fi |
1.41 |
|
663 |
|
|
//-------------------------------------------------- |
664 |
|
|
// retrieve sorting method |
665 |
|
|
//-------------------------------------------------- |
666 |
mocchiut |
1.37 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
667 |
|
|
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
668 |
|
|
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
669 |
mocchiut |
1.46 |
Bool_t use_S1 = how.Contains("S1", TString::kIgnoreCase); |
670 |
|
|
Bool_t use_S2 = how.Contains("S2", TString::kIgnoreCase); |
671 |
|
|
Bool_t use_S3 = how.Contains("S3", TString::kIgnoreCase); |
672 |
|
|
|
673 |
|
|
if ( use_TOF ){ |
674 |
|
|
use_S1 = true; |
675 |
|
|
use_S2 = true; |
676 |
|
|
use_S3 = true; |
677 |
|
|
}; |
678 |
mocchiut |
1.37 |
if( !CAL2 && use_CAL) use_CAL = false; |
679 |
mocchiut |
1.46 |
if( !TOF ){ |
680 |
|
|
use_TOF = false; |
681 |
|
|
use_S1 = false; |
682 |
|
|
use_S2 = false; |
683 |
|
|
use_S3 = false; |
684 |
|
|
} |
685 |
|
|
|
686 |
mocchiut |
1.37 |
if( !TRK2 ){ |
687 |
|
|
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
688 |
|
|
return; |
689 |
|
|
}; |
690 |
pam-fi |
1.9 |
|
691 |
mocchiut |
1.37 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
692 |
pam-fi |
1.41 |
|
693 |
|
|
|
694 |
|
|
//-------------------------------------------------- |
695 |
|
|
// loop over "physical" tracks sorted by the tracker |
696 |
|
|
//-------------------------------------------------- |
697 |
mocchiut |
1.37 |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
698 |
pam-fi |
1.4 |
|
699 |
mocchiut |
1.37 |
TrkTrack *ts = 0; |
700 |
|
|
CaloTrkVar *cs = 0; |
701 |
|
|
ToFTrkVar *os = 0; |
702 |
|
|
|
703 |
|
|
// get tracker tracks |
704 |
pam-fi |
1.41 |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
705 |
mocchiut |
1.37 |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
706 |
|
|
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
707 |
|
|
|
708 |
pam-fi |
1.41 |
TrkTrack *ti = 0; //tracker (image) |
709 |
mocchiut |
1.37 |
CaloTrkVar *ci = 0; |
710 |
|
|
ToFTrkVar *oi = 0; |
711 |
|
|
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
712 |
|
|
// if track has an image, check image selection |
713 |
mocchiut |
1.46 |
|
714 |
|
|
Int_t tp_score = 0; //main track sorted by the tracker |
715 |
|
|
Int_t ti_score = 0; //image track |
716 |
|
|
Int_t totp_score = 0; //main track sorted by the tracker |
717 |
|
|
Int_t toti_score = 0; //image track |
718 |
|
|
|
719 |
mocchiut |
1.37 |
if(tp->HasImage()){ |
720 |
pam-fi |
1.6 |
|
721 |
mocchiut |
1.37 |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
722 |
|
|
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
723 |
|
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
724 |
pam-fi |
1.6 |
|
725 |
mocchiut |
1.37 |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
726 |
pam-fi |
1.9 |
|
727 |
mocchiut |
1.37 |
//assign starting scores |
728 |
mocchiut |
1.46 |
tp_score = 0; //main track sorted by the tracker |
729 |
|
|
ti_score = 0; //image track |
730 |
pam-fi |
1.6 |
|
731 |
pam-fi |
1.41 |
// ----------------------------------------------------------------------------------------- |
732 |
mocchiut |
1.37 |
// calorimeter check |
733 |
pam-fi |
1.41 |
// ----------------------------------------------------------------------------------------- |
734 |
mocchiut |
1.37 |
// check the Y spatial residual on the first calorimeter plane |
735 |
|
|
// (cut on calorimeter variables from Emiliano) |
736 |
|
|
if( use_CAL && !calo2_obj ){ |
737 |
|
|
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!"; |
738 |
|
|
return; |
739 |
|
|
}; |
740 |
mocchiut |
1.46 |
if( use_CAL && !cp && ci ){ |
741 |
|
|
ti_score++; |
742 |
|
|
toti_score++; |
743 |
|
|
}; |
744 |
|
|
if( use_CAL && cp && !ci ){ |
745 |
|
|
tp_score++; |
746 |
|
|
totp_score++; |
747 |
|
|
}; |
748 |
mocchiut |
1.37 |
if( |
749 |
|
|
use_CAL && |
750 |
pam-fi |
1.41 |
// calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
751 |
|
|
// calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
752 |
mocchiut |
1.37 |
cp && ci && |
753 |
|
|
true){ |
754 |
pam-fi |
1.9 |
|
755 |
pam-fi |
1.6 |
|
756 |
pam-fi |
1.41 |
// Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
757 |
|
|
// Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
758 |
pam-fi |
1.6 |
|
759 |
pam-fi |
1.41 |
// if(resy_p <= resy_i) tp_score++; |
760 |
|
|
// else ti_score++; |
761 |
mocchiut |
1.37 |
|
762 |
pam-fi |
1.41 |
|
763 |
mocchiut |
1.46 |
if( cp->npresh > ci->npresh){ |
764 |
|
|
tp_score++; |
765 |
|
|
totp_score++; |
766 |
|
|
}; |
767 |
|
|
if( cp->npresh < ci->npresh){ |
768 |
|
|
ti_score++; |
769 |
|
|
toti_score++; |
770 |
|
|
}; |
771 |
pam-fi |
1.41 |
|
772 |
mocchiut |
1.37 |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
773 |
pam-fi |
1.9 |
|
774 |
mocchiut |
1.37 |
}; |
775 |
pam-fi |
1.41 |
// ----------------------------------------------------------------------------------------- |
776 |
mocchiut |
1.37 |
// TOF check |
777 |
pam-fi |
1.41 |
// ----------------------------------------------------------------------------------------- |
778 |
mocchiut |
1.37 |
// check the number of hit pmts along the track |
779 |
|
|
// on S12 S21 and S32, where paddles are parallel to Y axis |
780 |
mocchiut |
1.46 |
if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !tof_obj ){ |
781 |
mocchiut |
1.37 |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!"; |
782 |
|
|
return; |
783 |
|
|
}; |
784 |
mocchiut |
1.46 |
// |
785 |
|
|
if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !op && oi ){ |
786 |
|
|
ti_score++; |
787 |
|
|
toti_score++; |
788 |
|
|
}; |
789 |
|
|
if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && !oi ){ |
790 |
|
|
tp_score++; |
791 |
|
|
totp_score++; |
792 |
|
|
}; |
793 |
|
|
if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && oi ){ |
794 |
mocchiut |
1.37 |
// |
795 |
|
|
Float_t sen = 0.; |
796 |
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
797 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
798 |
|
|
if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (op->dedx).At(ih); |
799 |
|
|
}; |
800 |
|
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
801 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
802 |
|
|
if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (oi->dedx).At(ih); |
803 |
|
|
}; |
804 |
|
|
// |
805 |
mocchiut |
1.46 |
if ( sen >= sortthr && false){ // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!) |
806 |
mocchiut |
1.37 |
//printf(" IS A NUCLEUS! en = %f \n",sen); |
807 |
|
|
// |
808 |
|
|
// is a nucleus use a different algorithm |
809 |
|
|
// |
810 |
|
|
Int_t nz = 6; Float_t zin[6]; // << define TOF z-coordinates |
811 |
|
|
for(Int_t ip=0; ip<nz; ip++) |
812 |
|
|
zin[ip] = tof_obj->ToFLevel2::GetZTOF(tof_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates |
813 |
|
|
Trajectory *tr = new Trajectory(nz,zin); |
814 |
|
|
// |
815 |
|
|
Int_t nphit_p =0; |
816 |
|
|
Int_t nphit_i =0; |
817 |
|
|
Float_t enhit_p = 0.; |
818 |
|
|
Float_t enhit_i = 0.; |
819 |
|
|
// |
820 |
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
821 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
822 |
|
|
if(pl == 1 || pl == 2 || pl == 5){ |
823 |
|
|
nphit_p++; |
824 |
|
|
enhit_p += (op->dedx).At(ih); |
825 |
|
|
}; |
826 |
|
|
}; |
827 |
|
|
// |
828 |
|
|
tp->DoTrack2(tr); |
829 |
|
|
// |
830 |
|
|
if ( fabs(tr->y[0]-oi->ytofpos[0]) < 2. ){ |
831 |
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
832 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
833 |
|
|
if(pl == 0){ |
834 |
|
|
nphit_p++; |
835 |
|
|
enhit_p += (op->dedx).At(ih); |
836 |
|
|
}; |
837 |
|
|
}; |
838 |
|
|
}; |
839 |
|
|
if ( fabs(tr->y[3]-oi->ytofpos[1]) < 2. ){ |
840 |
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
841 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
842 |
|
|
if(pl == 3){ |
843 |
|
|
nphit_p++; |
844 |
|
|
enhit_p += (op->dedx).At(ih); |
845 |
|
|
}; |
846 |
|
|
}; |
847 |
|
|
}; |
848 |
|
|
if ( fabs(tr->y[4]-oi->ytofpos[2]) < 2. ){ |
849 |
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
850 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
851 |
|
|
if(pl == 4){ |
852 |
|
|
nphit_p++; |
853 |
|
|
enhit_p += (op->dedx).At(ih); |
854 |
|
|
}; |
855 |
|
|
}; |
856 |
|
|
}; |
857 |
pam-fi |
1.9 |
|
858 |
mocchiut |
1.37 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
859 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
860 |
|
|
if(pl == 1 || pl == 2 || pl == 5){ |
861 |
|
|
nphit_i++; |
862 |
|
|
enhit_i += (op->dedx).At(ih); |
863 |
|
|
}; |
864 |
|
|
}; |
865 |
|
|
// |
866 |
|
|
ti->DoTrack2(tr); |
867 |
|
|
// |
868 |
|
|
if ( fabs(tr->y[0]-oi->ytofpos[0]) < 2. ){ |
869 |
|
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
870 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
871 |
|
|
if(pl == 0){ |
872 |
|
|
nphit_i++; |
873 |
|
|
enhit_i += (op->dedx).At(ih); |
874 |
|
|
}; |
875 |
|
|
}; |
876 |
|
|
}; |
877 |
|
|
if ( fabs(tr->y[3]-oi->ytofpos[1]) < 2. ){ |
878 |
|
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
879 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
880 |
|
|
if(pl == 3){ |
881 |
|
|
nphit_i++; |
882 |
|
|
enhit_i += (op->dedx).At(ih); |
883 |
|
|
}; |
884 |
pam-fi |
1.6 |
}; |
885 |
mocchiut |
1.37 |
}; |
886 |
|
|
if ( fabs(tr->y[4]-oi->ytofpos[2]) < 2. ){ |
887 |
|
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
888 |
|
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
889 |
|
|
if(pl == 4){ |
890 |
|
|
nphit_i++; |
891 |
|
|
enhit_i += (op->dedx).At(ih); |
892 |
|
|
}; |
893 |
pam-fi |
1.13 |
}; |
894 |
mocchiut |
1.37 |
}; |
895 |
|
|
|
896 |
pam-fi |
1.6 |
|
897 |
mocchiut |
1.37 |
if( |
898 |
mocchiut |
1.46 |
(use_TOF || use_S1 || use_S2 || use_S3) && |
899 |
mocchiut |
1.37 |
(nphit_p+nphit_i) !=0 && |
900 |
|
|
true){ |
901 |
|
|
|
902 |
|
|
// printf(" seqno %i nphit_p %i nphit_i %i enhit_p %f enhit_i %f \n",trk2_obj->TrkLevel2::GetSeqNo(i),nphit_p,nphit_i,enhit_p,enhit_i); |
903 |
|
|
// printf(" score p %i score i %i \n",tp_score,ti_score); |
904 |
|
|
// if( enhit_p > enhit_i ) tp_score++; |
905 |
|
|
// if( nphit_p >= nphit_i && enhit_p > enhit_i ) tp_score++; |
906 |
|
|
if ( nphit_p > nphit_i ) tp_score++; |
907 |
|
|
if ( nphit_p < nphit_i ) ti_score++; |
908 |
|
|
if ( nphit_p == nphit_i ){ |
909 |
|
|
if ( enhit_p > enhit_i ) tp_score++; |
910 |
|
|
else ti_score++; |
911 |
|
|
}; |
912 |
|
|
// printf(" dopo score p %i score i %i \n",tp_score,ti_score); |
913 |
|
|
}; |
914 |
|
|
delete tr; |
915 |
|
|
// |
916 |
|
|
} else { |
917 |
|
|
// |
918 |
|
|
// NOT a NUCLEUS |
919 |
|
|
// |
920 |
|
|
//printf(" NOT a NUCLEUS! en = %f \n",sen); |
921 |
|
|
|
922 |
|
|
Int_t nphit_p =0; |
923 |
|
|
Int_t nphit_i =0; |
924 |
pam-fi |
1.6 |
|
925 |
|
|
|
926 |
mocchiut |
1.37 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
927 |
|
|
cout << "track: npmttdc "<< op->npmttdc << endl; |
928 |
|
|
cout << "image: npmtadc "<< oi->npmtadc << endl; |
929 |
|
|
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
930 |
pam-fi |
1.6 |
|
931 |
pam-fi |
1.41 |
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
932 |
|
|
// Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
933 |
|
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
934 |
|
|
// }; |
935 |
|
|
|
936 |
|
|
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
937 |
|
|
// Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
938 |
|
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
939 |
|
|
// }; |
940 |
|
|
// --- modified to count tdc signals (more efficient?) |
941 |
|
|
// --- and to implement check on tdcflag |
942 |
|
|
for (Int_t ih=0; ih < op->npmttdc; ih++){ |
943 |
mocchiut |
1.46 |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) ); |
944 |
pam-fi |
1.41 |
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
945 |
mocchiut |
1.46 |
if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){ |
946 |
|
|
if( (op->tdcflag).At(ih)==0 )nphit_p++; |
947 |
|
|
}; |
948 |
mocchiut |
1.37 |
}; |
949 |
pam-fi |
1.6 |
|
950 |
pam-fi |
1.41 |
for (Int_t ih=0; ih < oi->npmttdc; ih++){ |
951 |
mocchiut |
1.46 |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) ); |
952 |
pam-fi |
1.41 |
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
953 |
mocchiut |
1.46 |
if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){ |
954 |
|
|
if( (oi->tdcflag).At(ih)==0 )nphit_i++; |
955 |
|
|
}; |
956 |
mocchiut |
1.37 |
}; |
957 |
pam-fi |
1.6 |
|
958 |
mocchiut |
1.37 |
if( |
959 |
|
|
(nphit_p+nphit_i) !=0 && |
960 |
|
|
true){ |
961 |
pam-fi |
1.6 |
|
962 |
mocchiut |
1.46 |
if ( nphit_p != nphit_i ){ |
963 |
|
|
totp_score += nphit_p; |
964 |
|
|
toti_score += nphit_i; |
965 |
mocchiut |
1.47 |
tp_score+=nphit_p; |
966 |
|
|
ti_score+=nphit_i; |
967 |
mocchiut |
1.46 |
}; |
968 |
mocchiut |
1.47 |
// if ( nphit_p > nphit_i) tp_score+=nphit_p; |
969 |
|
|
// else if( nphit_p < nphit_i) ti_score+=nphit_i; |
970 |
|
|
// else ;//niente |
971 |
mocchiut |
1.37 |
}; |
972 |
|
|
}; |
973 |
|
|
// cout << "TOF "<<tp_score<<ti_score<<endl; |
974 |
|
|
}; |
975 |
pam-fi |
1.41 |
|
976 |
|
|
|
977 |
|
|
// if(tp_score == ti_score) use_TRK = true; |
978 |
|
|
|
979 |
|
|
|
980 |
|
|
// ----------------------------------------------------------------------------------------- |
981 |
mocchiut |
1.37 |
// tracker check |
982 |
pam-fi |
1.41 |
// ----------------------------------------------------------------------------------------- |
983 |
mocchiut |
1.37 |
// chi**2 difference is not always large enough to distinguish among |
984 |
|
|
// the real track and its image. |
985 |
|
|
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
986 |
pam-fi |
1.41 |
// *** MODIFIED ON AUGUST 2007 *** |
987 |
mocchiut |
1.37 |
if(use_TRK){ |
988 |
pam-fi |
1.41 |
// if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
989 |
|
|
// else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
990 |
|
|
|
991 |
|
|
// CHECK 1 : number of points along X |
992 |
mocchiut |
1.46 |
if ( tp->GetNX() >= ti->GetNX() ){ |
993 |
|
|
tp_score++ ; |
994 |
|
|
totp_score++ ; |
995 |
|
|
}; |
996 |
|
|
if ( tp->GetNX() <= ti->GetNX() ){ |
997 |
|
|
ti_score++ ; |
998 |
|
|
toti_score++ ; |
999 |
|
|
}; |
1000 |
pam-fi |
1.41 |
// CHECK 2 : number of points along Y |
1001 |
mocchiut |
1.46 |
if ( tp->GetNY() >= ti->GetNY() ){ |
1002 |
|
|
tp_score++ ; |
1003 |
|
|
totp_score++ ; |
1004 |
|
|
}; |
1005 |
|
|
if ( tp->GetNY() <= ti->GetNY() ){ |
1006 |
|
|
ti_score++ ; |
1007 |
|
|
toti_score++ ; |
1008 |
|
|
}; |
1009 |
pam-fi |
1.41 |
// CHECK 3 : chi**2 along X |
1010 |
|
|
// if( tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ; |
1011 |
|
|
// if( ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ; |
1012 |
|
|
// CHECK 4 : chi**2 along Y |
1013 |
|
|
// if( tp->GetChi2Y() > 0 && (tp->GetChi2Y() < ti->GetChi2Y() || ti->GetChi2Y() <=0) ) tp_score++ ; |
1014 |
|
|
// if( ti->GetChi2Y() > 0 && (ti->GetChi2Y() < tp->GetChi2Y() || tp->GetChi2Y() <=0) ) ti_score++ ; |
1015 |
|
|
// CHECK 5 : total chi**2 |
1016 |
|
|
// if( tp->chi2 > 0 && (tp->chi2 < ti->chi2 || ti->chi2 <=0) ) tp_score++ ; |
1017 |
|
|
// if( ti->chi2 > 0 && (ti->chi2 < tp->chi2 || tp->chi2 <=0) ) ti_score++ ; |
1018 |
|
|
|
1019 |
mocchiut |
1.37 |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
1020 |
|
|
}; |
1021 |
pam-fi |
1.6 |
|
1022 |
pam-fi |
1.41 |
|
1023 |
|
|
|
1024 |
|
|
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
1025 |
mocchiut |
1.37 |
// the winner is.... |
1026 |
pam-fi |
1.41 |
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
1027 |
mocchiut |
1.37 |
if (tp_score > ti_score) { |
1028 |
pam-fi |
1.41 |
|
1029 |
mocchiut |
1.37 |
|
1030 |
|
|
}else if (tp_score < ti_score) { |
1031 |
|
|
|
1032 |
|
|
|
1033 |
|
|
ts = ti;//its image!! |
1034 |
|
|
cs = ci; |
1035 |
|
|
os = oi; |
1036 |
mocchiut |
1.48 |
Int_t totis = toti_score; |
1037 |
mocchiut |
1.37 |
|
1038 |
|
|
ti = tp;//its image!! |
1039 |
|
|
ci = cp; |
1040 |
|
|
oi = op; |
1041 |
|
|
|
1042 |
|
|
tp = ts;//its image!! |
1043 |
|
|
cp = cs; |
1044 |
|
|
op = os; |
1045 |
pam-fi |
1.13 |
|
1046 |
mocchiut |
1.48 |
toti_score = totp_score; |
1047 |
|
|
totp_score = totis; |
1048 |
|
|
|
1049 |
pam-fi |
1.13 |
|
1050 |
mocchiut |
1.37 |
}else { |
1051 |
pam-fi |
1.41 |
|
1052 |
pam-fi |
1.39 |
// cout << "Warning - track image ambiguity not solved" << endl; |
1053 |
pam-fi |
1.41 |
|
1054 |
mocchiut |
1.37 |
}; |
1055 |
pam-fi |
1.6 |
|
1056 |
mocchiut |
1.37 |
}else{ |
1057 |
mocchiut |
1.46 |
totp_score = 1; |
1058 |
|
|
toti_score = 0; |
1059 |
|
|
|
1060 |
mocchiut |
1.37 |
// ts = tp; |
1061 |
|
|
// cs = cp; |
1062 |
|
|
// os = op; |
1063 |
|
|
}; |
1064 |
|
|
|
1065 |
|
|
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
1066 |
|
|
// sorted_tracks->Add(ts);//save the track in the sorted array |
1067 |
|
|
// sorted_tracks.Add(ts);//save the track in the sorted array |
1068 |
|
|
// sorted_tracks.Add(tp);//save the track in the sorted array |
1069 |
|
|
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
1070 |
|
|
// cout<<"o "<<tp<<endl; |
1071 |
|
|
// cout<<"o "<<cp<<endl; |
1072 |
|
|
// cout<<"o "<<op<<endl; |
1073 |
mocchiut |
1.46 |
|
1074 |
mocchiut |
1.37 |
new(ttsorted[i]) PamTrack(tp,cp,op); |
1075 |
|
|
new(ttimage[i]) PamTrack(ti,ci,oi); |
1076 |
mocchiut |
1.46 |
|
1077 |
|
|
((PamTrack*)(ttsorted[i]))->SetPScore(totp_score); |
1078 |
mocchiut |
1.48 |
((PamTrack*)(ttsorted[i]))->SetIScore(toti_score); |
1079 |
|
|
((PamTrack*)(ttimage[i]))->SetPScore(totp_score); |
1080 |
mocchiut |
1.46 |
((PamTrack*)(ttimage[i]))->SetIScore(toti_score); |
1081 |
mocchiut |
1.37 |
}; |
1082 |
|
|
|
1083 |
|
|
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
1084 |
|
|
cout << "void PamLevel2::SortTracks(): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
1085 |
|
|
tsorted->Delete(); tsorted=0; |
1086 |
|
|
timage->Delete(); timage=0; |
1087 |
|
|
} |
1088 |
|
|
|
1089 |
|
|
//Restore Object count |
1090 |
|
|
//To save space in the table keeping track of all referenced objects |
1091 |
|
|
//We reset the object count to what it was at the beginning of the event. |
1092 |
|
|
TProcessID::SetObjectCount(ObjectNumber); |
1093 |
pam-fi |
1.6 |
|
1094 |
pam-fi |
1.1 |
}; |
1095 |
|
|
//-------------------------------------- |
1096 |
|
|
// |
1097 |
|
|
// |
1098 |
|
|
//-------------------------------------- |
1099 |
|
|
/** |
1100 |
pam-fi |
1.2 |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
1101 |
|
|
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
1102 |
|
|
*/ |
1103 |
pam-fi |
1.13 |
// TRefArray *PamLevel2::GetTracks(){ |
1104 |
|
|
|
1105 |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1106 |
|
|
// SortTracks("+CAL+TOF"); |
1107 |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1108 |
|
|
|
1109 |
|
|
// // return sorted_tracks; |
1110 |
|
|
// return &sorted_tracks; |
1111 |
|
|
|
1112 |
|
|
// }; |
1113 |
|
|
TClonesArray *PamLevel2::GetTracks(){ |
1114 |
pam-fi |
1.8 |
|
1115 |
|
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1116 |
mocchiut |
1.37 |
SortTracks(); |
1117 |
pam-fi |
1.8 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1118 |
|
|
|
1119 |
pam-fi |
1.13 |
return tsorted; |
1120 |
|
|
|
1121 |
pam-fi |
1.2 |
}; |
1122 |
|
|
//-------------------------------------- |
1123 |
pam-fi |
1.3 |
// |
1124 |
|
|
// |
1125 |
pam-fi |
1.2 |
//-------------------------------------- |
1126 |
|
|
/** |
1127 |
pam-fi |
1.1 |
* Retrieves the it-th Pamela "physical" track. |
1128 |
|
|
* It override TrkLevel2::GetTrack(int it). |
1129 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
1130 |
|
|
*/ |
1131 |
|
|
PamTrack *PamLevel2::GetTrack(int it){ |
1132 |
pam-fi |
1.13 |
|
1133 |
|
|
// if(!trk2_obj) return 0; |
1134 |
pam-fi |
1.3 |
|
1135 |
mocchiut |
1.37 |
// // *-*-*-*+-*-*-*-*-*-*-*-*-* |
1136 |
pam-fi |
1.13 |
// SortTracks("+CAL+TOF"); |
1137 |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1138 |
|
|
// // if(!sorted_tracks)return 0; |
1139 |
|
|
// if(sorted_tracks.IsEmpty())return 0; |
1140 |
|
|
|
1141 |
|
|
// PamTrack *track = 0; |
1142 |
|
|
|
1143 |
|
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && it<sorted_tracks.GetEntriesFast() ){ |
1144 |
|
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
1145 |
|
|
// track = GetPamTrackAlong(t); |
1146 |
|
|
// }else{ |
1147 |
|
|
// cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
1148 |
|
|
// }; |
1149 |
|
|
|
1150 |
|
|
// return track; |
1151 |
|
|
|
1152 |
|
|
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
1153 |
pam-fi |
1.8 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1154 |
mocchiut |
1.37 |
SortTracks(); |
1155 |
pam-fi |
1.8 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1156 |
pam-fi |
1.13 |
if(!tsorted)return 0; |
1157 |
|
|
if(!tsorted->GetEntries())return 0; |
1158 |
|
|
|
1159 |
pam-fi |
1.6 |
PamTrack *track = 0; |
1160 |
|
|
|
1161 |
pam-fi |
1.13 |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks()){ |
1162 |
|
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
1163 |
|
|
// track = GetPamTrackAlong(t); |
1164 |
|
|
TClonesArray &t = *(tsorted); |
1165 |
|
|
track = (PamTrack*)t[it]; |
1166 |
|
|
|
1167 |
pam-fi |
1.6 |
}else{ |
1168 |
pam-fi |
1.13 |
cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
1169 |
pam-fi |
1.6 |
}; |
1170 |
|
|
|
1171 |
|
|
return track; |
1172 |
|
|
|
1173 |
pam-fi |
1.1 |
}; |
1174 |
pam-fi |
1.3 |
|
1175 |
pam-fi |
1.1 |
//-------------------------------------- |
1176 |
|
|
// |
1177 |
|
|
// |
1178 |
|
|
//-------------------------------------- |
1179 |
|
|
/** |
1180 |
pam-fi |
1.3 |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
1181 |
pam-fi |
1.1 |
* @param it Track number, ranging from 0 to GetNTracks(). |
1182 |
|
|
*/ |
1183 |
|
|
PamTrack *PamLevel2::GetTrackImage(int it){ |
1184 |
|
|
|
1185 |
pam-fi |
1.13 |
// if(!trk2_obj) return 0; |
1186 |
|
|
|
1187 |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1188 |
|
|
// SortTracks("+CAL+TOF"); |
1189 |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1190 |
|
|
// // if(!sorted_tracks)return 0; |
1191 |
|
|
// if(sorted_tracks.IsEmpty())return 0; |
1192 |
|
|
|
1193 |
|
|
// PamTrack *image = 0; |
1194 |
|
|
|
1195 |
|
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
1196 |
|
|
// TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it); |
1197 |
|
|
// if( temp->HasImage() ){ |
1198 |
|
|
// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
1199 |
|
|
// image = GetPamTrackAlong(t); |
1200 |
|
|
// }else{ |
1201 |
|
|
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
1202 |
|
|
// }; |
1203 |
|
|
// }else{ |
1204 |
|
|
// cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
1205 |
|
|
// }; |
1206 |
|
|
|
1207 |
|
|
// return image; |
1208 |
|
|
|
1209 |
|
|
|
1210 |
pam-fi |
1.8 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1211 |
mocchiut |
1.37 |
SortTracks(); |
1212 |
pam-fi |
1.8 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1213 |
pam-fi |
1.13 |
if(!timage)return 0; |
1214 |
|
|
if(!timage->GetEntries())return 0; |
1215 |
pam-fi |
1.8 |
|
1216 |
|
|
PamTrack *image = 0; |
1217 |
|
|
|
1218 |
pam-fi |
1.13 |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
1219 |
|
|
TClonesArray &t = *(tsorted); |
1220 |
|
|
PamTrack *temp = (PamTrack*)t[it]; |
1221 |
|
|
if( temp->GetTrkTrack()->HasImage() ){ |
1222 |
|
|
TClonesArray &t = *(timage); |
1223 |
|
|
image = (PamTrack*)t[it]; |
1224 |
pam-fi |
1.2 |
}else{ |
1225 |
pam-fi |
1.13 |
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
1226 |
pam-fi |
1.1 |
}; |
1227 |
pam-fi |
1.8 |
}else{ |
1228 |
pam-fi |
1.13 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
1229 |
pam-fi |
1.8 |
}; |
1230 |
pam-fi |
1.1 |
|
1231 |
pam-fi |
1.8 |
return image; |
1232 |
pam-fi |
1.1 |
} |
1233 |
|
|
|
1234 |
|
|
//-------------------------------------- |
1235 |
|
|
// |
1236 |
|
|
// |
1237 |
|
|
//-------------------------------------- |
1238 |
|
|
/** |
1239 |
pam-fi |
1.2 |
* Get the Pamela detector trees in a single file and make them friends. |
1240 |
|
|
* @param f TFile pointer |
1241 |
|
|
* @param detlist String to select trees to be included |
1242 |
|
|
* @return Pointer to a TTree |
1243 |
pam-fi |
1.1 |
*/ |
1244 |
pam-fi |
1.11 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ){ |
1245 |
pam-fi |
1.4 |
|
1246 |
pam-fi |
1.12 |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
1247 |
|
|
// else GetWhichTrees(f); |
1248 |
mocchiut |
1.35 |
if ( pam_tree ){ |
1249 |
|
|
printf("WARNING: TTree *PamLevel2::GetPamTree(TFile *fl, TString detlist) -- pam_tree already exists!\n "); |
1250 |
|
|
return pam_tree; |
1251 |
|
|
}; |
1252 |
|
|
// |
1253 |
|
|
|
1254 |
pam-fi |
1.20 |
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
1255 |
|
|
|
1256 |
pam-fi |
1.12 |
SetWhichTrees(detlist); |
1257 |
pam-fi |
1.9 |
|
1258 |
pam-fi |
1.6 |
TTree *Trout =0; |
1259 |
pam-fi |
1.9 |
|
1260 |
|
|
TString fname = f->GetName(); |
1261 |
|
|
if(!CheckLevel2File(fname))return NULL; |
1262 |
|
|
|
1263 |
pam-fi |
1.20 |
// UInt_t *found=0; |
1264 |
pam-fi |
1.11 |
|
1265 |
pam-fi |
1.12 |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
1266 |
|
|
if(TRK1)cout<<"TRK1 "; |
1267 |
|
|
if(TRK2)cout<<"TRK2 "; |
1268 |
|
|
if(TRKh)cout<<"TRKH "; |
1269 |
|
|
if(CAL1)cout<<"CAL1 "; |
1270 |
|
|
if(CAL2)cout<<"CAL2 "; |
1271 |
|
|
if(TOF)cout<<"TOF "; |
1272 |
|
|
if(TRG)cout<<"TRG "; |
1273 |
|
|
if(AC)cout<<"AC "; |
1274 |
|
|
if(ND)cout<<"ND "; |
1275 |
|
|
if(S4)cout<<"S4 "; |
1276 |
|
|
if(ORB)cout<<"ORB "; |
1277 |
|
|
cout << endl; |
1278 |
pam-fi |
1.20 |
if(SELLI)cout<<">>> Found selection-list <<<"<<endl; |
1279 |
pam-fi |
1.12 |
|
1280 |
|
|
f->cd(); |
1281 |
|
|
|
1282 |
pam-fi |
1.4 |
// Tracker |
1283 |
pam-fi |
1.1 |
TTree *T = (TTree*)f->Get("Tracker"); |
1284 |
pam-fi |
1.8 |
if(T && (TRK2||TRK1||TRKh)) { |
1285 |
pam-fi |
1.9 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1286 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkLevel2",0,found); |
1287 |
pam-fi |
1.8 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1288 |
pam-fi |
1.9 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1289 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkLevel1",0,found); |
1290 |
pam-fi |
1.8 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1291 |
pam-fi |
1.9 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1292 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkHough",0,found); |
1293 |
pam-fi |
1.9 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1294 |
|
|
if(!Trout)Trout=T; |
1295 |
|
|
else Trout->AddFriend(T); |
1296 |
pam-fi |
1.1 |
}else{ |
1297 |
|
|
cout << "Tracker : missing tree"<<endl; |
1298 |
|
|
}; |
1299 |
|
|
// Calorimeter |
1300 |
|
|
TTree *C = (TTree*)f->Get("Calorimeter"); |
1301 |
pam-fi |
1.9 |
if(C && (CAL2||CAL1)) { |
1302 |
|
|
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1303 |
pam-fi |
1.20 |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1304 |
pam-fi |
1.9 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1305 |
|
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1306 |
pam-fi |
1.20 |
// else C->SetBranchStatus("CaloLevel1",0,found); |
1307 |
pam-fi |
1.9 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1308 |
pam-fi |
1.4 |
if(!Trout)Trout=C; |
1309 |
|
|
else Trout->AddFriend(C); |
1310 |
pam-fi |
1.1 |
}else{ |
1311 |
|
|
cout << "Calorimeter : missing tree"<<endl; |
1312 |
|
|
}; |
1313 |
pam-fi |
1.12 |
|
1314 |
pam-fi |
1.1 |
// ToF |
1315 |
|
|
TTree *O = (TTree*)f->Get("ToF"); |
1316 |
pam-fi |
1.2 |
if(O && TOF) { |
1317 |
pam-fi |
1.9 |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1318 |
pam-fi |
1.1 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1319 |
pam-fi |
1.4 |
if(!Trout)Trout=O; |
1320 |
|
|
else Trout->AddFriend(O); |
1321 |
pam-fi |
1.1 |
}else{ |
1322 |
|
|
cout << "ToF : missing tree"<<endl; |
1323 |
|
|
}; |
1324 |
|
|
// Trigger |
1325 |
|
|
TTree *R = (TTree*)f->Get("Trigger"); |
1326 |
pam-fi |
1.2 |
if(R && TRG) { |
1327 |
pam-fi |
1.9 |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1328 |
pam-fi |
1.1 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1329 |
mocchiut |
1.35 |
if(!Trout)Trout=R; |
1330 |
pam-fi |
1.4 |
else Trout->AddFriend(R); |
1331 |
pam-fi |
1.1 |
}else{ |
1332 |
|
|
cout << "Trigger : missing tree"<<endl; |
1333 |
|
|
}; |
1334 |
|
|
// S4 |
1335 |
|
|
TTree *S = (TTree*)f->Get("S4"); |
1336 |
pam-fi |
1.2 |
if(S && S4) { |
1337 |
pam-fi |
1.9 |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1338 |
pam-fi |
1.1 |
cout << "S4 : set branch address S4Level2"<<endl; |
1339 |
mocchiut |
1.35 |
if(!Trout)Trout=S; |
1340 |
pam-fi |
1.4 |
else Trout->AddFriend(S); |
1341 |
pam-fi |
1.1 |
}else{ |
1342 |
|
|
cout << "S4 : missing tree"<<endl; |
1343 |
|
|
}; |
1344 |
|
|
// Neutron Detector |
1345 |
|
|
TTree *N = (TTree*)f->Get("NeutronD"); |
1346 |
pam-fi |
1.2 |
if(N && ND) { |
1347 |
pam-fi |
1.9 |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1348 |
pam-fi |
1.1 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1349 |
mocchiut |
1.35 |
if(!Trout)Trout=N; |
1350 |
pam-fi |
1.4 |
else Trout->AddFriend(N); |
1351 |
pam-fi |
1.1 |
}else{ |
1352 |
|
|
cout << "NeutronD : missing tree"<<endl; |
1353 |
|
|
}; |
1354 |
|
|
// Anticounters |
1355 |
|
|
TTree *A = (TTree*)f->Get("Anticounter"); |
1356 |
pam-fi |
1.2 |
if(A && AC) { |
1357 |
pam-fi |
1.9 |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1358 |
pam-fi |
1.1 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1359 |
mocchiut |
1.35 |
if(!Trout)Trout=A; |
1360 |
pam-fi |
1.4 |
else Trout->AddFriend(A); |
1361 |
pam-fi |
1.1 |
}else{ |
1362 |
|
|
cout << "Anticounter : missing tree"<<endl; |
1363 |
|
|
}; |
1364 |
pam-fi |
1.2 |
// Orbital Info |
1365 |
pam-fi |
1.11 |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
1366 |
|
|
if(B && ORB) { |
1367 |
|
|
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1368 |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1369 |
mocchiut |
1.35 |
if(!Trout)Trout=B; |
1370 |
pam-fi |
1.11 |
else Trout->AddFriend(B); |
1371 |
|
|
}else{ |
1372 |
|
|
cout << "OrbitalInfo : missing tree"<<endl; |
1373 |
|
|
}; |
1374 |
pam-fi |
1.20 |
|
1375 |
|
|
TTree *L = (TTree*)f->Get("SelectionList"); |
1376 |
|
|
if(L && SELLI==1) { |
1377 |
|
|
// L->SetBranchAddress("RunEntry",&irun); |
1378 |
|
|
// cout << "SelectionList: set branch address RunEntry"<<endl; |
1379 |
|
|
// L->SetBranchAddress("EventEntry",&irunentry); |
1380 |
|
|
// cout << "SelectionList: set branch address EventEntry"<<endl; |
1381 |
|
|
// if(!Trout)Trout=O; |
1382 |
|
|
// else Trout->AddFriend("SelectionList"); |
1383 |
|
|
cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemente!!!!"<<endl; |
1384 |
|
|
sel_tree = 0; |
1385 |
|
|
}else{ |
1386 |
|
|
cout << "SelectionList : missing tree"<<endl; |
1387 |
|
|
}; |
1388 |
pam-fi |
1.11 |
|
1389 |
|
|
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1390 |
mocchiut |
1.28 |
|
1391 |
|
|
pam_tree = (TChain*)Trout; |
1392 |
pam-fi |
1.1 |
|
1393 |
pam-fi |
1.11 |
return Trout; |
1394 |
pam-fi |
1.1 |
|
1395 |
|
|
} |
1396 |
pam-fi |
1.2 |
//-------------------------------------- |
1397 |
|
|
// |
1398 |
|
|
// |
1399 |
|
|
//-------------------------------------- |
1400 |
|
|
/** |
1401 |
|
|
* Get list of Level2 files. |
1402 |
|
|
* @param ddir Level2 data directory. |
1403 |
|
|
* @param flisttxt Name of txt file containing file list. |
1404 |
|
|
* @return Pointer to a TList of TSystemFiles |
1405 |
|
|
* If no input file list is given , all the Level2 files inside the directory are processed. |
1406 |
|
|
*/ |
1407 |
|
|
TList* PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){ |
1408 |
|
|
|
1409 |
pam-fi |
1.6 |
TString wdir = gSystem->WorkingDirectory(); |
1410 |
|
|
|
1411 |
mocchiut |
1.35 |
// if(ddir=="")ddir = wdir; |
1412 |
pam-fi |
1.6 |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
1413 |
mocchiut |
1.35 |
if ( ddir != ""){ |
1414 |
|
|
cout << "Level2 data directory : "<< ddir << endl; |
1415 |
|
|
} else { |
1416 |
|
|
cout << "Level2 data directory not given as input: trying to evaluate from list or taking working directory " << endl; |
1417 |
|
|
}; |
1418 |
pam-fi |
1.6 |
TList *contents = new TList; // create output list |
1419 |
|
|
contents->SetOwner(); |
1420 |
|
|
|
1421 |
pam-fi |
1.16 |
// char *fullpath; |
1422 |
pam-fi |
1.18 |
// const char *fullpath; |
1423 |
pam-fi |
1.6 |
|
1424 |
pam-fi |
1.26 |
// if no input file list is given: |
1425 |
pam-fi |
1.6 |
if ( flisttxt != "" ){ |
1426 |
pam-fi |
1.2 |
|
1427 |
pam-fi |
1.16 |
// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ |
1428 |
pam-fi |
1.18 |
// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ |
1429 |
|
|
// cout <<"File "<<flisttxt<<" not found"<<endl; |
1430 |
|
|
// return 0; |
1431 |
|
|
// } |
1432 |
|
|
// flisttxt = fullpath; |
1433 |
mocchiut |
1.28 |
if ( !flisttxt.EndsWith(".root") ){ |
1434 |
pam-fi |
1.18 |
|
1435 |
|
|
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1436 |
pam-fi |
1.16 |
|
1437 |
pam-fi |
1.11 |
if( !gSystem->ChangeDirectory(ddir) ){ |
1438 |
|
|
cout << "Cannot change directory : "<<ddir<<endl; |
1439 |
|
|
return 0; |
1440 |
|
|
} |
1441 |
pam-fi |
1.2 |
|
1442 |
pam-fi |
1.6 |
cout <<"Input file list : " << flisttxt <<endl; |
1443 |
|
|
ifstream in; |
1444 |
|
|
in.open(flisttxt, ios::in); //open input file list |
1445 |
pam-fi |
1.18 |
if(!in.good()){ |
1446 |
|
|
cout <<" ERROR opening the file "<<endl; |
1447 |
|
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
1448 |
|
|
return 0; |
1449 |
|
|
} |
1450 |
pam-fi |
1.9 |
int line=0; |
1451 |
pam-fi |
1.6 |
while (1) { |
1452 |
|
|
TString file; |
1453 |
|
|
in >> file; |
1454 |
|
|
if (!in.good()) break; |
1455 |
pam-fi |
1.9 |
line++; |
1456 |
pam-fi |
1.8 |
// cout <<"(1) " << file << endl; |
1457 |
pam-fi |
1.9 |
if(file.IsNull()){ |
1458 |
|
|
cout << "-- list interrupted at line "<<line <<endl; |
1459 |
|
|
break; |
1460 |
|
|
} |
1461 |
pam-fi |
1.10 |
if(file.Contains("#"))file = file(0,file.First("#")); |
1462 |
|
|
// cout <<"(2) " << file << endl; |
1463 |
pam-fi |
1.16 |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
1464 |
pam-fi |
1.18 |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
1465 |
pam-fi |
1.19 |
if( file.EndsWith(".root") ){ |
1466 |
mocchiut |
1.35 |
TString filedir; |
1467 |
|
|
if (ddir != ""){ |
1468 |
|
|
filedir = ddir; // take the input dir |
1469 |
|
|
} else { |
1470 |
|
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
1471 |
|
|
filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir |
1472 |
|
|
}; |
1473 |
|
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file)); |
1474 |
pam-fi |
1.19 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1475 |
|
|
delete fullpath; |
1476 |
|
|
} |
1477 |
pam-fi |
1.18 |
// }else{ |
1478 |
pam-fi |
1.10 |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
1479 |
pam-fi |
1.18 |
// }; |
1480 |
pam-fi |
1.6 |
}; |
1481 |
|
|
in.close(); |
1482 |
mocchiut |
1.28 |
} else { |
1483 |
mocchiut |
1.35 |
if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); |
1484 |
mocchiut |
1.28 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1485 |
|
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1486 |
|
|
delete fullpath; |
1487 |
|
|
}; |
1488 |
pam-fi |
1.6 |
}else{ |
1489 |
pam-fi |
1.2 |
|
1490 |
pam-fi |
1.6 |
cout << "No input file list given."<<endl; |
1491 |
|
|
cout << "Check for existing root files."<<endl; |
1492 |
pam-fi |
1.2 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
1493 |
mocchiut |
1.35 |
if ( ddir == "" ){ |
1494 |
|
|
ddir = wdir; |
1495 |
|
|
cout << "Level2 data directory : "<< ddir << endl; |
1496 |
|
|
}; |
1497 |
|
|
|
1498 |
pam-fi |
1.6 |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
1499 |
|
|
TList *temp = datadir->GetListOfFiles(); |
1500 |
pam-fi |
1.2 |
// temp->Print(); |
1501 |
|
|
// cout << "*************************************" << endl; |
1502 |
|
|
|
1503 |
pam-fi |
1.6 |
TIter next(temp); |
1504 |
|
|
TSystemFile *questo = 0; |
1505 |
|
|
|
1506 |
|
|
|
1507 |
|
|
while ( (questo = (TSystemFile*) next()) ) { |
1508 |
|
|
TString name = questo-> GetName(); |
1509 |
|
|
if( name.EndsWith(".root") ){ |
1510 |
pam-fi |
1.18 |
// const char *fullpath = gSystem->FindFile(ddir,name); |
1511 |
pam-fi |
1.16 |
// char *fullpath; |
1512 |
|
|
// gSystem->IsFileInIncludePath(name,&fullpath); |
1513 |
pam-fi |
1.18 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name)); |
1514 |
pam-fi |
1.6 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
1515 |
pam-fi |
1.18 |
delete fullpath; |
1516 |
pam-fi |
1.6 |
}; |
1517 |
|
|
} |
1518 |
|
|
delete temp; |
1519 |
|
|
delete datadir; |
1520 |
|
|
|
1521 |
|
|
}; |
1522 |
|
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
1523 |
pam-fi |
1.5 |
// cout << endl << "Selected files:" << endl; |
1524 |
|
|
// contents->Print(); |
1525 |
pam-fi |
1.18 |
cout << contents->GetEntries()<<" files \n"; |
1526 |
pam-fi |
1.5 |
// cout << endl; |
1527 |
pam-fi |
1.4 |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
1528 |
pam-fi |
1.6 |
return contents; |
1529 |
pam-fi |
1.2 |
}; |
1530 |
|
|
//-------------------------------------- |
1531 |
|
|
// |
1532 |
|
|
// |
1533 |
|
|
//-------------------------------------- |
1534 |
|
|
/** |
1535 |
|
|
* Get the Pamela detector chains from a list of files and make them friends. |
1536 |
|
|
* @param fl Pointer to a TList of TSystemFiles |
1537 |
|
|
* @param detlist String to select trees to be included |
1538 |
|
|
* @return Pointer to a TChain |
1539 |
|
|
*/ |
1540 |
pam-fi |
1.11 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
1541 |
mocchiut |
1.35 |
// |
1542 |
|
|
// |
1543 |
|
|
// |
1544 |
|
|
if ( pam_tree ){ |
1545 |
|
|
printf("WARNING: TChain *PamLevel2::GetPamTree(TList *fl, TString detlist) -- pam_tree already exists!\n "); |
1546 |
|
|
return pam_tree; |
1547 |
|
|
}; |
1548 |
|
|
// |
1549 |
pam-fi |
1.11 |
|
1550 |
|
|
TChain *Trout =0; |
1551 |
pam-fi |
1.2 |
|
1552 |
pam-fi |
1.12 |
// if( !detlist.IsNull() )SetWhichTrees(detlist); |
1553 |
|
|
SetWhichTrees(detlist); |
1554 |
pam-fi |
1.6 |
|
1555 |
pam-fi |
1.13 |
cout<< "GetPamTree(TList*,TString): input detector list --> "; |
1556 |
pam-fi |
1.12 |
if(TRK1)cout<<"TRK1 "; |
1557 |
|
|
if(TRK2)cout<<"TRK2 "; |
1558 |
|
|
if(TRKh)cout<<"TRKH "; |
1559 |
|
|
if(CAL1)cout<<"CAL1 "; |
1560 |
|
|
if(CAL2)cout<<"CAL2 "; |
1561 |
|
|
if(TOF)cout<<"TOF "; |
1562 |
|
|
if(TRG)cout<<"TRG "; |
1563 |
|
|
if(AC)cout<<"AC "; |
1564 |
|
|
if(ND)cout<<"ND "; |
1565 |
|
|
if(S4)cout<<"S4 "; |
1566 |
|
|
if(ORB)cout<<"ORB "; |
1567 |
|
|
cout << endl; |
1568 |
|
|
|
1569 |
mocchiut |
1.35 |
TChain *T = 0; |
1570 |
|
|
TChain *C = 0; |
1571 |
|
|
TChain *O = 0; |
1572 |
|
|
TChain *R = 0; |
1573 |
|
|
TChain *S = 0; |
1574 |
|
|
TChain *N = 0; |
1575 |
|
|
TChain *A = 0; |
1576 |
|
|
TChain *B = 0; |
1577 |
pam-fi |
1.20 |
|
1578 |
mocchiut |
1.35 |
TChain *L = 0; |
1579 |
pam-fi |
1.6 |
|
1580 |
pam-fi |
1.8 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
1581 |
pam-fi |
1.11 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
1582 |
|
|
if(TOF) O = new TChain("ToF"); |
1583 |
|
|
if(TRG) R = new TChain("Trigger"); |
1584 |
|
|
if(S4) S = new TChain("S4"); |
1585 |
|
|
if(ND) N = new TChain("NeutronD"); |
1586 |
|
|
if(AC) A = new TChain("Anticounter"); |
1587 |
|
|
if(ORB) B = new TChain("OrbitalInfo"); |
1588 |
pam-fi |
1.20 |
L = new TChain("SelectionList"); |
1589 |
pam-fi |
1.6 |
|
1590 |
|
|
// loop over files and create chains |
1591 |
|
|
TIter next(fl); |
1592 |
|
|
TSystemFile *questo = 0; |
1593 |
|
|
while ( (questo = (TSystemFile*) next()) ) { |
1594 |
|
|
TString name = questo->GetName(); |
1595 |
pam-fi |
1.13 |
cout << "File: "<< name << endl; |
1596 |
pam-fi |
1.6 |
if( CheckLevel2File(name) ){ |
1597 |
pam-fi |
1.8 |
if(TRK2||TRK1||TRKh) T->Add(name); |
1598 |
pam-fi |
1.11 |
if(CAL1||CAL2) C->Add(name); |
1599 |
|
|
if(TOF) O->Add(name); |
1600 |
|
|
if(TRG) R->Add(name); |
1601 |
|
|
if(S4) S->Add(name); |
1602 |
|
|
if(ND) N->Add(name); |
1603 |
|
|
if(AC) A->Add(name); |
1604 |
|
|
if(ORB) B->Add(name); |
1605 |
pam-fi |
1.20 |
if(SELLI==1) L->Add(name); |
1606 |
pam-fi |
1.4 |
}; |
1607 |
mocchiut |
1.35 |
}; |
1608 |
pam-fi |
1.6 |
|
1609 |
|
|
cout << "done chain \n"; |
1610 |
pam-fi |
1.36 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1611 |
pam-fi |
1.11 |
|
1612 |
pam-fi |
1.20 |
// UInt_t *found=0; |
1613 |
pam-fi |
1.11 |
// Tracker |
1614 |
|
|
if(T && (TRK2||TRK1||TRKh)) { |
1615 |
|
|
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1616 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkLevel2",0,found); |
1617 |
pam-fi |
1.11 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1618 |
|
|
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1619 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkLevel1",0,found); |
1620 |
pam-fi |
1.11 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1621 |
|
|
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1622 |
pam-fi |
1.20 |
// else T->SetBranchStatus("TrkHough",0,found); |
1623 |
pam-fi |
1.11 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1624 |
|
|
if(!Trout)Trout=T; |
1625 |
mocchiut |
1.35 |
else Trout->AddFriend("Tracker"); |
1626 |
pam-fi |
1.11 |
}else{ |
1627 |
|
|
cout << "Tracker : missing tree"<<endl; |
1628 |
|
|
}; |
1629 |
pam-fi |
1.6 |
// Calorimeter |
1630 |
pam-fi |
1.11 |
if(C && (CAL2||CAL1)) { |
1631 |
|
|
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1632 |
pam-fi |
1.20 |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1633 |
pam-fi |
1.11 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1634 |
|
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1635 |
pam-fi |
1.20 |
// else C->SetBranchStatus("CaloLevel1",0,found); |
1636 |
pam-fi |
1.11 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1637 |
|
|
if(!Trout)Trout=C; |
1638 |
|
|
else Trout->AddFriend("Calorimeter"); |
1639 |
|
|
}else{ |
1640 |
|
|
cout << "Calorimeter : missing tree"<<endl; |
1641 |
pam-fi |
1.6 |
}; |
1642 |
pam-fi |
1.4 |
// ToF |
1643 |
pam-fi |
1.11 |
if(O && TOF) { |
1644 |
|
|
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1645 |
|
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
1646 |
|
|
if(!Trout)Trout=O; |
1647 |
|
|
else Trout->AddFriend("ToF"); |
1648 |
|
|
}else{ |
1649 |
|
|
cout << "ToF : missing tree"<<endl; |
1650 |
pam-fi |
1.6 |
}; |
1651 |
pam-fi |
1.4 |
// Trigger |
1652 |
pam-fi |
1.11 |
if(R && TRG) { |
1653 |
|
|
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1654 |
|
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1655 |
|
|
if(!Trout)Trout=O; |
1656 |
|
|
else Trout->AddFriend("Trigger"); |
1657 |
|
|
}else{ |
1658 |
|
|
cout << "Trigger : missing tree"<<endl; |
1659 |
pam-fi |
1.6 |
}; |
1660 |
pam-fi |
1.4 |
// S4 |
1661 |
pam-fi |
1.11 |
if(S && S4) { |
1662 |
|
|
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1663 |
|
|
cout << "S4 : set branch address S4Level2"<<endl; |
1664 |
|
|
if(!Trout)Trout=O; |
1665 |
|
|
else Trout->AddFriend("S4"); |
1666 |
|
|
}else{ |
1667 |
|
|
cout << "S4 : missing tree"<<endl; |
1668 |
pam-fi |
1.6 |
}; |
1669 |
pam-fi |
1.4 |
// Neutron Detector |
1670 |
pam-fi |
1.11 |
if(N && ND) { |
1671 |
|
|
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1672 |
|
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1673 |
|
|
if(!Trout)Trout=O; |
1674 |
|
|
else Trout->AddFriend("NeutronD"); |
1675 |
|
|
}else{ |
1676 |
|
|
cout << "NeutronD : missing tree"<<endl; |
1677 |
pam-fi |
1.6 |
}; |
1678 |
pam-fi |
1.4 |
// Anticounters |
1679 |
pam-fi |
1.11 |
if(A && AC) { |
1680 |
|
|
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1681 |
|
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1682 |
|
|
if(!Trout)Trout=O; |
1683 |
|
|
else Trout->AddFriend("Anticounter"); |
1684 |
|
|
}else{ |
1685 |
|
|
cout << "Anticounter : missing tree"<<endl; |
1686 |
pam-fi |
1.6 |
}; |
1687 |
pam-fi |
1.11 |
// Orbital Info |
1688 |
|
|
if(B && ORB) { |
1689 |
|
|
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1690 |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1691 |
|
|
if(!Trout)Trout=O; |
1692 |
|
|
else Trout->AddFriend("OrbitalInfo"); |
1693 |
|
|
}else{ |
1694 |
|
|
cout << "OrbitalInfo : missing tree"<<endl; |
1695 |
pam-fi |
1.6 |
}; |
1696 |
pam-fi |
1.36 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1697 |
pam-fi |
1.20 |
|
1698 |
|
|
// Selection List |
1699 |
|
|
if(L && SELLI==1) { |
1700 |
|
|
cout<<">>> Found selection-list <<<"<<endl; |
1701 |
|
|
L->SetBranchAddress("RunEntry",&irun); |
1702 |
|
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1703 |
|
|
L->SetBranchAddress("EventEntry",&irunentry); |
1704 |
|
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1705 |
|
|
sel_tree = L; |
1706 |
|
|
// if(!Trout)Trout=O; |
1707 |
|
|
// else Trout->AddFriend("SelectionList"); |
1708 |
pam-fi |
1.36 |
cout << "----------------------------------------------------" <<endl; |
1709 |
pam-fi |
1.20 |
}else{ |
1710 |
|
|
// cout << "SelectionList : missing tree"<<endl; |
1711 |
|
|
if(L)L->Delete(); |
1712 |
|
|
}; |
1713 |
pam-fi |
1.6 |
|
1714 |
pam-fi |
1.11 |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1715 |
|
|
|
1716 |
pam-fi |
1.20 |
pam_tree = Trout; |
1717 |
|
|
|
1718 |
pam-fi |
1.11 |
return Trout; |
1719 |
pam-fi |
1.4 |
} |
1720 |
pam-fi |
1.8 |
|
1721 |
|
|
|
1722 |
|
|
|
1723 |
pam-fi |
1.4 |
//-------------------------------------- |
1724 |
|
|
// |
1725 |
|
|
// |
1726 |
|
|
//-------------------------------------- |
1727 |
|
|
/** |
1728 |
|
|
* Set branch addresses for Pamela friend trees |
1729 |
|
|
*/ |
1730 |
pam-fi |
1.8 |
void PamLevel2::SetBranchAddress(TTree *t){ |
1731 |
|
|
|
1732 |
|
|
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
1733 |
|
|
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
1734 |
|
|
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
1735 |
|
|
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
1736 |
|
|
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
1737 |
|
|
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
1738 |
|
|
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
1739 |
|
|
S4 = S4 & t->GetBranchStatus("S4Level2"); |
1740 |
|
|
ND = ND & t->GetBranchStatus("NDLevel2"); |
1741 |
|
|
AC = AC & t->GetBranchStatus("AcLevel2"); |
1742 |
|
|
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
1743 |
|
|
|
1744 |
|
|
|
1745 |
pam-fi |
1.4 |
// Tracker |
1746 |
pam-fi |
1.8 |
if(TRK1) { |
1747 |
pam-fi |
1.9 |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel2")); |
1748 |
pam-fi |
1.8 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
1749 |
|
|
}; |
1750 |
|
|
if(TRK2) { |
1751 |
pam-fi |
1.9 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
1752 |
pam-fi |
1.6 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
1753 |
|
|
}; |
1754 |
pam-fi |
1.8 |
if(TRKh) { |
1755 |
pam-fi |
1.9 |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1756 |
pam-fi |
1.8 |
cout << "Tracker : set branch address TrkHough"<<endl; |
1757 |
|
|
}; |
1758 |
pam-fi |
1.6 |
|
1759 |
|
|
// Calorimeter |
1760 |
pam-fi |
1.8 |
if(CAL1) { |
1761 |
pam-fi |
1.9 |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1762 |
pam-fi |
1.8 |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1763 |
|
|
}; |
1764 |
|
|
if(CAL2) { |
1765 |
pam-fi |
1.9 |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1766 |
pam-fi |
1.6 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1767 |
|
|
}; |
1768 |
|
|
|
1769 |
pam-fi |
1.4 |
// ToF |
1770 |
pam-fi |
1.6 |
if(TOF) { |
1771 |
pam-fi |
1.9 |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1772 |
pam-fi |
1.6 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1773 |
|
|
}; |
1774 |
pam-fi |
1.4 |
// Trigger |
1775 |
pam-fi |
1.6 |
if(TRG) { |
1776 |
pam-fi |
1.9 |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1777 |
pam-fi |
1.6 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1778 |
|
|
}; |
1779 |
pam-fi |
1.4 |
// S4 |
1780 |
pam-fi |
1.6 |
if(S4) { |
1781 |
pam-fi |
1.9 |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1782 |
pam-fi |
1.6 |
cout << "S4 : set branch address S4Level2"<<endl; |
1783 |
|
|
}; |
1784 |
pam-fi |
1.4 |
// Neutron Detector |
1785 |
pam-fi |
1.6 |
if(ND) { |
1786 |
pam-fi |
1.9 |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1787 |
pam-fi |
1.6 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1788 |
|
|
}; |
1789 |
pam-fi |
1.4 |
// Anticounters |
1790 |
pam-fi |
1.6 |
if(AC) { |
1791 |
pam-fi |
1.9 |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1792 |
pam-fi |
1.6 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1793 |
|
|
}; |
1794 |
pam-fi |
1.4 |
// OrbitalInfo |
1795 |
pam-fi |
1.6 |
if(ORB) { |
1796 |
pam-fi |
1.9 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1797 |
pam-fi |
1.6 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1798 |
|
|
}; |
1799 |
pam-fi |
1.20 |
// SelectionList |
1800 |
|
|
if(SELLI==1) { |
1801 |
|
|
t->SetBranchAddress("RunEntry", &irun); |
1802 |
|
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1803 |
|
|
t->SetBranchAddress("EventEntry", &irunentry); |
1804 |
|
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1805 |
|
|
}; |
1806 |
pam-fi |
1.6 |
|
1807 |
pam-fi |
1.4 |
} |
1808 |
pam-fi |
1.8 |
/** |
1809 |
|
|
* Set branch addresses for Pamela friend trees |
1810 |
|
|
*/ |
1811 |
|
|
void PamLevel2::SetBranchAddress(TChain *t){ |
1812 |
pam-fi |
1.4 |
|
1813 |
pam-fi |
1.8 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
1814 |
|
|
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
1815 |
|
|
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
1816 |
|
|
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
1817 |
|
|
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
1818 |
|
|
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
1819 |
|
|
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
1820 |
|
|
S4 = S4 & t->GetBranchStatus("S4Level2"); |
1821 |
|
|
ND = ND & t->GetBranchStatus("NDLevel2"); |
1822 |
|
|
AC = AC & t->GetBranchStatus("AcLevel2"); |
1823 |
|
|
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
1824 |
|
|
|
1825 |
|
|
// Tracker |
1826 |
pam-fi |
1.9 |
if(TRK2) { |
1827 |
pam-fi |
1.11 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1828 |
pam-fi |
1.9 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
1829 |
|
|
}; |
1830 |
pam-fi |
1.8 |
if(TRK1) { |
1831 |
pam-fi |
1.9 |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1832 |
pam-fi |
1.8 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
1833 |
|
|
}; |
1834 |
|
|
if(TRKh) { |
1835 |
pam-fi |
1.9 |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1836 |
pam-fi |
1.8 |
cout << "Tracker : set branch address TrkHough"<<endl; |
1837 |
|
|
}; |
1838 |
|
|
|
1839 |
|
|
// Calorimeter |
1840 |
pam-fi |
1.9 |
if(CAL2) { |
1841 |
|
|
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1842 |
|
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1843 |
|
|
}; |
1844 |
pam-fi |
1.8 |
if(CAL1) { |
1845 |
pam-fi |
1.9 |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1846 |
pam-fi |
1.8 |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1847 |
|
|
}; |
1848 |
|
|
|
1849 |
|
|
// ToF |
1850 |
|
|
if(TOF) { |
1851 |
pam-fi |
1.9 |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1852 |
pam-fi |
1.8 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1853 |
|
|
}; |
1854 |
|
|
// Trigger |
1855 |
|
|
if(TRG) { |
1856 |
pam-fi |
1.9 |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1857 |
pam-fi |
1.8 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1858 |
|
|
}; |
1859 |
|
|
// S4 |
1860 |
|
|
if(S4) { |
1861 |
pam-fi |
1.9 |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1862 |
pam-fi |
1.8 |
cout << "S4 : set branch address S4Level2"<<endl; |
1863 |
|
|
}; |
1864 |
|
|
// Neutron Detector |
1865 |
|
|
if(ND) { |
1866 |
pam-fi |
1.9 |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1867 |
pam-fi |
1.8 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1868 |
|
|
}; |
1869 |
|
|
// Anticounters |
1870 |
|
|
if(AC) { |
1871 |
pam-fi |
1.9 |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1872 |
pam-fi |
1.8 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1873 |
|
|
}; |
1874 |
|
|
// OrbitalInfo |
1875 |
|
|
if(ORB) { |
1876 |
pam-fi |
1.9 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1877 |
pam-fi |
1.8 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1878 |
|
|
}; |
1879 |
pam-fi |
1.20 |
// SelectionList |
1880 |
|
|
if(SELLI==1) { |
1881 |
|
|
t->SetBranchAddress("RunEntry", &irun); |
1882 |
|
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1883 |
|
|
t->SetBranchAddress("EventEntry", &irunentry); |
1884 |
|
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1885 |
|
|
}; |
1886 |
pam-fi |
1.8 |
|
1887 |
|
|
} |
1888 |
pam-fi |
1.9 |
|
1889 |
|
|
|
1890 |
pam-fi |
1.4 |
//-------------------------------------- |
1891 |
|
|
// |
1892 |
|
|
// |
1893 |
|
|
//-------------------------------------- |
1894 |
|
|
/** |
1895 |
|
|
* Get the Run tree chain from a list of files. |
1896 |
|
|
* @param fl Pointer to a TList of TSystemFiles |
1897 |
|
|
* @return Pointer to a TChain |
1898 |
|
|
*/ |
1899 |
|
|
TChain *PamLevel2::GetRunTree(TList *fl){ |
1900 |
mocchiut |
1.35 |
// |
1901 |
|
|
// |
1902 |
|
|
// |
1903 |
|
|
if ( run_tree ){ |
1904 |
|
|
printf("WARNING: TChain *PamLevel2::GetRunTree(TList *fl) -- run_tree already exists!\n "); |
1905 |
|
|
return run_tree; |
1906 |
|
|
}; |
1907 |
|
|
// |
1908 |
|
|
TChain *R = new TChain("Run"); |
1909 |
pam-fi |
1.6 |
|
1910 |
|
|
// loop over files and create chains |
1911 |
|
|
TIter next(fl); |
1912 |
|
|
TSystemFile *questo = 0; |
1913 |
|
|
while ( (questo = (TSystemFile*) next()) ) { |
1914 |
|
|
TString name = questo->GetName(); |
1915 |
pam-fi |
1.4 |
// cout << "File: "<< name << endl; |
1916 |
pam-fi |
1.6 |
if( CheckLevel2File(name) ){ |
1917 |
|
|
R->Add(name); |
1918 |
|
|
}; |
1919 |
|
|
} |
1920 |
pam-fi |
1.20 |
|
1921 |
|
|
if(R->GetNtrees()){ |
1922 |
pam-fi |
1.6 |
|
1923 |
pam-fi |
1.20 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1924 |
|
|
cout << "Run : set branch address RunInfo"<<endl; |
1925 |
|
|
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1926 |
|
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1927 |
|
|
}else{ |
1928 |
|
|
delete R; |
1929 |
|
|
R=0; |
1930 |
|
|
} |
1931 |
|
|
|
1932 |
|
|
run_tree = R; |
1933 |
|
|
|
1934 |
pam-fi |
1.6 |
return R; |
1935 |
pam-fi |
1.4 |
|
1936 |
|
|
} |
1937 |
|
|
//-------------------------------------- |
1938 |
|
|
// |
1939 |
|
|
// |
1940 |
|
|
//-------------------------------------- |
1941 |
|
|
/** |
1942 |
|
|
* Get the Run tree from a file. |
1943 |
|
|
* @param f Pointer to a TFile |
1944 |
|
|
* @return Pointer to a TTree |
1945 |
|
|
*/ |
1946 |
|
|
TTree *PamLevel2::GetRunTree(TFile *f){ |
1947 |
mocchiut |
1.35 |
if ( run_tree ){ |
1948 |
|
|
printf("WARNING: TTree *PamLevel2::GetRunTree(TFile *f) -- run_tree already exists!\n "); |
1949 |
|
|
return run_tree; |
1950 |
|
|
}; |
1951 |
|
|
|
1952 |
pam-fi |
1.4 |
|
1953 |
pam-fi |
1.20 |
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
1954 |
pam-fi |
1.4 |
|
1955 |
mocchiut |
1.35 |
TTree *T = (TTree*)f->Get("Run"); |
1956 |
pam-fi |
1.6 |
|
1957 |
mocchiut |
1.35 |
if(T){ |
1958 |
|
|
T->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1959 |
pam-fi |
1.20 |
cout << "Run : set branch address RunInfo"<<endl; |
1960 |
mocchiut |
1.35 |
T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1961 |
pam-fi |
1.20 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1962 |
|
|
} |
1963 |
mocchiut |
1.28 |
|
1964 |
mocchiut |
1.35 |
run_tree = (TChain*)T; |
1965 |
mocchiut |
1.28 |
|
1966 |
mocchiut |
1.35 |
return T; |
1967 |
pam-fi |
1.2 |
|
1968 |
|
|
} |
1969 |
mocchiut |
1.17 |
/** |
1970 |
|
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
1971 |
|
|
* @param run Pointer to the chain/tree which contains run infos |
1972 |
|
|
* @return true if a new run has been read, false if it is still the same run |
1973 |
|
|
*/ |
1974 |
pam-fi |
1.33 |
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev){ |
1975 |
mocchiut |
1.17 |
// |
1976 |
|
|
// check if we have already called once GetEntry, if not call it |
1977 |
|
|
// |
1978 |
pam-fi |
1.49 |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- ATTENZIONE --- NON E` MANTENUTA!!!!!!!.... "<<endl; |
1979 |
pam-fi |
1.34 |
if(!run){ |
1980 |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
1981 |
|
|
return(false); |
1982 |
|
|
} |
1983 |
|
|
if ( run->GetEntries() <= 0 ) return(false); |
1984 |
mocchiut |
1.17 |
// |
1985 |
pam-fi |
1.20 |
|
1986 |
mocchiut |
1.35 |
// Int_t oldrun = irun; |
1987 |
pam-fi |
1.33 |
Long64_t oldrun = irun; |
1988 |
mocchiut |
1.35 |
|
1989 |
pam-fi |
1.20 |
// -------------------------------------- |
1990 |
|
|
// if it is a full file (not preselected) |
1991 |
|
|
// -------------------------------------- |
1992 |
|
|
if(SELLI==0){ |
1993 |
pam-fi |
1.33 |
|
1994 |
pam-fi |
1.36 |
// |
1995 |
|
|
// the absolute time is necessary to relate the event with the run |
1996 |
|
|
// |
1997 |
pam-fi |
1.43 |
if( !GetOrbitalInfo() && !ISGP){ |
1998 |
pam-fi |
1.33 |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1999 |
|
|
return(false); |
2000 |
|
|
} |
2001 |
|
|
|
2002 |
pam-fi |
1.43 |
ULong64_t abstime = 0; |
2003 |
|
|
if( GetOrbitalInfo() )abstime=GetOrbitalInfo()->absTime; |
2004 |
|
|
|
2005 |
|
|
|
2006 |
pam-fi |
1.36 |
// |
2007 |
|
|
// the first time the routine is called, set run search from the beginning |
2008 |
|
|
// |
2009 |
mocchiut |
1.35 |
if ( irun < 0LL ){ |
2010 |
|
|
irun = 0LL; |
2011 |
pam-fi |
1.26 |
run->GetEntry(irun); |
2012 |
pam-fi |
1.33 |
runfirstentry = 0LL; |
2013 |
|
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
2014 |
|
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
2015 |
pam-fi |
1.43 |
|
2016 |
|
|
if( ISGP && run->GetEntries()!=1 ){ |
2017 |
|
|
cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run->GetEntries() << endl; |
2018 |
|
|
cout << "** WARNING ** run will not be updated"<<endl; |
2019 |
|
|
} |
2020 |
|
|
|
2021 |
pam-fi |
1.24 |
}; |
2022 |
mocchiut |
1.35 |
// |
2023 |
pam-fi |
1.43 |
if(ISGP)abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO |
2024 |
|
|
// |
2025 |
|
|
if ( irun == run->GetEntries()-1LL && |
2026 |
|
|
!(abstime >= GetRunInfo()->RUNHEADER_TIME && |
2027 |
|
|
abstime <= GetRunInfo()->RUNTRAILER_TIME) |
2028 |
mocchiut |
1.35 |
){ |
2029 |
|
|
irun = -1LL; |
2030 |
|
|
runfirstentry = 0LL; |
2031 |
|
|
runlastentry = -1LL; |
2032 |
|
|
}; |
2033 |
pam-fi |
1.24 |
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
2034 |
|
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
2035 |
mocchiut |
1.31 |
// |
2036 |
|
|
bool fromfirst = true; |
2037 |
|
|
// |
2038 |
pam-fi |
1.43 |
while ( !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
2039 |
pam-fi |
1.24 |
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
2040 |
pam-fi |
1.20 |
irun++; |
2041 |
|
|
run->GetEntry(irun); |
2042 |
mocchiut |
1.30 |
runfirstentry = runlastentry; |
2043 |
pam-fi |
1.33 |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; |
2044 |
|
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
2045 |
|
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2046 |
|
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
2047 |
mocchiut |
1.31 |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
2048 |
pam-fi |
1.43 |
// printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME); |
2049 |
mocchiut |
1.31 |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
2050 |
|
|
// |
2051 |
pam-fi |
1.33 |
// prevshift = 0; |
2052 |
mocchiut |
1.31 |
// |
2053 |
pam-fi |
1.43 |
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME)){ |
2054 |
pam-fi |
1.33 |
printf(" resetting irun (it should NOT happen!!!)\n"); |
2055 |
pam-fi |
1.32 |
fromfirst = false; |
2056 |
|
|
irun = 0; |
2057 |
|
|
run->GetEntry(irun); |
2058 |
|
|
runfirstentry = 0ULL; |
2059 |
pam-fi |
1.33 |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
2060 |
|
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
2061 |
mocchiut |
1.31 |
}; |
2062 |
|
|
// |
2063 |
pam-fi |
1.20 |
}; |
2064 |
mocchiut |
1.31 |
// |
2065 |
mocchiut |
1.35 |
if ( |
2066 |
pam-fi |
1.43 |
!(abstime >= GetRunInfo()->RUNHEADER_TIME && |
2067 |
|
|
abstime <= GetRunInfo()->RUNTRAILER_TIME) |
2068 |
pam-fi |
1.33 |
) { |
2069 |
mocchiut |
1.44 |
printf(" Something very wrong here: cannot find RUN containing absolute time %llu \n",abstime); |
2070 |
pam-fi |
1.33 |
return false; |
2071 |
|
|
} |
2072 |
pam-fi |
1.20 |
// |
2073 |
mocchiut |
1.30 |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
2074 |
pam-fi |
1.20 |
// |
2075 |
|
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
2076 |
|
|
// |
2077 |
pam-fi |
1.33 |
prevshift = 0; |
2078 |
|
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2079 |
pam-fi |
1.34 |
// cout << "runfirstentry "<<runfirstentry<<endl; |
2080 |
pam-fi |
1.20 |
return(true); |
2081 |
mocchiut |
1.17 |
}; |
2082 |
pam-fi |
1.20 |
// ---------------------------------------------------- |
2083 |
|
|
// if it is a preselected file (there is SelectionList) |
2084 |
|
|
// NBNB - the event tree MUST be read first |
2085 |
|
|
// ---------------------------------------------------- |
2086 |
|
|
if(SELLI==1){ |
2087 |
|
|
sel_tree->GetEntry(iev); |
2088 |
pam-fi |
1.34 |
// cout << irun << " "<< irunentry << endl; |
2089 |
pam-fi |
1.20 |
if(irun != oldrun){ |
2090 |
|
|
run->GetEntry(irun); |
2091 |
pam-fi |
1.33 |
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2092 |
pam-fi |
1.32 |
prevshift = 0; |
2093 |
pam-fi |
1.20 |
return true; |
2094 |
|
|
} |
2095 |
|
|
return false; |
2096 |
|
|
} |
2097 |
|
|
|
2098 |
|
|
return false; |
2099 |
mocchiut |
1.17 |
// |
2100 |
|
|
}; |
2101 |
pam-fi |
1.33 |
|
2102 |
pam-fi |
1.36 |
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev){ |
2103 |
|
|
|
2104 |
|
|
if(!run_tree){ |
2105 |
|
|
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
2106 |
|
|
return false; |
2107 |
|
|
} |
2108 |
|
|
if ( run_tree->GetEntries() <= 0 ) { |
2109 |
|
|
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
2110 |
|
|
return(false); |
2111 |
|
|
} |
2112 |
pam-fi |
1.33 |
|
2113 |
pam-fi |
1.36 |
Int_t oldrun = irun; // store current run index |
2114 |
|
|
|
2115 |
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2116 |
|
|
// if it is a full file (not preselected) |
2117 |
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2118 |
|
|
if(SELLI==0){ |
2119 |
|
|
|
2120 |
pam-fi |
1.45 |
// --------------------------------------------------------------- |
2121 |
|
|
// increment dead and live-time counters |
2122 |
|
|
// --------------------------------------------------------------- |
2123 |
|
|
if( GetTrigLevel2() ){ |
2124 |
|
|
totdltime[0]+=GetTrigLevel2()->dltime[0]; |
2125 |
|
|
totdltime[1]+=GetTrigLevel2()->dltime[1]; |
2126 |
|
|
} |
2127 |
|
|
totdltime[2]++; |
2128 |
|
|
|
2129 |
|
|
// cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl; |
2130 |
|
|
|
2131 |
|
|
// --------------------------------------------------------------- |
2132 |
|
|
// retrieve OBT and absolute time of the event |
2133 |
|
|
// --------------------------------------------------------------- |
2134 |
pam-fi |
1.43 |
ULong64_t abstime = 0; |
2135 |
|
|
ULong64_t obt = 0; |
2136 |
|
|
if( GetOrbitalInfo() ){ |
2137 |
|
|
abstime = GetOrbitalInfo()->absTime; |
2138 |
|
|
obt = GetOrbitalInfo()->OBT; |
2139 |
|
|
} |
2140 |
pam-fi |
1.36 |
// --------------------------------------------------------------- |
2141 |
|
|
// the absolute time is necessary to relate the event with the run |
2142 |
|
|
// --------------------------------------------------------------- |
2143 |
pam-fi |
1.43 |
if( !GetOrbitalInfo() && !ISGP ){ |
2144 |
pam-fi |
1.36 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
2145 |
|
|
return(false); |
2146 |
|
|
} |
2147 |
|
|
|
2148 |
|
|
// ----------------------------------------------------------------------- |
2149 |
|
|
// the first time the routine is called, set run search from the beginning |
2150 |
|
|
// ----------------------------------------------------------------------- |
2151 |
|
|
if ( irun < 0 ){ |
2152 |
|
|
irun = 0LL; |
2153 |
pam-fi |
1.39 |
irunentry = 0; |
2154 |
|
|
prevshift = 0; |
2155 |
pam-fi |
1.36 |
run_tree->GetEntry(irun); |
2156 |
pam-fi |
1.43 |
|
2157 |
|
|
if( ISGP && run_tree->GetEntries()!=1 ){ |
2158 |
|
|
cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl; |
2159 |
|
|
cout << "** WARNING ** run will not be updated"<<endl; |
2160 |
|
|
} |
2161 |
pam-fi |
1.36 |
}; |
2162 |
pam-fi |
1.43 |
|
2163 |
|
|
// ----------------------------------------------------------------------- |
2164 |
pam-fi |
1.49 |
// if it is simulation, assign abstime by hand (temporaneo!!!) |
2165 |
pam-fi |
1.43 |
// ----------------------------------------------------------------------- |
2166 |
|
|
if(ISGP){ |
2167 |
|
|
abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO |
2168 |
|
|
obt = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO |
2169 |
|
|
} |
2170 |
pam-fi |
1.36 |
// |
2171 |
|
|
bool fromfirst = true; // first loop over runs |
2172 |
pam-fi |
1.39 |
|
2173 |
|
|
// Bool_t hasfrag = false; |
2174 |
|
|
// if( GetRunInfo()->ID_RUN_FRAG!=0 && GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID)hasfrag=true; |
2175 |
|
|
// ULong64_t fragid = GetRunInfo()->ID_RUN_FRAG; |
2176 |
|
|
|
2177 |
pam-fi |
1.36 |
// ------------------------------------------------------ |
2178 |
|
|
// loop over runs to find the one that contains the event |
2179 |
|
|
// ------------------------------------------------------ |
2180 |
pam-fi |
1.39 |
while ( |
2181 |
|
|
( |
2182 |
|
|
( |
2183 |
pam-fi |
1.43 |
!(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
2184 |
|
|
abstime <= GetRunInfo()->RUNTRAILER_TIME) && |
2185 |
|
|
!(obt >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
2186 |
|
|
obt <= GetRunInfo()->RUNTRAILER_OBT) |
2187 |
pam-fi |
1.39 |
) |
2188 |
|
|
|| GetRunInfo()->NEVENTS==0 |
2189 |
pam-fi |
1.49 |
// || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento |
2190 |
|
|
|| !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift) |
2191 |
pam-fi |
1.39 |
) |
2192 |
|
|
&& irun < run_tree->GetEntries() ){ |
2193 |
|
|
|
2194 |
pam-fi |
1.49 |
// - - - - - - - - - - - - - |
2195 |
|
|
// irunentry = position of current entry, relative to the run |
2196 |
|
|
// prevshift = shift needed to synchronize l0 and l2 data (nested events) |
2197 |
|
|
// - - - - - - - - - - - - - |
2198 |
pam-fi |
1.45 |
|
2199 |
|
|
// ----------------------------------------- |
2200 |
|
|
// store dead and live-time of previous run |
2201 |
|
|
// ----------------------------------------- |
2202 |
|
|
if(fromfirst){ |
2203 |
|
|
if(oldrun==irun){ |
2204 |
|
|
/// decrement counters |
2205 |
|
|
if( GetTrigLevel2()){ |
2206 |
|
|
totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time |
2207 |
|
|
totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time |
2208 |
|
|
} |
2209 |
|
|
totdltime[2]--; //event counter |
2210 |
|
|
cout << endl; |
2211 |
|
|
cout << "n.events : "<<totdltime[2]<<endl; |
2212 |
|
|
cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl; |
2213 |
|
|
cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl; |
2214 |
|
|
}else{ |
2215 |
|
|
totdltime[0]=0;//live-time |
2216 |
|
|
totdltime[1]=0;//dead-time |
2217 |
|
|
totdltime[2]=0; //event counter |
2218 |
|
|
cout << " *** JUMP RUN *** irun "<<irun<<endl; |
2219 |
|
|
} |
2220 |
|
|
/// add an entry |
2221 |
|
|
if(run_tree_clone) |
2222 |
|
|
if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
2223 |
|
|
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
2224 |
|
|
/// reset counters |
2225 |
|
|
if( GetTrigLevel2() ){ |
2226 |
|
|
totdltime[0]=GetTrigLevel2()->dltime[0];//live-time |
2227 |
|
|
totdltime[1]=0; //dead-time |
2228 |
|
|
} |
2229 |
|
|
totdltime[2]=1; //event counter |
2230 |
|
|
} |
2231 |
|
|
|
2232 |
|
|
|
2233 |
pam-fi |
1.36 |
irun++; |
2234 |
|
|
// ------------------------------------ |
2235 |
|
|
// if the end of run tree is reached... |
2236 |
|
|
// ------------------------------------ |
2237 |
|
|
if( irun == run_tree->GetEntries() ){ |
2238 |
|
|
if(!fromfirst){ |
2239 |
|
|
// ----------------------------------------------------- |
2240 |
|
|
// if it happened already once and the run was not found |
2241 |
|
|
// ---> exit with error |
2242 |
|
|
// ----------------------------------------------------- |
2243 |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
2244 |
|
|
return false; |
2245 |
|
|
} |
2246 |
|
|
// ----------------------------------------- |
2247 |
|
|
// ...otherwise repeat search from beginning |
2248 |
|
|
// ----------------------------------------- |
2249 |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- reached end of run tree. searchin again from beginning " <<endl; |
2250 |
|
|
fromfirst = false; |
2251 |
|
|
irun = 0LL; |
2252 |
|
|
runfirstentry = 0LL; |
2253 |
|
|
} |
2254 |
|
|
// ------------------------------------------------------------------- |
2255 |
|
|
// save the index of the first entry of the run, relative to pam_tree, |
2256 |
|
|
// and read a new run |
2257 |
|
|
// ------------------------------------------------------------------- |
2258 |
pam-fi |
1.39 |
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift; |
2259 |
|
|
irunentry = 0; |
2260 |
pam-fi |
1.45 |
prevshift = 0; |
2261 |
pam-fi |
1.36 |
run_tree->GetEntry(irun); |
2262 |
pam-fi |
1.39 |
if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){ |
2263 |
pam-fi |
1.36 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
2264 |
|
|
cout << " (NB!! in this case some events are assigned to a wrong run)"<<endl; |
2265 |
|
|
} |
2266 |
pam-fi |
1.39 |
// if(hasfrag && fragid != GetRunInfo()->ID){ |
2267 |
|
|
// cout << "... where is the next fragment ??"<<endl; |
2268 |
|
|
// } |
2269 |
pam-fi |
1.36 |
}; |
2270 |
pam-fi |
1.39 |
|
2271 |
|
|
|
2272 |
pam-fi |
1.36 |
// -------------------------------------- |
2273 |
|
|
// if there was no need to update the run |
2274 |
|
|
// ---> exit with FALSE |
2275 |
|
|
// -------------------------------------- |
2276 |
|
|
if ( irun == oldrun ) return(false); |
2277 |
|
|
|
2278 |
|
|
// -------------------------------------- |
2279 |
|
|
// ... otherwise |
2280 |
pam-fi |
1.45 |
// -------------------------------------- |
2281 |
|
|
|
2282 |
|
|
|
2283 |
|
|
|
2284 |
|
|
// // ----------------------------------------- |
2285 |
|
|
// // store dead and live-time of previous run |
2286 |
|
|
// // ----------------------------------------- |
2287 |
|
|
// // -------------------------------------------------------------- |
2288 |
|
|
// // if the run is empty, fill the dead-live time branch with zeros |
2289 |
|
|
// // -------------------------------------------------------------- |
2290 |
|
|
// /// if some runs have been jumped, fill with zeros |
2291 |
|
|
// if(irun-oldrun>1){ |
2292 |
|
|
// ULong64_t temp[3]; |
2293 |
|
|
// temp[0]=totdltime[0]; |
2294 |
|
|
// temp[1]=totdltime[1]; |
2295 |
|
|
// temp[2]=totdltime[2]; |
2296 |
|
|
// for(int i=oldrun+1; i<irun; irun++){ |
2297 |
|
|
// totdltime[0]=0; |
2298 |
|
|
// totdltime[1]=0; |
2299 |
|
|
// totdltime[2]=0; |
2300 |
|
|
// cout << " ** JUMPED RUN **"<<endl; |
2301 |
|
|
// if(run_tree_clone) |
2302 |
|
|
// if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
2303 |
|
|
// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
2304 |
|
|
// } |
2305 |
|
|
// totdltime[0]=temp[0]; |
2306 |
|
|
// totdltime[1]=temp[1]; |
2307 |
|
|
// totdltime[2]=temp[2]; |
2308 |
|
|
// } |
2309 |
|
|
// /// decrement counters |
2310 |
|
|
// if( GetTrigLevel2() ){ |
2311 |
|
|
// totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time |
2312 |
|
|
// totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time |
2313 |
|
|
// } |
2314 |
|
|
// totdltime[2]--; //event counter |
2315 |
|
|
// /// add an entry |
2316 |
|
|
// if(irun>0 ){ |
2317 |
|
|
// cout << endl; |
2318 |
|
|
// cout << "n.events : "<<totdltime[2]<<endl; |
2319 |
|
|
// cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl; |
2320 |
|
|
// cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl; |
2321 |
|
|
// if(run_tree_clone) |
2322 |
|
|
// if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
2323 |
|
|
// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
2324 |
|
|
// } |
2325 |
|
|
// /// reset counters |
2326 |
|
|
// if( GetTrigLevel2() ){ |
2327 |
|
|
// totdltime[0]=GetTrigLevel2()->dltime[0];//live-time |
2328 |
|
|
// totdltime[1]=0; //dead-time |
2329 |
|
|
// } |
2330 |
|
|
// totdltime[2]=1; //event counter |
2331 |
|
|
|
2332 |
|
|
|
2333 |
|
|
// -------------------------------------- |
2334 |
pam-fi |
1.36 |
// ---> exit with TRUE |
2335 |
|
|
// -------------------------------------- |
2336 |
|
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2337 |
pam-fi |
1.39 |
// ---------------------------------------------------- |
2338 |
|
|
// then check if the run has a fragment |
2339 |
|
|
// in this case we have to switch to the next fragment |
2340 |
|
|
// when the end of the first fragment is reached |
2341 |
|
|
// ---------------------------------------------------- |
2342 |
|
|
if( |
2343 |
|
|
GetRunInfo()->ID_RUN_FRAG != 0 && |
2344 |
|
|
// GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID && |
2345 |
|
|
true ){ |
2346 |
|
|
cout << "* fragment *"<<endl; |
2347 |
|
|
} |
2348 |
pam-fi |
1.45 |
|
2349 |
pam-fi |
1.36 |
return(true); |
2350 |
|
|
}; |
2351 |
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2352 |
|
|
// if it is a preselected file (there is SelectionList) |
2353 |
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2354 |
|
|
if(SELLI==1){ |
2355 |
|
|
sel_tree->GetEntry(iev); |
2356 |
|
|
if(irun != oldrun){ |
2357 |
|
|
run_tree->GetEntry(irun); |
2358 |
|
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2359 |
|
|
prevshift = 0; |
2360 |
|
|
return true; |
2361 |
|
|
} |
2362 |
|
|
return false; |
2363 |
|
|
} |
2364 |
|
|
|
2365 |
|
|
return false; |
2366 |
|
|
// |
2367 |
|
|
}; |
2368 |
mocchiut |
1.17 |
/** |
2369 |
|
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
2370 |
|
|
* @param run Pointer to the chain/tree which contains run infos |
2371 |
|
|
* @return true if a new run has been read, false if it is still the same run |
2372 |
|
|
*/ |
2373 |
pam-fi |
1.33 |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev){ |
2374 |
mocchiut |
1.17 |
return(UpdateRunInfo((TChain*)run,iev)); |
2375 |
|
|
}; |
2376 |
|
|
|
2377 |
pam-fi |
1.2 |
//-------------------------------------- |
2378 |
|
|
// |
2379 |
|
|
// |
2380 |
|
|
//-------------------------------------- |
2381 |
|
|
/** |
2382 |
pam-fi |
1.8 |
* Set which trees shoul be analysed |
2383 |
pam-fi |
1.2 |
* @param detlist TString containing the sequence of trees required |
2384 |
|
|
*/ |
2385 |
|
|
void PamLevel2::SetWhichTrees(TString detlist){ |
2386 |
|
|
|
2387 |
pam-fi |
1.12 |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
2388 |
pam-fi |
1.20 |
CAL0 = false; |
2389 |
pam-fi |
1.8 |
CAL1 = true; |
2390 |
|
|
CAL2 = true; |
2391 |
|
|
TRK2 = true; |
2392 |
|
|
TRK1 = false; |
2393 |
|
|
TRKh = false; |
2394 |
pam-fi |
1.20 |
TRK0 = false; |
2395 |
pam-fi |
1.6 |
TRG = true; |
2396 |
|
|
TOF = true; |
2397 |
pam-fi |
1.20 |
TOF0 = false; |
2398 |
pam-fi |
1.6 |
S4 = true; |
2399 |
|
|
ND = true; |
2400 |
|
|
AC = true; |
2401 |
|
|
ORB = true; |
2402 |
|
|
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
2403 |
pam-fi |
1.20 |
CAL0 = false; |
2404 |
pam-fi |
1.8 |
CAL1 = false; |
2405 |
|
|
CAL2 = false; |
2406 |
|
|
TRK2 = false; |
2407 |
|
|
TRK1 = false; |
2408 |
|
|
TRKh = false; |
2409 |
pam-fi |
1.20 |
TRK0 = false; |
2410 |
pam-fi |
1.6 |
TRG = false; |
2411 |
|
|
TOF = false; |
2412 |
pam-fi |
1.20 |
TOF0 = false; |
2413 |
pam-fi |
1.6 |
S4 = false; |
2414 |
|
|
ND = false; |
2415 |
|
|
AC = false; |
2416 |
|
|
ORB = false; |
2417 |
|
|
}; |
2418 |
|
|
|
2419 |
pam-fi |
1.8 |
// ------------------------------------------------------------------------- |
2420 |
|
|
if( detlist.Contains("CAL1", TString::kIgnoreCase) ){ |
2421 |
|
|
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
2422 |
|
|
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
2423 |
|
|
}; |
2424 |
pam-fi |
1.20 |
|
2425 |
|
|
if( detlist.Contains("CAL0", TString::kIgnoreCase) ){ |
2426 |
|
|
if ( detlist.Contains("-CAL0", TString::kIgnoreCase) )CAL0=false; |
2427 |
|
|
if ( detlist.Contains("+CAL0", TString::kIgnoreCase) )CAL0=true; |
2428 |
|
|
}; |
2429 |
pam-fi |
1.8 |
|
2430 |
|
|
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
2431 |
|
|
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
2432 |
|
|
if ( detlist.Contains("+CAL2", TString::kIgnoreCase) )CAL2=true; |
2433 |
|
|
}; |
2434 |
|
|
|
2435 |
|
|
if( detlist.Contains("+CAL", TString::kIgnoreCase) && !CAL1 && !CAL2 )CAL2=true; |
2436 |
|
|
if( detlist.Contains("-CAL", TString::kIgnoreCase) && CAL1 && CAL2 ){ |
2437 |
|
|
CAL2=false; |
2438 |
|
|
CAL1=false; |
2439 |
|
|
} |
2440 |
|
|
// ------------------------------------------------------------------------- |
2441 |
pam-fi |
1.20 |
if( detlist.Contains("TRK0", TString::kIgnoreCase) ){ |
2442 |
|
|
if ( detlist.Contains("-TRK0", TString::kIgnoreCase) )TRK0=false; |
2443 |
|
|
if ( detlist.Contains("+TRK0", TString::kIgnoreCase) )TRK0=true; |
2444 |
|
|
}; |
2445 |
|
|
|
2446 |
pam-fi |
1.8 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
2447 |
|
|
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
2448 |
|
|
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
2449 |
|
|
}; |
2450 |
|
|
|
2451 |
|
|
if( detlist.Contains("TRK2", TString::kIgnoreCase)){ |
2452 |
|
|
if ( detlist.Contains("-TRK2", TString::kIgnoreCase) )TRK2=false; |
2453 |
|
|
if ( detlist.Contains("+TRK2", TString::kIgnoreCase) )TRK2=true; |
2454 |
|
|
}; |
2455 |
|
|
|
2456 |
|
|
if( detlist.Contains("TRKh", TString::kIgnoreCase)){ |
2457 |
|
|
if ( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh=false; |
2458 |
|
|
if ( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh=true; |
2459 |
|
|
}; |
2460 |
|
|
|
2461 |
|
|
if( detlist.Contains("+TRK", TString::kIgnoreCase) && !TRK1 && !TRK2 && !TRKh )TRK2=true; |
2462 |
|
|
if( detlist.Contains("-TRK", TString::kIgnoreCase) && TRK1 && TRK2 && TRKh){ |
2463 |
|
|
TRK2=false; |
2464 |
|
|
TRK1=false; |
2465 |
|
|
TRKh=false; |
2466 |
|
|
} |
2467 |
|
|
// ------------------------------------------------------------------------- |
2468 |
pam-fi |
1.6 |
|
2469 |
|
|
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
2470 |
|
|
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
2471 |
|
|
|
2472 |
|
|
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
2473 |
|
|
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
2474 |
pam-fi |
1.20 |
|
2475 |
|
|
if( detlist.Contains("-TOF0", TString::kIgnoreCase) )TOF0 = false; |
2476 |
|
|
else if( detlist.Contains("+TOF0", TString::kIgnoreCase) )TOF0 = true; |
2477 |
pam-fi |
1.6 |
|
2478 |
|
|
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
2479 |
|
|
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
2480 |
|
|
|
2481 |
|
|
if( detlist.Contains("-ND", TString::kIgnoreCase) )ND = false; |
2482 |
|
|
else if( detlist.Contains("+ND", TString::kIgnoreCase) )ND = true; |
2483 |
|
|
|
2484 |
|
|
if( detlist.Contains("-AC", TString::kIgnoreCase) )AC = false; |
2485 |
|
|
else if( detlist.Contains("+AC", TString::kIgnoreCase) )AC = true; |
2486 |
|
|
|
2487 |
|
|
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
2488 |
|
|
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
2489 |
pam-fi |
1.11 |
|
2490 |
pam-fi |
1.12 |
// cout<< "Set detector list --> "; |
2491 |
|
|
// if(TRK1)cout<<"TRK1 "; |
2492 |
|
|
// if(TRK2)cout<<"TRK2 "; |
2493 |
|
|
// if(TRKh)cout<<"TRKH "; |
2494 |
|
|
// if(CAL1)cout<<"CAL1 "; |
2495 |
|
|
// if(CAL2)cout<<"CAL2 "; |
2496 |
|
|
// if(TOF)cout<<"TOF "; |
2497 |
|
|
// if(TRG)cout<<"TRG "; |
2498 |
|
|
// if(AC)cout<<"AC "; |
2499 |
|
|
// if(ND)cout<<"ND "; |
2500 |
|
|
// if(S4)cout<<"S4 "; |
2501 |
|
|
// if(ORB)cout<<"ORB "; |
2502 |
|
|
// cout << endl; |
2503 |
pam-fi |
1.6 |
|
2504 |
pam-fi |
1.2 |
}; |
2505 |
pam-fi |
1.11 |
|
2506 |
|
|
|
2507 |
|
|
/** |
2508 |
|
|
* Set tree/branch detector flags from the content of a tree |
2509 |
|
|
*/ |
2510 |
|
|
void PamLevel2::GetWhichTrees(TFile* f){ |
2511 |
pam-fi |
1.20 |
|
2512 |
|
|
|
2513 |
|
|
|
2514 |
|
|
cout << "void PamLevel2::GetWhichTrees(TFile* f) --- WARNING!! --- ...potrebbe non funzionare "<<endl; |
2515 |
pam-fi |
1.11 |
// ----------- |
2516 |
|
|
// reset flags |
2517 |
|
|
// ----------- |
2518 |
pam-fi |
1.12 |
CAL1 = false; |
2519 |
|
|
CAL2 = false; |
2520 |
|
|
TRK2 = false; |
2521 |
|
|
TRK1 = false; |
2522 |
|
|
TRKh = false; |
2523 |
|
|
TRG = false; |
2524 |
|
|
TOF = false; |
2525 |
|
|
S4 = false; |
2526 |
|
|
ND = false; |
2527 |
|
|
AC = false; |
2528 |
|
|
ORB = false; |
2529 |
pam-fi |
1.11 |
|
2530 |
pam-fi |
1.12 |
RUN = false; |
2531 |
pam-fi |
1.11 |
|
2532 |
|
|
cout << "Checking file: "<<f->GetName()<<endl; |
2533 |
|
|
if( !f || f->IsZombie() ){ |
2534 |
|
|
cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; |
2535 |
|
|
return; |
2536 |
|
|
} |
2537 |
|
|
|
2538 |
|
|
TList *lk = f->GetListOfKeys(); |
2539 |
|
|
TIter next(lk); |
2540 |
|
|
TKey *key =0; |
2541 |
|
|
|
2542 |
|
|
Int_t nev = 0; |
2543 |
|
|
|
2544 |
|
|
while( (key = (TKey*)next()) ){ |
2545 |
|
|
|
2546 |
|
|
if( !strcmp(key->GetName(),"Run" ) )RUN = true; |
2547 |
|
|
|
2548 |
|
|
//========================================================= |
2549 |
|
|
if( !strcmp(key->GetName(),"Trigger" ) ){ |
2550 |
|
|
TRG = true; |
2551 |
|
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
2552 |
|
|
if( nev && nevt!=nev){ |
2553 |
|
|
cout << "File: "<< f->GetName() <<" Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
2554 |
|
|
TRG = false; |
2555 |
|
|
}else nev=nevt; |
2556 |
|
|
} |
2557 |
|
|
//========================================================= |
2558 |
|
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
2559 |
|
|
TOF = true; |
2560 |
|
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
2561 |
|
|
if( nev && nevt!=nev){ |
2562 |
|
|
cout << "File: "<< f->GetName() <<" ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
2563 |
|
|
TOF = false; |
2564 |
|
|
}else nev=nevt; |
2565 |
|
|
} |
2566 |
|
|
//========================================================= |
2567 |
|
|
if( !strcmp(key->GetName(),"S4" ) ){ |
2568 |
|
|
S4 = true; |
2569 |
|
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
2570 |
|
|
if( nev && nevt!=nev){ |
2571 |
|
|
cout << "File: "<< f->GetName() <<" S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
2572 |
|
|
S4 = false; |
2573 |
|
|
}else nev=nevt; |
2574 |
|
|
} |
2575 |
|
|
//========================================================= |
2576 |
|
|
|
2577 |
|
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
2578 |
|
|
ND = true; |
2579 |
|
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
2580 |
|
|
if( nev && nevt!=nev){ |
2581 |
|
|
cout << "File: "<< f->GetName() <<"NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
2582 |
|
|
ND =false; |
2583 |
|
|
}else nev=nevt; |
2584 |
|
|
} |
2585 |
|
|
//========================================================= |
2586 |
|
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
2587 |
|
|
AC = true; |
2588 |
|
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
2589 |
|
|
if( nev && nevt!=nev){ |
2590 |
|
|
cout << "File: "<< f->GetName() <<" Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
2591 |
|
|
AC =false; |
2592 |
|
|
}else nev=nevt; |
2593 |
|
|
} |
2594 |
|
|
//========================================================= |
2595 |
|
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
2596 |
|
|
ORB = true; |
2597 |
|
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
2598 |
|
|
if( nev && nevt!=nev){ |
2599 |
|
|
cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
2600 |
|
|
ORB = false; |
2601 |
|
|
}else nev=nevt; |
2602 |
|
|
} |
2603 |
|
|
//========================================================= |
2604 |
|
|
if( !strcmp(key->GetName(),"Tracker" ) ){ |
2605 |
|
|
TTree *T = (TTree*)f->Get("Tracker"); |
2606 |
|
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
2607 |
|
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
2608 |
|
|
if( !name.CompareTo("TrkLevel1") )TRK1=true; |
2609 |
|
|
if( !name.CompareTo("TrkLevel2") )TRK2=true; |
2610 |
|
|
if( !name.CompareTo("TrkHough") )TRKh=true; |
2611 |
|
|
}; |
2612 |
|
|
Int_t nevt = T->GetEntries(); |
2613 |
|
|
if( nev && nevt!=nev){ |
2614 |
|
|
cout << "File: "<< f->GetName() <<" Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
2615 |
|
|
TRK1 = false; |
2616 |
|
|
TRK2 = false; |
2617 |
|
|
TRKh = false; |
2618 |
|
|
}else nev=nevt; |
2619 |
|
|
T->Delete(); |
2620 |
|
|
}; |
2621 |
|
|
//========================================================= |
2622 |
|
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
2623 |
|
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
2624 |
|
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
2625 |
|
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
2626 |
|
|
if( !name.CompareTo("CaloLevel1") )CAL1=true; |
2627 |
|
|
if( !name.CompareTo("CaloLevel2") )CAL2=true; |
2628 |
|
|
}; |
2629 |
|
|
Int_t nevt = T->GetEntries(); |
2630 |
|
|
if( nev && nevt!=nev){ |
2631 |
|
|
cout << "File: "<< f->GetName() <<" Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
2632 |
|
|
CAL1 = false; |
2633 |
|
|
CAL2 = false; |
2634 |
|
|
}else nev=nevt; |
2635 |
|
|
T->Delete(); |
2636 |
|
|
}; |
2637 |
|
|
|
2638 |
|
|
}; |
2639 |
|
|
|
2640 |
pam-fi |
1.13 |
delete lk; |
2641 |
pam-fi |
1.12 |
|
2642 |
|
|
// cout<< "Get detector list from input file --> "; |
2643 |
|
|
// if(TRK1)cout<<"TRK1 "; |
2644 |
|
|
// if(TRK2)cout<<"TRK2 "; |
2645 |
|
|
// if(TRKh)cout<<"TRKH "; |
2646 |
|
|
// if(CAL1)cout<<"CAL1 "; |
2647 |
|
|
// if(CAL2)cout<<"CAL2 "; |
2648 |
|
|
// if(TOF)cout<<"TOF "; |
2649 |
|
|
// if(TRG)cout<<"TRG "; |
2650 |
|
|
// if(AC)cout<<"AC "; |
2651 |
|
|
// if(ND)cout<<"ND "; |
2652 |
|
|
// if(S4)cout<<"S4 "; |
2653 |
|
|
// if(ORB)cout<<"ORB "; |
2654 |
|
|
// cout << endl; |
2655 |
pam-fi |
1.11 |
|
2656 |
|
|
return ; |
2657 |
|
|
|
2658 |
|
|
}; |
2659 |
|
|
|
2660 |
|
|
|
2661 |
pam-fi |
1.2 |
//-------------------------------------- |
2662 |
|
|
// |
2663 |
|
|
// |
2664 |
|
|
//-------------------------------------- |
2665 |
|
|
/** |
2666 |
pam-fi |
1.3 |
* Check if a file contains selected Pamela Level2 trees. |
2667 |
pam-fi |
1.2 |
* @param name File name |
2668 |
pam-fi |
1.4 |
* @return true if the file is ok. |
2669 |
pam-fi |
1.2 |
*/ |
2670 |
|
|
Bool_t PamLevel2::CheckLevel2File(TString name){ |
2671 |
|
|
|
2672 |
pam-fi |
1.8 |
Bool_t CAL1__ok = false; |
2673 |
|
|
Bool_t CAL2__ok = false; |
2674 |
|
|
Bool_t TRK2__ok = false; |
2675 |
|
|
Bool_t TRK1__ok = false; |
2676 |
|
|
Bool_t TRKh__ok = false; |
2677 |
pam-fi |
1.7 |
Bool_t TRG__ok = false; |
2678 |
|
|
Bool_t TOF__ok = false; |
2679 |
|
|
Bool_t S4__ok = false; |
2680 |
|
|
Bool_t ND__ok = false; |
2681 |
|
|
Bool_t AC__ok = false; |
2682 |
|
|
Bool_t ORB__ok = false; |
2683 |
pam-fi |
1.6 |
|
2684 |
pam-fi |
1.7 |
Bool_t RUN__ok = false; |
2685 |
pam-fi |
1.6 |
|
2686 |
pam-fi |
1.20 |
Bool_t SELLI__ok = false; |
2687 |
pam-fi |
1.8 |
|
2688 |
|
|
cout << "Checking file: "<<name<<endl; |
2689 |
pam-fi |
1.6 |
TFile *f = new TFile(name.Data()); |
2690 |
|
|
if( !f || f->IsZombie() ){ |
2691 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false; |
2692 |
|
|
} |
2693 |
pam-fi |
1.7 |
// cout << "Get list of keys: "<<f<<endl; |
2694 |
pam-fi |
1.6 |
TList *lk = f->GetListOfKeys(); |
2695 |
pam-fi |
1.8 |
// lk->Print(); |
2696 |
pam-fi |
1.6 |
TIter next(lk); |
2697 |
|
|
TKey *key =0; |
2698 |
pam-fi |
1.8 |
|
2699 |
|
|
Int_t nev = 0; |
2700 |
|
|
|
2701 |
pam-fi |
1.6 |
while( (key = (TKey*)next()) ){ |
2702 |
|
|
|
2703 |
pam-fi |
1.20 |
// cout << key->GetName() << endl; |
2704 |
pam-fi |
1.12 |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
2705 |
|
|
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
2706 |
pam-fi |
1.7 |
// nev_previous = nev; |
2707 |
|
|
// cout << " n.entries "<< nev <<endl; |
2708 |
|
|
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
2709 |
|
|
// nev = ((TTree*)f->Get(key->GetName()))->GetEntries(); |
2710 |
|
|
// cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl; |
2711 |
|
|
// return false; |
2712 |
|
|
// }; |
2713 |
pam-fi |
1.6 |
|
2714 |
pam-fi |
1.20 |
|
2715 |
pam-fi |
1.6 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
2716 |
pam-fi |
1.8 |
|
2717 |
|
|
//========================================================= |
2718 |
pam-fi |
1.20 |
if( !strcmp(key->GetName(),"SelectionList" ) ){ |
2719 |
|
|
SELLI__ok = true; |
2720 |
|
|
if(SELLI==1){ |
2721 |
|
|
Int_t nevt = ((TTree*)f->Get("SelectionList"))->GetEntries(); |
2722 |
|
|
if( nev && nevt!=nev){ |
2723 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList tree has "<<nevt<<" events instead of "<<nev<< endl; |
2724 |
|
|
return false; |
2725 |
|
|
} |
2726 |
|
|
nev=nevt; |
2727 |
|
|
} |
2728 |
|
|
} |
2729 |
|
|
|
2730 |
|
|
//========================================================= |
2731 |
pam-fi |
1.8 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
2732 |
|
|
TRG__ok = true; |
2733 |
|
|
if(TRG){ |
2734 |
|
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
2735 |
|
|
if( nev && nevt!=nev){ |
2736 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
2737 |
|
|
return false; |
2738 |
|
|
} |
2739 |
|
|
nev=nevt; |
2740 |
|
|
} |
2741 |
|
|
} |
2742 |
|
|
//========================================================= |
2743 |
|
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
2744 |
|
|
TOF__ok = true; |
2745 |
|
|
if(TOF){ |
2746 |
|
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
2747 |
|
|
if( nev && nevt!=nev){ |
2748 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
2749 |
|
|
return false; |
2750 |
|
|
} |
2751 |
|
|
nev=nevt; |
2752 |
|
|
} |
2753 |
|
|
} |
2754 |
|
|
//========================================================= |
2755 |
|
|
if( !strcmp(key->GetName(),"S4" ) ){ |
2756 |
|
|
S4__ok = true; |
2757 |
|
|
if(S4){ |
2758 |
|
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
2759 |
|
|
if( nev && nevt!=nev){ |
2760 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
2761 |
|
|
return false; |
2762 |
|
|
} |
2763 |
|
|
nev=nevt; |
2764 |
|
|
} |
2765 |
|
|
} |
2766 |
|
|
//========================================================= |
2767 |
|
|
|
2768 |
|
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
2769 |
|
|
ND__ok = true; |
2770 |
|
|
if(ND){ |
2771 |
|
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
2772 |
|
|
if( nev && nevt!=nev){ |
2773 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
2774 |
|
|
return false; |
2775 |
|
|
} |
2776 |
|
|
nev=nevt; |
2777 |
|
|
} |
2778 |
|
|
} |
2779 |
|
|
//========================================================= |
2780 |
|
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
2781 |
|
|
AC__ok = true; |
2782 |
|
|
if(AC){ |
2783 |
|
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
2784 |
|
|
if( nev && nevt!=nev){ |
2785 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
2786 |
|
|
return false; |
2787 |
|
|
} |
2788 |
|
|
nev=nevt; |
2789 |
|
|
} |
2790 |
|
|
} |
2791 |
|
|
//========================================================= |
2792 |
|
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
2793 |
|
|
ORB__ok = true; |
2794 |
|
|
if(ORB){ |
2795 |
|
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
2796 |
|
|
if( nev && nevt!=nev){ |
2797 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
2798 |
|
|
return false; |
2799 |
|
|
} |
2800 |
|
|
nev=nevt; |
2801 |
|
|
} |
2802 |
|
|
} |
2803 |
|
|
//========================================================= |
2804 |
pam-fi |
1.6 |
if( !strcmp(key->GetName(),"Tracker" ) ){ |
2805 |
|
|
TTree *T = (TTree*)f->Get("Tracker"); |
2806 |
pam-fi |
1.8 |
if(TRK1||TRK2||TRKh){ |
2807 |
|
|
Int_t nevt = T->GetEntries(); |
2808 |
|
|
if( nev && nevt!=nev){ |
2809 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
2810 |
|
|
return false; |
2811 |
|
|
} |
2812 |
|
|
nev=nevt; |
2813 |
|
|
} |
2814 |
pam-fi |
1.6 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
2815 |
|
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
2816 |
pam-fi |
1.8 |
if( !name.CompareTo("TrkLevel1") )TRK1__ok=true; |
2817 |
|
|
if( !name.CompareTo("TrkLevel2") )TRK2__ok=true; |
2818 |
|
|
if( !name.CompareTo("TrkHough") )TRKh__ok=true; |
2819 |
|
|
}; |
2820 |
|
|
T->Delete(); |
2821 |
pam-fi |
1.2 |
}; |
2822 |
pam-fi |
1.8 |
//========================================================= |
2823 |
|
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
2824 |
|
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
2825 |
|
|
if(CAL1||CAL2){ |
2826 |
|
|
Int_t nevt = T->GetEntries(); |
2827 |
|
|
if( nev && nevt!=nev){ |
2828 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
2829 |
|
|
return false; |
2830 |
|
|
} |
2831 |
|
|
nev=nevt; |
2832 |
|
|
} |
2833 |
|
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
2834 |
|
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
2835 |
|
|
if( !name.CompareTo("CaloLevel1") )CAL1__ok=true; |
2836 |
|
|
if( !name.CompareTo("CaloLevel2") )CAL2__ok=true; |
2837 |
|
|
}; |
2838 |
|
|
T->Delete(); |
2839 |
|
|
}; |
2840 |
|
|
|
2841 |
pam-fi |
1.6 |
}; |
2842 |
pam-fi |
1.20 |
|
2843 |
|
|
if( SELLI==-1 )SELLI = (Int_t)SELLI__ok; |
2844 |
|
|
if( SELLI==0 && SELLI__ok ){ |
2845 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- found SelectionList (it is not a full-event file)" << endl; |
2846 |
|
|
return false; |
2847 |
|
|
} |
2848 |
|
|
if( SELLI==1 && !SELLI__ok ){ |
2849 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList missing" << endl; |
2850 |
|
|
return false; |
2851 |
|
|
} |
2852 |
pam-fi |
1.6 |
|
2853 |
pam-fi |
1.20 |
// cout << "SELLI "<<SELLI<<endl; |
2854 |
|
|
|
2855 |
pam-fi |
1.12 |
// cout<< "CheckLevel2File(TString): detector list --> "; |
2856 |
|
|
// if(TRK1__ok)cout<<"TRK1 "; |
2857 |
|
|
// if(TRK2__ok)cout<<"TRK2 "; |
2858 |
|
|
// if(TRKh__ok)cout<<"TRKH "; |
2859 |
|
|
// if(CAL1__ok)cout<<"CAL1 "; |
2860 |
|
|
// if(CAL2__ok)cout<<"CAL2 "; |
2861 |
|
|
// if(TOF__ok)cout<<"TOF "; |
2862 |
|
|
// if(TRG__ok)cout<<"TRG "; |
2863 |
|
|
// if(AC__ok)cout<<"AC "; |
2864 |
|
|
// if(ND__ok)cout<<"ND "; |
2865 |
|
|
// if(S4__ok)cout<<"S4 "; |
2866 |
|
|
// if(ORB__ok)cout<<"ORB "; |
2867 |
|
|
// cout << endl; |
2868 |
pam-fi |
1.8 |
|
2869 |
|
|
|
2870 |
pam-fi |
1.13 |
if(TRK2 && TRK1__ok)TRK1=1; |
2871 |
|
|
// ---------------------------------------------------------------------------- |
2872 |
|
|
// NOTA |
2873 |
|
|
// se c'e` il level1, lo devo necessarimente leggere. |
2874 |
|
|
// infatti (non ho capito perche`) i cluster vengono letti e allocati in memoria |
2875 |
|
|
// comunque, ma non vengono disallocati da PamLevel2::Clear() |
2876 |
|
|
// ---------------------------------------------------------------------------- |
2877 |
|
|
|
2878 |
|
|
|
2879 |
pam-fi |
1.6 |
if(!RUN__ok) { |
2880 |
pam-fi |
1.9 |
cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl; |
2881 |
|
|
// return false; |
2882 |
pam-fi |
1.8 |
}; |
2883 |
|
|
|
2884 |
|
|
if(CAL1 && !CAL1__ok){ |
2885 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel1 branch"<< endl; |
2886 |
|
|
return false; |
2887 |
|
|
}; |
2888 |
|
|
if(CAL2 && !CAL2__ok){ |
2889 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel2 branch"<< endl; |
2890 |
|
|
return false; |
2891 |
|
|
}; |
2892 |
|
|
if(TRK2 && !TRK2__ok){ |
2893 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel2 branch"<< endl; |
2894 |
|
|
return false; |
2895 |
|
|
}; |
2896 |
|
|
if(TRK1 && !TRK1__ok){ |
2897 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel1 branch"<< endl; |
2898 |
|
|
return false; |
2899 |
|
|
}; |
2900 |
|
|
if(TRKh && !TRKh__ok){ |
2901 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkHough branch"<< endl; |
2902 |
|
|
return false; |
2903 |
pam-fi |
1.6 |
}; |
2904 |
pam-fi |
1.8 |
if(ORB && !ORB__ok){ |
2905 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl; |
2906 |
|
|
return false; |
2907 |
pam-fi |
1.6 |
}; |
2908 |
pam-fi |
1.8 |
if(AC && !AC__ok){ |
2909 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl; |
2910 |
|
|
return false; |
2911 |
pam-fi |
1.6 |
}; |
2912 |
|
|
if(S4 && !S4__ok){ |
2913 |
pam-fi |
1.8 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl; |
2914 |
|
|
return false; |
2915 |
pam-fi |
1.6 |
}; |
2916 |
pam-fi |
1.8 |
if(TOF && !TOF__ok){ |
2917 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl; |
2918 |
|
|
return false; |
2919 |
pam-fi |
1.6 |
}; |
2920 |
pam-fi |
1.8 |
|
2921 |
pam-fi |
1.12 |
if(ND && !ND__ok){ |
2922 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
2923 |
|
|
return false; |
2924 |
|
|
}; |
2925 |
|
|
if(TRG && !TRG__ok){ |
2926 |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
2927 |
|
|
return false; |
2928 |
|
|
}; |
2929 |
|
|
|
2930 |
pam-fi |
1.8 |
|
2931 |
pam-fi |
1.13 |
// lk->Delete(); |
2932 |
|
|
// delete lk; |
2933 |
pam-fi |
1.8 |
f->Close(); |
2934 |
pam-fi |
1.12 |
|
2935 |
|
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
2936 |
|
|
// if(TRK1)cout<<"TRK1 "; |
2937 |
|
|
// if(TRK2)cout<<"TRK2 "; |
2938 |
|
|
// if(TRKh)cout<<"TRKH "; |
2939 |
|
|
// if(CAL1)cout<<"CAL1 "; |
2940 |
|
|
// if(CAL2)cout<<"CAL2 "; |
2941 |
|
|
// if(TOF)cout<<"TOF "; |
2942 |
|
|
// if(TRG)cout<<"TRG "; |
2943 |
|
|
// if(AC)cout<<"AC "; |
2944 |
|
|
// if(ND)cout<<"ND "; |
2945 |
|
|
// if(S4)cout<<"S4 "; |
2946 |
|
|
// if(ORB)cout<<"ORB "; |
2947 |
|
|
// cout << endl; |
2948 |
pam-fi |
1.8 |
|
2949 |
|
|
return true; |
2950 |
pam-fi |
1.2 |
|
2951 |
|
|
}; |
2952 |
|
|
|
2953 |
|
|
|
2954 |
pam-fi |
1.9 |
/** |
2955 |
|
|
* Create clone-trees |
2956 |
|
|
*/ |
2957 |
pam-fi |
1.11 |
void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ |
2958 |
pam-fi |
1.9 |
|
2959 |
|
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2960 |
|
|
cout << "Create clones of PAMELA trees "<<endl; |
2961 |
|
|
|
2962 |
|
|
Int_t i=0; |
2963 |
pam-fi |
1.20 |
pam_tree_clone[i] = fChain->GetTree()->CloneTree(0); |
2964 |
|
|
TString name = pam_tree_clone[i]->GetName(); |
2965 |
pam-fi |
1.9 |
name.Append("_clone"); |
2966 |
pam-fi |
1.20 |
// pam_tree_clone[i]->SetName(name.Data()); |
2967 |
|
|
cout << pam_tree_clone[i]->GetName() <<endl; |
2968 |
pam-fi |
1.9 |
i++; |
2969 |
|
|
|
2970 |
|
|
TList *li = fChain->GetListOfFriends(); |
2971 |
|
|
TIter next(li); |
2972 |
|
|
TFriendElement* T_friend=0; |
2973 |
pam-fi |
1.11 |
ofile->cd(); |
2974 |
pam-fi |
1.9 |
while( (T_friend = (TFriendElement*)next()) ){ |
2975 |
|
|
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
2976 |
|
|
// cout<<T_friend->GetTree()->GetName()<< endl; |
2977 |
pam-fi |
1.20 |
pam_tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
2978 |
|
|
pam_tree_clone[i]->SetAutoSave(1000000); |
2979 |
|
|
name = pam_tree_clone[i]->GetName(); |
2980 |
pam-fi |
1.9 |
name.Append("_clone"); |
2981 |
pam-fi |
1.20 |
// pam_tree_clone[i]->SetName(name.Data()); |
2982 |
|
|
cout << pam_tree_clone[i]->GetName() << endl; |
2983 |
pam-fi |
1.9 |
i++; |
2984 |
|
|
} |
2985 |
pam-fi |
1.13 |
|
2986 |
|
|
delete li; |
2987 |
pam-fi |
1.9 |
|
2988 |
|
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2989 |
|
|
|
2990 |
|
|
} |
2991 |
|
|
|
2992 |
pam-fi |
1.11 |
/** |
2993 |
|
|
* Create clone-trees |
2994 |
|
|
*/ |
2995 |
|
|
void PamLevel2::CreateCloneTrees(TFile *ofile){ |
2996 |
|
|
|
2997 |
pam-fi |
1.39 |
|
2998 |
|
|
// if the pointer is null, create a default file |
2999 |
|
|
|
3000 |
|
|
if(!ofile){ |
3001 |
|
|
cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl; |
3002 |
|
|
ofile = new TFile("clone-tree.root","recreate"); |
3003 |
|
|
} |
3004 |
|
|
|
3005 |
pam-fi |
1.11 |
ofile->cd(); |
3006 |
pam-fi |
1.9 |
|
3007 |
pam-fi |
1.11 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
3008 |
|
|
cout << "Create new PAMELA trees "<<endl; |
3009 |
pam-fi |
1.9 |
|
3010 |
pam-fi |
1.20 |
|
3011 |
|
|
run_tree_clone = new TTree("Run","PAMELA Level2 data from the GL_RUN table "); |
3012 |
|
|
run_tree_clone->Branch("RunInfo","GL_RUN",GetPointerTo("RunInfo")); |
3013 |
|
|
cout << "Run : branch RunInfo"<<endl; |
3014 |
|
|
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
3015 |
|
|
cout << "Run : branch SoftInfo"<<endl; |
3016 |
pam-fi |
1.36 |
// ------------------ |
3017 |
|
|
// replicate run tree |
3018 |
|
|
// ------------------ |
3019 |
|
|
cout << "----------------------------------------------------"<<endl; |
3020 |
|
|
cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl; |
3021 |
|
|
for (Int_t i=0; i<run_tree->GetEntries(); i++){ |
3022 |
|
|
run_tree->GetEntry(i); |
3023 |
|
|
cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
3024 |
|
|
run_tree_clone->Fill(); |
3025 |
|
|
} |
3026 |
|
|
cout << "----------------------------------------------------"<<endl; |
3027 |
pam-fi |
1.20 |
|
3028 |
pam-fi |
1.45 |
// ------------------------------------ |
3029 |
|
|
// add branch with dead and live times |
3030 |
|
|
// ------------------------------------ |
3031 |
|
|
run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l"); |
3032 |
|
|
cout << "Run : branch DeadLiveTime"<<endl; |
3033 |
|
|
|
3034 |
pam-fi |
1.20 |
|
3035 |
|
|
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
3036 |
pam-fi |
1.34 |
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
3037 |
|
|
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); |
3038 |
pam-fi |
1.20 |
|
3039 |
|
|
|
3040 |
pam-fi |
1.11 |
Int_t i=0; |
3041 |
|
|
if(TRK1||TRK2||TRKh){ |
3042 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
3043 |
pam-fi |
1.11 |
if(TRK1) { |
3044 |
pam-fi |
1.20 |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
3045 |
|
|
pam_tree_clone[i]->BranchRef(); |
3046 |
pam-fi |
1.11 |
cout << "Tracker : branch TrkLevel1"<<endl; |
3047 |
pam-fi |
1.36 |
// cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
3048 |
pam-fi |
1.11 |
}; |
3049 |
|
|
if(TRK2) { |
3050 |
pam-fi |
1.20 |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
3051 |
pam-fi |
1.11 |
cout << "Tracker : branch TrkLevel2"<<endl; |
3052 |
|
|
}; |
3053 |
|
|
if(TRKh) { |
3054 |
pam-fi |
1.20 |
pam_tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
3055 |
pam-fi |
1.11 |
cout << "Tracker : branch TrkHough"<<endl; |
3056 |
|
|
}; |
3057 |
|
|
i++; |
3058 |
|
|
} |
3059 |
pam-fi |
1.9 |
|
3060 |
pam-fi |
1.11 |
// Calorimeter |
3061 |
|
|
if(CAL1||CAL2){ |
3062 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
3063 |
pam-fi |
1.11 |
if(CAL1) { |
3064 |
pam-fi |
1.20 |
pam_tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
3065 |
pam-fi |
1.11 |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
3066 |
|
|
}; |
3067 |
|
|
if(CAL2) { |
3068 |
pam-fi |
1.20 |
pam_tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
3069 |
pam-fi |
1.11 |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
3070 |
|
|
}; |
3071 |
|
|
i++; |
3072 |
|
|
} |
3073 |
pam-fi |
1.9 |
|
3074 |
pam-fi |
1.11 |
// ToF |
3075 |
|
|
if(TOF) { |
3076 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
3077 |
|
|
pam_tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
3078 |
pam-fi |
1.11 |
cout << "ToF : branch ToFLevel2"<<endl; |
3079 |
|
|
i++; |
3080 |
|
|
}; |
3081 |
|
|
// Trigger |
3082 |
|
|
if(TRG) { |
3083 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
3084 |
|
|
pam_tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
3085 |
pam-fi |
1.11 |
cout << "Trigger : branch TrigLevel2"<<endl; |
3086 |
|
|
i++; |
3087 |
|
|
}; |
3088 |
|
|
// S4 |
3089 |
|
|
if(S4) { |
3090 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
3091 |
|
|
pam_tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
3092 |
pam-fi |
1.11 |
cout << "S4 : branch S4Level2"<<endl; |
3093 |
|
|
i++; |
3094 |
|
|
}; |
3095 |
|
|
// Neutron Detector |
3096 |
|
|
if(ND) { |
3097 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
3098 |
|
|
pam_tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
3099 |
pam-fi |
1.11 |
cout << "NeutronD : branch NDLevel2"<<endl; |
3100 |
|
|
i++; |
3101 |
|
|
}; |
3102 |
|
|
// Anticounters |
3103 |
|
|
if(AC) { |
3104 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
3105 |
|
|
pam_tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
3106 |
pam-fi |
1.11 |
cout << "Anticounter : branch AcLevel2"<<endl; |
3107 |
|
|
i++; |
3108 |
|
|
}; |
3109 |
|
|
// OrbitalInfo |
3110 |
|
|
if(ORB) { |
3111 |
pam-fi |
1.20 |
pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
3112 |
|
|
pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
3113 |
pam-fi |
1.11 |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
3114 |
|
|
i++; |
3115 |
|
|
}; |
3116 |
|
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
3117 |
pam-fi |
1.9 |
|
3118 |
pam-fi |
1.11 |
} |
3119 |
pam-fi |
1.9 |
|
3120 |
|
|
|
3121 |
|
|
/** |
3122 |
|
|
* Fill tree (created with CreateCloneTrees) |
3123 |
|
|
* |
3124 |
|
|
*/ |
3125 |
|
|
//void PamLevel2::FillNewPamTree(TTree *T){ |
3126 |
|
|
void PamLevel2::FillCloneTrees(){ |
3127 |
pam-fi |
1.20 |
|
3128 |
|
|
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
3129 |
pam-fi |
1.24 |
|
3130 |
pam-fi |
1.20 |
for(Int_t i=0; i<NCLONES; i++){ |
3131 |
|
|
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
3132 |
|
|
} |
3133 |
|
|
if(sel_tree_clone)sel_tree_clone->Fill(); |
3134 |
pam-fi |
1.21 |
|
3135 |
pam-fi |
1.9 |
} |
3136 |
|
|
|
3137 |
|
|
|
3138 |
|
|
TTree* PamLevel2::GetCloneTree(TString name){ |
3139 |
|
|
|
3140 |
pam-fi |
1.20 |
for(Int_t i=0; i<NCLONES; i++){ |
3141 |
|
|
if(pam_tree_clone[i]){ |
3142 |
|
|
TString na = pam_tree_clone[i]->GetName(); |
3143 |
|
|
if(!name.CompareTo(na))return pam_tree_clone[i]; |
3144 |
pam-fi |
1.9 |
}; |
3145 |
|
|
} |
3146 |
pam-fi |
1.20 |
if(run_tree_clone){ |
3147 |
|
|
TString na = run_tree_clone->GetName(); |
3148 |
|
|
if(!name.CompareTo(na))return run_tree_clone; |
3149 |
|
|
} |
3150 |
|
|
if(sel_tree_clone){ |
3151 |
|
|
TString na = sel_tree_clone->GetName(); |
3152 |
|
|
if(!name.CompareTo(na))return sel_tree_clone; |
3153 |
|
|
} |
3154 |
pam-fi |
1.9 |
return NULL; |
3155 |
|
|
|
3156 |
|
|
} |
3157 |
|
|
void PamLevel2::WriteCloneTrees(){ |
3158 |
|
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
3159 |
|
|
cout << "Write clones of PAMELA trees "<<endl; |
3160 |
pam-fi |
1.45 |
cout << run_tree_clone->GetName()<<endl; |
3161 |
|
|
if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
3162 |
|
|
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
3163 |
pam-fi |
1.20 |
run_tree_clone->Write(); |
3164 |
|
|
cout << sel_tree_clone->GetName()<<endl; |
3165 |
|
|
sel_tree_clone->Write(); |
3166 |
|
|
for(Int_t i=0; i<NCLONES; i++){ |
3167 |
|
|
if(pam_tree_clone[i]){ |
3168 |
|
|
cout << pam_tree_clone[i]->GetName()<<endl; |
3169 |
|
|
pam_tree_clone[i]->Write(); |
3170 |
pam-fi |
1.9 |
}; |
3171 |
|
|
} |
3172 |
|
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
3173 |
|
|
|
3174 |
|
|
} |
3175 |
|
|
|
3176 |
|
|
/** |
3177 |
pam-fi |
1.24 |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
3178 |
pam-fi |
1.9 |
*/ |
3179 |
pam-fi |
1.33 |
//Int_t PamLevel2::GetEntry(Int_t iee){ |
3180 |
|
|
Int_t PamLevel2::GetEntry(Long64_t iee){ |
3181 |
pam-fi |
1.9 |
|
3182 |
pam-fi |
1.39 |
// cout << "-------------------------------------"<<endl; |
3183 |
|
|
// cout << "Int_t PamLevel2::GetEntry("<<iee<<")"<<endl; |
3184 |
|
|
|
3185 |
pam-fi |
1.20 |
if(!pam_tree){ |
3186 |
mocchiut |
1.28 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
3187 |
pam-fi |
1.20 |
return 0; |
3188 |
|
|
} |
3189 |
mocchiut |
1.28 |
|
3190 |
|
|
|
3191 |
|
|
// |
3192 |
|
|
// This is a sort of bug: if you don't have the run tree you don't want to exit here you want to have loaded the event anyway... |
3193 |
|
|
// |
3194 |
|
|
// if(!run_tree ){ |
3195 |
|
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; |
3196 |
|
|
// return 0; |
3197 |
|
|
// } |
3198 |
pam-fi |
1.20 |
|
3199 |
pam-fi |
1.33 |
Long64_t ii=0; |
3200 |
pam-fi |
1.20 |
//------------------------------- |
3201 |
|
|
ii = iee; |
3202 |
pam-fi |
1.33 |
if( !pam_tree->GetEntry(ii) ){ |
3203 |
|
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl; |
3204 |
|
|
return 0; |
3205 |
|
|
} |
3206 |
mocchiut |
1.28 |
// |
3207 |
|
|
// ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0. |
3208 |
|
|
// in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not |
3209 |
|
|
// a problem if you don't check the return code of getentry. |
3210 |
|
|
// |
3211 |
|
|
if(!run_tree ){ |
3212 |
mocchiut |
1.29 |
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
3213 |
pam-fi |
1.36 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
3214 |
|
|
return 0; |
3215 |
mocchiut |
1.29 |
} else { |
3216 |
pam-fi |
1.36 |
return 1; //cosi` se non c'e` run esce qua... |
3217 |
mocchiut |
1.29 |
} |
3218 |
mocchiut |
1.28 |
} |
3219 |
|
|
|
3220 |
pam-fi |
1.20 |
//------------------------------- |
3221 |
|
|
ii = iee; |
3222 |
pam-fi |
1.33 |
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
3223 |
pam-fi |
1.36 |
// Bool_t UPDATED = UpdateRunInfo(ii); |
3224 |
|
|
UpdateRunInfo(ii); |
3225 |
pam-fi |
1.20 |
if(SELLI==0)irunentry = iee-runfirstentry; |
3226 |
pam-fi |
1.36 |
// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
3227 |
|
|
|
3228 |
pam-fi |
1.20 |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
3229 |
|
|
|
3230 |
pam-fi |
1.39 |
// cout << "irunentry "<<irunentry << endl; |
3231 |
|
|
// cout << "runfirstentry "<<runfirstentry << endl; |
3232 |
|
|
// cout << "nevents "<<GetRunInfo()->NEVENTS<< endl; |
3233 |
pam-fi |
1.40 |
|
3234 |
|
|
// if( TRK0 || CAL0 || TOF0 ){ |
3235 |
|
|
// if( !GetYodaEntry( ) ){ |
3236 |
|
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
3237 |
|
|
// return 0; |
3238 |
|
|
// } |
3239 |
|
|
// } |
3240 |
|
|
|
3241 |
|
|
|
3242 |
pam-fi |
1.20 |
return 1; |
3243 |
|
|
|
3244 |
|
|
} |
3245 |
|
|
|
3246 |
pam-fi |
1.40 |
TrkLevel0 *PamLevel2::GetTrkLevel0(){ |
3247 |
|
|
if( !TRK0 )return NULL; |
3248 |
|
|
if( !GetYodaEntry( ) ){ |
3249 |
|
|
cout << " Int_t PamLevel2::GetTrkLevel0() -- ERROR -- error reading level0 tree"<<endl; |
3250 |
|
|
return 0; |
3251 |
|
|
} |
3252 |
|
|
return trk0_obj; |
3253 |
|
|
}; |
3254 |
|
|
CaloLevel0 *PamLevel2::GetCaloLevel0(){ |
3255 |
|
|
if( !CAL0 )return NULL; |
3256 |
|
|
if( !GetYodaEntry( ) ){ |
3257 |
|
|
cout << " Int_t PamLevel2::GetCaloLevel0() -- ERROR -- error reading level0 tree"<<endl; |
3258 |
|
|
return 0; |
3259 |
|
|
} |
3260 |
|
|
return calo0_obj; |
3261 |
|
|
}; |
3262 |
|
|
|
3263 |
|
|
|
3264 |
pam-fi |
1.20 |
/** |
3265 |
|
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
3266 |
|
|
* Given the run ID (...), if needed it query the DB and load the proper file. |
3267 |
|
|
* @return Pointer to the tree |
3268 |
|
|
*/ |
3269 |
|
|
|
3270 |
|
|
|
3271 |
|
|
TTree* PamLevel2::GetYodaTree( ){ |
3272 |
|
|
|
3273 |
|
|
// cout << "TTree* PamLevel2::GetYodaTree( )"<<endl; |
3274 |
|
|
//=================================== |
3275 |
|
|
// check if iroot has changed |
3276 |
|
|
//=================================== |
3277 |
|
|
if( irun<0 ){ |
3278 |
pam-fi |
1.34 |
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = "<<irun<<endl; |
3279 |
|
|
// cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
3280 |
pam-fi |
1.20 |
return NULL; |
3281 |
|
|
} |
3282 |
|
|
Int_t irootnew = run_obj->ID_ROOT_L0; |
3283 |
pam-fi |
1.39 |
// cout << "iroot "<<iroot<<endl; |
3284 |
|
|
// cout << "irootnew "<<irootnew<<endl; |
3285 |
pam-fi |
1.20 |
|
3286 |
|
|
//=================================== |
3287 |
|
|
// load the level0 file |
3288 |
|
|
// (if not already loaded) |
3289 |
|
|
//=================================== |
3290 |
|
|
if( iroot != irootnew || !l0_tree){ |
3291 |
|
|
iroot = irootnew; |
3292 |
|
|
//=================================== |
3293 |
|
|
// open the DB connection |
3294 |
|
|
// (if not already opened) |
3295 |
|
|
//=================================== |
3296 |
|
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
3297 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
3298 |
|
|
cout<<"Connecting to DB"<<endl; |
3299 |
|
|
cout<<"HOST "<<host<<endl; |
3300 |
|
|
cout<<"USER "<<user<<endl; |
3301 |
|
|
cout<<"PSW "<<psw<<endl; |
3302 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
3303 |
|
|
if( !dbc )return NULL; |
3304 |
|
|
if( !dbc->IsConnected() )return NULL; |
3305 |
|
|
// cout<<"...done"<<endl; |
3306 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
3307 |
|
|
}else{ |
3308 |
|
|
// cout<<"DB already connected"<<endl; |
3309 |
|
|
} |
3310 |
|
|
GL_ROOT glroot = GL_ROOT(); |
3311 |
pam-fi |
1.24 |
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
3312 |
|
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
3313 |
|
|
return NULL; |
3314 |
|
|
}; |
3315 |
pam-fi |
1.20 |
TString filename = glroot.PATH + glroot.NAME; |
3316 |
|
|
if(l0_file){ |
3317 |
|
|
l0_file->Close(); |
3318 |
|
|
l0_file->Delete(); |
3319 |
|
|
} |
3320 |
|
|
cout << "Opening LEVEL0 file: "<< filename << endl; |
3321 |
|
|
FileStat_t t; |
3322 |
|
|
if( gSystem->GetPathInfo(filename.Data(),t) ){ |
3323 |
|
|
cout << " PamLevel2::GetYodaTree() -- ERROR opening file "<<endl; |
3324 |
|
|
return NULL; |
3325 |
|
|
} |
3326 |
|
|
l0_file = new TFile(filename); |
3327 |
|
|
if( !l0_file )return NULL; |
3328 |
|
|
l0_tree = (TTree*)l0_file->Get("Physics"); |
3329 |
|
|
if(!h0_obj)h0_obj = new EventHeader(); |
3330 |
|
|
l0_tree->SetBranchAddress("Header" ,&h0_obj); |
3331 |
mocchiut |
1.30 |
prevshift = 0; |
3332 |
pam-fi |
1.20 |
//--------------------------------------------------- |
3333 |
|
|
// TRACKER: |
3334 |
|
|
if(TRK0){ |
3335 |
|
|
if(!trk0_obj){ |
3336 |
|
|
trk0_obj = new TrkLevel0(); |
3337 |
|
|
trk0_obj->Set(); |
3338 |
|
|
}; |
3339 |
|
|
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
3340 |
|
|
} |
3341 |
pam-fi |
1.40 |
//-------------------------------------------------- |
3342 |
pam-fi |
1.20 |
// CALORIMETER: |
3343 |
|
|
if(CAL0){ |
3344 |
mocchiut |
1.30 |
if(!calo0_obj){ |
3345 |
|
|
calo0_obj = new CaloLevel0(); |
3346 |
|
|
calo0_obj->Set(); |
3347 |
|
|
}; |
3348 |
|
|
l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); |
3349 |
|
|
// cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
3350 |
pam-fi |
1.20 |
} |
3351 |
|
|
//--------------------------------------------------- |
3352 |
|
|
// TOF: |
3353 |
|
|
if(TOF0){ |
3354 |
|
|
cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl; |
3355 |
|
|
} |
3356 |
|
|
|
3357 |
|
|
}; |
3358 |
|
|
|
3359 |
pam-fi |
1.26 |
if(!dbc || (dbc && !dbc->IsConnected())){ |
3360 |
|
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
3361 |
|
|
} |
3362 |
|
|
|
3363 |
pam-fi |
1.33 |
if ( TRK0 ){ |
3364 |
|
|
TrkParams::Load(6); |
3365 |
|
|
if( !TrkParams::IsLoaded(6) ){ |
3366 |
|
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
3367 |
|
|
}; |
3368 |
|
|
TrkParams::SetCalib(run_obj,dbc); |
3369 |
|
|
TrkParams::LoadCalib( ); |
3370 |
|
|
if( !TrkParams::CalibIsLoaded() ){ |
3371 |
|
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl; |
3372 |
|
|
}; |
3373 |
|
|
} |
3374 |
pam-fi |
1.26 |
|
3375 |
pam-fi |
1.24 |
// cout << l0_tree << endl; |
3376 |
|
|
|
3377 |
pam-fi |
1.20 |
return l0_tree; |
3378 |
pam-fi |
1.9 |
|
3379 |
pam-fi |
1.20 |
} |
3380 |
pam-fi |
1.9 |
|
3381 |
pam-fi |
1.20 |
/** |
3382 |
|
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
3383 |
|
|
*/ |
3384 |
|
|
Int_t PamLevel2::GetYodaEntry(){ |
3385 |
pam-fi |
1.9 |
|
3386 |
pam-fi |
1.20 |
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
3387 |
|
|
if(!GetYodaTree())return 0; |
3388 |
|
|
|
3389 |
pam-fi |
1.27 |
// patch |
3390 |
pam-fi |
1.33 |
if( irunentry < 0){ |
3391 |
pam-fi |
1.36 |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
3392 |
pam-fi |
1.33 |
irunentry=0LL; |
3393 |
pam-fi |
1.27 |
} |
3394 |
pam-fi |
1.20 |
// --------------------------------- |
3395 |
|
|
// if file is NOT a preselected file |
3396 |
|
|
// --------------------------------- |
3397 |
pam-fi |
1.33 |
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
3398 |
pam-fi |
1.36 |
// cout << " irunentry "<<irunentry<<endl; |
3399 |
|
|
// cout << " EV_FROM "<<run_obj->EV_FROM<<endl; |
3400 |
|
|
// cout << " quellagiusta = irunentry + EV_FROM "<< quellagiusta << endl; |
3401 |
pam-fi |
1.24 |
|
3402 |
pam-fi |
1.26 |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
3403 |
|
|
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
3404 |
pam-fi |
1.43 |
// cout << " time "<< abstime << endl; |
3405 |
pam-fi |
1.26 |
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
3406 |
|
|
|
3407 |
pam-fi |
1.43 |
ULong64_t obt = 0; |
3408 |
|
|
ULong64_t pktn = 0; |
3409 |
|
|
if( GetOrbitalInfo() ){ |
3410 |
|
|
obt = GetOrbitalInfo()->OBT; |
3411 |
|
|
pktn = GetOrbitalInfo()->pkt_num; |
3412 |
|
|
} |
3413 |
|
|
|
3414 |
|
|
if( !GetOrbitalInfo() && !ISGP){ |
3415 |
pam-fi |
1.24 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
3416 |
|
|
return 0; |
3417 |
|
|
} |
3418 |
pam-fi |
1.43 |
if( obt==0 && pktn==0 && !ISGP ){ |
3419 |
pam-fi |
1.34 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
3420 |
|
|
return 0; |
3421 |
|
|
} |
3422 |
pam-fi |
1.24 |
|
3423 |
|
|
// --------------------------------------------------------------------- |
3424 |
|
|
// ATTENTION!!! |
3425 |
|
|
// If data are not pre-processed with cleaner, the level0 tree may contain |
3426 |
|
|
// spurious nested physics packets. |
3427 |
|
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
3428 |
|
|
// while level2 tree DOES NOT!! |
3429 |
|
|
// This means that "quellagiusta" in these cases is not correct. |
3430 |
|
|
// In order to retrieve the correct level0 event, I implemented a check |
3431 |
|
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
3432 |
|
|
// is shift forward until when the packets match. |
3433 |
|
|
// --------------------------------------------------------------------- |
3434 |
|
|
Int_t answer = 0; |
3435 |
|
|
Int_t shift =0; |
3436 |
mocchiut |
1.31 |
// printf(" siamo qui %i %i \n",shift,prevshift); |
3437 |
pam-fi |
1.39 |
Int_t maxshift = 10; |
3438 |
pam-fi |
1.24 |
do{ |
3439 |
mocchiut |
1.30 |
if(shift>0){ |
3440 |
pam-fi |
1.43 |
cout << " PKTNUM L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
3441 |
pam-fi |
1.36 |
cout << " RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM <<endl; |
3442 |
|
|
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
3443 |
pam-fi |
1.26 |
} |
3444 |
pam-fi |
1.33 |
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
3445 |
pam-fi |
1.24 |
shift++; |
3446 |
|
|
if( !GetEventHeader() ){ |
3447 |
|
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
3448 |
|
|
return 0; |
3449 |
|
|
} |
3450 |
pam-fi |
1.43 |
|
3451 |
|
|
if(ISGP){ |
3452 |
|
|
obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO |
3453 |
|
|
pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO |
3454 |
|
|
} |
3455 |
|
|
|
3456 |
|
|
// cout << "PKTNUM "<<shift<<" == L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
3457 |
|
|
// cout << " L2 --- "<< obt << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
3458 |
pam-fi |
1.26 |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
3459 |
pam-fi |
1.43 |
// cout << " obt "<< obt << endl; |
3460 |
pam-fi |
1.26 |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
3461 |
pam-fi |
1.43 |
// cout << " pktn "<< pktn << endl; |
3462 |
pam-fi |
1.26 |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
3463 |
mocchiut |
1.31 |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
3464 |
|
|
// |
3465 |
pam-fi |
1.33 |
if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ |
3466 |
mocchiut |
1.30 |
prevshift = 0; |
3467 |
|
|
shift = -1; |
3468 |
|
|
}; |
3469 |
pam-fi |
1.26 |
|
3470 |
pam-fi |
1.43 |
}while( ( obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || |
3471 |
|
|
pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ) |
3472 |
|
|
&& (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
3473 |
mocchiut |
1.30 |
|
3474 |
pam-fi |
1.39 |
if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) { |
3475 |
pam-fi |
1.36 |
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
3476 |
|
|
return 0; |
3477 |
|
|
} |
3478 |
pam-fi |
1.20 |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
3479 |
pam-fi |
1.24 |
// return GetYodaTree()->GetEntry(quellagiusta); |
3480 |
mocchiut |
1.30 |
if ( shift > 1 ) prevshift += (shift-1); |
3481 |
pam-fi |
1.20 |
|
3482 |
pam-fi |
1.24 |
return answer; |
3483 |
pam-fi |
1.20 |
|
3484 |
|
|
} |
3485 |
pam-fi |
1.40 |
/** |
3486 |
|
|
* \Brief Set DB connection |
3487 |
|
|
*/ |
3488 |
|
|
Bool_t PamLevel2::SetDBConnection(){ |
3489 |
mocchiut |
1.30 |
|
3490 |
pam-fi |
1.40 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
3491 |
|
|
cout<<"Connecting to DB"<<endl; |
3492 |
|
|
cout<<"HOST "<<host<<endl; |
3493 |
|
|
cout<<"USER "<<user<<endl; |
3494 |
|
|
cout<<"PSW "<<psw<<endl; |
3495 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
3496 |
|
|
if( !dbc )return false; |
3497 |
|
|
if( !dbc->IsConnected() )return false; |
3498 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
3499 |
|
|
return true; |
3500 |
mocchiut |
1.30 |
|
3501 |
pam-fi |
1.40 |
} |
3502 |
pam-fi |
1.45 |
|
3503 |
|
|
/** |
3504 |
|
|
* \Brief Add a friend to the pamela chain. |
3505 |
|
|
* @param cname name of the chain to be added |
3506 |
|
|
*/ |
3507 |
|
|
|
3508 |
|
|
TChain* PamLevel2::AddFriend(TString cname){ |
3509 |
|
|
|
3510 |
|
|
if(!GetPamTree()){ |
3511 |
|
|
cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<<endl; |
3512 |
|
|
return NULL; |
3513 |
|
|
} |
3514 |
|
|
|
3515 |
|
|
|
3516 |
|
|
TChain *c = new TChain( cname.Data() ); |
3517 |
|
|
|
3518 |
|
|
TIter next( GetPamTree()->GetListOfFiles() ); |
3519 |
|
|
Int_t nf = 0; |
3520 |
|
|
TChainElement* element = 0; |
3521 |
|
|
while ((element = (TChainElement*) next())) { |
3522 |
|
|
c->Add(element->GetTitle()); |
3523 |
|
|
nf++; |
3524 |
|
|
} |
3525 |
|
|
|
3526 |
|
|
GetPamTree()->AddFriend(cname.Data()); |
3527 |
|
|
|
3528 |
|
|
cout << "external chain created and added to pamela friends :"<<cname<<endl; |
3529 |
|
|
cout << "n.files "<<nf<<endl; |
3530 |
|
|
|
3531 |
|
|
|
3532 |
|
|
return c; |
3533 |
|
|
|
3534 |
|
|
} |