7 |
* Default constructor |
* Default constructor |
8 |
*/ |
*/ |
9 |
PamTrack::PamTrack(){ |
PamTrack::PamTrack(){ |
10 |
trk_track = this->TrkTrack::GetTrkTrack(); |
trk_track = 0; |
11 |
calo_track = this->CaloTrkVar::GetCaloTrkVar(); |
calo_track = 0; |
12 |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
tof_track = 0; |
13 |
|
candeleteobj = 0; |
14 |
}; |
}; |
15 |
//-------------------------------------- |
//-------------------------------------- |
16 |
// |
// |
20 |
* Constructor |
* Constructor |
21 |
*/ |
*/ |
22 |
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){ |
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){ |
23 |
trk_track = this->TrkTrack::GetTrkTrack(); |
|
24 |
calo_track = this->CaloTrkVar::GetCaloTrkVar(); |
trk_track = 0; |
25 |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
calo_track = 0; |
26 |
if(t) *trk_track = *t; |
tof_track = 0; |
27 |
if(c) *calo_track = *c; |
// if(t)trk_track = new TrkTrack(*t); |
28 |
if(o) *tof_track = *o; |
// if(c)calo_track = new CaloTrkVar(*c); |
29 |
|
// if(o)tof_track = new ToFTrkVar(*o); |
30 |
|
if(t)trk_track = t; |
31 |
|
if(c)calo_track = c; |
32 |
|
if(o)tof_track = o; |
33 |
|
candeleteobj = 0; |
34 |
|
|
35 |
}; |
}; |
36 |
|
PamTrack::PamTrack(const PamTrack& track){ |
37 |
|
|
38 |
|
TrkTrack *t = track.trk_track; |
39 |
|
CaloTrkVar *c = track.calo_track; |
40 |
|
ToFTrkVar *o = track.tof_track; |
41 |
|
|
42 |
|
trk_track = 0; |
43 |
|
calo_track = 0; |
44 |
|
tof_track = 0; |
45 |
|
if(t)trk_track = new TrkTrack(*t); |
46 |
|
if(c)calo_track = new CaloTrkVar(*c); |
47 |
|
if(o)tof_track = new ToFTrkVar(*o); |
48 |
|
candeleteobj = 1; |
49 |
|
|
50 |
|
} |
51 |
|
void PamTrack::Clear(){ |
52 |
|
|
53 |
|
// cout << "PamTrack::Clear() "<<candeleteobj<<endl; |
54 |
|
if(candeleteobj){ |
55 |
|
if(trk_track) trk_track->TrkTrack::Clear(); |
56 |
|
if(calo_track) calo_track->CaloTrkVar::Clear();//??? |
57 |
|
if(tof_track) tof_track->ToFTrkVar::Clear();//??? |
58 |
|
}else{ |
59 |
|
trk_track = 0; |
60 |
|
calo_track = 0; |
61 |
|
tof_track = 0; |
62 |
|
} |
63 |
|
} |
64 |
|
void PamTrack::Delete(){ |
65 |
|
// cout << "PamTrack::Delete() "<<candeleteobj<<endl; |
66 |
|
if(candeleteobj){ |
67 |
|
if(trk_track) { |
68 |
|
trk_track->TrkTrack::Clear(); |
69 |
|
delete trk_track; |
70 |
|
} |
71 |
|
if(calo_track){ |
72 |
|
calo_track->CaloTrkVar::Clear();//??? |
73 |
|
delete calo_track; |
74 |
|
} |
75 |
|
if(tof_track){ |
76 |
|
tof_track->ToFTrkVar::Clear();//??? |
77 |
|
delete tof_track; |
78 |
|
} |
79 |
|
}else{ |
80 |
|
Clear(); |
81 |
|
} |
82 |
|
} |
83 |
//-------------------------------------- |
//-------------------------------------- |
84 |
// |
// |
85 |
// |
// |
89 |
*/ |
*/ |
90 |
PamLevel2::PamLevel2(){ |
PamLevel2::PamLevel2(){ |
91 |
|
|
92 |
trk2_obj = TrkLevel2::GetTrkLevel2(); |
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
93 |
trk1_obj = TrkLevel1::GetTrkLevel1(); |
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
94 |
trkh_obj = TrkHough::GetTrkHough(); |
// trkh_obj = TrkHough::GetTrkHough(); |
95 |
calo1_obj = CaloLevel1::GetCaloLevel1(); |
// calo1_obj = CaloLevel1::GetCaloLevel1(); |
96 |
calo2_obj = CaloLevel2::GetCaloLevel2(); |
// calo2_obj = CaloLevel2::GetCaloLevel2(); |
97 |
tof_obj = ToFLevel2::GetToFLevel2(); |
// tof_obj = ToFLevel2::GetToFLevel2(); |
98 |
trig_obj = TrigLevel2::GetTrigLevel2(); |
// trig_obj = TrigLevel2::GetTrigLevel2(); |
99 |
s4_obj = S4Level2::GetS4Level2(); |
// s4_obj = S4Level2::GetS4Level2(); |
100 |
nd_obj = NDLevel2::GetNDLevel2(); |
// nd_obj = NDLevel2::GetNDLevel2(); |
101 |
ac_obj = AcLevel2::GetAcLevel2(); |
// ac_obj = AcLevel2::GetAcLevel2(); |
102 |
orb_obj = OrbitalInfo::GetOrbitalInfo(); |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
103 |
|
|
104 |
run_obj = new GL_RUN(); |
h0_obj = 0; |
105 |
|
trk0_obj = 0; |
106 |
// trk1_clone = 0; |
|
107 |
// trk2_clone = 0; |
trk2_obj = 0; |
108 |
// trkh_clone = 0; |
trk1_obj = 0; |
109 |
// calo1_clone = 0; |
trkh_obj = 0; |
110 |
// calo2_clone = 0; |
calo1_obj = 0; |
111 |
// tof_clone = 0; |
calo2_obj = 0; |
112 |
// trig_clone = 0; |
tof_obj = 0; |
113 |
// s4_clone = 0; |
trig_obj = 0; |
114 |
// nd_clone = 0; |
s4_obj = 0; |
115 |
// ac_clone = 0; |
nd_obj = 0; |
116 |
// orb_clone = 0; |
ac_obj = 0; |
117 |
|
orb_obj = 0; |
118 |
// T_clone = 0; |
|
119 |
// C_clone = 0; |
run_obj = 0;//new GL_RUN(); |
120 |
// O_clone = 0; |
soft_obj = 0;// Emiliano |
121 |
// R_clone = 0; |
irun = -1; |
122 |
// S_clone = 0; |
runfirstentry = 0ULL; |
123 |
// N_clone = 0; |
runlastentry = 0ULL; |
124 |
// A_clone = 0; |
|
125 |
// B_clone = 0; |
l0_file = NULL; |
126 |
|
l0_tree = NULL; |
127 |
|
iroot = -1; |
128 |
|
dbc = 0; |
129 |
|
|
130 |
|
irun = -1; |
131 |
|
run_tree = NULL; |
132 |
|
run_tree_clone = NULL; |
133 |
|
sel_tree = NULL; |
134 |
|
sel_tree_clone = NULL; |
135 |
|
|
136 |
|
irunentry = -1; |
137 |
|
pam_tree = NULL; |
138 |
|
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
139 |
|
|
140 |
|
host = "mysql://localhost/pamelaprod"; |
141 |
|
user = "anonymous"; |
142 |
|
psw = ""; |
143 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
144 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
145 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
146 |
|
if ( !pamdbhost ) pamdbhost = ""; |
147 |
|
if ( !pamdbuser ) pamdbuser = ""; |
148 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
149 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
150 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
151 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
152 |
|
|
153 |
for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; |
|
154 |
|
|
155 |
sorted_tracks = new TRefArray(); |
// sorted_tracks = 0;//new TRefArray(); |
156 |
|
|
157 |
|
CAL0 = false; |
158 |
CAL1 = true; |
CAL1 = true; |
159 |
CAL2 = true; |
CAL2 = true; |
160 |
TRK2 = true; |
TRK2 = true; |
161 |
TRK1 = false; |
TRK1 = false; |
162 |
TRKh = false; |
TRKh = false; |
163 |
TRG = true; |
TRKh = false; |
164 |
TOF = true; |
TRG = true; |
165 |
S4 = true; |
TOF = true; |
166 |
ND = true; |
TOF0 = false; |
167 |
AC = true; |
S4 = true; |
168 |
ORB = true; |
ND = true; |
169 |
|
AC = true; |
170 |
|
ORB = true; |
171 |
|
|
172 |
|
RUN = true; |
173 |
|
|
174 |
|
SELLI = -1; |
175 |
|
|
176 |
|
tsorted=0; |
177 |
|
timage=0; |
178 |
|
|
179 |
}; |
}; |
180 |
/** |
/** |
181 |
* Destructor |
* Delete the event (act as Dtor) |
182 |
*/ |
*/ |
183 |
PamLevel2::~PamLevel2(){ |
void PamLevel2::Delete(){ |
184 |
delete run_obj; |
|
185 |
Clear(); |
if(run_obj)delete run_obj; |
186 |
|
if(soft_obj)delete soft_obj; //Emiliano |
187 |
|
|
188 |
|
// cout << "void PamLevel2::Clear()"<<endl; |
189 |
|
if(h0_obj) delete h0_obj; |
190 |
|
if(trk0_obj) delete trk0_obj; |
191 |
|
if(trk1_obj) delete trk1_obj; |
192 |
|
if(trk2_obj) delete trk2_obj; |
193 |
|
if(trkh_obj) delete trkh_obj; |
194 |
|
if(calo1_obj)delete calo1_obj; |
195 |
|
if(calo2_obj)delete calo2_obj; |
196 |
|
if(tof_obj) delete tof_obj; |
197 |
|
if(trig_obj) delete trig_obj; |
198 |
|
if(s4_obj) delete s4_obj; |
199 |
|
if(nd_obj) delete nd_obj; |
200 |
|
if(ac_obj) delete ac_obj; |
201 |
|
if(orb_obj) delete orb_obj; |
202 |
|
|
203 |
|
if(tsorted){ |
204 |
|
tsorted->Delete(); |
205 |
|
delete tsorted; |
206 |
|
} |
207 |
|
if(timage){ |
208 |
|
timage->Delete(); |
209 |
|
delete timage; |
210 |
|
} |
211 |
|
|
212 |
|
if(dbc){ |
213 |
|
dbc->Close(); |
214 |
|
delete dbc; |
215 |
|
} |
216 |
|
|
217 |
|
if(l0_file)l0_file->Close(); |
218 |
|
if(pam_tree)pam_tree->Delete();; |
219 |
|
if(run_tree)run_tree->Delete();; |
220 |
|
if(sel_tree)sel_tree->Delete();; |
221 |
|
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
222 |
|
if(run_tree_clone)run_tree_clone->Delete();; |
223 |
|
if(sel_tree_clone)sel_tree_clone->Delete();; |
224 |
|
|
225 |
|
|
226 |
}; |
}; |
227 |
|
|
228 |
/** |
/** |
229 |
* Clear the event |
* Clear the event (NB! does not deallocate objects) |
230 |
*/ |
*/ |
231 |
void PamLevel2::Clear(){ |
void PamLevel2::Clear(){ |
232 |
|
|
233 |
TrkLevel1::Clear(); |
// cout << "void PamLevel2::Clear()"<<endl; |
234 |
|
|
235 |
TrkLevel2::Clear(); |
// |
236 |
CaloLevel2::Clear(); |
// 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 |
237 |
ToFLevel2::Clear(); |
// want to load them for each event even if they are the same... |
238 |
TrigLevel2::Clear(); |
// |
239 |
S4Level2::Clear(); |
// if(run_obj)delete run_obj; |
240 |
NDLevel2::Clear(); |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
241 |
AcLevel2::Clear(); |
// if(soft_obj) soft_obj->Clear(); |
242 |
OrbitalInfo::Clear(); |
|
243 |
|
if(h0_obj) h0_obj->Clear(); |
244 |
// if(trk1_clone)trk1_clone->Clear(); |
if(trk0_obj) trk0_obj->Clear(); |
245 |
// if(trk2_clone)trk2_clone->Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
246 |
// if(trkh_clone)trkh_clone->Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
247 |
// if(calo1_clone)calo1_clone->Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
248 |
// if(calo2_clone)calo2_clone->Clear(); |
if(calo1_obj)calo1_obj->Clear(); |
249 |
// if(tof_clone)tof_clone->Clear(); |
if(calo2_obj)calo2_obj->Clear(); |
250 |
// if(trig_clone)trig_clone->Clear(); |
if(tof_obj) tof_obj->Clear(); |
251 |
// if(s4_clone)s4_clone->Clear(); |
if(trig_obj) trig_obj->Clear(); |
252 |
// if(nd_clone)nd_clone->Clear(); |
if(s4_obj) s4_obj->Clear(); |
253 |
// if(ac_clone)ac_clone->Clear(); |
if(nd_obj) nd_obj->Clear(); |
254 |
// if(orb_clone)orb_clone->Clear(); |
if(ac_obj) ac_obj->Clear(); |
255 |
|
if(orb_obj) orb_obj->Clear(); |
256 |
|
|
257 |
sorted_tracks->Delete(); // clean the reference array |
// if(sorted_tracks)sorted_tracks->Clear(); |
258 |
|
// sorted_tracks.Clear(); |
259 |
|
|
260 |
|
if(tsorted){ |
261 |
|
tsorted->Delete(); |
262 |
|
} |
263 |
|
if(timage){ |
264 |
|
timage->Delete(); |
265 |
|
} |
266 |
|
|
267 |
}; |
}; |
268 |
|
|
274 |
void *PamLevel2::GetPointerTo(const char* c ){ |
void *PamLevel2::GetPointerTo(const char* c ){ |
275 |
|
|
276 |
TString objname = c; |
TString objname = c; |
277 |
if(!objname.CompareTo("TrkLevel1"))return &trk1_obj; |
|
278 |
if(!objname.CompareTo("TrkLevel2"))return &trk2_obj; |
if(!objname.CompareTo("TrkLevel1")) { |
279 |
if(!objname.CompareTo("TrkHough"))return &trkh_obj; |
if(!trk1_obj){ |
280 |
if(!objname.CompareTo("CaloLevel1"))return &calo1_obj; |
trk1_obj = new TrkLevel1(); |
281 |
if(!objname.CompareTo("CaloLevel2"))return &calo2_obj; |
trk1_obj->Set(); |
282 |
if(!objname.CompareTo("ToFLevel2"))return &tof_obj; |
} |
283 |
if(!objname.CompareTo("TrigLevel2"))return &trig_obj; |
return &trk1_obj; |
284 |
if(!objname.CompareTo("S4Level2"))return &s4_obj; |
}; |
285 |
if(!objname.CompareTo("NDLevel2"))return &nd_obj; |
if(!objname.CompareTo("TrkLevel2")) { |
286 |
if(!objname.CompareTo("AcLevel2"))return &ac_obj; |
if(!trk2_obj){ |
287 |
if(!objname.CompareTo("OrbitalInfo"))return &orb_obj; |
trk2_obj = new TrkLevel2(); |
288 |
|
trk2_obj->Set(); |
289 |
|
} |
290 |
|
return &trk2_obj; |
291 |
|
}; |
292 |
|
if(!objname.CompareTo("TrkHough")) { |
293 |
|
if(!trkh_obj) trkh_obj = new TrkHough(); |
294 |
|
return &trkh_obj; |
295 |
|
}; |
296 |
|
if(!objname.CompareTo("CaloLevel1")) { |
297 |
|
if(!calo1_obj) calo1_obj = new CaloLevel1(); |
298 |
|
return &calo1_obj; |
299 |
|
}; |
300 |
|
if(!objname.CompareTo("CaloLevel2")) { |
301 |
|
if(!calo2_obj){ |
302 |
|
calo2_obj = new CaloLevel2(); |
303 |
|
calo2_obj->Set(); |
304 |
|
}; |
305 |
|
return &calo2_obj; |
306 |
|
}; |
307 |
|
if(!objname.CompareTo("ToFLevel2")) { |
308 |
|
if(!tof_obj){ |
309 |
|
tof_obj = new ToFLevel2(); |
310 |
|
tof_obj->Set(); |
311 |
|
} |
312 |
|
return &tof_obj; |
313 |
|
}; |
314 |
|
if(!objname.CompareTo("TrigLevel2")) { |
315 |
|
if(!trig_obj) trig_obj = new TrigLevel2(); |
316 |
|
return &trig_obj; |
317 |
|
}; |
318 |
|
if(!objname.CompareTo("S4Level2")) { |
319 |
|
if(!s4_obj) s4_obj = new S4Level2(); |
320 |
|
return &s4_obj; |
321 |
|
}; |
322 |
|
if(!objname.CompareTo("NDLevel2")) { |
323 |
|
if(!nd_obj) nd_obj = new NDLevel2(); |
324 |
|
return &nd_obj; |
325 |
|
}; |
326 |
|
if(!objname.CompareTo("AcLevel2")) { |
327 |
|
if(!ac_obj) ac_obj = new AcLevel2(); |
328 |
|
return &ac_obj; |
329 |
|
}; |
330 |
|
if(!objname.CompareTo("OrbitalInfo")){ |
331 |
|
if(!orb_obj) orb_obj = new OrbitalInfo(); |
332 |
|
return &orb_obj; |
333 |
|
}; |
334 |
|
|
335 |
if(!objname.CompareTo("RunInfo"))return &run_obj; |
if(!objname.CompareTo("RunInfo"))return &run_obj; |
336 |
|
|
337 |
|
if(!objname.CompareTo("SoftInfo"))return &soft_obj; // Emiliano |
338 |
|
|
339 |
return NULL; |
return NULL; |
340 |
}; |
}; |
341 |
//-------------------------------------- |
//-------------------------------------- |
347 |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
348 |
*/ |
*/ |
349 |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
350 |
|
|
351 |
if( CaloLevel2::ntrk()==0 ){ |
if( !calo2_obj )return 0; |
352 |
|
|
353 |
|
if( calo2_obj->CaloLevel2::ntrk()==0 ){ |
354 |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
355 |
return NULL; |
return NULL; |
356 |
}; |
}; |
359 |
Int_t it_calo=0; |
Int_t it_calo=0; |
360 |
|
|
361 |
do{ |
do{ |
362 |
c = CaloLevel2::GetCaloTrkVar(it_calo); |
c = calo2_obj->CaloLevel2::GetCaloTrkVar(it_calo); |
363 |
it_calo++; |
it_calo++; |
364 |
} while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_calo < calo2_obj->CaloLevel2::ntrk()); |
365 |
|
|
366 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
367 |
c = 0; |
c = 0; |
380 |
*/ |
*/ |
381 |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
382 |
|
|
383 |
if( ToFLevel2::ntrk()==0 ){ |
if( !tof_obj )return 0; |
384 |
|
|
385 |
|
if( tof_obj->ToFLevel2::ntrk()==0 ){ |
386 |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
387 |
return NULL; |
return NULL; |
388 |
}; |
}; |
391 |
Int_t it_tof=0; |
Int_t it_tof=0; |
392 |
|
|
393 |
do{ |
do{ |
394 |
c = ToFLevel2::GetToFTrkVar(it_tof); |
c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); |
395 |
it_tof++; |
it_tof++; |
396 |
} while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); |
397 |
|
|
398 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
399 |
c = 0; |
c = 0; |
411 |
* Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. |
* Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. |
412 |
*/ |
*/ |
413 |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
414 |
|
|
415 |
|
cout <<"PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** "<<endl; |
416 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
417 |
|
|
418 |
CaloTrkVar *c = 0; |
CaloTrkVar *c = 0; |
419 |
ToFTrkVar *o = 0; |
ToFTrkVar *o = 0; |
420 |
|
|
439 |
|
|
440 |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
441 |
|
|
442 |
|
cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl; |
443 |
|
cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl; |
444 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
445 |
PamTrack *track = 0; |
PamTrack *track = 0; |
446 |
|
|
447 |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
if( itrk >=0 && itrk < trk2_obj->TrkLevel2::ntrk() ){ |
448 |
|
|
449 |
TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); |
TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); |
450 |
track = GetPamTrackAlong(t); |
track = GetPamTrackAlong(t); |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
}else{ |
}else{ |
455 |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
456 |
}; |
}; |
457 |
|
|
458 |
return track; |
return track; |
475 |
*/ |
*/ |
476 |
void PamLevel2::SortTracks(TString how){ |
void PamLevel2::SortTracks(TString how){ |
477 |
|
|
478 |
|
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
479 |
|
if( !trk2_obj ){ |
480 |
|
cout << "void PamLevel2::SortTracks(TString how): TrkLevel2 not loaded !!!"; |
481 |
|
return; |
482 |
|
}; |
483 |
// cout << "call SortTracs() "<<endl; |
// cout << "call SortTracs() "<<endl; |
484 |
//Save current Object count |
//Save current Object count |
485 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
486 |
|
|
487 |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
488 |
|
|
489 |
sorted_tracks->Delete(); //temporaneo??? |
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
490 |
|
// sorted_tracks->Clear(); |
491 |
|
// sorted_tracks.Clear(); |
492 |
|
|
493 |
|
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
494 |
|
tsorted->Delete(); |
495 |
|
TClonesArray &ttsorted = *tsorted; |
496 |
|
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
497 |
|
timage->Delete(); |
498 |
|
TClonesArray &ttimage = *timage; |
499 |
|
|
500 |
|
|
501 |
// loop over the tracks sorted by the tracker |
// loop over the tracks sorted by the tracker |
502 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
503 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
513 |
|
|
514 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
515 |
|
|
516 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
517 |
|
|
518 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
519 |
|
CaloTrkVar *cs = 0; |
520 |
|
ToFTrkVar *os = 0; |
521 |
|
|
522 |
// get tracker tracks |
// get tracker tracks |
523 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
524 |
CaloTrkVar *cp = 0; |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
525 |
ToFTrkVar *op = 0; |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
526 |
|
|
527 |
|
TrkTrack *ti = 0; //tracker (image) |
528 |
|
CaloTrkVar *ci = 0; |
529 |
|
ToFTrkVar *oi = 0; |
530 |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
531 |
// if track has an image, check image selection |
// if track has an image, check image selection |
532 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
533 |
|
|
534 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
535 |
CaloTrkVar *ci = 0; |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
536 |
ToFTrkVar *oi = 0; |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
537 |
|
|
538 |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
539 |
|
|
546 |
// ------------------------ |
// ------------------------ |
547 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
548 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
549 |
|
if( use_CAL && !calo2_obj ){ |
550 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but CaloLevel2 not loaded !!!"; |
551 |
|
return; |
552 |
|
}; |
553 |
if( |
if( |
554 |
use_CAL && |
use_CAL && |
555 |
npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
556 |
varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
557 |
|
cp && ci && |
558 |
true){ |
true){ |
559 |
|
|
|
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
|
|
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
|
560 |
|
|
561 |
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
562 |
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
563 |
|
|
564 |
if(resy_p <= resy_i) tp_score++; |
if(resy_p <= resy_i) tp_score++; |
565 |
else ti_score++; |
else ti_score++; |
572 |
// ------------------------ |
// ------------------------ |
573 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
574 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
575 |
if( use_TOF ){ |
if( use_TOF && !tof_obj ){ |
576 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
577 |
|
return; |
578 |
|
}; |
579 |
|
if( use_TOF && op && oi ){ |
580 |
|
|
581 |
Int_t nphit_p =0; |
Int_t nphit_p =0; |
582 |
Int_t nphit_i =0; |
Int_t nphit_i =0; |
583 |
|
|
|
op = GetToFStoredTrack(tp->GetSeqNo()); |
|
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
|
584 |
|
|
585 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
586 |
cout << "track: npmttdc "<< op->npmttdc << endl; |
cout << "track: npmttdc "<< op->npmttdc << endl; |
588 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
589 |
|
|
590 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
591 |
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
592 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
593 |
}; |
}; |
594 |
|
|
595 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
596 |
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
597 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
598 |
}; |
}; |
599 |
|
|
623 |
// ------------------------ |
// ------------------------ |
624 |
// the winner is.... |
// the winner is.... |
625 |
// ------------------------ |
// ------------------------ |
626 |
if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
if (tp_score > ti_score) { |
627 |
else if (tp_score < ti_score) ts = ti;//its image!! |
// ts = tp;//the track sorted by the tracker!! |
628 |
else { |
// cs = cp; |
629 |
ts = tp; |
// os = op; |
630 |
|
}else if (tp_score < ti_score) { |
631 |
|
ts = ti;//its image!! |
632 |
|
cs = ci; |
633 |
|
os = oi; |
634 |
|
|
635 |
|
ti = tp;//its image!! |
636 |
|
ci = cp; |
637 |
|
oi = op; |
638 |
|
|
639 |
|
tp = ts;//its image!! |
640 |
|
cp = cs; |
641 |
|
op = os; |
642 |
|
|
643 |
|
|
644 |
|
}else { |
645 |
|
// ts = tp; |
646 |
|
// cs = cp; |
647 |
|
// os = op; |
648 |
// cout << "Warning - track image ambiguity not solved" << endl; |
// cout << "Warning - track image ambiguity not solved" << endl; |
649 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
650 |
}; |
}; |
651 |
|
|
652 |
}else{ |
}else{ |
653 |
ts = tp; |
// ts = tp; |
654 |
|
// cs = cp; |
655 |
|
// os = op; |
656 |
}; |
}; |
657 |
|
|
658 |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
659 |
sorted_tracks->Add(ts);//save the track in the sorted array |
// sorted_tracks->Add(ts);//save the track in the sorted array |
660 |
|
// sorted_tracks.Add(ts);//save the track in the sorted array |
661 |
|
// sorted_tracks.Add(tp);//save the track in the sorted array |
662 |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
663 |
|
// cout<<"o "<<tp<<endl; |
664 |
|
// cout<<"o "<<cp<<endl; |
665 |
|
// cout<<"o "<<op<<endl; |
666 |
|
new(ttsorted[i]) PamTrack(tp,cp,op); |
667 |
|
new(ttimage[i]) PamTrack(ti,ci,oi); |
668 |
}; |
}; |
669 |
|
|
670 |
|
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
671 |
|
cout << "void PamLevel2::SortTracks(TString how): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
672 |
|
tsorted->Delete(); tsorted=0; |
673 |
|
timage->Delete(); timage=0; |
674 |
|
} |
675 |
|
|
676 |
//Restore Object count |
//Restore Object count |
677 |
//To save space in the table keeping track of all referenced objects |
//To save space in the table keeping track of all referenced objects |
678 |
//we assume that our events do not address each other. We reset the |
//We reset the object count to what it was at the beginning of the event. |
|
//object count to what it was at the beginning of the event. |
|
679 |
TProcessID::SetObjectCount(ObjectNumber); |
TProcessID::SetObjectCount(ObjectNumber); |
680 |
|
|
681 |
}; |
}; |
687 |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
688 |
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
689 |
*/ |
*/ |
690 |
TRefArray *PamLevel2::GetTracks(){ |
// TRefArray *PamLevel2::GetTracks(){ |
691 |
|
|
692 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
693 |
|
// SortTracks("+CAL+TOF"); |
694 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
695 |
|
|
696 |
|
// // return sorted_tracks; |
697 |
|
// return &sorted_tracks; |
698 |
|
|
699 |
|
// }; |
700 |
|
TClonesArray *PamLevel2::GetTracks(){ |
701 |
|
|
702 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
703 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
704 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
705 |
|
|
706 |
return sorted_tracks; |
return tsorted; |
707 |
|
|
708 |
}; |
}; |
709 |
//-------------------------------------- |
//-------------------------------------- |
710 |
// |
// |
716 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
717 |
*/ |
*/ |
718 |
PamTrack *PamLevel2::GetTrack(int it){ |
PamTrack *PamLevel2::GetTrack(int it){ |
719 |
|
|
720 |
|
// if(!trk2_obj) return 0; |
721 |
|
|
722 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
723 |
|
// SortTracks("+CAL+TOF"); |
724 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
725 |
|
// // if(!sorted_tracks)return 0; |
726 |
|
// if(sorted_tracks.IsEmpty())return 0; |
727 |
|
|
728 |
|
// PamTrack *track = 0; |
729 |
|
|
730 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && it<sorted_tracks.GetEntriesFast() ){ |
731 |
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
732 |
|
// track = GetPamTrackAlong(t); |
733 |
|
// }else{ |
734 |
|
// cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
735 |
|
// }; |
736 |
|
|
737 |
|
// return track; |
738 |
|
|
739 |
|
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
740 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
741 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
742 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
743 |
|
if(!tsorted)return 0; |
744 |
|
if(!tsorted->GetEntries())return 0; |
745 |
|
|
746 |
PamTrack *track = 0; |
PamTrack *track = 0; |
747 |
|
|
748 |
if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){ |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks()){ |
749 |
TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); |
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
750 |
track = GetPamTrackAlong(t); |
// track = GetPamTrackAlong(t); |
751 |
|
TClonesArray &t = *(tsorted); |
752 |
|
track = (PamTrack*)t[it]; |
753 |
|
|
754 |
}else{ |
}else{ |
755 |
cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
756 |
}; |
}; |
757 |
|
|
758 |
return track; |
return track; |
769 |
*/ |
*/ |
770 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
PamTrack *PamLevel2::GetTrackImage(int it){ |
771 |
|
|
772 |
|
// if(!trk2_obj) return 0; |
773 |
|
|
774 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
775 |
|
// SortTracks("+CAL+TOF"); |
776 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
777 |
|
// // if(!sorted_tracks)return 0; |
778 |
|
// if(sorted_tracks.IsEmpty())return 0; |
779 |
|
|
780 |
|
// PamTrack *image = 0; |
781 |
|
|
782 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
783 |
|
// TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it); |
784 |
|
// if( temp->HasImage() ){ |
785 |
|
// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
786 |
|
// image = GetPamTrackAlong(t); |
787 |
|
// }else{ |
788 |
|
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
789 |
|
// }; |
790 |
|
// }else{ |
791 |
|
// cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
792 |
|
// }; |
793 |
|
|
794 |
|
// return image; |
795 |
|
|
796 |
|
|
797 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
798 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
799 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
800 |
|
if(!timage)return 0; |
801 |
|
if(!timage->GetEntries())return 0; |
802 |
|
|
803 |
PamTrack *image = 0; |
PamTrack *image = 0; |
804 |
|
|
805 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
806 |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
TClonesArray &t = *(tsorted); |
807 |
if( temp->HasImage() ){ |
PamTrack *temp = (PamTrack*)t[it]; |
808 |
TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
if( temp->GetTrkTrack()->HasImage() ){ |
809 |
image = GetPamTrackAlong(t); |
TClonesArray &t = *(timage); |
810 |
|
image = (PamTrack*)t[it]; |
811 |
}else{ |
}else{ |
812 |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
813 |
}; |
}; |
814 |
}else{ |
}else{ |
815 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
816 |
}; |
}; |
817 |
|
|
818 |
return image; |
return image; |
828 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
829 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
830 |
*/ |
*/ |
831 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ){ |
832 |
|
|
833 |
// cout << "WARNING!!! -- obsolete method -- \n"; |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
834 |
// cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
// else GetWhichTrees(f); |
835 |
|
|
836 |
|
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
837 |
|
|
838 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
|
TTree *Trout =0; |
|
839 |
|
|
840 |
|
TTree *Trout =0; |
841 |
|
|
842 |
TString fname = f->GetName(); |
TString fname = f->GetName(); |
843 |
if(!CheckLevel2File(fname))return NULL; |
if(!CheckLevel2File(fname))return NULL; |
844 |
|
|
845 |
|
// UInt_t *found=0; |
846 |
|
|
847 |
|
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
848 |
|
if(TRK1)cout<<"TRK1 "; |
849 |
|
if(TRK2)cout<<"TRK2 "; |
850 |
|
if(TRKh)cout<<"TRKH "; |
851 |
|
if(CAL1)cout<<"CAL1 "; |
852 |
|
if(CAL2)cout<<"CAL2 "; |
853 |
|
if(TOF)cout<<"TOF "; |
854 |
|
if(TRG)cout<<"TRG "; |
855 |
|
if(AC)cout<<"AC "; |
856 |
|
if(ND)cout<<"ND "; |
857 |
|
if(S4)cout<<"S4 "; |
858 |
|
if(ORB)cout<<"ORB "; |
859 |
|
cout << endl; |
860 |
|
if(SELLI)cout<<">>> Found selection-list <<<"<<endl; |
861 |
|
|
862 |
|
f->cd(); |
863 |
|
|
864 |
// Tracker |
// Tracker |
865 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
866 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
867 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
868 |
|
// else T->SetBranchStatus("TrkLevel2",0,found); |
869 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
870 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
871 |
|
// else T->SetBranchStatus("TrkLevel1",0,found); |
872 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
873 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
874 |
|
// else T->SetBranchStatus("TrkHough",0,found); |
875 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
876 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
877 |
else Trout->AddFriend(T); |
else Trout->AddFriend(T); |
882 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
TTree *C = (TTree*)f->Get("Calorimeter"); |
883 |
if(C && (CAL2||CAL1)) { |
if(C && (CAL2||CAL1)) { |
884 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
885 |
|
// else C->SetBranchStatus("CaloLevel2",0,found); |
886 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
887 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
888 |
|
// else C->SetBranchStatus("CaloLevel1",0,found); |
889 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
890 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
891 |
else Trout->AddFriend(C); |
else Trout->AddFriend(C); |
892 |
}else{ |
}else{ |
893 |
cout << "Calorimeter : missing tree"<<endl; |
cout << "Calorimeter : missing tree"<<endl; |
894 |
}; |
}; |
895 |
|
|
896 |
// ToF |
// ToF |
897 |
TTree *O = (TTree*)f->Get("ToF"); |
TTree *O = (TTree*)f->Get("ToF"); |
898 |
if(O && TOF) { |
if(O && TOF) { |
944 |
cout << "Anticounter : missing tree"<<endl; |
cout << "Anticounter : missing tree"<<endl; |
945 |
}; |
}; |
946 |
// Orbital Info |
// Orbital Info |
947 |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
948 |
if(B && ORB) { |
if(B && ORB) { |
949 |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
950 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
951 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
952 |
else Trout->AddFriend(B); |
else Trout->AddFriend(B); |
953 |
}else{ |
}else{ |
954 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
955 |
}; |
}; |
956 |
|
|
957 |
|
TTree *L = (TTree*)f->Get("SelectionList"); |
958 |
|
if(L && SELLI==1) { |
959 |
|
// L->SetBranchAddress("RunEntry",&irun); |
960 |
|
// cout << "SelectionList: set branch address RunEntry"<<endl; |
961 |
|
// L->SetBranchAddress("EventEntry",&irunentry); |
962 |
|
// cout << "SelectionList: set branch address EventEntry"<<endl; |
963 |
|
// if(!Trout)Trout=O; |
964 |
|
// else Trout->AddFriend("SelectionList"); |
965 |
|
cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemente!!!!"<<endl; |
966 |
|
sel_tree = 0; |
967 |
|
}else{ |
968 |
|
cout << "SelectionList : missing tree"<<endl; |
969 |
|
}; |
970 |
|
|
971 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
972 |
|
|
973 |
return Trout; |
pam_tree = (TChain*)Trout; |
974 |
|
|
975 |
|
return Trout; |
976 |
|
|
977 |
} |
} |
978 |
//-------------------------------------- |
//-------------------------------------- |
997 |
TList *contents = new TList; // create output list |
TList *contents = new TList; // create output list |
998 |
contents->SetOwner(); |
contents->SetOwner(); |
999 |
|
|
1000 |
char *fullpath; |
// char *fullpath; |
1001 |
|
// const char *fullpath; |
1002 |
|
|
1003 |
// if no input file list is given: |
// if no input file list is given: |
1004 |
if ( flisttxt != "" ){ |
if ( flisttxt != "" ){ |
1005 |
|
|
1006 |
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0; |
// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ |
1007 |
|
// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ |
1008 |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
// cout <<"File "<<flisttxt<<" not found"<<endl; |
1009 |
flisttxt = fullpath; |
// return 0; |
1010 |
|
// } |
1011 |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
// flisttxt = fullpath; |
1012 |
|
if ( !flisttxt.EndsWith(".root") ){ |
1013 |
|
|
1014 |
|
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1015 |
|
|
1016 |
|
if( !gSystem->ChangeDirectory(ddir) ){ |
1017 |
|
cout << "Cannot change directory : "<<ddir<<endl; |
1018 |
|
return 0; |
1019 |
|
} |
1020 |
|
|
1021 |
cout <<"Input file list : " << flisttxt <<endl; |
cout <<"Input file list : " << flisttxt <<endl; |
1022 |
ifstream in; |
ifstream in; |
1023 |
in.open(flisttxt, ios::in); //open input file list |
in.open(flisttxt, ios::in); //open input file list |
1024 |
|
if(!in.good()){ |
1025 |
|
cout <<" ERROR opening the file "<<endl; |
1026 |
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
1027 |
|
return 0; |
1028 |
|
} |
1029 |
int line=0; |
int line=0; |
1030 |
while (1) { |
while (1) { |
1031 |
TString file; |
TString file; |
1033 |
if (!in.good()) break; |
if (!in.good()) break; |
1034 |
line++; |
line++; |
1035 |
// cout <<"(1) " << file << endl; |
// cout <<"(1) " << file << endl; |
|
if(file.Contains("#"))file = file(0,file.First("#")); |
|
|
// cout <<"(2) " << file << endl; |
|
1036 |
if(file.IsNull()){ |
if(file.IsNull()){ |
1037 |
cout << "-- list interrupted at line "<<line <<endl; |
cout << "-- list interrupted at line "<<line <<endl; |
1038 |
break; |
break; |
1039 |
} |
} |
1040 |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
if(file.Contains("#"))file = file(0,file.First("#")); |
1041 |
|
// cout <<"(2) " << file << endl; |
1042 |
|
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
1043 |
|
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
1044 |
|
if( file.EndsWith(".root") ){ |
1045 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); |
1046 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1047 |
|
delete fullpath; |
1048 |
}else{ |
} |
1049 |
if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
// }else{ |
1050 |
}; |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
1051 |
|
// }; |
1052 |
}; |
}; |
1053 |
in.close(); |
in.close(); |
1054 |
|
} else { |
1055 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1056 |
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1057 |
|
delete fullpath; |
1058 |
|
}; |
1059 |
}else{ |
}else{ |
1060 |
|
|
1061 |
cout << "No input file list given."<<endl; |
cout << "No input file list given."<<endl; |
1074 |
while ( (questo = (TSystemFile*) next()) ) { |
while ( (questo = (TSystemFile*) next()) ) { |
1075 |
TString name = questo-> GetName(); |
TString name = questo-> GetName(); |
1076 |
if( name.EndsWith(".root") ){ |
if( name.EndsWith(".root") ){ |
1077 |
char *fullpath; |
// const char *fullpath = gSystem->FindFile(ddir,name); |
1078 |
gSystem->IsFileInIncludePath(name,&fullpath); |
// char *fullpath; |
1079 |
|
// gSystem->IsFileInIncludePath(name,&fullpath); |
1080 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name)); |
1081 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
1082 |
|
delete fullpath; |
1083 |
}; |
}; |
1084 |
} |
} |
1085 |
delete temp; |
delete temp; |
1089 |
gSystem->ChangeDirectory(wdir); // back to the working directory |
gSystem->ChangeDirectory(wdir); // back to the working directory |
1090 |
// cout << endl << "Selected files:" << endl; |
// cout << endl << "Selected files:" << endl; |
1091 |
// contents->Print(); |
// contents->Print(); |
1092 |
cout << contents->GetEntries()<<" files selected\n"; |
cout << contents->GetEntries()<<" files \n"; |
1093 |
// cout << endl; |
// cout << endl; |
1094 |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
1095 |
return contents; |
return contents; |
1104 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
1105 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
1106 |
*/ |
*/ |
1107 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
|
|
|
|
// TChain *Tout=0; |
|
|
// if(Tout)Tout->Delete(); |
|
|
// Tout = NULL; |
|
1108 |
|
|
1109 |
TChain *Tout =0; |
TChain *Trout =0; |
1110 |
|
|
1111 |
|
// if( !detlist.IsNull() )SetWhichTrees(detlist); |
1112 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
1113 |
|
|
1114 |
|
cout<< "GetPamTree(TList*,TString): input detector list --> "; |
1115 |
|
if(TRK1)cout<<"TRK1 "; |
1116 |
|
if(TRK2)cout<<"TRK2 "; |
1117 |
|
if(TRKh)cout<<"TRKH "; |
1118 |
|
if(CAL1)cout<<"CAL1 "; |
1119 |
|
if(CAL2)cout<<"CAL2 "; |
1120 |
|
if(TOF)cout<<"TOF "; |
1121 |
|
if(TRG)cout<<"TRG "; |
1122 |
|
if(AC)cout<<"AC "; |
1123 |
|
if(ND)cout<<"ND "; |
1124 |
|
if(S4)cout<<"S4 "; |
1125 |
|
if(ORB)cout<<"ORB "; |
1126 |
|
cout << endl; |
1127 |
|
|
1128 |
TChain *T = 0; |
TChain *T = 0; |
1129 |
TChain *C = 0; |
TChain *C = 0; |
1130 |
TChain *O = 0; |
TChain *O = 0; |
1133 |
TChain *N = 0; |
TChain *N = 0; |
1134 |
TChain *A = 0; |
TChain *A = 0; |
1135 |
TChain *B = 0; |
TChain *B = 0; |
1136 |
|
|
1137 |
|
TChain *L = 0; |
1138 |
|
|
1139 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
1140 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
1141 |
if(TOF) O = new TChain("ToF"); |
if(TOF) O = new TChain("ToF"); |
1142 |
if(TRG) R = new TChain("Trigger"); |
if(TRG) R = new TChain("Trigger"); |
1143 |
if(S4) S = new TChain("S4"); |
if(S4) S = new TChain("S4"); |
1144 |
if(ND) N = new TChain("NeutronD"); |
if(ND) N = new TChain("NeutronD"); |
1145 |
if(AC) A = new TChain("Anticounter"); |
if(AC) A = new TChain("Anticounter"); |
1146 |
if(ORB) B = new TChain("OrbitalInfo"); |
if(ORB) B = new TChain("OrbitalInfo"); |
1147 |
|
|
1148 |
|
L = new TChain("SelectionList"); |
1149 |
|
|
1150 |
// loop over files and create chains |
// loop over files and create chains |
1151 |
TIter next(fl); |
TIter next(fl); |
1152 |
TSystemFile *questo = 0; |
TSystemFile *questo = 0; |
1153 |
while ( (questo = (TSystemFile*) next()) ) { |
while ( (questo = (TSystemFile*) next()) ) { |
1154 |
TString name = questo->GetName(); |
TString name = questo->GetName(); |
1155 |
// cout << "File: "<< name << endl; |
cout << "File: "<< name << endl; |
1156 |
if( CheckLevel2File(name) ){ |
if( CheckLevel2File(name) ){ |
1157 |
if(TRK2||TRK1||TRKh) T->Add(name); |
if(TRK2||TRK1||TRKh) T->Add(name); |
1158 |
if(CAL1||CAL2) C->Add(name); |
if(CAL1||CAL2) C->Add(name); |
1159 |
if(TOF) O->Add(name); |
if(TOF) O->Add(name); |
1160 |
if(TRG) R->Add(name); |
if(TRG) R->Add(name); |
1161 |
if(S4) S->Add(name); |
if(S4) S->Add(name); |
1162 |
if(ND) N->Add(name); |
if(ND) N->Add(name); |
1163 |
if(AC) A->Add(name); |
if(AC) A->Add(name); |
1164 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
1165 |
|
if(SELLI==1) L->Add(name); |
1166 |
}; |
}; |
1167 |
} |
} |
1168 |
|
|
1169 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1170 |
|
|
1171 |
|
// UInt_t *found=0; |
1172 |
|
// Tracker |
1173 |
|
if(T && (TRK2||TRK1||TRKh)) { |
1174 |
|
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1175 |
|
// else T->SetBranchStatus("TrkLevel2",0,found); |
1176 |
|
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1177 |
|
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1178 |
|
// else T->SetBranchStatus("TrkLevel1",0,found); |
1179 |
|
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1180 |
|
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1181 |
|
// else T->SetBranchStatus("TrkHough",0,found); |
1182 |
|
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1183 |
|
if(!Trout)Trout=T; |
1184 |
|
else Trout->AddFriend("Tracker"); |
1185 |
|
}else{ |
1186 |
|
cout << "Tracker : missing tree"<<endl; |
1187 |
|
}; |
1188 |
// Calorimeter |
// Calorimeter |
1189 |
if(CAL2||CAL1) { |
if(C && (CAL2||CAL1)) { |
1190 |
if(!Tout)Tout=C; |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1191 |
else Tout->AddFriend("Calorimeter"); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1192 |
|
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1193 |
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1194 |
|
// else C->SetBranchStatus("CaloLevel1",0,found); |
1195 |
|
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1196 |
|
if(!Trout)Trout=C; |
1197 |
|
else Trout->AddFriend("Calorimeter"); |
1198 |
|
}else{ |
1199 |
|
cout << "Calorimeter : missing tree"<<endl; |
1200 |
}; |
}; |
1201 |
// ToF |
// ToF |
1202 |
if(TOF) { |
if(O && TOF) { |
1203 |
if(!Tout)Tout=O; |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1204 |
else Tout->AddFriend("ToF"); |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1205 |
|
if(!Trout)Trout=O; |
1206 |
|
else Trout->AddFriend("ToF"); |
1207 |
|
}else{ |
1208 |
|
cout << "ToF : missing tree"<<endl; |
1209 |
}; |
}; |
|
// Tracker |
|
|
if(TRK2||TRK1||TRKh){ |
|
|
if(!Tout)Tout=T; |
|
|
else Tout->AddFriend("Tracker"); |
|
|
} |
|
1210 |
// Trigger |
// Trigger |
1211 |
if(TRG) { |
if(R && TRG) { |
1212 |
if(!Tout)Tout=R; |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1213 |
else Tout->AddFriend("Trigger"); |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1214 |
|
if(!Trout)Trout=O; |
1215 |
|
else Trout->AddFriend("Trigger"); |
1216 |
|
}else{ |
1217 |
|
cout << "Trigger : missing tree"<<endl; |
1218 |
}; |
}; |
1219 |
// S4 |
// S4 |
1220 |
if(S4) { |
if(S && S4) { |
1221 |
if(!Tout)Tout=S; |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1222 |
else Tout->AddFriend("S4"); |
cout << "S4 : set branch address S4Level2"<<endl; |
1223 |
|
if(!Trout)Trout=O; |
1224 |
|
else Trout->AddFriend("S4"); |
1225 |
|
}else{ |
1226 |
|
cout << "S4 : missing tree"<<endl; |
1227 |
}; |
}; |
1228 |
// Neutron Detector |
// Neutron Detector |
1229 |
if(ND) { |
if(N && ND) { |
1230 |
if(!Tout)Tout=N; |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1231 |
else Tout->AddFriend("NeutronD"); |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1232 |
|
if(!Trout)Trout=O; |
1233 |
|
else Trout->AddFriend("NeutronD"); |
1234 |
|
}else{ |
1235 |
|
cout << "NeutronD : missing tree"<<endl; |
1236 |
}; |
}; |
1237 |
// Anticounters |
// Anticounters |
1238 |
if(AC) { |
if(A && AC) { |
1239 |
if(!Tout)Tout=A; |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1240 |
else Tout->AddFriend("Anticounter"); |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1241 |
|
if(!Trout)Trout=O; |
1242 |
|
else Trout->AddFriend("Anticounter"); |
1243 |
|
}else{ |
1244 |
|
cout << "Anticounter : missing tree"<<endl; |
1245 |
}; |
}; |
1246 |
// OrbitalInfo |
// Orbital Info |
1247 |
if(ORB) { |
if(B && ORB) { |
1248 |
if(!Tout)Tout=B; |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1249 |
else Tout->AddFriend("OrbitalInfo"); |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1250 |
|
if(!Trout)Trout=O; |
1251 |
|
else Trout->AddFriend("OrbitalInfo"); |
1252 |
|
}else{ |
1253 |
|
cout << "OrbitalInfo : missing tree"<<endl; |
1254 |
|
}; |
1255 |
|
|
1256 |
|
// Selection List |
1257 |
|
if(L && SELLI==1) { |
1258 |
|
cout<<">>> Found selection-list <<<"<<endl; |
1259 |
|
L->SetBranchAddress("RunEntry",&irun); |
1260 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1261 |
|
L->SetBranchAddress("EventEntry",&irunentry); |
1262 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1263 |
|
sel_tree = L; |
1264 |
|
// if(!Trout)Trout=O; |
1265 |
|
// else Trout->AddFriend("SelectionList"); |
1266 |
|
}else{ |
1267 |
|
// cout << "SelectionList : missing tree"<<endl; |
1268 |
|
if(L)L->Delete(); |
1269 |
}; |
}; |
1270 |
|
|
1271 |
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1272 |
|
|
1273 |
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress(); |
pam_tree = Trout; |
1274 |
if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
|
1275 |
|
return Trout; |
|
return Tout; |
|
1276 |
} |
} |
1277 |
|
|
1278 |
|
|
1353 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1354 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1355 |
}; |
}; |
1356 |
|
// SelectionList |
1357 |
|
if(SELLI==1) { |
1358 |
|
t->SetBranchAddress("RunEntry", &irun); |
1359 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1360 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1361 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1362 |
|
}; |
1363 |
|
|
1364 |
} |
} |
1365 |
/** |
/** |
1381 |
|
|
1382 |
// Tracker |
// Tracker |
1383 |
if(TRK2) { |
if(TRK2) { |
1384 |
t->SetBranchAddress("TrkLevel2", this->GetPointerTo("TrkLevel2")); |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1385 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
1386 |
}; |
}; |
1387 |
if(TRK1) { |
if(TRK1) { |
1433 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1434 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1435 |
}; |
}; |
1436 |
|
// SelectionList |
1437 |
|
if(SELLI==1) { |
1438 |
|
t->SetBranchAddress("RunEntry", &irun); |
1439 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1440 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1441 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1442 |
|
}; |
1443 |
|
|
1444 |
} |
} |
1445 |
|
|
|
// void* PamLevel2::GetPointerToTrk() {return &trk2_obj;}; |
|
|
// void* PamLevel2::GetPointerToTrk(int s){ |
|
|
// switch (s) { |
|
|
// case 1: return &trk1_obj; |
|
|
// case 2: return &trk2_obj; |
|
|
// case 3: return &trkh_obj; |
|
|
// default: return 0; |
|
|
// }; |
|
|
// }; |
|
|
// void* PamLevel2::GetPointerToCalo() {return &calo2_obj; }; |
|
|
// void* GetPointerToCalo(int s){ |
|
|
// switch (s) { |
|
|
// case 1: return &calo1_obj; |
|
|
// case 2: return &calo2_obj; |
|
|
// default: return 0; |
|
|
// }; |
|
|
// }; |
|
|
// void* GetPointerToToF() {return &tof_obj; }; |
|
|
// void* GetPointerTo("TrigLevel2") {return &trig_obj; }; |
|
|
// void* GetPointerTo("S4Level2") {return &s4_obj; }; |
|
|
// void* GetPointerTo("NDLevel2") {return &nd_obj; }; |
|
|
// void* GetPointerTo("AcLevel2") {return &ac_obj; }; |
|
|
// void* GetPointerTo("OrbitalInfo") {return &orb_obj; }; |
|
|
// void* GetPointerTo("RunInfo") {return &run_obj; }; |
|
1446 |
|
|
1447 |
//-------------------------------------- |
//-------------------------------------- |
1448 |
// |
// |
1467 |
R->Add(name); |
R->Add(name); |
1468 |
}; |
}; |
1469 |
} |
} |
1470 |
|
|
1471 |
|
if(R->GetNtrees()){ |
1472 |
|
|
1473 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1474 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1475 |
|
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1476 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1477 |
|
}else{ |
1478 |
|
delete R; |
1479 |
|
R=0; |
1480 |
|
} |
1481 |
|
|
1482 |
|
run_tree = R; |
1483 |
|
|
1484 |
return R; |
return R; |
1485 |
|
|
1486 |
} |
} |
1495 |
*/ |
*/ |
1496 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
TTree *PamLevel2::GetRunTree(TFile *f){ |
1497 |
|
|
1498 |
|
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
1499 |
|
|
1500 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *R = (TTree*)f->Get("Run"); |
1501 |
|
|
1502 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
if(R){ |
1503 |
cout << "Run : set branch address RunInfo"<<endl; |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1504 |
|
cout << "Run : set branch address RunInfo"<<endl; |
1505 |
|
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1506 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1507 |
|
} |
1508 |
|
|
1509 |
|
run_tree = (TChain*)R; |
1510 |
|
|
1511 |
return R; |
return R; |
1512 |
|
|
1513 |
} |
} |
1514 |
|
/** |
1515 |
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
1516 |
|
* @param run Pointer to the chain/tree which contains run infos |
1517 |
|
* @return true if a new run has been read, false if it is still the same run |
1518 |
|
*/ |
1519 |
|
Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){ |
1520 |
|
// |
1521 |
|
// check if we have already called once GetEntry, if not call it |
1522 |
|
// |
1523 |
|
if ( run->GetEntries() <= 0 ) return(false); |
1524 |
|
// |
1525 |
|
|
1526 |
|
Int_t oldrun = irun; |
1527 |
|
// -------------------------------------- |
1528 |
|
// if it is a full file (not preselected) |
1529 |
|
// -------------------------------------- |
1530 |
|
if(SELLI==0){ |
1531 |
|
if ( irun < 0 ){ |
1532 |
|
irun = 0; |
1533 |
|
run->GetEntry(irun); |
1534 |
|
runfirstentry = 0ULL; |
1535 |
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; |
1536 |
|
return(true); |
1537 |
|
}; |
1538 |
|
|
1539 |
|
if( !GetOrbitalInfo() ){ |
1540 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1541 |
|
return(false); |
1542 |
|
} |
1543 |
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
1544 |
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
1545 |
|
while ( GetOrbitalInfo()->absTime > GetRunInfo()->RUNTRAILER_TIME && irun < run->GetEntries() ){ |
1546 |
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
1547 |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
1548 |
|
irun++; |
1549 |
|
run->GetEntry(irun); |
1550 |
|
runfirstentry = runlastentry+1ULL; |
1551 |
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
1552 |
|
}; |
1553 |
|
|
1554 |
|
// |
1555 |
|
if |
1556 |
|
( irun == oldrun || irun >= run->GetEntries() ) return(false); |
1557 |
|
// |
1558 |
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
1559 |
|
// |
1560 |
|
return(true); |
1561 |
|
}; |
1562 |
|
// ---------------------------------------------------- |
1563 |
|
// if it is a preselected file (there is SelectionList) |
1564 |
|
// NBNB - the event tree MUST be read first |
1565 |
|
// ---------------------------------------------------- |
1566 |
|
if(SELLI==1){ |
1567 |
|
sel_tree->GetEntry(iev); |
1568 |
|
if(irun != oldrun){ |
1569 |
|
run->GetEntry(irun); |
1570 |
|
return true; |
1571 |
|
} |
1572 |
|
return false; |
1573 |
|
} |
1574 |
|
|
1575 |
|
return false; |
1576 |
|
// |
1577 |
|
}; |
1578 |
|
/** |
1579 |
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
1580 |
|
* @param run Pointer to the chain/tree which contains run infos |
1581 |
|
* @return true if a new run has been read, false if it is still the same run |
1582 |
|
*/ |
1583 |
|
Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ |
1584 |
|
return(UpdateRunInfo((TChain*)run,iev)); |
1585 |
|
}; |
1586 |
|
|
1587 |
//-------------------------------------- |
//-------------------------------------- |
1588 |
// |
// |
1589 |
// |
// |
1594 |
*/ |
*/ |
1595 |
void PamLevel2::SetWhichTrees(TString detlist){ |
void PamLevel2::SetWhichTrees(TString detlist){ |
1596 |
|
|
1597 |
if(detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
1598 |
|
CAL0 = false; |
1599 |
CAL1 = true; |
CAL1 = true; |
1600 |
CAL2 = true; |
CAL2 = true; |
1601 |
TRK2 = true; |
TRK2 = true; |
1602 |
TRK1 = false; |
TRK1 = false; |
1603 |
TRKh = false; |
TRKh = false; |
1604 |
|
TRK0 = false; |
1605 |
TRG = true; |
TRG = true; |
1606 |
TOF = true; |
TOF = true; |
1607 |
|
TOF0 = false; |
1608 |
S4 = true; |
S4 = true; |
1609 |
ND = true; |
ND = true; |
1610 |
AC = true; |
AC = true; |
1611 |
ORB = true; |
ORB = true; |
1612 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
1613 |
|
CAL0 = false; |
1614 |
CAL1 = false; |
CAL1 = false; |
1615 |
CAL2 = false; |
CAL2 = false; |
1616 |
TRK2 = false; |
TRK2 = false; |
1617 |
TRK1 = false; |
TRK1 = false; |
1618 |
TRKh = false; |
TRKh = false; |
1619 |
|
TRK0 = false; |
1620 |
TRG = false; |
TRG = false; |
1621 |
TOF = false; |
TOF = false; |
1622 |
|
TOF0 = false; |
1623 |
S4 = false; |
S4 = false; |
1624 |
ND = false; |
ND = false; |
1625 |
AC = false; |
AC = false; |
1631 |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
1632 |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
1633 |
}; |
}; |
1634 |
|
|
1635 |
|
if( detlist.Contains("CAL0", TString::kIgnoreCase) ){ |
1636 |
|
if ( detlist.Contains("-CAL0", TString::kIgnoreCase) )CAL0=false; |
1637 |
|
if ( detlist.Contains("+CAL0", TString::kIgnoreCase) )CAL0=true; |
1638 |
|
}; |
1639 |
|
|
1640 |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
1641 |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
1648 |
CAL1=false; |
CAL1=false; |
1649 |
} |
} |
1650 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
1651 |
|
if( detlist.Contains("TRK0", TString::kIgnoreCase) ){ |
1652 |
|
if ( detlist.Contains("-TRK0", TString::kIgnoreCase) )TRK0=false; |
1653 |
|
if ( detlist.Contains("+TRK0", TString::kIgnoreCase) )TRK0=true; |
1654 |
|
}; |
1655 |
|
|
1656 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
1657 |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
1658 |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
1675 |
TRKh=false; |
TRKh=false; |
1676 |
} |
} |
1677 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
// if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK2 = false; |
|
|
// else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK2 = true; |
|
|
|
|
|
// if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1 = false; |
|
|
// else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1 = true; |
|
|
|
|
|
// if( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh = false; |
|
|
// else if( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh = true; |
|
1678 |
|
|
1679 |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
1680 |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
1681 |
|
|
1682 |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
1683 |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
1684 |
|
|
1685 |
|
if( detlist.Contains("-TOF0", TString::kIgnoreCase) )TOF0 = false; |
1686 |
|
else if( detlist.Contains("+TOF0", TString::kIgnoreCase) )TOF0 = true; |
1687 |
|
|
1688 |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
1689 |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
1696 |
|
|
1697 |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
1698 |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
1699 |
|
|
1700 |
|
// cout<< "Set detector list --> "; |
1701 |
|
// if(TRK1)cout<<"TRK1 "; |
1702 |
|
// if(TRK2)cout<<"TRK2 "; |
1703 |
|
// if(TRKh)cout<<"TRKH "; |
1704 |
|
// if(CAL1)cout<<"CAL1 "; |
1705 |
|
// if(CAL2)cout<<"CAL2 "; |
1706 |
|
// if(TOF)cout<<"TOF "; |
1707 |
|
// if(TRG)cout<<"TRG "; |
1708 |
|
// if(AC)cout<<"AC "; |
1709 |
|
// if(ND)cout<<"ND "; |
1710 |
|
// if(S4)cout<<"S4 "; |
1711 |
|
// if(ORB)cout<<"ORB "; |
1712 |
|
// cout << endl; |
1713 |
|
|
1714 |
}; |
}; |
1715 |
|
|
1716 |
|
|
1717 |
|
/** |
1718 |
|
* Set tree/branch detector flags from the content of a tree |
1719 |
|
*/ |
1720 |
|
void PamLevel2::GetWhichTrees(TFile* f){ |
1721 |
|
|
1722 |
|
|
1723 |
|
|
1724 |
|
cout << "void PamLevel2::GetWhichTrees(TFile* f) --- WARNING!! --- ...potrebbe non funzionare "<<endl; |
1725 |
|
// ----------- |
1726 |
|
// reset flags |
1727 |
|
// ----------- |
1728 |
|
CAL1 = false; |
1729 |
|
CAL2 = false; |
1730 |
|
TRK2 = false; |
1731 |
|
TRK1 = false; |
1732 |
|
TRKh = false; |
1733 |
|
TRG = false; |
1734 |
|
TOF = false; |
1735 |
|
S4 = false; |
1736 |
|
ND = false; |
1737 |
|
AC = false; |
1738 |
|
ORB = false; |
1739 |
|
|
1740 |
|
RUN = false; |
1741 |
|
|
1742 |
|
cout << "Checking file: "<<f->GetName()<<endl; |
1743 |
|
if( !f || f->IsZombie() ){ |
1744 |
|
cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; |
1745 |
|
return; |
1746 |
|
} |
1747 |
|
|
1748 |
|
TList *lk = f->GetListOfKeys(); |
1749 |
|
TIter next(lk); |
1750 |
|
TKey *key =0; |
1751 |
|
|
1752 |
|
Int_t nev = 0; |
1753 |
|
|
1754 |
|
while( (key = (TKey*)next()) ){ |
1755 |
|
|
1756 |
|
if( !strcmp(key->GetName(),"Run" ) )RUN = true; |
1757 |
|
|
1758 |
|
//========================================================= |
1759 |
|
if( !strcmp(key->GetName(),"Trigger" ) ){ |
1760 |
|
TRG = true; |
1761 |
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
1762 |
|
if( nev && nevt!=nev){ |
1763 |
|
cout << "File: "<< f->GetName() <<" Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
1764 |
|
TRG = false; |
1765 |
|
}else nev=nevt; |
1766 |
|
} |
1767 |
|
//========================================================= |
1768 |
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
1769 |
|
TOF = true; |
1770 |
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
1771 |
|
if( nev && nevt!=nev){ |
1772 |
|
cout << "File: "<< f->GetName() <<" ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
1773 |
|
TOF = false; |
1774 |
|
}else nev=nevt; |
1775 |
|
} |
1776 |
|
//========================================================= |
1777 |
|
if( !strcmp(key->GetName(),"S4" ) ){ |
1778 |
|
S4 = true; |
1779 |
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
1780 |
|
if( nev && nevt!=nev){ |
1781 |
|
cout << "File: "<< f->GetName() <<" S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
1782 |
|
S4 = false; |
1783 |
|
}else nev=nevt; |
1784 |
|
} |
1785 |
|
//========================================================= |
1786 |
|
|
1787 |
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
1788 |
|
ND = true; |
1789 |
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
1790 |
|
if( nev && nevt!=nev){ |
1791 |
|
cout << "File: "<< f->GetName() <<"NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
1792 |
|
ND =false; |
1793 |
|
}else nev=nevt; |
1794 |
|
} |
1795 |
|
//========================================================= |
1796 |
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
1797 |
|
AC = true; |
1798 |
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
1799 |
|
if( nev && nevt!=nev){ |
1800 |
|
cout << "File: "<< f->GetName() <<" Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1801 |
|
AC =false; |
1802 |
|
}else nev=nevt; |
1803 |
|
} |
1804 |
|
//========================================================= |
1805 |
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
1806 |
|
ORB = true; |
1807 |
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
1808 |
|
if( nev && nevt!=nev){ |
1809 |
|
cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
1810 |
|
ORB = false; |
1811 |
|
}else nev=nevt; |
1812 |
|
} |
1813 |
|
//========================================================= |
1814 |
|
if( !strcmp(key->GetName(),"Tracker" ) ){ |
1815 |
|
TTree *T = (TTree*)f->Get("Tracker"); |
1816 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1817 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1818 |
|
if( !name.CompareTo("TrkLevel1") )TRK1=true; |
1819 |
|
if( !name.CompareTo("TrkLevel2") )TRK2=true; |
1820 |
|
if( !name.CompareTo("TrkHough") )TRKh=true; |
1821 |
|
}; |
1822 |
|
Int_t nevt = T->GetEntries(); |
1823 |
|
if( nev && nevt!=nev){ |
1824 |
|
cout << "File: "<< f->GetName() <<" Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
1825 |
|
TRK1 = false; |
1826 |
|
TRK2 = false; |
1827 |
|
TRKh = false; |
1828 |
|
}else nev=nevt; |
1829 |
|
T->Delete(); |
1830 |
|
}; |
1831 |
|
//========================================================= |
1832 |
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
1833 |
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
1834 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1835 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1836 |
|
if( !name.CompareTo("CaloLevel1") )CAL1=true; |
1837 |
|
if( !name.CompareTo("CaloLevel2") )CAL2=true; |
1838 |
|
}; |
1839 |
|
Int_t nevt = T->GetEntries(); |
1840 |
|
if( nev && nevt!=nev){ |
1841 |
|
cout << "File: "<< f->GetName() <<" Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1842 |
|
CAL1 = false; |
1843 |
|
CAL2 = false; |
1844 |
|
}else nev=nevt; |
1845 |
|
T->Delete(); |
1846 |
|
}; |
1847 |
|
|
1848 |
|
}; |
1849 |
|
|
1850 |
|
delete lk; |
1851 |
|
|
1852 |
|
// cout<< "Get detector list from input file --> "; |
1853 |
|
// if(TRK1)cout<<"TRK1 "; |
1854 |
|
// if(TRK2)cout<<"TRK2 "; |
1855 |
|
// if(TRKh)cout<<"TRKH "; |
1856 |
|
// if(CAL1)cout<<"CAL1 "; |
1857 |
|
// if(CAL2)cout<<"CAL2 "; |
1858 |
|
// if(TOF)cout<<"TOF "; |
1859 |
|
// if(TRG)cout<<"TRG "; |
1860 |
|
// if(AC)cout<<"AC "; |
1861 |
|
// if(ND)cout<<"ND "; |
1862 |
|
// if(S4)cout<<"S4 "; |
1863 |
|
// if(ORB)cout<<"ORB "; |
1864 |
|
// cout << endl; |
1865 |
|
|
1866 |
|
return ; |
1867 |
|
|
1868 |
|
}; |
1869 |
|
|
1870 |
|
|
1871 |
//-------------------------------------- |
//-------------------------------------- |
1872 |
// |
// |
1873 |
// |
// |
1893 |
|
|
1894 |
Bool_t RUN__ok = false; |
Bool_t RUN__ok = false; |
1895 |
|
|
1896 |
|
Bool_t SELLI__ok = false; |
1897 |
|
|
1898 |
cout << "Checking file: "<<name<<endl; |
cout << "Checking file: "<<name<<endl; |
1899 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
1911 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
1912 |
|
|
1913 |
// cout << key->GetName() << endl; |
// cout << key->GetName() << endl; |
1914 |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
1915 |
|
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
1916 |
// nev_previous = nev; |
// nev_previous = nev; |
1917 |
// cout << " n.entries "<< nev <<endl; |
// cout << " n.entries "<< nev <<endl; |
1918 |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
1921 |
// return false; |
// return false; |
1922 |
// }; |
// }; |
1923 |
|
|
1924 |
|
|
1925 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
1926 |
|
|
1927 |
//========================================================= |
//========================================================= |
1928 |
|
if( !strcmp(key->GetName(),"SelectionList" ) ){ |
1929 |
|
SELLI__ok = true; |
1930 |
|
if(SELLI==1){ |
1931 |
|
Int_t nevt = ((TTree*)f->Get("SelectionList"))->GetEntries(); |
1932 |
|
if( nev && nevt!=nev){ |
1933 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList tree has "<<nevt<<" events instead of "<<nev<< endl; |
1934 |
|
return false; |
1935 |
|
} |
1936 |
|
nev=nevt; |
1937 |
|
} |
1938 |
|
} |
1939 |
|
|
1940 |
|
//========================================================= |
1941 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
1942 |
TRG__ok = true; |
TRG__ok = true; |
1943 |
if(TRG){ |
if(TRG){ |
2049 |
}; |
}; |
2050 |
|
|
2051 |
}; |
}; |
2052 |
|
|
2053 |
|
if( SELLI==-1 )SELLI = (Int_t)SELLI__ok; |
2054 |
|
if( SELLI==0 && SELLI__ok ){ |
2055 |
|
cout << "File: "<< f->GetName() <<" discarded ---- found SelectionList (it is not a full-event file)" << endl; |
2056 |
|
return false; |
2057 |
|
} |
2058 |
|
if( SELLI==1 && !SELLI__ok ){ |
2059 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList missing" << endl; |
2060 |
|
return false; |
2061 |
|
} |
2062 |
|
|
2063 |
|
// cout << "SELLI "<<SELLI<<endl; |
2064 |
|
|
2065 |
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
2066 |
|
// if(TRK1__ok)cout<<"TRK1 "; |
2067 |
|
// if(TRK2__ok)cout<<"TRK2 "; |
2068 |
|
// if(TRKh__ok)cout<<"TRKH "; |
2069 |
|
// if(CAL1__ok)cout<<"CAL1 "; |
2070 |
|
// if(CAL2__ok)cout<<"CAL2 "; |
2071 |
|
// if(TOF__ok)cout<<"TOF "; |
2072 |
|
// if(TRG__ok)cout<<"TRG "; |
2073 |
|
// if(AC__ok)cout<<"AC "; |
2074 |
|
// if(ND__ok)cout<<"ND "; |
2075 |
|
// if(S4__ok)cout<<"S4 "; |
2076 |
|
// if(ORB__ok)cout<<"ORB "; |
2077 |
|
// cout << endl; |
2078 |
|
|
2079 |
|
|
2080 |
|
if(TRK2 && TRK1__ok)TRK1=1; |
2081 |
|
// ---------------------------------------------------------------------------- |
2082 |
|
// NOTA |
2083 |
|
// se c'e` il level1, lo devo necessarimente leggere. |
2084 |
|
// infatti (non ho capito perche`) i cluster vengono letti e allocati in memoria |
2085 |
|
// comunque, ma non vengono disallocati da PamLevel2::Clear() |
2086 |
|
// ---------------------------------------------------------------------------- |
2087 |
|
|
2088 |
|
|
2089 |
if(!RUN__ok) { |
if(!RUN__ok) { |
2128 |
return false; |
return false; |
2129 |
}; |
}; |
2130 |
|
|
2131 |
if(ND && !ND__ok){ |
if(ND && !ND__ok){ |
2132 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
2133 |
return false; |
return false; |
2134 |
}; |
}; |
2135 |
if(TRG && !TRG__ok){ |
if(TRG && !TRG__ok){ |
2136 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
2137 |
return false; |
return false; |
2138 |
}; |
}; |
2139 |
|
|
|
|
|
|
|
|
|
|
|
2140 |
|
|
2141 |
lk->Delete(); |
// lk->Delete(); |
2142 |
|
// delete lk; |
2143 |
f->Close(); |
f->Close(); |
2144 |
|
|
2145 |
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
2146 |
|
// if(TRK1)cout<<"TRK1 "; |
2147 |
|
// if(TRK2)cout<<"TRK2 "; |
2148 |
|
// if(TRKh)cout<<"TRKH "; |
2149 |
|
// if(CAL1)cout<<"CAL1 "; |
2150 |
|
// if(CAL2)cout<<"CAL2 "; |
2151 |
|
// if(TOF)cout<<"TOF "; |
2152 |
|
// if(TRG)cout<<"TRG "; |
2153 |
|
// if(AC)cout<<"AC "; |
2154 |
|
// if(ND)cout<<"ND "; |
2155 |
|
// if(S4)cout<<"S4 "; |
2156 |
|
// if(ORB)cout<<"ORB "; |
2157 |
|
// cout << endl; |
2158 |
|
|
2159 |
return true; |
return true; |
2160 |
|
|
2164 |
/** |
/** |
2165 |
* Create clone-trees |
* Create clone-trees |
2166 |
*/ |
*/ |
2167 |
void PamLevel2::CreateCloneTrees( TChain *fChain ){ |
void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ |
2168 |
|
|
2169 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2170 |
cout << "Create clones of PAMELA trees "<<endl; |
cout << "Create clones of PAMELA trees "<<endl; |
2171 |
|
|
2172 |
Int_t i=0; |
Int_t i=0; |
2173 |
tree_clone[i] = fChain->GetTree()->CloneTree(0); |
pam_tree_clone[i] = fChain->GetTree()->CloneTree(0); |
2174 |
TString name = tree_clone[i]->GetName(); |
TString name = pam_tree_clone[i]->GetName(); |
2175 |
name.Append("_clone"); |
name.Append("_clone"); |
2176 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2177 |
cout << tree_clone[i]->GetName() <<endl; |
cout << pam_tree_clone[i]->GetName() <<endl; |
2178 |
i++; |
i++; |
2179 |
|
|
2180 |
TList *li = fChain->GetListOfFriends(); |
TList *li = fChain->GetListOfFriends(); |
2181 |
TIter next(li); |
TIter next(li); |
2182 |
TFriendElement* T_friend=0; |
TFriendElement* T_friend=0; |
2183 |
|
ofile->cd(); |
2184 |
while( (T_friend = (TFriendElement*)next()) ){ |
while( (T_friend = (TFriendElement*)next()) ){ |
2185 |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
2186 |
// cout<<T_friend->GetTree()->GetName()<< endl; |
// cout<<T_friend->GetTree()->GetName()<< endl; |
2187 |
tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
pam_tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
2188 |
name = tree_clone[i]->GetName(); |
pam_tree_clone[i]->SetAutoSave(1000000); |
2189 |
|
name = pam_tree_clone[i]->GetName(); |
2190 |
name.Append("_clone"); |
name.Append("_clone"); |
2191 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2192 |
cout << tree_clone[i]->GetName() << endl; |
cout << pam_tree_clone[i]->GetName() << endl; |
2193 |
i++; |
i++; |
2194 |
} |
} |
2195 |
|
|
2196 |
|
delete li; |
2197 |
|
|
2198 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2199 |
|
|
2200 |
} |
} |
2201 |
|
|
2202 |
// /** |
/** |
2203 |
// * Create clone-trees |
* Create clone-trees |
2204 |
// */ |
*/ |
2205 |
// void PamLevel2::CreateCloneTrees(){ |
void PamLevel2::CreateCloneTrees(TFile *ofile){ |
2206 |
|
|
2207 |
|
ofile->cd(); |
2208 |
|
|
2209 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2210 |
// cout << "Create new PAMELA trees "<<endl; |
cout << "Create new PAMELA trees "<<endl; |
2211 |
|
|
|
// if(TRK1||TRK2||TRKh){ |
|
|
// T_clone = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
|
|
// if(TRK1) { |
|
|
// trk1_clone = new TrkLevel1(); |
|
|
// T_clone->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
|
|
// T_clone->BranchRef(); |
|
|
// cout << "Tracker : branch TrkLevel1"<<endl; |
|
|
// }; |
|
|
// if(TRK2) { |
|
|
// trk2_clone = new TrkLevel2(); |
|
|
// T_clone->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
|
|
// cout << "Tracker : branch TrkLevel2"<<endl; |
|
|
// }; |
|
|
// if(TRKh) { |
|
|
// trkh_clone = new TrkHough(); |
|
|
// T_clone->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
|
|
// cout << "Tracker : branch TrkHough"<<endl; |
|
|
// }; |
|
|
// cout << hex << T_clone << dec << endl; |
|
|
// } |
|
2212 |
|
|
2213 |
// // Calorimeter |
run_tree_clone = new TTree("Run","PAMELA Level2 data from the GL_RUN table "); |
2214 |
// if(CAL1||CAL2){ |
run_tree_clone->Branch("RunInfo","GL_RUN",GetPointerTo("RunInfo")); |
2215 |
// C_clone = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
cout << "Run : branch RunInfo"<<endl; |
2216 |
// if(CAL1) { |
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
2217 |
// calo1_clone = new CaloLevel1(); |
cout << "Run : branch SoftInfo"<<endl; |
2218 |
// C_clone->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
|
|
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
|
|
// }; |
|
|
// if(CAL2) { |
|
|
// calo2_clone = new CaloLevel2(); |
|
|
// C_clone->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
|
|
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
|
|
// }; |
|
|
// } |
|
2219 |
|
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// O_clone = new TTree("ToF_clone","PAMELA ToF level2 data "); |
|
|
// tof_clone = new ToFLevel2(); |
|
|
// O_clone->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
|
|
// cout << "ToF : branch ToFLevel2"<<endl; |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// R_clone = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
|
|
// trig_clone = new TrigLevel2(); |
|
|
// R_clone->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
|
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// S_clone = new TTree("S4_clone","PAMELA S4 level2 data "); |
|
|
// s4_clone = new S4Level2(); |
|
|
// S_clone->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
|
|
// cout << "S4 : branch S4Level2"<<endl; |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// N_clone = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
|
|
// nd_clone = new NDLevel2(); |
|
|
// N_clone->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
|
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// A_clone = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
|
|
// ac_clone = new AcLevel2(); |
|
|
// A_clone->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
|
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// B_clone = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
|
|
// orb_clone = new OrbitalInfo(); |
|
|
// B_clone->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
|
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
|
|
// }; |
|
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
|
2220 |
|
|
2221 |
// } |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
2222 |
|
sel_tree_clone->Branch("RunEntry",&irun,"runentry/I"); |
2223 |
|
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/I"); |
2224 |
|
|
2225 |
|
|
2226 |
// /** |
Int_t i=0; |
2227 |
// * Create clone-trees |
if(TRK1||TRK2||TRKh){ |
2228 |
// */ |
pam_tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
2229 |
// void PamLevel2::CreateCloneTrees(){ |
if(TRK1) { |
2230 |
|
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2231 |
|
pam_tree_clone[i]->BranchRef(); |
2232 |
|
cout << "Tracker : branch TrkLevel1"<<endl; |
2233 |
|
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2234 |
|
}; |
2235 |
|
if(TRK2) { |
2236 |
|
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2237 |
|
cout << "Tracker : branch TrkLevel2"<<endl; |
2238 |
|
}; |
2239 |
|
if(TRKh) { |
2240 |
|
pam_tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
2241 |
|
cout << "Tracker : branch TrkHough"<<endl; |
2242 |
|
}; |
2243 |
|
i++; |
2244 |
|
} |
2245 |
|
|
2246 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
// Calorimeter |
2247 |
// cout << "Create new PAMELA trees "<<endl; |
if(CAL1||CAL2){ |
2248 |
|
pam_tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
2249 |
// if(TRK1||TRK2||TRKh){ |
if(CAL1) { |
2250 |
// T_clone = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
pam_tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
2251 |
// if(TRK1) { |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
2252 |
// trk1_clone = new TrkLevel1(); |
}; |
2253 |
// T_clone->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
if(CAL2) { |
2254 |
// T_clone->BranchRef(); |
pam_tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
2255 |
// cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
2256 |
// }; |
}; |
2257 |
// if(TRK2) { |
i++; |
2258 |
// trk2_clone = new TrkLevel2(); |
} |
|
// T_clone->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
|
|
// cout << "Tracker : branch TrkLevel2"<<endl; |
|
|
// }; |
|
|
// if(TRKh) { |
|
|
// trkh_clone = new TrkHough(); |
|
|
// T_clone->Branch("TrkHough","TrkHough", &trkh_clone); |
|
|
// cout << "Tracker : branch TrkHough"<<endl; |
|
|
// }; |
|
|
// cout << hex << T_clone << dec << endl; |
|
|
// } |
|
2259 |
|
|
2260 |
// // Calorimeter |
// ToF |
2261 |
// if(CAL1||CAL2){ |
if(TOF) { |
2262 |
// C_clone = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
pam_tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
2263 |
// if(CAL1) { |
pam_tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
2264 |
// calo1_clone = new CaloLevel1(); |
cout << "ToF : branch ToFLevel2"<<endl; |
2265 |
// C_clone->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
i++; |
2266 |
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
}; |
2267 |
// }; |
// Trigger |
2268 |
// if(CAL2) { |
if(TRG) { |
2269 |
// calo2_clone = new CaloLevel2(); |
pam_tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
2270 |
// C_clone->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
pam_tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
2271 |
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
cout << "Trigger : branch TrigLevel2"<<endl; |
2272 |
// }; |
i++; |
2273 |
// } |
}; |
2274 |
|
// S4 |
2275 |
|
if(S4) { |
2276 |
|
pam_tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
2277 |
|
pam_tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
2278 |
|
cout << "S4 : branch S4Level2"<<endl; |
2279 |
|
i++; |
2280 |
|
}; |
2281 |
|
// Neutron Detector |
2282 |
|
if(ND) { |
2283 |
|
pam_tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
2284 |
|
pam_tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
2285 |
|
cout << "NeutronD : branch NDLevel2"<<endl; |
2286 |
|
i++; |
2287 |
|
}; |
2288 |
|
// Anticounters |
2289 |
|
if(AC) { |
2290 |
|
pam_tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
2291 |
|
pam_tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
2292 |
|
cout << "Anticounter : branch AcLevel2"<<endl; |
2293 |
|
i++; |
2294 |
|
}; |
2295 |
|
// OrbitalInfo |
2296 |
|
if(ORB) { |
2297 |
|
pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
2298 |
|
pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
2299 |
|
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
2300 |
|
i++; |
2301 |
|
}; |
2302 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2303 |
|
|
2304 |
// // ToF |
} |
|
// if(TOF) { |
|
|
// O_clone = new TTree("ToF_clone","PAMELA ToF level2 data "); |
|
|
// tof_clone = new ToFLevel2(); |
|
|
// O_clone->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
|
|
// cout << "ToF : branch ToFLevel2"<<endl; |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// R_clone = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
|
|
// trig_clone = new TrigLevel2(); |
|
|
// R_clone->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
|
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// S_clone = new TTree("S4_clone","PAMELA S4 level2 data "); |
|
|
// s4_clone = new S4Level2(); |
|
|
// S_clone->Branch("S4Level2","S4Level2", &s4_clone); |
|
|
// cout << "S4 : branch S4Level2"<<endl; |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// N_clone = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
|
|
// nd_clone = new NDLevel2(); |
|
|
// N_clone->Branch("NDLevel2","NDLevel2", &nd_clone); |
|
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// A_clone = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
|
|
// ac_clone = new AcLevel2(); |
|
|
// A_clone->Branch("AcLevel2","AcLevel2", &ac_clone); |
|
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// B_clone = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
|
|
// orb_clone = new OrbitalInfo(); |
|
|
// B_clone->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
|
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
|
|
// }; |
|
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
|
2305 |
|
|
|
// } |
|
2306 |
|
|
2307 |
/** |
/** |
2308 |
* Fill tree (created with CreateCloneTrees) |
* Fill tree (created with CreateCloneTrees) |
2310 |
*/ |
*/ |
2311 |
//void PamLevel2::FillNewPamTree(TTree *T){ |
//void PamLevel2::FillNewPamTree(TTree *T){ |
2312 |
void PamLevel2::FillCloneTrees(){ |
void PamLevel2::FillCloneTrees(){ |
2313 |
|
|
2314 |
// // -------------------------------------- |
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
|
// // copy the event |
|
|
// // -------------------------------------- |
|
|
// if(trk1_clone) *trk1_clone = *trk1_obj; |
|
|
// if(trk2_clone){ |
|
|
// trk2_clone->Clear(); |
|
|
// trk2_obj->Copy(*trk2_clone); |
|
|
// // *trk2_clone = *trk2_obj; |
|
|
// } |
|
|
// if(trkh_clone) *trkh_clone = *trkh_obj; |
|
|
// if(calo1_clone){ |
|
|
// // *calo1_clone = *calo1_obj; |
|
|
// calo1_clone->Clear(); |
|
|
// calo1_obj->Copy(*calo1_clone); |
|
|
// } |
|
|
// if(calo2_clone){ |
|
|
// // *calo2_clone = *calo2_obj; |
|
|
// calo2_clone->Clear(); |
|
|
// calo2_obj->Copy(*calo2_clone); |
|
|
// } |
|
|
// if(tof_clone) *tof_clone = *tof_obj; |
|
|
// if(trig_clone) *trig_clone = *trig_obj; |
|
|
// if(s4_clone) *s4_clone = *s4_obj; |
|
|
// if(nd_clone) *nd_clone = *nd_obj; |
|
|
// if(ac_clone) *ac_clone = *ac_obj; |
|
|
// if(orb_clone) *orb_clone = *orb_obj; |
|
|
|
|
|
// if(T_clone)T_clone->Fill(); |
|
|
// if(C_clone)C_clone->Fill(); |
|
|
// if(O_clone)O_clone->Fill(); |
|
|
// if(R_clone)R_clone->Fill(); |
|
|
// if(S_clone)S_clone->Fill(); |
|
|
// if(N_clone)N_clone->Fill(); |
|
|
// if(A_clone)A_clone->Fill(); |
|
|
// if(O_clone)O_clone->Fill(); |
|
2315 |
|
|
2316 |
for(Int_t i=0; i<8; i++){ |
for(Int_t i=0; i<NCLONES; i++){ |
2317 |
if(tree_clone[i])tree_clone[i]->Fill(); |
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
2318 |
} |
} |
2319 |
|
if(sel_tree_clone)sel_tree_clone->Fill(); |
2320 |
|
|
2321 |
} |
} |
2322 |
|
|
2323 |
|
|
2324 |
TTree* PamLevel2::GetCloneTree(TString name){ |
TTree* PamLevel2::GetCloneTree(TString name){ |
2325 |
|
|
2326 |
for(Int_t i=0; i<8; i++){ |
for(Int_t i=0; i<NCLONES; i++){ |
2327 |
if(tree_clone[i]){ |
if(pam_tree_clone[i]){ |
2328 |
TString na = tree_clone[i]->GetName(); |
TString na = pam_tree_clone[i]->GetName(); |
2329 |
if(!name.CompareTo(na))return tree_clone[i]; |
if(!name.CompareTo(na))return pam_tree_clone[i]; |
2330 |
}; |
}; |
2331 |
} |
} |
2332 |
|
if(run_tree_clone){ |
2333 |
|
TString na = run_tree_clone->GetName(); |
2334 |
|
if(!name.CompareTo(na))return run_tree_clone; |
2335 |
|
} |
2336 |
|
if(sel_tree_clone){ |
2337 |
|
TString na = sel_tree_clone->GetName(); |
2338 |
|
if(!name.CompareTo(na))return sel_tree_clone; |
2339 |
|
} |
2340 |
return NULL; |
return NULL; |
2341 |
|
|
2342 |
} |
} |
2343 |
void PamLevel2::WriteCloneTrees(){ |
void PamLevel2::WriteCloneTrees(){ |
2344 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2345 |
cout << "Write clones of PAMELA trees "<<endl; |
cout << "Write clones of PAMELA trees "<<endl; |
2346 |
for(Int_t i=0; i<8; i++){ |
cout << run_tree_clone->GetName()<<endl; |
2347 |
if(tree_clone[i]){ |
run_tree_clone->Write(); |
2348 |
cout << tree_clone[i]->GetName()<<endl; |
cout << sel_tree_clone->GetName()<<endl; |
2349 |
tree_clone[i]->Write(); |
sel_tree_clone->Write(); |
2350 |
|
for(Int_t i=0; i<NCLONES; i++){ |
2351 |
|
if(pam_tree_clone[i]){ |
2352 |
|
cout << pam_tree_clone[i]->GetName()<<endl; |
2353 |
|
pam_tree_clone[i]->Write(); |
2354 |
}; |
}; |
2355 |
} |
} |
2356 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2358 |
} |
} |
2359 |
|
|
2360 |
/** |
/** |
2361 |
* Create a new (empty) Pamela trees |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
2362 |
|
*/ |
2363 |
|
Int_t PamLevel2::GetEntry(Int_t iee){ |
2364 |
|
|
2365 |
|
if(!pam_tree){ |
2366 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
2367 |
|
return 0; |
2368 |
|
} |
2369 |
|
|
2370 |
|
|
2371 |
|
// |
2372 |
|
// 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... |
2373 |
|
// |
2374 |
|
// if(!run_tree ){ |
2375 |
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; |
2376 |
|
// return 0; |
2377 |
|
// } |
2378 |
|
|
2379 |
|
Int_t ii=0; |
2380 |
|
//------------------------------- |
2381 |
|
ii = iee; |
2382 |
|
if( !pam_tree->GetEntry(ii) ) return 0; |
2383 |
|
|
2384 |
|
// |
2385 |
|
// ... 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. |
2386 |
|
// 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 |
2387 |
|
// a problem if you don't check the return code of getentry. |
2388 |
|
// |
2389 |
|
if(!run_tree ){ |
2390 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
2391 |
|
return 0; |
2392 |
|
} |
2393 |
|
|
2394 |
|
//------------------------------- |
2395 |
|
ii = iee; |
2396 |
|
Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2397 |
|
if(SELLI==0)irunentry = iee-runfirstentry; |
2398 |
|
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2399 |
|
|
2400 |
|
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2401 |
|
|
2402 |
|
if( TRK0 || CAL0 || TOF0 )GetYodaEntry( ); |
2403 |
|
|
2404 |
|
return 1; |
2405 |
|
|
2406 |
|
} |
2407 |
|
|
2408 |
|
/** |
2409 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
2410 |
|
* Given the run ID (...), if needed it query the DB and load the proper file. |
2411 |
|
* @return Pointer to the tree |
2412 |
*/ |
*/ |
|
// TTree* PamLevel2::GetNewPamTree(){ |
|
2413 |
|
|
|
// if(tree_clone)return tree_clone; |
|
2414 |
|
|
2415 |
// TTree *Tout = 0; |
TTree* PamLevel2::GetYodaTree( ){ |
2416 |
|
|
2417 |
|
// cout << "TTree* PamLevel2::GetYodaTree( )"<<endl; |
2418 |
|
//=================================== |
2419 |
|
// check if iroot has changed |
2420 |
|
//=================================== |
2421 |
|
if( irun<0 ){ |
2422 |
|
cout << "PamLevel2::GetYodaTree() -- ERROR "<<endl; |
2423 |
|
cout << "In order to use this method you have to load the RunInfo tree "<<endl; |
2424 |
|
cout << "with the method TChain* PamLevel2::GetRunTree(TString, TString)"<<endl; |
2425 |
|
// cout << " - read the event with PamLevel2::GetEntry(Int_t)"<<endl; |
2426 |
|
return NULL; |
2427 |
|
} |
2428 |
|
Int_t irootnew = run_obj->ID_ROOT_L0; |
2429 |
|
// cout << "iroot "<<iroot<<endl; |
2430 |
|
// cout << "irootnew "<<irootnew<<endl; |
2431 |
|
|
2432 |
|
//=================================== |
2433 |
|
// load the level0 file |
2434 |
|
// (if not already loaded) |
2435 |
|
//=================================== |
2436 |
|
if( iroot != irootnew || !l0_tree){ |
2437 |
|
iroot = irootnew; |
2438 |
|
//=================================== |
2439 |
|
// open the DB connection |
2440 |
|
// (if not already opened) |
2441 |
|
//=================================== |
2442 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2443 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2444 |
|
cout<<"Connecting to DB"<<endl; |
2445 |
|
cout<<"HOST "<<host<<endl; |
2446 |
|
cout<<"USER "<<user<<endl; |
2447 |
|
cout<<"PSW "<<psw<<endl; |
2448 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
2449 |
|
if( !dbc )return NULL; |
2450 |
|
if( !dbc->IsConnected() )return NULL; |
2451 |
|
// cout<<"...done"<<endl; |
2452 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2453 |
|
}else{ |
2454 |
|
// cout<<"DB already connected"<<endl; |
2455 |
|
} |
2456 |
|
GL_ROOT glroot = GL_ROOT(); |
2457 |
|
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
2458 |
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
2459 |
|
return NULL; |
2460 |
|
}; |
2461 |
|
TString filename = glroot.PATH + glroot.NAME; |
2462 |
|
if(l0_file){ |
2463 |
|
l0_file->Close(); |
2464 |
|
l0_file->Delete(); |
2465 |
|
} |
2466 |
|
cout << "Opening LEVEL0 file: "<< filename << endl; |
2467 |
|
FileStat_t t; |
2468 |
|
if( gSystem->GetPathInfo(filename.Data(),t) ){ |
2469 |
|
cout << " PamLevel2::GetYodaTree() -- ERROR opening file "<<endl; |
2470 |
|
return NULL; |
2471 |
|
} |
2472 |
|
l0_file = new TFile(filename); |
2473 |
|
if( !l0_file )return NULL; |
2474 |
|
l0_tree = (TTree*)l0_file->Get("Physics"); |
2475 |
|
if(!h0_obj)h0_obj = new EventHeader(); |
2476 |
|
l0_tree->SetBranchAddress("Header" ,&h0_obj); |
2477 |
|
//--------------------------------------------------- |
2478 |
|
// TRACKER: |
2479 |
|
if(TRK0){ |
2480 |
|
if(!trk0_obj){ |
2481 |
|
trk0_obj = new TrkLevel0(); |
2482 |
|
trk0_obj->Set(); |
2483 |
|
}; |
2484 |
|
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
2485 |
|
} |
2486 |
|
//--------------------------------------------------- |
2487 |
|
// CALORIMETER: |
2488 |
|
if(CAL0){ |
2489 |
|
cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
2490 |
|
} |
2491 |
|
//--------------------------------------------------- |
2492 |
|
// TOF: |
2493 |
|
if(TOF0){ |
2494 |
|
cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl; |
2495 |
|
} |
2496 |
|
|
2497 |
|
}; |
2498 |
|
|
2499 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2500 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
2501 |
|
} |
2502 |
|
|
2503 |
|
TrkParams::SetCalib(run_obj,dbc); |
2504 |
|
|
2505 |
|
|
2506 |
|
// cout << l0_tree << endl; |
2507 |
|
|
2508 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
return l0_tree; |
2509 |
// cout << "Create new PAMELA trees "<<endl; |
|
2510 |
|
} |
2511 |
|
|
2512 |
|
/** |
2513 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
2514 |
|
*/ |
2515 |
|
Int_t PamLevel2::GetYodaEntry(){ |
2516 |
|
|
2517 |
|
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
2518 |
|
if(!GetYodaTree())return 0; |
2519 |
|
|
2520 |
|
// patch |
2521 |
|
if( (Int_t)irunentry < 0){ |
2522 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
2523 |
|
irunentry=0; |
2524 |
|
} |
2525 |
|
// --------------------------------- |
2526 |
|
// if file is NOT a preselected file |
2527 |
|
// --------------------------------- |
2528 |
|
UInt_t quellagiusta = irunentry + run_obj->EV_FROM; |
2529 |
|
|
|
// if(TRK1||TRK2||TRKh){ |
|
|
// TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
|
|
// if(TRK1) { |
|
|
// trk1_clone = new TrkLevel1(); |
|
|
// T->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
|
|
// T->BranchRef(); |
|
|
// cout << "Tracker : branch TrkLevel1"<<endl; |
|
|
// }; |
|
|
// if(TRK2) { |
|
|
// trk2_clone = new TrkLevel2(); |
|
|
// T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
|
|
// cout << "Tracker : branch TrkLevel2"<<endl; |
|
|
// }; |
|
|
// if(TRKh) { |
|
|
// trkh_clone = new TrkHough(); |
|
|
// T->Branch("TrkHough","TrkHough", &trkh_clone); |
|
|
// cout << "Tracker : branch TrkHough"<<endl; |
|
|
// }; |
|
|
// if(!Tout)Tout=T; |
|
|
// else Tout->AddFriend("Tracker_clone"); |
|
|
// } |
|
|
|
|
|
// // Calorimeter |
|
|
// if(CAL1||CAL2){ |
|
|
// TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
|
|
// if(CAL1) { |
|
|
// calo1_clone = new CaloLevel1(); |
|
|
// C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
|
|
// }; |
|
|
// if(CAL2) { |
|
|
// calo2_clone = new CaloLevel2(); |
|
|
// C->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
|
|
// }; |
|
|
// if(!Tout)Tout=C; |
|
|
// else Tout->AddFriend("Calorimeter_clone"); |
|
|
// } |
|
|
|
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data "); |
|
|
// tof_clone = new ToFLevel2(); |
|
|
// O->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
|
|
// cout << "ToF : branch ToFLevel2"<<endl; |
|
|
// if(!Tout)Tout=O; |
|
|
// else Tout->AddFriend("ToF_clone"); |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
|
|
// trig_clone = new TrigLevel2(); |
|
|
// R->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
|
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
|
|
// if(!Tout)Tout=R; |
|
|
// else Tout->AddFriend("Trigger_clone"); |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// TTree *S = new TTree("S4_clone","PAMELA S4 level2 data "); |
|
|
// s4_clone = new S4Level2(); |
|
|
// S->Branch("S4Level2","S4Level2", &s4_clone); |
|
|
// cout << "S4 : branch S4Level2"<<endl; |
|
|
// if(!Tout)Tout=S; |
|
|
// else Tout->AddFriend("S4_clone"); |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
|
|
// nd_clone = new NDLevel2(); |
|
|
// N->Branch("NDLevel2","NDLevel2", &nd_clone); |
|
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
|
|
// if(!Tout)Tout=N; |
|
|
// else Tout->AddFriend("NeutronD_clone"); |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
|
|
// ac_clone = new AcLevel2(); |
|
|
// A->Branch("AcLevel2","AcLevel2", &ac_clone); |
|
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
|
|
// if(!Tout)Tout=A; |
|
|
// else Tout->AddFriend("Anticounter_clone"); |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
|
|
// orb_clone = new OrbitalInfo(); |
|
|
// B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
|
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
|
|
// if(!Tout)Tout=B; |
|
|
// else Tout->AddFriend("OrbitalInfo_clone"); |
|
|
// }; |
|
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
|
2530 |
|
|
2531 |
// tree_clone = Tout; |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
2532 |
// tree_clone->SetDirectory(0); |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
2533 |
|
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
2534 |
|
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
2535 |
|
|
2536 |
|
if( !GetOrbitalInfo() ){ |
2537 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
2538 |
|
return 0; |
2539 |
|
} |
2540 |
|
|
2541 |
// return Tout; |
// --------------------------------------------------------------------- |
2542 |
// } |
// ATTENTION!!! |
2543 |
// /** |
// If data are not pre-processed with cleaner, the level0 tree may contain |
2544 |
// * Fill a tree (created with GetNewPamTree) |
// spurious nested physics packets. |
2545 |
// * |
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
2546 |
// */ |
// while level2 tree DOES NOT!! |
2547 |
// //void PamLevel2::FillNewPamTree(TTree *T){ |
// This means that "quellagiusta" in these cases is not correct. |
2548 |
// void PamLevel2::FillNewPamTree(){ |
// In order to retrieve the correct level0 event, I implemented a check |
2549 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
2550 |
|
// is shift forward until when the packets match. |
2551 |
|
// --------------------------------------------------------------------- |
2552 |
|
Int_t answer = 0; |
2553 |
|
Int_t shift =0; |
2554 |
|
do{ |
2555 |
|
if(shift>0){ |
2556 |
|
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl; |
2557 |
|
} |
2558 |
|
answer = l0_tree->GetEntry(quellagiusta+shift); |
2559 |
|
shift++; |
2560 |
|
if( !GetEventHeader() ){ |
2561 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
2562 |
|
return 0; |
2563 |
|
} |
2564 |
|
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
2565 |
|
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
2566 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
2567 |
|
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
2568 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
2569 |
|
|
2570 |
// if(trk1_clone) *trk1_clone = *trk1_obj; |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < GetYodaTree()->GetEntries() ); |
|
// if(trk2_clone){ |
|
|
// trk2_clone->Clear(); |
|
|
// trk2_obj->Copy(*trk2_clone); |
|
|
// // *trk2_clone = *trk2_obj; |
|
|
// } |
|
|
// if(trkh_clone) *trkh_clone = *trkh_obj; |
|
|
// if(calo1_clone){ |
|
|
// // *calo1_clone = *calo1_obj; |
|
|
// calo1_clone->Clear(); |
|
|
// calo1_obj->Copy(*calo1_clone); |
|
|
// } |
|
|
// if(calo2_clone){ |
|
|
// // *calo2_clone = *calo2_obj; |
|
|
// calo2_clone->Clear(); |
|
|
// calo2_obj->Copy(*calo2_clone); |
|
|
// } |
|
|
// if(tof_clone) *tof_clone = *tof_obj; |
|
|
// if(trig_clone) *trig_clone = *trig_obj; |
|
|
// if(s4_clone) *s4_clone = *s4_obj; |
|
|
// if(nd_clone) *nd_clone = *nd_obj; |
|
|
// if(ac_clone) *ac_clone = *ac_obj; |
|
|
// if(orb_clone) *orb_clone = *orb_obj; |
|
|
|
|
|
// TTree *T = tree_clone; |
|
|
|
|
|
// T->Fill(); //fill main tree |
|
|
// // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl; |
|
|
// TList *li = T->GetListOfFriends(); |
|
|
// TIter next(li); |
|
|
// TFriendElement* T_friend=0; |
|
|
// while( (T_friend = (TFriendElement*)next()) ){ |
|
|
// // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
|
|
// T_friend->GetTree()->Fill();//fill friends |
|
|
// } |
|
2571 |
|
|
2572 |
// } |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
2573 |
|
// return GetYodaTree()->GetEntry(quellagiusta); |
2574 |
|
|
2575 |
|
return answer; |
2576 |
|
|
2577 |
|
} |