/[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.21 by mocchiut, Tue May 15 14:35:31 2012 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 45  void SoftInfo::GetLevel2Struct(cSoftInfo Line 88  void SoftInfo::GetLevel2Struct(cSoftInfo
88  }  }
89  /***********************/  /***********************/
90    
91    ItoRunInfo::~ItoRunInfo() {
92      this->GL_RUN::Clear();
93    }
94    
95  ItoRunInfo::ItoRunInfo() {  ItoRunInfo::ItoRunInfo() {
96    reprocessing = false;    reprocessing = false;
97    updating = false;    updating = false;
98    isreadonly = true;    isreadonly = true;
99    first_file_entry = 0;    first_file_entry = 0;
100    last_file_entry = 0;    last_file_entry = 0;
101    file_entries = 0ULL;    file_entries = 0;
102    totnorun = 0LL;    totnorun = 0;
103      this->GL_RUN::Clear();
104    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 = "";    
105    norun = 0;    norun = 0;
106    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
107    file = new TFile();    file = NULL;
108    newtree = new TTree();    newtree = NULL;//new TTree();
109  }  }
110    
111  ItoRunInfo::ItoRunInfo(TFile *processFl){  ItoRunInfo::ItoRunInfo(TFile *processFl){
# Line 73  ItoRunInfo::ItoRunInfo(TFile *processFl) Line 113  ItoRunInfo::ItoRunInfo(TFile *processFl)
113    file=(TFile*)processFl;    file=(TFile*)processFl;
114    dbc=NULL;    dbc=NULL;
115    processFolder = "";    processFolder = "";
116    idRun = 0ULL;    idRun = 0;
117    Detector = "NONE";    Detector = "NONE";
118    //    //
119    reprocessing = false;    reprocessing = false;
120    updating = false;    updating = false;
121    first_file_entry = 0;    first_file_entry = 0;
122    last_file_entry = 0;    last_file_entry = 0;
123    file_entries = 0ULL;    file_entries = 0;
124    version = new SoftInfo();    version = new SoftInfo();
125    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 = "";    
126    norun = 0;    norun = 0;
127    totnorun = 0;    totnorun = 0;
128    //  runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
129      newtree = NULL;
130      //
131    }
132    
133    
134    
135    TChain *ItoRunInfo::GetRunTree(TList *fl){
136      //
137      TChain *Tout = new TChain("Run");    
138      // loop over files and create chains  
139      TIter next(fl);
140      TSystemFile *questo = 0;
141      while ( (questo = (TSystemFile*) next()) ) {
142        TString name =  questo->GetName();
143        Tout->Add(name);
144      };
145      //
146      Tout->SetBranchAddress("RunInfo", GetPointerToRI());
147      printf("Run          : set branch address RunInfo\n");
148      Tout->SetBranchAddress("SoftInfo", GetPointerToSI());
149      printf("Software     : set branch address SoftInfo\n");
150      //
151      return Tout;                  
152    //    //
153  }  }
154    
# Line 106  ItoRunInfo::ItoRunInfo(TSQLServer *db, T Line 162  ItoRunInfo::ItoRunInfo(TSQLServer *db, T
162    updating = false;    updating = false;
163    first_file_entry = 0;    first_file_entry = 0;
164    last_file_entry = 0;    last_file_entry = 0;
165    file_entries = 0ULL;    file_entries = 0;
166    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 = "";    
167    norun = 0;    norun = 0;
168    totnorun = 0;    totnorun = 0;
169    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
170      //
171    }
172    
173    void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
174    //    //
175      if ( glrun && newrun ){
176        //
177    //    printf("copy \n");
178        //
179        newrun->ID = glrun->ID                         ;
180        newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG                ;
181        newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0                 ;
182        newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2                 ;
183        newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME             ;
184        newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME            ;
185        newrun->EV_FROM = glrun->EV_FROM                    ;
186        newrun->EV_TO = glrun->EV_TO                      ;
187        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
188        newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE           ;
189        newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A         ;
190        newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B         ;
191        newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO             ;
192        newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO               ;
193        newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT              ;
194        newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT             ;
195        newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT              ;
196        newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT             ;
197        newrun->NEVENTS = glrun->NEVENTS                    ;
198        newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC              ;
199        newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC               ;
200        newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP       ;
201        newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE           ;
202        newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB         ;
203        newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE        ;
204        newrun->PKT_COUNTER = glrun->PKT_COUNTER                ;
205        newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER          ;
206        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
207        newrun->CAL_DSP_MASK  = glrun->CAL_DSP_MASK               ;
208        newrun->BOOT_NUMBER  = glrun->BOOT_NUMBER                ;
209        newrun->PHYSENDRUN_MASK_S3S2S12  = glrun->PHYSENDRUN_MASK_S3S2S12                 ;
210        newrun->PHYSENDRUN_MASK_S11CRC  = glrun->PHYSENDRUN_MASK_S11CRC                 ;
211        newrun->VALIDATION  = glrun->VALIDATION                 ;
212        //
213      };
214      //
215      if ( newver && sinfo ){
216        //
217        newver->TRIG_ver = sinfo->TRIG_ver;
218        newver->TOF_ver = sinfo->TOF_ver;
219        newver->AC_ver = sinfo->AC_ver;
220        newver->TRK_ver = sinfo->TRK_ver;
221        newver->ORB_ver = sinfo->ORB_ver;
222        newver->CAL_ver = sinfo->CAL_ver;
223        newver->S4_ver = sinfo->S4_ver;
224        newver->DV_ver = sinfo->DV_ver;
225        newver->ND_ver = sinfo->ND_ver;
226        //
227      };
228  }  }
229    
230  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
231    //    //
232    isreadonly = false;    isreadonly = false;
233    idRun = run;    idRun = run;
234    //    //
235    Bool_t debug = false;    Bool_t debug = false;
236    //    //
237    Bool_t ismydir = false;    //  Bool_t ismydir = false;
238    //    //
239    if ( !strcmp(processFolder.Data(),"") ){    if ( !strcmp(processFolder.Data(),"") ){
240      processFolder = "runinfoFolder";      processFolder = "runinfoFolder";
241      ismydir = true;      //    ismydir = true;
242    };    };
243    //    //
244    GL_RUN *oldrun = new GL_RUN();    GL_RUN *oldrun = new GL_RUN();
# Line 141  Int_t ItoRunInfo::Update(ULong64_t run, Line 246  Int_t ItoRunInfo::Update(ULong64_t run,
246    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
247    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
248    //    //
249    ID = 0ULL;    this->GL_RUN::Clear();
250    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 = "";    
251    //    //
252    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
   //runlist->Reset();  
