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 |
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
116 |
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
142 |
|
|
143 |
run_obj = 0;//new GL_RUN(); |
run_obj = 0;//new GL_RUN(); |
144 |
soft_obj = 0;// Emiliano |
soft_obj = 0;// Emiliano |
145 |
irun = -1; |
irun = -1LL; |
146 |
runfirstentry = 0ULL; |
runfirstentry = 0LL; |
147 |
runlastentry = 0ULL; |
runlastentry = 0LL; |
148 |
|
|
149 |
l0_file = NULL; |
l0_file = NULL; |
150 |
l0_tree = NULL; |
l0_tree = NULL; |
153 |
|
|
154 |
prevshift = 0; |
prevshift = 0; |
155 |
|
|
|
irun = -1; |
|
156 |
run_tree = NULL; |
run_tree = NULL; |
157 |
run_tree_clone = NULL; |
run_tree_clone = NULL; |
158 |
sel_tree = NULL; |
sel_tree = NULL; |
159 |
sel_tree_clone = NULL; |
sel_tree_clone = NULL; |
160 |
|
|
161 |
irunentry = -1; |
irunentry = -1LL; |
162 |
pam_tree = NULL; |
pam_tree = NULL; |
163 |
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
164 |
|
|
241 |
} |
} |
242 |
|
|
243 |
if(l0_file)l0_file->Close(); |
if(l0_file)l0_file->Close(); |
244 |
if(pam_tree)pam_tree->Delete();; |
// 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();; |
if(run_tree)run_tree->Delete();; |
278 |
if(sel_tree)sel_tree->Delete();; |
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();; |
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
299 |
// if(soft_obj) soft_obj->Clear(); |
// if(soft_obj) soft_obj->Clear(); |
300 |
|
|
301 |
if(h0_obj) h0_obj->Clear(); |
if(h0_obj) h0_obj->Clear(); |
302 |
if(trk0_obj) trk0_obj->Clear(); |
// if(trk0_obj) trk0_obj->Clear(); |
303 |
if(calo0_obj) calo0_obj->Clear(); |
if(calo0_obj) calo0_obj->Clear(); |
304 |
if(trk1_obj) trk1_obj->Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
305 |
if(trk2_obj) trk2_obj->Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
306 |
if(trkh_obj) trkh_obj->Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
307 |
if(calo1_obj)calo1_obj->Clear(); |
if(calo1_obj)calo1_obj->Clear(); |
308 |
if(calo2_obj)calo2_obj->Clear(); |
if(calo2_obj)calo2_obj->Clear(); |
322 |
if(timage){ |
if(timage){ |
323 |
timage->Delete(); |
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 |
|
|
965 |
|
|
966 |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
967 |
// else GetWhichTrees(f); |
// 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; |
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
975 |
|
|
976 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
1046 |
if(R && TRG) { |
if(R && TRG) { |
1047 |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
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; |
1056 |
if(S && S4) { |
if(S && S4) { |
1057 |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
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; |
1066 |
if(N && ND) { |
if(N && ND) { |
1067 |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
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; |
1076 |
if(A && AC) { |
if(A && AC) { |
1077 |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
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; |
1086 |
if(B && ORB) { |
if(B && ORB) { |
1087 |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
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; |
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 |
|
|
1183 |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
1184 |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
1185 |
if( file.EndsWith(".root") ){ |
if( file.EndsWith(".root") ){ |
1186 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); |
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; |
delete fullpath; |
1196 |
} |
} |
1200 |
}; |
}; |
1201 |
in.close(); |
in.close(); |
1202 |
} else { |
} else { |
1203 |
|
if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); |
1204 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1205 |
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 |
1206 |
delete fullpath; |
delete fullpath; |
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(); |
1258 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
1259 |
*/ |
*/ |
1260 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
1261 |
|
// |
1262 |
|
// |
1263 |
|
// |
1264 |
|
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 *Trout =0; |
TChain *Trout =0; |
1271 |
|
|
1286 |
if(ORB)cout<<"ORB "; |
if(ORB)cout<<"ORB "; |
1287 |
cout << endl; |
cout << endl; |
1288 |
|
|
1289 |
TChain *T = 0; |
TChain *T = 0; |
1290 |
TChain *C = 0; |
TChain *C = 0; |
1291 |
TChain *O = 0; |
TChain *O = 0; |
1292 |
TChain *R = 0; |
TChain *R = 0; |
1293 |
TChain *S = 0; |
TChain *S = 0; |
1294 |
TChain *N = 0; |
TChain *N = 0; |
1295 |
TChain *A = 0; |
TChain *A = 0; |
1296 |
TChain *B = 0; |
TChain *B = 0; |
1297 |
|
|
1298 |
TChain *L = 0; |
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"); |
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"); |
L = new TChain("SelectionList"); |
1309 |
|
|
1310 |
// loop over files and create chains |
// loop over files and create chains |
1324 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
1325 |
if(SELLI==1) L->Add(name); |
if(SELLI==1) L->Add(name); |
1326 |
}; |
}; |
1327 |
} |
}; |
1328 |
|
|
1329 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1330 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1331 |
|
|
1332 |
// UInt_t *found=0; |
// UInt_t *found=0; |
1333 |
// Tracker |
// Tracker |
1342 |
// else T->SetBranchStatus("TrkHough",0,found); |
// else T->SetBranchStatus("TrkHough",0,found); |
1343 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1344 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
1345 |
else Trout->AddFriend("Tracker"); |
else Trout->AddFriend("Tracker"); |
1346 |
}else{ |
}else{ |
1347 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
1348 |
}; |
}; |
1413 |
}else{ |
}else{ |
1414 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
1415 |
}; |
}; |
1416 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1417 |
|
|
1418 |
// Selection List |
// Selection List |
1419 |
if(L && SELLI==1) { |
if(L && SELLI==1) { |
1425 |
sel_tree = L; |
sel_tree = L; |
1426 |
// if(!Trout)Trout=O; |
// if(!Trout)Trout=O; |
1427 |
// else Trout->AddFriend("SelectionList"); |
// else Trout->AddFriend("SelectionList"); |
1428 |
|
cout << "----------------------------------------------------" <<endl; |
1429 |
}else{ |
}else{ |
1430 |
// cout << "SelectionList : missing tree"<<endl; |
// cout << "SelectionList : missing tree"<<endl; |
1431 |
if(L)L->Delete(); |
if(L)L->Delete(); |
1617 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
1618 |
*/ |
*/ |
1619 |
TChain *PamLevel2::GetRunTree(TList *fl){ |
TChain *PamLevel2::GetRunTree(TList *fl){ |
1620 |
|
// |
1621 |
TChain *R = new TChain("Run"); |
// |
1622 |
|
// |
1623 |
|
if ( run_tree ){ |
1624 |
|
printf("WARNING: TChain *PamLevel2::GetRunTree(TList *fl) -- run_tree already exists!\n "); |
1625 |
|
return run_tree; |
1626 |
|
}; |
1627 |
|
// |
1628 |
|
TChain *R = new TChain("Run"); |
1629 |
|
|
1630 |
// loop over files and create chains |
// loop over files and create chains |
1631 |
TIter next(fl); |
TIter next(fl); |
1664 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
1665 |
*/ |
*/ |
1666 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
TTree *PamLevel2::GetRunTree(TFile *f){ |
1667 |
|
if ( run_tree ){ |
1668 |
|
printf("WARNING: TTree *PamLevel2::GetRunTree(TFile *f) -- run_tree already exists!\n "); |
1669 |
|
return run_tree; |
1670 |
|
}; |
1671 |
|
|
1672 |
|
|
1673 |
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
1674 |
|
|
1675 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *T = (TTree*)f->Get("Run"); |
1676 |
|
|
1677 |
if(R){ |
if(T){ |
1678 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
T->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1679 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1680 |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1681 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1682 |
} |
} |
1683 |
|
|
1684 |
run_tree = (TChain*)R; |
run_tree = (TChain*)T; |
1685 |
|
|
1686 |
return R; |
return T; |
1687 |
|
|
1688 |
} |
} |
1689 |
/** |
/** |
1691 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
1692 |
* @return true if a new run has been read, false if it is still the same run |
* @return true if a new run has been read, false if it is still the same run |
1693 |
*/ |
*/ |
1694 |
Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){ |
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev){ |
1695 |
// |
// |
1696 |
// check if we have already called once GetEntry, if not call it |
// check if we have already called once GetEntry, if not call it |
1697 |
// |
// |
1698 |
if ( run->GetEntries() <= 0 ) return(false); |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- NON FUNZIONA BENISSIMO.... "<<endl; |
1699 |
|
if(!run){ |
1700 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
1701 |
|
return(false); |
1702 |
|
} |
1703 |
|
if ( run->GetEntries() <= 0 ) return(false); |
1704 |
// |
// |
1705 |
|
|
1706 |
Int_t oldrun = irun; |
// Int_t oldrun = irun; |
1707 |
|
Long64_t oldrun = irun; |
1708 |
|
|
1709 |
// -------------------------------------- |
// -------------------------------------- |
1710 |
// if it is a full file (not preselected) |
// if it is a full file (not preselected) |
1711 |
// -------------------------------------- |
// -------------------------------------- |
1712 |
if(SELLI==0){ |
if(SELLI==0){ |
|
if ( irun < 0 ){ |
|
|
irun = 0; |
|
|
run->GetEntry(irun); |
|
|
runfirstentry = 0ULL; |
|
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
|
|
if ( (ULong64_t)(this->GetRunInfo()->NEVENTS) > 0ULL ) runlastentry -= 1ULL; |
|
|
return(true); |
|
|
}; |
|
1713 |
|
|
1714 |
|
// |
1715 |
|
// the absolute time is necessary to relate the event with the run |
1716 |
|
// |
1717 |
if( !GetOrbitalInfo() ){ |
if( !GetOrbitalInfo() ){ |
1718 |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1719 |
return(false); |
return(false); |
1720 |
} |
} |
1721 |
|
|
1722 |
|
// |
1723 |
|
// the first time the routine is called, set run search from the beginning |
1724 |
|
// |
1725 |
|
if ( irun < 0LL ){ |
1726 |
|
irun = 0LL; |
1727 |
|
run->GetEntry(irun); |
1728 |
|
runfirstentry = 0LL; |
1729 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1730 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
1731 |
|
}; |
1732 |
|
// |
1733 |
|
if ( irun == run->GetEntries()-1LL && |
1734 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
1735 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
1736 |
|
){ |
1737 |
|
irun = -1LL; |
1738 |
|
runfirstentry = 0LL; |
1739 |
|
runlastentry = -1LL; |
1740 |
|
}; |
1741 |
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
1742 |
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
1743 |
while ( GetOrbitalInfo()->absTime > GetRunInfo()->RUNTRAILER_TIME && irun < run->GetEntries() ){ |
// |
1744 |
|
bool fromfirst = true; |
1745 |
|
// |
1746 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
1747 |
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
|
1748 |
irun++; |
irun++; |
1749 |
run->GetEntry(irun); |
run->GetEntry(irun); |
1750 |
runfirstentry = runlastentry; |
runfirstentry = runlastentry; |
1751 |
if ( (ULong64_t)(this->GetRunInfo()->NEVENTS) > 0ULL ) runfirstentry += 1ULL; |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; |
1752 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1753 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1754 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
1755 |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
1756 |
|
// printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); |
1757 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
1758 |
|
// |
1759 |
|
// prevshift = 0; |
1760 |
|
// |
1761 |
|
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ |
1762 |
|
printf(" resetting irun (it should NOT happen!!!)\n"); |
1763 |
|
fromfirst = false; |
1764 |
|
irun = 0; |
1765 |
|
run->GetEntry(irun); |
1766 |
|
runfirstentry = 0ULL; |
1767 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1768 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
1769 |
|
}; |
1770 |
|
// |
1771 |
}; |
}; |
1772 |
|
// |
1773 |
|
if ( |
1774 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
1775 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
1776 |
|
) { |
1777 |
|
printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); |
1778 |
|
return false; |
1779 |
|
} |
1780 |
// |
// |
1781 |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
1782 |
// |
// |
1783 |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
1784 |
// |
// |
1785 |
|
prevshift = 0; |
1786 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1787 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
1788 |
return(true); |
return(true); |
1789 |
}; |
}; |
1790 |
// ---------------------------------------------------- |
// ---------------------------------------------------- |
1793 |
// ---------------------------------------------------- |
// ---------------------------------------------------- |
1794 |
if(SELLI==1){ |
if(SELLI==1){ |
1795 |
sel_tree->GetEntry(iev); |
sel_tree->GetEntry(iev); |
1796 |
|
// cout << irun << " "<< irunentry << endl; |
1797 |
if(irun != oldrun){ |
if(irun != oldrun){ |
1798 |
run->GetEntry(irun); |
run->GetEntry(irun); |
1799 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1800 |
|
prevshift = 0; |
1801 |
return true; |
return true; |
1802 |
} |
} |
1803 |
return false; |
return false; |
1806 |
return false; |
return false; |
1807 |
// |
// |
1808 |
}; |
}; |
1809 |
|
|
1810 |
|
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev){ |
1811 |
|
|
1812 |
|
if(!run_tree){ |
1813 |
|
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
1814 |
|
return false; |
1815 |
|
} |
1816 |
|
if ( run_tree->GetEntries() <= 0 ) { |
1817 |
|
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
1818 |
|
return(false); |
1819 |
|
} |
1820 |
|
|
1821 |
|
Int_t oldrun = irun; // store current run index |
1822 |
|
|
1823 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1824 |
|
// if it is a full file (not preselected) |
1825 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1826 |
|
if(SELLI==0){ |
1827 |
|
|
1828 |
|
// --------------------------------------------------------------- |
1829 |
|
// the absolute time is necessary to relate the event with the run |
1830 |
|
// --------------------------------------------------------------- |
1831 |
|
if( !GetOrbitalInfo() ){ |
1832 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1833 |
|
return(false); |
1834 |
|
} |
1835 |
|
|
1836 |
|
// ----------------------------------------------------------------------- |
1837 |
|
// the first time the routine is called, set run search from the beginning |
1838 |
|
// ----------------------------------------------------------------------- |
1839 |
|
if ( irun < 0 ){ |
1840 |
|
irun = 0LL; |
1841 |
|
run_tree->GetEntry(irun); |
1842 |
|
}; |
1843 |
|
// |
1844 |
|
bool fromfirst = true; // first loop over runs |
1845 |
|
// ------------------------------------------------------ |
1846 |
|
// loop over runs to find the one that contains the event |
1847 |
|
// ------------------------------------------------------ |
1848 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
1849 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && |
1850 |
|
!(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
1851 |
|
GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) && |
1852 |
|
irun < run_tree->GetEntries() ){ |
1853 |
|
irun++; |
1854 |
|
// ------------------------------------ |
1855 |
|
// if the end of run tree is reached... |
1856 |
|
// ------------------------------------ |
1857 |
|
if( irun == run_tree->GetEntries() ){ |
1858 |
|
if(!fromfirst){ |
1859 |
|
// ----------------------------------------------------- |
1860 |
|
// if it happened already once and the run was not found |
1861 |
|
// ---> exit with error |
1862 |
|
// ----------------------------------------------------- |
1863 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
1864 |
|
return false; |
1865 |
|
} |
1866 |
|
// ----------------------------------------- |
1867 |
|
// ...otherwise repeat search from beginning |
1868 |
|
// ----------------------------------------- |
1869 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- reached end of run tree. searchin again from beginning " <<endl; |
1870 |
|
fromfirst = false; |
1871 |
|
irun = 0LL; |
1872 |
|
runfirstentry = 0LL; |
1873 |
|
} |
1874 |
|
// ------------------------------------------------------------------- |
1875 |
|
// save the index of the first entry of the run, relative to pam_tree, |
1876 |
|
// and read a new run |
1877 |
|
// ------------------------------------------------------------------- |
1878 |
|
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS); |
1879 |
|
run_tree->GetEntry(irun); |
1880 |
|
if(GetRunInfo()->RUNHEADER_OBT>=GetRunInfo()->RUNTRAILER_OBT ){ |
1881 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
1882 |
|
cout << " (NB!! in this case some events are assigned to a wrong run)"<<endl; |
1883 |
|
} |
1884 |
|
}; |
1885 |
|
// -------------------------------------- |
1886 |
|
// if there was no need to update the run |
1887 |
|
// ---> exit with FALSE |
1888 |
|
// -------------------------------------- |
1889 |
|
if ( irun == oldrun ) return(false); |
1890 |
|
|
1891 |
|
// -------------------------------------- |
1892 |
|
// ... otherwise |
1893 |
|
// ---> exit with TRUE |
1894 |
|
// -------------------------------------- |
1895 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1896 |
|
prevshift = 0; |
1897 |
|
return(true); |
1898 |
|
}; |
1899 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1900 |
|
// if it is a preselected file (there is SelectionList) |
1901 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1902 |
|
if(SELLI==1){ |
1903 |
|
sel_tree->GetEntry(iev); |
1904 |
|
if(irun != oldrun){ |
1905 |
|
run_tree->GetEntry(irun); |
1906 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1907 |
|
prevshift = 0; |
1908 |
|
return true; |
1909 |
|
} |
1910 |
|
return false; |
1911 |
|
} |
1912 |
|
|
1913 |
|
return false; |
1914 |
|
// |
1915 |
|
}; |
1916 |
/** |
/** |
1917 |
* Update the runinfo informations (to be used to have Run infos event by event basis) |
* Update the runinfo informations (to be used to have Run infos event by event basis) |
1918 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
1919 |
* @return true if a new run has been read, false if it is still the same run |
* @return true if a new run has been read, false if it is still the same run |
1920 |
*/ |
*/ |
1921 |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev){ |
1922 |
return(UpdateRunInfo((TChain*)run,iev)); |
return(UpdateRunInfo((TChain*)run,iev)); |
1923 |
}; |
}; |
1924 |
|
|
2553 |
cout << "Run : branch RunInfo"<<endl; |
cout << "Run : branch RunInfo"<<endl; |
2554 |
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
2555 |
cout << "Run : branch SoftInfo"<<endl; |
cout << "Run : branch SoftInfo"<<endl; |
2556 |
|
// ------------------ |
2557 |
|
// replicate run tree |
2558 |
|
// ------------------ |
2559 |
|
cout << "----------------------------------------------------"<<endl; |
2560 |
|
cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl; |
2561 |
|
for (Int_t i=0; i<run_tree->GetEntries(); i++){ |
2562 |
|
run_tree->GetEntry(i); |
2563 |
|
cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
2564 |
|
run_tree_clone->Fill(); |
2565 |
|
} |
2566 |
|
cout << "----------------------------------------------------"<<endl; |
2567 |
|
|
2568 |
|
|
2569 |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
2570 |
sel_tree_clone->Branch("RunEntry",&irun,"runentry/I"); |
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
2571 |
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/I"); |
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); |
2572 |
|
|
2573 |
|
|
2574 |
Int_t i=0; |
Int_t i=0; |
2578 |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2579 |
pam_tree_clone[i]->BranchRef(); |
pam_tree_clone[i]->BranchRef(); |
2580 |
cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Tracker : branch TrkLevel1"<<endl; |
2581 |
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
// cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2582 |
}; |
}; |
2583 |
if(TRK2) { |
if(TRK2) { |
2584 |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2708 |
/** |
/** |
2709 |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
2710 |
*/ |
*/ |
2711 |
Int_t PamLevel2::GetEntry(Int_t iee){ |
//Int_t PamLevel2::GetEntry(Int_t iee){ |
2712 |
|
Int_t PamLevel2::GetEntry(Long64_t iee){ |
2713 |
|
|
2714 |
if(!pam_tree){ |
if(!pam_tree){ |
2715 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
2725 |
// return 0; |
// return 0; |
2726 |
// } |
// } |
2727 |
|
|
2728 |
Int_t ii=0; |
Long64_t ii=0; |
2729 |
//------------------------------- |
//------------------------------- |
2730 |
ii = iee; |
ii = iee; |
2731 |
if( !pam_tree->GetEntry(ii) ) return 0; |
if( !pam_tree->GetEntry(ii) ){ |
2732 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl; |
2733 |
|
return 0; |
2734 |
|
} |
2735 |
// |
// |
2736 |
// ... 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. |
// ... 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. |
2737 |
// 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 |
// 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 |
2739 |
// |
// |
2740 |
if(!run_tree ){ |
if(!run_tree ){ |
2741 |
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
2742 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
2743 |
return 0; |
return 0; |
2744 |
} else { |
} else { |
2745 |
return 1; //cosi` se non c'e` run esce qua... |
return 1; //cosi` se non c'e` run esce qua... |
2746 |
} |
} |
2747 |
} |
} |
2748 |
|
|
2749 |
//------------------------------- |
//------------------------------- |
2750 |
ii = iee; |
ii = iee; |
2751 |
Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2752 |
|
// Bool_t UPDATED = UpdateRunInfo(ii); |
2753 |
|
UpdateRunInfo(ii); |
2754 |
if(SELLI==0)irunentry = iee-runfirstentry; |
if(SELLI==0)irunentry = iee-runfirstentry; |
2755 |
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2756 |
|
|
2757 |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2758 |
|
|
2759 |
if( TRK0 || CAL0 || TOF0 )GetYodaEntry( ); |
// cout << " irunentry "<<irunentry << endl; |
2760 |
|
|
2761 |
|
if( TRK0 || CAL0 || TOF0 ){ |
2762 |
|
if( !GetYodaEntry( ) ){ |
2763 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
2764 |
|
return 0; |
2765 |
|
} |
2766 |
|
} |
2767 |
return 1; |
return 1; |
2768 |
|
|
2769 |
} |
} |
2782 |
// check if iroot has changed |
// check if iroot has changed |
2783 |
//=================================== |
//=================================== |
2784 |
if( irun<0 ){ |
if( irun<0 ){ |
2785 |
cout << "PamLevel2::GetYodaTree() -- ERROR "<<endl; |
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = "<<irun<<endl; |
2786 |
cout << "In order to use this method you have to load the RunInfo tree "<<endl; |
// cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
|
cout << "with the method TChain* PamLevel2::GetRunTree(TString, TString)"<<endl; |
|
|
// cout << " - read the event with PamLevel2::GetEntry(Int_t)"<<endl; |
|
2787 |
return NULL; |
return NULL; |
2788 |
} |
} |
2789 |
Int_t irootnew = run_obj->ID_ROOT_L0; |
Int_t irootnew = run_obj->ID_ROOT_L0; |
2867 |
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
2868 |
} |
} |
2869 |
|
|
2870 |
if ( TRK0 ) TrkParams::SetCalib(run_obj,dbc); |
if ( TRK0 ){ |
2871 |
|
TrkParams::Load(6); |
2872 |
|
if( !TrkParams::IsLoaded(6) ){ |
2873 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
2874 |
|
}; |
2875 |
|
TrkParams::SetCalib(run_obj,dbc); |
2876 |
|
TrkParams::LoadCalib( ); |
2877 |
|
if( !TrkParams::CalibIsLoaded() ){ |
2878 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl; |
2879 |
|
}; |
2880 |
|
} |
2881 |
|
|
2882 |
// cout << l0_tree << endl; |
// cout << l0_tree << endl; |
2883 |
|
|
2894 |
if(!GetYodaTree())return 0; |
if(!GetYodaTree())return 0; |
2895 |
|
|
2896 |
// patch |
// patch |
2897 |
if( (Int_t)irunentry < 0){ |
if( irunentry < 0){ |
2898 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
2899 |
irunentry=0; |
irunentry=0LL; |
2900 |
} |
} |
2901 |
// --------------------------------- |
// --------------------------------- |
2902 |
// if file is NOT a preselected file |
// if file is NOT a preselected file |
2903 |
// --------------------------------- |
// --------------------------------- |
2904 |
UInt_t quellagiusta = irunentry + run_obj->EV_FROM; |
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
2905 |
|
// cout << " irunentry "<<irunentry<<endl; |
2906 |
|
// cout << " EV_FROM "<<run_obj->EV_FROM<<endl; |
2907 |
|
// cout << " quellagiusta = irunentry + EV_FROM "<< quellagiusta << endl; |
2908 |
|
|
2909 |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
2910 |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
2915 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
2916 |
return 0; |
return 0; |
2917 |
} |
} |
2918 |
|
if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ |
2919 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
2920 |
|
return 0; |
2921 |
|
} |
2922 |
|
|
2923 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
2924 |
// ATTENTION!!! |
// ATTENTION!!! |
2933 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
2934 |
Int_t answer = 0; |
Int_t answer = 0; |
2935 |
Int_t shift =0; |
Int_t shift =0; |
2936 |
|
// printf(" siamo qui %i %i \n",shift,prevshift); |
2937 |
|
Int_t maxshift = 100; |
2938 |
do{ |
do{ |
2939 |
if(shift>0){ |
if(shift>0){ |
2940 |
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl; |
cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
2941 |
|
cout << " RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM <<endl; |
2942 |
|
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
2943 |
} |
} |
2944 |
answer = l0_tree->GetEntry(quellagiusta+shift+prevshift); |
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
2945 |
shift++; |
shift++; |
2946 |
if( !GetEventHeader() ){ |
if( !GetEventHeader() ){ |
2947 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
2948 |
return 0; |
return 0; |
2949 |
} |
} |
2950 |
|
// cout << "PKTNUM "<<shift<<" == L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
2951 |
|
// cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
2952 |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
2953 |
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
2954 |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
2955 |
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
2956 |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
2957 |
if ( prevshift != 0 && (quellagiusta+shift) == GetYodaTree()->GetEntries() ){ |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
2958 |
|
// |
2959 |
|
if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ |
2960 |
prevshift = 0; |
prevshift = 0; |
2961 |
shift = -1; |
shift = -1; |
2962 |
}; |
}; |
2963 |
|
|
2964 |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < GetYodaTree()->GetEntries() ); |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
|
|
|
|
if ( (quellagiusta+shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <<endl; |
|
2965 |
|
|
2966 |
|
if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() || shift == maxshift ) { |
2967 |
|
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
2968 |
|
return 0; |
2969 |
|
} |
2970 |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
2971 |
// return GetYodaTree()->GetEntry(quellagiusta); |
// return GetYodaTree()->GetEntry(quellagiusta); |
2972 |
if ( shift > 1 ) prevshift += (shift-1); |
if ( shift > 1 ) prevshift += (shift-1); |