/[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.44 by mocchiut, Mon Sep 3 09:16:48 2007 UTC revision 1.45 by pam-fi, Wed Sep 12 08:14:00 2007 UTC
# Line 150  void PamLevel2::Initialize(){ Line 150  void PamLevel2::Initialize(){
150      pam_tree = NULL;      pam_tree = NULL;
151      for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL;      for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL;
152    
153        totdltime[0] = 0LL;
154        totdltime[1] = 0LL;
155    
156      host = "mysql://localhost/pamelaprod";      host = "mysql://localhost/pamelaprod";
157      user = "anonymous";      user = "anonymous";
158      psw = "";      psw = "";
# Line 391  void PamLevel2::Reset(){ Line 394  void PamLevel2::Reset(){
394    runfirstentry = 0ULL;    runfirstentry = 0ULL;
395    runlastentry = 0ULL;        runlastentry = 0ULL;    
396    //    //
397      totdltime[0] = 0LL;
398      totdltime[1] = 0LL;
399      //
400  };  };
401    
402  Bool_t PamLevel2::IsGood(){  Bool_t PamLevel2::IsGood(){
# Line 707  void PamLevel2::SortTracks(){ Line 713  void PamLevel2::SortTracks(){
713          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";
714          return;          return;
715        };        };
716          if( use_CAL && !cp &&  ci )ti_score++;
717          if( use_CAL &&  cp && !ci )tp_score++;
718        if(        if(
719           use_CAL            &&           use_CAL            &&
720  //       calo2_obj->npcfit[1] > 5     &&   //no. of fit planes on Y view  //       calo2_obj->npcfit[1] > 5     &&   //no. of fit planes on Y view
# Line 738  void PamLevel2::SortTracks(){ Line 746  void PamLevel2::SortTracks(){
746          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";
747          return;          return;
748        };        };
749          if( use_TOF && !op &&  oi )ti_score++;
750          if( use_TOF &&  op && !oi )tp_score++;
751        if( use_TOF && op && oi ){        if( use_TOF && op && oi ){
752                                    
753          //          //
# Line 2031  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2041  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2041      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2042      if(SELLI==0){      if(SELLI==0){
2043    
2044            // ---------------------------------------------------------------
2045            // increment dead and live-time counters
2046            // ---------------------------------------------------------------
2047            if( GetTrigLevel2() ){
2048                totdltime[0]+=GetTrigLevel2()->dltime[0];
2049                totdltime[1]+=GetTrigLevel2()->dltime[1];
2050            }
2051            totdltime[2]++;
2052    
2053    //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;
2054    
2055            // ---------------------------------------------------------------
2056            // retrieve OBT and absolute time of the event
2057            // ---------------------------------------------------------------
2058          ULong64_t abstime = 0;          ULong64_t abstime = 0;
2059          ULong64_t obt     = 0;          ULong64_t obt     = 0;
2060          if( GetOrbitalInfo() ){          if( GetOrbitalInfo() ){
# Line 2061  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2085  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2085          };                };      
2086    
2087          // -----------------------------------------------------------------------          // -----------------------------------------------------------------------
2088          // if it is simulation, assigh abstime by end (temporaneo!!!)          // if it is simulation, assigh abstime by hand (temporaneo!!!)
2089          // -----------------------------------------------------------------------          // -----------------------------------------------------------------------
2090          if(ISGP){          if(ISGP){
2091              abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO              abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
# Line 2090  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2114  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2114                  )                  )
2115                  && irun < run_tree->GetEntries() ){                  && irun < run_tree->GetEntries() ){
2116    
2117    
2118    
2119    
2120                // -----------------------------------------
2121                // store dead and live-time of previous run
2122                // -----------------------------------------
2123                if(fromfirst){
2124                    if(oldrun==irun){
2125                        /// decrement counters
2126                        if( GetTrigLevel2()){
2127                            totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2128                            totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2129                        }
2130                        totdltime[2]--;                              //event counter
2131                        cout << endl;
2132                        cout << "n.events     : "<<totdltime[2]<<endl;
2133                        cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2134                        cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2135                    }else{
2136                        totdltime[0]=0;//live-time
2137                        totdltime[1]=0;//dead-time
2138                        totdltime[2]=0;                             //event counter
2139                        cout << " *** JUMP RUN *** irun "<<irun<<endl;
2140                    }
2141                    /// add an entry
2142                    if(run_tree_clone)
2143                        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2144                            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2145                    /// reset counters
2146                    if( GetTrigLevel2() ){
2147                        totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2148                        totdltime[1]=0;                         //dead-time
2149                    }
2150                    totdltime[2]=1;                             //event counter
2151                }
2152    
2153    
2154              irun++;              irun++;
2155              // ------------------------------------              // ------------------------------------
2156              // if the end of run tree is reached...              // if the end of run tree is reached...
# Line 2117  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2178  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2178              // -------------------------------------------------------------------              // -------------------------------------------------------------------
2179              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2180              irunentry = 0;              irunentry = 0;
2181              prevshift = 0;              prevshift = 0;          
2182              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);      
2183              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2184                  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 2137  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2198  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2198    
2199          // --------------------------------------          // --------------------------------------
2200          // ... otherwise          // ... otherwise
2201            // --------------------------------------
2202    
2203    
2204    
2205    //      // -----------------------------------------
2206    //      // store dead and live-time of previous run
2207    //      // -----------------------------------------
2208    //      // --------------------------------------------------------------
2209    //      // if the run is empty, fill the dead-live time branch with zeros
2210    //      // --------------------------------------------------------------
2211    //      /// if some runs have been jumped, fill with zeros
2212    //      if(irun-oldrun>1){
2213    //          ULong64_t  temp[3];
2214    //          temp[0]=totdltime[0];
2215    //          temp[1]=totdltime[1];
2216    //          temp[2]=totdltime[2];
2217    //          for(int i=oldrun+1; i<irun; irun++){
2218    //              totdltime[0]=0;
2219    //              totdltime[1]=0;
2220    //              totdltime[2]=0;
2221    //              cout << " ** JUMPED RUN **"<<endl;
2222    //              if(run_tree_clone)
2223    //                  if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2224    //                      run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2225    //          }
2226    //          totdltime[0]=temp[0];
2227    //          totdltime[1]=temp[1];
2228    //          totdltime[2]=temp[2];
2229    //      }
2230    //      /// decrement counters
2231    //      if( GetTrigLevel2() ){
2232    //          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2233    //          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2234    //      }
2235    //      totdltime[2]--;                              //event counter
2236    //      /// add an entry
2237    //      if(irun>0 ){
2238    //          cout << endl;
2239    //          cout << "n.events     : "<<totdltime[2]<<endl;
2240    //          cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2241    //          cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2242    //          if(run_tree_clone)
2243    //              if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2244    //                  run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2245    //      }
2246    //      /// reset counters
2247    //      if( GetTrigLevel2() ){
2248    //          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2249    //          totdltime[1]=0;                         //dead-time
2250    //      }
2251    //      totdltime[2]=1;                             //event counter
2252            
2253    
2254            // --------------------------------------
2255          // ---> exit with TRUE          // ---> exit with TRUE
2256          // --------------------------------------          // --------------------------------------
2257          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;
# Line 2151  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2266  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2266              true ){              true ){
2267              cout << "* fragment *"<<endl;                            cout << "* fragment *"<<endl;              
2268          }          }
2269            
2270          return(true);              return(true);    
2271      };      };
2272      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Line 2831  void PamLevel2::CreateCloneTrees(TFile * Line 2946  void PamLevel2::CreateCloneTrees(TFile *
2946      }      }
2947      cout << "----------------------------------------------------"<<endl;      cout << "----------------------------------------------------"<<endl;
2948    
2949        // ------------------------------------
2950        // add branch with dead and live times
2951        // ------------------------------------
2952        run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");
2953        cout << "Run          : branch DeadLiveTime"<<endl;
2954    
2955    
2956      sel_tree_clone = new TTree("SelectionList","List of selected events ");      sel_tree_clone = new TTree("SelectionList","List of selected events ");
2957      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
# Line 2957  TTree* PamLevel2::GetCloneTree(TString n Line 3078  TTree* PamLevel2::GetCloneTree(TString n
3078  void PamLevel2::WriteCloneTrees(){  void PamLevel2::WriteCloneTrees(){
3079      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
3080      cout << "Write clones of PAMELA trees "<<endl;      cout << "Write clones of PAMELA trees "<<endl;
3081      cout << run_tree_clone->GetName()<<endl;          cout << run_tree_clone->GetName()<<endl;  
3082        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
3083            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
3084      run_tree_clone->Write();      run_tree_clone->Write();
3085      cout << sel_tree_clone->GetName()<<endl;          cout << sel_tree_clone->GetName()<<endl;    
3086      sel_tree_clone->Write();      sel_tree_clone->Write();
# Line 3297  Bool_t PamLevel2::SetDBConnection(){ Line 3420  Bool_t PamLevel2::SetDBConnection(){
3420      return true;      return true;
3421    
3422  }  }
3423    
3424    /**
3425     * \Brief Add a friend to the pamela chain.
3426     * @param cname name of the chain to be added
3427     */
3428    
3429    TChain* PamLevel2::AddFriend(TString cname){
3430    
3431        if(!GetPamTree()){
3432            cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<<endl;
3433            return NULL;
3434        }
3435    
3436    
3437        TChain *c = new TChain( cname.Data() );
3438    
3439        TIter next( GetPamTree()->GetListOfFiles() );
3440        Int_t nf = 0;
3441        TChainElement* element = 0;    
3442        while ((element = (TChainElement*) next())) {      
3443            c->Add(element->GetTitle());
3444            nf++;
3445        }
3446    
3447        GetPamTree()->AddFriend(cname.Data());
3448    
3449        cout << "external chain created and added to pamela friends :"<<cname<<endl;
3450        cout << "n.files "<<nf<<endl;
3451        
3452    
3453        return c;    
3454    
3455    }

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.23