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 |
trk_l1_obj = this->TrkLevel1::GetTrkLevel1(); |
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
93 |
trk_obj = this->TrkLevel2::GetTrkLevel2(); |
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
94 |
calo_obj = this->CaloLevel2::GetCaloLevel2(); |
// trkh_obj = TrkHough::GetTrkHough(); |
95 |
tof_obj = this->ToFLevel2::GetToFLevel2(); |
// calo1_obj = CaloLevel1::GetCaloLevel1(); |
96 |
trig_obj = this->TrigLevel2::GetTrigLevel2(); |
// calo2_obj = CaloLevel2::GetCaloLevel2(); |
97 |
s4_obj = this->S4Level2::GetS4Level2(); |
// tof_obj = ToFLevel2::GetToFLevel2(); |
98 |
nd_obj = this->NDLevel2::GetNDLevel2(); |
// trig_obj = TrigLevel2::GetTrigLevel2(); |
99 |
ac_obj = this->AcLevel2::GetAcLevel2(); |
// s4_obj = S4Level2::GetS4Level2(); |
100 |
orb_obj = this->OrbitalInfo::GetOrbitalInfo(); |
// nd_obj = NDLevel2::GetNDLevel2(); |
101 |
|
// ac_obj = AcLevel2::GetAcLevel2(); |
102 |
run_obj = new GL_RUN(); |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
103 |
|
trk2_obj = 0; |
104 |
sorted_tracks = new TRefArray(); |
trk1_obj = 0; |
105 |
|
trkh_obj = 0; |
106 |
CAL = true; |
calo1_obj = 0; |
107 |
TRK = true; |
calo2_obj = 0; |
108 |
|
tof_obj = 0; |
109 |
|
trig_obj = 0; |
110 |
|
s4_obj = 0; |
111 |
|
nd_obj = 0; |
112 |
|
ac_obj = 0; |
113 |
|
orb_obj = 0; |
114 |
|
|
115 |
|
run_obj = 0;//new GL_RUN(); |
116 |
|
|
117 |
|
|
118 |
|
for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; |
119 |
|
|
120 |
|
// sorted_tracks = 0;//new TRefArray(); |
121 |
|
|
122 |
|
CAL1 = true; |
123 |
|
CAL2 = true; |
124 |
|
TRK2 = true; |
125 |
|
TRK1 = false; |
126 |
|
TRKh = false; |
127 |
TRG = true; |
TRG = true; |
128 |
TOF = true; |
TOF = true; |
129 |
S4 = true; |
S4 = true; |
131 |
AC = true; |
AC = true; |
132 |
ORB = true; |
ORB = true; |
133 |
|
|
134 |
TRK_L1 = false; |
RUN = true; |
135 |
|
|
136 |
Tout = NULL; |
tsorted=0; |
137 |
|
timage=0; |
138 |
|
|
139 |
}; |
}; |
140 |
/** |
/** |
141 |
* Destructor |
* Delete the event (act as Dtor) |
142 |
*/ |
*/ |
143 |
PamLevel2::~PamLevel2(){ |
void PamLevel2::Delete(){ |
|
|
|
|
TrkLevel1::Clear(); |
|
|
|
|
|
TrkLevel2::Clear(); |
|
|
CaloLevel2::Clear(); |
|
|
ToFLevel2::Clear(); |
|
|
TrigLevel2::Clear(); |
|
|
S4Level2::Clear(); |
|
|
NDLevel2::Clear(); |
|
|
AcLevel2::Clear(); |
|
|
OrbitalInfo::Clear(); |
|
|
|
|
|
delete run_obj; |
|
|
|
|
|
// delete sorted_tracks; |
|
|
sorted_tracks->Delete(); // clean the reference array |
|
|
|
|
|
if(Tout)Tout->Delete(); // delete loaded tree from memory |
|
144 |
|
|
145 |
|
if(run_obj)delete run_obj; |
146 |
|
|
147 |
|
// cout << "void PamLevel2::Clear()"<<endl; |
148 |
|
if(trk1_obj) delete trk1_obj; |
149 |
|
if(trk2_obj) delete trk2_obj; |
150 |
|
if(trkh_obj) delete trkh_obj; |
151 |
|
if(calo1_obj)delete calo1_obj; |
152 |
|
if(calo2_obj)delete calo2_obj; |
153 |
|
if(tof_obj) delete tof_obj; |
154 |
|
if(trig_obj) delete trig_obj; |
155 |
|
if(s4_obj) delete s4_obj; |
156 |
|
if(nd_obj) delete nd_obj; |
157 |
|
if(ac_obj) delete ac_obj; |
158 |
|
if(orb_obj) delete orb_obj; |
159 |
|
|
160 |
|
if(tsorted){ |
161 |
|
tsorted->Delete(); |
162 |
|
delete tsorted; |
163 |
|
} |
164 |
|
if(timage){ |
165 |
|
timage->Delete(); |
166 |
|
delete timage; |
167 |
|
} |
168 |
}; |
}; |
169 |
|
|
170 |
/** |
/** |
171 |
* Clear the event |
* Clear the event (NB! does not deallocate objects) |
172 |
*/ |
*/ |
173 |
void PamLevel2::Clear(){ |
void PamLevel2::Clear(){ |
174 |
|
|
175 |
TrkLevel1::Clear(); |
// cout << "void PamLevel2::Clear()"<<endl; |
176 |
|
if(run_obj)delete run_obj; |
177 |
TrkLevel2::Clear(); |
|
178 |
CaloLevel2::Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
179 |
ToFLevel2::Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
180 |
TrigLevel2::Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
181 |
S4Level2::Clear(); |
if(calo1_obj)calo1_obj->Clear(); |
182 |
NDLevel2::Clear(); |
if(calo2_obj)calo2_obj->Clear(); |
183 |
AcLevel2::Clear(); |
if(tof_obj) tof_obj->Clear(); |
184 |
OrbitalInfo::Clear(); |
if(trig_obj) trig_obj->Clear(); |
185 |
|
if(s4_obj) s4_obj->Clear(); |
186 |
|
if(nd_obj) nd_obj->Clear(); |
187 |
|
if(ac_obj) ac_obj->Clear(); |
188 |
|
if(orb_obj) orb_obj->Clear(); |
189 |
|
|
190 |
sorted_tracks->Delete(); // clean the reference array |
// if(sorted_tracks)sorted_tracks->Clear(); |
191 |
|
// sorted_tracks.Clear(); |
192 |
|
|
193 |
|
if(tsorted){ |
194 |
|
tsorted->Delete(); |
195 |
|
} |
196 |
|
if(timage){ |
197 |
|
timage->Delete(); |
198 |
|
} |
199 |
|
|
200 |
}; |
}; |
201 |
|
|
204 |
// |
// |
205 |
// |
// |
206 |
//-------------------------------------- |
//-------------------------------------- |
207 |
|
void *PamLevel2::GetPointerTo(const char* c ){ |
208 |
|
|
209 |
|
TString objname = c; |
210 |
|
|
211 |
|
if(!objname.CompareTo("TrkLevel1")) { |
212 |
|
if(!trk1_obj) trk1_obj = new TrkLevel1(); |
213 |
|
return &trk1_obj; |
214 |
|
}; |
215 |
|
if(!objname.CompareTo("TrkLevel2")) { |
216 |
|
if(!trk2_obj) trk2_obj = new TrkLevel2(); |
217 |
|
return &trk2_obj; |
218 |
|
}; |
219 |
|
if(!objname.CompareTo("TrkHough")) { |
220 |
|
if(!trkh_obj) trkh_obj = new TrkHough(); |
221 |
|
return &trkh_obj; |
222 |
|
}; |
223 |
|
if(!objname.CompareTo("CaloLevel1")) { |
224 |
|
if(!calo1_obj) calo1_obj = new CaloLevel1(); |
225 |
|
return &calo1_obj; |
226 |
|
}; |
227 |
|
if(!objname.CompareTo("CaloLevel2")) { |
228 |
|
if(!calo2_obj) calo2_obj = new CaloLevel2(); |
229 |
|
return &calo2_obj; |
230 |
|
}; |
231 |
|
if(!objname.CompareTo("ToFLevel2")) { |
232 |
|
if(!tof_obj) tof_obj = new ToFLevel2(); |
233 |
|
return &tof_obj; |
234 |
|
}; |
235 |
|
if(!objname.CompareTo("TrigLevel2")) { |
236 |
|
if(!trig_obj) trig_obj = new TrigLevel2(); |
237 |
|
return &trig_obj; |
238 |
|
}; |
239 |
|
if(!objname.CompareTo("S4Level2")) { |
240 |
|
if(!s4_obj) s4_obj = new S4Level2(); |
241 |
|
return &s4_obj; |
242 |
|
}; |
243 |
|
if(!objname.CompareTo("NDLevel2")) { |
244 |
|
if(!nd_obj) nd_obj = new NDLevel2(); |
245 |
|
return &nd_obj; |
246 |
|
}; |
247 |
|
if(!objname.CompareTo("AcLevel2")) { |
248 |
|
if(!ac_obj) ac_obj = new AcLevel2(); |
249 |
|
return &ac_obj; |
250 |
|
}; |
251 |
|
if(!objname.CompareTo("OrbitalInfo")){ |
252 |
|
if(!orb_obj) orb_obj = new OrbitalInfo(); |
253 |
|
return &orb_obj; |
254 |
|
}; |
255 |
|
|
256 |
|
if(!objname.CompareTo("RunInfo"))return &run_obj; |
257 |
|
return NULL; |
258 |
|
}; |
259 |
|
//-------------------------------------- |
260 |
|
// |
261 |
|
// |
262 |
|
//-------------------------------------- |
263 |
/** |
/** |
264 |
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
265 |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
266 |
*/ |
*/ |
267 |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
268 |
|
|
269 |
if( CaloLevel2::ntrk()==0 ){ |
if( !calo2_obj )return 0; |
270 |
|
|
271 |
|
if( calo2_obj->CaloLevel2::ntrk()==0 ){ |
272 |
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; |
273 |
return NULL; |
return NULL; |
274 |
}; |
}; |
277 |
Int_t it_calo=0; |
Int_t it_calo=0; |
278 |
|
|
279 |
do{ |
do{ |
280 |
c = CaloLevel2::GetCaloTrkVar(it_calo); |
c = calo2_obj->CaloLevel2::GetCaloTrkVar(it_calo); |
281 |
it_calo++; |
it_calo++; |
282 |
} while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_calo < calo2_obj->CaloLevel2::ntrk()); |
283 |
|
|
284 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
285 |
c = 0; |
c = 0; |
298 |
*/ |
*/ |
299 |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
300 |
|
|
301 |
if( ToFLevel2::ntrk()==0 ){ |
if( !tof_obj )return 0; |
302 |
|
|
303 |
|
if( tof_obj->ToFLevel2::ntrk()==0 ){ |
304 |
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; |
305 |
return NULL; |
return NULL; |
306 |
}; |
}; |
309 |
Int_t it_tof=0; |
Int_t it_tof=0; |
310 |
|
|
311 |
do{ |
do{ |
312 |
c = ToFLevel2::GetToFTrkVar(it_tof); |
c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); |
313 |
it_tof++; |
it_tof++; |
314 |
} while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); |
315 |
|
|
316 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
317 |
c = 0; |
c = 0; |
329 |
* 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. |
330 |
*/ |
*/ |
331 |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
332 |
|
|
333 |
|
cout <<"PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** "<<endl; |
334 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
335 |
|
|
336 |
CaloTrkVar *c = 0; |
CaloTrkVar *c = 0; |
337 |
ToFTrkVar *o = 0; |
ToFTrkVar *o = 0; |
338 |
|
|
339 |
if(CAL) c = GetCaloStoredTrack(t->GetSeqNo()); |
if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo()); |
340 |
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
341 |
|
|
342 |
// if(t && c && o)track = new PamTrack(t,c,o); |
// if(t && c && o)track = new PamTrack(t,c,o); |
357 |
|
|
358 |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
359 |
|
|
360 |
|
cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl; |
361 |
|
cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl; |
362 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
363 |
PamTrack *track = 0; |
PamTrack *track = 0; |
364 |
|
|
365 |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
if( itrk >=0 && itrk < trk2_obj->TrkLevel2::ntrk() ){ |
366 |
|
|
367 |
TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); |
TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); |
368 |
track = GetPamTrackAlong(t); |
track = GetPamTrackAlong(t); |
369 |
|
|
370 |
|
|
371 |
|
|
372 |
}else{ |
}else{ |
373 |
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; |
374 |
}; |
}; |
375 |
|
|
376 |
return track; |
return track; |
384 |
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. |
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. |
385 |
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
386 |
* Sorting cryteria: |
* Sorting cryteria: |
387 |
* TRK: lower chi**2 |
* TRK: lower chi**2 |
388 |
* CAL: lower Y spatial residual on the first calorimeter plane |
* CAL: lower Y spatial residual on the first calorimeter plane |
389 |
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
390 |
* The default sorting cryterium is "TOF+CAL". |
* The default sorting cryterium is "TOF+CAL". |
393 |
*/ |
*/ |
394 |
void PamLevel2::SortTracks(TString how){ |
void PamLevel2::SortTracks(TString how){ |
395 |
|
|
396 |
|
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
397 |
|
if( !trk2_obj ){ |
398 |
|
cout << "void PamLevel2::SortTracks(TString how): TrkLevel2 not loaded !!!"; |
399 |
|
return; |
400 |
|
}; |
401 |
|
// cout << "call SortTracs() "<<endl; |
402 |
//Save current Object count |
//Save current Object count |
403 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
404 |
|
|
405 |
sorted_tracks->Delete(); //temporaneo??? |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
406 |
|
|
407 |
|
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
408 |
|
// sorted_tracks->Clear(); |
409 |
|
// sorted_tracks.Clear(); |
410 |
|
|
411 |
|
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
412 |
|
tsorted->Delete(); |
413 |
|
TClonesArray &ttsorted = *tsorted; |
414 |
|
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
415 |
|
timage->Delete(); |
416 |
|
TClonesArray &ttimage = *timage; |
417 |
|
|
418 |
|
|
419 |
// loop over the tracks sorted by the tracker |
// loop over the tracks sorted by the tracker |
420 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
421 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
422 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
423 |
|
|
424 |
if( !CAL && use_CAL) use_CAL = false; |
if( !CAL2 && use_CAL) use_CAL = false; |
425 |
if( !TOF && use_TOF) use_TOF = false; |
if( !TOF && use_TOF) use_TOF = false; |
426 |
|
|
427 |
if( !TRK ){ |
if( !TRK2 ){ |
428 |
cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
429 |
return; |
return; |
430 |
}; |
}; |
431 |
|
|
432 |
|
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
433 |
|
|
434 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
435 |
|
|
436 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
437 |
|
CaloTrkVar *cs = 0; |
438 |
|
ToFTrkVar *os = 0; |
439 |
|
|
440 |
// get tracker tracks |
// get tracker tracks |
441 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
442 |
// CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
443 |
// ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
444 |
CaloTrkVar *cp = 0; |
|
445 |
ToFTrkVar *op = 0; |
TrkTrack *ti = 0; //tracker (image) |
446 |
|
CaloTrkVar *ci = 0; |
447 |
|
ToFTrkVar *oi = 0; |
448 |
|
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
449 |
// if track has an image, check image selection |
// if track has an image, check image selection |
450 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
451 |
|
|
452 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
453 |
// CaloTrkVar *ci = GetCaloStoredTrack(ti->GetSeqNo()); |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
454 |
// ToFTrkVar *oi = GetToFStoredTrack(ti->GetSeqNo()); |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
|
CaloTrkVar *ci = 0; |
|
|
ToFTrkVar *oi = 0; |
|
455 |
|
|
456 |
|
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
457 |
|
|
458 |
//assign starting scores |
//assign starting scores |
459 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
460 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
464 |
// ------------------------ |
// ------------------------ |
465 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
466 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
467 |
|
if( use_CAL && !calo2_obj ){ |
468 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but CaloLevel2 not loaded !!!"; |
469 |
|
return; |
470 |
|
}; |
471 |
if( |
if( |
472 |
use_CAL && |
use_CAL && |
473 |
npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
474 |
varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
475 |
true){ |
true){ |
476 |
|
|
477 |
|
|
478 |
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
479 |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
|
|
|
|
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
|
|
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
|
480 |
|
|
481 |
if(resy_p <= resy_i) tp_score++; |
if(resy_p <= resy_i) tp_score++; |
482 |
else ti_score++; |
else ti_score++; |
483 |
|
|
484 |
|
// cout << "CALO "<<tp_score<<ti_score<<endl; |
485 |
|
|
486 |
}; |
}; |
487 |
// ------------------------ |
// ------------------------ |
488 |
// TOF check |
// TOF check |
489 |
// ------------------------ |
// ------------------------ |
490 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
491 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
492 |
|
if( use_TOF && !tof_obj ){ |
493 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
494 |
|
return; |
495 |
|
}; |
496 |
if( use_TOF ){ |
if( use_TOF ){ |
497 |
|
|
498 |
Int_t nphit_p =0; |
Int_t nphit_p =0; |
499 |
Int_t nphit_i =0; |
Int_t nphit_i =0; |
500 |
|
|
|
op = GetToFStoredTrack(tp->GetSeqNo()); |
|
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
|
501 |
|
|
502 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
503 |
cout << "track: npmttdc "<< op->npmttdc << endl; |
cout << "track: npmttdc "<< op->npmttdc << endl; |
505 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
506 |
|
|
507 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
508 |
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
509 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
510 |
}; |
}; |
511 |
|
|
512 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
513 |
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
514 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
515 |
}; |
}; |
516 |
|
|
522 |
if( nphit_p >= nphit_i) tp_score++; |
if( nphit_p >= nphit_i) tp_score++; |
523 |
else ti_score++; |
else ti_score++; |
524 |
}; |
}; |
525 |
|
// cout << "TOF "<<tp_score<<ti_score<<endl; |
526 |
}; |
}; |
527 |
if(tp_score == ti_score) use_TRK = true; |
if(tp_score == ti_score) use_TRK = true; |
528 |
// ------------------------ |
// ------------------------ |
534 |
if(use_TRK){ |
if(use_TRK){ |
535 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
536 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
537 |
|
// cout << "TRK "<<tp_score<<ti_score<<endl; |
538 |
}; |
}; |
539 |
|
|
540 |
// ------------------------ |
// ------------------------ |
541 |
// the winner is.... |
// the winner is.... |
542 |
// ------------------------ |
// ------------------------ |
543 |
if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
if (tp_score > ti_score) { |
544 |
else if (tp_score < ti_score) ts = ti;//its image!! |
// ts = tp;//the track sorted by the tracker!! |
545 |
else { |
// cs = cp; |
546 |
ts = tp; |
// os = op; |
547 |
|
}else if (tp_score < ti_score) { |
548 |
|
ts = ti;//its image!! |
549 |
|
cs = ci; |
550 |
|
os = oi; |
551 |
|
|
552 |
|
ti = tp;//its image!! |
553 |
|
ci = cp; |
554 |
|
oi = op; |
555 |
|
|
556 |
|
tp = ts;//its image!! |
557 |
|
cp = cs; |
558 |
|
op = os; |
559 |
|
|
560 |
|
|
561 |
|
}else { |
562 |
|
// ts = tp; |
563 |
|
// cs = cp; |
564 |
|
// os = op; |
565 |
// cout << "Warning - track image ambiguity not solved" << endl; |
// cout << "Warning - track image ambiguity not solved" << endl; |
566 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
567 |
}; |
}; |
568 |
|
|
569 |
}else{ |
}else{ |
570 |
ts = tp; |
// ts = tp; |
571 |
|
// cs = cp; |
572 |
|
// os = op; |
573 |
}; |
}; |
574 |
|
|
575 |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
576 |
sorted_tracks->Add(ts);//save the track in the sorted array |
// sorted_tracks->Add(ts);//save the track in the sorted array |
577 |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
// sorted_tracks.Add(ts);//save the track in the sorted array |
578 |
|
// sorted_tracks.Add(tp);//save the track in the sorted array |
579 |
}; |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
580 |
|
// cout<<"o "<<tp<<endl; |
581 |
|
// cout<<"o "<<cp<<endl; |
582 |
|
// cout<<"o "<<op<<endl; |
583 |
|
new(ttsorted[i]) PamTrack(tp,cp,op); |
584 |
|
new(ttimage[i]) PamTrack(ti,ci,oi); |
585 |
|
}; |
586 |
|
|
587 |
|
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
588 |
|
cout << "void PamLevel2::SortTracks(TString how): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
589 |
|
tsorted->Delete(); tsorted=0; |
590 |
|
timage->Delete(); timage=0; |
591 |
|
} |
592 |
|
|
593 |
//Restore Object count |
//Restore Object count |
594 |
//To save space in the table keeping track of all referenced objects |
//To save space in the table keeping track of all referenced objects |
595 |
//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. |
|
596 |
TProcessID::SetObjectCount(ObjectNumber); |
TProcessID::SetObjectCount(ObjectNumber); |
597 |
|
|
598 |
}; |
}; |
604 |
* 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. |
605 |
* 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. |
606 |
*/ |
*/ |
607 |
TRefArray *PamLevel2::GetTracks(){ |
// TRefArray *PamLevel2::GetTracks(){ |
608 |
// |
|
609 |
// SortTracks("+CAL+TOF"); |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
610 |
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
// SortTracks("+CAL+TOF"); |
611 |
// |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
612 |
return sorted_tracks; |
|
613 |
|
// // return sorted_tracks; |
614 |
|
// return &sorted_tracks; |
615 |
|
|
616 |
|
// }; |
617 |
|
TClonesArray *PamLevel2::GetTracks(){ |
618 |
|
|
619 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
620 |
|
SortTracks("+CAL+TOF"); |
621 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
622 |
|
|
623 |
|
return tsorted; |
624 |
|
|
625 |
}; |
}; |
626 |
//-------------------------------------- |
//-------------------------------------- |
627 |
// |
// |
633 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
634 |
*/ |
*/ |
635 |
PamTrack *PamLevel2::GetTrack(int it){ |
PamTrack *PamLevel2::GetTrack(int it){ |
636 |
|
|
637 |
|
// if(!trk2_obj) return 0; |
638 |
|
|
639 |
// *-*-*-*-*-*-* |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
640 |
// SortTracks("+CAL+TOF"); |
// SortTracks("+CAL+TOF"); |
641 |
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
642 |
// *-*-*-*-*-*-* |
// // if(!sorted_tracks)return 0; |
643 |
|
// if(sorted_tracks.IsEmpty())return 0; |
644 |
|
|
645 |
|
// PamTrack *track = 0; |
646 |
|
|
647 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && it<sorted_tracks.GetEntriesFast() ){ |
648 |
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
649 |
|
// track = GetPamTrackAlong(t); |
650 |
|
// }else{ |
651 |
|
// cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
652 |
|
// }; |
653 |
|
|
654 |
|
// return track; |
655 |
|
|
656 |
|
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
657 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
658 |
|
SortTracks("+CAL+TOF"); |
659 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
660 |
|
if(!tsorted)return 0; |
661 |
|
if(!tsorted->GetEntries())return 0; |
662 |
|
|
663 |
PamTrack *track = 0; |
PamTrack *track = 0; |
664 |
|
|
665 |
if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){ |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks()){ |
666 |
TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); |
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
667 |
track = GetPamTrackAlong(t); |
// track = GetPamTrackAlong(t); |
668 |
|
TClonesArray &t = *(tsorted); |
669 |
|
track = (PamTrack*)t[it]; |
670 |
|
|
671 |
}else{ |
}else{ |
672 |
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; |
673 |
}; |
}; |
674 |
|
|
675 |
return track; |
return track; |
686 |
*/ |
*/ |
687 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
PamTrack *PamLevel2::GetTrackImage(int it){ |
688 |
|
|
689 |
// SortTracks("+CAL+TOF"); |
// if(!trk2_obj) return 0; |
|
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
|
|
|
|
|
PamTrack *image = 0; |
|
690 |
|
|
691 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
692 |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
// SortTracks("+CAL+TOF"); |
693 |
if( temp->HasImage() ){ |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
694 |
TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
// // if(!sorted_tracks)return 0; |
695 |
image = GetPamTrackAlong(t); |
// if(sorted_tracks.IsEmpty())return 0; |
696 |
}else{ |
|
697 |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
// PamTrack *image = 0; |
698 |
}; |
|
699 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
700 |
|
// TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it); |
701 |
|
// if( temp->HasImage() ){ |
702 |
|
// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
703 |
|
// image = GetPamTrackAlong(t); |
704 |
|
// }else{ |
705 |
|
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
706 |
|
// }; |
707 |
|
// }else{ |
708 |
|
// cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
709 |
|
// }; |
710 |
|
|
711 |
|
// return image; |
712 |
|
|
713 |
|
|
714 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
715 |
|
SortTracks("+CAL+TOF"); |
716 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
717 |
|
if(!timage)return 0; |
718 |
|
if(!timage->GetEntries())return 0; |
719 |
|
|
720 |
|
PamTrack *image = 0; |
721 |
|
|
722 |
|
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
723 |
|
TClonesArray &t = *(tsorted); |
724 |
|
PamTrack *temp = (PamTrack*)t[it]; |
725 |
|
if( temp->GetTrkTrack()->HasImage() ){ |
726 |
|
TClonesArray &t = *(timage); |
727 |
|
image = (PamTrack*)t[it]; |
728 |
}else{ |
}else{ |
729 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
730 |
}; |
}; |
731 |
|
}else{ |
732 |
|
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
733 |
|
}; |
734 |
|
|
735 |
return image; |
return image; |
736 |
} |
} |
737 |
|
|
738 |
//-------------------------------------- |
//-------------------------------------- |
745 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
746 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
747 |
*/ |
*/ |
748 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ){ |
749 |
|
|
750 |
// cout << "WARNING!!! -- obsolete method -- \n"; |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
751 |
// cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
// else GetWhichTrees(f); |
|
|
|
|
TTree *Trout =0; |
|
|
|
|
752 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
753 |
|
|
754 |
|
TTree *Trout =0; |
755 |
|
|
756 |
|
TString fname = f->GetName(); |
757 |
|
if(!CheckLevel2File(fname))return NULL; |
758 |
|
|
759 |
|
UInt_t *found=0; |
760 |
|
|
761 |
|
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
762 |
|
if(TRK1)cout<<"TRK1 "; |
763 |
|
if(TRK2)cout<<"TRK2 "; |
764 |
|
if(TRKh)cout<<"TRKH "; |
765 |
|
if(CAL1)cout<<"CAL1 "; |
766 |
|
if(CAL2)cout<<"CAL2 "; |
767 |
|
if(TOF)cout<<"TOF "; |
768 |
|
if(TRG)cout<<"TRG "; |
769 |
|
if(AC)cout<<"AC "; |
770 |
|
if(ND)cout<<"ND "; |
771 |
|
if(S4)cout<<"S4 "; |
772 |
|
if(ORB)cout<<"ORB "; |
773 |
|
cout << endl; |
774 |
|
|
775 |
|
f->cd(); |
776 |
|
|
777 |
// Tracker |
// Tracker |
778 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
779 |
if(T && TRK) { |
if(T && (TRK2||TRK1||TRKh)) { |
780 |
if(TRK_L1){ |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
781 |
T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
else T->SetBranchStatus("TrkLevel2",0,found); |
782 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
783 |
}; |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
784 |
T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
else T->SetBranchStatus("TrkLevel1",0,found); |
785 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
786 |
Trout=T; |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
787 |
|
else T->SetBranchStatus("TrkHough",0,found); |
788 |
|
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
789 |
|
if(!Trout)Trout=T; |
790 |
|
else Trout->AddFriend(T); |
791 |
}else{ |
}else{ |
792 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
793 |
}; |
}; |
794 |
// Calorimeter |
// Calorimeter |
795 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
TTree *C = (TTree*)f->Get("Calorimeter"); |
796 |
if(C && CAL) { |
if(C && (CAL2||CAL1)) { |
797 |
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
798 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
else C->SetBranchStatus("CaloLevel2",0,found); |
799 |
|
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
800 |
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
801 |
|
else C->SetBranchStatus("CaloLevel1",0,found); |
802 |
|
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
803 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
804 |
else Trout->AddFriend(C); |
else Trout->AddFriend(C); |
805 |
}else{ |
}else{ |
806 |
cout << "Calorimeter : missing tree"<<endl; |
cout << "Calorimeter : missing tree"<<endl; |
807 |
}; |
}; |
808 |
|
|
809 |
// ToF |
// ToF |
810 |
TTree *O = (TTree*)f->Get("ToF"); |
TTree *O = (TTree*)f->Get("ToF"); |
811 |
if(O && TOF) { |
if(O && TOF) { |
812 |
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
813 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
814 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
815 |
else Trout->AddFriend(O); |
else Trout->AddFriend(O); |
819 |
// Trigger |
// Trigger |
820 |
TTree *R = (TTree*)f->Get("Trigger"); |
TTree *R = (TTree*)f->Get("Trigger"); |
821 |
if(R && TRG) { |
if(R && TRG) { |
822 |
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
823 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
824 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
825 |
else Trout->AddFriend(R); |
else Trout->AddFriend(R); |
829 |
// S4 |
// S4 |
830 |
TTree *S = (TTree*)f->Get("S4"); |
TTree *S = (TTree*)f->Get("S4"); |
831 |
if(S && S4) { |
if(S && S4) { |
832 |
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
833 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
834 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
835 |
else Trout->AddFriend(S); |
else Trout->AddFriend(S); |
839 |
// Neutron Detector |
// Neutron Detector |
840 |
TTree *N = (TTree*)f->Get("NeutronD"); |
TTree *N = (TTree*)f->Get("NeutronD"); |
841 |
if(N && ND) { |
if(N && ND) { |
842 |
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
843 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
844 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
845 |
else Trout->AddFriend(N); |
else Trout->AddFriend(N); |
849 |
// Anticounters |
// Anticounters |
850 |
TTree *A = (TTree*)f->Get("Anticounter"); |
TTree *A = (TTree*)f->Get("Anticounter"); |
851 |
if(A && AC) { |
if(A && AC) { |
852 |
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
853 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
854 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
855 |
else Trout->AddFriend(A); |
else Trout->AddFriend(A); |
857 |
cout << "Anticounter : missing tree"<<endl; |
cout << "Anticounter : missing tree"<<endl; |
858 |
}; |
}; |
859 |
// Orbital Info |
// Orbital Info |
860 |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
861 |
if(B && ORB) { |
if(B && ORB) { |
862 |
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
863 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
864 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
865 |
else Trout->AddFriend(B); |
else Trout->AddFriend(B); |
866 |
}else{ |
}else{ |
867 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
868 |
}; |
}; |
869 |
|
|
870 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
871 |
|
|
872 |
return Trout; |
return Trout; |
873 |
|
|
874 |
} |
} |
875 |
//-------------------------------------- |
//-------------------------------------- |
899 |
// if no input file list is given: |
// if no input file list is given: |
900 |
if ( flisttxt != "" ){ |
if ( flisttxt != "" ){ |
901 |
|
|
902 |
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0; |
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ |
903 |
|
cout <<"File "<<flisttxt<<" not found"<<endl; |
904 |
|
return 0; |
905 |
|
} |
906 |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
907 |
flisttxt = fullpath; |
flisttxt = fullpath; |
908 |
|
|
909 |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
if( !gSystem->ChangeDirectory(ddir) ){ |
910 |
|
cout << "Cannot change directory : "<<ddir<<endl; |
911 |
|
return 0; |
912 |
|
} |
913 |
|
|
914 |
cout <<"Input file list : " << flisttxt <<endl; |
cout <<"Input file list : " << flisttxt <<endl; |
915 |
ifstream in; |
ifstream in; |
916 |
in.open(flisttxt, ios::in); //open input file list |
in.open(flisttxt, ios::in); //open input file list |
917 |
|
int line=0; |
918 |
while (1) { |
while (1) { |
919 |
TString file; |
TString file; |
920 |
in >> file; |
in >> file; |
921 |
if (!in.good()) break; |
if (!in.good()) break; |
922 |
|
line++; |
923 |
|
// cout <<"(1) " << file << endl; |
924 |
|
if(file.IsNull()){ |
925 |
|
cout << "-- list interrupted at line "<<line <<endl; |
926 |
|
break; |
927 |
|
} |
928 |
|
if(file.Contains("#"))file = file(0,file.First("#")); |
929 |
|
// cout <<"(2) " << file << endl; |
930 |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
931 |
// contents->Add(new TSystemDirectory(fullpath,ddir)); // add file to the list |
|
|
// contents->Add(new TSystemFile(fullpath,ddir)); // add file to the list |
|
932 |
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 |
933 |
|
|
934 |
}else{ |
}else{ |
935 |
cout << "warning! --- File "<<file<<" does not exists"<< endl; |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
936 |
}; |
}; |
937 |
}; |
}; |
938 |
in.close(); |
in.close(); |
982 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
983 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
984 |
*/ |
*/ |
985 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
|
|
|
|
// TChain *Tout=0; |
|
|
if(Tout)Tout->Delete(); |
|
|
Tout = NULL; |
|
986 |
|
|
987 |
|
TChain *Trout =0; |
988 |
|
|
989 |
|
// if( !detlist.IsNull() )SetWhichTrees(detlist); |
990 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
991 |
|
|
992 |
|
cout<< "GetPamTree(TList*,TString): input detector list --> "; |
993 |
|
if(TRK1)cout<<"TRK1 "; |
994 |
|
if(TRK2)cout<<"TRK2 "; |
995 |
|
if(TRKh)cout<<"TRKH "; |
996 |
|
if(CAL1)cout<<"CAL1 "; |
997 |
|
if(CAL2)cout<<"CAL2 "; |
998 |
|
if(TOF)cout<<"TOF "; |
999 |
|
if(TRG)cout<<"TRG "; |
1000 |
|
if(AC)cout<<"AC "; |
1001 |
|
if(ND)cout<<"ND "; |
1002 |
|
if(S4)cout<<"S4 "; |
1003 |
|
if(ORB)cout<<"ORB "; |
1004 |
|
cout << endl; |
1005 |
|
|
1006 |
TChain *T = 0; |
TChain *T = 0; |
1007 |
TChain *C = 0; |
TChain *C = 0; |
1008 |
TChain *O = 0; |
TChain *O = 0; |
1012 |
TChain *A = 0; |
TChain *A = 0; |
1013 |
TChain *B = 0; |
TChain *B = 0; |
1014 |
|
|
1015 |
if(TRK) T = new TChain("Tracker"); |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
1016 |
if(CAL) C = new TChain("Calorimeter"); |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
1017 |
if(TOF) O = new TChain("ToF"); |
if(TOF) O = new TChain("ToF"); |
1018 |
if(TRG) R = new TChain("Trigger"); |
if(TRG) R = new TChain("Trigger"); |
1019 |
if(S4) S = new TChain("S4"); |
if(S4) S = new TChain("S4"); |
1020 |
if(ND) N = new TChain("NeutronD"); |
if(ND) N = new TChain("NeutronD"); |
1021 |
if(AC) A = new TChain("Anticounter"); |
if(AC) A = new TChain("Anticounter"); |
1022 |
if(ORB) B = new TChain("OrbitalInfo"); |
if(ORB) B = new TChain("OrbitalInfo"); |
1023 |
|
|
1024 |
// loop over files and create chains |
// loop over files and create chains |
1025 |
TIter next(fl); |
TIter next(fl); |
1026 |
TSystemFile *questo = 0; |
TSystemFile *questo = 0; |
1027 |
while ( (questo = (TSystemFile*) next()) ) { |
while ( (questo = (TSystemFile*) next()) ) { |
1028 |
TString name = questo->GetName(); |
TString name = questo->GetName(); |
1029 |
// cout << "File: "<< name << endl; |
cout << "File: "<< name << endl; |
1030 |
if( CheckLevel2File(name) ){ |
if( CheckLevel2File(name) ){ |
1031 |
if(TRK) T->Add(name); |
if(TRK2||TRK1||TRKh) T->Add(name); |
1032 |
if(CAL) C->Add(name); |
if(CAL1||CAL2) C->Add(name); |
1033 |
if(TOF) O->Add(name); |
if(TOF) O->Add(name); |
1034 |
if(TRG) R->Add(name); |
if(TRG) R->Add(name); |
1035 |
if(S4) S->Add(name); |
if(S4) S->Add(name); |
1036 |
if(ND) N->Add(name); |
if(ND) N->Add(name); |
1037 |
if(AC) A->Add(name); |
if(AC) A->Add(name); |
1038 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
1039 |
}; |
}; |
1040 |
} |
} |
1041 |
|
|
1042 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1043 |
|
|
1044 |
// Tracker |
UInt_t *found=0; |
1045 |
if(TRK) if(!Tout)Tout=T; |
// Tracker |
1046 |
|
if(T && (TRK2||TRK1||TRKh)) { |
1047 |
|
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1048 |
|
else T->SetBranchStatus("TrkLevel2",0,found); |
1049 |
|
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1050 |
|
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1051 |
|
else T->SetBranchStatus("TrkLevel1",0,found); |
1052 |
|
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1053 |
|
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1054 |
|
else T->SetBranchStatus("TrkHough",0,found); |
1055 |
|
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1056 |
|
if(!Trout)Trout=T; |
1057 |
|
else Trout->AddFriend("Tracker"); |
1058 |
|
}else{ |
1059 |
|
cout << "Tracker : missing tree"<<endl; |
1060 |
|
}; |
1061 |
// Calorimeter |
// Calorimeter |
1062 |
if(CAL) { |
if(C && (CAL2||CAL1)) { |
1063 |
if(!Tout)Tout=C; |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1064 |
else Tout->AddFriend("Calorimeter"); |
else C->SetBranchStatus("CaloLevel2",0,found); |
1065 |
|
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1066 |
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1067 |
|
else C->SetBranchStatus("CaloLevel1",0,found); |
1068 |
|
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1069 |
|
if(!Trout)Trout=C; |
1070 |
|
else Trout->AddFriend("Calorimeter"); |
1071 |
|
}else{ |
1072 |
|
cout << "Calorimeter : missing tree"<<endl; |
1073 |
}; |
}; |
1074 |
// ToF |
// ToF |
1075 |
if(TOF) { |
if(O && TOF) { |
1076 |
if(!Tout)Tout=O; |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1077 |
else Tout->AddFriend("ToF"); |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1078 |
|
if(!Trout)Trout=O; |
1079 |
|
else Trout->AddFriend("ToF"); |
1080 |
|
}else{ |
1081 |
|
cout << "ToF : missing tree"<<endl; |
1082 |
}; |
}; |
1083 |
// Trigger |
// Trigger |
1084 |
if(TRG) { |
if(R && TRG) { |
1085 |
if(!Tout)Tout=O; |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1086 |
else Tout->AddFriend("Trigger"); |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1087 |
|
if(!Trout)Trout=O; |
1088 |
|
else Trout->AddFriend("Trigger"); |
1089 |
|
}else{ |
1090 |
|
cout << "Trigger : missing tree"<<endl; |
1091 |
}; |
}; |
1092 |
// S4 |
// S4 |
1093 |
if(S4) { |
if(S && S4) { |
1094 |
if(!Tout)Tout=O; |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1095 |
else Tout->AddFriend("S4"); |
cout << "S4 : set branch address S4Level2"<<endl; |
1096 |
|
if(!Trout)Trout=O; |
1097 |
|
else Trout->AddFriend("S4"); |
1098 |
|
}else{ |
1099 |
|
cout << "S4 : missing tree"<<endl; |
1100 |
}; |
}; |
1101 |
// Neutron Detector |
// Neutron Detector |
1102 |
if(ND) { |
if(N && ND) { |
1103 |
if(!Tout)Tout=O; |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1104 |
else Tout->AddFriend("NeutronD"); |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1105 |
|
if(!Trout)Trout=O; |
1106 |
|
else Trout->AddFriend("NeutronD"); |
1107 |
|
}else{ |
1108 |
|
cout << "NeutronD : missing tree"<<endl; |
1109 |
}; |
}; |
1110 |
// Anticounters |
// Anticounters |
1111 |
if(AC) { |
if(A && AC) { |
1112 |
if(!Tout)Tout=O; |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1113 |
else Tout->AddFriend("Anticounter"); |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1114 |
|
if(!Trout)Trout=O; |
1115 |
|
else Trout->AddFriend("Anticounter"); |
1116 |
|
}else{ |
1117 |
|
cout << "Anticounter : missing tree"<<endl; |
1118 |
}; |
}; |
1119 |
// OrbitalInfo |
// Orbital Info |
1120 |
if(ORB) { |
if(B && ORB) { |
1121 |
if(!Tout)Tout=O; |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1122 |
else Tout->AddFriend("OrbitalInfo"); |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1123 |
|
if(!Trout)Trout=O; |
1124 |
|
else Trout->AddFriend("OrbitalInfo"); |
1125 |
|
}else{ |
1126 |
|
cout << "OrbitalInfo : missing tree"<<endl; |
1127 |
}; |
}; |
1128 |
|
|
1129 |
|
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1130 |
|
|
1131 |
|
|
1132 |
|
// // Tracker |
1133 |
|
// if(TRK2||TRK1||TRKh){ |
1134 |
|
// if(!Tout)Tout=T; |
1135 |
|
// else Tout->AddFriend("Tracker"); |
1136 |
|
// } |
1137 |
|
// // Calorimeter |
1138 |
|
// if(CAL2||CAL1) { |
1139 |
|
// if(!Tout)Tout=C; |
1140 |
|
// else Tout->AddFriend("Calorimeter"); |
1141 |
|
// }; |
1142 |
|
// // ToF |
1143 |
|
// if(TOF) { |
1144 |
|
// if(!Tout)Tout=O; |
1145 |
|
// else Tout->AddFriend("ToF"); |
1146 |
|
// }; |
1147 |
|
// // Trigger |
1148 |
|
// if(TRG) { |
1149 |
|
// if(!Tout)Tout=R; |
1150 |
|
// else Tout->AddFriend("Trigger"); |
1151 |
|
// }; |
1152 |
|
// // S4 |
1153 |
|
// if(S4) { |
1154 |
|
// if(!Tout)Tout=S; |
1155 |
|
// else Tout->AddFriend("S4"); |
1156 |
|
// }; |
1157 |
|
// // Neutron Detector |
1158 |
|
// if(ND) { |
1159 |
|
// if(!Tout)Tout=N; |
1160 |
|
// else Tout->AddFriend("NeutronD"); |
1161 |
|
// }; |
1162 |
|
// // Anticounters |
1163 |
|
// if(AC) { |
1164 |
|
// if(!Tout)Tout=A; |
1165 |
|
// else Tout->AddFriend("Anticounter"); |
1166 |
|
// }; |
1167 |
|
// // OrbitalInfo |
1168 |
|
// if(ORB) { |
1169 |
|
// if(!Tout)Tout=B; |
1170 |
|
// else Tout->AddFriend("OrbitalInfo"); |
1171 |
|
// }; |
1172 |
|
|
1173 |
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
1174 |
|
|
1175 |
if( Tout->GetEntries() )PamLevel2::SetBranchAddress(); |
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
1176 |
|
|
1177 |
return Tout; |
return Trout; |
1178 |
} |
} |
1179 |
|
|
1180 |
|
|
1181 |
|
|
1182 |
//-------------------------------------- |
//-------------------------------------- |
1183 |
// |
// |
1184 |
// |
// |
1186 |
/** |
/** |
1187 |
* Set branch addresses for Pamela friend trees |
* Set branch addresses for Pamela friend trees |
1188 |
*/ |
*/ |
1189 |
void PamLevel2::SetBranchAddress(){ |
void PamLevel2::SetBranchAddress(TTree *t){ |
1190 |
|
|
1191 |
|
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
1192 |
|
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
1193 |
|
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
1194 |
|
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
1195 |
|
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
1196 |
|
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
1197 |
|
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
1198 |
|
S4 = S4 & t->GetBranchStatus("S4Level2"); |
1199 |
|
ND = ND & t->GetBranchStatus("NDLevel2"); |
1200 |
|
AC = AC & t->GetBranchStatus("AcLevel2"); |
1201 |
|
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
1202 |
|
|
1203 |
|
|
1204 |
// Tracker |
// Tracker |
1205 |
if(TRK) { |
if(TRK1) { |
1206 |
if(TRK_L1){ |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel2")); |
1207 |
Tout->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
1208 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
}; |
1209 |
}; |
if(TRK2) { |
1210 |
Tout->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
1211 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
1212 |
}; |
}; |
1213 |
|
if(TRKh) { |
1214 |
|
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1215 |
|
cout << "Tracker : set branch address TrkHough"<<endl; |
1216 |
|
}; |
1217 |
|
|
1218 |
// Calorimeter |
// Calorimeter |
1219 |
if(CAL) { |
if(CAL1) { |
1220 |
Tout->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1221 |
|
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1222 |
|
}; |
1223 |
|
if(CAL2) { |
1224 |
|
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1225 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1226 |
}; |
}; |
1227 |
|
|
1228 |
// ToF |
// ToF |
1229 |
if(TOF) { |
if(TOF) { |
1230 |
Tout->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1231 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
1232 |
}; |
}; |
1233 |
// Trigger |
// Trigger |
1234 |
if(TRG) { |
if(TRG) { |
1235 |
Tout->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1236 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1237 |
}; |
}; |
1238 |
// S4 |
// S4 |
1239 |
if(S4) { |
if(S4) { |
1240 |
Tout->SetBranchAddress("S4Level2", GetPointerToS4()); |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1241 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
1242 |
}; |
}; |
1243 |
// Neutron Detector |
// Neutron Detector |
1244 |
if(ND) { |
if(ND) { |
1245 |
Tout->SetBranchAddress("NDLevel2", GetPointerToND()); |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1246 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1247 |
}; |
}; |
1248 |
// Anticounters |
// Anticounters |
1249 |
if(AC) { |
if(AC) { |
1250 |
Tout->SetBranchAddress("AcLevel2", GetPointerToAc()); |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1251 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1252 |
}; |
}; |
1253 |
// OrbitalInfo |
// OrbitalInfo |
1254 |
if(ORB) { |
if(ORB) { |
1255 |
Tout->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1256 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1257 |
}; |
}; |
1258 |
|
|
1259 |
} |
} |
1260 |
|
/** |
1261 |
|
* Set branch addresses for Pamela friend trees |
1262 |
|
*/ |
1263 |
|
void PamLevel2::SetBranchAddress(TChain *t){ |
1264 |
|
|
1265 |
//-------------------------------------- |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
1266 |
// |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
1267 |
// |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
1268 |
//-------------------------------------- |
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
1269 |
void *PamLevel2::GetPointerTo(const char* c ){ |
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
1270 |
// cout << "objname "<< objname << endl; |
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
1271 |
TString objname = c; |
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
1272 |
if(!objname.CompareTo("TrkLevel1"))return &trk_l1_obj; |
S4 = S4 & t->GetBranchStatus("S4Level2"); |
1273 |
if(!objname.CompareTo("TrkLevel2"))return &trk_obj; |
ND = ND & t->GetBranchStatus("NDLevel2"); |
1274 |
|
AC = AC & t->GetBranchStatus("AcLevel2"); |
1275 |
|
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
1276 |
|
|
1277 |
|
// Tracker |
1278 |
|
if(TRK2) { |
1279 |
|
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1280 |
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
1281 |
|
}; |
1282 |
|
if(TRK1) { |
1283 |
|
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1284 |
|
cout << "Tracker : set branch address TrkLevel1"<<endl; |
1285 |
|
}; |
1286 |
|
if(TRKh) { |
1287 |
|
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1288 |
|
cout << "Tracker : set branch address TrkHough"<<endl; |
1289 |
|
}; |
1290 |
|
|
1291 |
return NULL; |
// Calorimeter |
1292 |
}; |
if(CAL2) { |
1293 |
|
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1294 |
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1295 |
|
}; |
1296 |
|
if(CAL1) { |
1297 |
|
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1298 |
|
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1299 |
|
}; |
1300 |
|
|
1301 |
|
// ToF |
1302 |
|
if(TOF) { |
1303 |
|
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
1304 |
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
1305 |
|
}; |
1306 |
|
// Trigger |
1307 |
|
if(TRG) { |
1308 |
|
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1309 |
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1310 |
|
}; |
1311 |
|
// S4 |
1312 |
|
if(S4) { |
1313 |
|
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1314 |
|
cout << "S4 : set branch address S4Level2"<<endl; |
1315 |
|
}; |
1316 |
|
// Neutron Detector |
1317 |
|
if(ND) { |
1318 |
|
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1319 |
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1320 |
|
}; |
1321 |
|
// Anticounters |
1322 |
|
if(AC) { |
1323 |
|
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1324 |
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1325 |
|
}; |
1326 |
|
// OrbitalInfo |
1327 |
|
if(ORB) { |
1328 |
|
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1329 |
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1330 |
|
}; |
1331 |
|
|
1332 |
|
} |
1333 |
|
|
1334 |
|
|
1335 |
//-------------------------------------- |
//-------------------------------------- |
1336 |
// |
// |
1337 |
// |
// |
1356 |
}; |
}; |
1357 |
} |
} |
1358 |
|
|
1359 |
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1360 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1361 |
|
|
1362 |
return R; |
return R; |
1376 |
|
|
1377 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *R = (TTree*)f->Get("Run"); |
1378 |
|
|
1379 |
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1380 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1381 |
|
|
1382 |
return R; |
return R; |
1387 |
// |
// |
1388 |
//-------------------------------------- |
//-------------------------------------- |
1389 |
/** |
/** |
1390 |
* Set which trees should be analysed |
* Set which trees shoul be analysed |
1391 |
* @param detlist TString containing the sequence of trees required |
* @param detlist TString containing the sequence of trees required |
1392 |
*/ |
*/ |
1393 |
void PamLevel2::SetWhichTrees(TString detlist){ |
void PamLevel2::SetWhichTrees(TString detlist){ |
1394 |
|
|
1395 |
if(detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
1396 |
CAL = true; |
CAL1 = true; |
1397 |
TRK = true; |
CAL2 = true; |
1398 |
TRK_L1 = false; |
TRK2 = true; |
1399 |
|
TRK1 = false; |
1400 |
|
TRKh = false; |
1401 |
TRG = true; |
TRG = true; |
1402 |
TOF = true; |
TOF = true; |
1403 |
S4 = true; |
S4 = true; |
1405 |
AC = true; |
AC = true; |
1406 |
ORB = true; |
ORB = true; |
1407 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
1408 |
CAL = false; |
CAL1 = false; |
1409 |
TRK = false; |
CAL2 = false; |
1410 |
TRK_L1 = false; |
TRK2 = false; |
1411 |
|
TRK1 = false; |
1412 |
|
TRKh = false; |
1413 |
TRG = false; |
TRG = false; |
1414 |
TOF = false; |
TOF = false; |
1415 |
S4 = false; |
S4 = false; |
1418 |
ORB = false; |
ORB = false; |
1419 |
}; |
}; |
1420 |
|
|
1421 |
if( detlist.Contains("-CAL", TString::kIgnoreCase) )CAL = false; |
// ------------------------------------------------------------------------- |
1422 |
else if( detlist.Contains("+CAL", TString::kIgnoreCase) )CAL = true; |
if( detlist.Contains("CAL1", TString::kIgnoreCase) ){ |
1423 |
|
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
1424 |
if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK = false; |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
1425 |
else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK = true; |
}; |
1426 |
|
|
1427 |
if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK_L1 = false; |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
1428 |
else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK_L1 = true; |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
1429 |
|
if ( detlist.Contains("+CAL2", TString::kIgnoreCase) )CAL2=true; |
1430 |
|
}; |
1431 |
|
|
1432 |
|
if( detlist.Contains("+CAL", TString::kIgnoreCase) && !CAL1 && !CAL2 )CAL2=true; |
1433 |
|
if( detlist.Contains("-CAL", TString::kIgnoreCase) && CAL1 && CAL2 ){ |
1434 |
|
CAL2=false; |
1435 |
|
CAL1=false; |
1436 |
|
} |
1437 |
|
// ------------------------------------------------------------------------- |
1438 |
|
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
1439 |
|
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
1440 |
|
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
1441 |
|
}; |
1442 |
|
|
1443 |
|
if( detlist.Contains("TRK2", TString::kIgnoreCase)){ |
1444 |
|
if ( detlist.Contains("-TRK2", TString::kIgnoreCase) )TRK2=false; |
1445 |
|
if ( detlist.Contains("+TRK2", TString::kIgnoreCase) )TRK2=true; |
1446 |
|
}; |
1447 |
|
|
1448 |
|
if( detlist.Contains("TRKh", TString::kIgnoreCase)){ |
1449 |
|
if ( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh=false; |
1450 |
|
if ( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh=true; |
1451 |
|
}; |
1452 |
|
|
1453 |
|
if( detlist.Contains("+TRK", TString::kIgnoreCase) && !TRK1 && !TRK2 && !TRKh )TRK2=true; |
1454 |
|
if( detlist.Contains("-TRK", TString::kIgnoreCase) && TRK1 && TRK2 && TRKh){ |
1455 |
|
TRK2=false; |
1456 |
|
TRK1=false; |
1457 |
|
TRKh=false; |
1458 |
|
} |
1459 |
|
// ------------------------------------------------------------------------- |
1460 |
|
|
1461 |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
1462 |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
1475 |
|
|
1476 |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
1477 |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
1478 |
|
|
1479 |
|
// cout<< "Set detector list --> "; |
1480 |
|
// if(TRK1)cout<<"TRK1 "; |
1481 |
|
// if(TRK2)cout<<"TRK2 "; |
1482 |
|
// if(TRKh)cout<<"TRKH "; |
1483 |
|
// if(CAL1)cout<<"CAL1 "; |
1484 |
|
// if(CAL2)cout<<"CAL2 "; |
1485 |
|
// if(TOF)cout<<"TOF "; |
1486 |
|
// if(TRG)cout<<"TRG "; |
1487 |
|
// if(AC)cout<<"AC "; |
1488 |
|
// if(ND)cout<<"ND "; |
1489 |
|
// if(S4)cout<<"S4 "; |
1490 |
|
// if(ORB)cout<<"ORB "; |
1491 |
|
// cout << endl; |
1492 |
|
|
1493 |
}; |
}; |
1494 |
|
|
1495 |
|
|
1496 |
|
/** |
1497 |
|
* Set tree/branch detector flags from the content of a tree |
1498 |
|
*/ |
1499 |
|
void PamLevel2::GetWhichTrees(TFile* f){ |
1500 |
|
|
1501 |
|
// ----------- |
1502 |
|
// reset flags |
1503 |
|
// ----------- |
1504 |
|
CAL1 = false; |
1505 |
|
CAL2 = false; |
1506 |
|
TRK2 = false; |
1507 |
|
TRK1 = false; |
1508 |
|
TRKh = false; |
1509 |
|
TRG = false; |
1510 |
|
TOF = false; |
1511 |
|
S4 = false; |
1512 |
|
ND = false; |
1513 |
|
AC = false; |
1514 |
|
ORB = false; |
1515 |
|
|
1516 |
|
RUN = false; |
1517 |
|
|
1518 |
|
cout << "Checking file: "<<f->GetName()<<endl; |
1519 |
|
if( !f || f->IsZombie() ){ |
1520 |
|
cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; |
1521 |
|
return; |
1522 |
|
} |
1523 |
|
|
1524 |
|
TList *lk = f->GetListOfKeys(); |
1525 |
|
TIter next(lk); |
1526 |
|
TKey *key =0; |
1527 |
|
|
1528 |
|
Int_t nev = 0; |
1529 |
|
|
1530 |
|
while( (key = (TKey*)next()) ){ |
1531 |
|
|
1532 |
|
if( !strcmp(key->GetName(),"Run" ) )RUN = true; |
1533 |
|
|
1534 |
|
//========================================================= |
1535 |
|
if( !strcmp(key->GetName(),"Trigger" ) ){ |
1536 |
|
TRG = true; |
1537 |
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
1538 |
|
if( nev && nevt!=nev){ |
1539 |
|
cout << "File: "<< f->GetName() <<" Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
1540 |
|
TRG = false; |
1541 |
|
}else nev=nevt; |
1542 |
|
} |
1543 |
|
//========================================================= |
1544 |
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
1545 |
|
TOF = true; |
1546 |
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
1547 |
|
if( nev && nevt!=nev){ |
1548 |
|
cout << "File: "<< f->GetName() <<" ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
1549 |
|
TOF = false; |
1550 |
|
}else nev=nevt; |
1551 |
|
} |
1552 |
|
//========================================================= |
1553 |
|
if( !strcmp(key->GetName(),"S4" ) ){ |
1554 |
|
S4 = true; |
1555 |
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
1556 |
|
if( nev && nevt!=nev){ |
1557 |
|
cout << "File: "<< f->GetName() <<" S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
1558 |
|
S4 = false; |
1559 |
|
}else nev=nevt; |
1560 |
|
} |
1561 |
|
//========================================================= |
1562 |
|
|
1563 |
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
1564 |
|
ND = true; |
1565 |
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
1566 |
|
if( nev && nevt!=nev){ |
1567 |
|
cout << "File: "<< f->GetName() <<"NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
1568 |
|
ND =false; |
1569 |
|
}else nev=nevt; |
1570 |
|
} |
1571 |
|
//========================================================= |
1572 |
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
1573 |
|
AC = true; |
1574 |
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
1575 |
|
if( nev && nevt!=nev){ |
1576 |
|
cout << "File: "<< f->GetName() <<" Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1577 |
|
AC =false; |
1578 |
|
}else nev=nevt; |
1579 |
|
} |
1580 |
|
//========================================================= |
1581 |
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
1582 |
|
ORB = true; |
1583 |
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
1584 |
|
if( nev && nevt!=nev){ |
1585 |
|
cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
1586 |
|
ORB = false; |
1587 |
|
}else nev=nevt; |
1588 |
|
} |
1589 |
|
//========================================================= |
1590 |
|
if( !strcmp(key->GetName(),"Tracker" ) ){ |
1591 |
|
TTree *T = (TTree*)f->Get("Tracker"); |
1592 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1593 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1594 |
|
if( !name.CompareTo("TrkLevel1") )TRK1=true; |
1595 |
|
if( !name.CompareTo("TrkLevel2") )TRK2=true; |
1596 |
|
if( !name.CompareTo("TrkHough") )TRKh=true; |
1597 |
|
}; |
1598 |
|
Int_t nevt = T->GetEntries(); |
1599 |
|
if( nev && nevt!=nev){ |
1600 |
|
cout << "File: "<< f->GetName() <<" Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
1601 |
|
TRK1 = false; |
1602 |
|
TRK2 = false; |
1603 |
|
TRKh = false; |
1604 |
|
}else nev=nevt; |
1605 |
|
T->Delete(); |
1606 |
|
}; |
1607 |
|
//========================================================= |
1608 |
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
1609 |
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
1610 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1611 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1612 |
|
if( !name.CompareTo("CaloLevel1") )CAL1=true; |
1613 |
|
if( !name.CompareTo("CaloLevel2") )CAL2=true; |
1614 |
|
}; |
1615 |
|
Int_t nevt = T->GetEntries(); |
1616 |
|
if( nev && nevt!=nev){ |
1617 |
|
cout << "File: "<< f->GetName() <<" Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1618 |
|
CAL1 = false; |
1619 |
|
CAL2 = false; |
1620 |
|
}else nev=nevt; |
1621 |
|
T->Delete(); |
1622 |
|
}; |
1623 |
|
|
1624 |
|
}; |
1625 |
|
|
1626 |
|
delete lk; |
1627 |
|
|
1628 |
|
// cout<< "Get detector list from input file --> "; |
1629 |
|
// if(TRK1)cout<<"TRK1 "; |
1630 |
|
// if(TRK2)cout<<"TRK2 "; |
1631 |
|
// if(TRKh)cout<<"TRKH "; |
1632 |
|
// if(CAL1)cout<<"CAL1 "; |
1633 |
|
// if(CAL2)cout<<"CAL2 "; |
1634 |
|
// if(TOF)cout<<"TOF "; |
1635 |
|
// if(TRG)cout<<"TRG "; |
1636 |
|
// if(AC)cout<<"AC "; |
1637 |
|
// if(ND)cout<<"ND "; |
1638 |
|
// if(S4)cout<<"S4 "; |
1639 |
|
// if(ORB)cout<<"ORB "; |
1640 |
|
// cout << endl; |
1641 |
|
|
1642 |
|
return ; |
1643 |
|
|
1644 |
|
}; |
1645 |
|
|
1646 |
|
|
1647 |
//-------------------------------------- |
//-------------------------------------- |
1648 |
// |
// |
1649 |
// |
// |
1655 |
*/ |
*/ |
1656 |
Bool_t PamLevel2::CheckLevel2File(TString name){ |
Bool_t PamLevel2::CheckLevel2File(TString name){ |
1657 |
|
|
1658 |
Bool_t CAL__ok = false; |
Bool_t CAL1__ok = false; |
1659 |
Bool_t TRK__ok = false; |
Bool_t CAL2__ok = false; |
1660 |
Bool_t TRK_L1__ok = false; |
Bool_t TRK2__ok = false; |
1661 |
Bool_t TRG__ok = false; |
Bool_t TRK1__ok = false; |
1662 |
Bool_t TOF__ok = false; |
Bool_t TRKh__ok = false; |
1663 |
Bool_t S4__ok = false; |
Bool_t TRG__ok = false; |
1664 |
Bool_t ND__ok = false; |
Bool_t TOF__ok = false; |
1665 |
Bool_t AC__ok = false; |
Bool_t S4__ok = false; |
1666 |
Bool_t ORB__ok = false; |
Bool_t ND__ok = false; |
1667 |
|
Bool_t AC__ok = false; |
1668 |
|
Bool_t ORB__ok = false; |
1669 |
|
|
1670 |
Bool_t RUN__ok = false; |
Bool_t RUN__ok = false; |
1671 |
|
|
1672 |
// cout << "Checking file: "<<name<<endl; |
|
1673 |
|
|
1674 |
|
cout << "Checking file: "<<name<<endl; |
1675 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
1676 |
if( !f || f->IsZombie() ){ |
if( !f || f->IsZombie() ){ |
1677 |
cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false; |
1678 |
} |
} |
1679 |
// cout << "Get list of keys: "<<f<<endl; |
// cout << "Get list of keys: "<<f<<endl; |
1680 |
TList *lk = f->GetListOfKeys(); |
TList *lk = f->GetListOfKeys(); |
1681 |
// lk->Print(); |
// lk->Print(); |
1682 |
TIter next(lk); |
TIter next(lk); |
1683 |
TKey *key =0; |
TKey *key =0; |
1684 |
Int_t nev =0; |
|
1685 |
Int_t nev_previous =0; |
Int_t nev = 0; |
1686 |
|
|
1687 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
1688 |
|
|
1689 |
nev_previous = nev; |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
1690 |
nev = ((TTree*)f->Get(key->GetName()))->GetEntries(); |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
1691 |
if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
// nev_previous = nev; |
1692 |
cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl; |
// cout << " n.entries "<< nev <<endl; |
1693 |
return false; |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
1694 |
}; |
// nev = ((TTree*)f->Get(key->GetName()))->GetEntries(); |
1695 |
|
// cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl; |
1696 |
|
// return false; |
1697 |
|
// }; |
1698 |
|
|
|
if( !strcmp(key->GetName(),"Calorimeter") )CAL__ok = true; |
|
|
if( !strcmp(key->GetName(),"Trigger" ) )TRG__ok = true; |
|
|
if( !strcmp(key->GetName(),"ToF" ) )TOF__ok = true; |
|
|
if( !strcmp(key->GetName(),"S4" ) )S4__ok = true; |
|
|
if( !strcmp(key->GetName(),"NeutronD" ) )ND__ok = true; |
|
|
if( !strcmp(key->GetName(),"Anticounter") )AC__ok = true; |
|
|
if( !strcmp(key->GetName(),"OrbitalInfo") )ORB__ok = true; |
|
1699 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
1700 |
|
|
1701 |
|
//========================================================= |
1702 |
|
if( !strcmp(key->GetName(),"Trigger" ) ){ |
1703 |
|
TRG__ok = true; |
1704 |
|
if(TRG){ |
1705 |
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
1706 |
|
if( nev && nevt!=nev){ |
1707 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
1708 |
|
return false; |
1709 |
|
} |
1710 |
|
nev=nevt; |
1711 |
|
} |
1712 |
|
} |
1713 |
|
//========================================================= |
1714 |
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
1715 |
|
TOF__ok = true; |
1716 |
|
if(TOF){ |
1717 |
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
1718 |
|
if( nev && nevt!=nev){ |
1719 |
|
cout << "File: "<< f->GetName() <<" discarded ---- ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
1720 |
|
return false; |
1721 |
|
} |
1722 |
|
nev=nevt; |
1723 |
|
} |
1724 |
|
} |
1725 |
|
//========================================================= |
1726 |
|
if( !strcmp(key->GetName(),"S4" ) ){ |
1727 |
|
S4__ok = true; |
1728 |
|
if(S4){ |
1729 |
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
1730 |
|
if( nev && nevt!=nev){ |
1731 |
|
cout << "File: "<< f->GetName() <<" discarded ---- S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
1732 |
|
return false; |
1733 |
|
} |
1734 |
|
nev=nevt; |
1735 |
|
} |
1736 |
|
} |
1737 |
|
//========================================================= |
1738 |
|
|
1739 |
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
1740 |
|
ND__ok = true; |
1741 |
|
if(ND){ |
1742 |
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
1743 |
|
if( nev && nevt!=nev){ |
1744 |
|
cout << "File: "<< f->GetName() <<" discarded ---- NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
1745 |
|
return false; |
1746 |
|
} |
1747 |
|
nev=nevt; |
1748 |
|
} |
1749 |
|
} |
1750 |
|
//========================================================= |
1751 |
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
1752 |
|
AC__ok = true; |
1753 |
|
if(AC){ |
1754 |
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
1755 |
|
if( nev && nevt!=nev){ |
1756 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1757 |
|
return false; |
1758 |
|
} |
1759 |
|
nev=nevt; |
1760 |
|
} |
1761 |
|
} |
1762 |
|
//========================================================= |
1763 |
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
1764 |
|
ORB__ok = true; |
1765 |
|
if(ORB){ |
1766 |
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
1767 |
|
if( nev && nevt!=nev){ |
1768 |
|
cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
1769 |
|
return false; |
1770 |
|
} |
1771 |
|
nev=nevt; |
1772 |
|
} |
1773 |
|
} |
1774 |
|
//========================================================= |
1775 |
if( !strcmp(key->GetName(),"Tracker" ) ){ |
if( !strcmp(key->GetName(),"Tracker" ) ){ |
|
TRK__ok = true; |
|
1776 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
1777 |
|
if(TRK1||TRK2||TRKh){ |
1778 |
|
Int_t nevt = T->GetEntries(); |
1779 |
|
if( nev && nevt!=nev){ |
1780 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
1781 |
|
return false; |
1782 |
|
} |
1783 |
|
nev=nevt; |
1784 |
|
} |
1785 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1786 |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1787 |
if( !name.CompareTo("TrkLevel1") )TRK_L1__ok=true; |
if( !name.CompareTo("TrkLevel1") )TRK1__ok=true; |
1788 |
}; |
if( !name.CompareTo("TrkLevel2") )TRK2__ok=true; |
1789 |
|
if( !name.CompareTo("TrkHough") )TRKh__ok=true; |
1790 |
|
}; |
1791 |
|
T->Delete(); |
1792 |
}; |
}; |
1793 |
|
//========================================================= |
1794 |
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
1795 |
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
1796 |
|
if(CAL1||CAL2){ |
1797 |
|
Int_t nevt = T->GetEntries(); |
1798 |
|
if( nev && nevt!=nev){ |
1799 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
1800 |
|
return false; |
1801 |
|
} |
1802 |
|
nev=nevt; |
1803 |
|
} |
1804 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
1805 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
1806 |
|
if( !name.CompareTo("CaloLevel1") )CAL1__ok=true; |
1807 |
|
if( !name.CompareTo("CaloLevel2") )CAL2__ok=true; |
1808 |
|
}; |
1809 |
|
T->Delete(); |
1810 |
|
}; |
1811 |
|
|
1812 |
}; |
}; |
1813 |
|
|
1814 |
lk->Delete(); |
// cout<< "CheckLevel2File(TString): detector list --> "; |
1815 |
f->Close(); |
// if(TRK1__ok)cout<<"TRK1 "; |
1816 |
|
// if(TRK2__ok)cout<<"TRK2 "; |
1817 |
Bool_t FLAG = true; |
// if(TRKh__ok)cout<<"TRKH "; |
1818 |
|
// if(CAL1__ok)cout<<"CAL1 "; |
1819 |
|
// if(CAL2__ok)cout<<"CAL2 "; |
1820 |
|
// if(TOF__ok)cout<<"TOF "; |
1821 |
|
// if(TRG__ok)cout<<"TRG "; |
1822 |
|
// if(AC__ok)cout<<"AC "; |
1823 |
|
// if(ND__ok)cout<<"ND "; |
1824 |
|
// if(S4__ok)cout<<"S4 "; |
1825 |
|
// if(ORB__ok)cout<<"ORB "; |
1826 |
|
// cout << endl; |
1827 |
|
|
1828 |
|
|
1829 |
|
if(TRK2 && TRK1__ok)TRK1=1; |
1830 |
|
// ---------------------------------------------------------------------------- |
1831 |
|
// NOTA |
1832 |
|
// se c'e` il level1, lo devo necessarimente leggere. |
1833 |
|
// infatti (non ho capito perche`) i cluster vengono letti e allocati in memoria |
1834 |
|
// comunque, ma non vengono disallocati da PamLevel2::Clear() |
1835 |
|
// ---------------------------------------------------------------------------- |
1836 |
|
|
1837 |
|
|
1838 |
if(!RUN__ok) { |
if(!RUN__ok) { |
1839 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing RunInfo tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl; |
1840 |
// FLAG = false; |
// return false; |
1841 |
}; |
}; |
1842 |
if(CAL && !CAL__ok){ |
|
1843 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Calorimeter tree"<< endl; return false; |
if(CAL1 && !CAL1__ok){ |
1844 |
// FLAG = false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel1 branch"<< endl; |
1845 |
}; |
return false; |
|
if(TRK && !TRK__ok){ |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker tree"<< endl; return false; |
|
|
// FLAG = false; |
|
|
}; |
|
|
if(TRK_L1 && !TRK_L1__ok){ |
|
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker Level1 Branch"<< endl; return false; |
|
|
// FLAG = false; |
|
1846 |
}; |
}; |
1847 |
if(TRG && !TRG__ok){ |
if(CAL2 && !CAL2__ok){ |
1848 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel2 branch"<< endl; |
1849 |
// FLAG = false; |
return false; |
1850 |
}; |
}; |
1851 |
if(TOF && !TOF__ok){ |
if(TRK2 && !TRK2__ok){ |
1852 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel2 branch"<< endl; |
1853 |
// FLAG = false; |
return false; |
1854 |
}; |
}; |
1855 |
if(S4 && !S4__ok){ |
if(TRK1 && !TRK1__ok){ |
1856 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel1 branch"<< endl; |
1857 |
// FLAG = false; |
return false; |
1858 |
}; |
}; |
1859 |
if(ND && !ND__ok){ |
if(TRKh && !TRKh__ok){ |
1860 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkHough branch"<< endl; |
1861 |
// FLAG = false; |
return false; |
1862 |
|
}; |
1863 |
|
if(ORB && !ORB__ok){ |
1864 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl; |
1865 |
|
return false; |
1866 |
}; |
}; |
1867 |
if(AC && !AC__ok){ |
if(AC && !AC__ok){ |
1868 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl; |
1869 |
// FLAG = false; |
return false; |
1870 |
}; |
}; |
1871 |
if(ORB && !ORB__ok){ |
if(S4 && !S4__ok){ |
1872 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl; return false; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl; |
1873 |
// FLAG = false; |
return false; |
1874 |
|
}; |
1875 |
|
if(TOF && !TOF__ok){ |
1876 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl; |
1877 |
|
return false; |
1878 |
|
}; |
1879 |
|
|
1880 |
|
if(ND && !ND__ok){ |
1881 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
1882 |
|
return false; |
1883 |
|
}; |
1884 |
|
if(TRG && !TRG__ok){ |
1885 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
1886 |
|
return false; |
1887 |
}; |
}; |
1888 |
|
|
1889 |
return FLAG; |
|
1890 |
|
// lk->Delete(); |
1891 |
|
// delete lk; |
1892 |
|
f->Close(); |
1893 |
|
|
1894 |
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
1895 |
|
// if(TRK1)cout<<"TRK1 "; |
1896 |
|
// if(TRK2)cout<<"TRK2 "; |
1897 |
|
// if(TRKh)cout<<"TRKH "; |
1898 |
|
// if(CAL1)cout<<"CAL1 "; |
1899 |
|
// if(CAL2)cout<<"CAL2 "; |
1900 |
|
// if(TOF)cout<<"TOF "; |
1901 |
|
// if(TRG)cout<<"TRG "; |
1902 |
|
// if(AC)cout<<"AC "; |
1903 |
|
// if(ND)cout<<"ND "; |
1904 |
|
// if(S4)cout<<"S4 "; |
1905 |
|
// if(ORB)cout<<"ORB "; |
1906 |
|
// cout << endl; |
1907 |
|
|
1908 |
|
return true; |
1909 |
|
|
1910 |
}; |
}; |
1911 |
|
|
1912 |
|
|
1913 |
|
/** |
1914 |
|
* Create clone-trees |
1915 |
|
*/ |
1916 |
|
void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ |
1917 |
|
|
1918 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1919 |
|
cout << "Create clones of PAMELA trees "<<endl; |
1920 |
|
|
1921 |
|
Int_t i=0; |
1922 |
|
tree_clone[i] = fChain->GetTree()->CloneTree(0); |
1923 |
|
TString name = tree_clone[i]->GetName(); |
1924 |
|
name.Append("_clone"); |
1925 |
|
// tree_clone[i]->SetName(name.Data()); |
1926 |
|
cout << tree_clone[i]->GetName() <<endl; |
1927 |
|
i++; |
1928 |
|
|
1929 |
|
TList *li = fChain->GetListOfFriends(); |
1930 |
|
TIter next(li); |
1931 |
|
TFriendElement* T_friend=0; |
1932 |
|
ofile->cd(); |
1933 |
|
while( (T_friend = (TFriendElement*)next()) ){ |
1934 |
|
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
1935 |
|
// cout<<T_friend->GetTree()->GetName()<< endl; |
1936 |
|
tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
1937 |
|
tree_clone[i]->SetAutoSave(1000000); |
1938 |
|
name = tree_clone[i]->GetName(); |
1939 |
|
name.Append("_clone"); |
1940 |
|
// tree_clone[i]->SetName(name.Data()); |
1941 |
|
cout << tree_clone[i]->GetName() << endl; |
1942 |
|
i++; |
1943 |
|
} |
1944 |
|
|
1945 |
|
delete li; |
1946 |
|
|
1947 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1948 |
|
|
1949 |
|
} |
1950 |
|
|
1951 |
|
/** |
1952 |
|
* Create clone-trees |
1953 |
|
*/ |
1954 |
|
void PamLevel2::CreateCloneTrees(TFile *ofile){ |
1955 |
|
|
1956 |
|
ofile->cd(); |
1957 |
|
|
1958 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1959 |
|
cout << "Create new PAMELA trees "<<endl; |
1960 |
|
|
1961 |
|
Int_t i=0; |
1962 |
|
|
1963 |
|
if(TRK1||TRK2||TRKh){ |
1964 |
|
tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
1965 |
|
if(TRK1) { |
1966 |
|
tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
1967 |
|
tree_clone[i]->BranchRef(); |
1968 |
|
cout << "Tracker : branch TrkLevel1"<<endl; |
1969 |
|
}; |
1970 |
|
if(TRK2) { |
1971 |
|
tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
1972 |
|
cout << "Tracker : branch TrkLevel2"<<endl; |
1973 |
|
}; |
1974 |
|
if(TRKh) { |
1975 |
|
tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
1976 |
|
cout << "Tracker : branch TrkHough"<<endl; |
1977 |
|
}; |
1978 |
|
i++; |
1979 |
|
} |
1980 |
|
|
1981 |
|
// Calorimeter |
1982 |
|
if(CAL1||CAL2){ |
1983 |
|
tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
1984 |
|
if(CAL1) { |
1985 |
|
tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
1986 |
|
cout << "Calorimeter : branch CaloLevel1"<<endl; |
1987 |
|
}; |
1988 |
|
if(CAL2) { |
1989 |
|
tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
1990 |
|
cout << "Calorimeter : branch CaloLevel2"<<endl; |
1991 |
|
}; |
1992 |
|
i++; |
1993 |
|
} |
1994 |
|
|
1995 |
|
// ToF |
1996 |
|
if(TOF) { |
1997 |
|
tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
1998 |
|
tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
1999 |
|
cout << "ToF : branch ToFLevel2"<<endl; |
2000 |
|
i++; |
2001 |
|
}; |
2002 |
|
// Trigger |
2003 |
|
if(TRG) { |
2004 |
|
tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
2005 |
|
tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
2006 |
|
cout << "Trigger : branch TrigLevel2"<<endl; |
2007 |
|
i++; |
2008 |
|
}; |
2009 |
|
// S4 |
2010 |
|
if(S4) { |
2011 |
|
tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
2012 |
|
tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
2013 |
|
cout << "S4 : branch S4Level2"<<endl; |
2014 |
|
i++; |
2015 |
|
}; |
2016 |
|
// Neutron Detector |
2017 |
|
if(ND) { |
2018 |
|
tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
2019 |
|
tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
2020 |
|
cout << "NeutronD : branch NDLevel2"<<endl; |
2021 |
|
i++; |
2022 |
|
}; |
2023 |
|
// Anticounters |
2024 |
|
if(AC) { |
2025 |
|
tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
2026 |
|
tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
2027 |
|
cout << "Anticounter : branch AcLevel2"<<endl; |
2028 |
|
i++; |
2029 |
|
}; |
2030 |
|
// OrbitalInfo |
2031 |
|
if(ORB) { |
2032 |
|
tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
2033 |
|
tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
2034 |
|
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
2035 |
|
i++; |
2036 |
|
}; |
2037 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2038 |
|
|
2039 |
|
} |
2040 |
|
|
2041 |
|
|
2042 |
|
/** |
2043 |
|
* Fill tree (created with CreateCloneTrees) |
2044 |
|
* |
2045 |
|
*/ |
2046 |
|
//void PamLevel2::FillNewPamTree(TTree *T){ |
2047 |
|
void PamLevel2::FillCloneTrees(){ |
2048 |
|
|
2049 |
|
for(Int_t i=0; i<8; i++){ |
2050 |
|
if(tree_clone[i])tree_clone[i]->Fill(); |
2051 |
|
} |
2052 |
|
} |
2053 |
|
|
2054 |
|
|
2055 |
|
TTree* PamLevel2::GetCloneTree(TString name){ |
2056 |
|
|
2057 |
|
for(Int_t i=0; i<8; i++){ |
2058 |
|
if(tree_clone[i]){ |
2059 |
|
TString na = tree_clone[i]->GetName(); |
2060 |
|
if(!name.CompareTo(na))return tree_clone[i]; |
2061 |
|
}; |
2062 |
|
} |
2063 |
|
return NULL; |
2064 |
|
|
2065 |
|
} |
2066 |
|
void PamLevel2::WriteCloneTrees(){ |
2067 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2068 |
|
cout << "Write clones of PAMELA trees "<<endl; |
2069 |
|
for(Int_t i=0; i<8; i++){ |
2070 |
|
if(tree_clone[i]){ |
2071 |
|
cout << tree_clone[i]->GetName()<<endl; |
2072 |
|
tree_clone[i]->Write(); |
2073 |
|
}; |
2074 |
|
} |
2075 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2076 |
|
|
2077 |
|
} |
2078 |
|
|
2079 |
|
/** |
2080 |
|
* Create a new (empty) Pamela trees |
2081 |
|
*/ |
2082 |
|
// TTree* PamLevel2::GetNewPamTree(){ |
2083 |
|
|
2084 |
|
// if(tree_clone)return tree_clone; |
2085 |
|
|
2086 |
|
// TTree *Tout = 0; |
2087 |
|
|
2088 |
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2089 |
|
// cout << "Create new PAMELA trees "<<endl; |
2090 |
|
|
2091 |
|
|
2092 |
|
// if(TRK1||TRK2||TRKh){ |
2093 |
|
// TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
2094 |
|
// if(TRK1) { |
2095 |
|
// trk1_clone = new TrkLevel1(); |
2096 |
|
// T->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
2097 |
|
// T->BranchRef(); |
2098 |
|
// cout << "Tracker : branch TrkLevel1"<<endl; |
2099 |
|
// }; |
2100 |
|
// if(TRK2) { |
2101 |
|
// trk2_clone = new TrkLevel2(); |
2102 |
|
// T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
2103 |
|
// cout << "Tracker : branch TrkLevel2"<<endl; |
2104 |
|
// }; |
2105 |
|
// if(TRKh) { |
2106 |
|
// trkh_clone = new TrkHough(); |
2107 |
|
// T->Branch("TrkHough","TrkHough", &trkh_clone); |
2108 |
|
// cout << "Tracker : branch TrkHough"<<endl; |
2109 |
|
// }; |
2110 |
|
// if(!Tout)Tout=T; |
2111 |
|
// else Tout->AddFriend("Tracker_clone"); |
2112 |
|
// } |
2113 |
|
|
2114 |
|
// // Calorimeter |
2115 |
|
// if(CAL1||CAL2){ |
2116 |
|
// TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
2117 |
|
// if(CAL1) { |
2118 |
|
// calo1_clone = new CaloLevel1(); |
2119 |
|
// C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
2120 |
|
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
2121 |
|
// }; |
2122 |
|
// if(CAL2) { |
2123 |
|
// calo2_clone = new CaloLevel2(); |
2124 |
|
// C->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
2125 |
|
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
2126 |
|
// }; |
2127 |
|
// if(!Tout)Tout=C; |
2128 |
|
// else Tout->AddFriend("Calorimeter_clone"); |
2129 |
|
// } |
2130 |
|
|
2131 |
|
// // ToF |
2132 |
|
// if(TOF) { |
2133 |
|
// TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data "); |
2134 |
|
// tof_clone = new ToFLevel2(); |
2135 |
|
// O->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
2136 |
|
// cout << "ToF : branch ToFLevel2"<<endl; |
2137 |
|
// if(!Tout)Tout=O; |
2138 |
|
// else Tout->AddFriend("ToF_clone"); |
2139 |
|
// }; |
2140 |
|
// // Trigger |
2141 |
|
// if(TRG) { |
2142 |
|
// TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
2143 |
|
// trig_clone = new TrigLevel2(); |
2144 |
|
// R->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
2145 |
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
2146 |
|
// if(!Tout)Tout=R; |
2147 |
|
// else Tout->AddFriend("Trigger_clone"); |
2148 |
|
// }; |
2149 |
|
// // S4 |
2150 |
|
// if(S4) { |
2151 |
|
// TTree *S = new TTree("S4_clone","PAMELA S4 level2 data "); |
2152 |
|
// s4_clone = new S4Level2(); |
2153 |
|
// S->Branch("S4Level2","S4Level2", &s4_clone); |
2154 |
|
// cout << "S4 : branch S4Level2"<<endl; |
2155 |
|
// if(!Tout)Tout=S; |
2156 |
|
// else Tout->AddFriend("S4_clone"); |
2157 |
|
// }; |
2158 |
|
// // Neutron Detector |
2159 |
|
// if(ND) { |
2160 |
|
// TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
2161 |
|
// nd_clone = new NDLevel2(); |
2162 |
|
// N->Branch("NDLevel2","NDLevel2", &nd_clone); |
2163 |
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
2164 |
|
// if(!Tout)Tout=N; |
2165 |
|
// else Tout->AddFriend("NeutronD_clone"); |
2166 |
|
// }; |
2167 |
|
// // Anticounters |
2168 |
|
// if(AC) { |
2169 |
|
// TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
2170 |
|
// ac_clone = new AcLevel2(); |
2171 |
|
// A->Branch("AcLevel2","AcLevel2", &ac_clone); |
2172 |
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
2173 |
|
// if(!Tout)Tout=A; |
2174 |
|
// else Tout->AddFriend("Anticounter_clone"); |
2175 |
|
// }; |
2176 |
|
// // OrbitalInfo |
2177 |
|
// if(ORB) { |
2178 |
|
// TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
2179 |
|
// orb_clone = new OrbitalInfo(); |
2180 |
|
// B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
2181 |
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
2182 |
|
// if(!Tout)Tout=B; |
2183 |
|
// else Tout->AddFriend("OrbitalInfo_clone"); |
2184 |
|
// }; |
2185 |
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2186 |
|
|
2187 |
|
// tree_clone = Tout; |
2188 |
|
// tree_clone->SetDirectory(0); |
2189 |
|
|
2190 |
|
// return Tout; |
2191 |
|
// } |
2192 |
|
// /** |
2193 |
|
// * Fill a tree (created with GetNewPamTree) |
2194 |
|
// * |
2195 |
|
// */ |
2196 |
|
// //void PamLevel2::FillNewPamTree(TTree *T){ |
2197 |
|
// void PamLevel2::FillNewPamTree(){ |
2198 |
|
|
2199 |
|
|
2200 |
|
// if(trk1_clone) *trk1_clone = *trk1_obj; |
2201 |
|
// if(trk2_clone){ |
2202 |
|
// trk2_clone->Clear(); |
2203 |
|
// trk2_obj->Copy(*trk2_clone); |
2204 |
|
// // *trk2_clone = *trk2_obj; |
2205 |
|
// } |
2206 |
|
// if(trkh_clone) *trkh_clone = *trkh_obj; |
2207 |
|
// if(calo1_clone){ |
2208 |
|
// // *calo1_clone = *calo1_obj; |
2209 |
|
// calo1_clone->Clear(); |
2210 |
|
// calo1_obj->Copy(*calo1_clone); |
2211 |
|
// } |
2212 |
|
// if(calo2_clone){ |
2213 |
|
// // *calo2_clone = *calo2_obj; |
2214 |
|
// calo2_clone->Clear(); |
2215 |
|
// calo2_obj->Copy(*calo2_clone); |
2216 |
|
// } |
2217 |
|
// if(tof_clone) *tof_clone = *tof_obj; |
2218 |
|
// if(trig_clone) *trig_clone = *trig_obj; |
2219 |
|
// if(s4_clone) *s4_clone = *s4_obj; |
2220 |
|
// if(nd_clone) *nd_clone = *nd_obj; |
2221 |
|
// if(ac_clone) *ac_clone = *ac_obj; |
2222 |
|
// if(orb_clone) *orb_clone = *orb_obj; |
2223 |
|
|
2224 |
|
// TTree *T = tree_clone; |
2225 |
|
|
2226 |
|
// T->Fill(); //fill main tree |
2227 |
|
// // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl; |
2228 |
|
// TList *li = T->GetListOfFriends(); |
2229 |
|
// TIter next(li); |
2230 |
|
// TFriendElement* T_friend=0; |
2231 |
|
// while( (T_friend = (TFriendElement*)next()) ){ |
2232 |
|
// // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
2233 |
|
// T_friend->GetTree()->Fill();//fill friends |
2234 |
|
// } |
2235 |
|
|
2236 |
|
// } |