/[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.6 by pam-fi, Fri Jul 21 11:00:13 2006 UTC revision 1.18 by mocchiut, Thu Sep 25 10:40:56 2008 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 20  using namespace std; Line 22  using namespace std;
22  //  //
23    
24  SoftInfo::SoftInfo() {  SoftInfo::SoftInfo() {
25      Clear();
26    }
27    
28    void SoftInfo::Clear(Option_t *t){
29    TRIG_ver = "";    TRIG_ver = "";
30    TOF_ver = "";    TOF_ver = "";
31    AC_ver = "";    AC_ver = "";
# Line 28  SoftInfo::SoftInfo() { Line 34  SoftInfo::SoftInfo() {
34    CAL_ver = "";    CAL_ver = "";
35    ND_ver = "";    ND_ver = "";
36    S4_ver = "";      S4_ver = "";  
37      DV_ver = "";
38  }  }
39    
40    UInt_t SoftInfo::GetSWinfo(TString Detector){
41      TString sver;
42      UInt_t version = 0;
43      if ( !strcmp(Detector.Data(),"TRIG") ){
44        sver = TRIG_ver;
45      };
46      if ( !strcmp(Detector.Data(),"TOF") ){
47        sver = TOF_ver;
48      };
49      if ( !strcmp(Detector.Data(),"AC") ){
50        sver = AC_ver;
51      };
52      if ( !strcmp(Detector.Data(),"TRK") ){
53        sver = TRK_ver;
54      };
55      if ( !strcmp(Detector.Data(),"CALO") ){
56        sver = CAL_ver;
57      };
58      if ( !strcmp(Detector.Data(),"S4") ){
59        sver = S4_ver;
60      };
61      if ( !strcmp(Detector.Data(),"DV") ){
62        sver = DV_ver;
63      };
64      if ( !strcmp(Detector.Data(),"ND") ){
65        sver = ND_ver;
66      };
67      if ( !strcmp(Detector.Data(),"ORB") ){
68        sver = ORB_ver;
69      };
70      sver.ReplaceAll("v",1," ",1);
71      sver.ReplaceAll("r",1," ",1);
72      version = (UInt_t)sver.Atoi();
73      return(version);
74    };
75    
76  /**  /**
77   * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common).   * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common).
78   */   */
# Line 51  ItoRunInfo::ItoRunInfo() { Line 94  ItoRunInfo::ItoRunInfo() {
94    isreadonly = true;    isreadonly = true;
95    first_file_entry = 0;    first_file_entry = 0;
96    last_file_entry = 0;    last_file_entry = 0;
97    file_entries = 0ULL;    file_entries = 0;
98    totnorun = 0LL;    totnorun = 0;
99      this->GL_RUN::Clear();
100    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 = "";    
101    norun = 0;    norun = 0;
102    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
103    file = new TFile();    file = NULL;
104    newtree = new TTree();    newtree = new TTree();
105  }  }
106    
# Line 73  ItoRunInfo::ItoRunInfo(TFile *processFl) Line 109  ItoRunInfo::ItoRunInfo(TFile *processFl)
109    file=(TFile*)processFl;    file=(TFile*)processFl;
110    dbc=NULL;    dbc=NULL;
111    processFolder = "";    processFolder = "";
112    idRun = 0ULL;    idRun = 0;
113    Detector = "NONE";    Detector = "NONE";
114    //    //
115    reprocessing = false;    reprocessing = false;
116    updating = false;    updating = false;
117    first_file_entry = 0;    first_file_entry = 0;
118    last_file_entry = 0;    last_file_entry = 0;
119    file_entries = 0ULL;    file_entries = 0;
120    version = new SoftInfo();    version = new SoftInfo();
121    version->TRIG_ver = "";    //  glrun = new GL_RUN();
   version->TOF_ver = "";  
   version->AC_ver = "";  
   version->TRK_ver = "";  
   version->ORB_ver = "";  
   version->CAL_ver = "";  
   version->ND_ver = "";  
   version->S4_ver = "";    
