/[PAMELA software]/DarthVader/RunInfo/src/RunInfo.cpp
ViewVC logotype

Diff of /DarthVader/RunInfo/src/RunInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Fri May 19 13:15:47 2006 UTC revision 1.12 by mocchiut, Tue Oct 24 07:31:50 2006 UTC
# Line 2  Line 2 
2  #include <sstream>  #include <sstream>
3  //  //
4  #include <TObject.h>  #include <TObject.h>
5    #include <TChain.h>
6  #include <TSystem.h>  #include <TSystem.h>
7  #include <TArrayL.h>  #include <TSystemFile.h>
8    #include <TArrayI.h>
9  #include <TFile.h>  #include <TFile.h>
10  #include <TTree.h>  #include <TTree.h>
11  #include <TDirectory.h>  #include <TDirectory.h>
# Line 30  SoftInfo::SoftInfo() { Line 32  SoftInfo::SoftInfo() {
32    S4_ver = "";      S4_ver = "";  
33  }  }
34    
35    void SoftInfo::Clear(){
36      TRIG_ver = "";
37      TOF_ver = "";
38      AC_ver = "";
39      TRK_ver = "";
40      ORB_ver = "";
41      CAL_ver = "";
42      ND_ver = "";
43      S4_ver = "";  
44    }
45    
46    
47    /**
48     * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common).
49     */
50    void SoftInfo::GetLevel2Struct(cSoftInfo *l2) const{
51      l2->FillTrigWith(TRIG_ver);
52      l2->FillTofWith(TOF_ver);
53      l2->FillAcWith(AC_ver);
54      l2->FillTrkWith(TRK_ver);
55      l2->FillOrbWith(ORB_ver);
56      l2->FillCalWith(CAL_ver);
57      l2->FillNdWith(ND_ver);
58      l2->FillS4With(S4_ver);
59    }
60    /***********************/
61    
62  ItoRunInfo::ItoRunInfo() {  ItoRunInfo::ItoRunInfo() {
63    reprocessing = false;    reprocessing = false;
64    updating = false;    updating = false;
65    isreadonly = true;    isreadonly = true;
66    first_file_entry = 0;    first_file_entry = 0;
67    last_file_entry = 0;    last_file_entry = 0;
68    file_entries = 0ULL;    file_entries = 0;
69    totnorun = 0LL;    totnorun = 0;
70      this->GL_RUN::Clear();
71    version = new SoftInfo();    version = new SoftInfo();
   version->TRIG_ver = "";  
   version->TOF_ver = "";  
   version->AC_ver = "";  
   version->TRK_ver = "";  
   version->CAL_ver = "";  
   version->ND_ver = "";  
   version->S4_ver = "";    
   version->ORB_ver = "";    
72    norun = 0;    norun = 0;
73    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
74    file = new TFile();    file = NULL;
75    newtree = new TTree();    newtree = new TTree();
76  }  }
77    
# Line 58  ItoRunInfo::ItoRunInfo(TFile *processFl) Line 80  ItoRunInfo::ItoRunInfo(TFile *processFl)
80    file=(TFile*)processFl;    file=(TFile*)processFl;
81    dbc=NULL;    dbc=NULL;
82    processFolder = "";    processFolder = "";
83    idRun = 0ULL;    idRun = 0;
84    Detector = "NONE";    Detector = "NONE";
85    //    //
86    reprocessing = false;    reprocessing = false;
87    updating = false;    updating = false;
88    first_file_entry = 0;    first_file_entry = 0;
89    last_file_entry = 0;    last_file_entry = 0;
90    file_entries = 0ULL;    file_entries = 0;
91    version = new SoftInfo();    version = new SoftInfo();
   version->TRIG_ver = "";  
   version->TOF_ver = "";  
   version->AC_ver = "";  
   version->TRK_ver = "";  
   version->ORB_ver = "";  
   version->CAL_ver = "";  
   version->ND_ver = "";  
   version->S4_ver = "";    