253    //    //
254    Bool_t found = false;    Bool_t found = false;
255    Int_t error = 0;    Int_t error = 0;
256    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
257    TTree *oldtree = 0;    TTree *oldtree = 0;
258    //    //
   //  
259    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
260    //    //
261    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 196  Int_t ItoRunInfo::Update(ULong64_t run, Line 271  Int_t ItoRunInfo::Update(ULong64_t run,
271      version->ORB_ver = Version;      version->ORB_ver = Version;
272      version->CAL_ver = Version;          version->CAL_ver = Version;    
273      version->S4_ver = Version;      version->S4_ver = Version;
274        version->DV_ver = Version;
275      version->ND_ver = Version;      version->ND_ver = Version;
276    } else {    } else {
277      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 280  Int_t ItoRunInfo::Update(ULong64_t run,
280      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
281      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
282      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;
283        if ( !strcmp(Detector.Data(),"DV") ) version->DV_ver = Version;
284      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;
285      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;
286      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);
287    };    };
288    //    //
289    if ( !oldtree ) {    if ( !oldtree ) {
# Line 217  Int_t ItoRunInfo::Update(ULong64_t run, Line 294  Int_t ItoRunInfo::Update(ULong64_t run,
294      //      //
295    } else {    } else {
296      //      //
 //     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");  
     //  
297      updating = true;      updating = true;
298      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
299      //      //
# Line 260  Int_t ItoRunInfo::Update(ULong64_t run, Line 309  Int_t ItoRunInfo::Update(ULong64_t run,
309    //      //  
310    //    //
311    if ( !updating ){    if ( !updating ){
312      if ( idRun == 0ULL ){      if ( idRun == 0 ){
313        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");
314        return(-805);        return(-805);
315      };      };
316      //      //
     runlist = new TArrayL(1);  
     //  
317      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
318      //      //
319      if ( error ){      if ( error ){
320        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");
321        return(error);        return(error);
322      };      };
323      if ( ID == 0ULL ){      if ( ID == 0 ){
324        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);
325        return(-5);        return(-5);
326      };      };
327      //      //
328      //      //
329      //      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;  
330      //      //
331      // fill the tree;      // fill the tree;
332      //      //
# Line 311  Int_t ItoRunInfo::Update(ULong64_t run, Line 335  Int_t ItoRunInfo::Update(ULong64_t run,
335      totnorun = 1;      totnorun = 1;
336      reprocessing = false;      reprocessing = false;
337      first_file_entry = 0;      first_file_entry = 0;
338      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);
339      norun = 1;      norun = 1;
340      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
341      //      //
342      newtree->SetName("Run");      newtree->SetName("Run");
343      //      //
344      file->cd();      file->cd();
345      //    file->Write("Run");      //
     //newtree->Delete();  
346      delete newver;      delete newver;
347      delete newrun;      delete newrun;
348      delete oldver;      delete oldver;
# Line 329  Int_t ItoRunInfo::Update(ULong64_t run, Line 352  Int_t ItoRunInfo::Update(ULong64_t run,
352      //      //
353    } else {    } else {
354      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
355      //      //
356      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
357      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
358      //      //
359      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
360      //      //
361      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
362          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
363          return(-806);
364        };
365      //      //
366      found = false;      found = false;
367      //      //
368      for ( UInt_t run = 0; run < totnorun; run++){      for ( UInt_t run = 0; run < totnorun; run++){
369        //        //
370        oldtree->GetEntry(run);        if ( oldtree->GetEntry(run) <= 0 ) throw -36;
371        //        //
372        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;  
373        //        //
374        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
375        //        //
376        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);
377        //        //
378        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
379          //          //
380          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u newrun->ID %i \n",idRun,(int)newrun->ID);
381          //          //
382          found = true;          found = true;
383          //          //
# Line 393  Int_t ItoRunInfo::Update(ULong64_t run, Line 395  Int_t ItoRunInfo::Update(ULong64_t run,
395              return(error);              return(error);
396            };            };
397            //            //
398            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
399            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;  
400          } else {          } else {
401            //            //
402            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 418  Int_t ItoRunInfo::Update(ULong64_t run, Line 407  Int_t ItoRunInfo::Update(ULong64_t run,
407              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
408              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
409              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
410                newver->DV_ver = oldver->DV_ver;
411              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
412              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
413            };            };
# Line 428  Int_t ItoRunInfo::Update(ULong64_t run, Line 418  Int_t ItoRunInfo::Update(ULong64_t run,
418              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
419              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
420              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
421                newver->DV_ver = oldver->DV_ver;
422              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
423              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
424              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 429  Int_t ItoRunInfo::Update(ULong64_t run,
429              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
430              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
431              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
432                newver->DV_ver = oldver->DV_ver;
433              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
434              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
435              newver->AC_ver = version->AC_ver;              newver->AC_ver = version->AC_ver;
# Line 448  Int_t ItoRunInfo::Update(ULong64_t run, Line 440  Int_t ItoRunInfo::Update(ULong64_t run,
440              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
441              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
442              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
443                newver->DV_ver = oldver->DV_ver;
444              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
445              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
446              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 459  Int_t ItoRunInfo::Update(ULong64_t run, Line 452  Int_t ItoRunInfo::Update(ULong64_t run,
452              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
453              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
454              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
455                newver->DV_ver = oldver->DV_ver;
456              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
457              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
458              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 468  Int_t ItoRunInfo::Update(ULong64_t run, Line 462  Int_t ItoRunInfo::Update(ULong64_t run,
462            if ( !strcmp(Detector.Data(),"CALO") ){            if ( !strcmp(Detector.Data(),"CALO") ){
463              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
464              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
465                newver->DV_ver = oldver->DV_ver;
466              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
467              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
468              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
# Line 484  Int_t ItoRunInfo::Update(ULong64_t run, Line 479  Int_t ItoRunInfo::Update(ULong64_t run,
479              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
480              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
481              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
482                newver->DV_ver = oldver->DV_ver;
483              newver->S4_ver = version->S4_ver;              newver->S4_ver = version->S4_ver;
484              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;
485            };            };
486              if ( !strcmp(Detector.Data(),"DV") ){
487                newver->TRIG_ver = oldver->TRIG_ver;
488                newver->TOF_ver = oldver->TOF_ver;
489                newver->ND_ver = oldver->ND_ver;
490                newver->AC_ver = oldver->AC_ver;
491                newver->TRK_ver = oldver->TRK_ver;
492                newver->ORB_ver = oldver->ORB_ver;
493                newver->CAL_ver = oldver->CAL_ver;
494                newver->S4_ver = oldver->S4_ver;
495                newver->DV_ver = version->DV_ver;
496                if ( strcmp(oldver->DV_ver.Data(),"") ) reprocessing = true;
497              };
498            if ( !strcmp(Detector.Data(),"ND") ){            if ( !strcmp(Detector.Data(),"ND") ){
499              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
500              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
501                newver->DV_ver = oldver->DV_ver;
502              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
503              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
504              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
# Line 500  Int_t ItoRunInfo::Update(ULong64_t run, Line 509  Int_t ItoRunInfo::Update(ULong64_t run,
509            };            };
510          };          };
511          //          //
512          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);
513          //          //
514        } else {        } else {
515          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);
516        };        };
517        //        //
518        file->cd();        file->cd();
519          if ( debug ) printf("filling: totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID);
520        newtree->Fill();        newtree->Fill();
521        //        //
522      };      };
523      //      //
     //    temprfile->Close();  
     //    gSystem->Unlink(temprname.str().c_str());  
     //    if ( ismydir ) gSystem->Unlink(tempdir.str().c_str());  
