/[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.3 by mocchiut, Fri Jun 30 09:21:59 2006 UTC revision 1.11 by mocchiut, Tue Oct 24 07:28:37 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("Run", GetPointerToRI());
115      Tout = RI;
116      //
117      return Tout;                  
118    //    //
119  }  }
120    
# Line 90  ItoRunInfo::ItoRunInfo(TSQLServer *db, T Line 128  ItoRunInfo::ItoRunInfo(TSQLServer *db, T
128    updating = false;    updating = false;
129    first_file_entry = 0;    first_file_entry = 0;
130    last_file_entry = 0;    last_file_entry = 0;
131    file_entries = 0ULL;    file_entries = 0;
132    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 = "";    
133    norun = 0;    norun = 0;
134    totnorun = 0;    totnorun = 0;
135      runlist = new TArrayI(500);
136    //    //
137  }  }
138    
139  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
140      //
141      if ( glrun && newrun ){
142        //
143        //    printf("copy \n");
144        //
145        newrun->ID = glrun->ID                         ;
146        newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG                ;
147        newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0                 ;
148        newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2                 ;
149        newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME             ;
150        newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME            ;
151        newrun->EV_FROM = glrun->EV_FROM                    ;
152        newrun->EV_TO = glrun->EV_TO                      ;
153        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
154        newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE           ;
155        newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A         ;
156        newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B         ;
157        newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO             ;
158        newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO               ;
159        newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT              ;
160        newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT             ;
161        newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT              ;
162        newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT             ;
163        newrun->NEVENTS = glrun->NEVENTS                    ;
164        newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC              ;
165        newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC               ;
166        newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP       ;
167        newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE           ;
168        newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB         ;
169        newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE        ;
170        newrun->PKT_COUNTER = glrun->PKT_COUNTER                ;
171        newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER          ;
172        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
173        newrun->CAL_DSP_MASK  = glrun->CAL_DSP_MASK               ;
174        newrun->BOOT_NUMBER  = glrun->BOOT_NUMBER                ;
175        newrun->VALIDATION  = glrun->VALIDATION                 ;
176        //
177      };
178      //
179      if ( newver && sinfo ){
180        //
181        newver->TRIG_ver = sinfo->TRIG_ver;
182        newver->TOF_ver = sinfo->TOF_ver;
183        newver->AC_ver = sinfo->AC_ver;
184        newver->TRK_ver = sinfo->TRK_ver;
185        newver->ORB_ver = sinfo->ORB_ver;
186        newver->CAL_ver = sinfo->CAL_ver;
187        newver->S4_ver = sinfo->S4_ver;
188        newver->ND_ver = sinfo->ND_ver;
189        //
190      };
191    }
192    
193    Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
194    //    //
195    isreadonly = false;    isreadonly = false;
196    idRun = run;    idRun = run;
# Line 124  Int_t ItoRunInfo::Update(ULong64_t run, Line 209  Int_t ItoRunInfo::Update(ULong64_t run,
209    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
210    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
211    //    //
212    ID = 0ULL;    this->GL_RUN::Clear();
213    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 = "";    
214    //    //
215    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
216    //    //
217    Bool_t found = false;    Bool_t found = false;
218    Int_t error = 0;    Int_t error = 0;
219    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
220    TTree *oldtree = 0;    TTree *oldtree = 0;
221    //    //
   //  
222    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
223    //    //
224    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 199  Int_t ItoRunInfo::Update(ULong64_t run, Line 255  Int_t ItoRunInfo::Update(ULong64_t run,
255      //      //
256    } else {    } else {
257      //      //
 //     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");  
     //  
258      updating = true;      updating = true;
259      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
260      //      //
# Line 242  Int_t ItoRunInfo::Update(ULong64_t run, Line 270  Int_t ItoRunInfo::Update(ULong64_t run,
270    //      //  
271    //    //
272    if ( !updating ){    if ( !updating ){
273      if ( idRun == 0ULL ){      if ( idRun == 0 ){
274        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");
275        return(-805);        return(-805);
276      };      };
277      //      //
     runlist = new TArrayL(1);  
     //  
278      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
279      //      //
280      if ( error ){      if ( error ){
281        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");
282        return(error);        return(error);
283      };      };
284      if ( ID == 0ULL ){      if ( ID == 0 ){
285        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);
286        return(-5);        return(-5);
287      };      };
288      //      //
289      //      //
290      //      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;  
291      //      //
292      // fill the tree;      // fill the tree;
293      //      //
# Line 293  Int_t ItoRunInfo::Update(ULong64_t run, Line 296  Int_t ItoRunInfo::Update(ULong64_t run,
296      totnorun = 1;      totnorun = 1;
297      reprocessing = false;      reprocessing = false;
298      first_file_entry = 0;      first_file_entry = 0;
299      last_file_entry = (UInt_t)(EV_REG_PHYS_TO - EV_REG_PHYS_FROM);      last_file_entry = (UInt_t)(EV_TO - EV_FROM);
300      norun = 1;      norun = 1;
301      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
302      //      //
303      newtree->SetName("Run");      newtree->SetName("Run");
304      //      //
305      file->cd();      file->cd();
306      //    file->Write("Run");      //
     //newtree->Delete();  
307      delete newver;      delete newver;
308      delete newrun;      delete newrun;
309      delete oldver;      delete oldver;
# Line 311  Int_t ItoRunInfo::Update(ULong64_t run, Line 313  Int_t ItoRunInfo::Update(ULong64_t run,
313      //      //
314    } else {    } else {
315      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
316      //      //
317      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
318      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
319      //      //
320      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
321      //      //
322      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
323          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
324          return(-806);
325        };
326      //      //
327      found = false;      found = false;
328      //      //
# Line 327  Int_t ItoRunInfo::Update(ULong64_t run, Line 330  Int_t ItoRunInfo::Update(ULong64_t run,
330        //        //
331        oldtree->GetEntry(run);        oldtree->GetEntry(run);
332        //        //
333        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;  
334        //        //
335        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
336        //        //
337        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);
338        //        //
339        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
340          //          //
341          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u \n",idRun);
342          //          //
343          found = true;          found = true;
344          //          //
# Line 375  Int_t ItoRunInfo::Update(ULong64_t run, Line 356  Int_t ItoRunInfo::Update(ULong64_t run,
356              return(error);              return(error);
357            };            };
358            //            //
359            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
360            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;  
361          } else {          } else {
362            //            //
363            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 482  Int_t ItoRunInfo::Update(ULong64_t run, Line 450  Int_t ItoRunInfo::Update(ULong64_t run,
450            };            };
451          };          };
452          //          //
453          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);
454          //          //
455        } else {        } else {
456          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);
457        };        };
458        //        //
459        file->cd();        file->cd();
# Line 493  Int_t ItoRunInfo::Update(ULong64_t run, Line 461  Int_t ItoRunInfo::Update(ULong64_t run,
461        //        //
462      };      };
463      //      //
     //    temprfile->Close();  
     //    gSystem->Unlink(temprname.str().c_str());  
     //    if ( ismydir ) gSystem->Unlink(tempdir.str().c_str());  
