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

Diff of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.56 by pam-fi, Tue Nov 20 18:16:30 2007 UTC revision 1.70 by mocchiut, Wed Dec 10 11:56:35 2008 UTC
# Line 284  PamTrack::PamTrack(){ Line 284  PamTrack::PamTrack(){
284      trk_track  = 0;      trk_track  = 0;
285      calo_track = 0;      calo_track = 0;
286      tof_track  = 0;      tof_track  = 0;
287        orb_track  = 0;
288      candeleteobj = 0;      candeleteobj = 0;
289      pscore = 0;      pscore = 0;
290      iscore = 0;      iscore = 0;
# Line 295  PamTrack::PamTrack(){ Line 296  PamTrack::PamTrack(){
296  /**  /**
297   * Constructor   * Constructor
298   */   */
299  PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){  PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r){
300    
301      trk_track  = 0;      trk_track  = 0;
302      calo_track = 0;      calo_track = 0;
303      tof_track  = 0;      tof_track  = 0;
304        orb_track  = 0;
305  //     if(t)trk_track  = new TrkTrack(*t);  //     if(t)trk_track  = new TrkTrack(*t);
306  //     if(c)calo_track = new CaloTrkVar(*c);  //     if(c)calo_track = new CaloTrkVar(*c);
307  //     if(o)tof_track  = new ToFTrkVar(*o);  //     if(o)tof_track  = new ToFTrkVar(*o);
308      if(t)trk_track  = t;      if(t)trk_track  = t;
309      if(c)calo_track = c;      if(c)calo_track = c;
310      if(o)tof_track  = o;      if(o)tof_track  = o;
311        if(r)orb_track  = r;
312      candeleteobj = 0;      candeleteobj = 0;
313    
314  };  };
# Line 314  PamTrack::PamTrack(const PamTrack& track Line 317  PamTrack::PamTrack(const PamTrack& track
317      TrkTrack   *t = track.trk_track;      TrkTrack   *t = track.trk_track;
318      CaloTrkVar *c = track.calo_track;      CaloTrkVar *c = track.calo_track;
319      ToFTrkVar  *o = track.tof_track;      ToFTrkVar  *o = track.tof_track;
320        OrbitalInfoTrkVar  *r = track.orb_track;
321    
322      trk_track  = 0;      trk_track  = 0;
323      calo_track = 0;      calo_track = 0;
324      tof_track  = 0;      tof_track  = 0;
325        orb_track  = 0;
326      if(t)trk_track  = new TrkTrack(*t);      if(t)trk_track  = new TrkTrack(*t);
327      if(c)calo_track = new CaloTrkVar(*c);      if(c)calo_track = new CaloTrkVar(*c);
328      if(o)tof_track  = new ToFTrkVar(*o);      if(o)tof_track  = new ToFTrkVar(*o);
329        if(r)orb_track  = new OrbitalInfoTrkVar(*r);
330      candeleteobj = 1;      candeleteobj = 1;
331            
332  }  }
# Line 331  void PamTrack::Clear(){ Line 337  void PamTrack::Clear(){
337          if(trk_track)  trk_track->TrkTrack::Clear();          if(trk_track)  trk_track->TrkTrack::Clear();
338          if(calo_track) calo_track->CaloTrkVar::Clear();//???          if(calo_track) calo_track->CaloTrkVar::Clear();//???
339          if(tof_track)  tof_track->ToFTrkVar::Clear();//???          if(tof_track)  tof_track->ToFTrkVar::Clear();//???
340            if(orb_track)  orb_track->OrbitalInfoTrkVar::Clear();//???
341      }else{      }else{
342          trk_track  = 0;          trk_track  = 0;
343          calo_track = 0;          calo_track = 0;
344          tof_track  = 0;          tof_track  = 0;
345            orb_track  = 0;
346      }      }
347      pscore = 0;      pscore = 0;
348      iscore = 0;      iscore = 0;
# Line 355  void PamTrack::Delete(){ Line 363  void PamTrack::Delete(){
363              tof_track->ToFTrkVar::Clear();//???              tof_track->ToFTrkVar::Clear();//???
364              delete tof_track;              delete tof_track;
365          }          }
366            if(orb_track){
367                orb_track->OrbitalInfoTrkVar::Clear();//???
368                delete orb_track;
369            }
370      }else{      }else{
371          Clear();          Clear();
372      }      }
# Line 391  PamLevel2::PamLevel2(TString ddir,TStrin Line 403  PamLevel2::PamLevel2(TString ddir,TStrin
403      GetRunTree(listf);      GetRunTree(listf);
404  };  };
405    
406    PamLevel2::PamLevel2(TString ddir,TList *list,TString detlist){
407        Initialize();
408        GetPamTree(list,detlist);
409        GetRunTree(list);
410    };
411  /**  /**
412   * Constructor   * Constructor
413   * @param ddir Name of directory where level2 files are stored.   * @param ddir Name of directory where level2 files are stored.
# Line 492  void PamLevel2::Initialize(){ Line 509  void PamLevel2::Initialize(){
509    
510      ISGP = false;      ISGP = false;
511    
512        DBG = false;
513    
514      tsorted=0;      tsorted=0;
515      timage=0;      timage=0;
516            
# Line 706  void PamLevel2::Reset(){ Line 725  void PamLevel2::Reset(){
725      //      //
726  };  };
727    
728  Bool_t PamLevel2::IsGood(){  Bool_t PamLevel2::IsGood(Bool_t strict){
729      Bool_t goodev=true;    Bool_t goodev=true;
730      //  if(trk2_obj && trk2_obj->UnpackError() != 0 ) goodev = false;    //
731      if(calo2_obj && calo2_obj->good != 1) goodev = false;    if(calo2_obj && !calo2_obj->IsGood(strict) ) goodev = false;
732      //
733      if ( strict ){
734        if(trk2_obj && trk2_obj->UnpackError() != 0 ) goodev = false;
735      if(tof_obj && tof_obj->unpackError != 0) goodev = false;        if(tof_obj && tof_obj->unpackError != 0) goodev = false;  
736      if(trig_obj && trig_obj->unpackError != 0) goodev = false;      if(trig_obj && trig_obj->unpackError != 0) goodev = false;
737      if(s4_obj && s4_obj->unpackError != 0) goodev = false;        if(s4_obj && s4_obj->unpackError != 0) goodev = false;  
738      if(nd_obj && nd_obj->unpackError != 0) goodev = false;        if(nd_obj && nd_obj->unpackError != 0) goodev = false;  
739      if(ac_obj && ac_obj->unpackError != 255) goodev = false;        if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>3)&1) || ((ac_obj->status[0]>>3)&1)) ) goodev = false;      
740      //  if(orb_obj)        //  if(orb_obj)  
741      return goodev;    } else {
742        if(nd_obj && nd_obj->unpackError != 0) goodev = false;  
743        if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>3)&1) || ((ac_obj->status[0]>>3)&1)) ) goodev = false;      
744      };
745      return(goodev);
746  };  };
747    
748  //--------------------------------------  //--------------------------------------
# Line 742  void *PamLevel2::GetPointerTo(const char Line 768  void *PamLevel2::GetPointerTo(const char
768          return &trk2_obj;          return &trk2_obj;
769      };      };
770      if(!objname.CompareTo("TrkHough"))   {      if(!objname.CompareTo("TrkHough"))   {
771          if(!trkh_obj)  trkh_obj  = new TrkHough();          if(!trkh_obj)  {
772                trkh_obj  = new TrkHough();
773                trkh_obj->Set();
774            }
775          return &trkh_obj;          return &trkh_obj;
776      };      };
777      if(!objname.CompareTo("CaloLevel1")) {      if(!objname.CompareTo("CaloLevel1")) {
# Line 864  ToFTrkVar *PamLevel2::GetToFStoredTrack( Line 893  ToFTrkVar *PamLevel2::GetToFStoredTrack(
893  //  //
894  //--------------------------------------  //--------------------------------------
895  /**  /**
896   * Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information.   * Retrieves the OrbitalInfo track matching the seqno-th tracker stored track.
897     * (If seqno = -1 retrieves the tracker-independent tof related track)
898     */
899    OrbitalInfoTrkVar *PamLevel2::GetOrbitalInfoStoredTrack(int seqno){
900            
901        if( !orb_obj )return 0;
902    
903        if( orb_obj->OrbitalInfo::ntrk()==0 ){
904            cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<<endl;
905            return NULL;
906        };
907        
908        OrbitalInfoTrkVar *c = 0;
909        Int_t it_tof=0;
910        
911        do{
912            c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof);
913            it_tof++;
914        } while( c && seqno != c->trkseqno && it_tof < orb_obj->OrbitalInfo::ntrk());      
915        
916        if(!c || seqno != c->trkseqno){
917            c = 0;
918            if(seqno!=-1)cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match OrbitalInfo stored tracks"<<endl;
919        };
920        return c;
921        
922    };
923    
924    //--------------------------------------
925    //
926    //
927    //--------------------------------------
928    /**
929     * Give the pamela track associated to a tracker track, retrieving related calorimeter, orbitalinfo and tof track information.
930   */   */
931  PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){  PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){
932            
# Line 873  PamTrack* PamLevel2::GetPamTrackAlong(Tr Line 935  PamTrack* PamLevel2::GetPamTrackAlong(Tr
935    
936      CaloTrkVar *c = 0;      CaloTrkVar *c = 0;
937      ToFTrkVar  *o = 0;      ToFTrkVar  *o = 0;
938        OrbitalInfoTrkVar  *r = 0;
939            
940      if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());      if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());
941      if(TOF) o = GetToFStoredTrack(t->GetSeqNo());      if(TOF) o = GetToFStoredTrack(t->GetSeqNo());
942        if(ORB) r = GetOrbitalInfoStoredTrack(t->GetSeqNo());
943            
944  //    if(t && c && o)track = new PamTrack(t,c,o);  //    if(t && c && o)track = new PamTrack(t,c,o);
945      PamTrack *track = new PamTrack(t,c,o);      PamTrack *track = new PamTrack(t,c,o,r);
946            
947      return track;      return track;
948    
# Line 896  PamTrack* PamLevel2::GetPamTrackAlong(Tr Line 960  PamTrack* PamLevel2::GetPamTrackAlong(Tr
960  PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){  PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){
961            
962      cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl;      cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl;
963      cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl;      cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack) OrbitalInfo::GetOrbitalInfoTrkVar(Int_t notrack)"<<endl;
964      cout <<"(if you use it, remember to delete the PamTrack object)"<<endl;      cout <<"(if you use it, remember to delete the PamTrack object)"<<endl;
965      PamTrack *track = 0;      PamTrack *track = 0;
966            
# Line 1008  void PamLevel2::SortTracks(){ Line 1072  void PamLevel2::SortTracks(){
1072          TrkTrack   *ts = 0;          TrkTrack   *ts = 0;
1073          CaloTrkVar *cs = 0;          CaloTrkVar *cs = 0;
1074          ToFTrkVar  *os = 0;          ToFTrkVar  *os = 0;
1075            OrbitalInfoTrkVar  *rs = 0;
1076                    
1077          // get tracker tracks          // get tracker tracks
1078          TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker          TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker
1079          CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());          CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());
1080          ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());          ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());
1081            OrbitalInfoTrkVar  *rp = GetOrbitalInfoStoredTrack(tp->GetSeqNo());
1082    
1083          TrkTrack   *ti = 0; //tracker (image)          TrkTrack   *ti = 0; //tracker (image)
1084          CaloTrkVar *ci = 0;          CaloTrkVar *ci = 0;
1085          ToFTrkVar  *oi = 0;          ToFTrkVar  *oi = 0;
1086            OrbitalInfoTrkVar  *ri = 0;
1087          //      cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;          //      cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;
1088          // if track has an image, check image selection          // if track has an image, check image selection
1089    
# Line 1030  void PamLevel2::SortTracks(){ Line 1097  void PamLevel2::SortTracks(){
1097              ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)              ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)
1098              ci = GetCaloStoredTrack(ti->GetSeqNo());              ci = GetCaloStoredTrack(ti->GetSeqNo());
1099              oi = GetToFStoredTrack(ti->GetSeqNo());              oi = GetToFStoredTrack(ti->GetSeqNo());
1100                ri = GetOrbitalInfoStoredTrack(ti->GetSeqNo());
1101                            
1102              //      cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;              //      cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;
1103    
# Line 1371  void PamLevel2::SortTracks(){ Line 1439  void PamLevel2::SortTracks(){
1439                  ts = ti;//its image!!                  ts = ti;//its image!!
1440                  cs = ci;                  cs = ci;
1441                  os = oi;                  os = oi;
1442                    rs = ri;
1443                  Int_t totis = toti_score;                  Int_t totis = toti_score;
1444    
1445                  ti = tp;//its image!!                  ti = tp;//its image!!
1446                  ci = cp;                  ci = cp;
1447                  oi = op;                  oi = op;
1448                    ri = rp;
1449    
1450                  tp = ts;//its image!!                  tp = ts;//its image!!
1451                  cp = cs;                  cp = cs;
1452                  op = os;                  op = os;
1453                    rp = rs;
1454    
1455                  toti_score = totp_score;                  toti_score = totp_score;
1456                  totp_score = totis;                  totp_score = totis;
# Line 1409  void PamLevel2::SortTracks(){ Line 1480  void PamLevel2::SortTracks(){
1480          //      cout<<"o "<<cp<<endl;          //      cout<<"o "<<cp<<endl;
1481          //      cout<<"o "<<op<<endl;          //      cout<<"o "<<op<<endl;
1482    
1483          new(ttsorted[i]) PamTrack(tp,cp,op);          new(ttsorted[i]) PamTrack(tp,cp,op,rp);
1484          new(ttimage[i])  PamTrack(ti,ci,oi);          new(ttimage[i])  PamTrack(ti,ci,oi,ri);
1485    
1486          ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);          ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);
1487          ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score);          ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score);
# Line 1520  PamTrack *PamLevel2::GetTrack(int it){ Line 1591  PamTrack *PamLevel2::GetTrack(int it){
1591   */   */
1592  PamTrack *PamLevel2::GetTrackImage(int it){  PamTrack *PamLevel2::GetTrackImage(int it){
1593    
 //     if(!trk2_obj) return 0;  
   
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 //     SortTracks("+CAL+TOF");  
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 // //    if(!sorted_tracks)return 0;  
 //     if(sorted_tracks.IsEmpty())return 0;  
       
 //     PamTrack *image = 0;  
       
 //     if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){  
 //      TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it);  
 //      if( temp->HasImage() ){  
 //          TrkTrack   *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());  
 //          image = GetPamTrackAlong(t);  
 //      }else{  
 //          cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;  
 //      };  
 //     }else{  
 //      cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl;  
 //     };  
       
 //     return image;  
   
   
1594  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
1595      SortTracks();      SortTracks();
1596  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
# Line 2168  void PamLevel2::SetBranchAddress(TTree * Line 2214  void PamLevel2::SetBranchAddress(TTree *
2214      if(GP) {      if(GP) {
2215  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2216          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2217          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri  //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2218    // //   t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2219            if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2220            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2221    
2222          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2223      };      };
2224            
# Line 2250  void PamLevel2::SetBranchAddress(TChain Line 2300  void PamLevel2::SetBranchAddress(TChain
2300      if(GP) {      if(GP) {
2301  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2302          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2303          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri          if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2304            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2305    //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2306          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2307      };      };
2308      // SelectionList      // SelectionList
# Line 2283  TChain *PamLevel2::GetRunTree(TList *fl) Line 2335  TChain *PamLevel2::GetRunTree(TList *fl)
2335          return run_tree;          return run_tree;
2336      };        };  
2337      //      //
2338    
2339    
2340      TChain *R = new TChain("Run");      TChain *R = new TChain("Run");
2341            
2342      // loop over files and create chains              // loop over files and create chains        
# Line 2295  TChain *PamLevel2::GetRunTree(TList *fl) Line 2349  TChain *PamLevel2::GetRunTree(TList *fl)
2349              R->Add(name);              R->Add(name);
2350          };          };
2351      }      }
2352        
2353    
2354      if(R->GetNtrees()){      if(RUN && R->GetNtrees()){
2355            
2356          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));
2357          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
# Line 2304  TChain *PamLevel2::GetRunTree(TList *fl) Line 2359  TChain *PamLevel2::GetRunTree(TList *fl)
2359          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2360    
2361          irunoffset = new int[R->GetNtrees()];          irunoffset = new int[R->GetNtrees()];
2362          cout << "----------------------------------------------------"<<endl;          if(DBG){
2363          cout << "irun\t | ";              cout << "----------------------------------------------------"<<endl;
2364          cout << "tree\t |";              cout << "irun\t | ";
2365                cout << "tree\t |";
2366  //      cout << "offset\t |";  //      cout << "offset\t |";
2367          cout << "RUN\t";              cout << "RUN\t";
2368          cout << "FRAG\t";              cout << "FRAG\t";
2369          cout << "NEVENTS\t";              cout << "NEVENTS\t";
2370          cout << "absolute time\t\t\t";              cout << "absolute time\t\t\t";
2371          cout << "on-board time";              cout << "on-board time";
2372          cout<<endl;              cout<<endl;
2373            }
2374          for (Int_t ii=0; ii<R->GetEntries(); ii++){          for (Int_t ii=0; ii<R->GetEntries(); ii++){
2375              R->GetEntry(ii);              R->GetEntry(ii);
2376              cout << ii<< "\t | ";              if(DBG){
2377              cout << R->GetTreeNumber()<< "\t |";                  cout << ii<< "\t | ";
2378                    cout << R->GetTreeNumber()<< "\t |";
2379  //          cout << R->GetChainOffset()<< "\t |";  //          cout << R->GetChainOffset()<< "\t |";
2380              cout <<GetRunInfo()->ID<<"\t";                  cout <<GetRunInfo()->ID<<"\t";
2381              cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";                  cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";
2382              cout <<GetRunInfo()->NEVENTS<< "\t";                  cout <<GetRunInfo()->NEVENTS<< "\t";
2383              cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";                  cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";
2384              cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";                  cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";
2385              cout <<endl;                  cout <<endl;
2386                }
2387              irunoffset[R->GetTreeNumber()]=R->GetChainOffset();              irunoffset[R->GetTreeNumber()]=R->GetChainOffset();
2388          }          }
2389            cout << "N.run = "<<R->GetEntries()<<endl;
2390          cout << "----------------------------------------------------"<<endl;          cout << "----------------------------------------------------"<<endl;
2391    
2392    
   