122    norun = 0;    norun = 0;
123    totnorun = 0;    totnorun = 0;
124    //  runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
125      //
126    }
127    
128    
129    
130    TChain *ItoRunInfo::GetRunTree(TList *fl){
131      //
132      TChain *Tout = new TChain("Run");    
133      // loop over files and create chains  
134      TIter next(fl);
135      TSystemFile *questo = 0;
136      while ( (questo = (TSystemFile*) next()) ) {
137        TString name =  questo->GetName();
138        Tout->Add(name);
139      };
140      //
141      Tout->SetBranchAddress("RunInfo", GetPointerToRI());
142      printf("Run          : set branch address RunInfo\n");
143      Tout->SetBranchAddress("SoftInfo", GetPointerToSI());
144      printf("Software     : set branch address SoftInfo\n");
145      //
146      return Tout;                  
147    //    //
148  }  }
149    
# Line 106  ItoRunInfo::ItoRunInfo(TSQLServer *db, T Line 157  ItoRunInfo::ItoRunInfo(TSQLServer *db, T
157    updating = false;    updating = false;
158    first_file_entry = 0;    first_file_entry = 0;
159    last_file_entry = 0;    last_file_entry = 0;
160    file_entries = 0ULL;    file_entries = 0;
161    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 = "";    
162    norun = 0;    norun = 0;
163    totnorun = 0;    totnorun = 0;
164    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
165    //    //
166  }  }
167    
168  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
169      //
170      if ( glrun && newrun ){
171        //
172        //    printf("copy \n");
173        //
174        newrun->ID = glrun->ID                         ;
175        newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG                ;
176        newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0                 ;
177        newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2                 ;
178        newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME             ;
179        newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME            ;
180        newrun->EV_FROM = glrun->EV_FROM                    ;
181        newrun->EV_TO = glrun->EV_TO                      ;
182        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
183        newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE           ;
184        newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A         ;
185        newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B         ;
186        newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO             ;
187        newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO               ;
188        newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT              ;
189        newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT             ;
190        newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT              ;
191        newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT             ;
192        newrun->NEVENTS = glrun->NEVENTS                    ;
193        newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC              ;
194        newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC               ;
195        newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP       ;
196        newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE           ;
197        newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB         ;
198        newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE        ;
199        newrun->PKT_COUNTER = glrun->PKT_COUNTER                ;
200        newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER          ;
201        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
202        newrun->CAL_DSP_MASK  = glrun->CAL_DSP_MASK               ;
203        newrun->BOOT_NUMBER  = glrun->BOOT_NUMBER                ;
204        newrun->PHYSENDRUN_MASK_S3S2S12  = glrun->PHYSENDRUN_MASK_S3S2S12                 ;
205        newrun->PHYSENDRUN_MASK_S11CRC  = glrun->PHYSENDRUN_MASK_S11CRC                 ;
206        newrun->VALIDATION  = glrun->VALIDATION                 ;
207        //
208      };
209      //
210      if ( newver && sinfo ){
211        //
212        newver->TRIG_ver = sinfo->TRIG_ver;
213        newver->TOF_ver = sinfo->TOF_ver;
214        newver->AC_ver = sinfo->AC_ver;
215        newver->TRK_ver = sinfo->TRK_ver;
216        newver->ORB_ver = sinfo->ORB_ver;
217        newver->CAL_ver = sinfo->CAL_ver;
218        newver->S4_ver = sinfo->S4_ver;
219        newver->DV_ver = sinfo->DV_ver;
220        newver->ND_ver = sinfo->ND_ver;
221        //
222      };
223    }
224    
225    Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
226    //    //
227    isreadonly = false;    isreadonly = false;
228    idRun = run;    idRun = run;
# Line 141  Int_t ItoRunInfo::Update(ULong64_t run, Line 241  Int_t ItoRunInfo::Update(ULong64_t run,
241    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
242    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
243    //    //
244    ID = 0ULL;    this->GL_RUN::Clear();
245    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 = "";    
246    //    //
247    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
   //runlist->Reset();  
248    //    //
249    Bool_t found = false;    Bool_t found = false;
250    Int_t error = 0;    Int_t error = 0;
251    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
252    TTree *oldtree = 0;    TTree *oldtree = 0;
253    //    //
   //  
