/[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.70 by mocchiut, Wed Dec 10 11:56:35 2008 UTC revision 1.80 by pam-fi, Wed Mar 25 14:42:36 2009 UTC
# Line 308  PamTrack::PamTrack(TrkTrack* t, CaloTrkV Line 308  PamTrack::PamTrack(TrkTrack* t, CaloTrkV
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;      if(r) orb_track  = r;
312      candeleteobj = 0;  
313       candeleteobj = 0;
314    
315  };  };
316  PamTrack::PamTrack(const PamTrack& track){  PamTrack::PamTrack(const PamTrack& track){
# Line 396  PamLevel2::PamLevel2(){ Line 397  PamLevel2::PamLevel2(){
397   * If no options are specified, the default is assumed. Default is:   * If no options are specified, the default is assumed. Default is:
398   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB
399   */   */
400  PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){  PamLevel2::PamLevel2(TString ddir,TString llist,TString detlist){
401      Initialize();      Initialize();
402      TList*  listf = GetListOfLevel2Files(ddir,list);      TList*  listf = GetListOfLevel2Files(ddir,llist);
403      GetPamTree(listf,detlist);      if(listf)GetPamTree(listf,detlist);
404      GetRunTree(listf);      if(listf)GetRunTree(listf);
405  };  };
406    
407  PamLevel2::PamLevel2(TString ddir,TList *list,TString detlist){  PamLevel2::PamLevel2(TString ddir,TList *llist,TString detlist){
408      Initialize();      Initialize();
409      GetPamTree(list,detlist);      GetPamTree(llist,detlist);
410      GetRunTree(list);      GetRunTree(llist);
411  };  };
412  /**  /**
413   * Constructor   * Constructor
# Line 415  PamLevel2::PamLevel2(TString ddir,TList Line 416  PamLevel2::PamLevel2(TString ddir,TList
416   * Default trees/branches are loaded. Default is:   * Default trees/branches are loaded. Default is:
417   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB
418   */   */
419  PamLevel2::PamLevel2(TString ddir,TString list){  PamLevel2::PamLevel2(TString ddir,TString llist){
420      Initialize();      Initialize();
421      TList*  listf = GetListOfLevel2Files(ddir,list);      TList*  listf = GetListOfLevel2Files(ddir,llist);
422      GetPamTree(listf,"");      GetPamTree(listf,"");
423      GetRunTree(listf);      GetRunTree(listf);
424  };  };
# Line 448  void PamLevel2::Initialize(){ Line 449  void PamLevel2::Initialize(){
449      irunt = -1LL;      irunt = -1LL;
450      runfirstentry = 0LL;      runfirstentry = 0LL;
451      runlastentry = 0LL;      runlastentry = 0LL;
452        gltsync = 0; // Emiliano
453    
454      l0_file = NULL;      l0_file = NULL;
455      l0_tree = NULL;      l0_tree = NULL;
# Line 557  void PamLevel2::Delete(){ Line 559  void PamLevel2::Delete(){
559          dbc->Close();          dbc->Close();
560          delete dbc;          delete dbc;
561      }      }
562    
563        if ( gltsync ) delete gltsync;
564            
565      if(l0_file)l0_file->Close();      if(l0_file)l0_file->Close();
566      //    if(pam_tree)pam_tree->Delete();;      //    if(pam_tree)pam_tree->Delete();;
# Line 736  Bool_t PamLevel2::IsGood(Bool_t strict){ Line 740  Bool_t PamLevel2::IsGood(Bool_t strict){
740      if(trig_obj && trig_obj->unpackError != 0) goodev = false;      if(trig_obj && trig_obj->unpackError != 0) goodev = false;
741      if(s4_obj && s4_obj->unpackError != 0) goodev = false;        if(s4_obj && s4_obj->unpackError != 0) goodev = false;  
742      if(nd_obj && nd_obj->unpackError != 0) goodev = false;        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;            if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false;      
744      //  if(orb_obj)        //  if(orb_obj)  
745    } else {    } else {
746      if(nd_obj && nd_obj->unpackError != 0) goodev = false;        if(nd_obj && nd_obj->unpackError != 0) goodev = false;  
747      if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>3)&1) || ((ac_obj->status[0]>>3)&1)) ) goodev = false;            if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false;      
748    };    };
749    return(goodev);    return(goodev);
750  };  };
# Line 808  void *PamLevel2::GetPointerTo(const char Line 812  void *PamLevel2::GetPointerTo(const char
812          if(!ac_obj)    ac_obj    = new AcLevel2();          if(!ac_obj)    ac_obj    = new AcLevel2();
813          return &ac_obj;          return &ac_obj;
814      };      };
815      if(!objname.CompareTo("OrbitalInfo")){      if(!objname.CompareTo("OrbitalInfo"))  {
816          if(!orb_obj)   orb_obj   = new OrbitalInfo();          if(!orb_obj){
817                orb_obj   = new OrbitalInfo();
818                orb_obj->Set();
819            }
820          return &orb_obj;          return &orb_obj;
821      };      };
822    //     if(!objname.CompareTo("OrbitalInfo")){
823    //      if(!orb_obj)   orb_obj   = new OrbitalInfo();
824    //      return &orb_obj;
825    //     };
826      if(!objname.CompareTo("GPamela")){      if(!objname.CompareTo("GPamela")){
827          if(!gp_obj)   gp_obj   = new GPamela();          if(!gp_obj)   gp_obj   = new GPamela();
828          return &gp_obj;          return &gp_obj;
# Line 900  OrbitalInfoTrkVar *PamLevel2::GetOrbital Line 911  OrbitalInfoTrkVar *PamLevel2::GetOrbital
911                    
912      if( !orb_obj )return 0;      if( !orb_obj )return 0;
913    
914    
915      if( orb_obj->OrbitalInfo::ntrk()==0 ){      if( orb_obj->OrbitalInfo::ntrk()==0 ){
916          cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<<endl;  //       // TRICK BEGIN
917          return NULL;  //       OrbitalInfoTrkVar  *r = new OrbitalInfoTrkVar(); // TEMPORARY TRICK
918    //       Int_t nn = 0;
919    //       TClonesArray &tor = *orb_obj->OrbitalInfoTrk;
920    //       for(Int_t nt=0; nt < tof_obj->ToFLevel2::ntrk(); nt++){  
921    //      //
922    //      ToFTrkVar *ptt = tof_obj->ToFLevel2::GetToFTrkVar(nt);
923    //      if ( ptt->trkseqno != -1  ){
924    //        //
925    //        r->trkseqno = ptt->trkseqno;
926    //        //
927    //        r->Eij = 0;  
928    //        //
929    //        r->Sij = 0;
930    //        //        
931    //        r->pitch = -1000.;
932    //        //
933    //        r->cutoff = -1000.;
934    //        //
935    //        new(tor[nn]) OrbitalInfoTrkVar(*r);
936    //        nn++;
937    //        //
938    //        r->Clear();
939    //        //
940    //      };
941    //       };
942    //       delete r;
943    //       OrbitalInfoTrkVar *c = 0;
944    //       c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0);
945    //       return c;
946    //       //TRICK END
947          cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<<endl;
948          return NULL;
949      };      };
950            
951      OrbitalInfoTrkVar *c = 0;      OrbitalInfoTrkVar *c = 0;
# Line 1664  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1707  TTree *PamLevel2::GetPamTree(TFile *f, T
1707      if(ORB)cout<<"ORB ";      if(ORB)cout<<"ORB ";
1708      if(GP)cout<<"GP ";      if(GP)cout<<"GP ";
1709      cout << endl;      cout << endl;
1710      if(SELLI)cout<<">>> Found selection-list <<<"<<endl;      if(SELLI && SELLI!=2)cout<<">>> Found selection-list <<<"<<endl; //EMILIANO
1711    
1712      f->cd();      f->cd();
1713    
# Line 1824  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1867  TTree *PamLevel2::GetPamTree(TFile *f, T
1867  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){
1868                    
1869      TString wdir = gSystem->WorkingDirectory();      TString wdir = gSystem->WorkingDirectory();
1870        
     //    if(ddir=="")ddir = wdir;  
 //      TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);  
1871      if ( ddir != ""){      if ( ddir != ""){
1872          cout << "Level2 data directory : "<<  ddir << endl;          cout << "Level2 data directory : "<<  ddir << endl;
1873      } else {      } else {
# Line 1835  TList*  PamLevel2::GetListOfLevel2Files( Line 1876  TList*  PamLevel2::GetListOfLevel2Files(
1876      TList *contents  = new TList; // create output list      TList *contents  = new TList; // create output list
1877      contents->SetOwner();      contents->SetOwner();
1878            
1879  //    char *fullpath;      // --------------------------------------
1880  //    const char *fullpath;      // case 1 : input file/file-list provided
1881            // --------------------------------------
     // if no input file list is given:    
1882      if ( flisttxt != "" ){      if ( flisttxt != "" ){
1883                    
1884  //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){                  // --------------------------------------
1885  //      if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){          // a list of files given as input
1886  //          cout <<"File "<<flisttxt<<" not found"<<endl;          // --------------------------------------
 //          return 0;  
 //      }        
 //      flisttxt = fullpath;  
1887          if ( !flisttxt.EndsWith(".root") ){          if ( !flisttxt.EndsWith(".root") ){
1888    
1889              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));              TString dir = gSystem->DirName(flisttxt);
1890    //          cout << " List directory "<<dir<<endl;
1891                if(dir == "." || dir == "")
1892                    flisttxt = gSystem->ConcatFileName(wdir.Data(),gSystem->BaseName(flisttxt));
1893    //              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
1894    
1895              if( !gSystem->ChangeDirectory(ddir) ){              if( !gSystem->ChangeDirectory(ddir) ){
1896                  cout << "Cannot change directory : "<<ddir<<endl;                  cout << "Cannot change directory : "<<ddir<<endl;
# Line 1860  TList*  PamLevel2::GetListOfLevel2Files( Line 1901  TList*  PamLevel2::GetListOfLevel2Files(
1901              ifstream in;              ifstream in;
1902              in.open(flisttxt, ios::in); //open input file list              in.open(flisttxt, ios::in); //open input file list
1903              if(!in.good()){              if(!in.good()){
1904                  cout <<" ERROR opening the file "<<endl;                  cout <<" TList*  PamLevel2::GetListOfLevel2Files(TString, TString) --> ERROR opening the file "<<endl;
1905                  gSystem->ChangeDirectory(wdir); // back to the working directory                  gSystem->ChangeDirectory(wdir); // back to the working directory
1906                  return 0;                  return 0;
1907              }                }  
1908              int line=0;              int line=0;
1909                // ...........................
1910                // loop over file-list records
1911                // ...........................
1912              while (1) {              while (1) {
1913                  TString file;                  TString file;
1914                  in >> file;                  in >> file;
1915                  if (!in.good()) break;                  if (!in.good()) break;
1916                  line++;                  line++;
1917  //          cout <<"(1) " << file << endl;                  cout <<"(*) " << file << endl;
1918                  if(file.IsNull()){                  if(file.IsNull()){
1919                      cout << "-- list interrupted at line "<<line <<endl;                      cout << "-- list interrupted at line "<<line <<endl;
1920                      break;                      break;
1921                  }                  }
1922                  if(file.Contains("#"))file = file(0,file.First("#"));                  if(file.Contains("#"))file = file(0,file.First("#"));
1923  //          cout <<"(2) " << file << endl;                  //
1924  //          if( gSystem->IsFileInIncludePath(file,&fullpath) ){                  // take only root files
1925  //          if( (fullpath = gSystem->FindFile(ddir,file)) ){                  //
1926                  if( file.EndsWith(".root") ){                  if( file.EndsWith(".root") ){
1927                      TString filedir;                      TString filedir;
1928                        cout << ddir << endl;
1929                      if (ddir != ""){                      if (ddir != ""){
1930                          filedir = ddir; // take the input dir                          filedir = ddir; // take the input dir
1931                      } else {                      } else {
1932                          gSystem->ChangeDirectory(wdir); // back to the working directory                          gSystem->ChangeDirectory(wdir); // back to the working directory
1933                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir
1934                      };                      };
1935                        filedir.Append("/");
1936                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));
1937                      contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list                      contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
1938                        cout << fullpath << endl;
1939                      delete fullpath;                      delete fullpath;
1940                  }                  }
1941  //          }else{  //          }else{
# Line 1896  TList*  PamLevel2::GetListOfLevel2Files( Line 1943  TList*  PamLevel2::GetListOfLevel2Files(
1943  //          };  //          };
1944              };              };
1945              in.close();              in.close();
1946            // --------------------------------------
1947            // a single root file given as input
1948            // --------------------------------------
1949          } else {          } else {
1950              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));
1951              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
1952              contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list              contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
1953              delete fullpath;              delete fullpath;
1954          };                };      
1955        // ---------------------------------------------------------------------------------
1956        // case 2 : no input file/file-list provided --> read all files insede the directory
1957        // ---------------------------------------------------------------------------------
1958      }else{      }else{
1959                    
1960          cout << "No input file list given."<<endl;          cout << "No input file list given."<<endl;
# Line 1914  TList*  PamLevel2::GetListOfLevel2Files( Line 1967  TList*  PamLevel2::GetListOfLevel2Files(
1967    
1968          TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);          TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);
1969          TList *temp = datadir->GetListOfFiles();          TList *temp = datadir->GetListOfFiles();
1970            if(!temp)return 0;
1971  //              temp->Print();  //              temp->Print();
1972  //              cout << "*************************************" << endl;  //              cout << "*************************************" << endl;
1973                    
# Line 2592  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2646  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2646          prevshift = 0;          prevshift = 0;
2647          run_tree->GetEntry(irun);          run_tree->GetEntry(irun);
2648          if( !GetOrbitalInfo() )cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated "<<endl;          if( !GetOrbitalInfo() )cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated "<<endl;
2649            if ( gltsync ) delete gltsync; //Emiliano
2650            if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection(); //Emiliano
2651            gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); //Emiliano // the "false" means not to use level0 file (not necessary here)
2652            if ( dbc ) dbc->Close();// Emiliano
2653      };            };      
2654      // ---------------------------------------------------------------      // ---------------------------------------------------------------
2655      // retrieve OBT and absolute time of the event      // retrieve OBT and absolute time of the event
2656      // ---------------------------------------------------------------      // ---------------------------------------------------------------
2657      ULong64_t abstime = 0LL;      ULong64_t abstime = 0LL;
2658      ULong64_t obt     = 0LL;      //    ULong64_t obt     = 0LL; // Emiliano
2659        Long64_t obt     = 0LL; // Emiliano, Long64_t GL_TIMESYNC::DBobt(UInt_t obt) since depending on the situation OBT is lowered or boosted
2660      if( GetOrbitalInfo() ){      if( GetOrbitalInfo() ){
2661          abstime = GetOrbitalInfo()->absTime;          abstime = GetOrbitalInfo()->absTime;
2662          obt     = GetOrbitalInfo()->OBT;          obt     = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano
2663      }else{      }else{
2664          abstime = GetRunInfo()->RUNHEADER_TIME;          abstime = GetRunInfo()->RUNHEADER_TIME;
2665          obt     = GetRunInfo()->RUNHEADER_OBT;          obt     = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano
2666      }      }
2667            
2668    
2669      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2670      // if it is a full file (not preselected)      // if it is a full file (not preselected)
2671      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2672      if(SELLI==0){      if(SELLI==0 || SELLI==2){ // Emiliano
2673    
2674          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2675          // increment dead and live-time counters          // increment dead and live-time counters
# Line 2643  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2702  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2702                  !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)                  !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2703                    abstime <= GetRunInfo()->RUNTRAILER_TIME)                    abstime <= GetRunInfo()->RUNTRAILER_TIME)
2704                  ||                  ||
2705                  !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)                  !(obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) &&         // additional check on OBT (ms) // Emiliano
2706                    obt <= GetRunInfo()->RUNTRAILER_OBT)                              obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT))           // Emiliano
2707                  ||                  ||
2708                  GetRunInfo()->NEVENTS==0                  GetRunInfo()->NEVENTS==0
2709  //              || !(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
# Line 2667  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2726  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2726              // store dead and live-time of previous run              // store dead and live-time of previous run
2727              // -----------------------------------------              // -----------------------------------------
2728  //          if(SELLI==0){  //          if(SELLI==0){
2729              if(SELLI!=2){
2730              if(fromfirst){              if(fromfirst){
2731                  if(oldrun==irun){                  if(oldrun==irun){
2732                      /// decrement counters                      /// decrement counters
# Line 2675  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2735  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2735                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2736                      }                      }
2737                      totdltime[2]--;                              //event counter                      totdltime[2]--;                              //event counter
2738                      cout << endl;                      if(DBG){
2739                      cout << "n.events     : "<<totdltime[2]<<endl;                          cout << endl;
2740                      cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;                          cout << "n.events     : "<<totdltime[2]<<endl;
2741                      cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;                                cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2742                            cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;          
2743                        }
2744                  }else{                  }else{
2745                      totdltime[0]=0;//live-time                      totdltime[0]=0;//live-time
2746                      totdltime[1]=0;//dead-time                      totdltime[1]=0;//dead-time
2747                      totdltime[2]=0;                             //event counter                      totdltime[2]=0;                             //event counter
2748                      cout << " *** JUMP RUN *** irun "<<irun<<endl;                      if(DBG)cout << " *** JUMP RUN *** irun "<<irun<<endl;
2749                  }                  }
2750                  /// add an entry                  /// add an entry
2751                  if(run_tree_clone)                  if(run_tree_clone)
# Line 2696  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2758  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2758                  }                  }
2759                  totdltime[2]=1;                             //event counter                  totdltime[2]=1;                             //event counter
2760              }              }
2761  //          }            }
2762              //        }
2763    
2764              irun++;                      irun++;        
2765              // ------------------------------------              // ------------------------------------
# Line 2728  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2791  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2791              prevshift = 0;                        prevshift = 0;          
2792              run_tree->GetEntry(irun);//update runinfo              run_tree->GetEntry(irun);//update runinfo
2793              irunt = irun - irunoffset[run_tree->GetTreeNumber()];              irunt = irun - irunoffset[run_tree->GetTreeNumber()];
2794              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if ( gltsync ) delete gltsync; // Emiliano
2795                if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection(); //Emiliano
2796                gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); // Emiliano
2797                if ( dbc ) dbc->Close(); // Emiliano
2798                if(gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT)>gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ){ // Emiliano
2799                  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;
2800                  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;
2801              }              }
# Line 3069  void  PamLevel2::GetWhichTrees(TFile* f) Line 3136  void  PamLevel2::GetWhichTrees(TFile* f)
3136      }      }
3137    
3138      TList *lk = f->GetListOfKeys();      TList *lk = f->GetListOfKeys();
3139        if(!lk)return;
3140      TIter next(lk);      TIter next(lk);
3141      TKey *key =0;      TKey *key =0;
3142    
# Line 3391  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3459  Bool_t  PamLevel2::CheckLevel2File(TStri
3459              if(GP){              if(GP){
3460                  Int_t nevt = ((TTree*)f->Get("h20"))->GetEntries();                  Int_t nevt = ((TTree*)f->Get("h20"))->GetEntries();
3461                  if( nev && nevt!=nev){                  if( nev && nevt!=nev){
3462                      cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl;                      cout << "File: "<< f->GetName() <<" discarded ---- h20 tree has "<<nevt<<" events instead of "<<nev<< endl;
3463                      return false;                      return false;
3464                  }                  }
3465                  nev=nevt;                  nev=nevt;
# Line 3594  void PamLevel2::CreateCloneTrees(TFile * Line 3662  void PamLevel2::CreateCloneTrees(TFile *
3662      // ------------------------------------      // ------------------------------------
3663      // add branch with dead and live times      // add branch with dead and live times
3664      // ------------------------------------      // ------------------------------------
3665      run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");      if ( SELLI != 2 ){ // EMILIANO
3666      cout << "Run          : branch DeadLiveTime"<<endl;        run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");
3667          cout << "Run          : branch DeadLiveTime"<<endl;
3668    
3669    
3670      sel_tree_clone = new TTree("SelectionList","List of selected events ");        sel_tree_clone = new TTree("SelectionList","List of selected events ");
3671  //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");        //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
3672      sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW        sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW
3673      sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");        sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");
3674            };
3675    
3676      Int_t i=0;      Int_t i=0;
3677      if(TRK1||TRK2||TRKh){      if(TRK1||TRK2||TRKh){
# Line 3675  void PamLevel2::CreateCloneTrees(TFile * Line 3744  void PamLevel2::CreateCloneTrees(TFile *
3744      };      };
3745      // OrbitalInfo      // OrbitalInfo
3746      if(ORB) {      if(ORB) {
3747          pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info  ");            pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA orbital info  ");  
3748          pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo"));          pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo"));
3749          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;
3750          i++;          i++;
3751      };      };
3752      // GPamela      // GPamela
3753      if(GP) {      if(GP) {
3754          pam_tree_clone[i] = new TTree("h20","PAMELA oribital info  ");            pam_tree_clone[i] = new TTree("h20","GPAMELA info ");  
3755          pam_tree_clone[i]->Branch("GPamela","GPamela", GetPointerTo("GPamela"),32000,1);//split          pam_tree_clone[i]->Branch("GPamela","GPamela", GetPointerTo("GPamela"),32000,1);//split
3756          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;
3757          i++;          i++;
# Line 3732  void PamLevel2::WriteCloneTrees(){ Line 3801  void PamLevel2::WriteCloneTrees(){
3801      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
3802      cout << "Write clones of PAMELA trees "<<endl;      cout << "Write clones of PAMELA trees "<<endl;
3803      cout << run_tree_clone->GetName()<<endl;        cout << run_tree_clone->GetName()<<endl;  
3804      if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())      if ( SELLI != 2){// Emiliano
3805          if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
3806          run_tree_clone->GetBranch("DeadLiveTime")->Fill();          run_tree_clone->GetBranch("DeadLiveTime")->Fill();
3807        };
3808      run_tree_clone->Write();      run_tree_clone->Write();
3809      cout << sel_tree_clone->GetName()<<endl;          if ( SELLI != 2){ //Emiliano
3810      sel_tree_clone->Write();        cout << sel_tree_clone->GetName()<<endl;    
3811          sel_tree_clone->Write();
3812        };
3813      for(Int_t i=0; i<NCLONES; i++){          for(Int_t i=0; i<NCLONES; i++){    
3814          if(pam_tree_clone[i]){          if(pam_tree_clone[i]){
3815              cout << pam_tree_clone[i]->GetName()<<endl;              cout << pam_tree_clone[i]->GetName()<<endl;
# Line 3774  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3847  Int_t PamLevel2::GetEntry(Long64_t iee){
3847      //-------------------------------      //-------------------------------
3848      ii = iee;      ii = iee;
3849      if( !pam_tree->GetEntry(ii) ){            if( !pam_tree->GetEntry(ii) ){      
3850          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl;        cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl;
3851          return 0;        return 0;
3852      }      }
   
3853      //      //
3854      // ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0.      // ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0.
3855      // 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
# Line 3797  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3869  Int_t PamLevel2::GetEntry(Long64_t iee){
3869  //    Bool_t UPDATED = UpdateRunInfo(run_tree,ii);  //    Bool_t UPDATED = UpdateRunInfo(run_tree,ii);
3870  //    Bool_t UPDATED = UpdateRunInfo(ii);  //    Bool_t UPDATED = UpdateRunInfo(ii);
3871      UpdateRunInfo(ii);      UpdateRunInfo(ii);
3872      if(SELLI==0)irunentry = iee-runfirstentry;      if(SELLI==0||SELLI==2)irunentry = iee-runfirstentry;
3873  //    if(UPDATED && run_tree_clone)run_tree_clone->Fill();  //    if(UPDATED && run_tree_clone)run_tree_clone->Fill();
3874        
3875  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;

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

  ViewVC Help
Powered by ViewVC 1.1.23