2393      }else{      }else{
2394          delete R;          delete R;
2395          R=0;          R=0;
2396      }      }
2397        
2398    
2399      run_tree = R;      run_tree = R;
2400    
# Line 2541  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2601  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2601      if( GetOrbitalInfo() ){      if( GetOrbitalInfo() ){
2602          abstime = GetOrbitalInfo()->absTime;          abstime = GetOrbitalInfo()->absTime;
2603          obt     = GetOrbitalInfo()->OBT;          obt     = GetOrbitalInfo()->OBT;
 //      cout << " ABS >>> "<<abstime<<" OBT >>> "<<obt<<" "<<endl;  
2604      }else{      }else{
2605          abstime = GetRunInfo()->RUNHEADER_TIME;          abstime = GetRunInfo()->RUNHEADER_TIME;
2606          obt     = GetRunInfo()->RUNHEADER_OBT;          obt     = GetRunInfo()->RUNHEADER_OBT;
2607      }      }
 //    cout << ISGP << " "<<abstime<<endl;  
     // ---------------------------------------------------------------  
     // the absolute time is necessary to relate the event with the run  
     // ---------------------------------------------------------------  
 //     if( !GetOrbitalInfo() && !ISGP ){  
 //      cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;  
 //      return(false);  
 //     }  
     // -----------------------------------------------------------------------  
     // if it is simulation, assign abstime by hand (temporaneo!!!)  
     // -----------------------------------------------------------------------  
 //     if(ISGP){  
 //      abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO  
 //      obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO  
 //     }  
