| 1 |
#include <PamLevel2.h> |
| 2 |
//-------------------------------------- |
| 3 |
// |
| 4 |
// |
| 5 |
//-------------------------------------- |
| 6 |
/** |
| 7 |
* Default constructor |
| 8 |
*/ |
| 9 |
PamTrack::PamTrack(){ |
| 10 |
trk_track = this->TrkTrack::GetTrkTrack(); |
| 11 |
calo_track = this->CaloTrkVar::GetCaloTrkVar(); |
| 12 |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
| 13 |
}; |
| 14 |
//-------------------------------------- |
| 15 |
// |
| 16 |
// |
| 17 |
//-------------------------------------- |
| 18 |
/** |
| 19 |
* Constructor |
| 20 |
*/ |
| 21 |
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){ |
| 22 |
trk_track = this->TrkTrack::GetTrkTrack(); |
| 23 |
calo_track = this->CaloTrkVar::GetCaloTrkVar(); |
| 24 |
tof_track = this->ToFTrkVar::GetToFTrkVar(); |
| 25 |
if(t) *trk_track = *t; |
| 26 |
if(c) *calo_track = *c; |
| 27 |
if(o) *tof_track = *o; |
| 28 |
}; |
| 29 |
|
| 30 |
//-------------------------------------- |
| 31 |
// |
| 32 |
// |
| 33 |
//-------------------------------------- |
| 34 |
/** |
| 35 |
* Constructor |
| 36 |
*/ |
| 37 |
PamLevel2::PamLevel2(){ |
| 38 |
|
| 39 |
trk2_obj = TrkLevel2::GetTrkLevel2(); |
| 40 |
trk1_obj = TrkLevel1::GetTrkLevel1(); |
| 41 |
trkh_obj = TrkHough::GetTrkHough(); |
| 42 |
calo1_obj = CaloLevel1::GetCaloLevel1(); |
| 43 |
calo2_obj = CaloLevel2::GetCaloLevel2(); |
| 44 |
tof_obj = ToFLevel2::GetToFLevel2(); |
| 45 |
trig_obj = TrigLevel2::GetTrigLevel2(); |
| 46 |
s4_obj = S4Level2::GetS4Level2(); |
| 47 |
nd_obj = NDLevel2::GetNDLevel2(); |
| 48 |
ac_obj = AcLevel2::GetAcLevel2(); |
| 49 |
orb_obj = OrbitalInfo::GetOrbitalInfo(); |
| 50 |
|
| 51 |
run_obj = new GL_RUN(); |
| 52 |
|
| 53 |
// trk1_clone = 0; |
| 54 |
// trk2_clone = 0; |
| 55 |
// trkh_clone = 0; |
| 56 |
// calo1_clone = 0; |
| 57 |
// calo2_clone = 0; |
| 58 |
// tof_clone = 0; |
| 59 |
// trig_clone = 0; |
| 60 |
// s4_clone = 0; |
| 61 |
// nd_clone = 0; |
| 62 |
// ac_clone = 0; |
| 63 |
// orb_clone = 0; |
| 64 |
|
| 65 |
// T_clone = 0; |
| 66 |
// C_clone = 0; |
| 67 |
// O_clone = 0; |
| 68 |
// R_clone = 0; |
| 69 |
// S_clone = 0; |
| 70 |
// N_clone = 0; |
| 71 |
// A_clone = 0; |
| 72 |
// B_clone = 0; |
| 73 |
|
| 74 |
for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; |
| 75 |
|
| 76 |
sorted_tracks = new TRefArray(); |
| 77 |
|
| 78 |
CAL1 = true; |
| 79 |
CAL2 = true; |
| 80 |
TRK2 = true; |
| 81 |
TRK1 = false; |
| 82 |
TRKh = false; |
| 83 |
TRG = true; |
| 84 |
TOF = true; |
| 85 |
S4 = true; |
| 86 |
ND = true; |
| 87 |
AC = true; |
| 88 |
ORB = true; |
| 89 |
|
| 90 |
RUN = true; |
| 91 |
|
| 92 |
}; |
| 93 |
/** |
| 94 |
* Destructor |
| 95 |
*/ |
| 96 |
PamLevel2::~PamLevel2(){ |
| 97 |
delete run_obj; |
| 98 |
Clear(); |
| 99 |
}; |
| 100 |
/** |
| 101 |
* Clear the event |
| 102 |
*/ |
| 103 |
void PamLevel2::Clear(){ |
| 104 |
|
| 105 |
TrkLevel1::Clear(); |
| 106 |
|
| 107 |
TrkLevel2::Clear(); |
| 108 |
CaloLevel2::Clear(); |
| 109 |
ToFLevel2::Clear(); |
| 110 |
TrigLevel2::Clear(); |
| 111 |
S4Level2::Clear(); |
| 112 |
NDLevel2::Clear(); |
| 113 |
AcLevel2::Clear(); |
| 114 |
OrbitalInfo::Clear(); |
| 115 |
|
| 116 |
// if(trk1_clone)trk1_clone->Clear(); |
| 117 |
// if(trk2_clone)trk2_clone->Clear(); |
| 118 |
// if(trkh_clone)trkh_clone->Clear(); |
| 119 |
// if(calo1_clone)calo1_clone->Clear(); |
| 120 |
// if(calo2_clone)calo2_clone->Clear(); |
| 121 |
// if(tof_clone)tof_clone->Clear(); |
| 122 |
// if(trig_clone)trig_clone->Clear(); |
| 123 |
// if(s4_clone)s4_clone->Clear(); |
| 124 |
// if(nd_clone)nd_clone->Clear(); |
| 125 |
// if(ac_clone)ac_clone->Clear(); |
| 126 |
// if(orb_clone)orb_clone->Clear(); |
| 127 |
|
| 128 |
sorted_tracks->Delete(); // clean the reference array |
| 129 |
|
| 130 |
}; |
| 131 |
|
| 132 |
|
| 133 |
//-------------------------------------- |
| 134 |
// |
| 135 |
// |
| 136 |
//-------------------------------------- |
| 137 |
void *PamLevel2::GetPointerTo(const char* c ){ |
| 138 |
|
| 139 |
TString objname = c; |
| 140 |
if(!objname.CompareTo("TrkLevel1"))return &trk1_obj; |
| 141 |
if(!objname.CompareTo("TrkLevel2"))return &trk2_obj; |
| 142 |
if(!objname.CompareTo("TrkHough"))return &trkh_obj; |
| 143 |
if(!objname.CompareTo("CaloLevel1"))return &calo1_obj; |
| 144 |
if(!objname.CompareTo("CaloLevel2"))return &calo2_obj; |
| 145 |
if(!objname.CompareTo("ToFLevel2"))return &tof_obj; |
| 146 |
if(!objname.CompareTo("TrigLevel2"))return &trig_obj; |
| 147 |
if(!objname.CompareTo("S4Level2"))return &s4_obj; |
| 148 |
if(!objname.CompareTo("NDLevel2"))return &nd_obj; |
| 149 |
if(!objname.CompareTo("AcLevel2"))return &ac_obj; |
| 150 |
if(!objname.CompareTo("OrbitalInfo"))return &orb_obj; |
| 151 |
if(!objname.CompareTo("RunInfo"))return &run_obj; |
| 152 |
return NULL; |
| 153 |
}; |
| 154 |
//-------------------------------------- |
| 155 |
// |
| 156 |
// |
| 157 |
//-------------------------------------- |
| 158 |
/** |
| 159 |
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
| 160 |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
| 161 |
*/ |
| 162 |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
| 163 |
|
| 164 |
if( CaloLevel2::ntrk()==0 ){ |
| 165 |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
| 166 |
return NULL; |
| 167 |
}; |
| 168 |
|
| 169 |
CaloTrkVar *c = 0; |
| 170 |
Int_t it_calo=0; |
| 171 |
|
| 172 |
do{ |
| 173 |
c = CaloLevel2::GetCaloTrkVar(it_calo); |
| 174 |
it_calo++; |
| 175 |
} while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
| 176 |
|
| 177 |
if(!c || seqno != c->trkseqno){ |
| 178 |
c = 0; |
| 179 |
if(seqno!=-1)cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match Calorimeter stored tracks"<<endl; |
| 180 |
}; |
| 181 |
return c; |
| 182 |
|
| 183 |
}; |
| 184 |
//-------------------------------------- |
| 185 |
// |
| 186 |
// |
| 187 |
//-------------------------------------- |
| 188 |
/** |
| 189 |
* Retrieves the ToF track matching the seqno-th tracker stored track. |
| 190 |
* (If seqno = -1 retrieves the tracker-independent tof track) |
| 191 |
*/ |
| 192 |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
| 193 |
|
| 194 |
if( ToFLevel2::ntrk()==0 ){ |
| 195 |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
| 196 |
return NULL; |
| 197 |
}; |
| 198 |
|
| 199 |
ToFTrkVar *c = 0; |
| 200 |
Int_t it_tof=0; |
| 201 |
|
| 202 |
do{ |
| 203 |
c = ToFLevel2::GetToFTrkVar(it_tof); |
| 204 |
it_tof++; |
| 205 |
} while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); |
| 206 |
|
| 207 |
if(!c || seqno != c->trkseqno){ |
| 208 |
c = 0; |
| 209 |
if(seqno!=-1)cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match ToF stored tracks"<<endl; |
| 210 |
}; |
| 211 |
return c; |
| 212 |
|
| 213 |
}; |
| 214 |
|
| 215 |
//-------------------------------------- |
| 216 |
// |
| 217 |
// |
| 218 |
//-------------------------------------- |
| 219 |
/** |
| 220 |
* Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. |
| 221 |
*/ |
| 222 |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
| 223 |
|
| 224 |
CaloTrkVar *c = 0; |
| 225 |
ToFTrkVar *o = 0; |
| 226 |
|
| 227 |
if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo()); |
| 228 |
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
| 229 |
|
| 230 |
// if(t && c && o)track = new PamTrack(t,c,o); |
| 231 |
PamTrack *track = new PamTrack(t,c,o); |
| 232 |
|
| 233 |
return track; |
| 234 |
|
| 235 |
}; |
| 236 |
//-------------------------------------- |
| 237 |
// |
| 238 |
// |
| 239 |
//-------------------------------------- |
| 240 |
/** |
| 241 |
* Retrieves the it-th stored track. |
| 242 |
* It override TrkLevel2::GetTrack(int it). |
| 243 |
* @param itrk Track number, ranging from 0 to GetNTracks(). |
| 244 |
*/ |
| 245 |
|
| 246 |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
| 247 |
|
| 248 |
PamTrack *track = 0; |
| 249 |
|
| 250 |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
| 251 |
|
| 252 |
TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); |
| 253 |
track = GetPamTrackAlong(t); |
| 254 |
|
| 255 |
}else{ |
| 256 |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
| 257 |
}; |
| 258 |
|
| 259 |
return track; |
| 260 |
|
| 261 |
} |
| 262 |
//-------------------------------------- |
| 263 |
// |
| 264 |
// |
| 265 |
//-------------------------------------- |
| 266 |
/** |
| 267 |
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. |
| 268 |
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
| 269 |
* Sorting cryteria: |
| 270 |
* TRK: lower chi**2 |
| 271 |
* CAL: lower Y spatial residual on the first calorimeter plane |
| 272 |
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
| 273 |
* The default sorting cryterium is "TOF+CAL". |
| 274 |
* |
| 275 |
* 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). |
| 276 |
*/ |
| 277 |
void PamLevel2::SortTracks(TString how){ |
| 278 |
|
| 279 |
// cout << "call SortTracs() "<<endl; |
| 280 |
//Save current Object count |
| 281 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
| 282 |
|
| 283 |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
| 284 |
|
| 285 |
sorted_tracks->Delete(); //temporaneo??? |
| 286 |
|
| 287 |
// loop over the tracks sorted by the tracker |
| 288 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
| 289 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
| 290 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
| 291 |
|
| 292 |
if( !CAL2 && use_CAL) use_CAL = false; |
| 293 |
if( !TOF && use_TOF) use_TOF = false; |
| 294 |
|
| 295 |
if( !TRK2 ){ |
| 296 |
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
| 297 |
return; |
| 298 |
}; |
| 299 |
|
| 300 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
| 301 |
|
| 302 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
| 303 |
|
| 304 |
TrkTrack *ts = 0; |
| 305 |
|
| 306 |
// get tracker tracks |
| 307 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
| 308 |
CaloTrkVar *cp = 0; |
| 309 |
ToFTrkVar *op = 0; |
| 310 |
|
| 311 |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
| 312 |
// if track has an image, check image selection |
| 313 |
if(tp->HasImage()){ |
| 314 |
|
| 315 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
| 316 |
CaloTrkVar *ci = 0; |
| 317 |
ToFTrkVar *oi = 0; |
| 318 |
|
| 319 |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
| 320 |
|
| 321 |
//assign starting scores |
| 322 |
Int_t tp_score = 0; //main track sorted by the tracker |
| 323 |
Int_t ti_score = 0; //image track |
| 324 |
|
| 325 |
// ------------------------ |
| 326 |
// calorimeter check |
| 327 |
// ------------------------ |
| 328 |
// check the Y spatial residual on the first calorimeter plane |
| 329 |
// (cut on calorimeter variables from Emiliano) |
| 330 |
if( |
| 331 |
use_CAL && |
| 332 |
npcfit[1] > 15 && //no. of fit planes on Y view |
| 333 |
varcfit[1] < 1000. && //fit variance on Y view |
| 334 |
true){ |
| 335 |
|
| 336 |
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
| 337 |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
| 338 |
|
| 339 |
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
| 340 |
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
| 341 |
|
| 342 |
if(resy_p <= resy_i) tp_score++; |
| 343 |
else ti_score++; |
| 344 |
|
| 345 |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
| 346 |
|
| 347 |
}; |
| 348 |
// ------------------------ |
| 349 |
// TOF check |
| 350 |
// ------------------------ |
| 351 |
// check the number of hit pmts along the track |
| 352 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
| 353 |
if( use_TOF ){ |
| 354 |
|
| 355 |
Int_t nphit_p =0; |
| 356 |
Int_t nphit_i =0; |
| 357 |
|
| 358 |
op = GetToFStoredTrack(tp->GetSeqNo()); |
| 359 |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
| 360 |
|
| 361 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
| 362 |
cout << "track: npmttdc "<< op->npmttdc << endl; |
| 363 |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
| 364 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
| 365 |
|
| 366 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
| 367 |
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
| 368 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
| 369 |
}; |
| 370 |
|
| 371 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
| 372 |
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
| 373 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
| 374 |
}; |
| 375 |
|
| 376 |
if( |
| 377 |
use_TOF && |
| 378 |
(nphit_p+nphit_i) !=0 && |
| 379 |
true){ |
| 380 |
|
| 381 |
if( nphit_p >= nphit_i) tp_score++; |
| 382 |
else ti_score++; |
| 383 |
}; |
| 384 |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
| 385 |
}; |
| 386 |
if(tp_score == ti_score) use_TRK = true; |
| 387 |
// ------------------------ |
| 388 |
// tracker check |
| 389 |
// ------------------------ |
| 390 |
// chi**2 difference is not always large enough to distinguish among |
| 391 |
// the real track and its image. |
| 392 |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
| 393 |
if(use_TRK){ |
| 394 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
| 395 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
| 396 |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
| 397 |
}; |
| 398 |
|
| 399 |
// ------------------------ |
| 400 |
// the winner is.... |
| 401 |
// ------------------------ |
| 402 |
if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
| 403 |
else if (tp_score < ti_score) ts = ti;//its image!! |
| 404 |
else { |
| 405 |
ts = tp; |
| 406 |
// cout << "Warning - track image ambiguity not solved" << endl; |
| 407 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
| 408 |
}; |
| 409 |
|
| 410 |
}else{ |
| 411 |
ts = tp; |
| 412 |
}; |
| 413 |
|
| 414 |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
| 415 |
sorted_tracks->Add(ts);//save the track in the sorted array |
| 416 |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
| 417 |
|
| 418 |
}; |
| 419 |
//Restore Object count |
| 420 |
//To save space in the table keeping track of all referenced objects |
| 421 |
//we assume that our events do not address each other. We reset the |
| 422 |
//object count to what it was at the beginning of the event. |
| 423 |
TProcessID::SetObjectCount(ObjectNumber); |
| 424 |
|
| 425 |
}; |
| 426 |
//-------------------------------------- |
| 427 |
// |
| 428 |
// |
| 429 |
//-------------------------------------- |
| 430 |
/** |
| 431 |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
| 432 |
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
| 433 |
*/ |
| 434 |
TRefArray *PamLevel2::GetTracks(){ |
| 435 |
|
| 436 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 437 |
SortTracks("+CAL+TOF"); |
| 438 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 439 |
|
| 440 |
return sorted_tracks; |
| 441 |
}; |
| 442 |
//-------------------------------------- |
| 443 |
// |
| 444 |
// |
| 445 |
//-------------------------------------- |
| 446 |
/** |
| 447 |
* Retrieves the it-th Pamela "physical" track. |
| 448 |
* It override TrkLevel2::GetTrack(int it). |
| 449 |
* @param it Track number, ranging from 0 to GetNTracks(). |
| 450 |
*/ |
| 451 |
PamTrack *PamLevel2::GetTrack(int it){ |
| 452 |
|
| 453 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 454 |
SortTracks("+CAL+TOF"); |
| 455 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 456 |
|
| 457 |
PamTrack *track = 0; |
| 458 |
|
| 459 |
if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){ |
| 460 |
TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); |
| 461 |
track = GetPamTrackAlong(t); |
| 462 |
}else{ |
| 463 |
cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
| 464 |
}; |
| 465 |
|
| 466 |
return track; |
| 467 |
|
| 468 |
}; |
| 469 |
|
| 470 |
//-------------------------------------- |
| 471 |
// |
| 472 |
// |
| 473 |
//-------------------------------------- |
| 474 |
/** |
| 475 |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
| 476 |
* @param it Track number, ranging from 0 to GetNTracks(). |
| 477 |
*/ |
| 478 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
| 479 |
|
| 480 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 481 |
SortTracks("+CAL+TOF"); |
| 482 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 483 |
|
| 484 |
PamTrack *image = 0; |
| 485 |
|
| 486 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
| 487 |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
| 488 |
if( temp->HasImage() ){ |
| 489 |
TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
| 490 |
image = GetPamTrackAlong(t); |
| 491 |
}else{ |
| 492 |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
| 493 |
}; |
| 494 |
}else{ |
| 495 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
| 496 |
}; |
| 497 |
|
| 498 |
return image; |
| 499 |
} |
| 500 |
|
| 501 |
//-------------------------------------- |
| 502 |
// |
| 503 |
// |
| 504 |
//-------------------------------------- |
| 505 |
/** |
| 506 |
* Get the Pamela detector trees in a single file and make them friends. |
| 507 |
* @param f TFile pointer |
| 508 |
* @param detlist String to select trees to be included |
| 509 |
* @return Pointer to a TTree |
| 510 |
*/ |
| 511 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ){ |
| 512 |
|
| 513 |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
| 514 |
// else GetWhichTrees(f); |
| 515 |
SetWhichTrees(detlist); |
| 516 |
|
| 517 |
TTree *Trout =0; |
| 518 |
|
| 519 |
TString fname = f->GetName(); |
| 520 |
if(!CheckLevel2File(fname))return NULL; |
| 521 |
|
| 522 |
UInt_t *found=0; |
| 523 |
|
| 524 |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
| 525 |
if(TRK1)cout<<"TRK1 "; |
| 526 |
if(TRK2)cout<<"TRK2 "; |
| 527 |
if(TRKh)cout<<"TRKH "; |
| 528 |
if(CAL1)cout<<"CAL1 "; |
| 529 |
if(CAL2)cout<<"CAL2 "; |
| 530 |
if(TOF)cout<<"TOF "; |
| 531 |
if(TRG)cout<<"TRG "; |
| 532 |
if(AC)cout<<"AC "; |
| 533 |
if(ND)cout<<"ND "; |
| 534 |
if(S4)cout<<"S4 "; |
| 535 |
if(ORB)cout<<"ORB "; |
| 536 |
cout << endl; |
| 537 |
|
| 538 |
f->cd(); |
| 539 |
|
| 540 |
// Tracker |
| 541 |
TTree *T = (TTree*)f->Get("Tracker"); |
| 542 |
if(T && (TRK2||TRK1||TRKh)) { |
| 543 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 544 |
else T->SetBranchStatus("TrkLevel2",0,found); |
| 545 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 546 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 547 |
else T->SetBranchStatus("TrkLevel1",0,found); |
| 548 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 549 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 550 |
else T->SetBranchStatus("TrkHough",0,found); |
| 551 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
| 552 |
if(!Trout)Trout=T; |
| 553 |
else Trout->AddFriend(T); |
| 554 |
}else{ |
| 555 |
cout << "Tracker : missing tree"<<endl; |
| 556 |
}; |
| 557 |
// Calorimeter |
| 558 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
| 559 |
if(C && (CAL2||CAL1)) { |
| 560 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 561 |
else C->SetBranchStatus("CaloLevel2",0,found); |
| 562 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 563 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 564 |
else C->SetBranchStatus("CaloLevel1",0,found); |
| 565 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 566 |
if(!Trout)Trout=C; |
| 567 |
else Trout->AddFriend(C); |
| 568 |
}else{ |
| 569 |
cout << "Calorimeter : missing tree"<<endl; |
| 570 |
}; |
| 571 |
|
| 572 |
// ToF |
| 573 |
TTree *O = (TTree*)f->Get("ToF"); |
| 574 |
if(O && TOF) { |
| 575 |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 576 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 577 |
if(!Trout)Trout=O; |
| 578 |
else Trout->AddFriend(O); |
| 579 |
}else{ |
| 580 |
cout << "ToF : missing tree"<<endl; |
| 581 |
}; |
| 582 |
// Trigger |
| 583 |
TTree *R = (TTree*)f->Get("Trigger"); |
| 584 |
if(R && TRG) { |
| 585 |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 586 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 587 |
if(!Trout)Trout=O; |
| 588 |
else Trout->AddFriend(R); |
| 589 |
}else{ |
| 590 |
cout << "Trigger : missing tree"<<endl; |
| 591 |
}; |
| 592 |
// S4 |
| 593 |
TTree *S = (TTree*)f->Get("S4"); |
| 594 |
if(S && S4) { |
| 595 |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 596 |
cout << "S4 : set branch address S4Level2"<<endl; |
| 597 |
if(!Trout)Trout=O; |
| 598 |
else Trout->AddFriend(S); |
| 599 |
}else{ |
| 600 |
cout << "S4 : missing tree"<<endl; |
| 601 |
}; |
| 602 |
// Neutron Detector |
| 603 |
TTree *N = (TTree*)f->Get("NeutronD"); |
| 604 |
if(N && ND) { |
| 605 |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 606 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 607 |
if(!Trout)Trout=O; |
| 608 |
else Trout->AddFriend(N); |
| 609 |
}else{ |
| 610 |
cout << "NeutronD : missing tree"<<endl; |
| 611 |
}; |
| 612 |
// Anticounters |
| 613 |
TTree *A = (TTree*)f->Get("Anticounter"); |
| 614 |
if(A && AC) { |
| 615 |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 616 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 617 |
if(!Trout)Trout=O; |
| 618 |
else Trout->AddFriend(A); |
| 619 |
}else{ |
| 620 |
cout << "Anticounter : missing tree"<<endl; |
| 621 |
}; |
| 622 |
// Orbital Info |
| 623 |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
| 624 |
if(B && ORB) { |
| 625 |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 626 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 627 |
if(!Trout)Trout=O; |
| 628 |
else Trout->AddFriend(B); |
| 629 |
}else{ |
| 630 |
cout << "OrbitalInfo : missing tree"<<endl; |
| 631 |
}; |
| 632 |
|
| 633 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
| 634 |
|
| 635 |
return Trout; |
| 636 |
|
| 637 |
} |
| 638 |
//-------------------------------------- |
| 639 |
// |
| 640 |
// |
| 641 |
//-------------------------------------- |
| 642 |
/** |
| 643 |
* Get list of Level2 files. |
| 644 |
* @param ddir Level2 data directory. |
| 645 |
* @param flisttxt Name of txt file containing file list. |
| 646 |
* @return Pointer to a TList of TSystemFiles |
| 647 |
* If no input file list is given , all the Level2 files inside the directory are processed. |
| 648 |
*/ |
| 649 |
TList* PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){ |
| 650 |
|
| 651 |
TString wdir = gSystem->WorkingDirectory(); |
| 652 |
|
| 653 |
if(ddir=="")ddir = wdir; |
| 654 |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
| 655 |
cout << "Level2 data directory : "<< ddir << endl; |
| 656 |
|
| 657 |
TList *contents = new TList; // create output list |
| 658 |
contents->SetOwner(); |
| 659 |
|
| 660 |
char *fullpath; |
| 661 |
|
| 662 |
// if no input file list is given: |
| 663 |
if ( flisttxt != "" ){ |
| 664 |
|
| 665 |
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ |
| 666 |
cout <<"File "<<flisttxt<<" not found"<<endl; |
| 667 |
return 0; |
| 668 |
} |
| 669 |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
| 670 |
flisttxt = fullpath; |
| 671 |
|
| 672 |
if( !gSystem->ChangeDirectory(ddir) ){ |
| 673 |
cout << "Cannot change directory : "<<ddir<<endl; |
| 674 |
return 0; |
| 675 |
} |
| 676 |
|
| 677 |
cout <<"Input file list : " << flisttxt <<endl; |
| 678 |
ifstream in; |
| 679 |
in.open(flisttxt, ios::in); //open input file list |
| 680 |
int line=0; |
| 681 |
while (1) { |
| 682 |
TString file; |
| 683 |
in >> file; |
| 684 |
if (!in.good()) break; |
| 685 |
line++; |
| 686 |
// cout <<"(1) " << file << endl; |
| 687 |
if(file.IsNull()){ |
| 688 |
cout << "-- list interrupted at line "<<line <<endl; |
| 689 |
break; |
| 690 |
} |
| 691 |
if(file.Contains("#"))file = file(0,file.First("#")); |
| 692 |
// cout <<"(2) " << file << endl; |
| 693 |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
| 694 |
|
| 695 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
| 696 |
|
| 697 |
}else{ |
| 698 |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
| 699 |
}; |
| 700 |
}; |
| 701 |
in.close(); |
| 702 |
|
| 703 |
}else{ |
| 704 |
|
| 705 |
cout << "No input file list given."<<endl; |
| 706 |
cout << "Check for existing root files."<<endl; |
| 707 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
| 708 |
|
| 709 |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
| 710 |
TList *temp = datadir->GetListOfFiles(); |
| 711 |
// temp->Print(); |
| 712 |
// cout << "*************************************" << endl; |
| 713 |
|
| 714 |
TIter next(temp); |
| 715 |
TSystemFile *questo = 0; |
| 716 |
|
| 717 |
|
| 718 |
while ( (questo = (TSystemFile*) next()) ) { |
| 719 |
TString name = questo-> GetName(); |
| 720 |
if( name.EndsWith(".root") ){ |
| 721 |
char *fullpath; |
| 722 |
gSystem->IsFileInIncludePath(name,&fullpath); |
| 723 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
| 724 |
}; |
| 725 |
} |
| 726 |
delete temp; |
| 727 |
delete datadir; |
| 728 |
|
| 729 |
}; |
| 730 |
gSystem->ChangeDirectory(wdir); // back to the working directory |
| 731 |
// cout << endl << "Selected files:" << endl; |
| 732 |
// contents->Print(); |
| 733 |
cout << contents->GetEntries()<<" files selected\n"; |
| 734 |
// cout << endl; |
| 735 |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
| 736 |
return contents; |
| 737 |
}; |
| 738 |
//-------------------------------------- |
| 739 |
// |
| 740 |
// |
| 741 |
//-------------------------------------- |
| 742 |
/** |
| 743 |
* Get the Pamela detector chains from a list of files and make them friends. |
| 744 |
* @param fl Pointer to a TList of TSystemFiles |
| 745 |
* @param detlist String to select trees to be included |
| 746 |
* @return Pointer to a TChain |
| 747 |
*/ |
| 748 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
| 749 |
|
| 750 |
TChain *Trout =0; |
| 751 |
|
| 752 |
// if( !detlist.IsNull() )SetWhichTrees(detlist); |
| 753 |
SetWhichTrees(detlist); |
| 754 |
|
| 755 |
cout<< "GetPamTree(TList*,TString): detector list --> "; |
| 756 |
if(TRK1)cout<<"TRK1 "; |
| 757 |
if(TRK2)cout<<"TRK2 "; |
| 758 |
if(TRKh)cout<<"TRKH "; |
| 759 |
if(CAL1)cout<<"CAL1 "; |
| 760 |
if(CAL2)cout<<"CAL2 "; |
| 761 |
if(TOF)cout<<"TOF "; |
| 762 |
if(TRG)cout<<"TRG "; |
| 763 |
if(AC)cout<<"AC "; |
| 764 |
if(ND)cout<<"ND "; |
| 765 |
if(S4)cout<<"S4 "; |
| 766 |
if(ORB)cout<<"ORB "; |
| 767 |
cout << endl; |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
TChain *T = 0; |
| 772 |
TChain *C = 0; |
| 773 |
TChain *O = 0; |
| 774 |
TChain *R = 0; |
| 775 |
TChain *S = 0; |
| 776 |
TChain *N = 0; |
| 777 |
TChain *A = 0; |
| 778 |
TChain *B = 0; |
| 779 |
|
| 780 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
| 781 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
| 782 |
if(TOF) O = new TChain("ToF"); |
| 783 |
if(TRG) R = new TChain("Trigger"); |
| 784 |
if(S4) S = new TChain("S4"); |
| 785 |
if(ND) N = new TChain("NeutronD"); |
| 786 |
if(AC) A = new TChain("Anticounter"); |
| 787 |
if(ORB) B = new TChain("OrbitalInfo"); |
| 788 |
|
| 789 |
// loop over files and create chains |
| 790 |
TIter next(fl); |
| 791 |
TSystemFile *questo = 0; |
| 792 |
while ( (questo = (TSystemFile*) next()) ) { |
| 793 |
TString name = questo->GetName(); |
| 794 |
// cout << "File: "<< name << endl; |
| 795 |
if( CheckLevel2File(name) ){ |
| 796 |
if(TRK2||TRK1||TRKh) T->Add(name); |
| 797 |
if(CAL1||CAL2) C->Add(name); |
| 798 |
if(TOF) O->Add(name); |
| 799 |
if(TRG) R->Add(name); |
| 800 |
if(S4) S->Add(name); |
| 801 |
if(ND) N->Add(name); |
| 802 |
if(AC) A->Add(name); |
| 803 |
if(ORB) B->Add(name); |
| 804 |
}; |
| 805 |
} |
| 806 |
|
| 807 |
cout << "done chain \n"; |
| 808 |
|
| 809 |
UInt_t *found=0; |
| 810 |
// Tracker |
| 811 |
if(T && (TRK2||TRK1||TRKh)) { |
| 812 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 813 |
else T->SetBranchStatus("TrkLevel2",0,found); |
| 814 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 815 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 816 |
else T->SetBranchStatus("TrkLevel1",0,found); |
| 817 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 818 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 819 |
else T->SetBranchStatus("TrkHough",0,found); |
| 820 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
| 821 |
if(!Trout)Trout=T; |
| 822 |
else Trout->AddFriend("Tracker"); |
| 823 |
}else{ |
| 824 |
cout << "Tracker : missing tree"<<endl; |
| 825 |
}; |
| 826 |
// Calorimeter |
| 827 |
if(C && (CAL2||CAL1)) { |
| 828 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 829 |
else C->SetBranchStatus("CaloLevel2",0,found); |
| 830 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 831 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 832 |
else C->SetBranchStatus("CaloLevel1",0,found); |
| 833 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 834 |
if(!Trout)Trout=C; |
| 835 |
else Trout->AddFriend("Calorimeter"); |
| 836 |
}else{ |
| 837 |
cout << "Calorimeter : missing tree"<<endl; |
| 838 |
}; |
| 839 |
// ToF |
| 840 |
if(O && TOF) { |
| 841 |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 842 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 843 |
if(!Trout)Trout=O; |
| 844 |
else Trout->AddFriend("ToF"); |
| 845 |
}else{ |
| 846 |
cout << "ToF : missing tree"<<endl; |
| 847 |
}; |
| 848 |
// Trigger |
| 849 |
if(R && TRG) { |
| 850 |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 851 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 852 |
if(!Trout)Trout=O; |
| 853 |
else Trout->AddFriend("Trigger"); |
| 854 |
}else{ |
| 855 |
cout << "Trigger : missing tree"<<endl; |
| 856 |
}; |
| 857 |
// S4 |
| 858 |
if(S && S4) { |
| 859 |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 860 |
cout << "S4 : set branch address S4Level2"<<endl; |
| 861 |
if(!Trout)Trout=O; |
| 862 |
else Trout->AddFriend("S4"); |
| 863 |
}else{ |
| 864 |
cout << "S4 : missing tree"<<endl; |
| 865 |
}; |
| 866 |
// Neutron Detector |
| 867 |
if(N && ND) { |
| 868 |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 869 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 870 |
if(!Trout)Trout=O; |
| 871 |
else Trout->AddFriend("NeutronD"); |
| 872 |
}else{ |
| 873 |
cout << "NeutronD : missing tree"<<endl; |
| 874 |
}; |
| 875 |
// Anticounters |
| 876 |
if(A && AC) { |
| 877 |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 878 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 879 |
if(!Trout)Trout=O; |
| 880 |
else Trout->AddFriend("Anticounter"); |
| 881 |
}else{ |
| 882 |
cout << "Anticounter : missing tree"<<endl; |
| 883 |
}; |
| 884 |
// Orbital Info |
| 885 |
if(B && ORB) { |
| 886 |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 887 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 888 |
if(!Trout)Trout=O; |
| 889 |
else Trout->AddFriend("OrbitalInfo"); |
| 890 |
}else{ |
| 891 |
cout << "OrbitalInfo : missing tree"<<endl; |
| 892 |
}; |
| 893 |
|
| 894 |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
| 895 |
|
| 896 |
|
| 897 |
// // Tracker |
| 898 |
// if(TRK2||TRK1||TRKh){ |
| 899 |
// if(!Tout)Tout=T; |
| 900 |
// else Tout->AddFriend("Tracker"); |
| 901 |
// } |
| 902 |
// // Calorimeter |
| 903 |
// if(CAL2||CAL1) { |
| 904 |
// if(!Tout)Tout=C; |
| 905 |
// else Tout->AddFriend("Calorimeter"); |
| 906 |
// }; |
| 907 |
// // ToF |
| 908 |
// if(TOF) { |
| 909 |
// if(!Tout)Tout=O; |
| 910 |
// else Tout->AddFriend("ToF"); |
| 911 |
// }; |
| 912 |
// // Trigger |
| 913 |
// if(TRG) { |
| 914 |
// if(!Tout)Tout=R; |
| 915 |
// else Tout->AddFriend("Trigger"); |
| 916 |
// }; |
| 917 |
// // S4 |
| 918 |
// if(S4) { |
| 919 |
// if(!Tout)Tout=S; |
| 920 |
// else Tout->AddFriend("S4"); |
| 921 |
// }; |
| 922 |
// // Neutron Detector |
| 923 |
// if(ND) { |
| 924 |
// if(!Tout)Tout=N; |
| 925 |
// else Tout->AddFriend("NeutronD"); |
| 926 |
// }; |
| 927 |
// // Anticounters |
| 928 |
// if(AC) { |
| 929 |
// if(!Tout)Tout=A; |
| 930 |
// else Tout->AddFriend("Anticounter"); |
| 931 |
// }; |
| 932 |
// // OrbitalInfo |
| 933 |
// if(ORB) { |
| 934 |
// if(!Tout)Tout=B; |
| 935 |
// else Tout->AddFriend("OrbitalInfo"); |
| 936 |
// }; |
| 937 |
|
| 938 |
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
| 939 |
|
| 940 |
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
| 941 |
|
| 942 |
return Trout; |
| 943 |
} |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
//-------------------------------------- |
| 948 |
// |
| 949 |
// |
| 950 |
//-------------------------------------- |
| 951 |
/** |
| 952 |
* Set branch addresses for Pamela friend trees |
| 953 |
*/ |
| 954 |
void PamLevel2::SetBranchAddress(TTree *t){ |
| 955 |
|
| 956 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
| 957 |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
| 958 |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
| 959 |
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
| 960 |
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
| 961 |
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
| 962 |
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
| 963 |
S4 = S4 & t->GetBranchStatus("S4Level2"); |
| 964 |
ND = ND & t->GetBranchStatus("NDLevel2"); |
| 965 |
AC = AC & t->GetBranchStatus("AcLevel2"); |
| 966 |
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
| 967 |
|
| 968 |
|
| 969 |
// Tracker |
| 970 |
if(TRK1) { |
| 971 |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel2")); |
| 972 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 973 |
}; |
| 974 |
if(TRK2) { |
| 975 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
| 976 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 977 |
}; |
| 978 |
if(TRKh) { |
| 979 |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 980 |
cout << "Tracker : set branch address TrkHough"<<endl; |
| 981 |
}; |
| 982 |
|
| 983 |
// Calorimeter |
| 984 |
if(CAL1) { |
| 985 |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 986 |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 987 |
}; |
| 988 |
if(CAL2) { |
| 989 |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 990 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 991 |
}; |
| 992 |
|
| 993 |
// ToF |
| 994 |
if(TOF) { |
| 995 |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 996 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 997 |
}; |
| 998 |
// Trigger |
| 999 |
if(TRG) { |
| 1000 |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1001 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1002 |
}; |
| 1003 |
// S4 |
| 1004 |
if(S4) { |
| 1005 |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1006 |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1007 |
}; |
| 1008 |
// Neutron Detector |
| 1009 |
if(ND) { |
| 1010 |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1011 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1012 |
}; |
| 1013 |
// Anticounters |
| 1014 |
if(AC) { |
| 1015 |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1016 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1017 |
}; |
| 1018 |
// OrbitalInfo |
| 1019 |
if(ORB) { |
| 1020 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1021 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1022 |
}; |
| 1023 |
|
| 1024 |
} |
| 1025 |
/** |
| 1026 |
* Set branch addresses for Pamela friend trees |
| 1027 |
*/ |
| 1028 |
void PamLevel2::SetBranchAddress(TChain *t){ |
| 1029 |
|
| 1030 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
| 1031 |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
| 1032 |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
| 1033 |
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
| 1034 |
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
| 1035 |
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
| 1036 |
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
| 1037 |
S4 = S4 & t->GetBranchStatus("S4Level2"); |
| 1038 |
ND = ND & t->GetBranchStatus("NDLevel2"); |
| 1039 |
AC = AC & t->GetBranchStatus("AcLevel2"); |
| 1040 |
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
| 1041 |
|
| 1042 |
// Tracker |
| 1043 |
if(TRK2) { |
| 1044 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 1045 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 1046 |
}; |
| 1047 |
if(TRK1) { |
| 1048 |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 1049 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 1050 |
}; |
| 1051 |
if(TRKh) { |
| 1052 |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 1053 |
cout << "Tracker : set branch address TrkHough"<<endl; |
| 1054 |
}; |
| 1055 |
|
| 1056 |
// Calorimeter |
| 1057 |
if(CAL2) { |
| 1058 |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1059 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 1060 |
}; |
| 1061 |
if(CAL1) { |
| 1062 |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1063 |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 1064 |
}; |
| 1065 |
|
| 1066 |
// ToF |
| 1067 |
if(TOF) { |
| 1068 |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1069 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 1070 |
}; |
| 1071 |
// Trigger |
| 1072 |
if(TRG) { |
| 1073 |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1074 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1075 |
}; |
| 1076 |
// S4 |
| 1077 |
if(S4) { |
| 1078 |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1079 |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1080 |
}; |
| 1081 |
// Neutron Detector |
| 1082 |
if(ND) { |
| 1083 |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1084 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1085 |
}; |
| 1086 |
// Anticounters |
| 1087 |
if(AC) { |
| 1088 |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1089 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1090 |
}; |
| 1091 |
// OrbitalInfo |
| 1092 |
if(ORB) { |
| 1093 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1094 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1095 |
}; |
| 1096 |
|
| 1097 |
} |
| 1098 |
|
| 1099 |
|
| 1100 |
//-------------------------------------- |
| 1101 |
// |
| 1102 |
// |
| 1103 |
//-------------------------------------- |
| 1104 |
/** |
| 1105 |
* Get the Run tree chain from a list of files. |
| 1106 |
* @param fl Pointer to a TList of TSystemFiles |
| 1107 |
* @return Pointer to a TChain |
| 1108 |
*/ |
| 1109 |
TChain *PamLevel2::GetRunTree(TList *fl){ |
| 1110 |
|
| 1111 |
TChain *R = new TChain("Run"); |
| 1112 |
|
| 1113 |
// loop over files and create chains |
| 1114 |
TIter next(fl); |
| 1115 |
TSystemFile *questo = 0; |
| 1116 |
while ( (questo = (TSystemFile*) next()) ) { |
| 1117 |
TString name = questo->GetName(); |
| 1118 |
// cout << "File: "<< name << endl; |
| 1119 |
if( CheckLevel2File(name) ){ |
| 1120 |
R->Add(name); |
| 1121 |
}; |
| 1122 |
} |
| 1123 |
|
| 1124 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
| 1125 |
cout << "Run : set branch address RunInfo"<<endl; |
| 1126 |
|
| 1127 |
return R; |
| 1128 |
|
| 1129 |
} |
| 1130 |
//-------------------------------------- |
| 1131 |
// |
| 1132 |
// |
| 1133 |
//-------------------------------------- |
| 1134 |
/** |
| 1135 |
* Get the Run tree from a file. |
| 1136 |
* @param f Pointer to a TFile |
| 1137 |
* @return Pointer to a TTree |
| 1138 |
*/ |
| 1139 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
| 1140 |
|
| 1141 |
|
| 1142 |
TTree *R = (TTree*)f->Get("Run"); |
| 1143 |
|
| 1144 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
| 1145 |
cout << "Run : set branch address RunInfo"<<endl; |
| 1146 |
|
| 1147 |
return R; |
| 1148 |
|
| 1149 |
} |
| 1150 |
//-------------------------------------- |
| 1151 |
// |
| 1152 |
// |
| 1153 |
//-------------------------------------- |
| 1154 |
/** |
| 1155 |
* Set which trees shoul be analysed |
| 1156 |
* @param detlist TString containing the sequence of trees required |
| 1157 |
*/ |
| 1158 |
void PamLevel2::SetWhichTrees(TString detlist){ |
| 1159 |
|
| 1160 |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
| 1161 |
CAL1 = true; |
| 1162 |
CAL2 = true; |
| 1163 |
TRK2 = true; |
| 1164 |
TRK1 = false; |
| 1165 |
TRKh = false; |
| 1166 |
TRG = true; |
| 1167 |
TOF = true; |
| 1168 |
S4 = true; |
| 1169 |
ND = true; |
| 1170 |
AC = true; |
| 1171 |
ORB = true; |
| 1172 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
| 1173 |
CAL1 = false; |
| 1174 |
CAL2 = false; |
| 1175 |
TRK2 = false; |
| 1176 |
TRK1 = false; |
| 1177 |
TRKh = false; |
| 1178 |
TRG = false; |
| 1179 |
TOF = false; |
| 1180 |
S4 = false; |
| 1181 |
ND = false; |
| 1182 |
AC = false; |
| 1183 |
ORB = false; |
| 1184 |
}; |
| 1185 |
|
| 1186 |
// ------------------------------------------------------------------------- |
| 1187 |
if( detlist.Contains("CAL1", TString::kIgnoreCase) ){ |
| 1188 |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
| 1189 |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
| 1190 |
}; |
| 1191 |
|
| 1192 |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
| 1193 |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
| 1194 |
if ( detlist.Contains("+CAL2", TString::kIgnoreCase) )CAL2=true; |
| 1195 |
}; |
| 1196 |
|
| 1197 |
if( detlist.Contains("+CAL", TString::kIgnoreCase) && !CAL1 && !CAL2 )CAL2=true; |
| 1198 |
if( detlist.Contains("-CAL", TString::kIgnoreCase) && CAL1 && CAL2 ){ |
| 1199 |
CAL2=false; |
| 1200 |
CAL1=false; |
| 1201 |
} |
| 1202 |
// ------------------------------------------------------------------------- |
| 1203 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
| 1204 |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
| 1205 |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
| 1206 |
}; |
| 1207 |
|
| 1208 |
if( detlist.Contains("TRK2", TString::kIgnoreCase)){ |
| 1209 |
if ( detlist.Contains("-TRK2", TString::kIgnoreCase) )TRK2=false; |
| 1210 |
if ( detlist.Contains("+TRK2", TString::kIgnoreCase) )TRK2=true; |
| 1211 |
}; |
| 1212 |
|
| 1213 |
if( detlist.Contains("TRKh", TString::kIgnoreCase)){ |
| 1214 |
if ( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh=false; |
| 1215 |
if ( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh=true; |
| 1216 |
}; |
| 1217 |
|
| 1218 |
if( detlist.Contains("+TRK", TString::kIgnoreCase) && !TRK1 && !TRK2 && !TRKh )TRK2=true; |
| 1219 |
if( detlist.Contains("-TRK", TString::kIgnoreCase) && TRK1 && TRK2 && TRKh){ |
| 1220 |
TRK2=false; |
| 1221 |
TRK1=false; |
| 1222 |
TRKh=false; |
| 1223 |
} |
| 1224 |
// ------------------------------------------------------------------------- |
| 1225 |
|
| 1226 |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
| 1227 |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
| 1228 |
|
| 1229 |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
| 1230 |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
| 1231 |
|
| 1232 |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
| 1233 |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
| 1234 |
|
| 1235 |
if( detlist.Contains("-ND", TString::kIgnoreCase) )ND = false; |
| 1236 |
else if( detlist.Contains("+ND", TString::kIgnoreCase) )ND = true; |
| 1237 |
|
| 1238 |
if( detlist.Contains("-AC", TString::kIgnoreCase) )AC = false; |
| 1239 |
else if( detlist.Contains("+AC", TString::kIgnoreCase) )AC = true; |
| 1240 |
|
| 1241 |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
| 1242 |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
| 1243 |
|
| 1244 |
// cout<< "Set detector list --> "; |
| 1245 |
// if(TRK1)cout<<"TRK1 "; |
| 1246 |
// if(TRK2)cout<<"TRK2 "; |
| 1247 |
// if(TRKh)cout<<"TRKH "; |
| 1248 |
// if(CAL1)cout<<"CAL1 "; |
| 1249 |
// if(CAL2)cout<<"CAL2 "; |
| 1250 |
// if(TOF)cout<<"TOF "; |
| 1251 |
// if(TRG)cout<<"TRG "; |
| 1252 |
// if(AC)cout<<"AC "; |
| 1253 |
// if(ND)cout<<"ND "; |
| 1254 |
// if(S4)cout<<"S4 "; |
| 1255 |
// if(ORB)cout<<"ORB "; |
| 1256 |
// cout << endl; |
| 1257 |
|
| 1258 |
}; |
| 1259 |
|
| 1260 |
|
| 1261 |
/** |
| 1262 |
* Set tree/branch detector flags from the content of a tree |
| 1263 |
*/ |
| 1264 |
void PamLevel2::GetWhichTrees(TFile* f){ |
| 1265 |
|
| 1266 |
|
| 1267 |
// ----------- |
| 1268 |
// reset flags |
| 1269 |
// ----------- |
| 1270 |
CAL1 = false; |
| 1271 |
CAL2 = false; |
| 1272 |
TRK2 = false; |
| 1273 |
TRK1 = false; |
| 1274 |
TRKh = false; |
| 1275 |
TRG = false; |
| 1276 |
TOF = false; |
| 1277 |
S4 = false; |
| 1278 |
ND = false; |
| 1279 |
AC = false; |
| 1280 |
ORB = false; |
| 1281 |
|
| 1282 |
RUN = false; |
| 1283 |
|
| 1284 |
cout << "Checking file: "<<f->GetName()<<endl; |
| 1285 |
if( !f || f->IsZombie() ){ |
| 1286 |
cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; |
| 1287 |
return; |
| 1288 |
} |
| 1289 |
|
| 1290 |
TList *lk = f->GetListOfKeys(); |
| 1291 |
TIter next(lk); |
| 1292 |
TKey *key =0; |
| 1293 |
|
| 1294 |
Int_t nev = 0; |
| 1295 |
|
| 1296 |
while( (key = (TKey*)next()) ){ |
| 1297 |
|
| 1298 |
if( !strcmp(key->GetName(),"Run" ) )RUN = true; |
| 1299 |
|
| 1300 |
//========================================================= |
| 1301 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
| 1302 |
TRG = true; |
| 1303 |
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
| 1304 |
if( nev && nevt!=nev){ |
| 1305 |
cout << "File: "<< f->GetName() <<" Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1306 |
TRG = false; |
| 1307 |
}else nev=nevt; |
| 1308 |
} |
| 1309 |
//========================================================= |
| 1310 |
if( !strcmp(key->GetName(),"ToF" ) ){ |
| 1311 |
TOF = true; |
| 1312 |
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
| 1313 |
if( nev && nevt!=nev){ |
| 1314 |
cout << "File: "<< f->GetName() <<" ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1315 |
TOF = false; |
| 1316 |
}else nev=nevt; |
| 1317 |
} |
| 1318 |
//========================================================= |
| 1319 |
if( !strcmp(key->GetName(),"S4" ) ){ |
| 1320 |
S4 = true; |
| 1321 |
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
| 1322 |
if( nev && nevt!=nev){ |
| 1323 |
cout << "File: "<< f->GetName() <<" S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1324 |
S4 = false; |
| 1325 |
}else nev=nevt; |
| 1326 |
} |
| 1327 |
//========================================================= |
| 1328 |
|
| 1329 |
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
| 1330 |
ND = true; |
| 1331 |
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
| 1332 |
if( nev && nevt!=nev){ |
| 1333 |
cout << "File: "<< f->GetName() <<"NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1334 |
ND =false; |
| 1335 |
}else nev=nevt; |
| 1336 |
} |
| 1337 |
//========================================================= |
| 1338 |
if( !strcmp(key->GetName(),"Anticounter") ){ |
| 1339 |
AC = true; |
| 1340 |
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
| 1341 |
if( nev && nevt!=nev){ |
| 1342 |
cout << "File: "<< f->GetName() <<" Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1343 |
AC =false; |
| 1344 |
}else nev=nevt; |
| 1345 |
} |
| 1346 |
//========================================================= |
| 1347 |
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
| 1348 |
ORB = true; |
| 1349 |
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
| 1350 |
if( nev && nevt!=nev){ |
| 1351 |
cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1352 |
ORB = false; |
| 1353 |
}else nev=nevt; |
| 1354 |
} |
| 1355 |
//========================================================= |
| 1356 |
if( !strcmp(key->GetName(),"Tracker" ) ){ |
| 1357 |
TTree *T = (TTree*)f->Get("Tracker"); |
| 1358 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 1359 |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 1360 |
if( !name.CompareTo("TrkLevel1") )TRK1=true; |
| 1361 |
if( !name.CompareTo("TrkLevel2") )TRK2=true; |
| 1362 |
if( !name.CompareTo("TrkHough") )TRKh=true; |
| 1363 |
}; |
| 1364 |
Int_t nevt = T->GetEntries(); |
| 1365 |
if( nev && nevt!=nev){ |
| 1366 |
cout << "File: "<< f->GetName() <<" Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1367 |
TRK1 = false; |
| 1368 |
TRK2 = false; |
| 1369 |
TRKh = false; |
| 1370 |
}else nev=nevt; |
| 1371 |
T->Delete(); |
| 1372 |
}; |
| 1373 |
//========================================================= |
| 1374 |
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
| 1375 |
TTree *T = (TTree*)f->Get("Calorimeter"); |
| 1376 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 1377 |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 1378 |
if( !name.CompareTo("CaloLevel1") )CAL1=true; |
| 1379 |
if( !name.CompareTo("CaloLevel2") )CAL2=true; |
| 1380 |
}; |
| 1381 |
Int_t nevt = T->GetEntries(); |
| 1382 |
if( nev && nevt!=nev){ |
| 1383 |
cout << "File: "<< f->GetName() <<" Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1384 |
CAL1 = false; |
| 1385 |
CAL2 = false; |
| 1386 |
}else nev=nevt; |
| 1387 |
T->Delete(); |
| 1388 |
}; |
| 1389 |
|
| 1390 |
}; |
| 1391 |
|
| 1392 |
lk->Delete(); |
| 1393 |
|
| 1394 |
// cout<< "Get detector list from input file --> "; |
| 1395 |
// if(TRK1)cout<<"TRK1 "; |
| 1396 |
// if(TRK2)cout<<"TRK2 "; |
| 1397 |
// if(TRKh)cout<<"TRKH "; |
| 1398 |
// if(CAL1)cout<<"CAL1 "; |
| 1399 |
// if(CAL2)cout<<"CAL2 "; |
| 1400 |
// if(TOF)cout<<"TOF "; |
| 1401 |
// if(TRG)cout<<"TRG "; |
| 1402 |
// if(AC)cout<<"AC "; |
| 1403 |
// if(ND)cout<<"ND "; |
| 1404 |
// if(S4)cout<<"S4 "; |
| 1405 |
// if(ORB)cout<<"ORB "; |
| 1406 |
// cout << endl; |
| 1407 |
|
| 1408 |
return ; |
| 1409 |
|
| 1410 |
}; |
| 1411 |
|
| 1412 |
|
| 1413 |
//-------------------------------------- |
| 1414 |
// |
| 1415 |
// |
| 1416 |
//-------------------------------------- |
| 1417 |
/** |
| 1418 |
* Check if a file contains selected Pamela Level2 trees. |
| 1419 |
* @param name File name |
| 1420 |
* @return true if the file is ok. |
| 1421 |
*/ |
| 1422 |
Bool_t PamLevel2::CheckLevel2File(TString name){ |
| 1423 |
|
| 1424 |
Bool_t CAL1__ok = false; |
| 1425 |
Bool_t CAL2__ok = false; |
| 1426 |
Bool_t TRK2__ok = false; |
| 1427 |
Bool_t TRK1__ok = false; |
| 1428 |
Bool_t TRKh__ok = false; |
| 1429 |
Bool_t TRG__ok = false; |
| 1430 |
Bool_t TOF__ok = false; |
| 1431 |
Bool_t S4__ok = false; |
| 1432 |
Bool_t ND__ok = false; |
| 1433 |
Bool_t AC__ok = false; |
| 1434 |
Bool_t ORB__ok = false; |
| 1435 |
|
| 1436 |
Bool_t RUN__ok = false; |
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
cout << "Checking file: "<<name<<endl; |
| 1441 |
TFile *f = new TFile(name.Data()); |
| 1442 |
if( !f || f->IsZombie() ){ |
| 1443 |
cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false; |
| 1444 |
} |
| 1445 |
// cout << "Get list of keys: "<<f<<endl; |
| 1446 |
TList *lk = f->GetListOfKeys(); |
| 1447 |
// lk->Print(); |
| 1448 |
TIter next(lk); |
| 1449 |
TKey *key =0; |
| 1450 |
|
| 1451 |
Int_t nev = 0; |
| 1452 |
|
| 1453 |
while( (key = (TKey*)next()) ){ |
| 1454 |
|
| 1455 |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
| 1456 |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
| 1457 |
// nev_previous = nev; |
| 1458 |
// cout << " n.entries "<< nev <<endl; |
| 1459 |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
| 1460 |
// nev = ((TTree*)f->Get(key->GetName()))->GetEntries(); |
| 1461 |
// cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl; |
| 1462 |
// return false; |
| 1463 |
// }; |
| 1464 |
|
| 1465 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
| 1466 |
|
| 1467 |
//========================================================= |
| 1468 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
| 1469 |
TRG__ok = true; |
| 1470 |
if(TRG){ |
| 1471 |
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
| 1472 |
if( nev && nevt!=nev){ |
| 1473 |
cout << "File: "<< f->GetName() <<" discarded ---- Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1474 |
return false; |
| 1475 |
} |
| 1476 |
nev=nevt; |
| 1477 |
} |
| 1478 |
} |
| 1479 |
//========================================================= |
| 1480 |
if( !strcmp(key->GetName(),"ToF" ) ){ |
| 1481 |
TOF__ok = true; |
| 1482 |
if(TOF){ |
| 1483 |
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
| 1484 |
if( nev && nevt!=nev){ |
| 1485 |
cout << "File: "<< f->GetName() <<" discarded ---- ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1486 |
return false; |
| 1487 |
} |
| 1488 |
nev=nevt; |
| 1489 |
} |
| 1490 |
} |
| 1491 |
//========================================================= |
| 1492 |
if( !strcmp(key->GetName(),"S4" ) ){ |
| 1493 |
S4__ok = true; |
| 1494 |
if(S4){ |
| 1495 |
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
| 1496 |
if( nev && nevt!=nev){ |
| 1497 |
cout << "File: "<< f->GetName() <<" discarded ---- S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1498 |
return false; |
| 1499 |
} |
| 1500 |
nev=nevt; |
| 1501 |
} |
| 1502 |
} |
| 1503 |
//========================================================= |
| 1504 |
|
| 1505 |
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
| 1506 |
ND__ok = true; |
| 1507 |
if(ND){ |
| 1508 |
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
| 1509 |
if( nev && nevt!=nev){ |
| 1510 |
cout << "File: "<< f->GetName() <<" discarded ---- NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1511 |
return false; |
| 1512 |
} |
| 1513 |
nev=nevt; |
| 1514 |
} |
| 1515 |
} |
| 1516 |
//========================================================= |
| 1517 |
if( !strcmp(key->GetName(),"Anticounter") ){ |
| 1518 |
AC__ok = true; |
| 1519 |
if(AC){ |
| 1520 |
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
| 1521 |
if( nev && nevt!=nev){ |
| 1522 |
cout << "File: "<< f->GetName() <<" discarded ---- Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1523 |
return false; |
| 1524 |
} |
| 1525 |
nev=nevt; |
| 1526 |
} |
| 1527 |
} |
| 1528 |
//========================================================= |
| 1529 |
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
| 1530 |
ORB__ok = true; |
| 1531 |
if(ORB){ |
| 1532 |
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
| 1533 |
if( nev && nevt!=nev){ |
| 1534 |
cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1535 |
return false; |
| 1536 |
} |
| 1537 |
nev=nevt; |
| 1538 |
} |
| 1539 |
} |
| 1540 |
//========================================================= |
| 1541 |
if( !strcmp(key->GetName(),"Tracker" ) ){ |
| 1542 |
TTree *T = (TTree*)f->Get("Tracker"); |
| 1543 |
if(TRK1||TRK2||TRKh){ |
| 1544 |
Int_t nevt = T->GetEntries(); |
| 1545 |
if( nev && nevt!=nev){ |
| 1546 |
cout << "File: "<< f->GetName() <<" discarded ---- Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1547 |
return false; |
| 1548 |
} |
| 1549 |
nev=nevt; |
| 1550 |
} |
| 1551 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 1552 |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 1553 |
if( !name.CompareTo("TrkLevel1") )TRK1__ok=true; |
| 1554 |
if( !name.CompareTo("TrkLevel2") )TRK2__ok=true; |
| 1555 |
if( !name.CompareTo("TrkHough") )TRKh__ok=true; |
| 1556 |
}; |
| 1557 |
T->Delete(); |
| 1558 |
}; |
| 1559 |
//========================================================= |
| 1560 |
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
| 1561 |
TTree *T = (TTree*)f->Get("Calorimeter"); |
| 1562 |
if(CAL1||CAL2){ |
| 1563 |
Int_t nevt = T->GetEntries(); |
| 1564 |
if( nev && nevt!=nev){ |
| 1565 |
cout << "File: "<< f->GetName() <<" discarded ---- Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 1566 |
return false; |
| 1567 |
} |
| 1568 |
nev=nevt; |
| 1569 |
} |
| 1570 |
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 1571 |
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 1572 |
if( !name.CompareTo("CaloLevel1") )CAL1__ok=true; |
| 1573 |
if( !name.CompareTo("CaloLevel2") )CAL2__ok=true; |
| 1574 |
}; |
| 1575 |
T->Delete(); |
| 1576 |
}; |
| 1577 |
|
| 1578 |
}; |
| 1579 |
|
| 1580 |
// cout<< "CheckLevel2File(TString): detector list --> "; |
| 1581 |
// if(TRK1__ok)cout<<"TRK1 "; |
| 1582 |
// if(TRK2__ok)cout<<"TRK2 "; |
| 1583 |
// if(TRKh__ok)cout<<"TRKH "; |
| 1584 |
// if(CAL1__ok)cout<<"CAL1 "; |
| 1585 |
// if(CAL2__ok)cout<<"CAL2 "; |
| 1586 |
// if(TOF__ok)cout<<"TOF "; |
| 1587 |
// if(TRG__ok)cout<<"TRG "; |
| 1588 |
// if(AC__ok)cout<<"AC "; |
| 1589 |
// if(ND__ok)cout<<"ND "; |
| 1590 |
// if(S4__ok)cout<<"S4 "; |
| 1591 |
// if(ORB__ok)cout<<"ORB "; |
| 1592 |
// cout << endl; |
| 1593 |
|
| 1594 |
|
| 1595 |
if(!RUN__ok) { |
| 1596 |
cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl; |
| 1597 |
// return false; |
| 1598 |
}; |
| 1599 |
|
| 1600 |
if(CAL1 && !CAL1__ok){ |
| 1601 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel1 branch"<< endl; |
| 1602 |
return false; |
| 1603 |
}; |
| 1604 |
if(CAL2 && !CAL2__ok){ |
| 1605 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel2 branch"<< endl; |
| 1606 |
return false; |
| 1607 |
}; |
| 1608 |
if(TRK2 && !TRK2__ok){ |
| 1609 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel2 branch"<< endl; |
| 1610 |
return false; |
| 1611 |
}; |
| 1612 |
if(TRK1 && !TRK1__ok){ |
| 1613 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel1 branch"<< endl; |
| 1614 |
return false; |
| 1615 |
}; |
| 1616 |
if(TRKh && !TRKh__ok){ |
| 1617 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkHough branch"<< endl; |
| 1618 |
return false; |
| 1619 |
}; |
| 1620 |
if(ORB && !ORB__ok){ |
| 1621 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl; |
| 1622 |
return false; |
| 1623 |
}; |
| 1624 |
if(AC && !AC__ok){ |
| 1625 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl; |
| 1626 |
return false; |
| 1627 |
}; |
| 1628 |
if(S4 && !S4__ok){ |
| 1629 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl; |
| 1630 |
return false; |
| 1631 |
}; |
| 1632 |
if(TOF && !TOF__ok){ |
| 1633 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl; |
| 1634 |
return false; |
| 1635 |
}; |
| 1636 |
|
| 1637 |
if(ND && !ND__ok){ |
| 1638 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
| 1639 |
return false; |
| 1640 |
}; |
| 1641 |
if(TRG && !TRG__ok){ |
| 1642 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
| 1643 |
return false; |
| 1644 |
}; |
| 1645 |
|
| 1646 |
|
| 1647 |
lk->Delete(); |
| 1648 |
f->Close(); |
| 1649 |
|
| 1650 |
// cout<< "CheckLevel2File(TString): detector list --> "; |
| 1651 |
// if(TRK1)cout<<"TRK1 "; |
| 1652 |
// if(TRK2)cout<<"TRK2 "; |
| 1653 |
// if(TRKh)cout<<"TRKH "; |
| 1654 |
// if(CAL1)cout<<"CAL1 "; |
| 1655 |
// if(CAL2)cout<<"CAL2 "; |
| 1656 |
// if(TOF)cout<<"TOF "; |
| 1657 |
// if(TRG)cout<<"TRG "; |
| 1658 |
// if(AC)cout<<"AC "; |
| 1659 |
// if(ND)cout<<"ND "; |
| 1660 |
// if(S4)cout<<"S4 "; |
| 1661 |
// if(ORB)cout<<"ORB "; |
| 1662 |
// cout << endl; |
| 1663 |
|
| 1664 |
return true; |
| 1665 |
|
| 1666 |
}; |
| 1667 |
|
| 1668 |
|
| 1669 |
/** |
| 1670 |
* Create clone-trees |
| 1671 |
*/ |
| 1672 |
void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ |
| 1673 |
|
| 1674 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1675 |
cout << "Create clones of PAMELA trees "<<endl; |
| 1676 |
|
| 1677 |
Int_t i=0; |
| 1678 |
tree_clone[i] = fChain->GetTree()->CloneTree(0); |
| 1679 |
TString name = tree_clone[i]->GetName(); |
| 1680 |
name.Append("_clone"); |
| 1681 |
// tree_clone[i]->SetName(name.Data()); |
| 1682 |
cout << tree_clone[i]->GetName() <<endl; |
| 1683 |
i++; |
| 1684 |
|
| 1685 |
TList *li = fChain->GetListOfFriends(); |
| 1686 |
TIter next(li); |
| 1687 |
TFriendElement* T_friend=0; |
| 1688 |
ofile->cd(); |
| 1689 |
while( (T_friend = (TFriendElement*)next()) ){ |
| 1690 |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
| 1691 |
// cout<<T_friend->GetTree()->GetName()<< endl; |
| 1692 |
tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
| 1693 |
tree_clone[i]->SetAutoSave(1000000); |
| 1694 |
name = tree_clone[i]->GetName(); |
| 1695 |
name.Append("_clone"); |
| 1696 |
// tree_clone[i]->SetName(name.Data()); |
| 1697 |
cout << tree_clone[i]->GetName() << endl; |
| 1698 |
i++; |
| 1699 |
} |
| 1700 |
|
| 1701 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1702 |
|
| 1703 |
} |
| 1704 |
|
| 1705 |
/** |
| 1706 |
* Create clone-trees |
| 1707 |
*/ |
| 1708 |
void PamLevel2::CreateCloneTrees(TFile *ofile){ |
| 1709 |
|
| 1710 |
ofile->cd(); |
| 1711 |
|
| 1712 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1713 |
cout << "Create new PAMELA trees "<<endl; |
| 1714 |
|
| 1715 |
Int_t i=0; |
| 1716 |
|
| 1717 |
if(TRK1||TRK2||TRKh){ |
| 1718 |
tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
| 1719 |
if(TRK1) { |
| 1720 |
tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
| 1721 |
tree_clone[i]->BranchRef(); |
| 1722 |
cout << "Tracker : branch TrkLevel1"<<endl; |
| 1723 |
}; |
| 1724 |
if(TRK2) { |
| 1725 |
tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
| 1726 |
cout << "Tracker : branch TrkLevel2"<<endl; |
| 1727 |
}; |
| 1728 |
if(TRKh) { |
| 1729 |
tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
| 1730 |
cout << "Tracker : branch TrkHough"<<endl; |
| 1731 |
}; |
| 1732 |
i++; |
| 1733 |
} |
| 1734 |
|
| 1735 |
// Calorimeter |
| 1736 |
if(CAL1||CAL2){ |
| 1737 |
tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
| 1738 |
if(CAL1) { |
| 1739 |
tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1740 |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
| 1741 |
}; |
| 1742 |
if(CAL2) { |
| 1743 |
tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1744 |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
| 1745 |
}; |
| 1746 |
i++; |
| 1747 |
} |
| 1748 |
|
| 1749 |
// ToF |
| 1750 |
if(TOF) { |
| 1751 |
tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
| 1752 |
tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1753 |
cout << "ToF : branch ToFLevel2"<<endl; |
| 1754 |
i++; |
| 1755 |
}; |
| 1756 |
// Trigger |
| 1757 |
if(TRG) { |
| 1758 |
tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
| 1759 |
tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1760 |
cout << "Trigger : branch TrigLevel2"<<endl; |
| 1761 |
i++; |
| 1762 |
}; |
| 1763 |
// S4 |
| 1764 |
if(S4) { |
| 1765 |
tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
| 1766 |
tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
| 1767 |
cout << "S4 : branch S4Level2"<<endl; |
| 1768 |
i++; |
| 1769 |
}; |
| 1770 |
// Neutron Detector |
| 1771 |
if(ND) { |
| 1772 |
tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
| 1773 |
tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
| 1774 |
cout << "NeutronD : branch NDLevel2"<<endl; |
| 1775 |
i++; |
| 1776 |
}; |
| 1777 |
// Anticounters |
| 1778 |
if(AC) { |
| 1779 |
tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
| 1780 |
tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
| 1781 |
cout << "Anticounter : branch AcLevel2"<<endl; |
| 1782 |
i++; |
| 1783 |
}; |
| 1784 |
// OrbitalInfo |
| 1785 |
if(ORB) { |
| 1786 |
tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
| 1787 |
tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1788 |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
| 1789 |
i++; |
| 1790 |
}; |
| 1791 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1792 |
|
| 1793 |
} |
| 1794 |
|
| 1795 |
// /** |
| 1796 |
// * Create clone-trees |
| 1797 |
// */ |
| 1798 |
// void PamLevel2::CreateCloneTrees(){ |
| 1799 |
|
| 1800 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1801 |
// cout << "Create new PAMELA trees "<<endl; |
| 1802 |
|
| 1803 |
// if(TRK1||TRK2||TRKh){ |
| 1804 |
// T_clone = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
| 1805 |
// if(TRK1) { |
| 1806 |
// trk1_clone = new TrkLevel1(); |
| 1807 |
// T_clone->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
| 1808 |
// T_clone->BranchRef(); |
| 1809 |
// cout << "Tracker : branch TrkLevel1"<<endl; |
| 1810 |
// }; |
| 1811 |
// if(TRK2) { |
| 1812 |
// trk2_clone = new TrkLevel2(); |
| 1813 |
// T_clone->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
| 1814 |
// cout << "Tracker : branch TrkLevel2"<<endl; |
| 1815 |
// }; |
| 1816 |
// if(TRKh) { |
| 1817 |
// trkh_clone = new TrkHough(); |
| 1818 |
// T_clone->Branch("TrkHough","TrkHough", &trkh_clone); |
| 1819 |
// cout << "Tracker : branch TrkHough"<<endl; |
| 1820 |
// }; |
| 1821 |
// cout << hex << T_clone << dec << endl; |
| 1822 |
// } |
| 1823 |
|
| 1824 |
// // Calorimeter |
| 1825 |
// if(CAL1||CAL2){ |
| 1826 |
// C_clone = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
| 1827 |
// if(CAL1) { |
| 1828 |
// calo1_clone = new CaloLevel1(); |
| 1829 |
// C_clone->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
| 1830 |
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
| 1831 |
// }; |
| 1832 |
// if(CAL2) { |
| 1833 |
// calo2_clone = new CaloLevel2(); |
| 1834 |
// C_clone->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
| 1835 |
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
| 1836 |
// }; |
| 1837 |
// } |
| 1838 |
|
| 1839 |
// // ToF |
| 1840 |
// if(TOF) { |
| 1841 |
// O_clone = new TTree("ToF_clone","PAMELA ToF level2 data "); |
| 1842 |
// tof_clone = new ToFLevel2(); |
| 1843 |
// O_clone->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
| 1844 |
// cout << "ToF : branch ToFLevel2"<<endl; |
| 1845 |
// }; |
| 1846 |
// // Trigger |
| 1847 |
// if(TRG) { |
| 1848 |
// R_clone = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
| 1849 |
// trig_clone = new TrigLevel2(); |
| 1850 |
// R_clone->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
| 1851 |
// cout << "Trigger : branch TrigLevel2"<<endl; |
| 1852 |
// }; |
| 1853 |
// // S4 |
| 1854 |
// if(S4) { |
| 1855 |
// S_clone = new TTree("S4_clone","PAMELA S4 level2 data "); |
| 1856 |
// s4_clone = new S4Level2(); |
| 1857 |
// S_clone->Branch("S4Level2","S4Level2", &s4_clone); |
| 1858 |
// cout << "S4 : branch S4Level2"<<endl; |
| 1859 |
// }; |
| 1860 |
// // Neutron Detector |
| 1861 |
// if(ND) { |
| 1862 |
// N_clone = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
| 1863 |
// nd_clone = new NDLevel2(); |
| 1864 |
// N_clone->Branch("NDLevel2","NDLevel2", &nd_clone); |
| 1865 |
// cout << "NeutronD : branch NDLevel2"<<endl; |
| 1866 |
// }; |
| 1867 |
// // Anticounters |
| 1868 |
// if(AC) { |
| 1869 |
// A_clone = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
| 1870 |
// ac_clone = new AcLevel2(); |
| 1871 |
// A_clone->Branch("AcLevel2","AcLevel2", &ac_clone); |
| 1872 |
// cout << "Anticounter : branch AcLevel2"<<endl; |
| 1873 |
// }; |
| 1874 |
// // OrbitalInfo |
| 1875 |
// if(ORB) { |
| 1876 |
// B_clone = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
| 1877 |
// orb_clone = new OrbitalInfo(); |
| 1878 |
// B_clone->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
| 1879 |
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
| 1880 |
// }; |
| 1881 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1882 |
|
| 1883 |
// } |
| 1884 |
|
| 1885 |
/** |
| 1886 |
* Fill tree (created with CreateCloneTrees) |
| 1887 |
* |
| 1888 |
*/ |
| 1889 |
//void PamLevel2::FillNewPamTree(TTree *T){ |
| 1890 |
void PamLevel2::FillCloneTrees(){ |
| 1891 |
|
| 1892 |
// // -------------------------------------- |
| 1893 |
// // copy the event |
| 1894 |
// // -------------------------------------- |
| 1895 |
// if(trk1_clone) *trk1_clone = *trk1_obj; |
| 1896 |
// if(trk2_clone){ |
| 1897 |
// trk2_clone->Clear(); |
| 1898 |
// trk2_obj->Copy(*trk2_clone); |
| 1899 |
// // *trk2_clone = *trk2_obj; |
| 1900 |
// } |
| 1901 |
// if(trkh_clone) *trkh_clone = *trkh_obj; |
| 1902 |
// if(calo1_clone){ |
| 1903 |
// // *calo1_clone = *calo1_obj; |
| 1904 |
// calo1_clone->Clear(); |
| 1905 |
// calo1_obj->Copy(*calo1_clone); |
| 1906 |
// } |
| 1907 |
// if(calo2_clone){ |
| 1908 |
// // *calo2_clone = *calo2_obj; |
| 1909 |
// calo2_clone->Clear(); |
| 1910 |
// calo2_obj->Copy(*calo2_clone); |
| 1911 |
// } |
| 1912 |
// if(tof_clone) *tof_clone = *tof_obj; |
| 1913 |
// if(trig_clone) *trig_clone = *trig_obj; |
| 1914 |
// if(s4_clone) *s4_clone = *s4_obj; |
| 1915 |
// if(nd_clone) *nd_clone = *nd_obj; |
| 1916 |
// if(ac_clone) *ac_clone = *ac_obj; |
| 1917 |
// if(orb_clone) *orb_clone = *orb_obj; |
| 1918 |
|
| 1919 |
// if(T_clone)T_clone->Fill(); |
| 1920 |
// if(C_clone)C_clone->Fill(); |
| 1921 |
// if(O_clone)O_clone->Fill(); |
| 1922 |
// if(R_clone)R_clone->Fill(); |
| 1923 |
// if(S_clone)S_clone->Fill(); |
| 1924 |
// if(N_clone)N_clone->Fill(); |
| 1925 |
// if(A_clone)A_clone->Fill(); |
| 1926 |
// if(O_clone)O_clone->Fill(); |
| 1927 |
|
| 1928 |
for(Int_t i=0; i<8; i++){ |
| 1929 |
if(tree_clone[i])tree_clone[i]->Fill(); |
| 1930 |
} |
| 1931 |
} |
| 1932 |
|
| 1933 |
|
| 1934 |
TTree* PamLevel2::GetCloneTree(TString name){ |
| 1935 |
|
| 1936 |
for(Int_t i=0; i<8; i++){ |
| 1937 |
if(tree_clone[i]){ |
| 1938 |
TString na = tree_clone[i]->GetName(); |
| 1939 |
if(!name.CompareTo(na))return tree_clone[i]; |
| 1940 |
}; |
| 1941 |
} |
| 1942 |
return NULL; |
| 1943 |
|
| 1944 |
} |
| 1945 |
void PamLevel2::WriteCloneTrees(){ |
| 1946 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1947 |
cout << "Write clones of PAMELA trees "<<endl; |
| 1948 |
for(Int_t i=0; i<8; i++){ |
| 1949 |
if(tree_clone[i]){ |
| 1950 |
cout << tree_clone[i]->GetName()<<endl; |
| 1951 |
tree_clone[i]->Write(); |
| 1952 |
}; |
| 1953 |
} |
| 1954 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1955 |
|
| 1956 |
} |
| 1957 |
|
| 1958 |
/** |
| 1959 |
* Create a new (empty) Pamela trees |
| 1960 |
*/ |
| 1961 |
// TTree* PamLevel2::GetNewPamTree(){ |
| 1962 |
|
| 1963 |
// if(tree_clone)return tree_clone; |
| 1964 |
|
| 1965 |
// TTree *Tout = 0; |
| 1966 |
|
| 1967 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 1968 |
// cout << "Create new PAMELA trees "<<endl; |
| 1969 |
|
| 1970 |
|
| 1971 |
// if(TRK1||TRK2||TRKh){ |
| 1972 |
// TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
| 1973 |
// if(TRK1) { |
| 1974 |
// trk1_clone = new TrkLevel1(); |
| 1975 |
// T->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
| 1976 |
// T->BranchRef(); |
| 1977 |
// cout << "Tracker : branch TrkLevel1"<<endl; |
| 1978 |
// }; |
| 1979 |
// if(TRK2) { |
| 1980 |
// trk2_clone = new TrkLevel2(); |
| 1981 |
// T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
| 1982 |
// cout << "Tracker : branch TrkLevel2"<<endl; |
| 1983 |
// }; |
| 1984 |
// if(TRKh) { |
| 1985 |
// trkh_clone = new TrkHough(); |
| 1986 |
// T->Branch("TrkHough","TrkHough", &trkh_clone); |
| 1987 |
// cout << "Tracker : branch TrkHough"<<endl; |
| 1988 |
// }; |
| 1989 |
// if(!Tout)Tout=T; |
| 1990 |
// else Tout->AddFriend("Tracker_clone"); |
| 1991 |
// } |
| 1992 |
|
| 1993 |
// // Calorimeter |
| 1994 |
// if(CAL1||CAL2){ |
| 1995 |
// TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
| 1996 |
// if(CAL1) { |
| 1997 |
// calo1_clone = new CaloLevel1(); |
| 1998 |
// C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
| 1999 |
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
| 2000 |
// }; |
| 2001 |
// if(CAL2) { |
| 2002 |
// calo2_clone = new CaloLevel2(); |
| 2003 |
// C->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
| 2004 |
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
| 2005 |
// }; |
| 2006 |
// if(!Tout)Tout=C; |
| 2007 |
// else Tout->AddFriend("Calorimeter_clone"); |
| 2008 |
// } |
| 2009 |
|
| 2010 |
// // ToF |
| 2011 |
// if(TOF) { |
| 2012 |
// TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data "); |
| 2013 |
// tof_clone = new ToFLevel2(); |
| 2014 |
// O->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
| 2015 |
// cout << "ToF : branch ToFLevel2"<<endl; |
| 2016 |
// if(!Tout)Tout=O; |
| 2017 |
// else Tout->AddFriend("ToF_clone"); |
| 2018 |
// }; |
| 2019 |
// // Trigger |
| 2020 |
// if(TRG) { |
| 2021 |
// TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
| 2022 |
// trig_clone = new TrigLevel2(); |
| 2023 |
// R->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
| 2024 |
// cout << "Trigger : branch TrigLevel2"<<endl; |
| 2025 |
// if(!Tout)Tout=R; |
| 2026 |
// else Tout->AddFriend("Trigger_clone"); |
| 2027 |
// }; |
| 2028 |
// // S4 |
| 2029 |
// if(S4) { |
| 2030 |
// TTree *S = new TTree("S4_clone","PAMELA S4 level2 data "); |
| 2031 |
// s4_clone = new S4Level2(); |
| 2032 |
// S->Branch("S4Level2","S4Level2", &s4_clone); |
| 2033 |
// cout << "S4 : branch S4Level2"<<endl; |
| 2034 |
// if(!Tout)Tout=S; |
| 2035 |
// else Tout->AddFriend("S4_clone"); |
| 2036 |
// }; |
| 2037 |
// // Neutron Detector |
| 2038 |
// if(ND) { |
| 2039 |
// TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
| 2040 |
// nd_clone = new NDLevel2(); |
| 2041 |
// N->Branch("NDLevel2","NDLevel2", &nd_clone); |
| 2042 |
// cout << "NeutronD : branch NDLevel2"<<endl; |
| 2043 |
// if(!Tout)Tout=N; |
| 2044 |
// else Tout->AddFriend("NeutronD_clone"); |
| 2045 |
// }; |
| 2046 |
// // Anticounters |
| 2047 |
// if(AC) { |
| 2048 |
// TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
| 2049 |
// ac_clone = new AcLevel2(); |
| 2050 |
// A->Branch("AcLevel2","AcLevel2", &ac_clone); |
| 2051 |
// cout << "Anticounter : branch AcLevel2"<<endl; |
| 2052 |
// if(!Tout)Tout=A; |
| 2053 |
// else Tout->AddFriend("Anticounter_clone"); |
| 2054 |
// }; |
| 2055 |
// // OrbitalInfo |
| 2056 |
// if(ORB) { |
| 2057 |
// TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
| 2058 |
// orb_clone = new OrbitalInfo(); |
| 2059 |
// B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
| 2060 |
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
| 2061 |
// if(!Tout)Tout=B; |
| 2062 |
// else Tout->AddFriend("OrbitalInfo_clone"); |
| 2063 |
// }; |
| 2064 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2065 |
|
| 2066 |
// tree_clone = Tout; |
| 2067 |
// tree_clone->SetDirectory(0); |
| 2068 |
|
| 2069 |
// return Tout; |
| 2070 |
// } |
| 2071 |
// /** |
| 2072 |
// * Fill a tree (created with GetNewPamTree) |
| 2073 |
// * |
| 2074 |
// */ |
| 2075 |
// //void PamLevel2::FillNewPamTree(TTree *T){ |
| 2076 |
// void PamLevel2::FillNewPamTree(){ |
| 2077 |
|
| 2078 |
|
| 2079 |
// if(trk1_clone) *trk1_clone = *trk1_obj; |
| 2080 |
// if(trk2_clone){ |
| 2081 |
// trk2_clone->Clear(); |
| 2082 |
// trk2_obj->Copy(*trk2_clone); |
| 2083 |
// // *trk2_clone = *trk2_obj; |
| 2084 |
// } |
| 2085 |
// if(trkh_clone) *trkh_clone = *trkh_obj; |
| 2086 |
// if(calo1_clone){ |
| 2087 |
// // *calo1_clone = *calo1_obj; |
| 2088 |
// calo1_clone->Clear(); |
| 2089 |
// calo1_obj->Copy(*calo1_clone); |
| 2090 |
// } |
| 2091 |
// if(calo2_clone){ |
| 2092 |
// // *calo2_clone = *calo2_obj; |
| 2093 |
// calo2_clone->Clear(); |
| 2094 |
// calo2_obj->Copy(*calo2_clone); |
| 2095 |
// } |
| 2096 |
// if(tof_clone) *tof_clone = *tof_obj; |
| 2097 |
// if(trig_clone) *trig_clone = *trig_obj; |
| 2098 |
// if(s4_clone) *s4_clone = *s4_obj; |
| 2099 |
// if(nd_clone) *nd_clone = *nd_obj; |
| 2100 |
// if(ac_clone) *ac_clone = *ac_obj; |
| 2101 |
// if(orb_clone) *orb_clone = *orb_obj; |
| 2102 |
|
| 2103 |
// TTree *T = tree_clone; |
| 2104 |
|
| 2105 |
// T->Fill(); //fill main tree |
| 2106 |
// // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl; |
| 2107 |
// TList *li = T->GetListOfFriends(); |
| 2108 |
// TIter next(li); |
| 2109 |
// TFriendElement* T_friend=0; |
| 2110 |
// while( (T_friend = (TFriendElement*)next()) ){ |
| 2111 |
// // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
| 2112 |
// T_friend->GetTree()->Fill();//fill friends |
| 2113 |
// } |
| 2114 |
|
| 2115 |
// } |