/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Annotation of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (hide annotations) (download)
Fri Mar 16 20:27:55 2007 UTC (17 years, 8 months ago) by pam-fi
Branch: MAIN
Changes since 1.25: +36 -29 lines
tracker calibration association

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

  ViewVC Help
Powered by ViewVC 1.1.23