2608            
2609    
2610      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Line 2579  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2623  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2623              }              }
2624              totdltime[2]++;              totdltime[2]++;
2625          }          }
 //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;  
   
 //      // ---------------------------------------------------------------  
 //      // retrieve OBT and absolute time of the event  
 //      // ---------------------------------------------------------------  
 //      ULong64_t abstime = 0;  
 //      ULong64_t obt     = 0;  
 //      if( GetOrbitalInfo() ){  
 //          abstime = GetOrbitalInfo()->absTime;  
 //          obt     = GetOrbitalInfo()->OBT;  
 //      }  
 //      // ---------------------------------------------------------------  
 //      // the absolute time is necessary to relate the event with the run  
 //      // ---------------------------------------------------------------  
 //      if( !GetOrbitalInfo() && !ISGP ){  
 //          cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;  
 //          return(false);  
 //      }  
         
 //      // -----------------------------------------------------------------------  
 //      // the first time the routine is called, set run search from the beginning  
 //      // -----------------------------------------------------------------------  
 //      if ( irun < 0 ){  
 //          irun = 0LL;  
 //          irunt = 0LL;  
 //          irunentry = 0;  
 //          prevshift = 0;  
 //          run_tree->GetEntry(irun);  
   
 //          if( ISGP && run_tree->GetEntries()!=1 ){  
 //              cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;  
 //              cout << "** WARNING ** run will not be updated"<<endl;  
 //          }  
 //      };        
