--- DarthVader/RunInfo/src/RunInfo.cpp 2006/05/19 13:15:47 1.1 +++ DarthVader/RunInfo/src/RunInfo.cpp 2006/08/04 10:31:30 1.7 @@ -30,6 +30,21 @@ S4_ver = ""; } +/** + * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common). + */ +void SoftInfo::GetLevel2Struct(cSoftInfo *l2) const{ + l2->FillTrigWith(TRIG_ver); + l2->FillTofWith(TOF_ver); + l2->FillAcWith(AC_ver); + l2->FillTrkWith(TRK_ver); + l2->FillOrbWith(ORB_ver); + l2->FillCalWith(CAL_ver); + l2->FillNdWith(ND_ver); + l2->FillS4With(S4_ver); +} +/***********************/ + ItoRunInfo::ItoRunInfo() { reprocessing = false; updating = false; @@ -48,8 +63,10 @@ version->S4_ver = ""; version->ORB_ver = ""; norun = 0; - runlist = new TArrayL(0,NULL); - file = new TFile(); + // runlist = new TArrayL(0,NULL); + runlist = new TArrayL(500); + // file = new TFile(); + file = NULL;//new TFile(); newtree = new TTree(); } @@ -77,6 +94,8 @@ version->S4_ver = ""; norun = 0; totnorun = 0; + runlist = new TArrayL(500); + // runlist = new TArrayL(0,NULL); // } @@ -102,6 +121,8 @@ version->S4_ver = ""; norun = 0; totnorun = 0; + // runlist = new TArrayL(0,NULL); + runlist = new TArrayL(500); // } @@ -149,7 +170,8 @@ version->S4_ver = ""; // norun = 0; - runlist = new TArrayL(0,NULL); + // runlist = new TArrayL(0,NULL); + //runlist->Reset(); // Bool_t found = false; Int_t error = 0; @@ -244,10 +266,10 @@ if ( !updating ){ if ( idRun == 0ULL ){ if ( debug ) printf("\n RUNINFO - ERROR: reprocessing data but no RunInfo tree in Level2 file. \n"); - return(-13); + return(-805); }; // - runlist = new TArrayL(1); + // runlist = new TArrayL(1); // error = Query_GL_RUN(idRun, dbc); // @@ -302,6 +324,10 @@ file->cd(); // file->Write("Run"); //newtree->Delete(); + delete newver; + delete newrun; + delete oldver; + delete oldrun; // return(0); // @@ -315,7 +341,11 @@ // totnorun = oldtree->GetEntries(); // - runlist = new TArrayL((Int_t)totnorun); + if ( totnorun > 500 ){ + if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n"); + return(-806); + }; + // runlist = new TArrayL((Int_t)totnorun); // found = false; // @@ -441,7 +471,7 @@ newver->ND_ver = oldver->ND_ver; newver->AC_ver = oldver->AC_ver; newver->ORB_ver = version->ORB_ver; - if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true; + if ( strcmp(oldver->ORB_ver.Data(),"") ) reprocessing = true; }; if ( !strcmp(Detector.Data(),"CALO") ){ newver->TRIG_ver = oldver->TRIG_ver; @@ -497,6 +527,10 @@ newtree->SetName("Run"); // file->Write("Run"); // newtree->Delete(); + delete newver; + delete newrun; + delete oldver; + delete oldrun; // if ( !found ){ if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %llu \n",idRun); @@ -535,7 +569,11 @@ // totnorun = newtree->GetEntries(); // - runlist = new TArrayL((Int_t)totnorun); + if ( totnorun > 500 ){ + if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n"); + return(-806); + }; + // runlist = new TArrayL((Int_t)totnorun); // first_file_entry = 0; // @@ -580,6 +618,8 @@ if ( debug ) printf("norun %i \n",(int)norun); Int_t error = 0; error = GetRunInfo(idRun); + delete newver; + delete newrun; if ( error ) return(error); return(0); } @@ -591,7 +631,9 @@ last_file_entry = 0; file_entries = 0ULL; norun = 0; - runlist = new TArrayL(0,NULL); + // runlist = new TArrayL(0,NULL); + delete runlist; + //if ( file ) delete file; file = new TFile(); if ( isreadonly ) newtree->Delete(); } @@ -602,16 +644,36 @@ UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){ // - ItoRunInfo *run = new ItoRunInfo(); + UInt_t startfrom = 0; + // + if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID); // - for ( UInt_t nrun = 0; nrun < norun; nrun++){ - run->GetRunInfo((ULong64_t)nrun); - if ( entry >= (UInt_t)run->first_file_entry && entry <= (UInt_t)run->last_file_entry ){ - run->newtree->Delete(); - return(nrun); + if ( entry > (UInt_t)last_file_entry ){ + for ( UInt_t nrun = 0; nrun < norun; nrun++){ + if ( ID == (ULong64_t)runlist->At(nrun) ) { + startfrom = nrun+1; + break; + }; }; + } else { + startfrom = 0; }; - run->newtree->Delete(); + // + if ( startfrom >= norun ) startfrom = 0; + // + retry: + // + for ( UInt_t nrun = startfrom; nrun < norun; nrun++){ + GetRunInfo((ULong64_t)runlist->At(nrun)); + if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){ + return((UInt_t)runlist->At(nrun)); + }; + }; + if ( startfrom ){ + startfrom = 0; + goto retry; + }; + printf(" ERROR! run not found \n"); return(0); } @@ -660,6 +722,9 @@ }; if ( !found ) first_file_entry += (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1); }; + delete nwver; + delete nwrun; if ( found ) return(0); return(-800); } +