524      file->cd();      file->cd();
525      if ( oldtree ) oldtree->Delete("all");      if ( oldtree ) oldtree->Delete("all");
526      newtree->SetName("Run");      newtree->SetName("Run");
527      //    file->Write("Run");      //
     //    newtree->Delete();  
528      delete newver;      delete newver;
529      delete newrun;      delete newrun;
530      delete oldver;      delete oldver;
531      delete oldrun;      delete oldrun;
532      //      //
533      if ( !found ){      if ( !found ){
534        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);
535        return(-5);        return(-5);
536      };      };
537      //      //
538        this->Write();
539      //    newtree->Write();      //    newtree->Write();
540    };    };
541    //  if ( oldtree ) oldtree->Delete(); // crasha qua in queste righe e se non le metti...
542    //  if ( newver ) delete newver;
543    //  if ( newrun ) delete newrun;
544    //  if ( oldver ) delete oldver;
545    //  if ( oldrun ) delete oldrun;
546    return(0);    return(0);
547  }  }
548    
549  Int_t ItoRunInfo::Read(ULong64_t idRun){  void ItoRunInfo::Write(){
550      file->cd();
551      newtree->Write("Run",TObject::kOverwrite);
552    }
553    
554    Int_t ItoRunInfo::Read(UInt_t idRun){
555    //    //
556    isreadonly = true;    isreadonly = true;
557    //    //
# Line 561  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 578  Int_t ItoRunInfo::Read(ULong64_t idRun){
578      //      //
579      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
580      //      //
581      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
582          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
583          return(-806);
584        };
585      //      //
586      first_file_entry = 0;      first_file_entry = 0;
587      //      //
588      for ( UInt_t run = 0; run < totnorun; run++){      for ( UInt_t run = 0; run < totnorun; run++){
589        //        //
590        newtree->GetEntry(run);        if ( newtree->GetEntry(run) <= 0 ) throw -36;
591        //        //
592        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
593        //        //
594        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);
595        //        //
596        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
597        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 ){  
598          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
599          norun++;          norun++;
600        };        };
601        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);
602      };      };
603    };    };
604    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
# Line 617  void ItoRunInfo::Close(){ Line 615  void ItoRunInfo::Close(){
615    updating = false;    updating = false;
616    first_file_entry = 0;    first_file_entry = 0;
617    last_file_entry = 0;    last_file_entry = 0;
618    file_entries = 0ULL;    file_entries = 0;
619    norun = 0;    norun = 0;
620    runlist = new TArrayL(0,NULL);    delete runlist;
621    file = new TFile();      //  file = new TFile();  
622    if ( isreadonly ) newtree->Delete();    file = 0;  
623      //  if ( isreadonly ) newtree->Delete();
624  }  }
625    
626  void ItoRunInfo::Clear(){  void ItoRunInfo::Clear(Option_t *t){
627    if ( newtree ) newtree->Delete();    if ( newtree ) newtree->Delete();
628  }  }
629    
# Line 636  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 635  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
635    //    //
636    if ( entry > (UInt_t)last_file_entry ){    if ( entry > (UInt_t)last_file_entry ){
637      for ( UInt_t nrun = 0; nrun < norun; nrun++){        for ( UInt_t nrun = 0; nrun < norun; nrun++){  
638        if ( ID == (ULong64_t)runlist->At(nrun) ) {        if ( ID == (UInt_t)runlist->At(nrun) ) {
639          startfrom = nrun+1;          startfrom = nrun+1;
640          break;          break;
641        };        };
# Line 650  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 649  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
649   retry:   retry:
650    //    //
651    for ( UInt_t nrun = startfrom; nrun < norun; nrun++){      for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
652      GetRunInfo((ULong64_t)runlist->At(nrun));      GetRunInfo((UInt_t)runlist->At(nrun));
653      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 ){
654        return((UInt_t)runlist->At(nrun));        return((UInt_t)runlist->At(nrun));
655      };      };
# Line 663  UInt_t ItoRunInfo::GetRunForEntry(UInt_t Line 662  UInt_t ItoRunInfo::GetRunForEntry(UInt_t
662    return(0);    return(0);
663  }  }
664    
665  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
666    Bool_t found = false;    Bool_t found = false;
667    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
668    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 677  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 676  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
676    totnorun = newtree->GetEntries();    totnorun = newtree->GetEntries();
677    //    //
678    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
679      newtree->GetEntry(nrun);      if ( newtree->GetEntry(nrun) <= 0 ) throw -36;
680      //      //
681      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
682        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;  
683        found = true;        found = true;
684        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);
685      };      };
686      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);
687    };    };
688    delete nwver;    delete nwver;
689    delete nwrun;    delete nwrun;

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

  ViewVC Help
Powered by ViewVC 1.1.23