2626    
 //      // -----------------------------------------------------------------------  
 //      // if it is simulation, assign abstime by hand (temporaneo!!!)  
 //      // -----------------------------------------------------------------------  
 //      if(ISGP){  
 //          abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO  
 //          obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO  
 //      }  
2627          //          //
2628          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2629    
 //      Bool_t hasfrag = false;  
 //      if( GetRunInfo()->ID_RUN_FRAG!=0 && GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID)hasfrag=true;  
 //      ULong64_t fragid = GetRunInfo()->ID_RUN_FRAG;  
2630    
2631          // ------------------------------------------------------          // ------------------------------------------------------
2632          // loop over runs to find the one that contains the event          // loop over runs to find the one that contains the event
2633          // ------------------------------------------------------          // ------------------------------------------------------
2634          while (          while (
2635              (              (
2636                  (  //              (
2637                      !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)  //                  !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2638                        abstime <= GetRunInfo()->RUNTRAILER_TIME) &&  //                    abstime <= GetRunInfo()->RUNTRAILER_TIME) &&
2639                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)  //                  !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2640                        obt <= GetRunInfo()->RUNTRAILER_OBT)  //                    obt <= GetRunInfo()->RUNTRAILER_OBT)
2641                      )  //                  )
2642                  || GetRunInfo()->NEVENTS==0                  
2643                    !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2644                      abstime <= GetRunInfo()->RUNTRAILER_TIME)
2645                    ||
2646                    !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2647                      obt <= GetRunInfo()->RUNTRAILER_OBT)          
2648                    ||
2649                    GetRunInfo()->NEVENTS==0
2650  //              || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento  //              || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento
2651                  || !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift)                  ||
2652                    !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift)
2653                  )                  )
2654              && irun < run_tree->GetEntries() ){              && irun < run_tree->GetEntries() ){
2655    
2656    
2657    //          if( !(abstime >= GetRunInfo()->RUNHEADER_TIME &&abstime <= GetRunInfo()->RUNTRAILER_TIME)  )cout << "ABS TIME "<<abstime << " " <<GetRunInfo()->RUNTRAILER_TIME <<endl;
2658    //          if( !(obt >= GetRunInfo()->RUNHEADER_OBT && obt <= GetRunInfo()->RUNTRAILER_OBT) )cout << "OBT TIME "<< obt <<" "<< GetRunInfo()->RUNTRAILER_OBT << endl;
2659    //          if( GetRunInfo()->NEVENTS==0  )cout <<"GetRunInfo()->NEVENTS==0 "<<endl;
2660    //          if( !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift) ) cout << "irunentry > "<<GetRunInfo()->NEVENTS-1-prevshift << endl;
2661              // - - - - - - - - - - - - -              // - - - - - - - - - - - - -
2662              // irunentry = position of current entry, relative to the run              // irunentry = position of current entry, relative to the run
2663              // prevshift = shift needed to synchronize l0 and l2 data (nested events)              // prevshift = shift needed to synchronize l0 and l2 data (nested events)
# Line 2654  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2667  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2667              // store dead and live-time of previous run              // store dead and live-time of previous run
2668              // -----------------------------------------              // -----------------------------------------
2669  //          if(SELLI==0){  //          if(SELLI==0){
2670                  if(fromfirst){              if(fromfirst){
2671                      if(oldrun==irun){                  if(oldrun==irun){
2672                          /// decrement counters                      /// decrement counters
2673                          if( GetTrigLevel2()){                      if( GetTrigLevel2()){
2674                              totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time                          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2675                              totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
                         }  
                         totdltime[2]--;                              //event counter  
                         cout << endl;  
                         cout << "n.events     : "<<totdltime[2]<<endl;  
                         cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;  
                         cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;            
                     }else{  
                         totdltime[0]=0;//live-time  
                         totdltime[1]=0;//dead-time  
                         totdltime[2]=0;                             //event counter  
                         cout << " *** JUMP RUN *** irun "<<irun<<endl;  
                     }  
                     /// add an entry  
                     if(run_tree_clone)  
                         if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
                             run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
                     /// reset counters  
                     if( GetTrigLevel2() ){  
                         totdltime[0]=GetTrigLevel2()->dltime[0];//live-time  
                         totdltime[1]=0;                         //dead-time  
2676                      }                      }
2677                      totdltime[2]=1;                             //event counter                      totdltime[2]--;                              //event counter
2678                        cout << endl;
2679                        cout << "n.events     : "<<totdltime[2]<<endl;
2680                        cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2681                        cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2682                    }else{
2683                        totdltime[0]=0;//live-time
2684                        totdltime[1]=0;//dead-time
2685                        totdltime[2]=0;                             //event counter
2686                        cout << " *** JUMP RUN *** irun "<<irun<<endl;
2687                  }                  }
2688                    /// add an entry
2689                    if(run_tree_clone)
2690                        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2691                            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2692                    /// reset counters
2693                    if( GetTrigLevel2() ){
2694                        totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2695                        totdltime[1]=0;                         //dead-time
2696                    }
2697                    totdltime[2]=1;                             //event counter
2698                }
2699  //          }  //          }
2700    
2701              irun++;                      irun++;        
# Line 2713  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2726  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2726              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2727              irunentry = 0;              irunentry = 0;
2728              prevshift = 0;                        prevshift = 0;          
2729              run_tree->GetEntry(irun);              run_tree->GetEntry(irun);//update runinfo
2730              irunt = irun - irunoffset[run_tree->GetTreeNumber()];              irunt = irun - irunoffset[run_tree->GetTreeNumber()];
2731              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2732                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;
# Line 2736  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2749  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2749          // --------------------------------------          // --------------------------------------
2750    
2751    
   
   
2752          // --------------------------------------          // --------------------------------------
2753          // ---> exit with TRUE          // ---> exit with TRUE
2754          // --------------------------------------          // --------------------------------------
2755          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;          if(DBG)cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2756            // ----------------------------------------------------
2757            // update the tracker parameters
2758            // (non ho trovato nessun altro modo sicuro di farlo...)
2759            // ----------------------------------------------------
2760            if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection();
2761            TrkParams::Set(GetRunInfo() ,dbc);
2762            if(dbc)dbc->Close();
2763    
2764          // ----------------------------------------------------          // ----------------------------------------------------
2765          // then check if the run has a fragment          // then check if the run has a fragment
2766          // in this case we have to switch to the next fragment          // in this case we have to switch to the next fragment
# Line 2750  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2769  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2769          if(          if(
2770              GetRunInfo()->ID_RUN_FRAG != 0 &&              GetRunInfo()->ID_RUN_FRAG != 0 &&
2771  //          GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID &&  //          GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID &&
2772                DBG &&
2773              true ){              true ){
2774              cout << "* fragment *"<<endl;                            cout << "* fragment *"<<endl;              
2775          }          }
# Line 2764  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2784  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2784      if(SELLI==1){            if(SELLI==1){      
2785          sel_tree->GetEntry(iev);// read irunt from SelectionList          sel_tree->GetEntry(iev);// read irunt from SelectionList
2786          irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW          irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW
2787          if(irun != oldrun){          if(irun != oldrun ){
2788              run_tree->GetEntry(irun);              if( irun < run_tree->GetEntries() )run_tree->GetEntry(irun);
2789              // check if the time is ok (with merged files it is not...)              // check if the time is ok (with merged files it is not...)
2790              // if not loop over run and look for the proper entry              // if not loop over run and look for the proper entry
2791              bool SECONDO_GIRO=false;              bool SECONDO_GIRO=false;
2792                //      Long64_t irun_start   = irun;
2793                int      offset_start = irunoffset[sel_tree->GetTreeNumber()];
2794              while (              while (
2795                  (                  (
2796                      (                      (
2797                          !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)                          !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2798                            abstime <= GetRunInfo()->RUNTRAILER_TIME)                            abstime <= GetRunInfo()->RUNTRAILER_TIME)
2799                          ||  //                      ||
2800                          !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)  //                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2801                            obt <= GetRunInfo()->RUNTRAILER_OBT)  //                        obt <= GetRunInfo()->RUNTRAILER_OBT)
2802                          )                          )
2803                      || GetRunInfo()->NEVENTS==0                      || GetRunInfo()->NEVENTS==0
2804                      )                      )
2805  //              && irun < run_tree->GetEntries()  //              && irun < run_tree->GetEntries()
2806                  ){                  ){
2807                  cout << " (test) ";  
2808                  cout << " tree "<<sel_tree->GetTreeNumber();                  if(DBG){
2809                  cout << " irunt "<<irunt;                      cout << " (test) ";
2810                  cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];                      cout << " tree "<<sel_tree->GetTreeNumber();
2811                  cout << " abs "<<abstime;                      cout << " irunt "<<irunt;
2812                  cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;                      cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2813                  cout << " obt "<<obt;                      cout << " abs "<<abstime;
2814                  cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;                      cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2815                  cout << " *** JUMP RUN *** irun "<<irun;                      cout << " obt "<<obt;
2816  //              if(!SECONDO_GIRO)cout << " (don't worry)";                      cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2817  //              else             cout << " (start worring...)";                      cout << " *** JUMP RUN *** irun "<<irun;
2818                  cout << endl;                      cout << endl;
2819                  irun++;                  }
2820    //              irun++;
2821                  irunoffset[sel_tree->GetTreeNumber()]++;                  irunoffset[sel_tree->GetTreeNumber()]++;
2822                    irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW          
2823                  if(irun == run_tree->GetEntries() && SECONDO_GIRO){                  if(irun == run_tree->GetEntries() && SECONDO_GIRO){
2824    //              if(irun == irun_start ){
2825                      cout << " ...grrrvzzkhhhajsdkj!!!! "<<endl;                      cout << " ...grrrvzzkhhhajsdkj!!!! "<<endl;
2826                        irunoffset[sel_tree->GetTreeNumber()] = offset_start;
2827                      return false;                      return false;
2828                  }                  }
2829                  if(irun == run_tree->GetEntries()){                  if( irun >= run_tree->GetEntries() || irun < 0){
2830                        cout << "irun = "<<irun<<" >>  search from the beginning... <<"<<endl;
2831                      SECONDO_GIRO=true;                      SECONDO_GIRO=true;
2832                      irun=0;                      irun=0;
2833                      irunoffset[sel_tree->GetTreeNumber()]=0;                      irunoffset[sel_tree->GetTreeNumber()]=-irunt;
2834                  }                  }
2835                  run_tree->GetEntry(irun);                  run_tree->GetEntry(irun);
2836              }              }
2837    
2838              cout << " (test) ";  
2839              cout << " tree "<<sel_tree->GetTreeNumber();              if(DBG){
2840              cout << " irunt "<<irunt;                  cout << " (test) ";
2841              cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];                  cout << " tree "<<sel_tree->GetTreeNumber();
2842              cout << " abs "<<abstime;                  cout << " irunt "<<irunt;
2843              cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;                  cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2844              cout << " obt "<<obt;                  cout << " abs "<<abstime;
2845              cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;                  cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2846              cout << endl;                  cout << " obt "<<obt;
2847              cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;                  cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2848              cout << endl;              }
2849                if(DBG)cout << endl;
2850                if(DBG)cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" (run-entry "<<irun<<")"<<endl;
2851                // ----------------------------------------------------
2852                // update the tracker parameters
2853                // (non ho trovato nessun altro modo sicuro di farlo...)
2854                // ----------------------------------------------------
2855                if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection();
2856                TrkParams::Set(GetRunInfo() ,dbc);
2857                if(dbc)dbc->Close();
2858    //          cout << endl;
2859              prevshift = 0;              prevshift = 0;
2860              return true;              return true;
2861          }          }
# Line 3025  void  PamLevel2::GetWhichTrees(TFile* f) Line 3062  void  PamLevel2::GetWhichTrees(TFile* f)
3062            
3063      RUN    = false;      RUN    = false;
3064                    
3065      cout << "Checking file: "<<f->GetName()<<endl;  //    cout << "Checking file: "<<f->GetName()<<endl;
3066      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
3067          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;
3068          return;          return;
# Line 3400  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3437  Bool_t  PamLevel2::CheckLevel2File(TStri
3437    
3438    
3439      if(!RUN__ok) {      if(!RUN__ok) {
3440          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl;          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree (NB: RUN infos will not be updated)"<< endl;
3441  //      return false;          RUN = false;
3442      };      };
3443    
3444      if(CAL1 && !CAL1__ok){      if(CAL1 && !CAL1__ok){
# Line 3524  void PamLevel2::CreateCloneTrees(TFile * Line 3561  void PamLevel2::CreateCloneTrees(TFile *
3561    
3562    
3563  //  if the pointer is null, create a default file  //  if the pointer is null, create a default file
3564        if(!run_tree)return;
3565    
3566      if(!ofile){      if(!ofile){
3567          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;
# Line 3745  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3783  Int_t PamLevel2::GetEntry(Long64_t iee){
3783      // in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not      // in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not
3784      // a problem if you don't check the return code of getentry.      // a problem if you don't check the return code of getentry.
3785      //      //
3786      if(!run_tree ){      if(!RUN || !run_tree ){
3787          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?
3788              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;
3789              return 0;              return 0;
# Line 3888  TTree* PamLevel2::GetYodaTree( ){ Line 3926  TTree* PamLevel2::GetYodaTree( ){
3926  //     }  //     }
3927    
3928      if ( TRK0 ){      if ( TRK0 ){
3929          TrkParams::Load(6);  //      TrkParams::Load(6);
3930          if( !TrkParams::IsLoaded(6) ){  //      if( !TrkParams::IsLoaded(6) ){
3931              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl;  //          cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl;
3932          };  //      };
3933          if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection();  //      if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection();
3934          TrkParams::SetCalib(run_obj,dbc);          TrkParams::SetCalib(run_obj,dbc);
3935          TrkParams::LoadCalib( );          TrkParams::LoadCalib( );
3936          if( !TrkParams::CalibIsLoaded() ){          if( !TrkParams::CalibIsLoaded() ){
3937              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl;              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl;
3938          };          };
3939          dbc->Close(); // EMILIANO, do not leave open connections, open only when needed  //      if(dbc)dbc->Close(); // EMILIANO, do not leave open connections, open only when needed
3940      }      }
3941    
3942    
# Line 3967  Int_t PamLevel2::GetYodaEntry(){ Line 4005  Int_t PamLevel2::GetYodaEntry(){
4005      do{      do{
4006          if(shift>0){              if(shift>0){    
4007              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
4008              cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;              if(DBG)cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;
4009              cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;              if(DBG)cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;
4010          }          }
4011          answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift);          answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift);
4012          shift++;          shift++;
# Line 4001  Int_t PamLevel2::GetYodaEntry(){ Line 4039  Int_t PamLevel2::GetYodaEntry(){
4039              && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);              && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);
4040    
4041      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {
4042          cout << " Big trouble here, no such event in Level0 data! " <<endl;          cout << " Big trouble here, no such event in Level0 data! (NB maxshift set to "<<maxshift<<" )" <<endl;
4043          return 0;          return 0;
4044      }      }
4045  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;
# Line 4016  Int_t PamLevel2::GetYodaEntry(){ Line 4054  Int_t PamLevel2::GetYodaEntry(){
4054   */   */
4055  Bool_t PamLevel2::SetDBConnection(){  Bool_t PamLevel2::SetDBConnection(){
4056    
4057      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //    cout << "PamLevel2::SetDBConnection()" << endl;
4058      cout<<"Connecting to DB"<<endl;      if(DBG){
4059      cout<<"HOST "<<host<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4060      cout<<"USER "<<user<<endl;          cout<<"Connecting to DB"<<endl;
4061      cout<<"PSW  "<<psw<<endl;          cout<<"HOST "<<host<<endl;
4062            cout<<"USER "<<user<<endl;
4063            cout<<"PSW  "<<psw<<endl;
4064        }
4065      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
4066      if( !dbc )return false;      if( !dbc )return false;
4067      if( !dbc->IsConnected() )return false;          if( !dbc->IsConnected() )return false;    
# Line 4028  Bool_t PamLevel2::SetDBConnection(){ Line 4069  Bool_t PamLevel2::SetDBConnection(){
4069      myquery.str("");  // EMILIANO      myquery.str("");  // EMILIANO
4070      myquery << "SET time_zone='+0:00'";  // EMILIANO      myquery << "SET time_zone='+0:00'";  // EMILIANO
4071      dbc->Query(myquery.str().c_str());  // EMILIANO      dbc->Query(myquery.str().c_str());  // EMILIANO
4072      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(DBG)cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4073      return true;      return true;
4074    
4075  }  }

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.23