464      file->cd();      file->cd();
465      if ( oldtree ) oldtree->Delete("all");      if ( oldtree ) oldtree->Delete("all");
466      newtree->SetName("Run");      newtree->SetName("Run");
467      //    file->Write("Run");      //
     //    newtree->Delete();  
468      delete newver;      delete newver;
469      delete newrun;      delete newrun;
470      delete oldver;      delete oldver;
471      delete oldrun;      delete oldrun;
472      //      //
473      if ( !found ){      if ( !found ){
474        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);
475        return(-5);        return(-5);
476      };      };
477      //      //
# Line 516  Int_t ItoRunInfo::Update(ULong64_t run, Line 480  Int_t ItoRunInfo::Update(ULong64_t run,
480    return(0);    return(0);
481  }  }
482    
483  Int_t ItoRunInfo::Read(ULong64_t idRun){  Int_t ItoRunInfo::Read(UInt_t idRun){
484    //    //
485    isreadonly = true;    isreadonly = true;
486    //    //
# Line 543  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 507  Int_t ItoRunInfo::Read(ULong64_t idRun){
507      //      //
508      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
509      //      //
510      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
511          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
512          return(-806);
513        };
514      //      //
515      first_file_entry = 0;      first_file_entry = 0;
516      //      //
# Line 551  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 518  Int_t ItoRunInfo::Read(ULong64_t idRun){
518        //        //
519        newtree->GetEntry(run);        newtree->GetEntry(run);
520        //        //
521        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
522        //        //
523        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);
524        //        //
525        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
526        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 ){  
527          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
528          norun++;          norun++;
529        };        };
530        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);
531      };      };
532    };    };
533    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
# Line 599  void ItoRunInfo::Close(){ Line 544  void ItoRunInfo::Close(){
544    updating = false;    updating = false;
545    first_file_entry = 0;    first_file_entry = 0;
546    last_file_entry = 0;    last_file_entry = 0;
547    file_entries = 0ULL;    file_entries = 0;
548    norun = 0;    norun = 0;
549    runlist = new TArrayL(0,NULL);    delete runlist;
550    file = new TFile();      file = new TFile();  
551    if ( isreadonly ) newtree->Delete();    if ( isreadonly ) newtree->Delete();
552  }  }
# Line 612  void ItoRunInfo::Clear(){ Line 557  void ItoRunInfo::Clear(){
557    
558  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
559    //    //
560    ItoRunInfo *run = new ItoRunInfo();    UInt_t startfrom = 0;
561      //
562      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
563      //
564      if ( entry > (UInt_t)last_file_entry ){
565        for ( UInt_t nrun = 0; nrun < norun; nrun++){  
566          if ( ID == (UInt_t)runlist->At(nrun) ) {
567            startfrom = nrun+1;
568            break;
569          };
570        };
571      } else {
572        startfrom = 0;
573      };
574      //
575      if ( startfrom >= norun ) startfrom = 0;
576    //    //
577    for ( UInt_t nrun = 0; nrun < norun; nrun++){     retry:
578      run->GetRunInfo((ULong64_t)nrun);    //
579      if ( entry >= (UInt_t)run->first_file_entry && entry <= (UInt_t)run->last_file_entry ){    for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
580        run->newtree->Delete();      GetRunInfo((UInt_t)runlist->At(nrun));
581        delete run;      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){
582        return(nrun);        return((UInt_t)runlist->At(nrun));
583      };      };
584    };    };
585    run->newtree->Delete();    if ( startfrom ){
586    delete run;      startfrom = 0;
587        goto retry;
588      };
589      printf(" ERROR! run not found \n");
590    return(0);    return(0);
591  }  }
592    
593  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
594    Bool_t found = false;    Bool_t found = false;
595    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
596    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 643  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 606  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
606    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
607      newtree->GetEntry(nrun);      newtree->GetEntry(nrun);
608      //      //
609      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
610        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;  
611        found = true;        found = true;
612        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);
613      };      };
614      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);
615    };    };
   if ( found ) return(0);  
616    delete nwver;    delete nwver;
617    delete nwrun;    delete nwrun;
618      if ( found ) return(0);
619    return(-800);    return(-800);
620  }  }
621    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23