| 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 |
// |
// |
| 86 |
//-------------------------------------- |
//-------------------------------------- |
| 87 |
/** |
/** |
| 88 |
* Constructor |
* Default Constructor |
| 89 |
*/ |
*/ |
| 90 |
PamLevel2::PamLevel2(){ |
PamLevel2::PamLevel2(){ |
| 91 |
|
Initialize(); |
| 92 |
|
}; |
| 93 |
|
|
| 94 |
|
/** |
| 95 |
|
* Constructor with given dir, list and detectors |
| 96 |
|
*/ |
| 97 |
|
PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){ |
| 98 |
|
Initialize(); |
| 99 |
|
GetPamTree(GetListOfLevel2Files(ddir,list),detlist); |
| 100 |
|
GetRunTree(GetListOfLevel2Files(ddir,list)); |
| 101 |
|
}; |
| 102 |
|
|
| 103 |
|
/** |
| 104 |
|
* Constructor with given dir and list |
| 105 |
|
*/ |
| 106 |
|
PamLevel2::PamLevel2(TString ddir,TString list){ |
| 107 |
|
Initialize(); |
| 108 |
|
GetPamTree(GetListOfLevel2Files(ddir,list),""); |
| 109 |
|
GetRunTree(GetListOfLevel2Files(ddir,list)); |
| 110 |
|
}; |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
void PamLevel2::Initialize(){ |
| 114 |
|
|
| 115 |
trk1_obj = this->TrkLevel1::GetTrkLevel1(); |
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
| 116 |
trk2_obj = this->TrkLevel2::GetTrkLevel2(); |
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
| 117 |
trkh_obj = this->TrkHough::GetTrkHough(); |
// trkh_obj = TrkHough::GetTrkHough(); |
| 118 |
calo1_obj = this->CaloLevel1::GetCaloLevel1(); |
// calo1_obj = CaloLevel1::GetCaloLevel1(); |
| 119 |
calo2_obj = this->CaloLevel2::GetCaloLevel2(); |
// calo2_obj = CaloLevel2::GetCaloLevel2(); |
| 120 |
tof_obj = this->ToFLevel2::GetToFLevel2(); |
// tof_obj = ToFLevel2::GetToFLevel2(); |
| 121 |
trig_obj = this->TrigLevel2::GetTrigLevel2(); |
// trig_obj = TrigLevel2::GetTrigLevel2(); |
| 122 |
s4_obj = this->S4Level2::GetS4Level2(); |
// s4_obj = S4Level2::GetS4Level2(); |
| 123 |
nd_obj = this->NDLevel2::GetNDLevel2(); |
// nd_obj = NDLevel2::GetNDLevel2(); |
| 124 |
ac_obj = this->AcLevel2::GetAcLevel2(); |
// ac_obj = AcLevel2::GetAcLevel2(); |
| 125 |
orb_obj = this->OrbitalInfo::GetOrbitalInfo(); |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
| 126 |
|
|
| 127 |
|
h0_obj = 0; |
| 128 |
|
trk0_obj = 0; |
| 129 |
|
calo0_obj = 0; |
| 130 |
|
|
| 131 |
|
trk2_obj = 0; |
| 132 |
|
trk1_obj = 0; |
| 133 |
|
trkh_obj = 0; |
| 134 |
|
calo1_obj = 0; |
| 135 |
|
calo2_obj = 0; |
| 136 |
|
tof_obj = 0; |
| 137 |
|
trig_obj = 0; |
| 138 |
|
s4_obj = 0; |
| 139 |
|
nd_obj = 0; |
| 140 |
|
ac_obj = 0; |
| 141 |
|
orb_obj = 0; |
| 142 |
|
|
| 143 |
|
run_obj = 0;//new GL_RUN(); |
| 144 |
|
soft_obj = 0;// Emiliano |
| 145 |
|
irun = -1LL; |
| 146 |
|
runfirstentry = 0LL; |
| 147 |
|
runlastentry = 0LL; |
| 148 |
|
|
| 149 |
|
l0_file = NULL; |
| 150 |
|
l0_tree = NULL; |
| 151 |
|
iroot = -1; |
| 152 |
|
dbc = 0; |
| 153 |
|
|
| 154 |
|
prevshift = 0; |
| 155 |
|
|
| 156 |
|
run_tree = NULL; |
| 157 |
|
run_tree_clone = NULL; |
| 158 |
|
sel_tree = NULL; |
| 159 |
|
sel_tree_clone = NULL; |
| 160 |
|
|
| 161 |
|
irunentry = -1LL; |
| 162 |
|
pam_tree = NULL; |
| 163 |
|
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
| 164 |
|
|
| 165 |
|
host = "mysql://localhost/pamelaprod"; |
| 166 |
|
user = "anonymous"; |
| 167 |
|
psw = ""; |
| 168 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 169 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 170 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 171 |
|
if ( !pamdbhost ) pamdbhost = ""; |
| 172 |
|
if ( !pamdbuser ) pamdbuser = ""; |
| 173 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 174 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 175 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 176 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 177 |
|
|
|
run_obj = new GL_RUN(); |
|
| 178 |
|
|
| 179 |
sorted_tracks = new TRefArray(); |
|
| 180 |
|
// sorted_tracks = 0;//new TRefArray(); |
| 181 |
|
|
| 182 |
|
CAL0 = false; |
| 183 |
|
CAL1 = true; |
| 184 |
CAL2 = true; |
CAL2 = true; |
| 185 |
TRK2 = true; |
TRK2 = true; |
| 186 |
TRK1 = false; |
TRK1 = false; |
| 187 |
TRKh = false; |
TRKh = false; |
| 188 |
TRG = true; |
TRKh = false; |
| 189 |
TOF = true; |
TRG = true; |
| 190 |
S4 = true; |
TOF = true; |
| 191 |
ND = true; |
TOF0 = false; |
| 192 |
AC = true; |
S4 = true; |
| 193 |
ORB = true; |
ND = true; |
| 194 |
|
AC = true; |
| 195 |
|
ORB = true; |
| 196 |
|
|
| 197 |
|
RUN = true; |
| 198 |
|
|
| 199 |
|
SELLI = -1; |
| 200 |
|
|
| 201 |
|
tsorted=0; |
| 202 |
|
timage=0; |
| 203 |
|
|
| 204 |
}; |
}; |
| 205 |
/** |
/** |
| 206 |
* Destructor |
* Delete the event (act as Dtor) |
| 207 |
*/ |
*/ |
| 208 |
PamLevel2::~PamLevel2(){ |
void PamLevel2::Delete(){ |
| 209 |
|
|
| 210 |
TrkLevel1::Clear(); |
if(run_obj)delete run_obj; |
| 211 |
|
if(soft_obj)delete soft_obj; //Emiliano |
| 212 |
TrkLevel2::Clear(); |
|
| 213 |
CaloLevel2::Clear(); |
// cout << "void PamLevel2::Clear()"<<endl; |
| 214 |
ToFLevel2::Clear(); |
if(h0_obj) delete h0_obj; |
| 215 |
TrigLevel2::Clear(); |
if(trk0_obj) delete trk0_obj; |
| 216 |
S4Level2::Clear(); |
if(calo0_obj) delete calo0_obj; |
| 217 |
NDLevel2::Clear(); |
if(trk1_obj) delete trk1_obj; |
| 218 |
AcLevel2::Clear(); |
if(trk2_obj) delete trk2_obj; |
| 219 |
OrbitalInfo::Clear(); |
if(trkh_obj) delete trkh_obj; |
| 220 |
|
if(calo1_obj)delete calo1_obj; |
| 221 |
|
if(calo2_obj)delete calo2_obj; |
| 222 |
|
if(tof_obj) delete tof_obj; |
| 223 |
|
if(trig_obj) delete trig_obj; |
| 224 |
|
if(s4_obj) delete s4_obj; |
| 225 |
|
if(nd_obj) delete nd_obj; |
| 226 |
|
if(ac_obj) delete ac_obj; |
| 227 |
|
if(orb_obj) delete orb_obj; |
| 228 |
|
|
| 229 |
|
if(tsorted){ |
| 230 |
|
tsorted->Delete(); |
| 231 |
|
delete tsorted; |
| 232 |
|
} |
| 233 |
|
if(timage){ |
| 234 |
|
timage->Delete(); |
| 235 |
|
delete timage; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
if(dbc){ |
| 239 |
|
dbc->Close(); |
| 240 |
|
delete dbc; |
| 241 |
|
} |
| 242 |
|
|
| 243 |
delete run_obj; |
if(l0_file)l0_file->Close(); |
| 244 |
|
// if(pam_tree)pam_tree->Delete();; |
| 245 |
|
|
| 246 |
|
if ( pam_tree ){ |
| 247 |
|
// |
| 248 |
|
// we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... |
| 249 |
|
// |
| 250 |
|
TList *temp = pam_tree->GetListOfFriends(); |
| 251 |
|
TList *contents = new TList; // create chain friend list |
| 252 |
|
contents->SetOwner(); |
| 253 |
|
TIter next(temp); |
| 254 |
|
TChain *questo = 0; |
| 255 |
|
while ( (questo = (TChain*) next()) ){ |
| 256 |
|
TString name = questo->GetName(); |
| 257 |
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
| 258 |
|
}; |
| 259 |
|
// |
| 260 |
|
// deleting the main chain |
| 261 |
|
// |
| 262 |
|
pam_tree->Delete(); |
| 263 |
|
// |
| 264 |
|
// deleting the friends... |
| 265 |
|
// |
| 266 |
|
TIter next2(contents); |
| 267 |
|
TChain *questa = 0; |
| 268 |
|
while ( questa = (TChain*)next2() ){ |
| 269 |
|
TString name = questa->GetName(); |
| 270 |
|
questa->Delete(); |
| 271 |
|
questa=NULL; |
| 272 |
|
}; |
| 273 |
|
// |
| 274 |
|
}; |
| 275 |
|
pam_tree = NULL; |
| 276 |
|
|
| 277 |
|
if(run_tree)run_tree->Delete();; |
| 278 |
|
if(sel_tree)sel_tree->Delete();; |
| 279 |
|
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
| 280 |
|
if(run_tree_clone)run_tree_clone->Delete();; |
| 281 |
|
if(sel_tree_clone)sel_tree_clone->Delete();; |
| 282 |
|
|
| 283 |
// delete sorted_tracks; |
|
|
sorted_tracks->Delete(); // clean the reference array |
|
|
|
|
|
|
|
| 284 |
}; |
}; |
| 285 |
|
|
| 286 |
/** |
/** |
| 287 |
* Clear the event |
* Clear the event (NB! does not deallocate objects) |
| 288 |
*/ |
*/ |
| 289 |
void PamLevel2::Clear(){ |
void PamLevel2::Clear(){ |
| 290 |
|
|
| 291 |
TrkLevel1::Clear(); |
// cout << "void PamLevel2::Clear()"<<endl; |
| 292 |
|
|
| 293 |
TrkLevel2::Clear(); |
// |
| 294 |
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 |
| 295 |
ToFLevel2::Clear(); |
// want to load them for each event even if they are the same... |
| 296 |
TrigLevel2::Clear(); |
// |
| 297 |
S4Level2::Clear(); |
// if(run_obj)delete run_obj; |
| 298 |
NDLevel2::Clear(); |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
| 299 |
AcLevel2::Clear(); |
// if(soft_obj) soft_obj->Clear(); |
| 300 |
OrbitalInfo::Clear(); |
|
| 301 |
|
if(h0_obj) h0_obj->Clear(); |
| 302 |
sorted_tracks->Delete(); // clean the reference array |
// if(trk0_obj) trk0_obj->Clear(); |
| 303 |
|
if(calo0_obj) calo0_obj->Clear(); |
| 304 |
|
if(trk1_obj) trk1_obj->Clear(); |
| 305 |
|
if(trk2_obj) trk2_obj->Clear(); |
| 306 |
|
if(trkh_obj) trkh_obj->Clear(); |
| 307 |
|
if(calo1_obj)calo1_obj->Clear(); |
| 308 |
|
if(calo2_obj)calo2_obj->Clear(); |
| 309 |
|
if(tof_obj) tof_obj->Clear(); |
| 310 |
|
if(trig_obj) trig_obj->Clear(); |
| 311 |
|
if(s4_obj) s4_obj->Clear(); |
| 312 |
|
if(nd_obj) nd_obj->Clear(); |
| 313 |
|
if(ac_obj) ac_obj->Clear(); |
| 314 |
|
if(orb_obj) orb_obj->Clear(); |
| 315 |
|
|
| 316 |
|
// if(sorted_tracks)sorted_tracks->Clear(); |
| 317 |
|
// sorted_tracks.Clear(); |
| 318 |
|
|
| 319 |
|
if(tsorted){ |
| 320 |
|
tsorted->Delete(); |
| 321 |
|
} |
| 322 |
|
if(timage){ |
| 323 |
|
timage->Delete(); |
| 324 |
|
} |
| 325 |
}; |
}; |
| 326 |
|
|
| 327 |
|
void PamLevel2::Reset(){ |
| 328 |
|
// |
| 329 |
|
// First of all clear everything |
| 330 |
|
// |
| 331 |
|
Clear(); |
| 332 |
|
// |
| 333 |
|
// close and reset chains and pointers |
| 334 |
|
// |
| 335 |
|
if ( pam_tree ){ |
| 336 |
|
// |
| 337 |
|
// we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... |
| 338 |
|
// |
| 339 |
|
TList *temp = pam_tree->GetListOfFriends(); |
| 340 |
|
TList *contents = new TList; // create chain friend list |
| 341 |
|
contents->SetOwner(); |
| 342 |
|
TIter next(temp); |
| 343 |
|
TChain *questo = 0; |
| 344 |
|
while ( (questo = (TChain*) next()) ){ |
| 345 |
|
TString name = questo->GetName(); |
| 346 |
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
| 347 |
|
}; |
| 348 |
|
// |
| 349 |
|
// deleting the main chain |
| 350 |
|
// |
| 351 |
|
pam_tree->Delete(); |
| 352 |
|
// |
| 353 |
|
// deleting the friends... |
| 354 |
|
// |
| 355 |
|
TIter next2(contents); |
| 356 |
|
TChain *questa = 0; |
| 357 |
|
while ( questa = (TChain*)next2() ){ |
| 358 |
|
TString name = questa->GetName(); |
| 359 |
|
questa->Delete(); |
| 360 |
|
questa=NULL; |
| 361 |
|
}; |
| 362 |
|
// |
| 363 |
|
}; |
| 364 |
|
pam_tree = NULL; |
| 365 |
|
// |
| 366 |
|
if(run_tree)run_tree->Delete();; |
| 367 |
|
run_tree = NULL; |
| 368 |
|
if(sel_tree)sel_tree->Delete();; |
| 369 |
|
sel_tree = NULL; |
| 370 |
|
// |
| 371 |
|
// Close file |
| 372 |
|
// |
| 373 |
|
if(l0_file)l0_file->Close("R"); |
| 374 |
|
l0_file = NULL; |
| 375 |
|
// |
| 376 |
|
h0_obj = 0; |
| 377 |
|
trk0_obj = 0; |
| 378 |
|
calo0_obj = 0; |
| 379 |
|
// |
| 380 |
|
trk2_obj = 0; |
| 381 |
|
trk1_obj = 0; |
| 382 |
|
trkh_obj = 0; |
| 383 |
|
calo1_obj = 0; |
| 384 |
|
calo2_obj = 0; |
| 385 |
|
tof_obj = 0; |
| 386 |
|
trig_obj = 0; |
| 387 |
|
s4_obj = 0; |
| 388 |
|
nd_obj = 0; |
| 389 |
|
ac_obj = 0; |
| 390 |
|
orb_obj = 0; |
| 391 |
|
// |
| 392 |
|
// Reset run pointers |
| 393 |
|
// |
| 394 |
|
run_obj = 0;//new GL_RUN(); |
| 395 |
|
soft_obj = 0;// Emiliano |
| 396 |
|
irun = -1; |
| 397 |
|
runfirstentry = 0ULL; |
| 398 |
|
runlastentry = 0ULL; |
| 399 |
|
// |
| 400 |
|
}; |
| 401 |
|
|
| 402 |
|
|
| 403 |
|
//-------------------------------------- |
| 404 |
|
// |
| 405 |
|
// |
| 406 |
|
//-------------------------------------- |
| 407 |
|
void *PamLevel2::GetPointerTo(const char* c ){ |
| 408 |
|
|
| 409 |
|
TString objname = c; |
| 410 |
|
|
| 411 |
|
if(!objname.CompareTo("TrkLevel1")) { |
| 412 |
|
if(!trk1_obj){ |
| 413 |
|
trk1_obj = new TrkLevel1(); |
| 414 |
|
trk1_obj->Set(); |
| 415 |
|
} |
| 416 |
|
return &trk1_obj; |
| 417 |
|
}; |
| 418 |
|
if(!objname.CompareTo("TrkLevel2")) { |
| 419 |
|
if(!trk2_obj){ |
| 420 |
|
trk2_obj = new TrkLevel2(); |
| 421 |
|
trk2_obj->Set(); |
| 422 |
|
} |
| 423 |
|
return &trk2_obj; |
| 424 |
|
}; |
| 425 |
|
if(!objname.CompareTo("TrkHough")) { |
| 426 |
|
if(!trkh_obj) trkh_obj = new TrkHough(); |
| 427 |
|
return &trkh_obj; |
| 428 |
|
}; |
| 429 |
|
if(!objname.CompareTo("CaloLevel1")) { |
| 430 |
|
if(!calo1_obj) calo1_obj = new CaloLevel1(); |
| 431 |
|
return &calo1_obj; |
| 432 |
|
}; |
| 433 |
|
if(!objname.CompareTo("CaloLevel2")) { |
| 434 |
|
if(!calo2_obj){ |
| 435 |
|
calo2_obj = new CaloLevel2(); |
| 436 |
|
calo2_obj->Set(); |
| 437 |
|
}; |
| 438 |
|
return &calo2_obj; |
| 439 |
|
}; |
| 440 |
|
if(!objname.CompareTo("ToFLevel2")) { |
| 441 |
|
if(!tof_obj){ |
| 442 |
|
tof_obj = new ToFLevel2(); |
| 443 |
|
tof_obj->Set(); |
| 444 |
|
} |
| 445 |
|
return &tof_obj; |
| 446 |
|
}; |
| 447 |
|
if(!objname.CompareTo("TrigLevel2")) { |
| 448 |
|
if(!trig_obj) trig_obj = new TrigLevel2(); |
| 449 |
|
return &trig_obj; |
| 450 |
|
}; |
| 451 |
|
if(!objname.CompareTo("S4Level2")) { |
| 452 |
|
if(!s4_obj) s4_obj = new S4Level2(); |
| 453 |
|
return &s4_obj; |
| 454 |
|
}; |
| 455 |
|
if(!objname.CompareTo("NDLevel2")) { |
| 456 |
|
if(!nd_obj) nd_obj = new NDLevel2(); |
| 457 |
|
return &nd_obj; |
| 458 |
|
}; |
| 459 |
|
if(!objname.CompareTo("AcLevel2")) { |
| 460 |
|
if(!ac_obj) ac_obj = new AcLevel2(); |
| 461 |
|
return &ac_obj; |
| 462 |
|
}; |
| 463 |
|
if(!objname.CompareTo("OrbitalInfo")){ |
| 464 |
|
if(!orb_obj) orb_obj = new OrbitalInfo(); |
| 465 |
|
return &orb_obj; |
| 466 |
|
}; |
| 467 |
|
|
| 468 |
|
if(!objname.CompareTo("RunInfo"))return &run_obj; |
| 469 |
|
|
| 470 |
|
if(!objname.CompareTo("SoftInfo"))return &soft_obj; // Emiliano |
| 471 |
|
|
| 472 |
|
return NULL; |
| 473 |
|
}; |
| 474 |
//-------------------------------------- |
//-------------------------------------- |
| 475 |
// |
// |
| 476 |
// |
// |
| 480 |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
| 481 |
*/ |
*/ |
| 482 |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ |
| 483 |
|
|
| 484 |
if( CaloLevel2::ntrk()==0 ){ |
if( !calo2_obj )return 0; |
| 485 |
|
|
| 486 |
|
if( calo2_obj->CaloLevel2::ntrk()==0 ){ |
| 487 |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl; |
| 488 |
return NULL; |
return NULL; |
| 489 |
}; |
}; |
| 492 |
Int_t it_calo=0; |
Int_t it_calo=0; |
| 493 |
|
|
| 494 |
do{ |
do{ |
| 495 |
c = CaloLevel2::GetCaloTrkVar(it_calo); |
c = calo2_obj->CaloLevel2::GetCaloTrkVar(it_calo); |
| 496 |
it_calo++; |
it_calo++; |
| 497 |
} while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_calo < calo2_obj->CaloLevel2::ntrk()); |
| 498 |
|
|
| 499 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
| 500 |
c = 0; |
c = 0; |
| 513 |
*/ |
*/ |
| 514 |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ |
| 515 |
|
|
| 516 |
if( ToFLevel2::ntrk()==0 ){ |
if( !tof_obj )return 0; |
| 517 |
|
|
| 518 |
|
if( tof_obj->ToFLevel2::ntrk()==0 ){ |
| 519 |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl; |
| 520 |
return NULL; |
return NULL; |
| 521 |
}; |
}; |
| 524 |
Int_t it_tof=0; |
Int_t it_tof=0; |
| 525 |
|
|
| 526 |
do{ |
do{ |
| 527 |
c = ToFLevel2::GetToFTrkVar(it_tof); |
c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); |
| 528 |
it_tof++; |
it_tof++; |
| 529 |
} while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); |
} while( c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); |
| 530 |
|
|
| 531 |
if(!c || seqno != c->trkseqno){ |
if(!c || seqno != c->trkseqno){ |
| 532 |
c = 0; |
c = 0; |
| 544 |
* 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. |
| 545 |
*/ |
*/ |
| 546 |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ |
| 547 |
|
|
| 548 |
|
cout <<"PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** "<<endl; |
| 549 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
| 550 |
|
|
| 551 |
CaloTrkVar *c = 0; |
CaloTrkVar *c = 0; |
| 552 |
ToFTrkVar *o = 0; |
ToFTrkVar *o = 0; |
| 553 |
|
|
| 572 |
|
|
| 573 |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){ |
| 574 |
|
|
| 575 |
|
cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl; |
| 576 |
|
cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl; |
| 577 |
|
cout <<"(if you use it, remember to delete the PamTrack object)"<<endl; |
| 578 |
PamTrack *track = 0; |
PamTrack *track = 0; |
| 579 |
|
|
| 580 |
if( itrk >=0 && itrk < TrkLevel2::ntrk() ){ |
if( itrk >=0 && itrk < trk2_obj->TrkLevel2::ntrk() ){ |
| 581 |
|
|
| 582 |
TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); |
TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); |
| 583 |
track = GetPamTrackAlong(t); |
track = GetPamTrackAlong(t); |
| 584 |
|
|
| 585 |
|
|
| 586 |
|
|
| 587 |
}else{ |
}else{ |
| 588 |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
| 589 |
}; |
}; |
| 590 |
|
|
| 591 |
return track; |
return track; |
| 608 |
*/ |
*/ |
| 609 |
void PamLevel2::SortTracks(TString how){ |
void PamLevel2::SortTracks(TString how){ |
| 610 |
|
|
| 611 |
|
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
| 612 |
|
if( !trk2_obj ){ |
| 613 |
|
cout << "void PamLevel2::SortTracks(TString how): TrkLevel2 not loaded !!!"; |
| 614 |
|
return; |
| 615 |
|
}; |
| 616 |
|
// cout << "call SortTracs() "<<endl; |
| 617 |
//Save current Object count |
//Save current Object count |
| 618 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
| 619 |
|
|
| 620 |
sorted_tracks->Delete(); //temporaneo??? |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
| 621 |
|
|
| 622 |
|
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
| 623 |
|
// sorted_tracks->Clear(); |
| 624 |
|
// sorted_tracks.Clear(); |
| 625 |
|
|
| 626 |
|
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
| 627 |
|
tsorted->Delete(); |
| 628 |
|
TClonesArray &ttsorted = *tsorted; |
| 629 |
|
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
| 630 |
|
timage->Delete(); |
| 631 |
|
TClonesArray &ttimage = *timage; |
| 632 |
|
|
| 633 |
|
|
| 634 |
// loop over the tracks sorted by the tracker |
// loop over the tracks sorted by the tracker |
| 635 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
| 636 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
| 640 |
if( !TOF && use_TOF) use_TOF = false; |
if( !TOF && use_TOF) use_TOF = false; |
| 641 |
|
|
| 642 |
if( !TRK2 ){ |
if( !TRK2 ){ |
| 643 |
cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
| 644 |
return; |
return; |
| 645 |
}; |
}; |
| 646 |
|
|
| 647 |
|
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
| 648 |
|
|
| 649 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
| 650 |
|
|
| 651 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
| 652 |
|
CaloTrkVar *cs = 0; |
| 653 |
|
ToFTrkVar *os = 0; |
| 654 |
|
|
| 655 |
// get tracker tracks |
// get tracker tracks |
| 656 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
| 657 |
CaloTrkVar *cp = 0; |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
| 658 |
ToFTrkVar *op = 0; |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
| 659 |
|
|
| 660 |
|
TrkTrack *ti = 0; //tracker (image) |
| 661 |
|
CaloTrkVar *ci = 0; |
| 662 |
|
ToFTrkVar *oi = 0; |
| 663 |
|
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
| 664 |
// if track has an image, check image selection |
// if track has an image, check image selection |
| 665 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
| 666 |
|
|
| 667 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
| 668 |
CaloTrkVar *ci = 0; |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
| 669 |
ToFTrkVar *oi = 0; |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
| 670 |
|
|
| 671 |
|
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
| 672 |
|
|
| 673 |
//assign starting scores |
//assign starting scores |
| 674 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
| 675 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
| 679 |
// ------------------------ |
// ------------------------ |
| 680 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
| 681 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
| 682 |
|
if( use_CAL && !calo2_obj ){ |
| 683 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but CaloLevel2 not loaded !!!"; |
| 684 |
|
return; |
| 685 |
|
}; |
| 686 |
if( |
if( |
| 687 |
use_CAL && |
use_CAL && |
| 688 |
npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
| 689 |
varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
| 690 |
|
cp && ci && |
| 691 |
true){ |
true){ |
| 692 |
|
|
| 693 |
|
|
| 694 |
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
| 695 |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
|
|
|
|
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
|
|
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
|
| 696 |
|
|
| 697 |
if(resy_p <= resy_i) tp_score++; |
if(resy_p <= resy_i) tp_score++; |
| 698 |
else ti_score++; |
else ti_score++; |
| 699 |
|
|
| 700 |
|
// cout << "CALO "<<tp_score<<ti_score<<endl; |
| 701 |
|
|
| 702 |
}; |
}; |
| 703 |
// ------------------------ |
// ------------------------ |
| 704 |
// TOF check |
// TOF check |
| 705 |
// ------------------------ |
// ------------------------ |
| 706 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
| 707 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
| 708 |
if( use_TOF ){ |
if( use_TOF && !tof_obj ){ |
| 709 |
|
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
| 710 |
|
return; |
| 711 |
|
}; |
| 712 |
|
if( use_TOF && op && oi ){ |
| 713 |
|
|
| 714 |
Int_t nphit_p =0; |
Int_t nphit_p =0; |
| 715 |
Int_t nphit_i =0; |
Int_t nphit_i =0; |
| 716 |
|
|
|
op = GetToFStoredTrack(tp->GetSeqNo()); |
|
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
|
| 717 |
|
|
| 718 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
| 719 |
cout << "track: npmttdc "<< op->npmttdc << endl; |
cout << "track: npmttdc "<< op->npmttdc << endl; |
| 721 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
| 722 |
|
|
| 723 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
| 724 |
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
| 725 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
| 726 |
}; |
}; |
| 727 |
|
|
| 728 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
| 729 |
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
| 730 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
| 731 |
}; |
}; |
| 732 |
|
|
| 738 |
if( nphit_p >= nphit_i) tp_score++; |
if( nphit_p >= nphit_i) tp_score++; |
| 739 |
else ti_score++; |
else ti_score++; |
| 740 |
}; |
}; |
| 741 |
|
// cout << "TOF "<<tp_score<<ti_score<<endl; |
| 742 |
}; |
}; |
| 743 |
if(tp_score == ti_score) use_TRK = true; |
if(tp_score == ti_score) use_TRK = true; |
| 744 |
// ------------------------ |
// ------------------------ |
| 750 |
if(use_TRK){ |
if(use_TRK){ |
| 751 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
| 752 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
| 753 |
|
// cout << "TRK "<<tp_score<<ti_score<<endl; |
| 754 |
}; |
}; |
| 755 |
|
|
| 756 |
// ------------------------ |
// ------------------------ |
| 757 |
// the winner is.... |
// the winner is.... |
| 758 |
// ------------------------ |
// ------------------------ |
| 759 |
if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! |
if (tp_score > ti_score) { |
| 760 |
else if (tp_score < ti_score) ts = ti;//its image!! |
// ts = tp;//the track sorted by the tracker!! |
| 761 |
else { |
// cs = cp; |
| 762 |
ts = tp; |
// os = op; |
| 763 |
|
}else if (tp_score < ti_score) { |
| 764 |
|
ts = ti;//its image!! |
| 765 |
|
cs = ci; |
| 766 |
|
os = oi; |
| 767 |
|
|
| 768 |
|
ti = tp;//its image!! |
| 769 |
|
ci = cp; |
| 770 |
|
oi = op; |
| 771 |
|
|
| 772 |
|
tp = ts;//its image!! |
| 773 |
|
cp = cs; |
| 774 |
|
op = os; |
| 775 |
|
|
| 776 |
|
|
| 777 |
|
}else { |
| 778 |
|
// ts = tp; |
| 779 |
|
// cs = cp; |
| 780 |
|
// os = op; |
| 781 |
// cout << "Warning - track image ambiguity not solved" << endl; |
// cout << "Warning - track image ambiguity not solved" << endl; |
| 782 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
| 783 |
}; |
}; |
| 784 |
|
|
| 785 |
}else{ |
}else{ |
| 786 |
ts = tp; |
// ts = tp; |
| 787 |
|
// cs = cp; |
| 788 |
|
// os = op; |
| 789 |
}; |
}; |
| 790 |
|
|
| 791 |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
| 792 |
sorted_tracks->Add(ts);//save the track in the sorted array |
// sorted_tracks->Add(ts);//save the track in the sorted array |
| 793 |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
// sorted_tracks.Add(ts);//save the track in the sorted array |
| 794 |
|
// sorted_tracks.Add(tp);//save the track in the sorted array |
| 795 |
}; |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
| 796 |
|
// cout<<"o "<<tp<<endl; |
| 797 |
|
// cout<<"o "<<cp<<endl; |
| 798 |
|
// cout<<"o "<<op<<endl; |
| 799 |
|
new(ttsorted[i]) PamTrack(tp,cp,op); |
| 800 |
|
new(ttimage[i]) PamTrack(ti,ci,oi); |
| 801 |
|
}; |
| 802 |
|
|
| 803 |
|
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
| 804 |
|
cout << "void PamLevel2::SortTracks(TString how): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
| 805 |
|
tsorted->Delete(); tsorted=0; |
| 806 |
|
timage->Delete(); timage=0; |
| 807 |
|
} |
| 808 |
|
|
| 809 |
//Restore Object count |
//Restore Object count |
| 810 |
//To save space in the table keeping track of all referenced objects |
//To save space in the table keeping track of all referenced objects |
| 811 |
//we assume that our events do not address each other. We reset the |
//We reset the object count to what it was at the beginning of the event. |
|
//object count to what it was at the beginning of the event. |
|
| 812 |
TProcessID::SetObjectCount(ObjectNumber); |
TProcessID::SetObjectCount(ObjectNumber); |
| 813 |
|
|
| 814 |
}; |
}; |
| 820 |
* 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. |
| 821 |
* 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. |
| 822 |
*/ |
*/ |
| 823 |
TRefArray *PamLevel2::GetTracks(){ |
// TRefArray *PamLevel2::GetTracks(){ |
| 824 |
|
|
| 825 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 826 |
|
// SortTracks("+CAL+TOF"); |
| 827 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 828 |
|
|
| 829 |
|
// // return sorted_tracks; |
| 830 |
|
// return &sorted_tracks; |
| 831 |
|
|
| 832 |
|
// }; |
| 833 |
|
TClonesArray *PamLevel2::GetTracks(){ |
| 834 |
|
|
| 835 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 836 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
| 837 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 838 |
|
|
| 839 |
return sorted_tracks; |
return tsorted; |
| 840 |
|
|
| 841 |
}; |
}; |
| 842 |
//-------------------------------------- |
//-------------------------------------- |
| 843 |
// |
// |
| 849 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
| 850 |
*/ |
*/ |
| 851 |
PamTrack *PamLevel2::GetTrack(int it){ |
PamTrack *PamLevel2::GetTrack(int it){ |
| 852 |
|
|
| 853 |
|
// if(!trk2_obj) return 0; |
| 854 |
|
|
| 855 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 856 |
|
// SortTracks("+CAL+TOF"); |
| 857 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 858 |
|
// // if(!sorted_tracks)return 0; |
| 859 |
|
// if(sorted_tracks.IsEmpty())return 0; |
| 860 |
|
|
| 861 |
|
// PamTrack *track = 0; |
| 862 |
|
|
| 863 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && it<sorted_tracks.GetEntriesFast() ){ |
| 864 |
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
| 865 |
|
// track = GetPamTrackAlong(t); |
| 866 |
|
// }else{ |
| 867 |
|
// cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
| 868 |
|
// }; |
| 869 |
|
|
| 870 |
|
// return track; |
| 871 |
|
|
| 872 |
|
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
| 873 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 874 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
| 875 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 876 |
|
if(!tsorted)return 0; |
| 877 |
|
if(!tsorted->GetEntries())return 0; |
| 878 |
|
|
| 879 |
PamTrack *track = 0; |
PamTrack *track = 0; |
| 880 |
|
|
| 881 |
if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){ |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks()){ |
| 882 |
TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); |
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
| 883 |
track = GetPamTrackAlong(t); |
// track = GetPamTrackAlong(t); |
| 884 |
|
TClonesArray &t = *(tsorted); |
| 885 |
|
track = (PamTrack*)t[it]; |
| 886 |
|
|
| 887 |
}else{ |
}else{ |
| 888 |
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; |
| 889 |
}; |
}; |
| 890 |
|
|
| 891 |
return track; |
return track; |
| 902 |
*/ |
*/ |
| 903 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
PamTrack *PamLevel2::GetTrackImage(int it){ |
| 904 |
|
|
| 905 |
|
// if(!trk2_obj) return 0; |
| 906 |
|
|
| 907 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 908 |
|
// SortTracks("+CAL+TOF"); |
| 909 |
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
| 910 |
|
// // if(!sorted_tracks)return 0; |
| 911 |
|
// if(sorted_tracks.IsEmpty())return 0; |
| 912 |
|
|
| 913 |
|
// PamTrack *image = 0; |
| 914 |
|
|
| 915 |
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
| 916 |
|
// TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it); |
| 917 |
|
// if( temp->HasImage() ){ |
| 918 |
|
// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
| 919 |
|
// image = GetPamTrackAlong(t); |
| 920 |
|
// }else{ |
| 921 |
|
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
| 922 |
|
// }; |
| 923 |
|
// }else{ |
| 924 |
|
// cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
| 925 |
|
// }; |
| 926 |
|
|
| 927 |
|
// return image; |
| 928 |
|
|
| 929 |
|
|
| 930 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 931 |
SortTracks("+CAL+TOF"); |
SortTracks("+CAL+TOF"); |
| 932 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
| 933 |
|
if(!timage)return 0; |
| 934 |
|
if(!timage->GetEntries())return 0; |
| 935 |
|
|
| 936 |
PamTrack *image = 0; |
PamTrack *image = 0; |
| 937 |
|
|
| 938 |
if( it >=0 && it < TrkLevel2::GetNTracks() ){ |
if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ |
| 939 |
TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); |
TClonesArray &t = *(tsorted); |
| 940 |
if( temp->HasImage() ){ |
PamTrack *temp = (PamTrack*)t[it]; |
| 941 |
TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); |
if( temp->GetTrkTrack()->HasImage() ){ |
| 942 |
image = GetPamTrackAlong(t); |
TClonesArray &t = *(timage); |
| 943 |
|
image = (PamTrack*)t[it]; |
| 944 |
}else{ |
}else{ |
| 945 |
cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl; |
| 946 |
}; |
}; |
| 947 |
}else{ |
}else{ |
| 948 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl; |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
| 949 |
}; |
}; |
| 950 |
|
|
| 951 |
return image; |
return image; |
| 961 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
| 962 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
| 963 |
*/ |
*/ |
| 964 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ){ |
| 965 |
|
|
| 966 |
|
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
| 967 |
|
// else GetWhichTrees(f); |
| 968 |
|
if ( pam_tree ){ |
| 969 |
|
printf("WARNING: TTree *PamLevel2::GetPamTree(TFile *fl, TString detlist) -- pam_tree already exists!\n "); |
| 970 |
|
return pam_tree; |
| 971 |
|
}; |
| 972 |
|
// |
| 973 |
|
|
| 974 |
|
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
| 975 |
|
|
|
// cout << "WARNING!!! -- obsolete method -- \n"; |
|
|
// cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
|
|
|
|
|
TTree *Trout =0; |
|
|
|
|
| 976 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
| 977 |
|
|
| 978 |
|
TTree *Trout =0; |
| 979 |
|
|
| 980 |
|
TString fname = f->GetName(); |
| 981 |
|
if(!CheckLevel2File(fname))return NULL; |
| 982 |
|
|
| 983 |
|
// UInt_t *found=0; |
| 984 |
|
|
| 985 |
|
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
| 986 |
|
if(TRK1)cout<<"TRK1 "; |
| 987 |
|
if(TRK2)cout<<"TRK2 "; |
| 988 |
|
if(TRKh)cout<<"TRKH "; |
| 989 |
|
if(CAL1)cout<<"CAL1 "; |
| 990 |
|
if(CAL2)cout<<"CAL2 "; |
| 991 |
|
if(TOF)cout<<"TOF "; |
| 992 |
|
if(TRG)cout<<"TRG "; |
| 993 |
|
if(AC)cout<<"AC "; |
| 994 |
|
if(ND)cout<<"ND "; |
| 995 |
|
if(S4)cout<<"S4 "; |
| 996 |
|
if(ORB)cout<<"ORB "; |
| 997 |
|
cout << endl; |
| 998 |
|
if(SELLI)cout<<">>> Found selection-list <<<"<<endl; |
| 999 |
|
|
| 1000 |
|
f->cd(); |
| 1001 |
|
|
| 1002 |
// Tracker |
// Tracker |
| 1003 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
| 1004 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
| 1005 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 1006 |
|
// else T->SetBranchStatus("TrkLevel2",0,found); |
| 1007 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 1008 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 1009 |
|
// else T->SetBranchStatus("TrkLevel1",0,found); |
| 1010 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 1011 |
// if(TRKh)T->SetBranchAddress("TrkHough", GetPointerToTrk(3)); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 1012 |
// if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
// else T->SetBranchStatus("TrkHough",0,found); |
| 1013 |
Trout=T; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
| 1014 |
|
if(!Trout)Trout=T; |
| 1015 |
|
else Trout->AddFriend(T); |
| 1016 |
}else{ |
}else{ |
| 1017 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
| 1018 |
}; |
}; |
| 1019 |
// Calorimeter |
// Calorimeter |
| 1020 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
TTree *C = (TTree*)f->Get("Calorimeter"); |
| 1021 |
if(C && CAL2) { |
if(C && (CAL2||CAL1)) { |
| 1022 |
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1023 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
// else C->SetBranchStatus("CaloLevel2",0,found); |
| 1024 |
|
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 1025 |
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1026 |
|
// else C->SetBranchStatus("CaloLevel1",0,found); |
| 1027 |
|
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 1028 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
| 1029 |
else Trout->AddFriend(C); |
else Trout->AddFriend(C); |
| 1030 |
}else{ |
}else{ |
| 1031 |
cout << "Calorimeter : missing tree"<<endl; |
cout << "Calorimeter : missing tree"<<endl; |
| 1032 |
}; |
}; |
| 1033 |
|
|
| 1034 |
// ToF |
// ToF |
| 1035 |
TTree *O = (TTree*)f->Get("ToF"); |
TTree *O = (TTree*)f->Get("ToF"); |
| 1036 |
if(O && TOF) { |
if(O && TOF) { |
| 1037 |
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1038 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 1039 |
if(!Trout)Trout=O; |
if(!Trout)Trout=O; |
| 1040 |
else Trout->AddFriend(O); |
else Trout->AddFriend(O); |
| 1044 |
// Trigger |
// Trigger |
| 1045 |
TTree *R = (TTree*)f->Get("Trigger"); |
TTree *R = (TTree*)f->Get("Trigger"); |
| 1046 |
if(R && TRG) { |
if(R && TRG) { |
| 1047 |
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1048 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1049 |
if(!Trout)Trout=O; |
if(!Trout)Trout=R; |
| 1050 |
else Trout->AddFriend(R); |
else Trout->AddFriend(R); |
| 1051 |
}else{ |
}else{ |
| 1052 |
cout << "Trigger : missing tree"<<endl; |
cout << "Trigger : missing tree"<<endl; |
| 1054 |
// S4 |
// S4 |
| 1055 |
TTree *S = (TTree*)f->Get("S4"); |
TTree *S = (TTree*)f->Get("S4"); |
| 1056 |
if(S && S4) { |
if(S && S4) { |
| 1057 |
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1058 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1059 |
if(!Trout)Trout=O; |
if(!Trout)Trout=S; |
| 1060 |
else Trout->AddFriend(S); |
else Trout->AddFriend(S); |
| 1061 |
}else{ |
}else{ |
| 1062 |
cout << "S4 : missing tree"<<endl; |
cout << "S4 : missing tree"<<endl; |
| 1064 |
// Neutron Detector |
// Neutron Detector |
| 1065 |
TTree *N = (TTree*)f->Get("NeutronD"); |
TTree *N = (TTree*)f->Get("NeutronD"); |
| 1066 |
if(N && ND) { |
if(N && ND) { |
| 1067 |
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1068 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1069 |
if(!Trout)Trout=O; |
if(!Trout)Trout=N; |
| 1070 |
else Trout->AddFriend(N); |
else Trout->AddFriend(N); |
| 1071 |
}else{ |
}else{ |
| 1072 |
cout << "NeutronD : missing tree"<<endl; |
cout << "NeutronD : missing tree"<<endl; |
| 1074 |
// Anticounters |
// Anticounters |
| 1075 |
TTree *A = (TTree*)f->Get("Anticounter"); |
TTree *A = (TTree*)f->Get("Anticounter"); |
| 1076 |
if(A && AC) { |
if(A && AC) { |
| 1077 |
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1078 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1079 |
if(!Trout)Trout=O; |
if(!Trout)Trout=A; |
| 1080 |
else Trout->AddFriend(A); |
else Trout->AddFriend(A); |
| 1081 |
}else{ |
}else{ |
| 1082 |
cout << "Anticounter : missing tree"<<endl; |
cout << "Anticounter : missing tree"<<endl; |
| 1083 |
}; |
}; |
| 1084 |
// Orbital Info |
// Orbital Info |
| 1085 |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
| 1086 |
if(B && ORB) { |
if(B && ORB) { |
| 1087 |
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1088 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1089 |
if(!Trout)Trout=O; |
if(!Trout)Trout=B; |
| 1090 |
else Trout->AddFriend(B); |
else Trout->AddFriend(B); |
| 1091 |
}else{ |
}else{ |
| 1092 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
| 1093 |
}; |
}; |
| 1094 |
|
|
| 1095 |
|
TTree *L = (TTree*)f->Get("SelectionList"); |
| 1096 |
|
if(L && SELLI==1) { |
| 1097 |
|
// L->SetBranchAddress("RunEntry",&irun); |
| 1098 |
|
// cout << "SelectionList: set branch address RunEntry"<<endl; |
| 1099 |
|
// L->SetBranchAddress("EventEntry",&irunentry); |
| 1100 |
|
// cout << "SelectionList: set branch address EventEntry"<<endl; |
| 1101 |
|
// if(!Trout)Trout=O; |
| 1102 |
|
// else Trout->AddFriend("SelectionList"); |
| 1103 |
|
cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemente!!!!"<<endl; |
| 1104 |
|
sel_tree = 0; |
| 1105 |
|
}else{ |
| 1106 |
|
cout << "SelectionList : missing tree"<<endl; |
| 1107 |
|
}; |
| 1108 |
|
|
| 1109 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
| 1110 |
|
|
| 1111 |
return Trout; |
pam_tree = (TChain*)Trout; |
| 1112 |
|
|
| 1113 |
|
return Trout; |
| 1114 |
|
|
| 1115 |
} |
} |
| 1116 |
//-------------------------------------- |
//-------------------------------------- |
| 1128 |
|
|
| 1129 |
TString wdir = gSystem->WorkingDirectory(); |
TString wdir = gSystem->WorkingDirectory(); |
| 1130 |
|
|
| 1131 |
if(ddir=="")ddir = wdir; |
// if(ddir=="")ddir = wdir; |
| 1132 |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
| 1133 |
cout << "Level2 data directory : "<< ddir << endl; |
if ( ddir != ""){ |
| 1134 |
|
cout << "Level2 data directory : "<< ddir << endl; |
| 1135 |
|
} else { |
| 1136 |
|
cout << "Level2 data directory not given as input: trying to evaluate from list or taking working directory " << endl; |
| 1137 |
|
}; |
| 1138 |
TList *contents = new TList; // create output list |
TList *contents = new TList; // create output list |
| 1139 |
contents->SetOwner(); |
contents->SetOwner(); |
| 1140 |
|
|
| 1141 |
char *fullpath; |
// char *fullpath; |
| 1142 |
|
// const char *fullpath; |
| 1143 |
|
|
| 1144 |
// if no input file list is given: |
// if no input file list is given: |
| 1145 |
if ( flisttxt != "" ){ |
if ( flisttxt != "" ){ |
| 1146 |
|
|
| 1147 |
if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0; |
// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ |
| 1148 |
|
// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ |
| 1149 |
// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
// cout <<"File "<<flisttxt<<" not found"<<endl; |
| 1150 |
flisttxt = fullpath; |
// return 0; |
| 1151 |
|
// } |
| 1152 |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
// flisttxt = fullpath; |
| 1153 |
|
if ( !flisttxt.EndsWith(".root") ){ |
| 1154 |
|
|
| 1155 |
|
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
| 1156 |
|
|
| 1157 |
|
if( !gSystem->ChangeDirectory(ddir) ){ |
| 1158 |
|
cout << "Cannot change directory : "<<ddir<<endl; |
| 1159 |
|
return 0; |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
cout <<"Input file list : " << flisttxt <<endl; |
cout <<"Input file list : " << flisttxt <<endl; |
| 1163 |
ifstream in; |
ifstream in; |
| 1164 |
in.open(flisttxt, ios::in); //open input file list |
in.open(flisttxt, ios::in); //open input file list |
| 1165 |
|
if(!in.good()){ |
| 1166 |
|
cout <<" ERROR opening the file "<<endl; |
| 1167 |
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
| 1168 |
|
return 0; |
| 1169 |
|
} |
| 1170 |
|
int line=0; |
| 1171 |
while (1) { |
while (1) { |
| 1172 |
TString file; |
TString file; |
| 1173 |
in >> file; |
in >> file; |
| 1174 |
if (!in.good()) break; |
if (!in.good()) break; |
| 1175 |
|
line++; |
| 1176 |
// cout <<"(1) " << file << endl; |
// cout <<"(1) " << file << endl; |
| 1177 |
|
if(file.IsNull()){ |
| 1178 |
|
cout << "-- list interrupted at line "<<line <<endl; |
| 1179 |
|
break; |
| 1180 |
|
} |
| 1181 |
if(file.Contains("#"))file = file(0,file.First("#")); |
if(file.Contains("#"))file = file(0,file.First("#")); |
| 1182 |
// cout <<"(2) " << file << endl; |
// cout <<"(2) " << file << endl; |
| 1183 |
|
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
| 1184 |
if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
| 1185 |
|
if( file.EndsWith(".root") ){ |
| 1186 |
|
TString filedir; |
| 1187 |
|
if (ddir != ""){ |
| 1188 |
|
filedir = ddir; // take the input dir |
| 1189 |
|
} else { |
| 1190 |
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
| 1191 |
|
filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir |
| 1192 |
|
}; |
| 1193 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file)); |
| 1194 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
| 1195 |
|
delete fullpath; |
| 1196 |
}else{ |
} |
| 1197 |
if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
// }else{ |
| 1198 |
}; |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
| 1199 |
|
// }; |
| 1200 |
}; |
}; |
| 1201 |
in.close(); |
in.close(); |
| 1202 |
|
} else { |
| 1203 |
|
if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); |
| 1204 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
| 1205 |
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
| 1206 |
|
delete fullpath; |
| 1207 |
|
}; |
| 1208 |
}else{ |
}else{ |
| 1209 |
|
|
| 1210 |
cout << "No input file list given."<<endl; |
cout << "No input file list given."<<endl; |
| 1211 |
cout << "Check for existing root files."<<endl; |
cout << "Check for existing root files."<<endl; |
| 1212 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
| 1213 |
|
if ( ddir == "" ){ |
| 1214 |
|
ddir = wdir; |
| 1215 |
|
cout << "Level2 data directory : "<< ddir << endl; |
| 1216 |
|
}; |
| 1217 |
|
|
| 1218 |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
| 1219 |
TList *temp = datadir->GetListOfFiles(); |
TList *temp = datadir->GetListOfFiles(); |
| 1220 |
// temp->Print(); |
// temp->Print(); |
| 1227 |
while ( (questo = (TSystemFile*) next()) ) { |
while ( (questo = (TSystemFile*) next()) ) { |
| 1228 |
TString name = questo-> GetName(); |
TString name = questo-> GetName(); |
| 1229 |
if( name.EndsWith(".root") ){ |
if( name.EndsWith(".root") ){ |
| 1230 |
char *fullpath; |
// const char *fullpath = gSystem->FindFile(ddir,name); |
| 1231 |
gSystem->IsFileInIncludePath(name,&fullpath); |
// char *fullpath; |
| 1232 |
|
// gSystem->IsFileInIncludePath(name,&fullpath); |
| 1233 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name)); |
| 1234 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); |
| 1235 |
|
delete fullpath; |
| 1236 |
}; |
}; |
| 1237 |
} |
} |
| 1238 |
delete temp; |
delete temp; |
| 1242 |
gSystem->ChangeDirectory(wdir); // back to the working directory |
gSystem->ChangeDirectory(wdir); // back to the working directory |
| 1243 |
// cout << endl << "Selected files:" << endl; |
// cout << endl << "Selected files:" << endl; |
| 1244 |
// contents->Print(); |
// contents->Print(); |
| 1245 |
cout << contents->GetEntries()<<" files selected\n"; |
cout << contents->GetEntries()<<" files \n"; |
| 1246 |
// cout << endl; |
// cout << endl; |
| 1247 |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
| 1248 |
return contents; |
return contents; |
| 1257 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
| 1258 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
| 1259 |
*/ |
*/ |
| 1260 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
| 1261 |
|
// |
| 1262 |
// TChain *Tout=0; |
// |
| 1263 |
// if(Tout)Tout->Delete(); |
// |
| 1264 |
// Tout = NULL; |
if ( pam_tree ){ |
| 1265 |
|
printf("WARNING: TChain *PamLevel2::GetPamTree(TList *fl, TString detlist) -- pam_tree already exists!\n "); |
| 1266 |
|
return pam_tree; |
| 1267 |
|
}; |
| 1268 |
|
// |
| 1269 |
|
|
| 1270 |
TChain *Tout =0; |
TChain *Trout =0; |
| 1271 |
|
|
| 1272 |
|
// if( !detlist.IsNull() )SetWhichTrees(detlist); |
| 1273 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
| 1274 |
|
|
| 1275 |
TChain *T = 0; |
cout<< "GetPamTree(TList*,TString): input detector list --> "; |
| 1276 |
TChain *C = 0; |
if(TRK1)cout<<"TRK1 "; |
| 1277 |
TChain *O = 0; |
if(TRK2)cout<<"TRK2 "; |
| 1278 |
TChain *R = 0; |
if(TRKh)cout<<"TRKH "; |
| 1279 |
TChain *S = 0; |
if(CAL1)cout<<"CAL1 "; |
| 1280 |
TChain *N = 0; |
if(CAL2)cout<<"CAL2 "; |
| 1281 |
TChain *A = 0; |
if(TOF)cout<<"TOF "; |
| 1282 |
TChain *B = 0; |
if(TRG)cout<<"TRG "; |
| 1283 |
|
if(AC)cout<<"AC "; |
| 1284 |
|
if(ND)cout<<"ND "; |
| 1285 |
|
if(S4)cout<<"S4 "; |
| 1286 |
|
if(ORB)cout<<"ORB "; |
| 1287 |
|
cout << endl; |
| 1288 |
|
|
| 1289 |
|
TChain *T = 0; |
| 1290 |
|
TChain *C = 0; |
| 1291 |
|
TChain *O = 0; |
| 1292 |
|
TChain *R = 0; |
| 1293 |
|
TChain *S = 0; |
| 1294 |
|
TChain *N = 0; |
| 1295 |
|
TChain *A = 0; |
| 1296 |
|
TChain *B = 0; |
| 1297 |
|
|
| 1298 |
|
TChain *L = 0; |
| 1299 |
|
|
| 1300 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
| 1301 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
| 1302 |
if(TOF) O = new TChain("ToF"); |
if(TOF) O = new TChain("ToF"); |
| 1303 |
if(TRG) R = new TChain("Trigger"); |
if(TRG) R = new TChain("Trigger"); |
| 1304 |
if(S4) S = new TChain("S4"); |
if(S4) S = new TChain("S4"); |
| 1305 |
if(ND) N = new TChain("NeutronD"); |
if(ND) N = new TChain("NeutronD"); |
| 1306 |
if(AC) A = new TChain("Anticounter"); |
if(AC) A = new TChain("Anticounter"); |
| 1307 |
if(ORB) B = new TChain("OrbitalInfo"); |
if(ORB) B = new TChain("OrbitalInfo"); |
| 1308 |
|
L = new TChain("SelectionList"); |
| 1309 |
|
|
| 1310 |
// loop over files and create chains |
// loop over files and create chains |
| 1311 |
TIter next(fl); |
TIter next(fl); |
| 1312 |
TSystemFile *questo = 0; |
TSystemFile *questo = 0; |
| 1313 |
while ( (questo = (TSystemFile*) next()) ) { |
while ( (questo = (TSystemFile*) next()) ) { |
| 1314 |
TString name = questo->GetName(); |
TString name = questo->GetName(); |
| 1315 |
// cout << "File: "<< name << endl; |
cout << "File: "<< name << endl; |
| 1316 |
if( CheckLevel2File(name) ){ |
if( CheckLevel2File(name) ){ |
| 1317 |
if(TRK2||TRK1||TRKh) T->Add(name); |
if(TRK2||TRK1||TRKh) T->Add(name); |
| 1318 |
if(CAL1||CAL2) C->Add(name); |
if(CAL1||CAL2) C->Add(name); |
| 1319 |
if(TOF) O->Add(name); |
if(TOF) O->Add(name); |
| 1320 |
if(TRG) R->Add(name); |
if(TRG) R->Add(name); |
| 1321 |
if(S4) S->Add(name); |
if(S4) S->Add(name); |
| 1322 |
if(ND) N->Add(name); |
if(ND) N->Add(name); |
| 1323 |
if(AC) A->Add(name); |
if(AC) A->Add(name); |
| 1324 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
| 1325 |
|
if(SELLI==1) L->Add(name); |
| 1326 |
}; |
}; |
| 1327 |
} |
}; |
| 1328 |
|
|
| 1329 |
cout << "done chain \n"; |
cout << "done chain \n"; |
| 1330 |
|
|
| 1331 |
// Tracker |
// UInt_t *found=0; |
| 1332 |
if(TRK2||TRK1||TRKh)if(!Tout)Tout=T; |
// Tracker |
| 1333 |
|
if(T && (TRK2||TRK1||TRKh)) { |
| 1334 |
|
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 1335 |
|
// else T->SetBranchStatus("TrkLevel2",0,found); |
| 1336 |
|
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 1337 |
|
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 1338 |
|
// else T->SetBranchStatus("TrkLevel1",0,found); |
| 1339 |
|
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 1340 |
|
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 1341 |
|
// else T->SetBranchStatus("TrkHough",0,found); |
| 1342 |
|
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
| 1343 |
|
if(!Trout)Trout=T; |
| 1344 |
|
else Trout->AddFriend("Tracker"); |
| 1345 |
|
}else{ |
| 1346 |
|
cout << "Tracker : missing tree"<<endl; |
| 1347 |
|
}; |
| 1348 |
// Calorimeter |
// Calorimeter |
| 1349 |
if(CAL2||CAL1) { |
if(C && (CAL2||CAL1)) { |
| 1350 |
if(!Tout)Tout=C; |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1351 |
else Tout->AddFriend("Calorimeter"); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
| 1352 |
|
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 1353 |
|
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1354 |
|
// else C->SetBranchStatus("CaloLevel1",0,found); |
| 1355 |
|
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 1356 |
|
if(!Trout)Trout=C; |
| 1357 |
|
else Trout->AddFriend("Calorimeter"); |
| 1358 |
|
}else{ |
| 1359 |
|
cout << "Calorimeter : missing tree"<<endl; |
| 1360 |
}; |
}; |
| 1361 |
// ToF |
// ToF |
| 1362 |
if(TOF) { |
if(O && TOF) { |
| 1363 |
if(!Tout)Tout=O; |
O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1364 |
else Tout->AddFriend("ToF"); |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 1365 |
|
if(!Trout)Trout=O; |
| 1366 |
|
else Trout->AddFriend("ToF"); |
| 1367 |
|
}else{ |
| 1368 |
|
cout << "ToF : missing tree"<<endl; |
| 1369 |
}; |
}; |
| 1370 |
// Trigger |
// Trigger |
| 1371 |
if(TRG) { |
if(R && TRG) { |
| 1372 |
if(!Tout)Tout=O; |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1373 |
else Tout->AddFriend("Trigger"); |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1374 |
|
if(!Trout)Trout=O; |
| 1375 |
|
else Trout->AddFriend("Trigger"); |
| 1376 |
|
}else{ |
| 1377 |
|
cout << "Trigger : missing tree"<<endl; |
| 1378 |
}; |
}; |
| 1379 |
// S4 |
// S4 |
| 1380 |
if(S4) { |
if(S && S4) { |
| 1381 |
if(!Tout)Tout=O; |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1382 |
else Tout->AddFriend("S4"); |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1383 |
|
if(!Trout)Trout=O; |
| 1384 |
|
else Trout->AddFriend("S4"); |
| 1385 |
|
}else{ |
| 1386 |
|
cout << "S4 : missing tree"<<endl; |
| 1387 |
}; |
}; |
| 1388 |
// Neutron Detector |
// Neutron Detector |
| 1389 |
if(ND) { |
if(N && ND) { |
| 1390 |
if(!Tout)Tout=O; |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1391 |
else Tout->AddFriend("NeutronD"); |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1392 |
|
if(!Trout)Trout=O; |
| 1393 |
|
else Trout->AddFriend("NeutronD"); |
| 1394 |
|
}else{ |
| 1395 |
|
cout << "NeutronD : missing tree"<<endl; |
| 1396 |
}; |
}; |
| 1397 |
// Anticounters |
// Anticounters |
| 1398 |
if(AC) { |
if(A && AC) { |
| 1399 |
if(!Tout)Tout=O; |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1400 |
else Tout->AddFriend("Anticounter"); |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1401 |
|
if(!Trout)Trout=O; |
| 1402 |
|
else Trout->AddFriend("Anticounter"); |
| 1403 |
|
}else{ |
| 1404 |
|
cout << "Anticounter : missing tree"<<endl; |
| 1405 |
}; |
}; |
| 1406 |
// OrbitalInfo |
// Orbital Info |
| 1407 |
if(ORB) { |
if(B && ORB) { |
| 1408 |
if(!Tout)Tout=O; |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1409 |
else Tout->AddFriend("OrbitalInfo"); |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1410 |
|
if(!Trout)Trout=O; |
| 1411 |
|
else Trout->AddFriend("OrbitalInfo"); |
| 1412 |
|
}else{ |
| 1413 |
|
cout << "OrbitalInfo : missing tree"<<endl; |
| 1414 |
|
}; |
| 1415 |
|
|
| 1416 |
|
// Selection List |
| 1417 |
|
if(L && SELLI==1) { |
| 1418 |
|
cout<<">>> Found selection-list <<<"<<endl; |
| 1419 |
|
L->SetBranchAddress("RunEntry",&irun); |
| 1420 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
| 1421 |
|
L->SetBranchAddress("EventEntry",&irunentry); |
| 1422 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
| 1423 |
|
sel_tree = L; |
| 1424 |
|
// if(!Trout)Trout=O; |
| 1425 |
|
// else Trout->AddFriend("SelectionList"); |
| 1426 |
|
}else{ |
| 1427 |
|
// cout << "SelectionList : missing tree"<<endl; |
| 1428 |
|
if(L)L->Delete(); |
| 1429 |
}; |
}; |
| 1430 |
|
|
| 1431 |
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
| 1432 |
|
|
| 1433 |
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress(); |
pam_tree = Trout; |
| 1434 |
if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
|
| 1435 |
|
return Trout; |
|
return Tout; |
|
| 1436 |
} |
} |
| 1437 |
|
|
| 1438 |
|
|
| 1446 |
*/ |
*/ |
| 1447 |
void PamLevel2::SetBranchAddress(TTree *t){ |
void PamLevel2::SetBranchAddress(TTree *t){ |
| 1448 |
|
|
|
|
|
|
|
|
| 1449 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
| 1450 |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
| 1451 |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
| 1461 |
|
|
| 1462 |
// Tracker |
// Tracker |
| 1463 |
if(TRK1) { |
if(TRK1) { |
| 1464 |
t->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel2")); |
| 1465 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 1466 |
}; |
}; |
| 1467 |
if(TRK2) { |
if(TRK2) { |
| 1468 |
t->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
| 1469 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 1470 |
}; |
}; |
| 1471 |
if(TRKh) { |
if(TRKh) { |
| 1472 |
t->SetBranchAddress("TrkHough", GetPointerToTrk(3)); |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 1473 |
cout << "Tracker : set branch address TrkHough"<<endl; |
cout << "Tracker : set branch address TrkHough"<<endl; |
| 1474 |
}; |
}; |
| 1475 |
|
|
| 1476 |
// Calorimeter |
// Calorimeter |
| 1477 |
if(CAL1) { |
if(CAL1) { |
| 1478 |
t->SetBranchAddress("CaloLevel1", GetPointerToCalo(1)); |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1479 |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 1480 |
}; |
}; |
| 1481 |
if(CAL2) { |
if(CAL2) { |
| 1482 |
t->SetBranchAddress("CaloLevel2", GetPointerToCalo(2)); |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1483 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 1484 |
}; |
}; |
| 1485 |
|
|
| 1486 |
// ToF |
// ToF |
| 1487 |
if(TOF) { |
if(TOF) { |
| 1488 |
t->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1489 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 1490 |
}; |
}; |
| 1491 |
// Trigger |
// Trigger |
| 1492 |
if(TRG) { |
if(TRG) { |
| 1493 |
t->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1494 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1495 |
}; |
}; |
| 1496 |
// S4 |
// S4 |
| 1497 |
if(S4) { |
if(S4) { |
| 1498 |
t->SetBranchAddress("S4Level2", GetPointerToS4()); |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1499 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1500 |
}; |
}; |
| 1501 |
// Neutron Detector |
// Neutron Detector |
| 1502 |
if(ND) { |
if(ND) { |
| 1503 |
t->SetBranchAddress("NDLevel2", GetPointerToND()); |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1504 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1505 |
}; |
}; |
| 1506 |
// Anticounters |
// Anticounters |
| 1507 |
if(AC) { |
if(AC) { |
| 1508 |
t->SetBranchAddress("AcLevel2", GetPointerToAc()); |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1509 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1510 |
}; |
}; |
| 1511 |
// OrbitalInfo |
// OrbitalInfo |
| 1512 |
if(ORB) { |
if(ORB) { |
| 1513 |
t->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1514 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1515 |
}; |
}; |
| 1516 |
|
// SelectionList |
| 1517 |
|
if(SELLI==1) { |
| 1518 |
|
t->SetBranchAddress("RunEntry", &irun); |
| 1519 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
| 1520 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
| 1521 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
| 1522 |
|
}; |
| 1523 |
|
|
| 1524 |
} |
} |
| 1525 |
/** |
/** |
| 1527 |
*/ |
*/ |
| 1528 |
void PamLevel2::SetBranchAddress(TChain *t){ |
void PamLevel2::SetBranchAddress(TChain *t){ |
| 1529 |
|
|
|
|
|
|
|
|
|
|
|
| 1530 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
| 1531 |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
| 1532 |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
| 1539 |
AC = AC & t->GetBranchStatus("AcLevel2"); |
AC = AC & t->GetBranchStatus("AcLevel2"); |
| 1540 |
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
| 1541 |
|
|
|
|
|
|
|
|
| 1542 |
// Tracker |
// Tracker |
| 1543 |
|
if(TRK2) { |
| 1544 |
|
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
| 1545 |
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
| 1546 |
|
}; |
| 1547 |
if(TRK1) { |
if(TRK1) { |
| 1548 |
t->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
| 1549 |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
cout << "Tracker : set branch address TrkLevel1"<<endl; |
| 1550 |
}; |
}; |
|
if(TRK2) { |
|
|
t->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
|
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
|
|
}; |
|
| 1551 |
if(TRKh) { |
if(TRKh) { |
| 1552 |
t->SetBranchAddress("TrkHough", GetPointerToTrk(3)); |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
| 1553 |
cout << "Tracker : set branch address TrkHough"<<endl; |
cout << "Tracker : set branch address TrkHough"<<endl; |
| 1554 |
}; |
}; |
| 1555 |
|
|
| 1556 |
// Calorimeter |
// Calorimeter |
|
if(CAL1) { |
|
|
t->SetBranchAddress("CaloLevel1", GetPointerToCalo(1)); |
|
|
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
|
|
}; |
|
| 1557 |
if(CAL2) { |
if(CAL2) { |
| 1558 |
t->SetBranchAddress("CaloLevel2", GetPointerToCalo(2)); |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
| 1559 |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
| 1560 |
}; |
}; |
| 1561 |
|
if(CAL1) { |
| 1562 |
|
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
| 1563 |
|
cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
| 1564 |
|
}; |
| 1565 |
|
|
| 1566 |
// ToF |
// ToF |
| 1567 |
if(TOF) { |
if(TOF) { |
| 1568 |
t->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); |
| 1569 |
cout << "ToF : set branch address ToFLevel2"<<endl; |
cout << "ToF : set branch address ToFLevel2"<<endl; |
| 1570 |
}; |
}; |
| 1571 |
// Trigger |
// Trigger |
| 1572 |
if(TRG) { |
if(TRG) { |
| 1573 |
t->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
| 1574 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
| 1575 |
}; |
}; |
| 1576 |
// S4 |
// S4 |
| 1577 |
if(S4) { |
if(S4) { |
| 1578 |
t->SetBranchAddress("S4Level2", GetPointerToS4()); |
t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
| 1579 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
| 1580 |
}; |
}; |
| 1581 |
// Neutron Detector |
// Neutron Detector |
| 1582 |
if(ND) { |
if(ND) { |
| 1583 |
t->SetBranchAddress("NDLevel2", GetPointerToND()); |
t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
| 1584 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
| 1585 |
}; |
}; |
| 1586 |
// Anticounters |
// Anticounters |
| 1587 |
if(AC) { |
if(AC) { |
| 1588 |
t->SetBranchAddress("AcLevel2", GetPointerToAc()); |
t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
| 1589 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
| 1590 |
}; |
}; |
| 1591 |
// OrbitalInfo |
// OrbitalInfo |
| 1592 |
if(ORB) { |
if(ORB) { |
| 1593 |
t->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 1594 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
| 1595 |
}; |
}; |
| 1596 |
|
// SelectionList |
| 1597 |
|
if(SELLI==1) { |
| 1598 |
|
t->SetBranchAddress("RunEntry", &irun); |
| 1599 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
| 1600 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
| 1601 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
| 1602 |
|
}; |
| 1603 |
|
|
| 1604 |
} |
} |
| 1605 |
//-------------------------------------- |
|
| 1606 |
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
void *PamLevel2::GetPointerTo(const char* c ){ |
|
|
// cout << "objname "<< objname << endl; |
|
|
TString objname = c; |
|
|
if(!objname.CompareTo("TrkLevel1"))return &trk1_obj; |
|
|
if(!objname.CompareTo("TrkLevel2"))return &trk2_obj; |
|
|
if(!objname.CompareTo("TrkHough"))return &trkh_obj; |
|
|
|
|
|
return NULL; |
|
|
}; |
|
| 1607 |
//-------------------------------------- |
//-------------------------------------- |
| 1608 |
// |
// |
| 1609 |
// |
// |
| 1614 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
| 1615 |
*/ |
*/ |
| 1616 |
TChain *PamLevel2::GetRunTree(TList *fl){ |
TChain *PamLevel2::GetRunTree(TList *fl){ |
| 1617 |
|
// |
| 1618 |
TChain *R = new TChain("Run"); |
// |
| 1619 |
|
// |
| 1620 |
|
if ( run_tree ){ |
| 1621 |
|
printf("WARNING: TChain *PamLevel2::GetRunTree(TList *fl) -- run_tree already exists!\n "); |
| 1622 |
|
return run_tree; |
| 1623 |
|
}; |
| 1624 |
|
// |
| 1625 |
|
TChain *R = new TChain("Run"); |
| 1626 |
|
|
| 1627 |
// loop over files and create chains |
// loop over files and create chains |
| 1628 |
TIter next(fl); |
TIter next(fl); |
| 1634 |
R->Add(name); |
R->Add(name); |
| 1635 |
}; |
}; |
| 1636 |
} |
} |
| 1637 |
|
|
| 1638 |
|
if(R->GetNtrees()){ |
| 1639 |
|
|
| 1640 |
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
| 1641 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
| 1642 |
|
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
| 1643 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
| 1644 |
|
}else{ |
| 1645 |
|
delete R; |
| 1646 |
|
R=0; |
| 1647 |
|
} |
| 1648 |
|
|
| 1649 |
|
run_tree = R; |
| 1650 |
|
|
| 1651 |
return R; |
return R; |
| 1652 |
|
|
| 1653 |
} |
} |
| 1661 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
| 1662 |
*/ |
*/ |
| 1663 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
TTree *PamLevel2::GetRunTree(TFile *f){ |
| 1664 |
|
if ( run_tree ){ |
| 1665 |
|
printf("WARNING: TTree *PamLevel2::GetRunTree(TFile *f) -- run_tree already exists!\n "); |
| 1666 |
|
return run_tree; |
| 1667 |
|
}; |
| 1668 |
|
|
| 1669 |
|
|
| 1670 |
|
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
| 1671 |
|
|
| 1672 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *T = (TTree*)f->Get("Run"); |
| 1673 |
|
|
| 1674 |
R->SetBranchAddress("RunInfo", GetPointerToRun()); |
if(T){ |
| 1675 |
cout << "Run : set branch address RunInfo"<<endl; |
T->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
| 1676 |
|
cout << "Run : set branch address RunInfo"<<endl; |
| 1677 |
return R; |
T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
| 1678 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
| 1679 |
|
} |
| 1680 |
|
|
| 1681 |
|
run_tree = (TChain*)T; |
| 1682 |
|
|
| 1683 |
|
return T; |
| 1684 |
|
|
| 1685 |
} |
} |
| 1686 |
|
/** |
| 1687 |
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
| 1688 |
|
* @param run Pointer to the chain/tree which contains run infos |
| 1689 |
|
* @return true if a new run has been read, false if it is still the same run |
| 1690 |
|
*/ |
| 1691 |
|
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev){ |
| 1692 |
|
// |
| 1693 |
|
// check if we have already called once GetEntry, if not call it |
| 1694 |
|
// |
| 1695 |
|
if(!run){ |
| 1696 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
| 1697 |
|
return(false); |
| 1698 |
|
} |
| 1699 |
|
if ( run->GetEntries() <= 0 ) return(false); |
| 1700 |
|
// |
| 1701 |
|
|
| 1702 |
|
// Int_t oldrun = irun; |
| 1703 |
|
Long64_t oldrun = irun; |
| 1704 |
|
|
| 1705 |
|
// -------------------------------------- |
| 1706 |
|
// if it is a full file (not preselected) |
| 1707 |
|
// -------------------------------------- |
| 1708 |
|
if(SELLI==0){ |
| 1709 |
|
|
| 1710 |
|
if( !GetOrbitalInfo() ){ |
| 1711 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
| 1712 |
|
return(false); |
| 1713 |
|
} |
| 1714 |
|
|
| 1715 |
|
if ( irun < 0LL ){ |
| 1716 |
|
irun = 0LL; |
| 1717 |
|
run->GetEntry(irun); |
| 1718 |
|
runfirstentry = 0LL; |
| 1719 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
| 1720 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
| 1721 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1722 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
| 1723 |
|
// return(true); |
| 1724 |
|
}; |
| 1725 |
|
// |
| 1726 |
|
if ( irun == run->GetEntries()-1LL && |
| 1727 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
| 1728 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
| 1729 |
|
){ |
| 1730 |
|
irun = -1LL; |
| 1731 |
|
runfirstentry = 0LL; |
| 1732 |
|
runlastentry = -1LL; |
| 1733 |
|
}; |
| 1734 |
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
| 1735 |
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
| 1736 |
|
// |
| 1737 |
|
bool fromfirst = true; |
| 1738 |
|
// |
| 1739 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
| 1740 |
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
| 1741 |
|
irun++; |
| 1742 |
|
run->GetEntry(irun); |
| 1743 |
|
runfirstentry = runlastentry; |
| 1744 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; |
| 1745 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
| 1746 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1747 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
| 1748 |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
| 1749 |
|
// printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); |
| 1750 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
| 1751 |
|
// |
| 1752 |
|
// prevshift = 0; |
| 1753 |
|
// |
| 1754 |
|
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ |
| 1755 |
|
printf(" resetting irun (it should NOT happen!!!)\n"); |
| 1756 |
|
fromfirst = false; |
| 1757 |
|
irun = 0; |
| 1758 |
|
run->GetEntry(irun); |
| 1759 |
|
runfirstentry = 0ULL; |
| 1760 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
| 1761 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
| 1762 |
|
}; |
| 1763 |
|
// |
| 1764 |
|
}; |
| 1765 |
|
// |
| 1766 |
|
if ( |
| 1767 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
| 1768 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
| 1769 |
|
) { |
| 1770 |
|
printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); |
| 1771 |
|
return false; |
| 1772 |
|
} |
| 1773 |
|
// |
| 1774 |
|
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
| 1775 |
|
// |
| 1776 |
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
| 1777 |
|
// |
| 1778 |
|
prevshift = 0; |
| 1779 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1780 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
| 1781 |
|
return(true); |
| 1782 |
|
}; |
| 1783 |
|
// ---------------------------------------------------- |
| 1784 |
|
// if it is a preselected file (there is SelectionList) |
| 1785 |
|
// NBNB - the event tree MUST be read first |
| 1786 |
|
// ---------------------------------------------------- |
| 1787 |
|
if(SELLI==1){ |
| 1788 |
|
sel_tree->GetEntry(iev); |
| 1789 |
|
// cout << irun << " "<< irunentry << endl; |
| 1790 |
|
if(irun != oldrun){ |
| 1791 |
|
run->GetEntry(irun); |
| 1792 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1793 |
|
prevshift = 0; |
| 1794 |
|
return true; |
| 1795 |
|
} |
| 1796 |
|
return false; |
| 1797 |
|
} |
| 1798 |
|
|
| 1799 |
|
return false; |
| 1800 |
|
// |
| 1801 |
|
}; |
| 1802 |
|
|
| 1803 |
|
// Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev){ |
| 1804 |
|
// // |
| 1805 |
|
// // check if we have already called once GetEntry, if not call it |
| 1806 |
|
// // |
| 1807 |
|
// if(!run_tree){ |
| 1808 |
|
// cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
| 1809 |
|
// return false; |
| 1810 |
|
// } |
| 1811 |
|
// if ( run_tree->GetEntries() <= 0 ) { |
| 1812 |
|
// cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
| 1813 |
|
// return(false); |
| 1814 |
|
// } |
| 1815 |
|
// // |
| 1816 |
|
|
| 1817 |
|
// Int_t oldrun = irun; |
| 1818 |
|
// // -------------------------------------- |
| 1819 |
|
// // if it is a full file (not preselected) |
| 1820 |
|
// // -------------------------------------- |
| 1821 |
|
// if(SELLI==0){ |
| 1822 |
|
|
| 1823 |
|
// if( !GetOrbitalInfo() ){ |
| 1824 |
|
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
| 1825 |
|
// return(false); |
| 1826 |
|
// } |
| 1827 |
|
|
| 1828 |
|
// if ( irun < 0 ){ |
| 1829 |
|
// irun = 0; |
| 1830 |
|
// run_tree->GetEntry(irun); |
| 1831 |
|
// runfirstentry = iev; |
| 1832 |
|
// if( iev != 0){ |
| 1833 |
|
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- WARNING -- "<<endl; |
| 1834 |
|
// } |
| 1835 |
|
// }; |
| 1836 |
|
|
| 1837 |
|
// bool fromfirst = true; |
| 1838 |
|
|
| 1839 |
|
// while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries() ){ |
| 1840 |
|
// irun++; |
| 1841 |
|
// if( irun == run->GetEntries() ){ |
| 1842 |
|
// if(!fromfirst){ |
| 1843 |
|
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
| 1844 |
|
// return false; |
| 1845 |
|
// } |
| 1846 |
|
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- reached end of run tree. searchin again from beginning (should not happen)" <<endl; |
| 1847 |
|
// fromfirst = false; |
| 1848 |
|
// irun =0; |
| 1849 |
|
// } |
| 1850 |
|
// run_tree->GetEntry(irun); |
| 1851 |
|
// runfirstentry = iev; |
| 1852 |
|
// }; |
| 1853 |
|
// // |
| 1854 |
|
// if ( irun == oldrun ) return(false); |
| 1855 |
|
// // |
| 1856 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1857 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
| 1858 |
|
// prevshift = 0; |
| 1859 |
|
// return(true); |
| 1860 |
|
// }; |
| 1861 |
|
// // ---------------------------------------------------- |
| 1862 |
|
// // if it is a preselected file (there is SelectionList) |
| 1863 |
|
// // NBNB - the event tree MUST be read first |
| 1864 |
|
// // ---------------------------------------------------- |
| 1865 |
|
// if(SELLI==1){ |
| 1866 |
|
// sel_tree->GetEntry(iev); |
| 1867 |
|
// if(irun != oldrun){ |
| 1868 |
|
// run->GetEntry(irun); |
| 1869 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1870 |
|
// prevshift = 0; |
| 1871 |
|
// return true; |
| 1872 |
|
// } |
| 1873 |
|
// return false; |
| 1874 |
|
// } |
| 1875 |
|
|
| 1876 |
|
// return false; |
| 1877 |
|
// // |
| 1878 |
|
// }; |
| 1879 |
|
/** |
| 1880 |
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
| 1881 |
|
* @param run Pointer to the chain/tree which contains run infos |
| 1882 |
|
* @return true if a new run has been read, false if it is still the same run |
| 1883 |
|
*/ |
| 1884 |
|
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev){ |
| 1885 |
|
return(UpdateRunInfo((TChain*)run,iev)); |
| 1886 |
|
}; |
| 1887 |
|
|
| 1888 |
//-------------------------------------- |
//-------------------------------------- |
| 1889 |
// |
// |
| 1890 |
// |
// |
| 1895 |
*/ |
*/ |
| 1896 |
void PamLevel2::SetWhichTrees(TString detlist){ |
void PamLevel2::SetWhichTrees(TString detlist){ |
| 1897 |
|
|
| 1898 |
if(detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
| 1899 |
|
CAL0 = false; |
| 1900 |
CAL1 = true; |
CAL1 = true; |
| 1901 |
CAL2 = true; |
CAL2 = true; |
| 1902 |
TRK2 = true; |
TRK2 = true; |
| 1903 |
TRK1 = false; |
TRK1 = false; |
| 1904 |
TRKh = false; |
TRKh = false; |
| 1905 |
|
TRK0 = false; |
| 1906 |
TRG = true; |
TRG = true; |
| 1907 |
TOF = true; |
TOF = true; |
| 1908 |
|
TOF0 = false; |
| 1909 |
S4 = true; |
S4 = true; |
| 1910 |
ND = true; |
ND = true; |
| 1911 |
AC = true; |
AC = true; |
| 1912 |
ORB = true; |
ORB = true; |
| 1913 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
| 1914 |
|
CAL0 = false; |
| 1915 |
CAL1 = false; |
CAL1 = false; |
| 1916 |
CAL2 = false; |
CAL2 = false; |
| 1917 |
TRK2 = false; |
TRK2 = false; |
| 1918 |
TRK1 = false; |
TRK1 = false; |
| 1919 |
TRKh = false; |
TRKh = false; |
| 1920 |
|
TRK0 = false; |
| 1921 |
TRG = false; |
TRG = false; |
| 1922 |
TOF = false; |
TOF = false; |
| 1923 |
|
TOF0 = false; |
| 1924 |
S4 = false; |
S4 = false; |
| 1925 |
ND = false; |
ND = false; |
| 1926 |
AC = false; |
AC = false; |
| 1932 |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
| 1933 |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
| 1934 |
}; |
}; |
| 1935 |
|
|
| 1936 |
|
if( detlist.Contains("CAL0", TString::kIgnoreCase) ){ |
| 1937 |
|
if ( detlist.Contains("-CAL0", TString::kIgnoreCase) )CAL0=false; |
| 1938 |
|
if ( detlist.Contains("+CAL0", TString::kIgnoreCase) )CAL0=true; |
| 1939 |
|
}; |
| 1940 |
|
|
| 1941 |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
| 1942 |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
| 1949 |
CAL1=false; |
CAL1=false; |
| 1950 |
} |
} |
| 1951 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
| 1952 |
|
if( detlist.Contains("TRK0", TString::kIgnoreCase) ){ |
| 1953 |
|
if ( detlist.Contains("-TRK0", TString::kIgnoreCase) )TRK0=false; |
| 1954 |
|
if ( detlist.Contains("+TRK0", TString::kIgnoreCase) )TRK0=true; |
| 1955 |
|
}; |
| 1956 |
|
|
| 1957 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
| 1958 |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
| 1959 |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
| 1976 |
TRKh=false; |
TRKh=false; |
| 1977 |
} |
} |
| 1978 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
// if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK2 = false; |
|
|
// else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK2 = true; |
|
|
|
|
|
// if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1 = false; |
|
|
// else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1 = true; |
|
|
|
|
|
// if( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh = false; |
|
|
// else if( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh = true; |
|
| 1979 |
|
|
| 1980 |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; |
| 1981 |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; |
| 1982 |
|
|
| 1983 |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
| 1984 |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
| 1985 |
|
|
| 1986 |
|
if( detlist.Contains("-TOF0", TString::kIgnoreCase) )TOF0 = false; |
| 1987 |
|
else if( detlist.Contains("+TOF0", TString::kIgnoreCase) )TOF0 = true; |
| 1988 |
|
|
| 1989 |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
| 1990 |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
| 1997 |
|
|
| 1998 |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; |
| 1999 |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; |
| 2000 |
|
|
| 2001 |
|
// cout<< "Set detector list --> "; |
| 2002 |
|
// if(TRK1)cout<<"TRK1 "; |
| 2003 |
|
// if(TRK2)cout<<"TRK2 "; |
| 2004 |
|
// if(TRKh)cout<<"TRKH "; |
| 2005 |
|
// if(CAL1)cout<<"CAL1 "; |
| 2006 |
|
// if(CAL2)cout<<"CAL2 "; |
| 2007 |
|
// if(TOF)cout<<"TOF "; |
| 2008 |
|
// if(TRG)cout<<"TRG "; |
| 2009 |
|
// if(AC)cout<<"AC "; |
| 2010 |
|
// if(ND)cout<<"ND "; |
| 2011 |
|
// if(S4)cout<<"S4 "; |
| 2012 |
|
// if(ORB)cout<<"ORB "; |
| 2013 |
|
// cout << endl; |
| 2014 |
|
|
| 2015 |
}; |
}; |
| 2016 |
|
|
| 2017 |
|
|
| 2018 |
|
/** |
| 2019 |
|
* Set tree/branch detector flags from the content of a tree |
| 2020 |
|
*/ |
| 2021 |
|
void PamLevel2::GetWhichTrees(TFile* f){ |
| 2022 |
|
|
| 2023 |
|
|
| 2024 |
|
|
| 2025 |
|
cout << "void PamLevel2::GetWhichTrees(TFile* f) --- WARNING!! --- ...potrebbe non funzionare "<<endl; |
| 2026 |
|
// ----------- |
| 2027 |
|
// reset flags |
| 2028 |
|
// ----------- |
| 2029 |
|
CAL1 = false; |
| 2030 |
|
CAL2 = false; |
| 2031 |
|
TRK2 = false; |
| 2032 |
|
TRK1 = false; |
| 2033 |
|
TRKh = false; |
| 2034 |
|
TRG = false; |
| 2035 |
|
TOF = false; |
| 2036 |
|
S4 = false; |
| 2037 |
|
ND = false; |
| 2038 |
|
AC = false; |
| 2039 |
|
ORB = false; |
| 2040 |
|
|
| 2041 |
|
RUN = false; |
| 2042 |
|
|
| 2043 |
|
cout << "Checking file: "<<f->GetName()<<endl; |
| 2044 |
|
if( !f || f->IsZombie() ){ |
| 2045 |
|
cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; |
| 2046 |
|
return; |
| 2047 |
|
} |
| 2048 |
|
|
| 2049 |
|
TList *lk = f->GetListOfKeys(); |
| 2050 |
|
TIter next(lk); |
| 2051 |
|
TKey *key =0; |
| 2052 |
|
|
| 2053 |
|
Int_t nev = 0; |
| 2054 |
|
|
| 2055 |
|
while( (key = (TKey*)next()) ){ |
| 2056 |
|
|
| 2057 |
|
if( !strcmp(key->GetName(),"Run" ) )RUN = true; |
| 2058 |
|
|
| 2059 |
|
//========================================================= |
| 2060 |
|
if( !strcmp(key->GetName(),"Trigger" ) ){ |
| 2061 |
|
TRG = true; |
| 2062 |
|
Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); |
| 2063 |
|
if( nev && nevt!=nev){ |
| 2064 |
|
cout << "File: "<< f->GetName() <<" Trigger tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2065 |
|
TRG = false; |
| 2066 |
|
}else nev=nevt; |
| 2067 |
|
} |
| 2068 |
|
//========================================================= |
| 2069 |
|
if( !strcmp(key->GetName(),"ToF" ) ){ |
| 2070 |
|
TOF = true; |
| 2071 |
|
Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); |
| 2072 |
|
if( nev && nevt!=nev){ |
| 2073 |
|
cout << "File: "<< f->GetName() <<" ToF tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2074 |
|
TOF = false; |
| 2075 |
|
}else nev=nevt; |
| 2076 |
|
} |
| 2077 |
|
//========================================================= |
| 2078 |
|
if( !strcmp(key->GetName(),"S4" ) ){ |
| 2079 |
|
S4 = true; |
| 2080 |
|
Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); |
| 2081 |
|
if( nev && nevt!=nev){ |
| 2082 |
|
cout << "File: "<< f->GetName() <<" S4 tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2083 |
|
S4 = false; |
| 2084 |
|
}else nev=nevt; |
| 2085 |
|
} |
| 2086 |
|
//========================================================= |
| 2087 |
|
|
| 2088 |
|
if( !strcmp(key->GetName(),"NeutronD" ) ){ |
| 2089 |
|
ND = true; |
| 2090 |
|
Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); |
| 2091 |
|
if( nev && nevt!=nev){ |
| 2092 |
|
cout << "File: "<< f->GetName() <<"NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2093 |
|
ND =false; |
| 2094 |
|
}else nev=nevt; |
| 2095 |
|
} |
| 2096 |
|
//========================================================= |
| 2097 |
|
if( !strcmp(key->GetName(),"Anticounter") ){ |
| 2098 |
|
AC = true; |
| 2099 |
|
Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); |
| 2100 |
|
if( nev && nevt!=nev){ |
| 2101 |
|
cout << "File: "<< f->GetName() <<" Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2102 |
|
AC =false; |
| 2103 |
|
}else nev=nevt; |
| 2104 |
|
} |
| 2105 |
|
//========================================================= |
| 2106 |
|
if( !strcmp(key->GetName(),"OrbitalInfo") ){ |
| 2107 |
|
ORB = true; |
| 2108 |
|
Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); |
| 2109 |
|
if( nev && nevt!=nev){ |
| 2110 |
|
cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2111 |
|
ORB = false; |
| 2112 |
|
}else nev=nevt; |
| 2113 |
|
} |
| 2114 |
|
//========================================================= |
| 2115 |
|
if( !strcmp(key->GetName(),"Tracker" ) ){ |
| 2116 |
|
TTree *T = (TTree*)f->Get("Tracker"); |
| 2117 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 2118 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 2119 |
|
if( !name.CompareTo("TrkLevel1") )TRK1=true; |
| 2120 |
|
if( !name.CompareTo("TrkLevel2") )TRK2=true; |
| 2121 |
|
if( !name.CompareTo("TrkHough") )TRKh=true; |
| 2122 |
|
}; |
| 2123 |
|
Int_t nevt = T->GetEntries(); |
| 2124 |
|
if( nev && nevt!=nev){ |
| 2125 |
|
cout << "File: "<< f->GetName() <<" Tracker tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2126 |
|
TRK1 = false; |
| 2127 |
|
TRK2 = false; |
| 2128 |
|
TRKh = false; |
| 2129 |
|
}else nev=nevt; |
| 2130 |
|
T->Delete(); |
| 2131 |
|
}; |
| 2132 |
|
//========================================================= |
| 2133 |
|
if( !strcmp(key->GetName(),"Calorimeter" ) ){ |
| 2134 |
|
TTree *T = (TTree*)f->Get("Calorimeter"); |
| 2135 |
|
for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){ |
| 2136 |
|
TString name = T->GetListOfBranches()->At(i)->GetName(); |
| 2137 |
|
if( !name.CompareTo("CaloLevel1") )CAL1=true; |
| 2138 |
|
if( !name.CompareTo("CaloLevel2") )CAL2=true; |
| 2139 |
|
}; |
| 2140 |
|
Int_t nevt = T->GetEntries(); |
| 2141 |
|
if( nev && nevt!=nev){ |
| 2142 |
|
cout << "File: "<< f->GetName() <<" Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2143 |
|
CAL1 = false; |
| 2144 |
|
CAL2 = false; |
| 2145 |
|
}else nev=nevt; |
| 2146 |
|
T->Delete(); |
| 2147 |
|
}; |
| 2148 |
|
|
| 2149 |
|
}; |
| 2150 |
|
|
| 2151 |
|
delete lk; |
| 2152 |
|
|
| 2153 |
|
// cout<< "Get detector list from input file --> "; |
| 2154 |
|
// if(TRK1)cout<<"TRK1 "; |
| 2155 |
|
// if(TRK2)cout<<"TRK2 "; |
| 2156 |
|
// if(TRKh)cout<<"TRKH "; |
| 2157 |
|
// if(CAL1)cout<<"CAL1 "; |
| 2158 |
|
// if(CAL2)cout<<"CAL2 "; |
| 2159 |
|
// if(TOF)cout<<"TOF "; |
| 2160 |
|
// if(TRG)cout<<"TRG "; |
| 2161 |
|
// if(AC)cout<<"AC "; |
| 2162 |
|
// if(ND)cout<<"ND "; |
| 2163 |
|
// if(S4)cout<<"S4 "; |
| 2164 |
|
// if(ORB)cout<<"ORB "; |
| 2165 |
|
// cout << endl; |
| 2166 |
|
|
| 2167 |
|
return ; |
| 2168 |
|
|
| 2169 |
|
}; |
| 2170 |
|
|
| 2171 |
|
|
| 2172 |
//-------------------------------------- |
//-------------------------------------- |
| 2173 |
// |
// |
| 2174 |
// |
// |
| 2194 |
|
|
| 2195 |
Bool_t RUN__ok = false; |
Bool_t RUN__ok = false; |
| 2196 |
|
|
| 2197 |
|
Bool_t SELLI__ok = false; |
| 2198 |
|
|
| 2199 |
cout << "Checking file: "<<name<<endl; |
cout << "Checking file: "<<name<<endl; |
| 2200 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
| 2212 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
| 2213 |
|
|
| 2214 |
// cout << key->GetName() << endl; |
// cout << key->GetName() << endl; |
| 2215 |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
| 2216 |
|
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
| 2217 |
// nev_previous = nev; |
// nev_previous = nev; |
| 2218 |
// cout << " n.entries "<< nev <<endl; |
// cout << " n.entries "<< nev <<endl; |
| 2219 |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
// if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ |
| 2222 |
// return false; |
// return false; |
| 2223 |
// }; |
// }; |
| 2224 |
|
|
| 2225 |
|
|
| 2226 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
| 2227 |
|
|
| 2228 |
//========================================================= |
//========================================================= |
| 2229 |
|
if( !strcmp(key->GetName(),"SelectionList" ) ){ |
| 2230 |
|
SELLI__ok = true; |
| 2231 |
|
if(SELLI==1){ |
| 2232 |
|
Int_t nevt = ((TTree*)f->Get("SelectionList"))->GetEntries(); |
| 2233 |
|
if( nev && nevt!=nev){ |
| 2234 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList tree has "<<nevt<<" events instead of "<<nev<< endl; |
| 2235 |
|
return false; |
| 2236 |
|
} |
| 2237 |
|
nev=nevt; |
| 2238 |
|
} |
| 2239 |
|
} |
| 2240 |
|
|
| 2241 |
|
//========================================================= |
| 2242 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
| 2243 |
TRG__ok = true; |
TRG__ok = true; |
| 2244 |
if(TRG){ |
if(TRG){ |
| 2350 |
}; |
}; |
| 2351 |
|
|
| 2352 |
}; |
}; |
| 2353 |
|
|
| 2354 |
|
if( SELLI==-1 )SELLI = (Int_t)SELLI__ok; |
| 2355 |
|
if( SELLI==0 && SELLI__ok ){ |
| 2356 |
|
cout << "File: "<< f->GetName() <<" discarded ---- found SelectionList (it is not a full-event file)" << endl; |
| 2357 |
|
return false; |
| 2358 |
|
} |
| 2359 |
|
if( SELLI==1 && !SELLI__ok ){ |
| 2360 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList missing" << endl; |
| 2361 |
|
return false; |
| 2362 |
|
} |
| 2363 |
|
|
| 2364 |
|
// cout << "SELLI "<<SELLI<<endl; |
| 2365 |
|
|
| 2366 |
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
| 2367 |
|
// if(TRK1__ok)cout<<"TRK1 "; |
| 2368 |
|
// if(TRK2__ok)cout<<"TRK2 "; |
| 2369 |
|
// if(TRKh__ok)cout<<"TRKH "; |
| 2370 |
|
// if(CAL1__ok)cout<<"CAL1 "; |
| 2371 |
|
// if(CAL2__ok)cout<<"CAL2 "; |
| 2372 |
|
// if(TOF__ok)cout<<"TOF "; |
| 2373 |
|
// if(TRG__ok)cout<<"TRG "; |
| 2374 |
|
// if(AC__ok)cout<<"AC "; |
| 2375 |
|
// if(ND__ok)cout<<"ND "; |
| 2376 |
|
// if(S4__ok)cout<<"S4 "; |
| 2377 |
|
// if(ORB__ok)cout<<"ORB "; |
| 2378 |
|
// cout << endl; |
| 2379 |
|
|
| 2380 |
|
|
| 2381 |
|
if(TRK2 && TRK1__ok)TRK1=1; |
| 2382 |
|
// ---------------------------------------------------------------------------- |
| 2383 |
|
// NOTA |
| 2384 |
|
// se c'e` il level1, lo devo necessarimente leggere. |
| 2385 |
|
// infatti (non ho capito perche`) i cluster vengono letti e allocati in memoria |
| 2386 |
|
// comunque, ma non vengono disallocati da PamLevel2::Clear() |
| 2387 |
|
// ---------------------------------------------------------------------------- |
| 2388 |
|
|
| 2389 |
|
|
| 2390 |
if(!RUN__ok) { |
if(!RUN__ok) { |
| 2391 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing RunInfo tree"<< endl; |
cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl; |
| 2392 |
return false; |
// return false; |
| 2393 |
}; |
}; |
| 2394 |
|
|
| 2395 |
if(CAL1 && !CAL1__ok){ |
if(CAL1 && !CAL1__ok){ |
| 2429 |
return false; |
return false; |
| 2430 |
}; |
}; |
| 2431 |
|
|
| 2432 |
if(ND && !ND__ok){ |
if(ND && !ND__ok){ |
| 2433 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; |
| 2434 |
return false; |
return false; |
| 2435 |
|
}; |
| 2436 |
|
if(TRG && !TRG__ok){ |
| 2437 |
|
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
| 2438 |
|
return false; |
| 2439 |
|
}; |
| 2440 |
|
|
| 2441 |
|
|
| 2442 |
|
// lk->Delete(); |
| 2443 |
|
// delete lk; |
| 2444 |
|
f->Close(); |
| 2445 |
|
|
| 2446 |
|
// cout<< "CheckLevel2File(TString): detector list --> "; |
| 2447 |
|
// if(TRK1)cout<<"TRK1 "; |
| 2448 |
|
// if(TRK2)cout<<"TRK2 "; |
| 2449 |
|
// if(TRKh)cout<<"TRKH "; |
| 2450 |
|
// if(CAL1)cout<<"CAL1 "; |
| 2451 |
|
// if(CAL2)cout<<"CAL2 "; |
| 2452 |
|
// if(TOF)cout<<"TOF "; |
| 2453 |
|
// if(TRG)cout<<"TRG "; |
| 2454 |
|
// if(AC)cout<<"AC "; |
| 2455 |
|
// if(ND)cout<<"ND "; |
| 2456 |
|
// if(S4)cout<<"S4 "; |
| 2457 |
|
// if(ORB)cout<<"ORB "; |
| 2458 |
|
// cout << endl; |
| 2459 |
|
|
| 2460 |
|
return true; |
| 2461 |
|
|
| 2462 |
|
}; |
| 2463 |
|
|
| 2464 |
|
|
| 2465 |
|
/** |
| 2466 |
|
* Create clone-trees |
| 2467 |
|
*/ |
| 2468 |
|
void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ |
| 2469 |
|
|
| 2470 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2471 |
|
cout << "Create clones of PAMELA trees "<<endl; |
| 2472 |
|
|
| 2473 |
|
Int_t i=0; |
| 2474 |
|
pam_tree_clone[i] = fChain->GetTree()->CloneTree(0); |
| 2475 |
|
TString name = pam_tree_clone[i]->GetName(); |
| 2476 |
|
name.Append("_clone"); |
| 2477 |
|
// pam_tree_clone[i]->SetName(name.Data()); |
| 2478 |
|
cout << pam_tree_clone[i]->GetName() <<endl; |
| 2479 |
|
i++; |
| 2480 |
|
|
| 2481 |
|
TList *li = fChain->GetListOfFriends(); |
| 2482 |
|
TIter next(li); |
| 2483 |
|
TFriendElement* T_friend=0; |
| 2484 |
|
ofile->cd(); |
| 2485 |
|
while( (T_friend = (TFriendElement*)next()) ){ |
| 2486 |
|
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
| 2487 |
|
// cout<<T_friend->GetTree()->GetName()<< endl; |
| 2488 |
|
pam_tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
| 2489 |
|
pam_tree_clone[i]->SetAutoSave(1000000); |
| 2490 |
|
name = pam_tree_clone[i]->GetName(); |
| 2491 |
|
name.Append("_clone"); |
| 2492 |
|
// pam_tree_clone[i]->SetName(name.Data()); |
| 2493 |
|
cout << pam_tree_clone[i]->GetName() << endl; |
| 2494 |
|
i++; |
| 2495 |
|
} |
| 2496 |
|
|
| 2497 |
|
delete li; |
| 2498 |
|
|
| 2499 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2500 |
|
|
| 2501 |
|
} |
| 2502 |
|
|
| 2503 |
|
/** |
| 2504 |
|
* Create clone-trees |
| 2505 |
|
*/ |
| 2506 |
|
void PamLevel2::CreateCloneTrees(TFile *ofile){ |
| 2507 |
|
|
| 2508 |
|
ofile->cd(); |
| 2509 |
|
|
| 2510 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2511 |
|
cout << "Create new PAMELA trees "<<endl; |
| 2512 |
|
|
| 2513 |
|
|
| 2514 |
|
run_tree_clone = new TTree("Run","PAMELA Level2 data from the GL_RUN table "); |
| 2515 |
|
run_tree_clone->Branch("RunInfo","GL_RUN",GetPointerTo("RunInfo")); |
| 2516 |
|
cout << "Run : branch RunInfo"<<endl; |
| 2517 |
|
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
| 2518 |
|
cout << "Run : branch SoftInfo"<<endl; |
| 2519 |
|
|
| 2520 |
|
|
| 2521 |
|
|
| 2522 |
|
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
| 2523 |
|
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
| 2524 |
|
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); |
| 2525 |
|
|
| 2526 |
|
|
| 2527 |
|
Int_t i=0; |
| 2528 |
|
if(TRK1||TRK2||TRKh){ |
| 2529 |
|
pam_tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
| 2530 |
|
if(TRK1) { |
| 2531 |
|
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
| 2532 |
|
pam_tree_clone[i]->BranchRef(); |
| 2533 |
|
cout << "Tracker : branch TrkLevel1"<<endl; |
| 2534 |
|
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
| 2535 |
|
}; |
| 2536 |
|
if(TRK2) { |
| 2537 |
|
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
| 2538 |
|
cout << "Tracker : branch TrkLevel2"<<endl; |
| 2539 |
|
}; |
| 2540 |
|
if(TRKh) { |
| 2541 |
|
pam_tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
| 2542 |
|
cout << "Tracker : branch TrkHough"<<endl; |
| 2543 |
|
}; |
| 2544 |
|
i++; |
| 2545 |
|
} |
| 2546 |
|
|
| 2547 |
|
// Calorimeter |
| 2548 |
|
if(CAL1||CAL2){ |
| 2549 |
|
pam_tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
| 2550 |
|
if(CAL1) { |
| 2551 |
|
pam_tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
| 2552 |
|
cout << "Calorimeter : branch CaloLevel1"<<endl; |
| 2553 |
|
}; |
| 2554 |
|
if(CAL2) { |
| 2555 |
|
pam_tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
| 2556 |
|
cout << "Calorimeter : branch CaloLevel2"<<endl; |
| 2557 |
|
}; |
| 2558 |
|
i++; |
| 2559 |
|
} |
| 2560 |
|
|
| 2561 |
|
// ToF |
| 2562 |
|
if(TOF) { |
| 2563 |
|
pam_tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
| 2564 |
|
pam_tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
| 2565 |
|
cout << "ToF : branch ToFLevel2"<<endl; |
| 2566 |
|
i++; |
| 2567 |
|
}; |
| 2568 |
|
// Trigger |
| 2569 |
|
if(TRG) { |
| 2570 |
|
pam_tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
| 2571 |
|
pam_tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
| 2572 |
|
cout << "Trigger : branch TrigLevel2"<<endl; |
| 2573 |
|
i++; |
| 2574 |
|
}; |
| 2575 |
|
// S4 |
| 2576 |
|
if(S4) { |
| 2577 |
|
pam_tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
| 2578 |
|
pam_tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
| 2579 |
|
cout << "S4 : branch S4Level2"<<endl; |
| 2580 |
|
i++; |
| 2581 |
|
}; |
| 2582 |
|
// Neutron Detector |
| 2583 |
|
if(ND) { |
| 2584 |
|
pam_tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
| 2585 |
|
pam_tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
| 2586 |
|
cout << "NeutronD : branch NDLevel2"<<endl; |
| 2587 |
|
i++; |
| 2588 |
|
}; |
| 2589 |
|
// Anticounters |
| 2590 |
|
if(AC) { |
| 2591 |
|
pam_tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
| 2592 |
|
pam_tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
| 2593 |
|
cout << "Anticounter : branch AcLevel2"<<endl; |
| 2594 |
|
i++; |
| 2595 |
|
}; |
| 2596 |
|
// OrbitalInfo |
| 2597 |
|
if(ORB) { |
| 2598 |
|
pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
| 2599 |
|
pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
| 2600 |
|
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
| 2601 |
|
i++; |
| 2602 |
|
}; |
| 2603 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2604 |
|
|
| 2605 |
|
} |
| 2606 |
|
|
| 2607 |
|
|
| 2608 |
|
/** |
| 2609 |
|
* Fill tree (created with CreateCloneTrees) |
| 2610 |
|
* |
| 2611 |
|
*/ |
| 2612 |
|
//void PamLevel2::FillNewPamTree(TTree *T){ |
| 2613 |
|
void PamLevel2::FillCloneTrees(){ |
| 2614 |
|
|
| 2615 |
|
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
| 2616 |
|
|
| 2617 |
|
for(Int_t i=0; i<NCLONES; i++){ |
| 2618 |
|
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
| 2619 |
|
} |
| 2620 |
|
if(sel_tree_clone)sel_tree_clone->Fill(); |
| 2621 |
|
|
| 2622 |
|
} |
| 2623 |
|
|
| 2624 |
|
|
| 2625 |
|
TTree* PamLevel2::GetCloneTree(TString name){ |
| 2626 |
|
|
| 2627 |
|
for(Int_t i=0; i<NCLONES; i++){ |
| 2628 |
|
if(pam_tree_clone[i]){ |
| 2629 |
|
TString na = pam_tree_clone[i]->GetName(); |
| 2630 |
|
if(!name.CompareTo(na))return pam_tree_clone[i]; |
| 2631 |
}; |
}; |
| 2632 |
if(TRG && !TRG__ok){ |
} |
| 2633 |
cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; |
if(run_tree_clone){ |
| 2634 |
return false; |
TString na = run_tree_clone->GetName(); |
| 2635 |
|
if(!name.CompareTo(na))return run_tree_clone; |
| 2636 |
|
} |
| 2637 |
|
if(sel_tree_clone){ |
| 2638 |
|
TString na = sel_tree_clone->GetName(); |
| 2639 |
|
if(!name.CompareTo(na))return sel_tree_clone; |
| 2640 |
|
} |
| 2641 |
|
return NULL; |
| 2642 |
|
|
| 2643 |
|
} |
| 2644 |
|
void PamLevel2::WriteCloneTrees(){ |
| 2645 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2646 |
|
cout << "Write clones of PAMELA trees "<<endl; |
| 2647 |
|
cout << run_tree_clone->GetName()<<endl; |
| 2648 |
|
run_tree_clone->Write(); |
| 2649 |
|
cout << sel_tree_clone->GetName()<<endl; |
| 2650 |
|
sel_tree_clone->Write(); |
| 2651 |
|
for(Int_t i=0; i<NCLONES; i++){ |
| 2652 |
|
if(pam_tree_clone[i]){ |
| 2653 |
|
cout << pam_tree_clone[i]->GetName()<<endl; |
| 2654 |
|
pam_tree_clone[i]->Write(); |
| 2655 |
}; |
}; |
| 2656 |
|
} |
| 2657 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 2658 |
|
|
| 2659 |
|
} |
| 2660 |
|
|
| 2661 |
|
/** |
| 2662 |
|
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
| 2663 |
|
*/ |
| 2664 |
|
//Int_t PamLevel2::GetEntry(Int_t iee){ |
| 2665 |
|
Int_t PamLevel2::GetEntry(Long64_t iee){ |
| 2666 |
|
|
| 2667 |
|
if(!pam_tree){ |
| 2668 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
| 2669 |
|
return 0; |
| 2670 |
|
} |
| 2671 |
|
|
| 2672 |
|
|
| 2673 |
|
// |
| 2674 |
|
// This is a sort of bug: if you don't have the run tree you don't want to exit here you want to have loaded the event anyway... |
| 2675 |
|
// |
| 2676 |
|
// if(!run_tree ){ |
| 2677 |
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; |
| 2678 |
|
// return 0; |
| 2679 |
|
// } |
| 2680 |
|
|
| 2681 |
|
Long64_t ii=0; |
| 2682 |
|
//------------------------------- |
| 2683 |
|
ii = iee; |
| 2684 |
|
if( !pam_tree->GetEntry(ii) ){ |
| 2685 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl; |
| 2686 |
|
return 0; |
| 2687 |
|
} |
| 2688 |
|
// |
| 2689 |
|
// ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0. |
| 2690 |
|
// in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not |
| 2691 |
|
// a problem if you don't check the return code of getentry. |
| 2692 |
|
// |
| 2693 |
|
if(!run_tree ){ |
| 2694 |
|
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
| 2695 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
| 2696 |
|
return 0; |
| 2697 |
|
} else { |
| 2698 |
|
return 1; //cosi` se non c'e` run esce qua... |
| 2699 |
|
} |
| 2700 |
|
} |
| 2701 |
|
|
| 2702 |
lk->Delete(); |
//------------------------------- |
| 2703 |
f->Close(); |
ii = iee; |
| 2704 |
|
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
| 2705 |
return true; |
Bool_t UPDATED = UpdateRunInfo(ii); |
| 2706 |
|
if(SELLI==0)irunentry = iee-runfirstentry; |
| 2707 |
}; |
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
| 2708 |
|
|
| 2709 |
|
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
| 2710 |
|
|
| 2711 |
|
if( TRK0 || CAL0 || TOF0 )GetYodaEntry( ); |
| 2712 |
|
|
| 2713 |
|
return 1; |
| 2714 |
|
|
| 2715 |
|
} |
| 2716 |
|
|
| 2717 |
|
/** |
| 2718 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
| 2719 |
|
* Given the run ID (...), if needed it query the DB and load the proper file. |
| 2720 |
|
* @return Pointer to the tree |
| 2721 |
|
*/ |
| 2722 |
|
|
| 2723 |
|
|
| 2724 |
|
TTree* PamLevel2::GetYodaTree( ){ |
| 2725 |
|
|
| 2726 |
|
// cout << "TTree* PamLevel2::GetYodaTree( )"<<endl; |
| 2727 |
|
//=================================== |
| 2728 |
|
// check if iroot has changed |
| 2729 |
|
//=================================== |
| 2730 |
|
if( irun<0 ){ |
| 2731 |
|
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = "<<irun<<endl; |
| 2732 |
|
// cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
| 2733 |
|
return NULL; |
| 2734 |
|
} |
| 2735 |
|
Int_t irootnew = run_obj->ID_ROOT_L0; |
| 2736 |
|
// cout << "iroot "<<iroot<<endl; |
| 2737 |
|
// cout << "irootnew "<<irootnew<<endl; |
| 2738 |
|
|
| 2739 |
|
//=================================== |
| 2740 |
|
// load the level0 file |
| 2741 |
|
// (if not already loaded) |
| 2742 |
|
//=================================== |
| 2743 |
|
if( iroot != irootnew || !l0_tree){ |
| 2744 |
|
iroot = irootnew; |
| 2745 |
|
//=================================== |
| 2746 |
|
// open the DB connection |
| 2747 |
|
// (if not already opened) |
| 2748 |
|
//=================================== |
| 2749 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
| 2750 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 2751 |
|
cout<<"Connecting to DB"<<endl; |
| 2752 |
|
cout<<"HOST "<<host<<endl; |
| 2753 |
|
cout<<"USER "<<user<<endl; |
| 2754 |
|
cout<<"PSW "<<psw<<endl; |
| 2755 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 2756 |
|
if( !dbc )return NULL; |
| 2757 |
|
if( !dbc->IsConnected() )return NULL; |
| 2758 |
|
// cout<<"...done"<<endl; |
| 2759 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 2760 |
|
}else{ |
| 2761 |
|
// cout<<"DB already connected"<<endl; |
| 2762 |
|
} |
| 2763 |
|
GL_ROOT glroot = GL_ROOT(); |
| 2764 |
|
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
| 2765 |
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
| 2766 |
|
return NULL; |
| 2767 |
|
}; |
| 2768 |
|
TString filename = glroot.PATH + glroot.NAME; |
| 2769 |
|
if(l0_file){ |
| 2770 |
|
l0_file->Close(); |
| 2771 |
|
l0_file->Delete(); |
| 2772 |
|
} |
| 2773 |
|
cout << "Opening LEVEL0 file: "<< filename << endl; |
| 2774 |
|
FileStat_t t; |
| 2775 |
|
if( gSystem->GetPathInfo(filename.Data(),t) ){ |
| 2776 |
|
cout << " PamLevel2::GetYodaTree() -- ERROR opening file "<<endl; |
| 2777 |
|
return NULL; |
| 2778 |
|
} |
| 2779 |
|
l0_file = new TFile(filename); |
| 2780 |
|
if( !l0_file )return NULL; |
| 2781 |
|
l0_tree = (TTree*)l0_file->Get("Physics"); |
| 2782 |
|
if(!h0_obj)h0_obj = new EventHeader(); |
| 2783 |
|
l0_tree->SetBranchAddress("Header" ,&h0_obj); |
| 2784 |
|
prevshift = 0; |
| 2785 |
|
//--------------------------------------------------- |
| 2786 |
|
// TRACKER: |
| 2787 |
|
if(TRK0){ |
| 2788 |
|
if(!trk0_obj){ |
| 2789 |
|
trk0_obj = new TrkLevel0(); |
| 2790 |
|
trk0_obj->Set(); |
| 2791 |
|
}; |
| 2792 |
|
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
| 2793 |
|
} |
| 2794 |
|
//--------------------------------------------------- |
| 2795 |
|
// CALORIMETER: |
| 2796 |
|
if(CAL0){ |
| 2797 |
|
if(!calo0_obj){ |
| 2798 |
|
calo0_obj = new CaloLevel0(); |
| 2799 |
|
calo0_obj->Set(); |
| 2800 |
|
}; |
| 2801 |
|
l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); |
| 2802 |
|
// cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
| 2803 |
|
} |
| 2804 |
|
//--------------------------------------------------- |
| 2805 |
|
// TOF: |
| 2806 |
|
if(TOF0){ |
| 2807 |
|
cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl; |
| 2808 |
|
} |
| 2809 |
|
|
| 2810 |
|
}; |
| 2811 |
|
|
| 2812 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
| 2813 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
| 2814 |
|
} |
| 2815 |
|
|
| 2816 |
|
if ( TRK0 ){ |
| 2817 |
|
TrkParams::Load(6); |
| 2818 |
|
if( !TrkParams::IsLoaded(6) ){ |
| 2819 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
| 2820 |
|
}; |
| 2821 |
|
TrkParams::SetCalib(run_obj,dbc); |
| 2822 |
|
TrkParams::LoadCalib( ); |
| 2823 |
|
if( !TrkParams::CalibIsLoaded() ){ |
| 2824 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl; |
| 2825 |
|
}; |
| 2826 |
|
} |
| 2827 |
|
|
| 2828 |
|
// cout << l0_tree << endl; |
| 2829 |
|
|
| 2830 |
|
return l0_tree; |
| 2831 |
|
|
| 2832 |
|
} |
| 2833 |
|
|
| 2834 |
|
/** |
| 2835 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
| 2836 |
|
*/ |
| 2837 |
|
Int_t PamLevel2::GetYodaEntry(){ |
| 2838 |
|
|
| 2839 |
|
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
| 2840 |
|
if(!GetYodaTree())return 0; |
| 2841 |
|
|
| 2842 |
|
// patch |
| 2843 |
|
if( irunentry < 0){ |
| 2844 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
| 2845 |
|
irunentry=0LL; |
| 2846 |
|
} |
| 2847 |
|
// --------------------------------- |
| 2848 |
|
// if file is NOT a preselected file |
| 2849 |
|
// --------------------------------- |
| 2850 |
|
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
| 2851 |
|
|
| 2852 |
|
|
| 2853 |
|
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
| 2854 |
|
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
| 2855 |
|
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
| 2856 |
|
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
| 2857 |
|
|
| 2858 |
|
if( !GetOrbitalInfo() ){ |
| 2859 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
| 2860 |
|
return 0; |
| 2861 |
|
} |
| 2862 |
|
if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ |
| 2863 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
| 2864 |
|
return 0; |
| 2865 |
|
} |
| 2866 |
|
|
| 2867 |
|
// --------------------------------------------------------------------- |
| 2868 |
|
// ATTENTION!!! |
| 2869 |
|
// If data are not pre-processed with cleaner, the level0 tree may contain |
| 2870 |
|
// spurious nested physics packets. |
| 2871 |
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
| 2872 |
|
// while level2 tree DOES NOT!! |
| 2873 |
|
// This means that "quellagiusta" in these cases is not correct. |
| 2874 |
|
// In order to retrieve the correct level0 event, I implemented a check |
| 2875 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
| 2876 |
|
// is shift forward until when the packets match. |
| 2877 |
|
// --------------------------------------------------------------------- |
| 2878 |
|
Int_t answer = 0; |
| 2879 |
|
Int_t shift =0; |
| 2880 |
|
// printf(" siamo qui %i %i \n",shift,prevshift); |
| 2881 |
|
do{ |
| 2882 |
|
if(shift>0){ |
| 2883 |
|
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
| 2884 |
|
} |
| 2885 |
|
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
| 2886 |
|
shift++; |
| 2887 |
|
if( !GetEventHeader() ){ |
| 2888 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
| 2889 |
|
return 0; |
| 2890 |
|
} |
| 2891 |
|
// cout << "PKTNUM "<<shift<<" == L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
| 2892 |
|
// cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
| 2893 |
|
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
| 2894 |
|
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
| 2895 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
| 2896 |
|
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
| 2897 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
| 2898 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
| 2899 |
|
// |
| 2900 |
|
if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ |
| 2901 |
|
prevshift = 0; |
| 2902 |
|
shift = -1; |
| 2903 |
|
}; |
| 2904 |
|
|
| 2905 |
|
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() ); |
| 2906 |
|
|
| 2907 |
|
if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <<endl; |
| 2908 |
|
|
| 2909 |
|
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
| 2910 |
|
// return GetYodaTree()->GetEntry(quellagiusta); |
| 2911 |
|
if ( shift > 1 ) prevshift += (shift-1); |
| 2912 |
|
|
| 2913 |
|
return answer; |
| 2914 |
|
|
| 2915 |
|
} |
| 2916 |
|
|
| 2917 |
|
|