24 |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
25 |
if(t) *trk_track = *t; |
if(t) *trk_track = *t; |
26 |
if(c) *calo_track = *c; |
if(c) *calo_track = *c; |
27 |
if(o) *tof_track = *o; |
if(o) *tof_track = *o; |
28 |
}; |
}; |
29 |
|
|
30 |
//-------------------------------------- |
//-------------------------------------- |
36 |
*/ |
*/ |
37 |
PamLevel2::PamLevel2(){ |
PamLevel2::PamLevel2(){ |
38 |
|
|
39 |
trk_obj = this->TrkLevel2::GetTrkLevel2(); |
trk_l1_obj = this->TrkLevel1::GetTrkLevel1(); |
40 |
calo_obj = this->CaloLevel2::GetCaloLevel2(); |
trk_obj = this->TrkLevel2::GetTrkLevel2(); |
41 |
tof_obj = this->ToFLevel2::GetToFLevel2(); |
calo_obj = this->CaloLevel2::GetCaloLevel2(); |
42 |
trig_obj = this->TrigLevel2::GetTrigLevel2(); |
tof_obj = this->ToFLevel2::GetToFLevel2(); |
43 |
s4_obj = this->S4Level2::GetS4Level2(); |
trig_obj = this->TrigLevel2::GetTrigLevel2(); |
44 |
nd_obj = this->NDLevel2::GetNDLevel2(); |
s4_obj = this->S4Level2::GetS4Level2(); |
45 |
ac_obj = this->AcLevel2::GetAcLevel2(); |
nd_obj = this->NDLevel2::GetNDLevel2(); |
46 |
orb_obj = this->OrbitalInfo::GetOrbitalInfo(); |
ac_obj = this->AcLevel2::GetAcLevel2(); |
47 |
|
orb_obj = this->OrbitalInfo::GetOrbitalInfo(); |
48 |
|
|
49 |
|
run_obj = new GL_RUN(); |
50 |
|
|
51 |
sorted_tracks = new TRefArray(); |
sorted_tracks = new TRefArray(); |
52 |
|
|
53 |
CAL = true; |
CAL = true; |
59 |
AC = true; |
AC = true; |
60 |
ORB = true; |
ORB = true; |
61 |
|
|
62 |
|
TRK_L1 = false; |
63 |
|
|
64 |
|
Tout = NULL; |
65 |
}; |
}; |
66 |
/** |
/** |
67 |
* Destructor |
* Destructor |
68 |
*/ |
*/ |
69 |
PamLevel2::~PamLevel2(){ |
PamLevel2::~PamLevel2(){ |
70 |
|
|
71 |
delete sorted_tracks; |
TrkLevel1::Clear(); |
72 |
|
|
73 |
|
TrkLevel2::Clear(); |
74 |
|
CaloLevel2::Clear(); |
75 |
|
ToFLevel2::Clear(); |
76 |
|
TrigLevel2::Clear(); |
77 |
|
S4Level2::Clear(); |
78 |
|
NDLevel2::Clear(); |
79 |
|
AcLevel2::Clear(); |
80 |
|
OrbitalInfo::Clear(); |
81 |
|
|
82 |
|
delete run_obj; |
83 |
|
|
84 |
|
// delete sorted_tracks; |
85 |
|
sorted_tracks->Delete(); // clean the reference array |
86 |
|
|
87 |
|
if(Tout)Tout->Delete(); // delete loaded tree from memory |
88 |
|
|
89 |
}; |
}; |
90 |
/** |
/** |
91 |
* Clear the event |
* Clear the event |
92 |
*/ |
*/ |
93 |
void PamLevel2::Clear(){ |
void PamLevel2::Clear(){ |
94 |
|
|
95 |
sorted_tracks->Delete(); |
TrkLevel1::Clear(); |
96 |
|
|
97 |
|
TrkLevel2::Clear(); |
98 |
|
CaloLevel2::Clear(); |
99 |
|
ToFLevel2::Clear(); |
100 |
|
TrigLevel2::Clear(); |
101 |
|
S4Level2::Clear(); |
102 |
|
NDLevel2::Clear(); |
103 |
|
AcLevel2::Clear(); |
104 |
|
OrbitalInfo::Clear(); |
105 |
|
|
106 |
|
sorted_tracks->Delete(); // clean the reference array |
107 |
|
|
108 |
}; |
}; |
109 |
|
|
113 |
// |
// |
114 |
//-------------------------------------- |
//-------------------------------------- |
115 |
/** |
/** |
116 |
|
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
117 |
|
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
118 |
|
*/ |
119 |
|
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
120 |
|
|
121 |
|
if( CaloLevel2::ntrk()==0 ){ |
122 |
|
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
123 |
|
return NULL; |
124 |
|
}; |
125 |
|
|
126 |
|
CaloTrkVar *c = 0; |
127 |
|
Int_t it_calo=0; |
128 |
|
|
129 |
|
do{ |
130 |
|
c = CaloLevel2::GetCaloTrkVar(it_calo); |
131 |
|
it_calo++; |
132 |
|
} while( seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
133 |
|
|
134 |
|
if(seqno != c->trkseqno){ |
135 |
|
c = 0; |
136 |
|
if(seqno!=-1)cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match Calorimeter stored tracks"<<endl; |
137 |
|
}; |
138 |
|
return c; |
139 |
|
|
140 |
|
}; |
141 |
|
//-------------------------------------- |
142 |
|
// |
143 |
|
// |
144 |
|
//-------------------------------------- |
145 |
|
/** |
146 |
|
* Retrieves the ToF track matching the seqno-th tracker stored track. |
147 |
|
* (If seqno = -1 retrieves the tracker-independent tof track) |
148 |
|
*/ |
149 |
|
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
150 |
|
|
151 |
|
if( ToFLevel2::ntrk()==0 ){ |
152 |
|
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
153 |
|
return NULL; |
154 |
|
}; |
155 |
|
|
156 |
|
ToFTrkVar *c = 0; |
157 |
|
Int_t it_tof=0; |
158 |
|
|
159 |
|
do{ |
160 |
|
c = ToFLevel2::GetToFTrkVar(it_tof); |
161 |
|
it_tof++; |
162 |
|
} while( seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); |
163 |
|
|
164 |
|
if(seqno != c->trkseqno){ |
165 |
|
c = 0; |
166 |
|
if(seqno!=-1)cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match ToF stored tracks"<<endl; |
167 |
|
}; |
168 |
|
return c; |
169 |
|
|
170 |
|
}; |
171 |
|
|
172 |
|
//-------------------------------------- |
173 |
|
// |
174 |
|
// |
175 |
|
//-------------------------------------- |
176 |
|
/** |
177 |
|
* Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. |
178 |
|
*/ |
179 |
|
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
180 |
|
|
181 |
|
CaloTrkVar *c = 0; |
182 |
|
ToFTrkVar *o = 0; |
183 |
|
|
184 |
|
if(CAL) c = GetCaloStoredTrack(t->GetSeqNo()); |
185 |
|
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
186 |
|
|
187 |
|
// if(t && c && o)track = new PamTrack(t,c,o); |
188 |
|
PamTrack *track = new PamTrack(t,c,o); |
189 |
|
|
190 |
|
return track; |
191 |
|
|
192 |
|
}; |
193 |
|
//-------------------------------------- |
194 |
|
// |
195 |
|
// |
196 |
|
//-------------------------------------- |
197 |
|
/** |
198 |
* Retrieves the it-th stored track. |
* Retrieves the it-th stored track. |
199 |
* It override TrkLevel2::GetTrack(int it). |
* It override TrkLevel2::GetTrack(int it). |
200 |
* @param itrk Track number, ranging from 0 to GetNTracks(). |
* @param itrk Track number, ranging from 0 to GetNTracks(). |
202 |
|
|
203 |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
204 |
|
|
205 |
TrkTrack *t = 0; |
PamTrack *track = 0; |
206 |
CaloTrkVar *c = 0; |
|
207 |
ToFTrkVar *o = 0; |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
208 |
|
|
209 |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); |
210 |
t = TrkLevel2::GetStoredTrack(itrk); |
track = GetPamTrackAlong(t); |
211 |
/* c = CaloLevel2::GetCaloTrkVar(t->GetSeqNo()); |
|
|
o = ToFLevel2::GetToFTrkVar(t->GetSeqNo()); */ |
|
|
Int_t it_calo=0; |
|
|
do{ |
|
|
c = CaloLevel2::GetCaloTrkVar(it_calo); |
|
|
it_calo++; |
|
|
} while(t->GetSeqNo() != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != c->trkseqno )cout << "PamLevel2::GetStoredTrack(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match Calorimeter SeqNo"<< c->trkseqno<<endl; |
|
|
|
|
|
Int_t it_tof=0; |
|
|
do{ |
|
|
o = ToFLevel2::GetToFTrkVar(it_tof); |
|
|
it_tof++; |
|
|
} while(t->GetSeqNo() != o->trkseqno && it_tof < ToFLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != o->trkseqno )cout << "PamLevel2::GetStoredTrack(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match ToF SeqNo "<< o->trkseqno <<endl; |
|
|
|
|
212 |
}else{ |
}else{ |
213 |
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() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
214 |
}; |
}; |
215 |
|
|
216 |
// hence create a "PamTrack" object |
return track; |
|
PamTrack *track = 0; |
|
|
if(t && c && o)track = new PamTrack(t,c,o); |
|
|
return track; |
|
217 |
|
|
218 |
} |
} |
219 |
//-------------------------------------- |
//-------------------------------------- |
221 |
// |
// |
222 |
//-------------------------------------- |
//-------------------------------------- |
223 |
/** |
/** |
224 |
* Sort physical (tracker) tracks and stores them in a TObjectArray (of TrkTrack objects). |
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. |
225 |
* The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
226 |
|
* Sorting cryteria: |
227 |
|
* TRK: lower chi**2 |
228 |
|
* CAL: lower Y spatial residual on the first calorimeter plane |
229 |
|
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
230 |
|
* The default sorting cryterium is "TOF+CAL". |
231 |
|
* |
232 |
|
* The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how). |
233 |
*/ |
*/ |
234 |
void PamLevel2::SortTracks(){ |
void PamLevel2::SortTracks(TString how){ |
235 |
|
|
236 |
sorted_tracks->Delete(); //temporaneo |
//Save current Object count |
237 |
|
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
238 |
|
|
239 |
|
sorted_tracks->Delete(); //temporaneo??? |
240 |
|
|
241 |
// loop over the tracks sorted by the tracker |
// loop over the tracks sorted by the tracker |
242 |
|
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
243 |
|
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
244 |
|
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
245 |
|
|
246 |
|
if( !CAL && use_CAL) use_CAL = false; |
247 |
|
if( !TOF && use_TOF) use_TOF = false; |
248 |
|
|
249 |
|
if( !TRK ){ |
250 |
|
cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
251 |
|
return; |
252 |
|
}; |
253 |
|
|
254 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
255 |
|
|
256 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
257 |
|
|
258 |
// get tracker tracks |
// get tracker tracks |
259 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
260 |
CaloTrkVar *cp = CaloLevel2::GetCaloTrkVar(tp->GetSeqNo()); //calorimeter |
// CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
261 |
ToFTrkVar *op = ToFLevel2::GetToFTrkVar(tp->GetSeqNo()); //tof |
// ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
262 |
|
CaloTrkVar *cp = 0; |
263 |
|
ToFTrkVar *op = 0; |
264 |
|
|
265 |
// if track has an image, check image selection |
// if track has an image, check image selection |
266 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
267 |
|
|
268 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
269 |
CaloTrkVar *ci = CaloLevel2::GetCaloTrkVar(ti->GetSeqNo());//calorimeter (image) |
// CaloTrkVar *ci = GetCaloStoredTrack(ti->GetSeqNo()); |
270 |
ToFTrkVar *oi = ToFLevel2::GetToFTrkVar(ti->GetSeqNo()); //tof (image) |
// ToFTrkVar *oi = GetToFStoredTrack(ti->GetSeqNo()); |
271 |
|
CaloTrkVar *ci = 0; |
272 |
|
ToFTrkVar *oi = 0; |
273 |
|
|
274 |
//assign starting scores |
//assign starting scores |
275 |
Int_t tp_score = 1; //"principal" track, sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
276 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
277 |
|
|
278 |
// ------------------------ |
// ------------------------ |
279 |
// calorimeter check |
// calorimeter check |
280 |
// ------------------------ |
// ------------------------ |
281 |
|
// check the Y spatial residual on the first calorimeter plane |
282 |
|
// (cut on calorimeter variables from Emiliano) |
283 |
if( |
if( |
284 |
npcfit[1] > 3 && //no. of fit planes on Y view |
use_CAL && |
285 |
// varcfit[1] < 50.&& //fit variance on Y view |
npcfit[1] > 15 && //no. of fit planes on Y view |
286 |
true){ |
varcfit[1] < 1000. && //fit variance on Y view |
287 |
|
true){ |
288 |
Float_t resy_p = cp->tbar[0][1] - cbar[0][1];if(resy_p < 0)resy_p= - resy_p; |
|
289 |
Float_t resy_i = ci->tbar[0][1] - cbar[0][1];if(resy_i < 0)resy_i= - resy_i; |
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
290 |
|
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
291 |
|
|
292 |
|
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
293 |
|
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
294 |
|
|
295 |
if(resy_p <= resy_i) tp_score++; |
if(resy_p <= resy_i) tp_score++; |
296 |
else ti_score++; |
else ti_score++; |
298 |
// ------------------------ |
// ------------------------ |
299 |
// TOF check |
// TOF check |
300 |
// ------------------------ |
// ------------------------ |
301 |
|
// check the number of hit pmts along the track |
302 |
|
// on S12 S21 and S32, where paddles are parallel to Y axis |
303 |
|
if( use_TOF ){ |
304 |
|
|
305 |
|
Int_t nphit_p =0; |
306 |
|
Int_t nphit_i =0; |
307 |
|
|
308 |
|
op = GetToFStoredTrack(tp->GetSeqNo()); |
309 |
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
310 |
|
|
311 |
|
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
312 |
|
cout << "track: npmttdc "<< op->npmttdc << endl; |
313 |
|
cout << "image: npmtadc "<< oi->npmtadc << endl; |
314 |
|
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
315 |
|
|
316 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
317 |
|
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
318 |
|
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
319 |
|
}; |
320 |
|
|
321 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
322 |
|
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
323 |
|
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
324 |
|
}; |
325 |
|
|
326 |
|
if( |
327 |
|
use_TOF && |
328 |
|
(nphit_p+nphit_i) !=0 && |
329 |
|
true){ |
330 |
|
|
331 |
|
if( nphit_p >= nphit_i) tp_score++; |
332 |
|
else ti_score++; |
333 |
|
}; |
334 |
|
}; |
335 |
|
if(tp_score == ti_score) use_TRK = true; |
336 |
|
// ------------------------ |
337 |
|
// tracker check |
338 |
|
// ------------------------ |
339 |
|
// chi**2 difference is not always large enough to distinguish among |
340 |
|
// the real track and its image. |
341 |
|
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
342 |
|
if(use_TRK){ |
343 |
|
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
344 |
|
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
345 |
|
}; |
346 |
|
|
347 |
// ------------------------ |
// ------------------------ |
348 |
// the winner is.... |
// the winner is.... |
349 |
// ------------------------ |
// ------------------------ |
350 |
if(tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
351 |
else ts = ti;//its image!! |
else if (tp_score < ti_score) ts = ti;//its image!! |
352 |
|
else { |
353 |
|
ts = tp; |
354 |
|
// cout << "Warning - track image ambiguity not solved" << endl; |
355 |
|
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
356 |
|
}; |
357 |
|
|
358 |
}else{ |
}else{ |
359 |
ts = tp; |
ts = tp; |
360 |
}; |
}; |
361 |
|
|
362 |
|
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
363 |
sorted_tracks->Add(ts);//save the track in the sorted array |
sorted_tracks->Add(ts);//save the track in the sorted array |
364 |
|
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
365 |
|
|
366 |
}; |
}; |
367 |
|
//Restore Object count |
368 |
|
//To save space in the table keeping track of all referenced objects |
369 |
|
//we assume that our events do not address each other. We reset the |
370 |
|
//object count to what it was at the beginning of the event. |
371 |
|
TProcessID::SetObjectCount(ObjectNumber); |
372 |
|
|
373 |
}; |
}; |
374 |
//-------------------------------------- |
//-------------------------------------- |
380 |
* 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. |
381 |
*/ |
*/ |
382 |
TRefArray *PamLevel2::GetTracks(){ |
TRefArray *PamLevel2::GetTracks(){ |
383 |
// if(!sorted_tracks->GetEntries()) SortTracks(); |
// |
384 |
SortTracks(); |
// SortTracks("+CAL+TOF"); |
385 |
|
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
386 |
|
// |
387 |
return sorted_tracks; |
return sorted_tracks; |
388 |
}; |
}; |
389 |
//-------------------------------------- |
//-------------------------------------- |
390 |
// |
// |
391 |
// |
// |
392 |
//-------------------------------------- |
//-------------------------------------- |
393 |
/** |
/** |
394 |
* Retrieves the it-th Pamela "physical" track. |
* Retrieves the it-th Pamela "physical" track. |
396 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
397 |
*/ |
*/ |
398 |
PamTrack *PamLevel2::GetTrack(int it){ |
PamTrack *PamLevel2::GetTrack(int it){ |
|
|
|
|
SortTracks(); |
|
399 |
|
|
400 |
TrkTrack *t = 0; |
// *-*-*-*-*-*-* |
401 |
CaloTrkVar *c = 0; |
// SortTracks("+CAL+TOF"); |
402 |
ToFTrkVar *o = 0; |
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
403 |
|
// *-*-*-*-*-*-* |
404 |
|
|
405 |
|
PamTrack *track = 0; |
406 |
|
|
407 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
408 |
|
TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); |
409 |
t = (TrkTrack*)sorted_tracks->At(it); |
// cout << "GetTrack(int it):: sorted_tracks->At(it) "<<it<<" "<<t<<endl; |
410 |
|
track = GetPamTrackAlong(t); |
|
Int_t it_calo=0; |
|
|
do{ |
|
|
c = CaloLevel2::GetCaloTrkVar(it_calo); |
|
|
it_calo++; |
|
|
} while(t->GetSeqNo() != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != c->trkseqno )cout << "PamLevel2::GetTrack(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match Calorimeter SeqNo"<< c->trkseqno<<endl; |
|
|
|
|
|
Int_t it_tof=0; |
|
|
do{ |
|
|
o = ToFLevel2::GetToFTrkVar(it_tof); |
|
|
it_tof++; |
|
|
} while(t->GetSeqNo() != o->trkseqno && it_tof < ToFLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != o->trkseqno )cout << "PamLevel2::GetTrack(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match ToF SeqNo "<< o->trkseqno <<endl; |
|
|
|
|
411 |
}else{ |
}else{ |
412 |
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() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
413 |
}; |
}; |
|
|
|
|
// hence create a "PamTrack" object |
|
|
PamTrack *track = 0; |
|
|
if(t && c && o)track = new PamTrack(t,c,o); |
|
414 |
|
|
415 |
return track; |
return track; |
416 |
|
|
417 |
}; |
}; |
418 |
|
|
419 |
//-------------------------------------- |
//-------------------------------------- |
420 |
// |
// |
421 |
// |
// |
422 |
//-------------------------------------- |
//-------------------------------------- |
423 |
/** |
/** |
424 |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::GetTracks(). |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
425 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
426 |
*/ |
*/ |
427 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
PamTrack *PamLevel2::GetTrackImage(int it){ |
428 |
|
|
429 |
// if(!sorted_tracks->GetEntries()) SortTracks(); |
// SortTracks("+CAL+TOF"); |
430 |
SortTracks(); |
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
431 |
|
|
432 |
TrkTrack *t = 0; |
PamTrack *image = 0; |
|
CaloTrkVar *c = 0; |
|
|
ToFTrkVar *o = 0; |
|
433 |
|
|
434 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
435 |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
436 |
if( temp->HasImage() ){ |
if( temp->HasImage() ){ |
437 |
|
TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
438 |
t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
image = GetPamTrackAlong(t); |
|
|
|
|
/* c = CaloLevel2::GetCaloTrkVar(temp->GetImageSeqNo()); |
|
|
o = ToFLevel2::GetToFTrkVar(temp->GetImageSeqNo());*/ |
|
|
|
|
|
Int_t it_calo=0; |
|
|
do{ |
|
|
c = CaloLevel2::GetCaloTrkVar(it_calo); |
|
|
it_calo++; |
|
|
} while(t->GetSeqNo() != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != c->trkseqno )cout << "PamLevel2::GetTrackImage(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match Calorimeter SeqNo"<< c->trkseqno<<endl; |
|
|
|
|
|
Int_t it_tof=0; |
|
|
do{ |
|
|
o = ToFLevel2::GetToFTrkVar(it_tof); |
|
|
it_tof++; |
|
|
} while(t->GetSeqNo() != o->trkseqno && it_tof < ToFLevel2::ntrk()); |
|
|
if( t->GetSeqNo() != o->trkseqno )cout << "PamLevel2::GetTrackImage(int) : tracker SeqNo "<< t->GetSeqNo() <<" does not match ToF SeqNo "<< o->trkseqno <<endl; |
|
439 |
}else{ |
}else{ |
440 |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
441 |
}; |
}; |
443 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
444 |
}; |
}; |
445 |
|
|
|
// hence create a "PamTrack" object |
|
|
PamTrack *image = 0; |
|
|
if(t && c && o)image = new PamTrack(t,c,o); |
|
|
|
|
446 |
return image; |
return image; |
|
|
|
447 |
} |
} |
448 |
|
|
449 |
//-------------------------------------- |
//-------------------------------------- |
456 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
457 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
458 |
*/ |
*/ |
459 |
TTree *PamLevel2::LoadPamTrees(TFile *f, TString detlist="+ALL"){ |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
460 |
|
|
461 |
TTree *Tout =0; |
// cout << "WARNING!!! -- obsolete method -- \n"; |
462 |
|
// cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
463 |
|
|
464 |
SetWhichTrees(detlist); |
TTree *Trout =0; |
465 |
|
|
466 |
// Tracker |
SetWhichTrees(detlist); |
467 |
|
// Tracker |
468 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
469 |
if(T && TRK) { |
if(T && TRK) { |
470 |
T->SetBranchAddress("TrkLevel2", GetPointerToTrk()); |
if(TRK_L1){ |
471 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
472 |
if(!Tout)Tout=T; |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
473 |
|
}; |
474 |
|
T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
475 |
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
476 |
|
Trout=T; |
477 |
}else{ |
}else{ |
478 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
479 |
}; |
}; |
482 |
if(C && CAL) { |
if(C && CAL) { |
483 |
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
484 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
485 |
if(!Tout)Tout=C; |
if(!Trout)Trout=C; |
486 |
else Tout->AddFriend(C); |
else Trout->AddFriend(C); |
487 |
}else{ |
}else{ |
488 |
cout << "Calorimeter : missing tree"<<endl; |
cout << "Calorimeter : missing tree"<<endl; |
489 |
}; |
}; |
492 |
if(O && TOF) { |
if(O && TOF) { |
493 |
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
494 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
495 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
496 |
else Tout->AddFriend(O); |
else Trout->AddFriend(O); |
497 |
}else{ |
}else{ |
498 |
cout << "ToF : missing tree"<<endl; |
cout << "ToF : missing tree"<<endl; |
499 |
}; |
}; |
502 |
if(R && TRG) { |
if(R && TRG) { |
503 |
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
504 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
505 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
506 |
else Tout->AddFriend(R); |
else Trout->AddFriend(R); |
507 |
}else{ |
}else{ |
508 |
cout << "Trigger : missing tree"<<endl; |
cout << "Trigger : missing tree"<<endl; |
509 |
}; |
}; |
512 |
if(S && S4) { |
if(S && S4) { |
513 |
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
514 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
515 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
516 |
else Tout->AddFriend(S); |
else Trout->AddFriend(S); |
517 |
}else{ |
}else{ |
518 |
cout << "S4 : missing tree"<<endl; |
cout << "S4 : missing tree"<<endl; |
519 |
}; |
}; |
522 |
if(N && ND) { |
if(N && ND) { |
523 |
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
524 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
525 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
526 |
else Tout->AddFriend(N); |
else Trout->AddFriend(N); |
527 |
}else{ |
}else{ |
528 |
cout << "NeutronD : missing tree"<<endl; |
cout << "NeutronD : missing tree"<<endl; |
529 |
}; |
}; |
532 |
if(A && AC) { |
if(A && AC) { |
533 |
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
534 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
535 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
536 |
else Tout->AddFriend(A); |
else Trout->AddFriend(A); |
537 |
}else{ |
}else{ |
538 |
cout << "Anticounter : missing tree"<<endl; |
cout << "Anticounter : missing tree"<<endl; |
539 |
}; |
}; |
542 |
if(B && ORB) { |
if(B && ORB) { |
543 |
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
544 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
545 |
if(!Tout)Tout=O; |
if(!Trout)Trout=O; |
546 |
else Tout->AddFriend(B); |
else Trout->AddFriend(B); |
547 |
}else{ |
}else{ |
548 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
549 |
}; |
}; |
550 |
|
|
551 |
return Tout; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
|
|
|
|
} |
|
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* Get the Pamela detector trees in a single file and make them friends. |
|
|
* @param f TFile pointer |
|
|
* @return Pointer to a TTree |
|
|
*/ |
|
|
TTree *PamLevel2::LoadPamTrees(TFile *f){ |
|
|
|
|
|
TTree *Tout =0; |
|
|
|
|
|
SetWhichTrees("+ALL"); |
|
552 |
|
|
553 |
// Tracker |
return Trout; |
|
TTree *T = (TTree*)f->Get("Tracker"); |
|
|
if(T && TRK) { |
|
|
T->SetBranchAddress("TrkLevel2", GetPointerToTrk()); |
|
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
|
|
if(!Tout)Tout=T; |
|
|
}else{ |
|
|
cout << "Tracker : missing tree"<<endl; |
|
|
}; |
|
|
// Calorimeter |
|
|
TTree *C = (TTree*)f->Get("Calorimeter"); |
|
|
if(C && CAL) { |
|
|
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
|
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
|
|
if(!Tout)Tout=C; |
|
|
else Tout->AddFriend(C); |
|
|
}else{ |
|
|
cout << "Calorimeter : missing tree"<<endl; |
|
|
}; |
|
|
// ToF |
|
|
TTree *O = (TTree*)f->Get("ToF"); |
|
|
if(O && TOF) { |
|
|
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
|
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(O); |
|
|
}else{ |
|
|
cout << "ToF : missing tree"<<endl; |
|
|
}; |
|
|
// Trigger |
|
|
TTree *R = (TTree*)f->Get("Trigger"); |
|
|
if(R && TRG) { |
|
|
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
|
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(R); |
|
|
}else{ |
|
|
cout << "Trigger : missing tree"<<endl; |
|
|
}; |
|
|
// S4 |
|
|
TTree *S = (TTree*)f->Get("S4"); |
|
|
if(S && S4) { |
|
|
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
|
|
cout << "S4 : set branch address S4Level2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(S); |
|
|
}else{ |
|
|
cout << "S4 : missing tree"<<endl; |
|
|
}; |
|
|
// Neutron Detector |
|
|
TTree *N = (TTree*)f->Get("NeutronD"); |
|
|
if(N && ND) { |
|
|
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
|
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(N); |
|
|
}else{ |
|
|
cout << "NeutronD : missing tree"<<endl; |
|
|
}; |
|
|
// Anticounters |
|
|
TTree *A = (TTree*)f->Get("Anticounter"); |
|
|
if(A && AC) { |
|
|
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
|
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(A); |
|
|
}else{ |
|
|
cout << "Anticounter : missing tree"<<endl; |
|
|
}; |
|
|
// Orbital Info |
|
|
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
|
|
if(B && ORB) { |
|
|
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(B); |
|
|
}else{ |
|
|
cout << "OrbitalInfo : missing tree"<<endl; |
|
|
}; |
|
|
|
|
|
return Tout; |
|
554 |
|
|
555 |
} |
} |
556 |
//-------------------------------------- |
//-------------------------------------- |
569 |
TString wdir = gSystem->WorkingDirectory(); |
TString wdir = gSystem->WorkingDirectory(); |
570 |
|
|
571 |
if(ddir=="")ddir = wdir; |
if(ddir=="")ddir = wdir; |
572 |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
573 |
cout << "Level2 data directory : "<< endl << ddir << endl; |
cout << "Level2 data directory : "<< ddir << endl; |
574 |
|
|
575 |
TList *contents = new TList; // create output list |
TList *contents = new TList; // create output list |
576 |
contents->SetOwner(); |
contents->SetOwner(); |
577 |
|
|
578 |
|
char *fullpath; |
579 |
|
|
580 |
// if no input file list is given: |
// if no input file list is given: |
581 |
if ( flisttxt != "" ){ |
if ( flisttxt != "" ){ |
582 |
|
|
583 |
|
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0; |
584 |
|
|
585 |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
586 |
|
flisttxt = fullpath; |
|
flisttxt = gSystem->ConcatFileName(wdir,gSystem->BaseName(flisttxt)); |
|
587 |
|
|
588 |
cout <<"Input file list : "<< endl << flisttxt <<endl; |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
589 |
ifstream in; |
|
590 |
in.open(flisttxt, ios::in); |
cout <<"Input file list : " << flisttxt <<endl; |
591 |
|
ifstream in; |
592 |
|
in.open(flisttxt, ios::in); //open input file list |
593 |
while (1) { |
while (1) { |
594 |
TString file; |
TString file; |
595 |
in >> file; |
in >> file; |
596 |
if (!in.good()) break; |
if (!in.good()) break; |
|
char *fullpath; |
|
597 |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
598 |
// contents->Add(new TSystemDirectory(fullpath,ddir)); // add file to the list |
// contents->Add(new TSystemDirectory(fullpath,ddir)); // add file to the list |
599 |
// contents->Add(new TSystemFile(fullpath,ddir)); // add file to the list |
// contents->Add(new TSystemFile(fullpath,ddir)); // add file to the list |
610 |
cout << "Check for existing root files."<<endl; |
cout << "Check for existing root files."<<endl; |
611 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
612 |
|
|
613 |
|
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
614 |
TList *temp = datadir->GetListOfFiles(); |
TList *temp = datadir->GetListOfFiles(); |
615 |
// temp->Print(); |
// temp->Print(); |
616 |
// cout << "*************************************" << endl; |
// cout << "*************************************" << endl; |
628 |
}; |
}; |
629 |
} |
} |
630 |
delete temp; |
delete temp; |
631 |
|
delete datadir; |
632 |
|
|
633 |
}; |
}; |
634 |
gSystem->ChangeDirectory(wdir); |
gSystem->ChangeDirectory(wdir); // back to the working directory |
635 |
cout << endl << "Selected files:" << endl; |
// cout << endl << "Selected files:" << endl; |
636 |
contents->Print(); |
// contents->Print(); |
637 |
cout << endl; |
cout << contents->GetEntries()<<" files selected\n"; |
638 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << endl; |
639 |
|
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
640 |
return contents; |
return contents; |
641 |
}; |
}; |
642 |
//-------------------------------------- |
//-------------------------------------- |
649 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
650 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
651 |
*/ |
*/ |
652 |
TChain *PamLevel2::LoadPamTrees(TList *fl, TString detlist="+ALL"){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){ |
653 |
|
|
654 |
TChain *Tout=0; |
// TChain *Tout=0; |
655 |
|
if(Tout)Tout->Delete(); |
656 |
|
Tout = NULL; |
657 |
|
|
658 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
659 |
|
|
692 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
693 |
}; |
}; |
694 |
} |
} |
695 |
|
|
696 |
// Tracker |
// Tracker |
697 |
if(TRK) { |
if(TRK) if(!Tout)Tout=T; |
698 |
T->SetBranchAddress("TrkLevel2", GetPointerToTrk()); |
|
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
|
|
if(!Tout)Tout=T; |
|
|
}; |
|
|
|
|
699 |
// Calorimeter |
// Calorimeter |
700 |
if(CAL) { |
if(CAL) { |
|
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
|
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
|
701 |
if(!Tout)Tout=C; |
if(!Tout)Tout=C; |
702 |
else Tout->AddFriend("Calorimeter"); |
else Tout->AddFriend("Calorimeter"); |
703 |
}; |
}; |
704 |
|
|
705 |
// ToF |
// ToF |
706 |
if(TOF) { |
if(TOF) { |
|
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
|
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
|
707 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
708 |
else Tout->AddFriend("ToF"); |
else Tout->AddFriend("ToF"); |
709 |
}; |
}; |
710 |
// Trigger |
// Trigger |
711 |
if(TRG) { |
if(TRG) { |
|
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
|
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
|
712 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
713 |
else Tout->AddFriend("Trigger"); |
else Tout->AddFriend("Trigger"); |
714 |
}; |
}; |
715 |
// S4 |
// S4 |
716 |
if(S4) { |
if(S4) { |
|
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
|
|
cout << "S4 : set branch address S4Level2"<<endl; |
|
717 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
718 |
else Tout->AddFriend("S4"); |
else Tout->AddFriend("S4"); |
719 |
}; |
}; |
720 |
// Neutron Detector |
// Neutron Detector |
721 |
if(ND) { |
if(ND) { |
|
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
|
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
|
722 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
723 |
else Tout->AddFriend("NeutronD"); |
else Tout->AddFriend("NeutronD"); |
724 |
}; |
}; |
725 |
// Anticounters |
// Anticounters |
726 |
if(AC) { |
if(AC) { |
|
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
|
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
|
727 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
728 |
else Tout->AddFriend("Anticounter"); |
else Tout->AddFriend("Anticounter"); |
729 |
}; |
}; |
730 |
// OrbitalInfo |
// OrbitalInfo |
731 |
if(ORB) { |
if(ORB) { |
|
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
|
732 |
if(!Tout)Tout=O; |
if(!Tout)Tout=O; |
733 |
else Tout->AddFriend("OrbitalInfo"); |
else Tout->AddFriend("OrbitalInfo"); |
734 |
}; |
}; |
735 |
|
|
736 |
|
cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
737 |
|
|
738 |
|
PamLevel2::SetBranchAddress(); |
739 |
|
|
740 |
return Tout; |
return Tout; |
741 |
|
} |
742 |
|
//-------------------------------------- |
743 |
|
// |
744 |
|
// |
745 |
|
//-------------------------------------- |
746 |
|
/** |
747 |
|
* Set branch addresses for Pamela friend trees |
748 |
|
*/ |
749 |
|
void PamLevel2::SetBranchAddress(){ |
750 |
|
// Tracker |
751 |
|
if(TRK) { |
752 |
|
if(TRK_L1){ |
753 |
|
Tout->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
754 |
|
cout << "Tracker : set branch address TrkLevel1"<<endl; |
755 |
|
}; |
756 |
|
Tout->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
757 |
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
758 |
|
}; |
759 |
|
|
760 |
|
// Calorimeter |
761 |
|
if(CAL) { |
762 |
|
Tout->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
763 |
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
764 |
|
}; |
765 |
|
|
766 |
|
// ToF |
767 |
|
if(TOF) { |
768 |
|
Tout->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
769 |
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
770 |
|
}; |
771 |
|
// Trigger |
772 |
|
if(TRG) { |
773 |
|
Tout->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
774 |
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
775 |
|
}; |
776 |
|
// S4 |
777 |
|
if(S4) { |
778 |
|
Tout->SetBranchAddress("S4Level2", GetPointerToS4()); |
779 |
|
cout << "S4 : set branch address S4Level2"<<endl; |
780 |
|
}; |
781 |
|
// Neutron Detector |
782 |
|
if(ND) { |
783 |
|
Tout->SetBranchAddress("NDLevel2", GetPointerToND()); |
784 |
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
785 |
|
}; |
786 |
|
// Anticounters |
787 |
|
if(AC) { |
788 |
|
Tout->SetBranchAddress("AcLevel2", GetPointerToAc()); |
789 |
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
790 |
|
}; |
791 |
|
// OrbitalInfo |
792 |
|
if(ORB) { |
793 |
|
Tout->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
794 |
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
795 |
|
}; |
796 |
|
|
797 |
|
} |
798 |
|
|
799 |
|
//-------------------------------------- |
800 |
|
// |
801 |
|
// |
802 |
|
//-------------------------------------- |
803 |
|
void *PamLevel2::GetPointerTo(const char* c ){ |
804 |
|
// cout << "objname "<< objname << endl; |
805 |
|
TString objname = c; |
806 |
|
if(!objname.CompareTo("TrkLevel1"))return &trk_l1_obj; |
807 |
|
if(!objname.CompareTo("TrkLevel2"))return &trk_obj; |
808 |
|
|
809 |
|
return NULL; |
810 |
|
}; |
811 |
|
//-------------------------------------- |
812 |
|
// |
813 |
|
// |
814 |
|
//-------------------------------------- |
815 |
|
/** |
816 |
|
* Get the Run tree chain from a list of files. |
817 |
|
* @param fl Pointer to a TList of TSystemFiles |
818 |
|
* @return Pointer to a TChain |
819 |
|
*/ |
820 |
|
TChain *PamLevel2::GetRunTree(TList *fl){ |
821 |
|
|
822 |
|
TChain *R = new TChain("Run"); |
823 |
|
|
824 |
|
// loop over files and create chains |
825 |
|
TIter next(fl); |
826 |
|
TSystemFile *questo = 0; |
827 |
|
while ( (questo = (TSystemFile*) next()) ) { |
828 |
|
TString name = questo->GetName(); |
829 |
|
// cout << "File: "<< name << endl; |
830 |
|
if( CheckLevel2File(name) ){ |
831 |
|
R->Add(name); |
832 |
|
}; |
833 |
|
} |
834 |
|
|
835 |
|
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
836 |
|
cout << "Run : set branch address RunInfo"<<endl; |
837 |
|
|
838 |
|
return R; |
839 |
|
|
840 |
|
} |
841 |
|
//-------------------------------------- |
842 |
|
// |
843 |
|
// |
844 |
|
//-------------------------------------- |
845 |
|
/** |
846 |
|
* Get the Run tree from a file. |
847 |
|
* @param f Pointer to a TFile |
848 |
|
* @return Pointer to a TTree |
849 |
|
*/ |
850 |
|
TTree *PamLevel2::GetRunTree(TFile *f){ |
851 |
|
|
852 |
|
|
853 |
|
TTree *R = (TTree*)f->Get("Run"); |
854 |
|
|
855 |
|
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
856 |
|
cout << "Run : set branch address RunInfo"<<endl; |
857 |
|
|
858 |
|
return R; |
859 |
|
|
860 |
} |
} |
861 |
//-------------------------------------- |
//-------------------------------------- |
871 |
if(detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.Contains("+ALL", TString::kIgnoreCase)){ |
872 |
CAL = true; |
CAL = true; |
873 |
TRK = true; |
TRK = true; |
874 |
|
TRK_L1 = false; |
875 |
TRG = true; |
TRG = true; |
876 |
TOF = true; |
TOF = true; |
877 |
S4 = true; |
S4 = true; |
881 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
882 |
CAL = false; |
CAL = false; |
883 |
TRK = false; |
TRK = false; |
884 |
|
TRK_L1 = false; |
885 |
TRG = false; |
TRG = false; |
886 |
TOF = false; |
TOF = false; |
887 |
S4 = false; |
S4 = false; |
896 |
if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK = false; |
if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK = false; |
897 |
else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK = true; |
else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK = true; |
898 |
|
|
899 |
|
if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK_L1 = false; |
900 |
|
else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK_L1 = true; |
901 |
|
|
902 |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
903 |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
904 |
|
|
923 |
// |
// |
924 |
//-------------------------------------- |
//-------------------------------------- |
925 |
/** |
/** |
926 |
* Check if a file contains required trees. |
* Check if a file contains selected Pamela Level2 trees. |
927 |
* @param name File name |
* @param name File name |
928 |
* @return Pointer to a TChain |
* @return true if the file is ok. |
929 |
*/ |
*/ |
930 |
Bool_t PamLevel2::CheckLevel2File(TString name){ |
Bool_t PamLevel2::CheckLevel2File(TString name){ |
931 |
|
|
932 |
Bool_t CAL__ok = false; |
Bool_t CAL__ok = false; |
933 |
Bool_t TRK__ok = false; |
Bool_t TRK__ok = false; |
934 |
|
Bool_t TRK_L1__ok = false; |
935 |
Bool_t TRG__ok = false; |
Bool_t TRG__ok = false; |
936 |
Bool_t TOF__ok = false; |
Bool_t TOF__ok = false; |
937 |
Bool_t S4__ok = false; |
Bool_t S4__ok = false; |
949 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
950 |
// cout << key->GetName() << endl; |
// cout << key->GetName() << endl; |
951 |
if( !strcmp(key->GetName(),"Calorimeter") )CAL__ok = true; |
if( !strcmp(key->GetName(),"Calorimeter") )CAL__ok = true; |
952 |
if( !strcmp(key->GetName(),"Tracker" ) )TRK__ok = true; |
// if( !strcmp(key->GetName(),"Tracker" ) )TRK__ok = true; |
953 |
if( !strcmp(key->GetName(),"Trigger" ) )TRG__ok = true; |
if( !strcmp(key->GetName(),"Trigger" ) )TRG__ok = true; |
954 |
if( !strcmp(key->GetName(),"ToF" ) )TOF__ok = true; |
if( !strcmp(key->GetName(),"ToF" ) )TOF__ok = true; |
955 |
if( !strcmp(key->GetName(),"S4" ) )S4__ok = true; |
if( !strcmp(key->GetName(),"S4" ) )S4__ok = true; |
957 |
if( !strcmp(key->GetName(),"Anticounter") )AC__ok = true; |
if( !strcmp(key->GetName(),"Anticounter") )AC__ok = true; |
958 |
if( !strcmp(key->GetName(),"OrbitalInfo") )ORB__ok = true; |
if( !strcmp(key->GetName(),"OrbitalInfo") )ORB__ok = true; |
959 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
960 |
|
|
961 |
|
if( !strcmp(key->GetName(),"Tracker" ) ){ |
962 |
|
TRK__ok = true; |
963 |
|
TTree *T = (TTree*)f->Get("Tracker"); |
964 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
965 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
966 |
|
if( !name.CompareTo("TrkLevel1") )TRK_L1__ok=true; |
967 |
|
}; |
968 |
|
}; |
969 |
|
|
970 |
}; |
}; |
971 |
|
|
972 |
lk->Delete(); |
lk->Delete(); |
985 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker tree"<< endl; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker tree"<< endl; |
986 |
FLAG = false; |
FLAG = false; |
987 |
}; |
}; |
988 |
|
if(TRK_L1 && !TRK_L1__ok){ |
989 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker Level1 Branch"<< endl; |
990 |
|
FLAG = false; |
991 |
|
}; |
992 |
if(TRG && !TRG__ok){ |
if(TRG && !TRG__ok){ |
993 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
994 |
FLAG = false; |
FLAG = false; |