--- DarthVader/RunInfo/src/RunInfo.cpp 2006/09/05 14:49:46 1.10 +++ DarthVader/RunInfo/src/RunInfo.cpp 2014/08/27 14:44:35 1.22 @@ -15,24 +15,32 @@ // #include #include +ClassImp(ProcInfo); ClassImp(SoftInfo); ClassImp(ItoRunInfo); // using namespace std; // +ProcInfo::ProcInfo() { + Clear(); +} + +void ProcInfo::Clear(Option_t *t){ + runID = 0; + date = ""; + commandLine = ""; + outputFilename = ""; + localDir = ""; + uname = ""; + DB = ""; +} + SoftInfo::SoftInfo() { - TRIG_ver = ""; - TOF_ver = ""; - AC_ver = ""; - TRK_ver = ""; - ORB_ver = ""; - CAL_ver = ""; - ND_ver = ""; - S4_ver = ""; + Clear(); } -void SoftInfo::Clear(){ +void SoftInfo::Clear(Option_t *t){ TRIG_ver = ""; TOF_ver = ""; AC_ver = ""; @@ -41,8 +49,44 @@ CAL_ver = ""; ND_ver = ""; S4_ver = ""; + DV_ver = ""; } +UInt_t SoftInfo::GetSWinfo(TString Detector){ + TString sver; + UInt_t version = 0; + if ( !strcmp(Detector.Data(),"TRIG") ){ + sver = TRIG_ver; + }; + if ( !strcmp(Detector.Data(),"TOF") ){ + sver = TOF_ver; + }; + if ( !strcmp(Detector.Data(),"AC") ){ + sver = AC_ver; + }; + if ( !strcmp(Detector.Data(),"TRK") ){ + sver = TRK_ver; + }; + if ( !strcmp(Detector.Data(),"CALO") ){ + sver = CAL_ver; + }; + if ( !strcmp(Detector.Data(),"S4") ){ + sver = S4_ver; + }; + if ( !strcmp(Detector.Data(),"DV") ){ + sver = DV_ver; + }; + if ( !strcmp(Detector.Data(),"ND") ){ + sver = ND_ver; + }; + if ( !strcmp(Detector.Data(),"ORB") ){ + sver = ORB_ver; + }; + sver.ReplaceAll("v",1," ",1); + sver.ReplaceAll("r",1," ",1); + version = (UInt_t)sver.Atoi(); + return(version); +}; /** * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common). @@ -59,6 +103,10 @@ } /***********************/ +ItoRunInfo::~ItoRunInfo() { + this->GL_RUN::Clear(); +} + ItoRunInfo::ItoRunInfo() { reprocessing = false; updating = false; @@ -72,7 +120,7 @@ norun = 0; runlist = new TArrayI(500); file = NULL; - newtree = new TTree(); + newtree = NULL;//new TTree(); } ItoRunInfo::ItoRunInfo(TFile *processFl){ @@ -89,35 +137,31 @@ last_file_entry = 0; file_entries = 0; version = new SoftInfo(); + // glrun = new GL_RUN(); norun = 0; totnorun = 0; runlist = new TArrayI(500); + newtree = NULL; // } -TChain *ItoRunInfo::LoadRunInfoTree(TList *fl){ - // - TChain *Tout=0; +TChain *ItoRunInfo::GetRunTree(TList *fl){ // - TChain *RI = 0; - TChain *SI = 0; - RI = new TChain("RunInfo"); - SI = new TChain("SoftInfo"); + TChain *Tout = new TChain("Run"); // loop over files and create chains TIter next(fl); TSystemFile *questo = 0; while ( (questo = (TSystemFile*) next()) ) { TString name = questo->GetName(); - RI->Add(name); - SI->Add(name); + Tout->Add(name); }; // - RI->SetBranchAddress("RunInfo", GetPointerToRI()); - Tout = RI; - SI->SetBranchAddress("SoftInfo", GetPointerToSI()); - Tout->AddFriend("SoftInfo"); + Tout->SetBranchAddress("RunInfo", GetPointerToRI()); + printf("Run : set branch address RunInfo\n"); + Tout->SetBranchAddress("SoftInfo", GetPointerToSI()); + printf("Software : set branch address SoftInfo\n"); // return Tout; // @@ -145,7 +189,7 @@ // if ( glrun && newrun ){ // - // printf("copy \n"); +// printf("copy \n"); // newrun->ID = glrun->ID ; newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG ; @@ -177,6 +221,8 @@ newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED ; newrun->CAL_DSP_MASK = glrun->CAL_DSP_MASK ; newrun->BOOT_NUMBER = glrun->BOOT_NUMBER ; + newrun->PHYSENDRUN_MASK_S3S2S12 = glrun->PHYSENDRUN_MASK_S3S2S12 ; + newrun->PHYSENDRUN_MASK_S11CRC = glrun->PHYSENDRUN_MASK_S11CRC ; newrun->VALIDATION = glrun->VALIDATION ; // }; @@ -190,6 +236,7 @@ newver->ORB_ver = sinfo->ORB_ver; newver->CAL_ver = sinfo->CAL_ver; newver->S4_ver = sinfo->S4_ver; + newver->DV_ver = sinfo->DV_ver; newver->ND_ver = sinfo->ND_ver; // }; @@ -202,11 +249,11 @@ // Bool_t debug = false; // - Bool_t ismydir = false; + // Bool_t ismydir = false; // if ( !strcmp(processFolder.Data(),"") ){ processFolder = "runinfoFolder"; - ismydir = true; + // ismydir = true; }; // GL_RUN *oldrun = new GL_RUN(); @@ -239,6 +286,7 @@ version->ORB_ver = Version; version->CAL_ver = Version; version->S4_ver = Version; + version->DV_ver = Version; version->ND_ver = Version; } else { if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version; @@ -247,9 +295,10 @@ if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version; if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version; if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version; + if ( !strcmp(Detector.Data(),"DV") ) version->DV_ver = Version; if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version; if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version; - if ( strcmp(Detector.Data(),"TRIG") && strcmp(Detector.Data(),"TOF") && strcmp(Detector.Data(),"AC") && strcmp(Detector.Data(),"TRK") && strcmp(Detector.Data(),"CALO") && strcmp(Detector.Data(),"S4") && strcmp(Detector.Data(),"ND") && strcmp(Detector.Data(),"ORB") ) return(-804); + if ( strcmp(Detector.Data(),"TRIG") && strcmp(Detector.Data(),"TOF") && strcmp(Detector.Data(),"AC") && strcmp(Detector.Data(),"TRK") && strcmp(Detector.Data(),"CALO") && strcmp(Detector.Data(),"S4") && strcmp(Detector.Data(),"ND") && strcmp(Detector.Data(),"ORB") && strcmp(Detector.Data(),"DV") ) return(-804); }; // if ( !oldtree ) { @@ -301,7 +350,7 @@ totnorun = 1; reprocessing = false; first_file_entry = 0; - last_file_entry = (UInt_t)(EV_TO - EV_FROM); + if ( EV_TO >= EV_FROM ) last_file_entry = (UInt_t)(EV_TO - EV_FROM); norun = 1; runlist->AddAt((Int_t)ID,0); // @@ -333,7 +382,7 @@ // for ( UInt_t run = 0; run < totnorun; run++){ // - oldtree->GetEntry(run); + if ( oldtree->GetEntry(run) <= 0 ) throw -36; // CopyFromTo(oldrun,newrun,oldver,newver); // @@ -343,7 +392,7 @@ // if ( idRun == 0 || idRun == newrun->ID ) { // - if ( debug ) printf(" Updating run number %u \n",idRun); + if ( debug ) printf(" Updating run number %u newrun->ID %i \n",idRun,(int)newrun->ID); // found = true; // @@ -373,6 +422,7 @@ newver->ORB_ver = oldver->ORB_ver; newver->CAL_ver = oldver->CAL_ver; newver->S4_ver = oldver->S4_ver; + newver->DV_ver = oldver->DV_ver; newver->ND_ver = oldver->ND_ver; if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true; }; @@ -383,6 +433,7 @@ newver->TRK_ver = oldver->TRK_ver; newver->ORB_ver = oldver->ORB_ver; newver->CAL_ver = oldver->CAL_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->ND_ver = oldver->ND_ver; if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true; @@ -393,6 +444,7 @@ newver->TRK_ver = oldver->TRK_ver; newver->ORB_ver = oldver->ORB_ver; newver->CAL_ver = oldver->CAL_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->ND_ver = oldver->ND_ver; newver->AC_ver = version->AC_ver; @@ -403,6 +455,7 @@ newver->TOF_ver = oldver->TOF_ver; newver->CAL_ver = oldver->CAL_ver; newver->ORB_ver = oldver->ORB_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->ND_ver = oldver->ND_ver; newver->AC_ver = oldver->AC_ver; @@ -414,6 +467,7 @@ newver->TOF_ver = oldver->TOF_ver; newver->CAL_ver = oldver->CAL_ver; newver->TRK_ver = oldver->TRK_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->ND_ver = oldver->ND_ver; newver->AC_ver = oldver->AC_ver; @@ -423,6 +477,7 @@ if ( !strcmp(Detector.Data(),"CALO") ){ newver->TRIG_ver = oldver->TRIG_ver; newver->TOF_ver = oldver->TOF_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->ORB_ver = oldver->ORB_ver; newver->ND_ver = oldver->ND_ver; @@ -439,12 +494,26 @@ newver->TRK_ver = oldver->TRK_ver; newver->ORB_ver = oldver->ORB_ver; newver->CAL_ver = oldver->CAL_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = version->S4_ver; if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true; }; + if ( !strcmp(Detector.Data(),"DV") ){ + newver->TRIG_ver = oldver->TRIG_ver; + newver->TOF_ver = oldver->TOF_ver; + newver->ND_ver = oldver->ND_ver; + newver->AC_ver = oldver->AC_ver; + newver->TRK_ver = oldver->TRK_ver; + newver->ORB_ver = oldver->ORB_ver; + newver->CAL_ver = oldver->CAL_ver; + newver->S4_ver = oldver->S4_ver; + newver->DV_ver = version->DV_ver; + if ( strcmp(oldver->DV_ver.Data(),"") ) reprocessing = true; + }; if ( !strcmp(Detector.Data(),"ND") ){ newver->TRIG_ver = oldver->TRIG_ver; newver->TOF_ver = oldver->TOF_ver; + newver->DV_ver = oldver->DV_ver; newver->S4_ver = oldver->S4_ver; newver->AC_ver = oldver->AC_ver; newver->ORB_ver = oldver->ORB_ver; @@ -455,13 +524,14 @@ }; }; // - last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1); + if ( oldrun->EV_TO >= oldrun->EV_FROM ) last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1); // } else { if ( !found ) first_file_entry += (oldrun->EV_TO - oldrun->EV_FROM + 1); }; // file->cd(); + if ( debug ) printf("filling: totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID); newtree->Fill(); // }; @@ -480,11 +550,22 @@ return(-5); }; // + this->Write(); // newtree->Write(); }; +// if ( oldtree ) oldtree->Delete(); // crasha qua in queste righe e se non le metti... +// if ( newver ) delete newver; +// if ( newrun ) delete newrun; +// if ( oldver ) delete oldver; +// if ( oldrun ) delete oldrun; return(0); } +void ItoRunInfo::Write(){ + file->cd(); + newtree->Write("Run",TObject::kOverwrite); +} + Int_t ItoRunInfo::Read(UInt_t idRun){ // isreadonly = true; @@ -521,7 +602,7 @@ // for ( UInt_t run = 0; run < totnorun; run++){ // - newtree->GetEntry(run); + if ( newtree->GetEntry(run) <= 0 ) throw -36; // file_entries += (newrun->EV_TO - newrun->EV_FROM + 1); // @@ -532,7 +613,7 @@ runlist->AddAt(newrun->ID,norun); norun++; }; - last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1); + if ( newrun->EV_TO >= newrun->EV_FROM ) last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1); }; }; if ( debug ) printf("norun %i \n",(int)norun); @@ -552,11 +633,12 @@ file_entries = 0; norun = 0; delete runlist; - file = new TFile(); - if ( isreadonly ) newtree->Delete(); + // file = new TFile(); + file = 0; + // if ( isreadonly ) newtree->Delete(); } -void ItoRunInfo::Clear(){ +void ItoRunInfo::Clear(Option_t *t){ if ( newtree ) newtree->Delete(); } @@ -609,12 +691,12 @@ totnorun = newtree->GetEntries(); // for ( UInt_t nrun = 0; nrun < totnorun; nrun++){ - newtree->GetEntry(nrun); + if ( newtree->GetEntry(nrun) <= 0 ) throw -36; // if ( nwrun->ID == run || run == 0 ){ CopyFromTo(nwrun,(GL_RUN*)this,nwver,version); found = true; - last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1); + if ( nwrun->EV_TO >= nwrun->EV_FROM ) last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1); }; if ( !found ) first_file_entry += (nwrun->EV_TO - nwrun->EV_FROM + 1); };