/[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.4 by mocchiut, Mon Jul 17 12:14:30 2006 UTC revision 1.17 by mocchiut, Mon Nov 26 08:01:15 2007 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).
78     */
79    void SoftInfo::GetLevel2Struct(cSoftInfo *l2) const{
80      l2->FillTrigWith(TRIG_ver);
81      l2->FillTofWith(TOF_ver);
82      l2->FillAcWith(AC_ver);
83      l2->FillTrkWith(TRK_ver);
84      l2->FillOrbWith(ORB_ver);
85      l2->FillCalWith(CAL_ver);
86      l2->FillNdWith(ND_ver);
87      l2->FillS4With(S4_ver);
88    }
89    /***********************/
90    
91  ItoRunInfo::ItoRunInfo() {  ItoRunInfo::ItoRunInfo() {
92    reprocessing = false;    reprocessing = false;
93    updating = false;    updating = false;
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 58  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 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 90  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 TArrayI(500);
165      //
166    }
167    
168    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->VALIDATION  = glrun->VALIDATION                 ;
205        //
206      };
207    //    //
208      if ( newver && sinfo ){
209        //
210        newver->TRIG_ver = sinfo->TRIG_ver;
211        newver->TOF_ver = sinfo->TOF_ver;
212        newver->AC_ver = sinfo->AC_ver;
213        newver->TRK_ver = sinfo->TRK_ver;
214        newver->ORB_ver = sinfo->ORB_ver;
215        newver->CAL_ver = sinfo->CAL_ver;
216        newver->S4_ver = sinfo->S4_ver;
217        newver->DV_ver = sinfo->DV_ver;
218        newver->ND_ver = sinfo->ND_ver;
219        //
220      };
221  }  }
222    
223  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
224    //    //
225    isreadonly = false;    isreadonly = false;
226    idRun = run;    idRun = run;
# Line 124  Int_t ItoRunInfo::Update(ULong64_t run, Line 239  Int_t ItoRunInfo::Update(ULong64_t run,
239    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
240    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
241    //    //
242    ID = 0ULL;    this->GL_RUN::Clear();
243    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 = "";    
244    //    //
245    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
246    //    //
247    Bool_t found = false;    Bool_t found = false;
248    Int_t error = 0;    Int_t error = 0;
249    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
250    TTree *oldtree = 0;    TTree *oldtree = 0;
251    //    //
   //  
