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