/[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.23 by mocchiut, Thu Mar 8 15:25:27 2007 UTC revision 1.24 by pam-fi, Thu Mar 15 12:18:51 2007 UTC
# Line 1527  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 1527  Bool_t PamLevel2::UpdateRunInfo(TChain *
1527            run->GetEntry(0);            run->GetEntry(0);
1528            runfirstentry = 0ULL;            runfirstentry = 0ULL;
1529            runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL;            runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL;
1530        };        };      
1531        while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){  
1532          if( !GetOrbitalInfo() ){
1533              cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
1534              return(false);
1535          }
1536          // modificato il controllo sull'aggiornamento del run, per evitare problemi
1537          // dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!)
1538          while ( GetOrbitalInfo()->absTime > GetRunInfo()->RUNTRAILER_TIME && irun < run->GetEntries() ){
1539    //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){
1540            //    printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));            //    printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));
1541            irun++;            irun++;
1542            run->GetEntry(irun);            run->GetEntry(irun);
1543            runfirstentry = runlastentry+1ULL;            runfirstentry = runlastentry+1ULL;
1544            runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS);            runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS);
1545        };        };
1546          
1547        //        //
1548        if ( irun == oldrun || irun >= run->GetEntries() ) return(false);        if ( irun == oldrun || irun >= run->GetEntries() ) return(false);
1549        //        //
# Line 2213  void PamLevel2::CreateCloneTrees(TFile * Line 2222  void PamLevel2::CreateCloneTrees(TFile *
2222              pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1"));              pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1"));
2223              pam_tree_clone[i]->BranchRef();              pam_tree_clone[i]->BranchRef();
2224              cout << "Tracker      : branch TrkLevel1"<<endl;              cout << "Tracker      : branch TrkLevel1"<<endl;
2225                cout << "CreateCloneTrees " << GetTrkLevel1()<<endl;
2226          };          };
2227          if(TRK2) {          if(TRK2) {
2228              pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2"));              pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2"));
# Line 2294  void PamLevel2::CreateCloneTrees(TFile * Line 2304  void PamLevel2::CreateCloneTrees(TFile *
2304  void PamLevel2::FillCloneTrees(){  void PamLevel2::FillCloneTrees(){
2305            
2306  //    cout << "PamLevel2::FillCloneTrees()" << irunentry << endl;  //    cout << "PamLevel2::FillCloneTrees()" << irunentry << endl;
2307    
2308      for(Int_t i=0; i<NCLONES; i++){      for(Int_t i=0; i<NCLONES; i++){
2309          if(pam_tree_clone[i])pam_tree_clone[i]->Fill();          if(pam_tree_clone[i])pam_tree_clone[i]->Fill();
2310      }      }
2311      if(sel_tree_clone)sel_tree_clone->Fill();          if(sel_tree_clone)sel_tree_clone->Fill();    
 //    if( irunentry == 0 || run_tree_clone->GetEntries()==0 )run_tree_clone->Fill();  
 //    Int_t nstoredruns = run_tree_clone->GetEntries();  
 //     if( irun ==  nstoredruns )run_tree_clone->Fill();  
 //     else if( irun > nstoredruns || irun < nstoredruns-1){  
 //      cout << " PamLevel2::FillCloneTrees() -- ERROR -- current run "<< irun <<" stored runs "<< nstoredruns <<endl;  
 //     }  
2312    
2313  }  }
2314    
# Line 2345  void PamLevel2::WriteCloneTrees(){ Line 2350  void PamLevel2::WriteCloneTrees(){
2350  }  }
2351    
2352  /**  /**
2353   * Method to get both level2-trees entry and corresponding run entry.   * Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry.
2354   */   */
   
   
2355  Int_t PamLevel2::GetEntry(Int_t iee){  Int_t PamLevel2::GetEntry(Int_t iee){
2356            
2357      if(!pam_tree){      if(!pam_tree){
# Line 2401  TTree* PamLevel2::GetYodaTree( ){ Line 2404  TTree* PamLevel2::GetYodaTree( ){
2404          return NULL;          return NULL;
2405      }          }    
2406      Int_t irootnew = run_obj->ID_ROOT_L0;      Int_t irootnew = run_obj->ID_ROOT_L0;
2407  //    cout << "iroot    "<<iroot<<endl;  //     cout << "iroot    "<<iroot<<endl;
2408  //    cout << "irootnew "<<irootnew<<endl;  //     cout << "irootnew "<<irootnew<<endl;
2409    
2410      //===================================      //===================================
2411      // load the level0 file      // load the level0 file
# Line 2429  TTree* PamLevel2::GetYodaTree( ){ Line 2432  TTree* PamLevel2::GetYodaTree( ){
2432  //          cout<<"DB already connected"<<endl;  //          cout<<"DB already connected"<<endl;
2433          }          }
2434          GL_ROOT glroot = GL_ROOT();          GL_ROOT glroot = GL_ROOT();
2435          if( glroot.Query_GL_ROOT(iroot,dbc) )return NULL;          if( glroot.Query_GL_ROOT(iroot,dbc) ){
2436                cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl;
2437                return NULL;
2438            };
2439          TString filename = glroot.PATH + glroot.NAME;          TString filename = glroot.PATH + glroot.NAME;
2440          if(l0_file){          if(l0_file){
2441              l0_file->Close();              l0_file->Close();
# Line 2469  TTree* PamLevel2::GetYodaTree( ){ Line 2475  TTree* PamLevel2::GetYodaTree( ){
2475    
2476      };      };
2477    
2478    //    cout << l0_tree << endl;
2479        
2480      return l0_tree;      return l0_tree;
2481    
2482  }  }
# Line 2485  Int_t PamLevel2::GetYodaEntry(){ Line 2493  Int_t PamLevel2::GetYodaEntry(){
2493      //  if file is NOT a preselected file      //  if file is NOT a preselected file
2494      //  ---------------------------------      //  ---------------------------------
2495      Int_t quellagiusta = irunentry + run_obj->EV_FROM;      Int_t quellagiusta = irunentry + run_obj->EV_FROM;
2496      //  ------------------------------------------  
2497      //  otherwise read the "preselected-list" tree      if( !GetOrbitalInfo() ){
2498      //  ------------------------------------------          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl;
2499            return 0;
2500        }
2501    
2502        // ---------------------------------------------------------------------
2503        // ATTENTION!!!
2504        // If data are not pre-processed with cleaner, the level0 tree may contain
2505        // spurious nested physics packets.
2506        // The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries
2507        // while level2 tree DOES NOT!!
2508        // This means that "quellagiusta" in these cases is not correct.
2509        // In order to retrieve the correct level0 event, I implemented a check
2510        // of the OBT and pkt-number. In case of mismatch, the level0 entry number
2511        // is shift forward until when the packets match.
2512        // ---------------------------------------------------------------------
2513        Int_t answer = 0;
2514        Int_t shift =0;
2515        do{
2516    //      if(shift>0){
2517    //          cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl;
2518    //      }
2519            answer = GetYodaTree()->GetEntry(quellagiusta+shift);
2520            shift++;
2521            if( !GetEventHeader() ){
2522                cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl;
2523                return 0;
2524            }
2525    //      if( (quellagiusta+shift) == GetYodaTree()->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl;
2526        }while( ( (UInt_t)(GetOrbitalInfo()->OBT) != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < (UInt_t)(GetYodaTree()->GetEntries()) );
2527    
2528  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;
2529      return GetYodaTree()->GetEntry(quellagiusta);  //    return GetYodaTree()->GetEntry(quellagiusta);
2530            
2531      return 1;      return answer;
2532            
2533  }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.23