252    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
253    //    //
254    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 178  Int_t ItoRunInfo::Update(ULong64_t run, Line 264  Int_t ItoRunInfo::Update(ULong64_t run,
264      version->ORB_ver = Version;      version->ORB_ver = Version;
265      version->CAL_ver = Version;          version->CAL_ver = Version;    
266      version->S4_ver = Version;      version->S4_ver = Version;
267        version->DV_ver = Version;
268      version->ND_ver = Version;      version->ND_ver = Version;
269    } else {    } else {
270      if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;      if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;
# Line 186  Int_t ItoRunInfo::Update(ULong64_t run, Line 273  Int_t ItoRunInfo::Update(ULong64_t run,
273      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
274      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
275      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;
276        if ( !strcmp(Detector.Data(),"DV") ) version->DV_ver = Version;
277      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;
278      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;
279      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);
280    };    };
281    //    //
282    if ( !oldtree ) {    if ( !oldtree ) {
# Line 199  Int_t ItoRunInfo::Update(ULong64_t run, Line 287  Int_t ItoRunInfo::Update(ULong64_t run,
287      //      //
288    } else {    } else {
289      //      //
 //     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");  
     //  
290      updating = true;      updating = true;
291      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
292      //      //
# Line 242  Int_t ItoRunInfo::Update(ULong64_t run, Line 302  Int_t ItoRunInfo::Update(ULong64_t run,
302    //      //  
303    //    //
304    if ( !updating ){    if ( !updating ){
305      if ( idRun == 0ULL ){      if ( idRun == 0 ){
306        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");
307        return(-805);        return(-805);
308      };      };
309      //      //
     runlist = new TArrayL(1);  
     //  
310      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
311      //      //
312      if ( error ){      if ( error ){
313        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");
314        return(error);        return(error);
315      };      };
316      if ( ID == 0ULL ){      if ( ID == 0 ){
317        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);
318        return(-5);        return(-5);
319      };      };
320      //      //
321      //      //
322      //      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;  
323      //      //
324      // fill the tree;      // fill the tree;
325      //      //
# Line 293  Int_t ItoRunInfo::Update(ULong64_t run, Line 328  Int_t ItoRunInfo::Update(ULong64_t run,
328      totnorun = 1;      totnorun = 1;
329      reprocessing = false;      reprocessing = false;
330      first_file_entry = 0;      first_file_entry = 0;
331      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);
332      norun = 1;      norun = 1;
333      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
334      //      //
335      newtree->SetName("Run");      newtree->SetName("Run");
336      //      //
337      file->cd();      file->cd();
338      //    file->Write("Run");      //
     //newtree->Delete();  
339      delete newver;      delete newver;
340      delete newrun;      delete newrun;
341      delete oldver;      delete oldver;
# Line 311  Int_t ItoRunInfo::Update(ULong64_t run, Line 345  Int_t ItoRunInfo::Update(ULong64_t run,
345      //      //
346    } else {    } else {
347      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
348      //      //
349      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
350      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
351      //      //
352      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
353      //      //
354      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
355          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
356          return(-806);
357        };
358      //      //
359      found = false;      found = false;
360      //      //
# Line 327  Int_t ItoRunInfo::Update(ULong64_t run, Line 362  Int_t ItoRunInfo::Update(ULong64_t run,
362        //        //
363        oldtree->GetEntry(run);        oldtree->GetEntry(run);
364        //        //
365        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;  
366        //        //
367        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
368        //        //
369        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);
370        //        //
371        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
372          //          //
373          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u \n",idRun);
374          //          //
375          found = true;          found = true;
376          //          //
# Line 375  Int_t ItoRunInfo::Update(ULong64_t run, Line 388  Int_t ItoRunInfo::Update(ULong64_t run,
388              return(error);              return(error);
389            };            };
390            //            //
391            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
392            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;  
393          } else {          } else {
394            //            //
395            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 400  Int_t ItoRunInfo::Update(ULong64_t run, Line 400  Int_t ItoRunInfo::Update(ULong64_t run,
400              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
401              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
402              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
403                newver->DV_ver = oldver->DV_ver;
404              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
405              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
406            };            };
# Line 410  Int_t ItoRunInfo::Update(ULong64_t run, Line 411  Int_t ItoRunInfo::Update(ULong64_t run,
411              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
412              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
413              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
414                newver->DV_ver = oldver->DV_ver;
415              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
416              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
417              if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;
# Line 420  Int_t ItoRunInfo::Update(ULong64_t run, Line 422  Int_t ItoRunInfo::Update(ULong64_t run,
422              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
423              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
424              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
425                newver->DV_ver = oldver->DV_ver;
426              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
427              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
428              newver->AC_ver = version->AC_ver;              newver->AC_ver = version->AC_ver;
# Line 430  Int_t ItoRunInfo::Update(ULong64_t run, Line 433  Int_t ItoRunInfo::Update(ULong64_t run,
433              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
434              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
435              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
436                newver->DV_ver = oldver->DV_ver;
437              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
438              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
439              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 441  Int_t ItoRunInfo::Update(ULong64_t run, Line 445  Int_t ItoRunInfo::Update(ULong64_t run,
445              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
446              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
447              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
448                newver->DV_ver = oldver->DV_ver;
449              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
450              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
451              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 450  Int_t ItoRunInfo::Update(ULong64_t run, Line 455  Int_t ItoRunInfo::Update(ULong64_t run,
455            if ( !strcmp(Detector.Data(),"CALO") ){            if ( !strcmp(Detector.Data(),"CALO") ){
456              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
457              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
458                newver->DV_ver = oldver->DV_ver;
459              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
460              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
461              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
# Line 466  Int_t ItoRunInfo::Update(ULong64_t run, Line 472  Int_t ItoRunInfo::Update(ULong64_t run,
472              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
473              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
474              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
475                newver->DV_ver = oldver->DV_ver;
476              newver->S4_ver = version->S4_ver;              newver->S4_ver = version->S4_ver;
477              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;
478            };            };
479              if ( !strcmp(Detector.Data(),"DV") ){
480                newver->TRIG_ver = oldver->TRIG_ver;
481                newver->TOF_ver = oldver->TOF_ver;
482                newver->ND_ver = oldver->ND_ver;
483                newver->AC_ver = oldver->AC_ver;
484                newver->TRK_ver = oldver->TRK_ver;
485                newver->ORB_ver = oldver->ORB_ver;
486                newver->CAL_ver = oldver->CAL_ver;
487                newver->S4_ver = oldver->S4_ver;
488                newver->DV_ver = version->DV_ver;
489                if ( strcmp(oldver->DV_ver.Data(),"") ) reprocessing = true;
490              };
491            if ( !strcmp(Detector.Data(),"ND") ){            if ( !strcmp(Detector.Data(),"ND") ){
492              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
493              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
494                newver->DV_ver = oldver->DV_ver;
495              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
496              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
497              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
# Line 482  Int_t ItoRunInfo::Update(ULong64_t run, Line 502  Int_t ItoRunInfo::Update(ULong64_t run,
502            };            };
503          };          };
504          //          //
505          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);
506          //          //
507        } else {        } else {
508          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);
509        };        };
510        //        //
511        file->cd();        file->cd();
# Line 493  Int_t ItoRunInfo::Update(ULong64_t run, Line 513  Int_t ItoRunInfo::Update(ULong64_t run,
513        //        //
514      };      };
515      //      //
     //    temprfile->Close();  
     //    gSystem->Unlink(temprname.str().c_str());  
     //    if ( ismydir ) gSystem->Unlink(tempdir.str().c_str());  