92    norun = 0;    norun = 0;
93    totnorun = 0;    totnorun = 0;
94      runlist = new TArrayI(500);
95      //
96    }
97    
98    
99    
100    TChain *ItoRunInfo::LoadRunInfoTree(TList *fl){
101      //
102      TChain *Tout=0;
103      //
104      TChain *RI = 0;      
105      RI = new TChain("Run");      
106      // loop over files and create chains  
107      TIter next(fl);
108      TSystemFile *questo = 0;
109      while ( (questo = (TSystemFile*) next()) ) {
110        TString name =  questo->GetName();
111        RI->Add(name);
112      };
113      //
114      RI->SetBranchAddress("RunInfo", GetPointerToRI());
115      RI->SetBranchAddress("SoftInfo", GetPointerToSI());
116      Tout = RI;
117      //
118      return Tout;                  
119    //    //
120  }  }
121    
# Line 90  ItoRunInfo::ItoRunInfo(TSQLServer *db, T Line 129  ItoRunInfo::ItoRunInfo(TSQLServer *db, T
129    updating = false;    updating = false;
130    first_file_entry = 0;    first_file_entry = 0;
131    last_file_entry = 0;    last_file_entry = 0;
132    file_entries = 0ULL;    file_entries = 0;
133    version = new SoftInfo();    version = new SoftInfo();
   version->TRIG_ver = "";  
   version->TOF_ver = "";  
   version->AC_ver = "";  
   version->TRK_ver = "";  
   version->ORB_ver = "";  
   version->CAL_ver = "";  
   version->ND_ver = "";  
   version->S4_ver = "";    
134    norun = 0;    norun = 0;
135    totnorun = 0;    totnorun = 0;
136      runlist = new TArrayI(500);
137      //
138    }
139    
140    void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
141      //
142      if ( glrun && newrun ){
143        //
144        //    printf("copy \n");
145        //
146        newrun->ID = glrun->ID                         ;
147        newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG                ;
148        newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0                 ;
149        newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2                 ;
150        newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME             ;
151        newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME            ;
152        newrun->EV_FROM = glrun->EV_FROM                    ;
153        newrun->EV_TO = glrun->EV_TO                      ;
154        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
155        newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE           ;
156        newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A         ;
157        newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B         ;
158        newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO             ;
159        newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO               ;
160        newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT              ;
161        newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT             ;
162        newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT              ;
163        newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT             ;
164        newrun->NEVENTS = glrun->NEVENTS                    ;
165        newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC              ;
166        newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC               ;
167        newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP       ;
168        newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE           ;
169        newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB         ;
170        newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE        ;
171        newrun->PKT_COUNTER = glrun->PKT_COUNTER                ;
172        newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER          ;
173        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
174        newrun->CAL_DSP_MASK  = glrun->CAL_DSP_MASK               ;
175        newrun->BOOT_NUMBER  = glrun->BOOT_NUMBER                ;
176        newrun->VALIDATION  = glrun->VALIDATION                 ;
177        //
178      };
179    //    //
180      if ( newver && sinfo ){
181        //
182        newver->TRIG_ver = sinfo->TRIG_ver;
183        newver->TOF_ver = sinfo->TOF_ver;
184        newver->AC_ver = sinfo->AC_ver;
185        newver->TRK_ver = sinfo->TRK_ver;
186        newver->ORB_ver = sinfo->ORB_ver;
187        newver->CAL_ver = sinfo->CAL_ver;
188        newver->S4_ver = sinfo->S4_ver;
189        newver->ND_ver = sinfo->ND_ver;
190        //
191      };
192  }  }
193    
194  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
195    //    //
196    isreadonly = false;    isreadonly = false;
197    idRun = run;    idRun = run;
# Line 124  Int_t ItoRunInfo::Update(ULong64_t run, Line 210  Int_t ItoRunInfo::Update(ULong64_t run,
210    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
211    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
212    //    //
213    ID = 0ULL;    this->GL_RUN::Clear();
214    ID_REG_RUN = 0ULL;    version->Clear();
   ID_REG_RUN_L2 = 0ULL;  
   RUNHEADER_TIME = 0ULL;  
   RUNTRAILER_TIME = 0ULL;  
   EV_REG_PHYS_FROM = 0;  
   EV_REG_PHYS_TO = 0;    
   EV_REG_RUNHEADER = 0;    
   EV_REG_RUNTRAILER = 0;    
   TRK_CALIB_USED = 0;  
   EFF_WRK_SCHEDULE = 0;  
   PRH_VAR_TRG_MODE_A = 0;  
   PRH_VAR_TRG_MODE_B = 0;  
   ACQ_BUILD_INFO = 0;  
   ACQ_VAR_INFO = 0;  
   version->TRIG_ver = "";  
   version->TOF_ver = "";  
   version->AC_ver = "";  
   version->TRK_ver = "";  
   version->ORB_ver = "";  
   version->CAL_ver = "";  
   version->ND_ver = "";  
   version->S4_ver = "";    
