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(); |
123 |
// nd_obj = NDLevel2::GetNDLevel2(); |
// nd_obj = NDLevel2::GetNDLevel2(); |
124 |
// ac_obj = AcLevel2::GetAcLevel2(); |
// ac_obj = AcLevel2::GetAcLevel2(); |
125 |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
126 |
|
|
127 |
|
h0_obj = 0; |
128 |
|
trk0_obj = 0; |
129 |
|
calo0_obj = 0; |
130 |
|
|
131 |
trk2_obj = 0; |
trk2_obj = 0; |
132 |
trk1_obj = 0; |
trk1_obj = 0; |
133 |
trkh_obj = 0; |
trkh_obj = 0; |
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; |
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 |
|
|
178 |
for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; |
|
179 |
|
|
180 |
// sorted_tracks = 0;//new TRefArray(); |
// sorted_tracks = 0;//new TRefArray(); |
181 |
|
|
182 |
|
CAL0 = false; |
183 |
CAL1 = true; |
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; |
RUN = true; |
198 |
|
|
199 |
|
SELLI = -1; |
200 |
|
|
201 |
tsorted=0; |
tsorted=0; |
202 |
timage=0; |
timage=0; |
203 |
|
|
204 |
|
howtosort = "+CAL+TOF"; |
205 |
|
//howtosort = "+TOF"; |
206 |
|
sortthr = 100.; |
207 |
|
|
208 |
}; |
}; |
209 |
/** |
/** |
215 |
if(soft_obj)delete soft_obj; //Emiliano |
if(soft_obj)delete soft_obj; //Emiliano |
216 |
|
|
217 |
// cout << "void PamLevel2::Clear()"<<endl; |
// cout << "void PamLevel2::Clear()"<<endl; |
218 |
|
if(h0_obj) delete h0_obj; |
219 |
|
if(trk0_obj) delete trk0_obj; |
220 |
|
if(calo0_obj) delete calo0_obj; |
221 |
if(trk1_obj) delete trk1_obj; |
if(trk1_obj) delete trk1_obj; |
222 |
if(trk2_obj) delete trk2_obj; |
if(trk2_obj) delete trk2_obj; |
223 |
if(trkh_obj) delete trkh_obj; |
if(trkh_obj) delete trkh_obj; |
238 |
timage->Delete(); |
timage->Delete(); |
239 |
delete timage; |
delete timage; |
240 |
} |
} |
241 |
|
|
242 |
|
if(dbc){ |
243 |
|
dbc->Close(); |
244 |
|
delete dbc; |
245 |
|
} |
246 |
|
|
247 |
|
if(l0_file)l0_file->Close(); |
248 |
|
// if(pam_tree)pam_tree->Delete();; |
249 |
|
|
250 |
|
if ( pam_tree ){ |
251 |
|
// |
252 |
|
// 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... |
253 |
|
// |
254 |
|
TList *temp = pam_tree->GetListOfFriends(); |
255 |
|
TList *contents = new TList; // create chain friend list |
256 |
|
contents->SetOwner(); |
257 |
|
TIter next(temp); |
258 |
|
TChain *questo = 0; |
259 |
|
while ( (questo = (TChain*) next()) ){ |
260 |
|
TString name = questo->GetName(); |
261 |
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
262 |
|
}; |
263 |
|
// |
264 |
|
// deleting the main chain |
265 |
|
// |
266 |
|
pam_tree->Delete(); |
267 |
|
// |
268 |
|
// deleting the friends... |
269 |
|
// |
270 |
|
TIter next2(contents); |
271 |
|
TChain *questa = 0; |
272 |
|
while ( questa = (TChain*)next2() ){ |
273 |
|
TString name = questa->GetName(); |
274 |
|
questa->Delete(); |
275 |
|
questa=NULL; |
276 |
|
}; |
277 |
|
// |
278 |
|
}; |
279 |
|
pam_tree = NULL; |
280 |
|
|
281 |
|
if(run_tree)run_tree->Delete();; |
282 |
|
if(sel_tree)sel_tree->Delete();; |
283 |
|
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
284 |
|
if(run_tree_clone)run_tree_clone->Delete();; |
285 |
|
if(sel_tree_clone)sel_tree_clone->Delete();; |
286 |
|
|
287 |
|
|
288 |
}; |
}; |
289 |
|
|
290 |
/** |
/** |
302 |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
303 |
// if(soft_obj) soft_obj->Clear(); |
// if(soft_obj) soft_obj->Clear(); |
304 |
|
|
305 |
|
if(h0_obj) h0_obj->Clear(); |
306 |
|
// if(trk0_obj) trk0_obj->Clear(); |
307 |
|
if(calo0_obj) calo0_obj->Clear(); |
308 |
if(trk1_obj) trk1_obj->Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
309 |
if(trk2_obj) trk2_obj->Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
310 |
if(trkh_obj) trkh_obj->Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
311 |
if(calo1_obj)calo1_obj->Clear(); |
if(calo1_obj)calo1_obj->Clear(); |
312 |
if(calo2_obj)calo2_obj->Clear(); |
if(calo2_obj)calo2_obj->Clear(); |
326 |
if(timage){ |
if(timage){ |
327 |
timage->Delete(); |
timage->Delete(); |
328 |
} |
} |
329 |
|
}; |
330 |
|
|
331 |
|
void PamLevel2::Reset(){ |
332 |
|
// |
333 |
|
// First of all clear everything |
334 |
|
// |
335 |
|
Clear(); |
336 |
|
// |
337 |
|
// close and reset chains and pointers |
338 |
|
// |
339 |
|
if ( pam_tree ){ |
340 |
|
// |
341 |
|
// 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... |
342 |
|
// |
343 |
|
TList *temp = pam_tree->GetListOfFriends(); |
344 |
|
TList *contents = new TList; // create chain friend list |
345 |
|
contents->SetOwner(); |
346 |
|
TIter next(temp); |
347 |
|
TChain *questo = 0; |
348 |
|
while ( (questo = (TChain*) next()) ){ |
349 |
|
TString name = questo->GetName(); |
350 |
|
contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list |
351 |
|
}; |
352 |
|
// |
353 |
|
// deleting the main chain |
354 |
|
// |
355 |
|
pam_tree->Delete(); |
356 |
|
// |
357 |
|
// deleting the friends... |
358 |
|
// |
359 |
|
TIter next2(contents); |
360 |
|
TChain *questa = 0; |
361 |
|
while ( questa = (TChain*)next2() ){ |
362 |
|
TString name = questa->GetName(); |
363 |
|
questa->Delete(); |
364 |
|
questa=NULL; |
365 |
|
}; |
366 |
|
// |
367 |
|
}; |
368 |
|
pam_tree = NULL; |
369 |
|
// |
370 |
|
if(run_tree)run_tree->Delete();; |
371 |
|
run_tree = NULL; |
372 |
|
if(sel_tree)sel_tree->Delete();; |
373 |
|
sel_tree = NULL; |
374 |
|
// |
375 |
|
// Close file |
376 |
|
// |
377 |
|
if(l0_file)l0_file->Close("R"); |
378 |
|
l0_file = NULL; |
379 |
|
// |
380 |
|
h0_obj = 0; |
381 |
|
trk0_obj = 0; |
382 |
|
calo0_obj = 0; |
383 |
|
// |
384 |
|
trk2_obj = 0; |
385 |
|
trk1_obj = 0; |
386 |
|
trkh_obj = 0; |
387 |
|
calo1_obj = 0; |
388 |
|
calo2_obj = 0; |
389 |
|
tof_obj = 0; |
390 |
|
trig_obj = 0; |
391 |
|
s4_obj = 0; |
392 |
|
nd_obj = 0; |
393 |
|
ac_obj = 0; |
394 |
|
orb_obj = 0; |
395 |
|
// |
396 |
|
// Reset run pointers |
397 |
|
// |
398 |
|
run_obj = 0;//new GL_RUN(); |
399 |
|
soft_obj = 0;// Emiliano |
400 |
|
irun = -1; |
401 |
|
runfirstentry = 0ULL; |
402 |
|
runlastentry = 0ULL; |
403 |
|
// |
404 |
}; |
}; |
405 |
|
|
406 |
|
|
597 |
} |
} |
598 |
//-------------------------------------- |
//-------------------------------------- |
599 |
// |
// |
600 |
|
|
601 |
|
/** |
602 |
|
* Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks. Left here as backward compatibility method. |
603 |
|
**/ |
604 |
|
void PamLevel2::SortTracks(TString how){ |
605 |
|
printf(" WARNING! obsolete, use SortTracks() and SetSortingMethod(TString) instead! \n Setting sorting method to %s \n",how.Data()); |
606 |
|
howtosort = how; |
607 |
|
SortTracks(); |
608 |
|
}; |
609 |
|
|
610 |
// |
// |
611 |
//-------------------------------------- |
//-------------------------------------- |
612 |
/** |
/** |
620 |
* |
* |
621 |
* The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how). |
* The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how). |
622 |
*/ |
*/ |
623 |
void PamLevel2::SortTracks(TString how){ |
void PamLevel2::SortTracks(){ |
624 |
|
TString how = howtosort; |
625 |
|
|
626 |
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
// cout <<" PamLevel2::SortTracks(TString how) "<<endl; |
627 |
if( !trk2_obj ){ |
if( !trk2_obj ){ |
628 |
cout << "void PamLevel2::SortTracks(TString how): TrkLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(): TrkLevel2 not loaded !!!"; |
629 |
return; |
return; |
630 |
}; |
}; |
631 |
// cout << "call SortTracs() "<<endl; |
// cout << "call SortTracs() "<<endl; |
632 |
//Save current Object count |
//Save current Object count |
633 |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
634 |
|
|
635 |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
// cout << "ObjectNumber "<<ObjectNumber <<endl; |
636 |
|
|
637 |
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
// if(!sorted_tracks)sorted_tracks = new TRefArray(); |
638 |
// sorted_tracks->Clear(); |
// sorted_tracks->Clear(); |
639 |
// sorted_tracks.Clear(); |
// sorted_tracks.Clear(); |
640 |
|
|
641 |
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
642 |
tsorted->Delete(); |
tsorted->Delete(); |
643 |
TClonesArray &ttsorted = *tsorted; |
TClonesArray &ttsorted = *tsorted; |
644 |
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); |
645 |
timage->Delete(); |
timage->Delete(); |
646 |
TClonesArray &ttimage = *timage; |
TClonesArray &ttimage = *timage; |
647 |
|
|
648 |
|
|
649 |
// loop over the tracks sorted by the tracker |
// loop over the tracks sorted by the tracker |
650 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
651 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
652 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
653 |
|
|
654 |
if( !CAL2 && use_CAL) use_CAL = false; |
if( !CAL2 && use_CAL) use_CAL = false; |
655 |
if( !TOF && use_TOF) use_TOF = false; |
if( !TOF && use_TOF) use_TOF = false; |
656 |
|
|
657 |
if( !TRK2 ){ |
if( !TRK2 ){ |
658 |
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
// cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
659 |
return; |
return; |
660 |
}; |
}; |
661 |
|
|
662 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
663 |
|
|
664 |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
665 |
|
|
666 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
667 |
CaloTrkVar *cs = 0; |
CaloTrkVar *cs = 0; |
668 |
ToFTrkVar *os = 0; |
ToFTrkVar *os = 0; |
669 |
|
|
670 |
// get tracker tracks |
// get tracker tracks |
671 |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
672 |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
673 |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
674 |
|
|
675 |
TrkTrack *ti = 0; //tracker (image) |
TrkTrack *ti = 0; //tracker (image) |
676 |
CaloTrkVar *ci = 0; |
CaloTrkVar *ci = 0; |
677 |
ToFTrkVar *oi = 0; |
ToFTrkVar *oi = 0; |
678 |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
679 |
// if track has an image, check image selection |
// if track has an image, check image selection |
680 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
681 |
|
|
682 |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) |
683 |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
684 |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
oi = GetToFStoredTrack(ti->GetSeqNo()); |
685 |
|
|
686 |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
687 |
|
|
688 |
//assign starting scores |
//assign starting scores |
689 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
690 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
691 |
|
|
692 |
// ------------------------ |
// ------------------------ |
693 |
// calorimeter check |
// calorimeter check |
694 |
// ------------------------ |
// ------------------------ |
695 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
696 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
697 |
if( use_CAL && !calo2_obj ){ |
if( use_CAL && !calo2_obj ){ |
698 |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but CaloLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!"; |
699 |
return; |
return; |
700 |
}; |
}; |
701 |
if( |
if( |
702 |
use_CAL && |
use_CAL && |
703 |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
704 |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
705 |
true){ |
cp && ci && |
706 |
|
true){ |
707 |
|
|
708 |
|
|
709 |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
710 |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
711 |
|
|
712 |
if(resy_p <= resy_i) tp_score++; |
if(resy_p <= resy_i) tp_score++; |
713 |
else ti_score++; |
else ti_score++; |
714 |
|
|
715 |
|
// cout << "CALO "<<tp_score<<ti_score<<endl; |
716 |
|
|
717 |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
}; |
718 |
|
// ------------------------ |
719 |
|
// TOF check |
720 |
|
// ------------------------ |
721 |
|
// check the number of hit pmts along the track |
722 |
|
// on S12 S21 and S32, where paddles are parallel to Y axis |
723 |
|
if( use_TOF && !tof_obj ){ |
724 |
|
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!"; |
725 |
|
return; |
726 |
|
}; |
727 |
|
if( use_TOF && op && oi ){ |
728 |
|
|
729 |
|
// |
730 |
|
Float_t sen = 0.; |
731 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
732 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
733 |
|
if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (op->dedx).At(ih); |
734 |
|
}; |
735 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
736 |
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
737 |
|
if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (oi->dedx).At(ih); |
738 |
|
}; |
739 |
|
// |
740 |
|
if ( sen >= sortthr ){ |
741 |
|
//printf(" IS A NUCLEUS! en = %f \n",sen); |
742 |
|
// |
743 |
|
// is a nucleus use a different algorithm |
744 |
|
// |
745 |
|
Int_t nz = 6; Float_t zin[6]; // << define TOF z-coordinates |
746 |
|
for(Int_t ip=0; ip<nz; ip++) |
747 |
|
zin[ip] = tof_obj->ToFLevel2::GetZTOF(tof_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates |
748 |
|
Trajectory *tr = new Trajectory(nz,zin); |
749 |
|
// |
750 |
|
Int_t nphit_p =0; |
751 |
|
Int_t nphit_i =0; |
752 |
|
Float_t enhit_p = 0.; |
753 |
|
Float_t enhit_i = 0.; |
754 |
|
// |
755 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
756 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
757 |
|
if(pl == 1 || pl == 2 || pl == 5){ |
758 |
|
nphit_p++; |
759 |
|
enhit_p += (op->dedx).At(ih); |
760 |
|
}; |
761 |
|
}; |
762 |
|
// |
763 |
|
tp->DoTrack2(tr); |
764 |
|
// |
765 |
|
if ( fabs(tr->y[0]-oi->ytofpos[0]) < 2. ){ |
766 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
767 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
768 |
|
if(pl == 0){ |
769 |
|
nphit_p++; |
770 |
|
enhit_p += (op->dedx).At(ih); |
771 |
|
}; |
772 |
|
}; |
773 |
|
}; |
774 |
|
if ( fabs(tr->y[3]-oi->ytofpos[1]) < 2. ){ |
775 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
776 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
777 |
|
if(pl == 3){ |
778 |
|
nphit_p++; |
779 |
|
enhit_p += (op->dedx).At(ih); |
780 |
|
}; |
781 |
|
}; |
782 |
|
}; |
783 |
|
if ( fabs(tr->y[4]-oi->ytofpos[2]) < 2. ){ |
784 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
785 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
786 |
|
if(pl == 4){ |
787 |
|
nphit_p++; |
788 |
|
enhit_p += (op->dedx).At(ih); |
789 |
|
}; |
790 |
|
}; |
791 |
|
}; |
792 |
|
|
793 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
794 |
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
795 |
|
if(pl == 1 || pl == 2 || pl == 5){ |
796 |
|
nphit_i++; |
797 |
|
enhit_i += (op->dedx).At(ih); |
798 |
|
}; |
799 |
|
}; |
800 |
|
// |
801 |
|
ti->DoTrack2(tr); |
802 |
|
// |
803 |
|
if ( fabs(tr->y[0]-oi->ytofpos[0]) < 2. ){ |
804 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
805 |
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
806 |
|
if(pl == 0){ |
807 |
|
nphit_i++; |
808 |
|
enhit_i += (op->dedx).At(ih); |
809 |
|
}; |
810 |
|
}; |
811 |
|
}; |
812 |
|
if ( fabs(tr->y[3]-oi->ytofpos[1]) < 2. ){ |
813 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
814 |
|
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
815 |
|
if(pl == 3){ |
816 |
|
nphit_i++; |
817 |
|
enhit_i += (op->dedx).At(ih); |
818 |
|
}; |
819 |
}; |
}; |
820 |
// ------------------------ |
}; |
821 |
// TOF check |
if ( fabs(tr->y[4]-oi->ytofpos[2]) < 2. ){ |
822 |
// ------------------------ |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
823 |
// check the number of hit pmts along the track |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
824 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
if(pl == 4){ |
825 |
if( use_TOF && !tof_obj ){ |
nphit_i++; |
826 |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
enhit_i += (op->dedx).At(ih); |
827 |
return; |
}; |
828 |
}; |
}; |
829 |
if( use_TOF ){ |
}; |
830 |
|
|
831 |
|
|
832 |
Int_t nphit_p =0; |
if( |
833 |
Int_t nphit_i =0; |
use_TOF && |
834 |
|
(nphit_p+nphit_i) !=0 && |
835 |
|
true){ |
836 |
|
|
837 |
|
// printf(" seqno %i nphit_p %i nphit_i %i enhit_p %f enhit_i %f \n",trk2_obj->TrkLevel2::GetSeqNo(i),nphit_p,nphit_i,enhit_p,enhit_i); |
838 |
|
// printf(" score p %i score i %i \n",tp_score,ti_score); |
839 |
|
// if( enhit_p > enhit_i ) tp_score++; |
840 |
|
// if( nphit_p >= nphit_i && enhit_p > enhit_i ) tp_score++; |
841 |
|
if ( nphit_p > nphit_i ) tp_score++; |
842 |
|
if ( nphit_p < nphit_i ) ti_score++; |
843 |
|
if ( nphit_p == nphit_i ){ |
844 |
|
if ( enhit_p > enhit_i ) tp_score++; |
845 |
|
else ti_score++; |
846 |
|
}; |
847 |
|
// printf(" dopo score p %i score i %i \n",tp_score,ti_score); |
848 |
|
}; |
849 |
|
delete tr; |
850 |
|
// |
851 |
|
} else { |
852 |
|
// |
853 |
|
// NOT a NUCLEUS |
854 |
|
// |
855 |
|
//printf(" NOT a NUCLEUS! en = %f \n",sen); |
856 |
|
|
857 |
|
Int_t nphit_p =0; |
858 |
|
Int_t nphit_i =0; |
859 |
|
|
860 |
|
|
861 |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
862 |
cout << "track: npmttdc "<< op->npmttdc << endl; |
cout << "track: npmttdc "<< op->npmttdc << endl; |
863 |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
864 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
865 |
|
|
866 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
867 |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
868 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
869 |
}; |
}; |
870 |
|
|
871 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
872 |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
873 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
874 |
}; |
}; |
875 |
|
|
876 |
if( |
if( |
877 |
use_TOF && |
use_TOF && |
878 |
(nphit_p+nphit_i) !=0 && |
(nphit_p+nphit_i) !=0 && |
879 |
true){ |
true){ |
880 |
|
|
881 |
if( nphit_p >= nphit_i) tp_score++; |
if( nphit_p >= nphit_i) tp_score++; |
882 |
else ti_score++; |
else ti_score++; |
883 |
}; |
}; |
884 |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
}; |
885 |
}; |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
886 |
if(tp_score == ti_score) use_TRK = true; |
}; |
887 |
// ------------------------ |
if(tp_score == ti_score) use_TRK = true; |
888 |
// tracker check |
// ------------------------ |
889 |
// ------------------------ |
// tracker check |
890 |
// chi**2 difference is not always large enough to distinguish among |
// ------------------------ |
891 |
// the real track and its image. |
// chi**2 difference is not always large enough to distinguish among |
892 |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
// the real track and its image. |
893 |
if(use_TRK){ |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
894 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
if(use_TRK){ |
895 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
896 |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
897 |
}; |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
898 |
|
}; |
899 |
|
|
900 |
// ------------------------ |
// ------------------------ |
901 |
// the winner is.... |
// the winner is.... |
902 |
// ------------------------ |
// ------------------------ |
903 |
if (tp_score > ti_score) { |
if (tp_score > ti_score) { |
904 |
// ts = tp;//the track sorted by the tracker!! |
// ts = tp;//the track sorted by the tracker!! |
905 |
// cs = cp; |
// cs = cp; |
906 |
// os = op; |
// os = op; |
907 |
}else if (tp_score < ti_score) { |
// cout << "It's primary!" << endl; |
908 |
ts = ti;//its image!! |
|
909 |
cs = ci; |
}else if (tp_score < ti_score) { |
910 |
os = oi; |
|
911 |
|
// cout << "It's image!" << endl; |
912 |
ti = tp;//its image!! |
|
913 |
ci = cp; |
ts = ti;//its image!! |
914 |
oi = op; |
cs = ci; |
915 |
|
os = oi; |
916 |
tp = ts;//its image!! |
|
917 |
cp = cs; |
ti = tp;//its image!! |
918 |
op = os; |
ci = cp; |
919 |
|
oi = op; |
920 |
|
|
921 |
|
tp = ts;//its image!! |
922 |
|
cp = cs; |
923 |
|
op = os; |
924 |
|
|
925 |
|
|
926 |
}else { |
}else { |
927 |
// ts = tp; |
// ts = tp; |
928 |
// cs = cp; |
// cs = cp; |
929 |
// os = op; |
// os = op; |
930 |
// cout << "Warning - track image ambiguity not solved" << endl; |
cout << "Warning - track image ambiguity not solved" << endl; |
931 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
932 |
}; |
}; |
933 |
|
|
934 |
}else{ |
}else{ |
935 |
// ts = tp; |
// ts = tp; |
936 |
// cs = cp; |
// cs = cp; |
937 |
// os = op; |
// os = op; |
938 |
}; |
}; |
939 |
|
|
940 |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
941 |
// sorted_tracks->Add(ts);//save the track in the sorted array |
// sorted_tracks->Add(ts);//save the track in the sorted array |
942 |
// sorted_tracks.Add(ts);//save the track in the sorted array |
// sorted_tracks.Add(ts);//save the track in the sorted array |
943 |
// sorted_tracks.Add(tp);//save the track in the sorted array |
// sorted_tracks.Add(tp);//save the track in the sorted array |
944 |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
945 |
// cout<<"o "<<tp<<endl; |
// cout<<"o "<<tp<<endl; |
946 |
// cout<<"o "<<cp<<endl; |
// cout<<"o "<<cp<<endl; |
947 |
// cout<<"o "<<op<<endl; |
// cout<<"o "<<op<<endl; |
948 |
new(ttsorted[i]) PamTrack(tp,cp,op); |
new(ttsorted[i]) PamTrack(tp,cp,op); |
949 |
new(ttimage[i]) PamTrack(ti,ci,oi); |
new(ttimage[i]) PamTrack(ti,ci,oi); |
950 |
}; |
}; |
951 |
|
|
952 |
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ |
953 |
cout << "void PamLevel2::SortTracks(TString how): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
cout << "void PamLevel2::SortTracks(): tsorted->GetEntries() "<<tsorted->GetEntries()<<" != trk2_obj->GetNTracks() = "<<trk2_obj->GetNTracks() <<endl; |
954 |
tsorted->Delete(); tsorted=0; |
tsorted->Delete(); tsorted=0; |
955 |
timage->Delete(); timage=0; |
timage->Delete(); timage=0; |
956 |
} |
} |
957 |
|
|
958 |
//Restore Object count |
//Restore Object count |
959 |
//To save space in the table keeping track of all referenced objects |
//To save space in the table keeping track of all referenced objects |
960 |
//We reset the object count to what it was at the beginning of the event. |
//We reset the object count to what it was at the beginning of the event. |
961 |
TProcessID::SetObjectCount(ObjectNumber); |
TProcessID::SetObjectCount(ObjectNumber); |
962 |
|
|
963 |
}; |
}; |
964 |
//-------------------------------------- |
//-------------------------------------- |
982 |
TClonesArray *PamLevel2::GetTracks(){ |
TClonesArray *PamLevel2::GetTracks(){ |
983 |
|
|
984 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
985 |
SortTracks("+CAL+TOF"); |
SortTracks(); |
986 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
987 |
|
|
988 |
return tsorted; |
return tsorted; |
1001 |
|
|
1002 |
// if(!trk2_obj) return 0; |
// if(!trk2_obj) return 0; |
1003 |
|
|
1004 |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
// // *-*-*-*+-*-*-*-*-*-*-*-*-* |
1005 |
// SortTracks("+CAL+TOF"); |
// SortTracks("+CAL+TOF"); |
1006 |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
1007 |
// // if(!sorted_tracks)return 0; |
// // if(!sorted_tracks)return 0; |
1020 |
|
|
1021 |
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
1022 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1023 |
SortTracks("+CAL+TOF"); |
SortTracks(); |
1024 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1025 |
if(!tsorted)return 0; |
if(!tsorted)return 0; |
1026 |
if(!tsorted->GetEntries())return 0; |
if(!tsorted->GetEntries())return 0; |
1077 |
|
|
1078 |
|
|
1079 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1080 |
SortTracks("+CAL+TOF"); |
SortTracks(); |
1081 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
1082 |
if(!timage)return 0; |
if(!timage)return 0; |
1083 |
if(!timage->GetEntries())return 0; |
if(!timage->GetEntries())return 0; |
1114 |
|
|
1115 |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
1116 |
// else GetWhichTrees(f); |
// else GetWhichTrees(f); |
1117 |
|
if ( pam_tree ){ |
1118 |
|
printf("WARNING: TTree *PamLevel2::GetPamTree(TFile *fl, TString detlist) -- pam_tree already exists!\n "); |
1119 |
|
return pam_tree; |
1120 |
|
}; |
1121 |
|
// |
1122 |
|
|
1123 |
|
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
1124 |
|
|
1125 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
1126 |
|
|
1127 |
TTree *Trout =0; |
TTree *Trout =0; |
1129 |
TString fname = f->GetName(); |
TString fname = f->GetName(); |
1130 |
if(!CheckLevel2File(fname))return NULL; |
if(!CheckLevel2File(fname))return NULL; |
1131 |
|
|
1132 |
UInt_t *found=0; |
// UInt_t *found=0; |
1133 |
|
|
1134 |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
1135 |
if(TRK1)cout<<"TRK1 "; |
if(TRK1)cout<<"TRK1 "; |
1144 |
if(S4)cout<<"S4 "; |
if(S4)cout<<"S4 "; |
1145 |
if(ORB)cout<<"ORB "; |
if(ORB)cout<<"ORB "; |
1146 |
cout << endl; |
cout << endl; |
1147 |
|
if(SELLI)cout<<">>> Found selection-list <<<"<<endl; |
1148 |
|
|
1149 |
f->cd(); |
f->cd(); |
1150 |
|
|
1152 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
1153 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
1154 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1155 |
else T->SetBranchStatus("TrkLevel2",0,found); |
// else T->SetBranchStatus("TrkLevel2",0,found); |
1156 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1157 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1158 |
else T->SetBranchStatus("TrkLevel1",0,found); |
// else T->SetBranchStatus("TrkLevel1",0,found); |
1159 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1160 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1161 |
else T->SetBranchStatus("TrkHough",0,found); |
// else T->SetBranchStatus("TrkHough",0,found); |
1162 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1163 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
1164 |
else Trout->AddFriend(T); |
else Trout->AddFriend(T); |
1169 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
TTree *C = (TTree*)f->Get("Calorimeter"); |
1170 |
if(C && (CAL2||CAL1)) { |
if(C && (CAL2||CAL1)) { |
1171 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1172 |
else C->SetBranchStatus("CaloLevel2",0,found); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1173 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1174 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1175 |
else C->SetBranchStatus("CaloLevel1",0,found); |
// else C->SetBranchStatus("CaloLevel1",0,found); |
1176 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1177 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
1178 |
else Trout->AddFriend(C); |
else Trout->AddFriend(C); |
1195 |
if(R && TRG) { |
if(R && TRG) { |
1196 |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); |
1197 |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
cout << "Trigger : set branch address TrigLevel2"<<endl; |
1198 |
if(!Trout)Trout=O; |
if(!Trout)Trout=R; |
1199 |
else Trout->AddFriend(R); |
else Trout->AddFriend(R); |
1200 |
}else{ |
}else{ |
1201 |
cout << "Trigger : missing tree"<<endl; |
cout << "Trigger : missing tree"<<endl; |
1205 |
if(S && S4) { |
if(S && S4) { |
1206 |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); |
1207 |
cout << "S4 : set branch address S4Level2"<<endl; |
cout << "S4 : set branch address S4Level2"<<endl; |
1208 |
if(!Trout)Trout=O; |
if(!Trout)Trout=S; |
1209 |
else Trout->AddFriend(S); |
else Trout->AddFriend(S); |
1210 |
}else{ |
}else{ |
1211 |
cout << "S4 : missing tree"<<endl; |
cout << "S4 : missing tree"<<endl; |
1215 |
if(N && ND) { |
if(N && ND) { |
1216 |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); |
1217 |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
cout << "NeutronD : set branch address NDLevel2"<<endl; |
1218 |
if(!Trout)Trout=O; |
if(!Trout)Trout=N; |
1219 |
else Trout->AddFriend(N); |
else Trout->AddFriend(N); |
1220 |
}else{ |
}else{ |
1221 |
cout << "NeutronD : missing tree"<<endl; |
cout << "NeutronD : missing tree"<<endl; |
1225 |
if(A && AC) { |
if(A && AC) { |
1226 |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); |
1227 |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
cout << "Anticounter : set branch address AcLevel2"<<endl; |
1228 |
if(!Trout)Trout=O; |
if(!Trout)Trout=A; |
1229 |
else Trout->AddFriend(A); |
else Trout->AddFriend(A); |
1230 |
}else{ |
}else{ |
1231 |
cout << "Anticounter : missing tree"<<endl; |
cout << "Anticounter : missing tree"<<endl; |
1235 |
if(B && ORB) { |
if(B && ORB) { |
1236 |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1237 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1238 |
if(!Trout)Trout=O; |
if(!Trout)Trout=B; |
1239 |
else Trout->AddFriend(B); |
else Trout->AddFriend(B); |
1240 |
}else{ |
}else{ |
1241 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
1242 |
}; |
}; |
1243 |
|
|
1244 |
|
TTree *L = (TTree*)f->Get("SelectionList"); |
1245 |
|
if(L && SELLI==1) { |
1246 |
|
// L->SetBranchAddress("RunEntry",&irun); |
1247 |
|
// cout << "SelectionList: set branch address RunEntry"<<endl; |
1248 |
|
// L->SetBranchAddress("EventEntry",&irunentry); |
1249 |
|
// cout << "SelectionList: set branch address EventEntry"<<endl; |
1250 |
|
// if(!Trout)Trout=O; |
1251 |
|
// else Trout->AddFriend("SelectionList"); |
1252 |
|
cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemente!!!!"<<endl; |
1253 |
|
sel_tree = 0; |
1254 |
|
}else{ |
1255 |
|
cout << "SelectionList : missing tree"<<endl; |
1256 |
|
}; |
1257 |
|
|
1258 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1259 |
|
|
1260 |
|
pam_tree = (TChain*)Trout; |
1261 |
|
|
1262 |
return Trout; |
return Trout; |
1263 |
|
|
1277 |
|
|
1278 |
TString wdir = gSystem->WorkingDirectory(); |
TString wdir = gSystem->WorkingDirectory(); |
1279 |
|
|
1280 |
if(ddir=="")ddir = wdir; |
// if(ddir=="")ddir = wdir; |
1281 |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
1282 |
cout << "Level2 data directory : "<< ddir << endl; |
if ( ddir != ""){ |
1283 |
|
cout << "Level2 data directory : "<< ddir << endl; |
1284 |
|
} else { |
1285 |
|
cout << "Level2 data directory not given as input: trying to evaluate from list or taking working directory " << endl; |
1286 |
|
}; |
1287 |
TList *contents = new TList; // create output list |
TList *contents = new TList; // create output list |
1288 |
contents->SetOwner(); |
contents->SetOwner(); |
1289 |
|
|
1299 |
// return 0; |
// return 0; |
1300 |
// } |
// } |
1301 |
// flisttxt = fullpath; |
// flisttxt = fullpath; |
1302 |
|
if ( !flisttxt.EndsWith(".root") ){ |
1303 |
|
|
1304 |
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1305 |
|
|
1331 |
// cout <<"(2) " << file << endl; |
// cout <<"(2) " << file << endl; |
1332 |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
1333 |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
1334 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); |
if( file.EndsWith(".root") ){ |
1335 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
TString filedir; |
1336 |
delete fullpath; |
if (ddir != ""){ |
1337 |
|
filedir = ddir; // take the input dir |
1338 |
|
} else { |
1339 |
|
gSystem->ChangeDirectory(wdir); // back to the working directory |
1340 |
|
filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir |
1341 |
|
}; |
1342 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file)); |
1343 |
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1344 |
|
delete fullpath; |
1345 |
|
} |
1346 |
// }else{ |
// }else{ |
1347 |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
1348 |
// }; |
// }; |
1349 |
}; |
}; |
1350 |
in.close(); |
in.close(); |
1351 |
|
} else { |
1352 |
|
if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); |
1353 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1354 |
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1355 |
|
delete fullpath; |
1356 |
|
}; |
1357 |
}else{ |
}else{ |
1358 |
|
|
1359 |
cout << "No input file list given."<<endl; |
cout << "No input file list given."<<endl; |
1360 |
cout << "Check for existing root files."<<endl; |
cout << "Check for existing root files."<<endl; |
1361 |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl; |
1362 |
|
if ( ddir == "" ){ |
1363 |
|
ddir = wdir; |
1364 |
|
cout << "Level2 data directory : "<< ddir << endl; |
1365 |
|
}; |
1366 |
|
|
1367 |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
1368 |
TList *temp = datadir->GetListOfFiles(); |
TList *temp = datadir->GetListOfFiles(); |
1369 |
// temp->Print(); |
// temp->Print(); |
1407 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
1408 |
*/ |
*/ |
1409 |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ |
1410 |
|
// |
1411 |
|
// |
1412 |
|
// |
1413 |
|
if ( pam_tree ){ |
1414 |
|
printf("WARNING: TChain *PamLevel2::GetPamTree(TList *fl, TString detlist) -- pam_tree already exists!\n "); |
1415 |
|
return pam_tree; |
1416 |
|
}; |
1417 |
|
// |
1418 |
|
|
1419 |
TChain *Trout =0; |
TChain *Trout =0; |
1420 |
|
|
1435 |
if(ORB)cout<<"ORB "; |
if(ORB)cout<<"ORB "; |
1436 |
cout << endl; |
cout << endl; |
1437 |
|
|
1438 |
TChain *T = 0; |
TChain *T = 0; |
1439 |
TChain *C = 0; |
TChain *C = 0; |
1440 |
TChain *O = 0; |
TChain *O = 0; |
1441 |
TChain *R = 0; |
TChain *R = 0; |
1442 |
TChain *S = 0; |
TChain *S = 0; |
1443 |
TChain *N = 0; |
TChain *N = 0; |
1444 |
TChain *A = 0; |
TChain *A = 0; |
1445 |
TChain *B = 0; |
TChain *B = 0; |
1446 |
|
|
1447 |
|
TChain *L = 0; |
1448 |
|
|
1449 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
1450 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
1454 |
if(ND) N = new TChain("NeutronD"); |
if(ND) N = new TChain("NeutronD"); |
1455 |
if(AC) A = new TChain("Anticounter"); |
if(AC) A = new TChain("Anticounter"); |
1456 |
if(ORB) B = new TChain("OrbitalInfo"); |
if(ORB) B = new TChain("OrbitalInfo"); |
1457 |
|
L = new TChain("SelectionList"); |
1458 |
|
|
1459 |
// loop over files and create chains |
// loop over files and create chains |
1460 |
TIter next(fl); |
TIter next(fl); |
1471 |
if(ND) N->Add(name); |
if(ND) N->Add(name); |
1472 |
if(AC) A->Add(name); |
if(AC) A->Add(name); |
1473 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
1474 |
|
if(SELLI==1) L->Add(name); |
1475 |
}; |
}; |
1476 |
} |
}; |
1477 |
|
|
1478 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1479 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1480 |
|
|
1481 |
UInt_t *found=0; |
// UInt_t *found=0; |
1482 |
// Tracker |
// Tracker |
1483 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
1484 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1485 |
else T->SetBranchStatus("TrkLevel2",0,found); |
// else T->SetBranchStatus("TrkLevel2",0,found); |
1486 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1487 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1488 |
else T->SetBranchStatus("TrkLevel1",0,found); |
// else T->SetBranchStatus("TrkLevel1",0,found); |
1489 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1490 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1491 |
else T->SetBranchStatus("TrkHough",0,found); |
// else T->SetBranchStatus("TrkHough",0,found); |
1492 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1493 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
1494 |
else Trout->AddFriend("Tracker"); |
else Trout->AddFriend("Tracker"); |
1495 |
}else{ |
}else{ |
1496 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
1497 |
}; |
}; |
1498 |
// Calorimeter |
// Calorimeter |
1499 |
if(C && (CAL2||CAL1)) { |
if(C && (CAL2||CAL1)) { |
1500 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1501 |
else C->SetBranchStatus("CaloLevel2",0,found); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1502 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1503 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1504 |
else C->SetBranchStatus("CaloLevel1",0,found); |
// else C->SetBranchStatus("CaloLevel1",0,found); |
1505 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1506 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
1507 |
else Trout->AddFriend("Calorimeter"); |
else Trout->AddFriend("Calorimeter"); |
1562 |
}else{ |
}else{ |
1563 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
1564 |
}; |
}; |
1565 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1566 |
|
|
1567 |
|
// Selection List |
1568 |
|
if(L && SELLI==1) { |
1569 |
|
cout<<">>> Found selection-list <<<"<<endl; |
1570 |
|
L->SetBranchAddress("RunEntry",&irun); |
1571 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1572 |
|
L->SetBranchAddress("EventEntry",&irunentry); |
1573 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1574 |
|
sel_tree = L; |
1575 |
|
// if(!Trout)Trout=O; |
1576 |
|
// else Trout->AddFriend("SelectionList"); |
1577 |
|
cout << "----------------------------------------------------" <<endl; |
1578 |
|
}else{ |
1579 |
|
// cout << "SelectionList : missing tree"<<endl; |
1580 |
|
if(L)L->Delete(); |
1581 |
|
}; |
1582 |
|
|
1583 |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1584 |
|
|
1585 |
|
pam_tree = Trout; |
1586 |
// // Tracker |
|
|
// if(TRK2||TRK1||TRKh){ |
|
|
// if(!Tout)Tout=T; |
|
|
// else Tout->AddFriend("Tracker"); |
|
|
// } |
|
|
// // Calorimeter |
|
|
// if(CAL2||CAL1) { |
|
|
// if(!Tout)Tout=C; |
|
|
// else Tout->AddFriend("Calorimeter"); |
|
|
// }; |
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// if(!Tout)Tout=O; |
|
|
// else Tout->AddFriend("ToF"); |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// if(!Tout)Tout=R; |
|
|
// else Tout->AddFriend("Trigger"); |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// if(!Tout)Tout=S; |
|
|
// else Tout->AddFriend("S4"); |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// if(!Tout)Tout=N; |
|
|
// else Tout->AddFriend("NeutronD"); |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// if(!Tout)Tout=A; |
|
|
// else Tout->AddFriend("Anticounter"); |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// if(!Tout)Tout=B; |
|
|
// else Tout->AddFriend("OrbitalInfo"); |
|
|
// }; |
|
|
|
|
|
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
|
|
|
|
|
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
|
|
|
|
1587 |
return Trout; |
return Trout; |
1588 |
} |
} |
1589 |
|
|
1665 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1666 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1667 |
}; |
}; |
1668 |
|
// SelectionList |
1669 |
|
if(SELLI==1) { |
1670 |
|
t->SetBranchAddress("RunEntry", &irun); |
1671 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1672 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1673 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1674 |
|
}; |
1675 |
|
|
1676 |
} |
} |
1677 |
/** |
/** |
1745 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1746 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1747 |
}; |
}; |
1748 |
|
// SelectionList |
1749 |
|
if(SELLI==1) { |
1750 |
|
t->SetBranchAddress("RunEntry", &irun); |
1751 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1752 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1753 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1754 |
|
}; |
1755 |
|
|
1756 |
} |
} |
1757 |
|
|
1766 |
* @return Pointer to a TChain |
* @return Pointer to a TChain |
1767 |
*/ |
*/ |
1768 |
TChain *PamLevel2::GetRunTree(TList *fl){ |
TChain *PamLevel2::GetRunTree(TList *fl){ |
1769 |
|
// |
1770 |
TChain *R = new TChain("Run"); |
// |
1771 |
|
// |
1772 |
|
if ( run_tree ){ |
1773 |
|
printf("WARNING: TChain *PamLevel2::GetRunTree(TList *fl) -- run_tree already exists!\n "); |
1774 |
|
return run_tree; |
1775 |
|
}; |
1776 |
|
// |
1777 |
|
TChain *R = new TChain("Run"); |
1778 |
|
|
1779 |
// loop over files and create chains |
// loop over files and create chains |
1780 |
TIter next(fl); |
TIter next(fl); |
1786 |
R->Add(name); |
R->Add(name); |
1787 |
}; |
}; |
1788 |
} |
} |
1789 |
|
|
1790 |
|
if(R->GetNtrees()){ |
1791 |
|
|
1792 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1793 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1794 |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1795 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1796 |
|
}else{ |
1797 |
|
delete R; |
1798 |
|
R=0; |
1799 |
|
} |
1800 |
|
|
1801 |
|
run_tree = R; |
1802 |
|
|
1803 |
return R; |
return R; |
1804 |
|
|
1805 |
} |
} |
1813 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
1814 |
*/ |
*/ |
1815 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
TTree *PamLevel2::GetRunTree(TFile *f){ |
1816 |
|
if ( run_tree ){ |
1817 |
|
printf("WARNING: TTree *PamLevel2::GetRunTree(TFile *f) -- run_tree already exists!\n "); |
1818 |
|
return run_tree; |
1819 |
|
}; |
1820 |
|
|
1821 |
|
|
1822 |
|
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
1823 |
|
|
1824 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *T = (TTree*)f->Get("Run"); |
1825 |
|
|
1826 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
if(T){ |
1827 |
cout << "Run : set branch address RunInfo"<<endl; |
T->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1828 |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
cout << "Run : set branch address RunInfo"<<endl; |
1829 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1830 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1831 |
return R; |
} |
1832 |
|
|
1833 |
|
run_tree = (TChain*)T; |
1834 |
|
|
1835 |
|
return T; |
1836 |
|
|
1837 |
} |
} |
1838 |
/** |
/** |
1840 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
1841 |
* @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 |
1842 |
*/ |
*/ |
1843 |
Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){ |
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev){ |
1844 |
// |
// |
1845 |
// check if we have already called once GetEntry, if not call it |
// check if we have already called once GetEntry, if not call it |
1846 |
// |
// |
1847 |
if ( run->GetEntries() <= 0 ) return(false); |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- NON FUNZIONA BENISSIMO.... "<<endl; |
1848 |
|
if(!run){ |
1849 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
1850 |
|
return(false); |
1851 |
|
} |
1852 |
|
if ( run->GetEntries() <= 0 ) return(false); |
1853 |
// |
// |
1854 |
Int_t oldrun = irun; |
|
1855 |
if ( irun < 0 ){ |
// Int_t oldrun = irun; |
1856 |
irun = 0; |
Long64_t oldrun = irun; |
1857 |
run->GetEntry(0); |
|
1858 |
runfirstentry = 0ULL; |
// -------------------------------------- |
1859 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; |
// if it is a full file (not preselected) |
1860 |
}; |
// -------------------------------------- |
1861 |
while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
if(SELLI==0){ |
1862 |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
|
1863 |
irun++; |
// |
1864 |
run->GetEntry(irun); |
// the absolute time is necessary to relate the event with the run |
1865 |
runfirstentry = runlastentry+1ULL; |
// |
1866 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
if( !GetOrbitalInfo() ){ |
1867 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1868 |
|
return(false); |
1869 |
|
} |
1870 |
|
|
1871 |
|
// |
1872 |
|
// the first time the routine is called, set run search from the beginning |
1873 |
|
// |
1874 |
|
if ( irun < 0LL ){ |
1875 |
|
irun = 0LL; |
1876 |
|
run->GetEntry(irun); |
1877 |
|
runfirstentry = 0LL; |
1878 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1879 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
1880 |
|
}; |
1881 |
|
// |
1882 |
|
if ( irun == run->GetEntries()-1LL && |
1883 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
1884 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
1885 |
|
){ |
1886 |
|
irun = -1LL; |
1887 |
|
runfirstentry = 0LL; |
1888 |
|
runlastentry = -1LL; |
1889 |
|
}; |
1890 |
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
1891 |
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
1892 |
|
// |
1893 |
|
bool fromfirst = true; |
1894 |
|
// |
1895 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
1896 |
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
1897 |
|
irun++; |
1898 |
|
run->GetEntry(irun); |
1899 |
|
runfirstentry = runlastentry; |
1900 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; |
1901 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1902 |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1903 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
1904 |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
1905 |
|
// printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); |
1906 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
1907 |
|
// |
1908 |
|
// prevshift = 0; |
1909 |
|
// |
1910 |
|
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ |
1911 |
|
printf(" resetting irun (it should NOT happen!!!)\n"); |
1912 |
|
fromfirst = false; |
1913 |
|
irun = 0; |
1914 |
|
run->GetEntry(irun); |
1915 |
|
runfirstentry = 0ULL; |
1916 |
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1917 |
|
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
1918 |
|
}; |
1919 |
|
// |
1920 |
|
}; |
1921 |
|
// |
1922 |
|
if ( |
1923 |
|
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
1924 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
1925 |
|
) { |
1926 |
|
printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); |
1927 |
|
return false; |
1928 |
|
} |
1929 |
|
// |
1930 |
|
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
1931 |
|
// |
1932 |
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
1933 |
|
// |
1934 |
|
prevshift = 0; |
1935 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1936 |
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
1937 |
|
return(true); |
1938 |
}; |
}; |
1939 |
|
// ---------------------------------------------------- |
1940 |
|
// if it is a preselected file (there is SelectionList) |
1941 |
|
// NBNB - the event tree MUST be read first |
1942 |
|
// ---------------------------------------------------- |
1943 |
|
if(SELLI==1){ |
1944 |
|
sel_tree->GetEntry(iev); |
1945 |
|
// cout << irun << " "<< irunentry << endl; |
1946 |
|
if(irun != oldrun){ |
1947 |
|
run->GetEntry(irun); |
1948 |
|
cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1949 |
|
prevshift = 0; |
1950 |
|
return true; |
1951 |
|
} |
1952 |
|
return false; |
1953 |
|
} |
1954 |
|
|
1955 |
|
return false; |
1956 |
// |
// |
1957 |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
}; |
1958 |
// |
|
1959 |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev){ |
1960 |
// |
|
1961 |
return(true); |
if(!run_tree){ |
1962 |
// |
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
1963 |
|
return false; |
1964 |
|
} |
1965 |
|
if ( run_tree->GetEntries() <= 0 ) { |
1966 |
|
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
1967 |
|
return(false); |
1968 |
|
} |
1969 |
|
|
1970 |
|
Int_t oldrun = irun; // store current run index |
1971 |
|
|
1972 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1973 |
|
// if it is a full file (not preselected) |
1974 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1975 |
|
if(SELLI==0){ |
1976 |
|
|
1977 |
|
// --------------------------------------------------------------- |
1978 |
|
// the absolute time is necessary to relate the event with the run |
1979 |
|
// --------------------------------------------------------------- |
1980 |
|
if( !GetOrbitalInfo() ){ |
1981 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1982 |
|
return(false); |
1983 |
|
} |
1984 |
|
|
1985 |
|
// ----------------------------------------------------------------------- |
1986 |
|
// the first time the routine is called, set run search from the beginning |
1987 |
|
// ----------------------------------------------------------------------- |
1988 |
|
if ( irun < 0 ){ |
1989 |
|
irun = 0LL; |
1990 |
|
run_tree->GetEntry(irun); |
1991 |
|
}; |
1992 |
|
// |
1993 |
|
bool fromfirst = true; // first loop over runs |
1994 |
|
// ------------------------------------------------------ |
1995 |
|
// loop over runs to find the one that contains the event |
1996 |
|
// ------------------------------------------------------ |
1997 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
1998 |
|
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && |
1999 |
|
!(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
2000 |
|
GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) && |
2001 |
|
irun < run_tree->GetEntries() ){ |
2002 |
|
irun++; |
2003 |
|
// ------------------------------------ |
2004 |
|
// if the end of run tree is reached... |
2005 |
|
// ------------------------------------ |
2006 |
|
if( irun == run_tree->GetEntries() ){ |
2007 |
|
if(!fromfirst){ |
2008 |
|
// ----------------------------------------------------- |
2009 |
|
// if it happened already once and the run was not found |
2010 |
|
// ---> exit with error |
2011 |
|
// ----------------------------------------------------- |
2012 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
2013 |
|
return false; |
2014 |
|
} |
2015 |
|
// ----------------------------------------- |
2016 |
|
// ...otherwise repeat search from beginning |
2017 |
|
// ----------------------------------------- |
2018 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- reached end of run tree. searchin again from beginning " <<endl; |
2019 |
|
fromfirst = false; |
2020 |
|
irun = 0LL; |
2021 |
|
runfirstentry = 0LL; |
2022 |
|
} |
2023 |
|
// ------------------------------------------------------------------- |
2024 |
|
// save the index of the first entry of the run, relative to pam_tree, |
2025 |
|
// and read a new run |
2026 |
|
// ------------------------------------------------------------------- |
2027 |
|
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS); |
2028 |
|
run_tree->GetEntry(irun); |
2029 |
|
if(GetRunInfo()->RUNHEADER_OBT>=GetRunInfo()->RUNTRAILER_OBT ){ |
2030 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
2031 |
|
cout << " (NB!! in this case some events are assigned to a wrong run)"<<endl; |
2032 |
|
} |
2033 |
|
}; |
2034 |
|
// -------------------------------------- |
2035 |
|
// if there was no need to update the run |
2036 |
|
// ---> exit with FALSE |
2037 |
|
// -------------------------------------- |
2038 |
|
if ( irun == oldrun ) return(false); |
2039 |
|
|
2040 |
|
// -------------------------------------- |
2041 |
|
// ... otherwise |
2042 |
|
// ---> exit with TRUE |
2043 |
|
// -------------------------------------- |
2044 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2045 |
|
prevshift = 0; |
2046 |
|
return(true); |
2047 |
|
}; |
2048 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2049 |
|
// if it is a preselected file (there is SelectionList) |
2050 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
2051 |
|
if(SELLI==1){ |
2052 |
|
sel_tree->GetEntry(iev); |
2053 |
|
if(irun != oldrun){ |
2054 |
|
run_tree->GetEntry(irun); |
2055 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
2056 |
|
prevshift = 0; |
2057 |
|
return true; |
2058 |
|
} |
2059 |
|
return false; |
2060 |
|
} |
2061 |
|
|
2062 |
|
return false; |
2063 |
|
// |
2064 |
}; |
}; |
2065 |
/** |
/** |
2066 |
* 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) |
2067 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
2068 |
* @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 |
2069 |
*/ |
*/ |
2070 |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev){ |
2071 |
return(UpdateRunInfo((TChain*)run,iev)); |
return(UpdateRunInfo((TChain*)run,iev)); |
2072 |
}; |
}; |
2073 |
|
|
2082 |
void PamLevel2::SetWhichTrees(TString detlist){ |
void PamLevel2::SetWhichTrees(TString detlist){ |
2083 |
|
|
2084 |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
2085 |
|
CAL0 = false; |
2086 |
CAL1 = true; |
CAL1 = true; |
2087 |
CAL2 = true; |
CAL2 = true; |
2088 |
TRK2 = true; |
TRK2 = true; |
2089 |
TRK1 = false; |
TRK1 = false; |
2090 |
TRKh = false; |
TRKh = false; |
2091 |
|
TRK0 = false; |
2092 |
TRG = true; |
TRG = true; |
2093 |
TOF = true; |
TOF = true; |
2094 |
|
TOF0 = false; |
2095 |
S4 = true; |
S4 = true; |
2096 |
ND = true; |
ND = true; |
2097 |
AC = true; |
AC = true; |
2098 |
ORB = true; |
ORB = true; |
2099 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
2100 |
|
CAL0 = false; |
2101 |
CAL1 = false; |
CAL1 = false; |
2102 |
CAL2 = false; |
CAL2 = false; |
2103 |
TRK2 = false; |
TRK2 = false; |
2104 |
TRK1 = false; |
TRK1 = false; |
2105 |
TRKh = false; |
TRKh = false; |
2106 |
|
TRK0 = false; |
2107 |
TRG = false; |
TRG = false; |
2108 |
TOF = false; |
TOF = false; |
2109 |
|
TOF0 = false; |
2110 |
S4 = false; |
S4 = false; |
2111 |
ND = false; |
ND = false; |
2112 |
AC = false; |
AC = false; |
2118 |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
2119 |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
2120 |
}; |
}; |
2121 |
|
|
2122 |
|
if( detlist.Contains("CAL0", TString::kIgnoreCase) ){ |
2123 |
|
if ( detlist.Contains("-CAL0", TString::kIgnoreCase) )CAL0=false; |
2124 |
|
if ( detlist.Contains("+CAL0", TString::kIgnoreCase) )CAL0=true; |
2125 |
|
}; |
2126 |
|
|
2127 |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
2128 |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
2135 |
CAL1=false; |
CAL1=false; |
2136 |
} |
} |
2137 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
2138 |
|
if( detlist.Contains("TRK0", TString::kIgnoreCase) ){ |
2139 |
|
if ( detlist.Contains("-TRK0", TString::kIgnoreCase) )TRK0=false; |
2140 |
|
if ( detlist.Contains("+TRK0", TString::kIgnoreCase) )TRK0=true; |
2141 |
|
}; |
2142 |
|
|
2143 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
2144 |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
2145 |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
2168 |
|
|
2169 |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
2170 |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
2171 |
|
|
2172 |
|
if( detlist.Contains("-TOF0", TString::kIgnoreCase) )TOF0 = false; |
2173 |
|
else if( detlist.Contains("+TOF0", TString::kIgnoreCase) )TOF0 = true; |
2174 |
|
|
2175 |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
2176 |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
2205 |
* Set tree/branch detector flags from the content of a tree |
* Set tree/branch detector flags from the content of a tree |
2206 |
*/ |
*/ |
2207 |
void PamLevel2::GetWhichTrees(TFile* f){ |
void PamLevel2::GetWhichTrees(TFile* f){ |
2208 |
|
|
2209 |
|
|
2210 |
|
|
2211 |
|
cout << "void PamLevel2::GetWhichTrees(TFile* f) --- WARNING!! --- ...potrebbe non funzionare "<<endl; |
2212 |
// ----------- |
// ----------- |
2213 |
// reset flags |
// reset flags |
2214 |
// ----------- |
// ----------- |
2380 |
|
|
2381 |
Bool_t RUN__ok = false; |
Bool_t RUN__ok = false; |
2382 |
|
|
2383 |
|
Bool_t SELLI__ok = false; |
2384 |
|
|
2385 |
cout << "Checking file: "<<name<<endl; |
cout << "Checking file: "<<name<<endl; |
2386 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
2397 |
|
|
2398 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
2399 |
|
|
2400 |
|
// cout << key->GetName() << endl; |
2401 |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
2402 |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
2403 |
// nev_previous = nev; |
// nev_previous = nev; |
2408 |
// return false; |
// return false; |
2409 |
// }; |
// }; |
2410 |
|
|
2411 |
|
|
2412 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
2413 |
|
|
2414 |
//========================================================= |
//========================================================= |
2415 |
|
if( !strcmp(key->GetName(),"SelectionList" ) ){ |
2416 |
|
SELLI__ok = true; |
2417 |
|
if(SELLI==1){ |
2418 |
|
Int_t nevt = ((TTree*)f->Get("SelectionList"))->GetEntries(); |
2419 |
|
if( nev && nevt!=nev){ |
2420 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList tree has "<<nevt<<" events instead of "<<nev<< endl; |
2421 |
|
return false; |
2422 |
|
} |
2423 |
|
nev=nevt; |
2424 |
|
} |
2425 |
|
} |
2426 |
|
|
2427 |
|
//========================================================= |
2428 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
2429 |
TRG__ok = true; |
TRG__ok = true; |
2430 |
if(TRG){ |
if(TRG){ |
2536 |
}; |
}; |
2537 |
|
|
2538 |
}; |
}; |
2539 |
|
|
2540 |
|
if( SELLI==-1 )SELLI = (Int_t)SELLI__ok; |
2541 |
|
if( SELLI==0 && SELLI__ok ){ |
2542 |
|
cout << "File: "<< f->GetName() <<" discarded ---- found SelectionList (it is not a full-event file)" << endl; |
2543 |
|
return false; |
2544 |
|
} |
2545 |
|
if( SELLI==1 && !SELLI__ok ){ |
2546 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList missing" << endl; |
2547 |
|
return false; |
2548 |
|
} |
2549 |
|
|
2550 |
|
// cout << "SELLI "<<SELLI<<endl; |
2551 |
|
|
2552 |
// cout<< "CheckLevel2File(TString): detector list --> "; |
// cout<< "CheckLevel2File(TString): detector list --> "; |
2553 |
// if(TRK1__ok)cout<<"TRK1 "; |
// if(TRK1__ok)cout<<"TRK1 "; |
2554 |
// if(TRK2__ok)cout<<"TRK2 "; |
// if(TRK2__ok)cout<<"TRK2 "; |
2657 |
cout << "Create clones of PAMELA trees "<<endl; |
cout << "Create clones of PAMELA trees "<<endl; |
2658 |
|
|
2659 |
Int_t i=0; |
Int_t i=0; |
2660 |
tree_clone[i] = fChain->GetTree()->CloneTree(0); |
pam_tree_clone[i] = fChain->GetTree()->CloneTree(0); |
2661 |
TString name = tree_clone[i]->GetName(); |
TString name = pam_tree_clone[i]->GetName(); |
2662 |
name.Append("_clone"); |
name.Append("_clone"); |
2663 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2664 |
cout << tree_clone[i]->GetName() <<endl; |
cout << pam_tree_clone[i]->GetName() <<endl; |
2665 |
i++; |
i++; |
2666 |
|
|
2667 |
TList *li = fChain->GetListOfFriends(); |
TList *li = fChain->GetListOfFriends(); |
2671 |
while( (T_friend = (TFriendElement*)next()) ){ |
while( (T_friend = (TFriendElement*)next()) ){ |
2672 |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
2673 |
// cout<<T_friend->GetTree()->GetName()<< endl; |
// cout<<T_friend->GetTree()->GetName()<< endl; |
2674 |
tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
pam_tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
2675 |
tree_clone[i]->SetAutoSave(1000000); |
pam_tree_clone[i]->SetAutoSave(1000000); |
2676 |
name = tree_clone[i]->GetName(); |
name = pam_tree_clone[i]->GetName(); |
2677 |
name.Append("_clone"); |
name.Append("_clone"); |
2678 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2679 |
cout << tree_clone[i]->GetName() << endl; |
cout << pam_tree_clone[i]->GetName() << endl; |
2680 |
i++; |
i++; |
2681 |
} |
} |
2682 |
|
|
2696 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2697 |
cout << "Create new PAMELA trees "<<endl; |
cout << "Create new PAMELA trees "<<endl; |
2698 |
|
|
|
Int_t i=0; |
|
2699 |
|
|
2700 |
|
run_tree_clone = new TTree("Run","PAMELA Level2 data from the GL_RUN table "); |
2701 |
|
run_tree_clone->Branch("RunInfo","GL_RUN",GetPointerTo("RunInfo")); |
2702 |
|
cout << "Run : branch RunInfo"<<endl; |
2703 |
|
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
2704 |
|
cout << "Run : branch SoftInfo"<<endl; |
2705 |
|
// ------------------ |
2706 |
|
// replicate run tree |
2707 |
|
// ------------------ |
2708 |
|
cout << "----------------------------------------------------"<<endl; |
2709 |
|
cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl; |
2710 |
|
for (Int_t i=0; i<run_tree->GetEntries(); i++){ |
2711 |
|
run_tree->GetEntry(i); |
2712 |
|
cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
2713 |
|
run_tree_clone->Fill(); |
2714 |
|
} |
2715 |
|
cout << "----------------------------------------------------"<<endl; |
2716 |
|
|
2717 |
|
|
2718 |
|
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
2719 |
|
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
2720 |
|
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); |
2721 |
|
|
2722 |
|
|
2723 |
|
Int_t i=0; |
2724 |
if(TRK1||TRK2||TRKh){ |
if(TRK1||TRK2||TRKh){ |
2725 |
tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
pam_tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
2726 |
if(TRK1) { |
if(TRK1) { |
2727 |
tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2728 |
tree_clone[i]->BranchRef(); |
pam_tree_clone[i]->BranchRef(); |
2729 |
cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Tracker : branch TrkLevel1"<<endl; |
2730 |
|
// cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2731 |
}; |
}; |
2732 |
if(TRK2) { |
if(TRK2) { |
2733 |
tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2734 |
cout << "Tracker : branch TrkLevel2"<<endl; |
cout << "Tracker : branch TrkLevel2"<<endl; |
2735 |
}; |
}; |
2736 |
if(TRKh) { |
if(TRKh) { |
2737 |
tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
pam_tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
2738 |
cout << "Tracker : branch TrkHough"<<endl; |
cout << "Tracker : branch TrkHough"<<endl; |
2739 |
}; |
}; |
2740 |
i++; |
i++; |
2742 |
|
|
2743 |
// Calorimeter |
// Calorimeter |
2744 |
if(CAL1||CAL2){ |
if(CAL1||CAL2){ |
2745 |
tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
pam_tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
2746 |
if(CAL1) { |
if(CAL1) { |
2747 |
tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
pam_tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
2748 |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
2749 |
}; |
}; |
2750 |
if(CAL2) { |
if(CAL2) { |
2751 |
tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
pam_tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
2752 |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
2753 |
}; |
}; |
2754 |
i++; |
i++; |
2756 |
|
|
2757 |
// ToF |
// ToF |
2758 |
if(TOF) { |
if(TOF) { |
2759 |
tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
pam_tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
2760 |
tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
pam_tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
2761 |
cout << "ToF : branch ToFLevel2"<<endl; |
cout << "ToF : branch ToFLevel2"<<endl; |
2762 |
i++; |
i++; |
2763 |
}; |
}; |
2764 |
// Trigger |
// Trigger |
2765 |
if(TRG) { |
if(TRG) { |
2766 |
tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
pam_tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
2767 |
tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
pam_tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
2768 |
cout << "Trigger : branch TrigLevel2"<<endl; |
cout << "Trigger : branch TrigLevel2"<<endl; |
2769 |
i++; |
i++; |
2770 |
}; |
}; |
2771 |
// S4 |
// S4 |
2772 |
if(S4) { |
if(S4) { |
2773 |
tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
pam_tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
2774 |
tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
pam_tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
2775 |
cout << "S4 : branch S4Level2"<<endl; |
cout << "S4 : branch S4Level2"<<endl; |
2776 |
i++; |
i++; |
2777 |
}; |
}; |
2778 |
// Neutron Detector |
// Neutron Detector |
2779 |
if(ND) { |
if(ND) { |
2780 |
tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
pam_tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
2781 |
tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
pam_tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
2782 |
cout << "NeutronD : branch NDLevel2"<<endl; |
cout << "NeutronD : branch NDLevel2"<<endl; |
2783 |
i++; |
i++; |
2784 |
}; |
}; |
2785 |
// Anticounters |
// Anticounters |
2786 |
if(AC) { |
if(AC) { |
2787 |
tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
pam_tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
2788 |
tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
pam_tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
2789 |
cout << "Anticounter : branch AcLevel2"<<endl; |
cout << "Anticounter : branch AcLevel2"<<endl; |
2790 |
i++; |
i++; |
2791 |
}; |
}; |
2792 |
// OrbitalInfo |
// OrbitalInfo |
2793 |
if(ORB) { |
if(ORB) { |
2794 |
tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
2795 |
tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
2796 |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
2797 |
i++; |
i++; |
2798 |
}; |
}; |
2807 |
*/ |
*/ |
2808 |
//void PamLevel2::FillNewPamTree(TTree *T){ |
//void PamLevel2::FillNewPamTree(TTree *T){ |
2809 |
void PamLevel2::FillCloneTrees(){ |
void PamLevel2::FillCloneTrees(){ |
2810 |
|
|
2811 |
for(Int_t i=0; i<8; i++){ |
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
2812 |
if(tree_clone[i])tree_clone[i]->Fill(); |
|
2813 |
|
for(Int_t i=0; i<NCLONES; i++){ |
2814 |
|
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
2815 |
} |
} |
2816 |
|
if(sel_tree_clone)sel_tree_clone->Fill(); |
2817 |
|
|
2818 |
} |
} |
2819 |
|
|
2820 |
|
|
2821 |
TTree* PamLevel2::GetCloneTree(TString name){ |
TTree* PamLevel2::GetCloneTree(TString name){ |
2822 |
|
|
2823 |
for(Int_t i=0; i<8; i++){ |
for(Int_t i=0; i<NCLONES; i++){ |
2824 |
if(tree_clone[i]){ |
if(pam_tree_clone[i]){ |
2825 |
TString na = tree_clone[i]->GetName(); |
TString na = pam_tree_clone[i]->GetName(); |
2826 |
if(!name.CompareTo(na))return tree_clone[i]; |
if(!name.CompareTo(na))return pam_tree_clone[i]; |
2827 |
}; |
}; |
2828 |
} |
} |
2829 |
|
if(run_tree_clone){ |
2830 |
|
TString na = run_tree_clone->GetName(); |
2831 |
|
if(!name.CompareTo(na))return run_tree_clone; |
2832 |
|
} |
2833 |
|
if(sel_tree_clone){ |
2834 |
|
TString na = sel_tree_clone->GetName(); |
2835 |
|
if(!name.CompareTo(na))return sel_tree_clone; |
2836 |
|
} |
2837 |
return NULL; |
return NULL; |
2838 |
|
|
2839 |
} |
} |
2840 |
void PamLevel2::WriteCloneTrees(){ |
void PamLevel2::WriteCloneTrees(){ |
2841 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2842 |
cout << "Write clones of PAMELA trees "<<endl; |
cout << "Write clones of PAMELA trees "<<endl; |
2843 |
for(Int_t i=0; i<8; i++){ |
cout << run_tree_clone->GetName()<<endl; |
2844 |
if(tree_clone[i]){ |
run_tree_clone->Write(); |
2845 |
cout << tree_clone[i]->GetName()<<endl; |
cout << sel_tree_clone->GetName()<<endl; |
2846 |
tree_clone[i]->Write(); |
sel_tree_clone->Write(); |
2847 |
|
for(Int_t i=0; i<NCLONES; i++){ |
2848 |
|
if(pam_tree_clone[i]){ |
2849 |
|
cout << pam_tree_clone[i]->GetName()<<endl; |
2850 |
|
pam_tree_clone[i]->Write(); |
2851 |
}; |
}; |
2852 |
} |
} |
2853 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2855 |
} |
} |
2856 |
|
|
2857 |
/** |
/** |
2858 |
* Create a new (empty) Pamela trees |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
2859 |
*/ |
*/ |
2860 |
// TTree* PamLevel2::GetNewPamTree(){ |
//Int_t PamLevel2::GetEntry(Int_t iee){ |
2861 |
|
Int_t PamLevel2::GetEntry(Long64_t iee){ |
2862 |
|
|
2863 |
|
if(!pam_tree){ |
2864 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
2865 |
|
return 0; |
2866 |
|
} |
2867 |
|
|
|
// if(tree_clone)return tree_clone; |
|
2868 |
|
|
2869 |
// TTree *Tout = 0; |
// |
2870 |
|
// 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... |
2871 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
// |
2872 |
// cout << "Create new PAMELA trees "<<endl; |
// if(!run_tree ){ |
2873 |
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; |
2874 |
|
// return 0; |
2875 |
|
// } |
2876 |
|
|
2877 |
|
Long64_t ii=0; |
2878 |
|
//------------------------------- |
2879 |
|
ii = iee; |
2880 |
|
if( !pam_tree->GetEntry(ii) ){ |
2881 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl; |
2882 |
|
return 0; |
2883 |
|
} |
2884 |
|
// |
2885 |
|
// ... 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. |
2886 |
|
// 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 |
2887 |
|
// a problem if you don't check the return code of getentry. |
2888 |
|
// |
2889 |
|
if(!run_tree ){ |
2890 |
|
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
2891 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
2892 |
|
return 0; |
2893 |
|
} else { |
2894 |
|
return 1; //cosi` se non c'e` run esce qua... |
2895 |
|
} |
2896 |
|
} |
2897 |
|
|
2898 |
|
//------------------------------- |
2899 |
|
ii = iee; |
2900 |
|
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2901 |
|
// Bool_t UPDATED = UpdateRunInfo(ii); |
2902 |
|
UpdateRunInfo(ii); |
2903 |
|
if(SELLI==0)irunentry = iee-runfirstentry; |
2904 |
|
// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2905 |
|
|
2906 |
|
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2907 |
|
|
2908 |
|
// cout << " irunentry "<<irunentry << endl; |
2909 |
|
|
2910 |
|
if( TRK0 || CAL0 || TOF0 ){ |
2911 |
|
if( !GetYodaEntry( ) ){ |
2912 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
2913 |
|
return 0; |
2914 |
|
} |
2915 |
|
} |
2916 |
|
return 1; |
2917 |
|
|
2918 |
|
} |
2919 |
|
|
2920 |
|
/** |
2921 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
2922 |
|
* Given the run ID (...), if needed it query the DB and load the proper file. |
2923 |
|
* @return Pointer to the tree |
2924 |
|
*/ |
2925 |
|
|
2926 |
|
|
2927 |
|
TTree* PamLevel2::GetYodaTree( ){ |
2928 |
|
|
2929 |
|
// cout << "TTree* PamLevel2::GetYodaTree( )"<<endl; |
2930 |
|
//=================================== |
2931 |
|
// check if iroot has changed |
2932 |
|
//=================================== |
2933 |
|
if( irun<0 ){ |
2934 |
|
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = "<<irun<<endl; |
2935 |
|
// cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
2936 |
|
return NULL; |
2937 |
|
} |
2938 |
|
Int_t irootnew = run_obj->ID_ROOT_L0; |
2939 |
|
// cout << "iroot "<<iroot<<endl; |
2940 |
|
// cout << "irootnew "<<irootnew<<endl; |
2941 |
|
|
2942 |
|
//=================================== |
2943 |
|
// load the level0 file |
2944 |
|
// (if not already loaded) |
2945 |
|
//=================================== |
2946 |
|
if( iroot != irootnew || !l0_tree){ |
2947 |
|
iroot = irootnew; |
2948 |
|
//=================================== |
2949 |
|
// open the DB connection |
2950 |
|
// (if not already opened) |
2951 |
|
//=================================== |
2952 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2953 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2954 |
|
cout<<"Connecting to DB"<<endl; |
2955 |
|
cout<<"HOST "<<host<<endl; |
2956 |
|
cout<<"USER "<<user<<endl; |
2957 |
|
cout<<"PSW "<<psw<<endl; |
2958 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
2959 |
|
if( !dbc )return NULL; |
2960 |
|
if( !dbc->IsConnected() )return NULL; |
2961 |
|
// cout<<"...done"<<endl; |
2962 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2963 |
|
}else{ |
2964 |
|
// cout<<"DB already connected"<<endl; |
2965 |
|
} |
2966 |
|
GL_ROOT glroot = GL_ROOT(); |
2967 |
|
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
2968 |
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
2969 |
|
return NULL; |
2970 |
|
}; |
2971 |
|
TString filename = glroot.PATH + glroot.NAME; |
2972 |
|
if(l0_file){ |
2973 |
|
l0_file->Close(); |
2974 |
|
l0_file->Delete(); |
2975 |
|
} |
2976 |
|
cout << "Opening LEVEL0 file: "<< filename << endl; |
2977 |
|
FileStat_t t; |
2978 |
|
if( gSystem->GetPathInfo(filename.Data(),t) ){ |
2979 |
|
cout << " PamLevel2::GetYodaTree() -- ERROR opening file "<<endl; |
2980 |
|
return NULL; |
2981 |
|
} |
2982 |
|
l0_file = new TFile(filename); |
2983 |
|
if( !l0_file )return NULL; |
2984 |
|
l0_tree = (TTree*)l0_file->Get("Physics"); |
2985 |
|
if(!h0_obj)h0_obj = new EventHeader(); |
2986 |
|
l0_tree->SetBranchAddress("Header" ,&h0_obj); |
2987 |
|
prevshift = 0; |
2988 |
|
//--------------------------------------------------- |
2989 |
|
// TRACKER: |
2990 |
|
if(TRK0){ |
2991 |
|
if(!trk0_obj){ |
2992 |
|
trk0_obj = new TrkLevel0(); |
2993 |
|
trk0_obj->Set(); |
2994 |
|
}; |
2995 |
|
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
2996 |
|
} |
2997 |
|
//--------------------------------------------------- |
2998 |
|
// CALORIMETER: |
2999 |
|
if(CAL0){ |
3000 |
|
if(!calo0_obj){ |
3001 |
|
calo0_obj = new CaloLevel0(); |
3002 |
|
calo0_obj->Set(); |
3003 |
|
}; |
3004 |
|
l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); |
3005 |
|
// cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
3006 |
|
} |
3007 |
|
//--------------------------------------------------- |
3008 |
|
// TOF: |
3009 |
|
if(TOF0){ |
3010 |
|
cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl; |
3011 |
|
} |
3012 |
|
|
3013 |
|
}; |
3014 |
|
|
3015 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
3016 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
3017 |
|
} |
3018 |
|
|
3019 |
|
if ( TRK0 ){ |
3020 |
|
TrkParams::Load(6); |
3021 |
|
if( !TrkParams::IsLoaded(6) ){ |
3022 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
3023 |
|
}; |
3024 |
|
TrkParams::SetCalib(run_obj,dbc); |
3025 |
|
TrkParams::LoadCalib( ); |
3026 |
|
if( !TrkParams::CalibIsLoaded() ){ |
3027 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl; |
3028 |
|
}; |
3029 |
|
} |
3030 |
|
|
3031 |
|
// cout << l0_tree << endl; |
3032 |
|
|
3033 |
|
return l0_tree; |
3034 |
|
|
3035 |
|
} |
3036 |
|
|
3037 |
|
/** |
3038 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
3039 |
|
*/ |
3040 |
|
Int_t PamLevel2::GetYodaEntry(){ |
3041 |
|
|
3042 |
|
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
3043 |
|
if(!GetYodaTree())return 0; |
3044 |
|
|
3045 |
// if(TRK1||TRK2||TRKh){ |
// patch |
3046 |
// TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
if( irunentry < 0){ |
3047 |
// if(TRK1) { |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
3048 |
// trk1_clone = new TrkLevel1(); |
irunentry=0LL; |
3049 |
// T->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
} |
3050 |
// T->BranchRef(); |
// --------------------------------- |
3051 |
// cout << "Tracker : branch TrkLevel1"<<endl; |
// if file is NOT a preselected file |
3052 |
// }; |
// --------------------------------- |
3053 |
// if(TRK2) { |
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
3054 |
// trk2_clone = new TrkLevel2(); |
// cout << " irunentry "<<irunentry<<endl; |
3055 |
// T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
// cout << " EV_FROM "<<run_obj->EV_FROM<<endl; |
3056 |
// cout << "Tracker : branch TrkLevel2"<<endl; |
// cout << " quellagiusta = irunentry + EV_FROM "<< quellagiusta << endl; |
3057 |
// }; |
|
3058 |
// if(TRKh) { |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
3059 |
// trkh_clone = new TrkHough(); |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
3060 |
// T->Branch("TrkHough","TrkHough", &trkh_clone); |
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
3061 |
// cout << "Tracker : branch TrkHough"<<endl; |
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
3062 |
// }; |
|
3063 |
// if(!Tout)Tout=T; |
if( !GetOrbitalInfo() ){ |
3064 |
// else Tout->AddFriend("Tracker_clone"); |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
3065 |
// } |
return 0; |
3066 |
|
} |
3067 |
// // Calorimeter |
if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ |
3068 |
// if(CAL1||CAL2){ |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
3069 |
// TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
return 0; |
3070 |
// if(CAL1) { |
} |
|
// calo1_clone = new CaloLevel1(); |
|
|
// C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
|
|
// }; |
|
|
// if(CAL2) { |
|
|
// calo2_clone = new CaloLevel2(); |
|
|
// C->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
|
|
// }; |
|
|
// if(!Tout)Tout=C; |
|
|
// else Tout->AddFriend("Calorimeter_clone"); |
|
|
// } |
|
|
|
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data "); |
|
|
// tof_clone = new ToFLevel2(); |
|
|
// O->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
|
|
// cout << "ToF : branch ToFLevel2"<<endl; |
|
|
// if(!Tout)Tout=O; |
|
|
// else Tout->AddFriend("ToF_clone"); |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
|
|
// trig_clone = new TrigLevel2(); |
|
|
// R->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
|
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
|
|
// if(!Tout)Tout=R; |
|
|
// else Tout->AddFriend("Trigger_clone"); |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// TTree *S = new TTree("S4_clone","PAMELA S4 level2 data "); |
|
|
// s4_clone = new S4Level2(); |
|
|
// S->Branch("S4Level2","S4Level2", &s4_clone); |
|
|
// cout << "S4 : branch S4Level2"<<endl; |
|
|
// if(!Tout)Tout=S; |
|
|
// else Tout->AddFriend("S4_clone"); |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
|
|
// nd_clone = new NDLevel2(); |
|
|
// N->Branch("NDLevel2","NDLevel2", &nd_clone); |
|
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
|
|
// if(!Tout)Tout=N; |
|
|
// else Tout->AddFriend("NeutronD_clone"); |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
|
|
// ac_clone = new AcLevel2(); |
|
|
// A->Branch("AcLevel2","AcLevel2", &ac_clone); |
|
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
|
|
// if(!Tout)Tout=A; |
|
|
// else Tout->AddFriend("Anticounter_clone"); |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
|
|
// orb_clone = new OrbitalInfo(); |
|
|
// B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
|
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
|
|
// if(!Tout)Tout=B; |
|
|
// else Tout->AddFriend("OrbitalInfo_clone"); |
|
|
// }; |
|
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
|
3071 |
|
|
3072 |
// tree_clone = Tout; |
// --------------------------------------------------------------------- |
3073 |
// tree_clone->SetDirectory(0); |
// ATTENTION!!! |
3074 |
|
// If data are not pre-processed with cleaner, the level0 tree may contain |
3075 |
|
// spurious nested physics packets. |
3076 |
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
3077 |
|
// while level2 tree DOES NOT!! |
3078 |
|
// This means that "quellagiusta" in these cases is not correct. |
3079 |
|
// In order to retrieve the correct level0 event, I implemented a check |
3080 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
3081 |
|
// is shift forward until when the packets match. |
3082 |
|
// --------------------------------------------------------------------- |
3083 |
|
Int_t answer = 0; |
3084 |
|
Int_t shift =0; |
3085 |
|
// printf(" siamo qui %i %i \n",shift,prevshift); |
3086 |
|
Int_t maxshift = 100; |
3087 |
|
do{ |
3088 |
|
if(shift>0){ |
3089 |
|
cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
3090 |
|
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; |
3091 |
|
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
3092 |
|
} |
3093 |
|
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
3094 |
|
shift++; |
3095 |
|
if( !GetEventHeader() ){ |
3096 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
3097 |
|
return 0; |
3098 |
|
} |
3099 |
|
// cout << "PKTNUM "<<shift<<" == L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
3100 |
|
// cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
3101 |
|
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
3102 |
|
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
3103 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
3104 |
|
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
3105 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
3106 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
3107 |
|
// |
3108 |
|
if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ |
3109 |
|
prevshift = 0; |
3110 |
|
shift = -1; |
3111 |
|
}; |
3112 |
|
|
3113 |
// return Tout; |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
3114 |
// } |
|
3115 |
// /** |
if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() || shift == maxshift ) { |
3116 |
// * Fill a tree (created with GetNewPamTree) |
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
3117 |
// * |
return 0; |
3118 |
// */ |
} |
3119 |
// //void PamLevel2::FillNewPamTree(TTree *T){ |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
3120 |
// void PamLevel2::FillNewPamTree(){ |
// return GetYodaTree()->GetEntry(quellagiusta); |
3121 |
|
if ( shift > 1 ) prevshift += (shift-1); |
3122 |
|
|
3123 |
|
return answer; |
3124 |
|
|
3125 |
|
} |
3126 |
|
|
|
// if(trk1_clone) *trk1_clone = *trk1_obj; |
|
|
// if(trk2_clone){ |
|
|
// trk2_clone->Clear(); |
|
|
// trk2_obj->Copy(*trk2_clone); |
|
|
// // *trk2_clone = *trk2_obj; |
|
|
// } |
|
|
// if(trkh_clone) *trkh_clone = *trkh_obj; |
|
|
// if(calo1_clone){ |
|
|
// // *calo1_clone = *calo1_obj; |
|
|
// calo1_clone->Clear(); |
|
|
// calo1_obj->Copy(*calo1_clone); |
|
|
// } |
|
|
// if(calo2_clone){ |
|
|
// // *calo2_clone = *calo2_obj; |
|
|
// calo2_clone->Clear(); |
|
|
// calo2_obj->Copy(*calo2_clone); |
|
|
// } |
|
|
// if(tof_clone) *tof_clone = *tof_obj; |
|
|
// if(trig_clone) *trig_clone = *trig_obj; |
|
|
// if(s4_clone) *s4_clone = *s4_obj; |
|
|
// if(nd_clone) *nd_clone = *nd_obj; |
|
|
// if(ac_clone) *ac_clone = *ac_obj; |
|
|
// if(orb_clone) *orb_clone = *orb_obj; |
|
|
|
|
|
// TTree *T = tree_clone; |
|
|
|
|
|
// T->Fill(); //fill main tree |
|
|
// // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl; |
|
|
// TList *li = T->GetListOfFriends(); |
|
|
// TIter next(li); |
|
|
// TFriendElement* T_friend=0; |
|
|
// while( (T_friend = (TFriendElement*)next()) ){ |
|
|
// // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
|
|
// T_friend->GetTree()->Fill();//fill friends |
|
|
// } |
|
3127 |
|
|
|
// } |
|