/[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.38 by mocchiut, Fri Apr 27 13:58:04 2007 UTC revision 1.40 by pam-fi, Fri May 25 13:38:51 2007 UTC
# Line 304  void PamLevel2::Clear(){ Line 304  void PamLevel2::Clear(){
304    
305      if(h0_obj)   h0_obj->Clear();            if(h0_obj)   h0_obj->Clear();      
306  //    if(trk0_obj) trk0_obj->Clear();    //    if(trk0_obj) trk0_obj->Clear();  
     if(calo0_obj) calo0_obj->Clear();    
307      if(trk1_obj) trk1_obj->Clear();          if(trk1_obj) trk1_obj->Clear();    
308      if(trk2_obj) trk2_obj->Clear();      if(trk2_obj) trk2_obj->Clear();
309      if(trkh_obj) trkh_obj->Clear();      if(trkh_obj) trkh_obj->Clear();
310        if(calo0_obj) calo0_obj->Clear();  
311      if(calo1_obj)calo1_obj->Clear();      if(calo1_obj)calo1_obj->Clear();
312      if(calo2_obj)calo2_obj->Clear();      if(calo2_obj)calo2_obj->Clear();
313      if(tof_obj)  tof_obj->Clear();      if(tof_obj)  tof_obj->Clear();
# Line 939  void PamLevel2::SortTracks(){ Line 939  void PamLevel2::SortTracks(){
939          //              ts = tp;          //              ts = tp;
940          //              cs = cp;          //              cs = cp;
941          //              os = op;          //              os = op;
942          cout << "Warning - track image ambiguity not solved" << endl;  //      cout << "Warning - track image ambiguity not solved" << endl;
943          //                              cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl;          //                              cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl;
944        };        };
945                            
# Line 1999  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 1999  Bool_t PamLevel2::UpdateRunInfo(Long64_t
1999          // -----------------------------------------------------------------------          // -----------------------------------------------------------------------
2000          if ( irun < 0 ){          if ( irun < 0 ){
2001              irun = 0LL;              irun = 0LL;
2002                irunentry = 0;
2003                prevshift = 0;
2004              run_tree->GetEntry(irun);              run_tree->GetEntry(irun);
2005          };                };      
2006          //          //
2007          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2008    
2009    //      Bool_t hasfrag = false;
2010    //      if( GetRunInfo()->ID_RUN_FRAG!=0 && GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID)hasfrag=true;
2011    //      ULong64_t fragid = GetRunInfo()->ID_RUN_FRAG;
2012    
2013          // ------------------------------------------------------          // ------------------------------------------------------
2014          // loop over runs to find the one that contains the event          // loop over runs to find the one that contains the event
2015          // ------------------------------------------------------          // ------------------------------------------------------
2016          while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)          while (
2017                    GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) &&              (
2018                  !(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)                  (
2019                    GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) &&                      !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2020                  irun < run_tree->GetEntries() ){                        GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) &&
2021                        !(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2022                          GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT)
2023                        )
2024                    || GetRunInfo()->NEVENTS==0
2025                    || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift)
2026                    )
2027                    && irun < run_tree->GetEntries() ){
2028    
2029              irun++;              irun++;
2030              // ------------------------------------              // ------------------------------------
2031              // if the end of run tree is reached...              // if the end of run tree is reached...
# Line 2036  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2051  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2051              // save the index of the first entry of the run, relative to pam_tree,              // save the index of the first entry of the run, relative to pam_tree,
2052              // and read a new run              // and read a new run
2053              // -------------------------------------------------------------------              // -------------------------------------------------------------------
2054              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS);              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2055                irunentry = 0;
2056                prevshift = 0;
2057              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);      
2058              if(GetRunInfo()->RUNHEADER_OBT>=GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2059                  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;
2060                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;
2061              }              }
2062    //          if(hasfrag &&  fragid != GetRunInfo()->ID){
2063    //              cout << "... where is the next fragment ??"<<endl;
2064    //          }
2065          };          };
2066    
2067    
2068          // --------------------------------------          // --------------------------------------
2069          // if there was no need to update the run          // if there was no need to update the run
2070          // ---> exit with FALSE          // ---> exit with FALSE
# Line 2054  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2076  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2076          // ---> exit with TRUE          // ---> exit with TRUE
2077          // --------------------------------------          // --------------------------------------
2078          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2079          prevshift = 0;          // ----------------------------------------------------
2080            // then check if the run has a fragment
2081            // in this case we have to switch to the next fragment
2082            // when the end of the first fragment is reached
2083            // ----------------------------------------------------
2084            if(
2085                GetRunInfo()->ID_RUN_FRAG != 0 &&
2086    //          GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID &&
2087                true ){
2088                cout << "* fragment *"<<endl;              
2089            }
2090            
2091          return(true);              return(true);    
2092      };      };
2093      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Line 2703  void PamLevel2::CreateCloneTrees0( TChai Line 2736  void PamLevel2::CreateCloneTrees0( TChai
2736   */   */
2737  void PamLevel2::CreateCloneTrees(TFile *ofile){  void PamLevel2::CreateCloneTrees(TFile *ofile){
2738    
2739    
2740    //  if the pointer is null, create a default file
2741    
2742        if(!ofile){
2743            cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;
2744            ofile = new TFile("clone-tree.root","recreate");
2745        }
2746    
2747      ofile->cd();      ofile->cd();
2748    
2749      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
# Line 2872  void PamLevel2::WriteCloneTrees(){ Line 2913  void PamLevel2::WriteCloneTrees(){
2913  //Int_t PamLevel2::GetEntry(Int_t iee){  //Int_t PamLevel2::GetEntry(Int_t iee){
2914  Int_t PamLevel2::GetEntry(Long64_t iee){  Int_t PamLevel2::GetEntry(Long64_t iee){
2915            
2916    //     cout << "-------------------------------------"<<endl;
2917    //     cout << "Int_t PamLevel2::GetEntry("<<iee<<")"<<endl;
2918    
2919      if(!pam_tree){      if(!pam_tree){
2920          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl;          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl;
2921          return 0;          return 0;
# Line 2917  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 2961  Int_t PamLevel2::GetEntry(Long64_t iee){
2961        
2962  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;
2963    
2964  //    cout << " irunentry "<<irunentry << endl;  //     cout << "irunentry     "<<irunentry << endl;
2965    //     cout << "runfirstentry "<<runfirstentry << endl;
2966    //     cout << "nevents       "<<GetRunInfo()->NEVENTS<< endl;
2967    
2968    //     if( TRK0 || CAL0 || TOF0 ){
2969    //      if( !GetYodaEntry( ) ){
2970    //          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl;
2971    //          return 0;
2972    //      }
2973    //     }
2974    
2975    
     if( TRK0 || CAL0 || TOF0 ){  
         if( !GetYodaEntry( ) ){  
             cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl;  
             return 0;  
         }  
     }  
2976      return 1;      return 1;
2977    
2978  }  }
2979    
2980    TrkLevel0    *PamLevel2::GetTrkLevel0(){
2981        if( !TRK0 )return NULL;
2982        if( !GetYodaEntry( ) ){
2983            cout << " Int_t PamLevel2::GetTrkLevel0() -- ERROR -- error reading level0 tree"<<endl;
2984            return 0;
2985        }
2986        return trk0_obj;
2987    };
2988    CaloLevel0    *PamLevel2::GetCaloLevel0(){
2989        if( !CAL0 )return NULL;
2990        if( !GetYodaEntry( ) ){
2991            cout << " Int_t PamLevel2::GetCaloLevel0() -- ERROR -- error reading level0 tree"<<endl;
2992            return 0;
2993        }
2994        return calo0_obj;
2995    };
2996    
2997    
2998  /**  /**
2999   * Method to retrieve the level0 tree (YODA tree) that contains the current event.   * Method to retrieve the level0 tree (YODA tree) that contains the current event.
3000   * Given the run ID (...), if needed it query the DB and load the proper file.   * Given the run ID (...), if needed it query the DB and load the proper file.
# Line 2948  TTree* PamLevel2::GetYodaTree( ){ Line 3014  TTree* PamLevel2::GetYodaTree( ){
3014          return NULL;          return NULL;
3015      }          }    
3016      Int_t irootnew = run_obj->ID_ROOT_L0;      Int_t irootnew = run_obj->ID_ROOT_L0;
3017  //     cout << "iroot    "<<iroot<<endl;  //      cout << "iroot    "<<iroot<<endl;
3018  //     cout << "irootnew "<<irootnew<<endl;  //      cout << "irootnew "<<irootnew<<endl;
3019    
3020      //===================================      //===================================
3021      // load the level0 file      // load the level0 file
# Line 3006  TTree* PamLevel2::GetYodaTree( ){ Line 3072  TTree* PamLevel2::GetYodaTree( ){
3072              };              };
3073              l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent());              l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent());
3074          }          }
3075          //---------------------------------------------------          //--------------------------------------------------
3076          // CALORIMETER:          // CALORIMETER:
3077          if(CAL0){          if(CAL0){
3078              if(!calo0_obj){              if(!calo0_obj){
# Line 3095  Int_t PamLevel2::GetYodaEntry(){ Line 3161  Int_t PamLevel2::GetYodaEntry(){
3161      Int_t answer = 0;      Int_t answer = 0;
3162      Int_t shift =0;      Int_t shift =0;
3163      //    printf(" siamo qui %i %i \n",shift,prevshift);      //    printf(" siamo qui %i %i \n",shift,prevshift);
3164      Int_t maxshift = 100;      Int_t maxshift = 10;
3165      do{      do{
3166          if(shift>0){              if(shift>0){    
3167              cout << " PKTNUM  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
# Line 3124  Int_t PamLevel2::GetYodaEntry(){ Line 3190  Int_t PamLevel2::GetYodaEntry(){
3190    
3191      }while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);      }while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);
3192    
3193      if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() || shift == maxshift ) {      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {
3194          cout << " Big trouble here, no such event in Level0 data! " <<endl;          cout << " Big trouble here, no such event in Level0 data! " <<endl;
3195          return 0;          return 0;
3196      }      }
# Line 3135  Int_t PamLevel2::GetYodaEntry(){ Line 3201  Int_t PamLevel2::GetYodaEntry(){
3201      return answer;      return answer;
3202            
3203  }  }
3204    /**
3205     * \Brief Set DB connection
3206     */
3207    Bool_t PamLevel2::SetDBConnection(){
3208    
3209        cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
3210        cout<<"Connecting to DB"<<endl;
3211        cout<<"HOST "<<host<<endl;
3212        cout<<"USER "<<user<<endl;
3213        cout<<"PSW  "<<psw<<endl;
3214        dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
3215        if( !dbc )return false;
3216        if( !dbc->IsConnected() )return false;    
3217        cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
3218        return true;
3219    
3220    }

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.23