215    //    //
216    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
217    //    //
218    Bool_t found = false;    Bool_t found = false;
219    Int_t error = 0;    Int_t error = 0;
220    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
221    TTree *oldtree = 0;    TTree *oldtree = 0;
222    //    //
   //  
223    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
224    //    //
225    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 199  Int_t ItoRunInfo::Update(ULong64_t run, Line 256  Int_t ItoRunInfo::Update(ULong64_t run,
256      //      //
257    } else {    } else {
258      //      //
 //     temprname.str("");  
 //     temprname << routdir;  
 //     temprname << "/" << processFolder.Data();  
 //     gSystem->MakeDirectory(temprname.str().c_str());  
 //     tempdir.str("");  
 //     tempdir << temprname.str().c_str();  
 //     temprname << "/runinfo_run";  
 //     temprname << idRun << ".root";    
 //     if ( debug ) printf(" file temporaneo is %s \n",temprname.str().c_str());  
 //     //  
 //     temprfile = new TFile(temprname.str().c_str(),"RECREATE");  
 //     //  
 //     temprrun = new TTree();  
 //     //  
 //     if ( !temprfile ) return(-805);  
 //     if ( !oldtree ) return(-806);  
 //     if ( !temprrun ) return(-807);  
 //     //  
 //     temprrun = oldtree->CloneTree(-1,"fast");      
 //     //  
 //     temprfile->cd();  
 //     temprrun->SetName("Run-old");  
 //     temprfile->Write();  
 //     if ( temprrun ) temprrun->Delete();  
 //     temprfile->Close();    
 //     //  
 //     oldtree->Delete("all");  
     //  
259      updating = true;      updating = true;
260      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
261      //      //
# Line 242  Int_t ItoRunInfo::Update(ULong64_t run, Line 271  Int_t ItoRunInfo::Update(ULong64_t run,
271    //      //  
272    //    //
273    if ( !updating ){    if ( !updating ){
274      if ( idRun == 0ULL ){      if ( idRun == 0 ){
275        if ( debug ) printf("\n RUNINFO - ERROR: reprocessing data but no RunInfo tree in Level2 file. \n");        if ( debug ) printf("\n RUNINFO - ERROR: reprocessing data but no RunInfo tree in Level2 file. \n");
276        return(-13);        return(-805);
277      };      };
278      //      //
     runlist = new TArrayL(1);  
     //  
279      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
280      //      //
281      if ( error ){      if ( error ){
282        if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");        if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");
283        return(error);        return(error);
284      };      };
285      if ( ID == 0ULL ){      if ( ID == 0 ){
286        if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %llu \n",idRun);        if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
287        return(-5);        return(-5);
288      };      };
289      //      //
290      //      //
291      //      CopyFromTo((GL_RUN*)this,newrun,version,newver);
     newrun->ID = ID;  
     newrun->ID_REG_RUN = ID_REG_RUN;  
     newrun->ID_REG_RUN_L2 = ID_REG_RUN_L2;  
     newrun->RUNHEADER_TIME = RUNHEADER_TIME;  
     newrun->RUNTRAILER_TIME = RUNTRAILER_TIME;  
     newrun->EV_REG_PHYS_FROM = EV_REG_PHYS_FROM;  
     newrun->EV_REG_PHYS_TO = EV_REG_PHYS_TO;  
     newrun->EV_REG_RUNHEADER = EV_REG_RUNHEADER;  
     newrun->EV_REG_RUNTRAILER = EV_REG_RUNTRAILER;  
     newrun->TRK_CALIB_USED = TRK_CALIB_USED;  
     newrun->EFF_WRK_SCHEDULE = EFF_WRK_SCHEDULE;  
     newrun->PRH_VAR_TRG_MODE_A = PRH_VAR_TRG_MODE_A;  
     newrun->PRH_VAR_TRG_MODE_B = PRH_VAR_TRG_MODE_B;  
     newrun->ACQ_BUILD_INFO = ACQ_BUILD_INFO;  
     newrun->ACQ_VAR_INFO = ACQ_VAR_INFO;  
     newver->TRIG_ver = version->TRIG_ver;  
     newver->TOF_ver = version->TOF_ver;  
     newver->AC_ver = version->AC_ver;  
     newver->TRK_ver = version->TRK_ver;  
     newver->ORB_ver = version->ORB_ver;  
     newver->CAL_ver = version->CAL_ver;  
     newver->S4_ver = version->S4_ver;  
     newver->ND_ver = version->ND_ver;  
292      //      //
293      // fill the tree;      // fill the tree;
294      //      //
# Line 293  Int_t ItoRunInfo::Update(ULong64_t run, Line 297  Int_t ItoRunInfo::Update(ULong64_t run,
297      totnorun = 1;      totnorun = 1;
298      reprocessing = false;      reprocessing = false;
299      first_file_entry = 0;      first_file_entry = 0;
300      last_file_entry = (UInt_t)(EV_REG_PHYS_TO - EV_REG_PHYS_FROM);      last_file_entry = (UInt_t)(EV_TO - EV_FROM);
301      norun = 1;      norun = 1;
302      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
303      //      //
304      newtree->SetName("Run");      newtree->SetName("Run");
305      //      //
306      file->cd();      file->cd();
307      //    file->Write("Run");      //
308      //newtree->Delete();      delete newver;
309        delete newrun;
310        delete oldver;
311        delete oldrun;
312      //      //
313      return(0);      return(0);
314      //      //
315    } else {    } else {
316      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
317      //      //
318      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
319      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
320      //      //
321      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
322      //      //
323      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
324          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
325          return(-806);
326        };
327      //      //
328      found = false;      found = false;
329      //      //
# Line 323  Int_t ItoRunInfo::Update(ULong64_t run, Line 331  Int_t ItoRunInfo::Update(ULong64_t run,
331        //        //
332        oldtree->GetEntry(run);        oldtree->GetEntry(run);
333        //        //
334        newrun->ID = oldrun->ID;        CopyFromTo(oldrun,newrun,oldver,newver);
       newrun->ID_REG_RUN = oldrun->ID_REG_RUN;  
       newrun->ID_REG_RUN_L2 = oldrun->ID_REG_RUN_L2;  
       newrun->RUNHEADER_TIME = oldrun->RUNHEADER_TIME;  
       newrun->RUNTRAILER_TIME = oldrun->RUNTRAILER_TIME;  
       newrun->EV_REG_PHYS_FROM = oldrun->EV_REG_PHYS_FROM;  
       newrun->EV_REG_PHYS_TO = oldrun->EV_REG_PHYS_TO;  
       newrun->EV_REG_RUNHEADER = oldrun->EV_REG_RUNHEADER;  
       newrun->EV_REG_RUNTRAILER = oldrun->EV_REG_RUNTRAILER;  
       newrun->TRK_CALIB_USED = oldrun->TRK_CALIB_USED;  
       newrun->EFF_WRK_SCHEDULE = oldrun->EFF_WRK_SCHEDULE;  
       newrun->PRH_VAR_TRG_MODE_A = oldrun->PRH_VAR_TRG_MODE_A;  
       newrun->PRH_VAR_TRG_MODE_B = oldrun->PRH_VAR_TRG_MODE_B;  
       newrun->ACQ_BUILD_INFO = oldrun->ACQ_BUILD_INFO;  
       newrun->ACQ_VAR_INFO = oldrun->ACQ_VAR_INFO;  
       newver->TRIG_ver = oldver->TRIG_ver;  
       newver->TOF_ver = oldver->TOF_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->ND_ver = oldver->ND_ver;  
335        //        //
336        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
337        //        //
338        if ( debug ) printf("totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID);        if ( debug ) printf("totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID);
339        //        //
340        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
341          //          //
342          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u \n",idRun);
343          //          //
344          found = true;          found = true;
345          //          //
# Line 371  Int_t ItoRunInfo::Update(ULong64_t run, Line 357  Int_t ItoRunInfo::Update(ULong64_t run,
357              return(error);              return(error);
358            };            };
359            //            //
360            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
361            newrun->ID_REG_RUN = ID_REG_RUN;            //
           newrun->ID_REG_RUN_L2 = ID_REG_RUN_L2;  
           newrun->RUNHEADER_TIME = RUNHEADER_TIME;  
           newrun->RUNTRAILER_TIME = RUNTRAILER_TIME;  
           newrun->EV_REG_PHYS_FROM = EV_REG_PHYS_FROM;  
           newrun->EV_REG_PHYS_TO = EV_REG_PHYS_TO;  
           newrun->EV_REG_RUNHEADER = EV_REG_RUNHEADER;  
           newrun->EV_REG_RUNTRAILER = EV_REG_RUNTRAILER;  
           newrun->TRK_CALIB_USED = TRK_CALIB_USED;  
           newrun->EFF_WRK_SCHEDULE = EFF_WRK_SCHEDULE;  
           newrun->PRH_VAR_TRG_MODE_A = PRH_VAR_TRG_MODE_A;  
           newrun->PRH_VAR_TRG_MODE_B = PRH_VAR_TRG_MODE_B;  
           newrun->ACQ_BUILD_INFO = ACQ_BUILD_INFO;  
           newrun->ACQ_VAR_INFO = ACQ_VAR_INFO;  