254    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
255    //    //
256    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 196  Int_t ItoRunInfo::Update(ULong64_t run, Line 266  Int_t ItoRunInfo::Update(ULong64_t run,
266      version->ORB_ver = Version;      version->ORB_ver = Version;
267      version->CAL_ver = Version;          version->CAL_ver = Version;    
268      version->S4_ver = Version;      version->S4_ver = Version;
269        version->DV_ver = Version;
270      version->ND_ver = Version;      version->ND_ver = Version;
271    } else {    } else {
272      if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;      if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;
# Line 204  Int_t ItoRunInfo::Update(ULong64_t run, Line 275  Int_t ItoRunInfo::Update(ULong64_t run,
275      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
276      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
277      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;
278        if ( !strcmp(Detector.Data(),"DV") ) version->DV_ver = Version;
279      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;
280      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;
281      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);
282    };    };
283    //    //
284    if ( !oldtree ) {    if ( !oldtree ) {
# Line 217  Int_t ItoRunInfo::Update(ULong64_t run, Line 289  Int_t ItoRunInfo::Update(ULong64_t run,
289      //      //
290    } else {    } else {
291      //      //
 //     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");  
     //  
292      updating = true;      updating = true;
293      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
294      //      //
# Line 260  Int_t ItoRunInfo::Update(ULong64_t run, Line 304  Int_t ItoRunInfo::Update(ULong64_t run,
304    //      //  
305    //    //
306    if ( !updating ){    if ( !updating ){
307      if ( idRun == 0ULL ){      if ( idRun == 0 ){
308        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");
309        return(-805);        return(-805);
310      };      };
311      //      //
     runlist = new TArrayL(1);  
     //  
312      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
313      //      //
314      if ( error ){      if ( error ){
315        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");
316        return(error);        return(error);
317      };      };
318      if ( ID == 0ULL ){      if ( ID == 0 ){
319        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);
320        return(-5);        return(-5);
321      };      };
322      //      //
323      //      //
324      //      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;  
325      //      //
326      // fill the tree;      // fill the tree;
327      //      //
# Line 311  Int_t ItoRunInfo::Update(ULong64_t run, Line 330  Int_t ItoRunInfo::Update(ULong64_t run,
330      totnorun = 1;      totnorun = 1;
331      reprocessing = false;      reprocessing = false;
332      first_file_entry = 0;      first_file_entry = 0;
333      last_file_entry = (UInt_t)(EV_REG_PHYS_TO - EV_REG_PHYS_FROM);      if ( EV_TO >= EV_FROM ) last_file_entry = (UInt_t)(EV_TO - EV_FROM);
334      norun = 1;      norun = 1;
335      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
336      //      //
337      newtree->SetName("Run");      newtree->SetName("Run");
338      //      //
339      file->cd();      file->cd();
340      //    file->Write("Run");      //
     //newtree->Delete();  
341      delete newver;      delete newver;
342      delete newrun;      delete newrun;
343      delete oldver;      delete oldver;
# Line 329  Int_t ItoRunInfo::Update(ULong64_t run, Line 347  Int_t ItoRunInfo::Update(ULong64_t run,
347      //      //
348    } else {    } else {
349      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
350      //      //
351      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
352      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
353      //      //
354      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
355      //      //
356      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
357          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
358          return(-806);
359        };
360      //      //
361      found = false;      found = false;
362      //      //
# Line 345  Int_t ItoRunInfo::Update(ULong64_t run, Line 364  Int_t ItoRunInfo::Update(ULong64_t run,
364        //        //
365        oldtree->GetEntry(run);        oldtree->GetEntry(run);
366        //        //
367        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;  
368        //        //
369        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
370        //        //
371        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);
372        //        //
373        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
374          //          //
375          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u \n",idRun);
376          //          //
377          found = true;          found = true;
378          //          //
# Line 393  Int_t ItoRunInfo::Update(ULong64_t run, Line 390  Int_t ItoRunInfo::Update(ULong64_t run,
390              return(error);              return(error);
391            };            };
392            //            //
393            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
394            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;  
395          } else {          } else {
396            //            //
397            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 418  Int_t ItoRunInfo::Update(ULong64_t run, Line 402  Int_t ItoRunInfo::Update(ULong64_t run,
402              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
403              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
404              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
405                newver->DV_ver = oldver->DV_ver;
406              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
407              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
408            };            };
# Line 428  Int_t ItoRunInfo::Update(ULong64_t run, Line 413  Int_t ItoRunInfo::Update(ULong64_t run,
413              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
414              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
415              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
416                newver->DV_ver = oldver->DV_ver;
417              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
418              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
419              if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;
# Line 438  Int_t ItoRunInfo::Update(ULong64_t run, Line 424  Int_t ItoRunInfo::Update(ULong64_t run,
424              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
425              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
426              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
427                newver->DV_ver = oldver->DV_ver;
428              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
429              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
430              newver->AC_ver = version->AC_ver;              newver->AC_ver = version->AC_ver;
# Line 448  Int_t ItoRunInfo::Update(ULong64_t run, Line 435  Int_t ItoRunInfo::Update(ULong64_t run,
435              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
436              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
437              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
438                newver->DV_ver = oldver->DV_ver;
439              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
440              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
441              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 459  Int_t ItoRunInfo::Update(ULong64_t run, Line 447  Int_t ItoRunInfo::Update(ULong64_t run,
447              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
448              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
449              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
450                newver->DV_ver = oldver->DV_ver;
451              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
452              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
453              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 468  Int_t ItoRunInfo::Update(ULong64_t run, Line 457  Int_t ItoRunInfo::Update(ULong64_t run,
457            if ( !strcmp(Detector.Data(),"CALO") ){            if ( !strcmp(Detector.Data(),"CALO") ){
458              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
459              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
460                newver->DV_ver = oldver->DV_ver;
461              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
462              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
463              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
# Line 484  Int_t ItoRunInfo::Update(ULong64_t run, Line 474  Int_t ItoRunInfo::Update(ULong64_t run,
474              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
475              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
476              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
477                newver->DV_ver = oldver->DV_ver;
478              newver->S4_ver = version->S4_ver;              newver->S4_ver = version->S4_ver;
479              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;
480            };            };
481              if ( !strcmp(Detector.Data(),"DV") ){
482                newver->TRIG_ver = oldver->TRIG_ver;
483                newver->TOF_ver = oldver->TOF_ver;
484                newver->ND_ver = oldver->ND_ver;
485                newver->AC_ver = oldver->AC_ver;
486                newver->TRK_ver = oldver->TRK_ver;
487                newver->ORB_ver = oldver->ORB_ver;
488                newver->CAL_ver = oldver->CAL_ver;
489                newver->S4_ver = oldver->S4_ver;
490                newver->DV_ver = version->DV_ver;
491                if ( strcmp(oldver->DV_ver.Data(),"") ) reprocessing = true;
492              };
493            if ( !strcmp(Detector.Data(),"ND") ){            if ( !strcmp(Detector.Data(),"ND") ){
494              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
495              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
496                newver->DV_ver = oldver->DV_ver;
497              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
498              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
499              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
# Line 500  Int_t ItoRunInfo::Update(ULong64_t run, Line 504  Int_t ItoRunInfo::Update(ULong64_t run,
504            };            };
505          };          };
506          //          //
507          last_file_entry = first_file_entry + (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);          if ( oldrun->EV_TO >= oldrun->EV_FROM ) last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1);
508          //          //
509        } else {        } else {
510          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);
511        };        };
512        //        //
513        file->cd();        file->cd();
# Line 511  Int_t ItoRunInfo::Update(ULong64_t run, Line 515  Int_t ItoRunInfo::Update(ULong64_t run,
515        //        //
516      };      };
517      //      //
     //    temprfile->Close();  
     //    gSystem->Unlink(temprname.str().c_str());  
     //    if ( ismydir ) gSystem->Unlink(tempdir.str().c_str());  