516      file->cd();      file->cd();
517      if ( oldtree ) oldtree->Delete("all");      if ( oldtree ) oldtree->Delete("all");
518      newtree->SetName("Run");      newtree->SetName("Run");
519      //    file->Write("Run");      //
     //    newtree->Delete();  
520      delete newver;      delete newver;
521      delete newrun;      delete newrun;
522      delete oldver;      delete oldver;
523      delete oldrun;      delete oldrun;
524      //      //
525      if ( !found ){      if ( !found ){
526        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);
527        return(-5);        return(-5);
528      };      };
529      //      //
# Line 516  Int_t ItoRunInfo::Update(ULong64_t run, Line 532  Int_t ItoRunInfo::Update(ULong64_t run,
532    return(0);    return(0);
533  }  }
534    
535  Int_t ItoRunInfo::Read(ULong64_t idRun){  Int_t ItoRunInfo::Read(UInt_t idRun){
536    //    //
537    isreadonly = true;    isreadonly = true;
538    //    //
# Line 543  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 559  Int_t ItoRunInfo::Read(ULong64_t idRun){
559      //      //
560      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
561      //      //
562      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
563          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
564          return(-806);
565        };
566      //      //
567      first_file_entry = 0;      first_file_entry = 0;
568      //      //
# Line 551  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 570  Int_t ItoRunInfo::Read(ULong64_t idRun){
570        //        //
571        newtree->GetEntry(run);        newtree->GetEntry(run);
572        //        //
573        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
574        //        //
575        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);
576        //        //
577        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
578        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 ){  
579          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
580          norun++;          norun++;
581        };        };
582        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);
583      };      };
584    };    };
585    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
# Line 599  void ItoRunInfo::Close(){ Line 596  void ItoRunInfo::Close(){
596    updating = false;    updating = false;
597    first_file_entry = 0;    first_file_entry = 0;
598    last_file_entry = 0;    last_file_entry = 0;
599    file_entries = 0ULL;    file_entries = 0;
600    norun = 0;    norun = 0;
601    runlist = new TArrayL(0,NULL);    delete runlist;
602    file = new TFile();      //  file = new TFile();  
603      file = 0;  
604    if ( isreadonly ) newtree->Delete();    if ( isreadonly ) newtree->Delete();
605  }  }
606    
607  void ItoRunInfo::Clear(){  void ItoRunInfo::Clear(Option_t *t){
608    if ( newtree ) newtree->Delete();    if ( newtree ) newtree->Delete();
609  }  }
610    
611  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
612    //    //
613    //  ItoRunInfo *run = new ItoRunInfo(file);    UInt_t startfrom = 0;
614      //
615      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
616    //    //
617    for ( UInt_t nrun = 0; nrun < norun; nrun++){      if ( entry > (UInt_t)last_file_entry ){
618      //    run->GetRunInfo((ULong64_t)nrun);          for ( UInt_t nrun = 0; nrun < norun; nrun++){  
619      //    printf("nrun = %i runlist = %llu \n",nrun,(ULong64_t)runlist->At(nrun));        if ( ID == (UInt_t)runlist->At(nrun) ) {
620      GetRunInfo((ULong64_t)runlist->At(nrun));          startfrom = nrun+1;
621      //    printf("entry %i first %i last %i \n",entry,(UInt_t)first_file_entry,(UInt_t)last_file_entry );          break;
622          };
623        };
624      } else {
625        startfrom = 0;
626      };
627      //
628      if ( startfrom >= norun ) startfrom = 0;
629      //
630     retry:
631      //
632      for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
633        GetRunInfo((UInt_t)runlist->At(nrun));
634      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 ){
       //      run->newtree->Delete();  
       //      delete run;  
       //printf("nrun is %i \n",nrun);  
635        return((UInt_t)runlist->At(nrun));        return((UInt_t)runlist->At(nrun));
636      };      };
637    };    };
638    //  run->newtree->Delete();    if ( startfrom ){
639    //  delete run;      startfrom = 0;
640        goto retry;
641      };
642      printf(" ERROR! run not found \n");
643    return(0);    return(0);
644  }  }
645    
646  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
647    Bool_t found = false;    Bool_t found = false;
648    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
649    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 647  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 659  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
659    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
660      newtree->GetEntry(nrun);      newtree->GetEntry(nrun);
661      //      //
662      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
663        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;  
664        found = true;        found = true;
665        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);
666      };      };
667      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);
668    };    };
669    delete nwver;    delete nwver;
670    delete nwrun;    delete nwrun;
671    if ( found ) return(0);    if ( found ) return(0);
672    return(-800);    return(-800);
673  }  }
674    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.23