362          } else {          } else {
363            //            //
364            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 441  Int_t ItoRunInfo::Update(ULong64_t run, Line 414  Int_t ItoRunInfo::Update(ULong64_t run,
414              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
415              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
416              newver->ORB_ver = version->ORB_ver;              newver->ORB_ver = version->ORB_ver;
417              if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->ORB_ver.Data(),"") ) reprocessing = true;
418            };            };
419            if ( !strcmp(Detector.Data(),"CALO") ){            if ( !strcmp(Detector.Data(),"CALO") ){
420              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
# Line 478  Int_t ItoRunInfo::Update(ULong64_t run, Line 451  Int_t ItoRunInfo::Update(ULong64_t run,
451            };            };
452          };          };
453          //          //
454          last_file_entry = first_file_entry + (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);          last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1);
455          //          //
456        } else {        } else {
457          if ( !found ) first_file_entry += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);          if ( !found ) first_file_entry += (oldrun->EV_TO - oldrun->EV_FROM + 1);
458        };        };
459        //        //
460        file->cd();        file->cd();
# Line 489  Int_t ItoRunInfo::Update(ULong64_t run, Line 462  Int_t ItoRunInfo::Update(ULong64_t run,
462        //        //
463      };      };
464      //      //
     //    temprfile->Close();  
     //    gSystem->Unlink(temprname.str().c_str());  
     //    if ( ismydir ) gSystem->Unlink(tempdir.str().c_str());  