518      file->cd();      file->cd();
519      if ( oldtree ) oldtree->Delete("all");      if ( oldtree ) oldtree->Delete("all");
520      newtree->SetName("Run");      newtree->SetName("Run");
521      //    file->Write("Run");      //
     //    newtree->Delete();  
522      delete newver;      delete newver;
523      delete newrun;      delete newrun;
524      delete oldver;      delete oldver;
525      delete oldrun;      delete oldrun;
526      //      //
527      if ( !found ){      if ( !found ){
528        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);
529        return(-5);        return(-5);
530      };      };
531      //      //
# Line 534  Int_t ItoRunInfo::Update(ULong64_t run, Line 534  Int_t ItoRunInfo::Update(ULong64_t run,
534    return(0);    return(0);
535  }  }
536    
537  Int_t ItoRunInfo::Read(ULong64_t idRun){  Int_t ItoRunInfo::Read(UInt_t idRun){
538    //    //
539    isreadonly = true;    isreadonly = true;
540    //    //
# Line 561  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 561  Int_t ItoRunInfo::Read(ULong64_t idRun){
561      //      //
562      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
563      //      //
564      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
565          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
566          return(-806);
567        };
568      //      //
569      first_file_entry = 0;      first_file_entry = 0;
570      //      //
# Line 569  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 572  Int_t ItoRunInfo::Read(ULong64_t idRun){
572        //        //
573        newtree->GetEntry(run);        newtree->GetEntry(run);
574        //        //
575        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
576        //        //
577        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);
578        //        //
579        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
580        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 ){  
581          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
582          norun++;          norun++;
583        };        };
584        last_file_entry = first_file_entry + (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        if ( newrun->EV_TO >= newrun->EV_FROM ) last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1);
585      };      };
586    };    };
587    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
# Line 617  void ItoRunInfo::Close(){ Line 598  void ItoRunInfo::Close(){
598    updating = false;    updating = false;
599    first_file_entry = 0;    first_file_entry = 0;
600    last_file_entry = 0;    last_file_entry = 0;
601    file_entries = 0ULL;    file_entries = 0;
602    norun = 0;    norun = 0;
603    runlist = new TArrayL(0,NULL);    delete runlist;
604    file = new TFile();      //  file = new TFile();  
605      file = 0;  
606    if ( isreadonly ) newtree->Delete();    if ( isreadonly ) newtree->Delete();
607  }  }
608    
609  void ItoRunInfo::Clear(){  void ItoRunInfo::Clear(Option_t *t){
610    if ( newtree ) newtree->Delete();    if ( newtree ) newtree->Delete();
611  }  }
612    
# Line 636  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 618  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
618    //    //
619    if ( entry > (UInt_t)last_file_entry ){    if ( entry > (UInt_t)last_file_entry ){
620      for ( UInt_t nrun = 0; nrun < norun; nrun++){        for ( UInt_t nrun = 0; nrun < norun; nrun++){  
621        if ( ID == (ULong64_t)runlist->At(nrun) ) {        if ( ID == (UInt_t)runlist->At(nrun) ) {
622          startfrom = nrun+1;          startfrom = nrun+1;
623          break;          break;
624        };        };
# Line 650  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 632  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
632   retry:   retry:
633    //    //
634    for ( UInt_t nrun = startfrom; nrun < norun; nrun++){      for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
635      GetRunInfo((ULong64_t)runlist->At(nrun));      GetRunInfo((UInt_t)runlist->At(nrun));
636      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){
637        return((UInt_t)runlist->At(nrun));        return((UInt_t)runlist->At(nrun));
638      };      };
# Line 663  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 645  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
645    return(0);    return(0);
646  }  }
647    
648  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
649    Bool_t found = false;    Bool_t found = false;
650    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
651    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 679  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 661  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
661    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
662      newtree->GetEntry(nrun);      newtree->GetEntry(nrun);
663      //      //
664      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
665        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;  
666        found = true;        found = true;
667        last_file_entry = first_file_entry + (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1);        if ( nwrun->EV_TO >= nwrun->EV_FROM ) last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1);
668      };      };
669      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);
670    };    };
671    delete nwver;    delete nwver;
672    delete nwrun;    delete nwrun;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.23