/[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.97 by pam-fi, Fri Oct 17 06:54:11 2014 UTC revision 1.101 by mocchiut, Fri Oct 17 16:04:42 2014 UTC
# Line 566  void PamLevel2::Initialize() { Line 566  void PamLevel2::Initialize() {
566    
567    run_obj = 0;//new GL_RUN();    run_obj = 0;//new GL_RUN();
568    soft_obj = 0;// Emiliano    soft_obj = 0;// Emiliano
569      proc_obj = 0;// Emiliano
570    irun = -1LL;    irun = -1LL;
571    irunt = -1LL;    irunt = -1LL;
572    totrunentry = 0LL;    totrunentry = 0LL;
# Line 576  void PamLevel2::Initialize() { Line 577  void PamLevel2::Initialize() {
577    gltsync = 0; // Emiliano    gltsync = 0; // Emiliano
578    fUpdateRunInfo = true; // Emiliano    fUpdateRunInfo = true; // Emiliano
579    fUseDBinRunInfo = true; // Emiliano    fUseDBinRunInfo = true; // Emiliano
580      fDiscarded = false; //EM
581    isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events    isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events
582    il0entry = 0LL;    il0entry = 0LL;
583    //  hasL0EE = true;    //  hasL0EE = true;
# Line 591  void PamLevel2::Initialize() { Line 593  void PamLevel2::Initialize() {
593    
594    run_tree = NULL;    run_tree = NULL;
595    run_tree_clone = NULL;    run_tree_clone = NULL;
596    
597      proc_tree = NULL;
598      proc_tree_clone = NULL;
599    
600    sel_tree = NULL;    sel_tree = NULL;
601    sel_tree_clone = NULL;    sel_tree_clone = NULL;
602    
# Line 638  void PamLevel2::Initialize() { Line 644  void PamLevel2::Initialize() {
644    ND = true;    ND = true;
645    AC = true;    AC = true;
646    ORB = true;    ORB = true;
647      PROC = true;
648    GP = false;    GP = false;
649    
650    EXT = false;    EXT = false;
# Line 680  void PamLevel2::Delete() { Line 687  void PamLevel2::Delete() {
687      delete run_obj;      delete run_obj;
688    if (soft_obj)    if (soft_obj)
689      delete soft_obj; //Emiliano      delete soft_obj; //Emiliano
690      if (proc_obj)
691        delete proc_obj; //Emiliano
692    
693    //    cout << "void PamLevel2::Clear()"<<endl;    //    cout << "void PamLevel2::Clear()"<<endl;
694    if (h0_obj)    if (h0_obj)
# Line 880  void PamLevel2::Clear() { Line 889  void PamLevel2::Clear() {
889      orb2_obj->Clear();      orb2_obj->Clear();
890    if (gp_obj)    if (gp_obj)
891      gp_obj->Clear();      gp_obj->Clear();
892      if (proc_obj)
893        proc_obj->Clear();
894    
895    //    if(sorted_tracks)sorted_tracks->Clear();    //    if(sorted_tracks)sorted_tracks->Clear();
896    //    sorted_tracks.Clear();    //    sorted_tracks.Clear();
# Line 983  void PamLevel2::Reset() { Line 994  void PamLevel2::Reset() {
994    ac_obj = 0;    ac_obj = 0;
995    orb2_obj = 0;    orb2_obj = 0;
996    gp_obj = 0;    gp_obj = 0;
997      proc_obj = 0;
998    
999    trk_ext_obj     = 0;    trk_ext_obj     = 0;
1000    trk_ext_nuc_obj = 0;    trk_ext_nuc_obj = 0;
# Line 1014  void PamLevel2::Reset() { Line 1026  void PamLevel2::Reset() {
1026    //    //
1027    run_obj = 0;//new GL_RUN();    run_obj = 0;//new GL_RUN();
1028    soft_obj = 0;// Emiliano    soft_obj = 0;// Emiliano
1029      proc_obj = 0;// Emiliano
1030    irun = -1;    irun = -1;
1031    irunt = -1;    irunt = -1;
1032    totrunentry = 0LL;    totrunentry = 0LL;
# Line 1188  void *PamLevel2::GetPointerTo(const char Line 1201  void *PamLevel2::GetPointerTo(const char
1201    if (!objname.CompareTo("SoftInfo"))    if (!objname.CompareTo("SoftInfo"))
1202      return &soft_obj; // Emiliano      return &soft_obj; // Emiliano
1203    
1204      if (!objname.CompareTo("ProcInfo")){
1205        if (!proc_obj)
1206          proc_obj = new ProcInfo();    
1207        return &proc_obj; // Emiliano
1208      }
1209    
1210    return NULL;    return NULL;
1211  }  }
1212  ;  ;
# Line 3303  TChain *PamLevel2::GetPamTree(TList *fl, Line 3322  TChain *PamLevel2::GetPamTree(TList *fl,
3322    TChain *G = 0;    TChain *G = 0;
3323    
3324    TChain *L = 0;    TChain *L = 0;
3325      TChain *P = 0;
3326    
3327    if (TRK2 || TRK1 || TRKh)    if (TRK2 || TRK1 || TRKh)
3328      T = new TChain("Tracker");      T = new TChain("Tracker");
# Line 3322  TChain *PamLevel2::GetPamTree(TList *fl, Line 3342  TChain *PamLevel2::GetPamTree(TList *fl,
3342      B = new TChain("OrbitalInfo");      B = new TChain("OrbitalInfo");
3343    if (GP)    if (GP)
3344      G = new TChain("h20");      G = new TChain("h20");
3345      if (PROC)
3346        P = new TChain("ProcessingInfo");
3347    L = new TChain("SelectionList");    L = new TChain("SelectionList");
3348    
3349    // loop over files and create chains    // loop over files and create chains
# Line 3349  TChain *PamLevel2::GetPamTree(TList *fl, Line 3371  TChain *PamLevel2::GetPamTree(TList *fl,
3371          B->Add(name);          B->Add(name);
3372        if (GP)        if (GP)
3373          G->Add(name);          G->Add(name);
3374          if (P)
3375            P->Add(name);
3376        if (SELLI == 1)        if (SELLI == 1)
3377          L->Add(name);          L->Add(name);
3378       };       };
# Line 3474  TChain *PamLevel2::GetPamTree(TList *fl, Line 3498  TChain *PamLevel2::GetPamTree(TList *fl,
3498        L->Delete();        L->Delete();
3499    };    };
3500    
3501      //ProcessingInfo EM
3502      if ( P && P->GetEntries() ){
3503        cout << "----------------------------------------------------" << endl;
3504        cout << ">>> Found ProcessingInfo <<<" << endl;
3505        //  L->SetBranchAddress("RunEntry",&irun);
3506        P->SetBranchAddress("ProcInfo", &proc_obj);//NEWNEW
3507      }
3508    //  --------------------------------------------    //  --------------------------------------------
3509    //  return the pamela chain with all the friends    //  return the pamela chain with all the friends
3510    //  --------------------------------------------    //  --------------------------------------------
# Line 4571  void PamLevel2::GetWhichTrees(TFile* f) Line 4602  void PamLevel2::GetWhichTrees(TFile* f)
4602    //    cout << "Checking file: "<<f->GetName()<<endl;    //    cout << "Checking file: "<<f->GetName()<<endl;
4603    if (!f || f->IsZombie()) {    if (!f || f->IsZombie()) {
4604      cout << "File: " << f->GetName() << " Non valid root file" << endl;      cout << "File: " << f->GetName() << " Non valid root file" << endl;
4605        fDiscarded = true;
4606      return;      return;
4607    }    }
4608    
# Line 4777  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4809  Bool_t PamLevel2::CheckLevel2File(TStrin
4809    TFile *f = new TFile(name.Data());    TFile *f = new TFile(name.Data());
4810    if (!f || f->IsZombie()) {    if (!f || f->IsZombie()) {
4811      cout << "File: " << f->GetName() << " discarded ---- Non valid root file" << endl;      cout << "File: " << f->GetName() << " discarded ---- Non valid root file" << endl;
4812        fDiscarded = true;
4813      return false;      return false;
4814    }    }
4815    //    cout << "Get list of keys: "<<f<<endl;    //    cout << "Get list of keys: "<<f<<endl;
# Line 4815  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4848  Bool_t PamLevel2::CheckLevel2File(TStrin
4848          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4849            cout << "File: " << f->GetName() << " discarded ---- SelectionList tree has " << nevt            cout << "File: " << f->GetName() << " discarded ---- SelectionList tree has " << nevt
4850                << " events instead of " << nev << endl;                << " events instead of " << nev << endl;
4851              fDiscarded = true;
4852            return false;            return false;
4853          }          }
4854          nev = nevt;          nev = nevt;
# Line 4829  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4863  Bool_t PamLevel2::CheckLevel2File(TStrin
4863          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4864            cout << "File: " << f->GetName() << " discarded ---- Trigger tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- Trigger tree has " << nevt << " events instead of "
4865                << nev << endl;                << nev << endl;
4866              fDiscarded = true;
4867            return false;            return false;
4868          }          }
4869          nev = nevt;          nev = nevt;
# Line 4842  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4877  Bool_t PamLevel2::CheckLevel2File(TStrin
4877          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4878            cout << "File: " << f->GetName() << " discarded ---- ToF tree has " << nevt << " events instead of " << nev            cout << "File: " << f->GetName() << " discarded ---- ToF tree has " << nevt << " events instead of " << nev
4879                << endl;                << endl;
4880              fDiscarded = true;
4881            return false;            return false;
4882          }          }
4883          nev = nevt;          nev = nevt;
# Line 4855  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4891  Bool_t PamLevel2::CheckLevel2File(TStrin
4891          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4892            cout << "File: " << f->GetName() << " discarded ---- S4 tree has " << nevt << " events instead of " << nev            cout << "File: " << f->GetName() << " discarded ---- S4 tree has " << nevt << " events instead of " << nev
4893                << endl;                << endl;
4894              fDiscarded = true;
4895            return false;            return false;
4896          }          }
4897          nev = nevt;          nev = nevt;
# Line 4869  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4906  Bool_t PamLevel2::CheckLevel2File(TStrin
4906          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4907            cout << "File: " << f->GetName() << " discarded ---- NeutronD tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- NeutronD tree has " << nevt << " events instead of "
4908                << nev << endl;                << nev << endl;
4909              fDiscarded = true;
4910            return false;            return false;
4911          }          }
4912          nev = nevt;          nev = nevt;
# Line 4882  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4920  Bool_t PamLevel2::CheckLevel2File(TStrin
4920          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4921            cout << "File: " << f->GetName() << " discarded ---- Anticounter tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- Anticounter tree has " << nevt << " events instead of "
4922                << nev << endl;                << nev << endl;
4923              fDiscarded = true;
4924            return false;            return false;
4925          }          }
4926          nev = nevt;          nev = nevt;
# Line 4895  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4934  Bool_t PamLevel2::CheckLevel2File(TStrin
4934          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4935            cout << "File: " << f->GetName() << " discarded ---- OrbitalInfo tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- OrbitalInfo tree has " << nevt << " events instead of "
4936                << nev << endl;                << nev << endl;
4937              fDiscarded = true;
4938            return false;            return false;
4939          }          }
4940          nev = nevt;          nev = nevt;
# Line 4908  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4948  Bool_t PamLevel2::CheckLevel2File(TStrin
4948          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4949            cout << "File: " << f->GetName() << " discarded ---- Tracker tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- Tracker tree has " << nevt << " events instead of "
4950                << nev << endl;                << nev << endl;
4951              fDiscarded = true;
4952            return false;            return false;
4953          }          }
4954          nev = nevt;          nev = nevt;
# Line 4931  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4972  Bool_t PamLevel2::CheckLevel2File(TStrin
4972          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4973            cout << "File: " << f->GetName() << " discarded ---- Calorimeter tree has " << nevt << " events instead of "            cout << "File: " << f->GetName() << " discarded ---- Calorimeter tree has " << nevt << " events instead of "
4974                << nev << endl;                << nev << endl;
4975              fDiscarded = true;
4976            return false;            return false;
4977          }          }
4978          nev = nevt;          nev = nevt;
# Line 4953  Bool_t PamLevel2::CheckLevel2File(TStrin Line 4995  Bool_t PamLevel2::CheckLevel2File(TStrin
4995          if (nev && nevt != nev) {          if (nev && nevt != nev) {
4996            cout << "File: " << f->GetName() << " discarded ---- h20 tree has " << nevt << " events instead of " << nev            cout << "File: " << f->GetName() << " discarded ---- h20 tree has " << nevt << " events instead of " << nev
4997                << endl;                << endl;
4998              fDiscarded = true;
4999            return false;            return false;
5000          }          }
5001          nev = nevt;          nev = nevt;
# Line 4965  Bool_t PamLevel2::CheckLevel2File(TStrin Line 5008  Bool_t PamLevel2::CheckLevel2File(TStrin
5008      SELLI = (Int_t) SELLI__ok;      SELLI = (Int_t) SELLI__ok;
5009    if (SELLI == 0 && SELLI__ok) {    if (SELLI == 0 && SELLI__ok) {
5010      cout << "File: " << f->GetName() << " discarded ---- found SelectionList (it is not a full-event file)" << endl;      cout << "File: " << f->GetName() << " discarded ---- found SelectionList (it is not a full-event file)" << endl;
5011        fDiscarded = true;
5012      return false;      return false;
5013    }    }
5014    if (SELLI == 1 && !SELLI__ok) {    if (SELLI == 1 && !SELLI__ok) {
5015      cout << "File: " << f->GetName() << " discarded ---- SelectionList missing" << endl;      cout << "File: " << f->GetName() << " discarded ---- SelectionList missing" << endl;
5016        fDiscarded = true;
5017      return false;      return false;
5018    }    }
5019    
# Line 5007  Bool_t PamLevel2::CheckLevel2File(TStrin Line 5052  Bool_t PamLevel2::CheckLevel2File(TStrin
5052    
5053    if (CAL1 && !CAL1__ok) {    if (CAL1 && !CAL1__ok) {
5054      cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel1 branch" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel1 branch" << endl;
5055        fDiscarded = true;
5056      return false;      return false;
5057    };    };
5058    if (CAL2 && !CAL2__ok) {    if (CAL2 && !CAL2__ok) {
5059      cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel2 branch" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel2 branch" << endl;
5060        fDiscarded = true;
5061      return false;      return false;
5062    };    };
5063    if (TRK2 && !TRK2__ok) {    if (TRK2 && !TRK2__ok) {
5064      cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel2 branch" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel2 branch" << endl;
5065        fDiscarded = true;
5066      return false;      return false;
5067    };    };
5068    if (TRK1 && !TRK1__ok) {    if (TRK1 && !TRK1__ok) {
5069      cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel1 branch" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel1 branch" << endl;
5070        fDiscarded = true;
5071      return false;      return false;
5072    };    };
5073    if (TRKh && !TRKh__ok) {    if (TRKh && !TRKh__ok) {
5074      cout << "File: " << f->GetName() << " discarded ---- Missing TrkHough branch" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing TrkHough branch" << endl;
5075        fDiscarded = true;
5076      return false;      return false;
5077    };    };
5078    if (ORB && !ORB__ok) {    if (ORB && !ORB__ok) {
5079      cout << "File: " << f->GetName() << " discarded ---- Missing ORB tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing ORB tree" << endl;
5080        fDiscarded = true;
5081      return false;      return false;
5082    };    };
5083    if (AC && !AC__ok) {    if (AC && !AC__ok) {
5084      cout << "File: " << f->GetName() << " discarded ---- Missing AC tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing AC tree" << endl;
5085        fDiscarded = true;
5086      return false;      return false;
5087    };    };
5088    if (S4 && !S4__ok) {    if (S4 && !S4__ok) {
5089      cout << "File: " << f->GetName() << " discarded ---- Missing S4 tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing S4 tree" << endl;
5090        fDiscarded = true;
5091      return false;      return false;
5092    };    };
5093    if (TOF && !TOF__ok) {    if (TOF && !TOF__ok) {
5094      cout << "File: " << f->GetName() << " discarded ---- Missing ToF tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing ToF tree" << endl;
5095        fDiscarded = true;
5096      return false;      return false;
5097    };    };
5098    
5099    if (ND && !ND__ok) {    if (ND && !ND__ok) {
5100      cout << "File: " << f->GetName() << " discarded ---- Missing ND tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing ND tree" << endl;
5101        fDiscarded = true;
5102      return false;      return false;
5103    };    };
5104    if (TRG && !TRG__ok) {    if (TRG && !TRG__ok) {
5105      cout << "File: " << f->GetName() << " discarded ---- Missing Trigger tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing Trigger tree" << endl;
5106        fDiscarded = true;
5107      return false;      return false;
5108    };    };
5109    if (GP && !GP__ok) {    if (GP && !GP__ok) {
5110      cout << "File: " << f->GetName() << " discarded ---- Missing h20 tree" << endl;      cout << "File: " << f->GetName() << " discarded ---- Missing h20 tree" << endl;
5111        fDiscarded = true;
5112      return false;      return false;
5113    };    };
5114    
# Line 5151  void PamLevel2::CreateCloneTrees(TFile * Line 5208  void PamLevel2::CreateCloneTrees(TFile *
5208      //  cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;      //  cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;
5209      run_tree_clone->Fill();      run_tree_clone->Fill();
5210    }    }
5211    cout << "----------------------------------------------------" << endl;    if ( PROC ){
5212        proc_tree_clone = new TTree("ProcessingInfo","Log of data processing");
5213        proc_tree_clone->Branch("ProcInfo", "ProcInfo", GetPointerTo("ProcInfo"));
5214        cout << "ProcessingInfo: branch ProcessingInfo" << endl;  
5215        // ------------------
5216        // replicate processinginfo tree
5217        // ------------------
5218        //    cout << "----------------------------------------------------"<<endl;
5219        //    cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl;
5220        for (Int_t i = 0; i < proc_tree->GetEntries(); i++) {
5221          proc_tree->GetEntry(i);
5222          //        cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;
5223          proc_tree_clone->Fill();
5224        }
5225        if ( SELLI != 2 || true ){      
5226          proc_obj->runID = 0;
5227          TTimeStamp *dt = new TTimeStamp();
5228          proc_obj->date = dt->AsString();
5229          delete dt;
5230          proc_obj->commandLine = Form("PamelaLevel2 was called");
5231          proc_obj->outputFilename = "";
5232          proc_obj->localDir = gSystem->WorkingDirectory();
5233          proc_obj->uname = gSystem->GetFromPipe("uname -a");
5234          proc_obj->DB = Form("mysql://%s/%s",dbc->GetHost(),dbc->GetDB());
5235          proc_tree_clone->Fill();
5236        }
5237        cout << "----------------------------------------------------" << endl;
5238      }
5239    // ------------------------------------    // ------------------------------------
5240    // add branch with dead and live times    // add branch with dead and live times
5241    // ------------------------------------    // ------------------------------------
# Line 5343  TTree* PamLevel2::GetCloneTree(TString n Line 5426  TTree* PamLevel2::GetCloneTree(TString n
5426      if (!name.CompareTo(na))      if (!name.CompareTo(na))
5427        return sel_tree_clone;        return sel_tree_clone;
5428    }    }
5429      if (proc_tree_clone && PROC) {
5430        TString na = proc_tree_clone->GetName();
5431        if (!name.CompareTo(na))
5432          return proc_tree_clone;
5433      }
5434    return NULL;    return NULL;
5435    
5436  }  }
# Line 5362  void PamLevel2::WriteCloneTrees() { Line 5450  void PamLevel2::WriteCloneTrees() {
5450    for (Int_t i = 0; i < NCLONES; i++) {    for (Int_t i = 0; i < NCLONES; i++) {
5451      if (pam_tree_clone[i]) {      if (pam_tree_clone[i]) {
5452        cout << pam_tree_clone[i]->GetName() << endl;        cout << pam_tree_clone[i]->GetName() << endl;
5453        pam_tree_clone[i]->Write();        pam_tree_clone[i]->Write(pam_tree_clone[i]->GetName(),TObject::kOverwrite);
5454      };      };
5455    }    }
5456      
5457      if ( PROC ){
5458        proc_tree_clone->Write("ProcessingInfo",TObject::kOverwrite);
5459      }
5460    cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl;    cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl;
5461    
5462  }  }

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.101

  ViewVC Help
Powered by ViewVC 1.1.23