465      file->cd();      file->cd();
466      if ( oldtree ) oldtree->Delete("all");      if ( oldtree ) oldtree->Delete("all");
467      newtree->SetName("Run");      newtree->SetName("Run");
468      //    file->Write("Run");      //
469      //    newtree->Delete();      delete newver;
470        delete newrun;
471        delete oldver;
472        delete oldrun;
473      //      //
474      if ( !found ){      if ( !found ){
475        if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %llu \n",idRun);        if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
476        return(-5);        return(-5);
477      };      };
478      //      //
# Line 508  Int_t ItoRunInfo::Update(ULong64_t run, Line 481  Int_t ItoRunInfo::Update(ULong64_t run,
481    return(0);    return(0);
482  }  }
483    
484  Int_t ItoRunInfo::Read(ULong64_t idRun){  Int_t ItoRunInfo::Read(UInt_t idRun){
485    //    //
486    isreadonly = true;    isreadonly = true;
487    //    //
# Line 535  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 508  Int_t ItoRunInfo::Read(ULong64_t idRun){
508      //      //
509      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
510      //      //
511      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
512          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
513          return(-806);
514        };
515      //      //
516      first_file_entry = 0;      first_file_entry = 0;
517      //      //
# Line 543  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 519  Int_t ItoRunInfo::Read(ULong64_t idRun){
519        //        //
520        newtree->GetEntry(run);        newtree->GetEntry(run);
521        //        //
522        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
523        //        //
524        if ( debug ) printf("totnorun %i  newrun->ID %i \n",(int)totnorun,(int)newrun->ID);        if ( debug ) printf("totnorun %i  newrun->ID %i \n",(int)totnorun,(int)newrun->ID);
525        //        //
526        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
527        ID_REG_RUN = newrun->ID_REG_RUN;        if ( idRun == ID || idRun == 0 ){
       ID_REG_RUN_L2 = newrun->ID_REG_RUN_L2;  
       RUNHEADER_TIME = newrun->RUNHEADER_TIME;  
       RUNTRAILER_TIME = newrun->RUNTRAILER_TIME;  
       EV_REG_PHYS_FROM = newrun->EV_REG_PHYS_FROM;  
       EV_REG_PHYS_TO = newrun->EV_REG_PHYS_TO;  
       EV_REG_RUNHEADER = newrun->EV_REG_RUNHEADER;  
       EV_REG_RUNTRAILER = newrun->EV_REG_RUNTRAILER;  
       TRK_CALIB_USED = newrun->TRK_CALIB_USED;  
       EFF_WRK_SCHEDULE = newrun->EFF_WRK_SCHEDULE;  
       PRH_VAR_TRG_MODE_A = newrun->PRH_VAR_TRG_MODE_A;  
       PRH_VAR_TRG_MODE_B = newrun->PRH_VAR_TRG_MODE_B;  
       ACQ_BUILD_INFO = newrun->ACQ_BUILD_INFO;  
       ACQ_VAR_INFO = newrun->ACQ_VAR_INFO;  
       version->TRIG_ver = newver->TRIG_ver;  
       version->TOF_ver = newver->TOF_ver;  
       version->AC_ver = newver->AC_ver;  
       version->TRK_ver = newver->TRK_ver;  
       version->ORB_ver = newver->ORB_ver;  
       version->CAL_ver = newver->CAL_ver;  
       version->S4_ver = newver->S4_ver;  
       version->ND_ver = newver->ND_ver;  
       if ( idRun == ID || idRun == 0ULL ){  
528          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
529          norun++;          norun++;
530        };        };
531        last_file_entry = first_file_entry + (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1);
532      };      };
533    };    };
534    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
535    Int_t error = 0;    Int_t error = 0;
536    error = GetRunInfo(idRun);    error = GetRunInfo(idRun);
537      delete newver;
538      delete newrun;
539    if ( error ) return(error);    if ( error ) return(error);
540    return(0);    return(0);
541  }      }    
# Line 589  void ItoRunInfo::Close(){ Line 545  void ItoRunInfo::Close(){
545    updating = false;    updating = false;
546    first_file_entry = 0;    first_file_entry = 0;
547    last_file_entry = 0;    last_file_entry = 0;
548    file_entries = 0ULL;    file_entries = 0;
549    norun = 0;    norun = 0;
550    runlist = new TArrayL(0,NULL);    delete runlist;
551    file = new TFile();      file = new TFile();  
552    if ( isreadonly ) newtree->Delete();    if ( isreadonly ) newtree->Delete();
553  }  }
# Line 602  void ItoRunInfo::Clear(){ Line 558  void ItoRunInfo::Clear(){
558    
559  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
560    //    //
561    ItoRunInfo *run = new ItoRunInfo();    UInt_t startfrom = 0;
562      //
563      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
564      //
565      if ( entry > (UInt_t)last_file_entry ){
566        for ( UInt_t nrun = 0; nrun < norun; nrun++){  
567          if ( ID == (UInt_t)runlist->At(nrun) ) {
568            startfrom = nrun+1;
569            break;
570          };
571        };
572      } else {
573        startfrom = 0;
574      };
575      //
576      if ( startfrom >= norun ) startfrom = 0;
577    //    //
578    for ( UInt_t nrun = 0; nrun < norun; nrun++){     retry:
579      run->GetRunInfo((ULong64_t)nrun);    //
580      if ( entry >= (UInt_t)run->first_file_entry && entry <= (UInt_t)run->last_file_entry ){    for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
581        run->newtree->Delete();      GetRunInfo((UInt_t)runlist->At(nrun));
582        return(nrun);      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){
583          return((UInt_t)runlist->At(nrun));
584      };      };
585    };    };
586    run->newtree->Delete();    if ( startfrom ){
587        startfrom = 0;
588        goto retry;
589      };
590      printf(" ERROR! run not found \n");
591    return(0);    return(0);
592  }  }
593    
594  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
595    Bool_t found = false;    Bool_t found = false;
596    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
597    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 631  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 607  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
607    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
608      newtree->GetEntry(nrun);      newtree->GetEntry(nrun);
609      //      //
610      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
611        ID = nwrun->ID;        CopyFromTo(nwrun,(GL_RUN*)this,nwver,version);
       ID_REG_RUN = nwrun->ID_REG_RUN;  
       ID_REG_RUN_L2 = nwrun->ID_REG_RUN_L2;  
       RUNHEADER_TIME = nwrun->RUNHEADER_TIME;  
       RUNTRAILER_TIME = nwrun->RUNTRAILER_TIME;  
       EV_REG_PHYS_FROM = nwrun->EV_REG_PHYS_FROM;  
       EV_REG_PHYS_TO = nwrun->EV_REG_PHYS_TO;  
       EV_REG_RUNHEADER = nwrun->EV_REG_RUNHEADER;  
       EV_REG_RUNTRAILER = nwrun->EV_REG_RUNTRAILER;  
       TRK_CALIB_USED = nwrun->TRK_CALIB_USED;  
       EFF_WRK_SCHEDULE = nwrun->EFF_WRK_SCHEDULE;  
       PRH_VAR_TRG_MODE_A = nwrun->PRH_VAR_TRG_MODE_A;  
       PRH_VAR_TRG_MODE_B = nwrun->PRH_VAR_TRG_MODE_B;  
       ACQ_BUILD_INFO = nwrun->ACQ_BUILD_INFO;  
       ACQ_VAR_INFO = nwrun->ACQ_VAR_INFO;  
       version->TRIG_ver = nwver->TRIG_ver;  
       version->TOF_ver = nwver->TOF_ver;  
       version->AC_ver = nwver->AC_ver;  
       version->TRK_ver = nwver->TRK_ver;  
       version->ORB_ver = nwver->ORB_ver;  
       version->CAL_ver = nwver->CAL_ver;  
       version->S4_ver = nwver->S4_ver;  
       version->ND_ver = nwver->ND_ver;  
612        found = true;        found = true;
613        last_file_entry = first_file_entry + (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1);        last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1);
614      };      };
615      if ( !found ) first_file_entry += (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1);      if ( !found ) first_file_entry += (nwrun->EV_TO - nwrun->EV_FROM + 1);
616    };    };
617      delete nwver;
618      delete nwrun;
619    if ( found ) return(0);    if ( found ) return(0);
620    return(-800);    return(-800);
621  }  }
622    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.23