/[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.14 by mocchiut, Thu Nov 9 14:44:08 2006 UTC
# Line 2  Line 2 
2  #include <sstream>  #include <sstream>
3  //  //
4  #include <TObject.h>  #include <TObject.h>
5    #include <TChain.h>
6  #include <TSystem.h>  #include <TSystem.h>
7  #include <TArrayL.h>  #include <TSystemFile.h>
8    #include <TArrayI.h>
9  #include <TFile.h>  #include <TFile.h>
10  #include <TTree.h>  #include <TTree.h>
11  #include <TDirectory.h>  #include <TDirectory.h>
# Line 28  SoftInfo::SoftInfo() { Line 30  SoftInfo::SoftInfo() {
30    CAL_ver = "";    CAL_ver = "";
31    ND_ver = "";    ND_ver = "";
32    S4_ver = "";      S4_ver = "";  
33      DV_ver = "";
34  }  }
35    
36    void SoftInfo::Clear(){
37      TRIG_ver = "";
38      TOF_ver = "";
39      AC_ver = "";
40      TRK_ver = "";
41      ORB_ver = "";
42      CAL_ver = "";
43      ND_ver = "";
44      S4_ver = "";  
45      DV_ver = "";
46    }
47    
48    UInt_t SoftInfo::GetSWinfo(TString Detector){
49      TString sver;
50      UInt_t version = 0;
51      if ( !strcmp(Detector.Data(),"TRIG") ){
52        sver = TRIG_ver;
53      };
54      if ( !strcmp(Detector.Data(),"TOF") ){
55        sver = TOF_ver;
56      };
57      if ( !strcmp(Detector.Data(),"AC") ){
58        sver = AC_ver;
59      };
60      if ( !strcmp(Detector.Data(),"TRK") ){
61        sver = TRK_ver;
62      };
63      if ( !strcmp(Detector.Data(),"CALO") ){
64        sver = CAL_ver;
65      };
66      if ( !strcmp(Detector.Data(),"S4") ){
67        sver = S4_ver;
68      };
69      if ( !strcmp(Detector.Data(),"DV") ){
70        sver = DV_ver;
71      };
72      if ( !strcmp(Detector.Data(),"ND") ){
73        sver = ND_ver;
74      };
75      if ( !strcmp(Detector.Data(),"ORB") ){
76        sver = ORB_ver;
77      };
78      sver.ReplaceAll("v",1," ",1);
79      sver.ReplaceAll("r",1," ",1);
80      version = (UInt_t)sver.Atoi();
81      return(version);
82    };
83    
84    /**
85     * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common).
86     */
87    void SoftInfo::GetLevel2Struct(cSoftInfo *l2) const{
88      l2->FillTrigWith(TRIG_ver);
89      l2->FillTofWith(TOF_ver);
90      l2->FillAcWith(AC_ver);
91      l2->FillTrkWith(TRK_ver);
92      l2->FillOrbWith(ORB_ver);
93      l2->FillCalWith(CAL_ver);
94      l2->FillNdWith(ND_ver);
95      l2->FillS4With(S4_ver);
96    }
97    /***********************/
98    
99  ItoRunInfo::ItoRunInfo() {  ItoRunInfo::ItoRunInfo() {
100    reprocessing = false;    reprocessing = false;
101    updating = false;    updating = false;
102    isreadonly = true;    isreadonly = true;
103    first_file_entry = 0;    first_file_entry = 0;
104    last_file_entry = 0;    last_file_entry = 0;
105    file_entries = 0ULL;    file_entries = 0;
106    totnorun = 0LL;    totnorun = 0;
107      this->GL_RUN::Clear();
108    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 = "";    
109    norun = 0;    norun = 0;
110    runlist = new TArrayL(0,NULL);    runlist = new TArrayI(500);
111    file = new TFile();    file = NULL;
112    newtree = new TTree();    newtree = new TTree();
113  }  }
114    
# Line 58  ItoRunInfo::ItoRunInfo(TFile *processFl) Line 117  ItoRunInfo::ItoRunInfo(TFile *processFl)
117    file=(TFile*)processFl;    file=(TFile*)processFl;
118    dbc=NULL;    dbc=NULL;
119    processFolder = "";    processFolder = "";
120    idRun = 0ULL;    idRun = 0;
121    Detector = "NONE";    Detector = "NONE";
122    //    //
123    reprocessing = false;    reprocessing = false;
124    updating = false;    updating = false;
125    first_file_entry = 0;    first_file_entry = 0;
126    last_file_entry = 0;    last_file_entry = 0;
127    file_entries = 0ULL;    file_entries = 0;
128    version = new SoftInfo();    version = new SoftInfo();
129    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 = "";    
130    norun = 0;    norun = 0;
131    totnorun = 0;    totnorun = 0;
132      runlist = new TArrayI(500);
133      //
134    }
135    
136    
137    
138    TChain *ItoRunInfo::GetRunTree(TList *fl){
139      //
140      TChain *Tout = new TChain("Run");    
141      // loop over files and create chains  
142      TIter next(fl);
143      TSystemFile *questo = 0;
144      while ( (questo = (TSystemFile*) next()) ) {
145        TString name =  questo->GetName();
146        Tout->Add(name);
147      };
148      //
149      Tout->SetBranchAddress("RunInfo", GetPointerToRI());
150      printf("Run          : set branch address RunInfo\n");
151      Tout->SetBranchAddress("SoftInfo", GetPointerToSI());
152      printf("Software     : set branch address SoftInfo\n");
153      //
154      return Tout;                  
155    //    //
156  }  }
157    
# Line 90  ItoRunInfo::ItoRunInfo(TSQLServer *db, T Line 165  ItoRunInfo::ItoRunInfo(TSQLServer *db, T
165    updating = false;    updating = false;
166    first_file_entry = 0;    first_file_entry = 0;
167    last_file_entry = 0;    last_file_entry = 0;
168    file_entries = 0ULL;    file_entries = 0;
169    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 = "";    
170    norun = 0;    norun = 0;
171    totnorun = 0;    totnorun = 0;
172      runlist = new TArrayI(500);
173    //    //
174  }  }
175    
176  Int_t ItoRunInfo::Update(ULong64_t run, TString Detector, TString Version){  void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
177      //
178      if ( glrun && newrun ){
179        //
180        //    printf("copy \n");
181        //
182        newrun->ID = glrun->ID                         ;
183        newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG                ;
184        newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0                 ;
185        newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2                 ;
186        newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME             ;
187        newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME            ;
188        newrun->EV_FROM = glrun->EV_FROM                    ;
189        newrun->EV_TO = glrun->EV_TO                      ;
190        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
191        newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE           ;
192        newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A         ;
193        newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B         ;
194        newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO             ;
195        newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO               ;
196        newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT              ;
197        newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT             ;
198        newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT              ;
199        newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT             ;
200        newrun->NEVENTS = glrun->NEVENTS                    ;
201        newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC              ;
202        newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC               ;
203        newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP       ;
204        newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE           ;
205        newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB         ;
206        newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE        ;
207        newrun->PKT_COUNTER = glrun->PKT_COUNTER                ;
208        newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER          ;
209        newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED             ;
210        newrun->CAL_DSP_MASK  = glrun->CAL_DSP_MASK               ;
211        newrun->BOOT_NUMBER  = glrun->BOOT_NUMBER                ;
212        newrun->VALIDATION  = glrun->VALIDATION                 ;
213        //
214      };
215      //
216      if ( newver && sinfo ){
217        //
218        newver->TRIG_ver = sinfo->TRIG_ver;
219        newver->TOF_ver = sinfo->TOF_ver;
220        newver->AC_ver = sinfo->AC_ver;
221        newver->TRK_ver = sinfo->TRK_ver;
222        newver->ORB_ver = sinfo->ORB_ver;
223        newver->CAL_ver = sinfo->CAL_ver;
224        newver->S4_ver = sinfo->S4_ver;
225        newver->DV_ver = sinfo->DV_ver;
226        newver->ND_ver = sinfo->ND_ver;
227        //
228      };
229    }
230    
231    Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
232    //    //
233    isreadonly = false;    isreadonly = false;
234    idRun = run;    idRun = run;
# Line 124  Int_t ItoRunInfo::Update(ULong64_t run, Line 247  Int_t ItoRunInfo::Update(ULong64_t run,
247    SoftInfo *oldver = new SoftInfo();    SoftInfo *oldver = new SoftInfo();
248    SoftInfo *newver = new SoftInfo();    SoftInfo *newver = new SoftInfo();
249    //    //
250    ID = 0ULL;    this->GL_RUN::Clear();
251    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 = "";    
252    //    //
253    norun = 0;    norun = 0;
   runlist = new TArrayL(0,NULL);  
254    //    //
255    Bool_t found = false;    Bool_t found = false;
256    Int_t error = 0;    Int_t error = 0;
257    //    //
   //  TFile *temprfile = 0;  
   //  TTree *temprrun = 0;  
   //  stringstream temprname;  
   //  stringstream tempdir;  
   //  const char* routdir = gSystem->DirName(gSystem->DirName(file->GetPath()));  
   //  
258    TTree *oldtree = 0;    TTree *oldtree = 0;
259    //    //
   //  
260    // Try to get the tree Run in the processed file    // Try to get the tree Run in the processed file
261    //    //
262    oldtree = (TTree*)file->Get("Run");      oldtree = (TTree*)file->Get("Run");  
# Line 178  Int_t ItoRunInfo::Update(ULong64_t run, Line 272  Int_t ItoRunInfo::Update(ULong64_t run,
272      version->ORB_ver = Version;      version->ORB_ver = Version;
273      version->CAL_ver = Version;          version->CAL_ver = Version;    
274      version->S4_ver = Version;      version->S4_ver = Version;
275        version->DV_ver = Version;
276      version->ND_ver = Version;      version->ND_ver = Version;
277    } else {    } else {
278      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 281  Int_t ItoRunInfo::Update(ULong64_t run,
281      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;      if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
282      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;      if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
283      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;      if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;
284        if ( !strcmp(Detector.Data(),"DV") ) version->DV_ver = Version;
285      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;      if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;
286      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;      if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;
287      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);
288    };    };
289    //    //
290    if ( !oldtree ) {    if ( !oldtree ) {
# Line 199  Int_t ItoRunInfo::Update(ULong64_t run, Line 295  Int_t ItoRunInfo::Update(ULong64_t run,
295      //      //
296    } else {    } else {
297      //      //
 //     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");  
     //  
298      updating = true;      updating = true;
299      if ( debug ) printf(" RunInfo: updating versioning information \n");      if ( debug ) printf(" RunInfo: updating versioning information \n");
300      //      //
# Line 242  Int_t ItoRunInfo::Update(ULong64_t run, Line 310  Int_t ItoRunInfo::Update(ULong64_t run,
310    //      //  
311    //    //
312    if ( !updating ){    if ( !updating ){
313      if ( idRun == 0ULL ){      if ( idRun == 0 ){
314        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");
315        return(-805);        return(-805);
316      };      };
317      //      //
     runlist = new TArrayL(1);  
     //  
318      error = Query_GL_RUN(idRun, dbc);      error = Query_GL_RUN(idRun, dbc);
319      //      //
320      if ( error ){      if ( error ){
321        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");
322        return(error);        return(error);
323      };      };
324      if ( ID == 0ULL ){      if ( ID == 0 ){
325        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);
326        return(-5);        return(-5);
327      };      };
328      //      //
329      //      //
330      //      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;  
331      //      //
332      // fill the tree;      // fill the tree;
333      //      //
# Line 293  Int_t ItoRunInfo::Update(ULong64_t run, Line 336  Int_t ItoRunInfo::Update(ULong64_t run,
336      totnorun = 1;      totnorun = 1;
337      reprocessing = false;      reprocessing = false;
338      first_file_entry = 0;      first_file_entry = 0;
339      last_file_entry = (UInt_t)(EV_REG_PHYS_TO - EV_REG_PHYS_FROM);      last_file_entry = (UInt_t)(EV_TO - EV_FROM);
340      norun = 1;      norun = 1;
341      runlist->AddAt((Long64_t)ID,0);      runlist->AddAt((Int_t)ID,0);
342      //      //
343      newtree->SetName("Run");      newtree->SetName("Run");
344      //      //
345      file->cd();      file->cd();
346      //    file->Write("Run");      //
     //newtree->Delete();  
347      delete newver;      delete newver;
348      delete newrun;      delete newrun;
349      delete oldver;      delete oldver;
# Line 311  Int_t ItoRunInfo::Update(ULong64_t run, Line 353  Int_t ItoRunInfo::Update(ULong64_t run,
353      //      //
354    } else {    } else {
355      //      //
     //    temprfile = new TFile(temprname.str().c_str(),"READ");  
     //    oldtree = (TTree*)temprfile->Get("Run-old");  
356      //      //
357      oldtree->SetBranchAddress("RunInfo",&oldrun);      oldtree->SetBranchAddress("RunInfo",&oldrun);
358      oldtree->SetBranchAddress("SoftInfo",&oldver);      oldtree->SetBranchAddress("SoftInfo",&oldver);
359      //      //
360      totnorun = oldtree->GetEntries();      totnorun = oldtree->GetEntries();
361      //      //
362      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
363          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
364          return(-806);
365        };
366      //      //
367      found = false;      found = false;
368      //      //
# Line 327  Int_t ItoRunInfo::Update(ULong64_t run, Line 370  Int_t ItoRunInfo::Update(ULong64_t run,
370        //        //
371        oldtree->GetEntry(run);        oldtree->GetEntry(run);
372        //        //
373        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;  
374        //        //
375        file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);        file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
376        //        //
377        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);
378        //        //
379        if ( idRun == 0ULL || idRun == newrun->ID ) {        if ( idRun == 0 || idRun == newrun->ID ) {
380          //          //
381          if ( debug ) printf(" Updating run number %llu \n",idRun);          if ( debug ) printf(" Updating run number %u \n",idRun);
382          //          //
383          found = true;          found = true;
384          //          //
# Line 375  Int_t ItoRunInfo::Update(ULong64_t run, Line 396  Int_t ItoRunInfo::Update(ULong64_t run,
396              return(error);              return(error);
397            };            };
398            //            //
399            newrun->ID = ID;            CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
400            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;  
401          } else {          } else {
402            //            //
403            if ( !strcmp(Detector.Data(),"TRIG") ){            if ( !strcmp(Detector.Data(),"TRIG") ){
# Line 400  Int_t ItoRunInfo::Update(ULong64_t run, Line 408  Int_t ItoRunInfo::Update(ULong64_t run,
408              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
409              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
410              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
411                newver->DV_ver = oldver->DV_ver;
412              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
413              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
414            };            };
# Line 410  Int_t ItoRunInfo::Update(ULong64_t run, Line 419  Int_t ItoRunInfo::Update(ULong64_t run,
419              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
420              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
421              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
422                newver->DV_ver = oldver->DV_ver;
423              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
424              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
425              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 430  Int_t ItoRunInfo::Update(ULong64_t run,
430              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
431              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
432              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
433                newver->DV_ver = oldver->DV_ver;
434              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
435              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
436              newver->AC_ver = version->AC_ver;              newver->AC_ver = version->AC_ver;
# Line 430  Int_t ItoRunInfo::Update(ULong64_t run, Line 441  Int_t ItoRunInfo::Update(ULong64_t run,
441              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
442              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
443              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
444                newver->DV_ver = oldver->DV_ver;
445              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
446              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
447              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 441  Int_t ItoRunInfo::Update(ULong64_t run, Line 453  Int_t ItoRunInfo::Update(ULong64_t run,
453              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
454              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
455              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
456                newver->DV_ver = oldver->DV_ver;
457              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
458              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
459              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
# Line 450  Int_t ItoRunInfo::Update(ULong64_t run, Line 463  Int_t ItoRunInfo::Update(ULong64_t run,
463            if ( !strcmp(Detector.Data(),"CALO") ){            if ( !strcmp(Detector.Data(),"CALO") ){
464              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
465              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
466                newver->DV_ver = oldver->DV_ver;
467              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
468              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
469              newver->ND_ver = oldver->ND_ver;              newver->ND_ver = oldver->ND_ver;
# Line 466  Int_t ItoRunInfo::Update(ULong64_t run, Line 480  Int_t ItoRunInfo::Update(ULong64_t run,
480              newver->TRK_ver = oldver->TRK_ver;              newver->TRK_ver = oldver->TRK_ver;
481              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
482              newver->CAL_ver = oldver->CAL_ver;              newver->CAL_ver = oldver->CAL_ver;
483                newver->DV_ver = oldver->DV_ver;
484              newver->S4_ver = version->S4_ver;              newver->S4_ver = version->S4_ver;
485              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;              if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;
486            };            };
487              if ( !strcmp(Detector.Data(),"DV") ){
488                newver->TRIG_ver = oldver->TRIG_ver;
489                newver->TOF_ver = oldver->TOF_ver;
490                newver->ND_ver = oldver->ND_ver;
491                newver->AC_ver = oldver->AC_ver;
492                newver->TRK_ver = oldver->TRK_ver;
493                newver->ORB_ver = oldver->ORB_ver;
494                newver->CAL_ver = oldver->CAL_ver;
495                newver->S4_ver = oldver->S4_ver;
496                newver->DV_ver = version->DV_ver;
497                if ( strcmp(oldver->DV_ver.Data(),"") ) reprocessing = true;
498              };
499            if ( !strcmp(Detector.Data(),"ND") ){            if ( !strcmp(Detector.Data(),"ND") ){
500              newver->TRIG_ver = oldver->TRIG_ver;              newver->TRIG_ver = oldver->TRIG_ver;
501              newver->TOF_ver = oldver->TOF_ver;              newver->TOF_ver = oldver->TOF_ver;
502                newver->DV_ver = oldver->DV_ver;
503              newver->S4_ver = oldver->S4_ver;              newver->S4_ver = oldver->S4_ver;
504              newver->AC_ver = oldver->AC_ver;              newver->AC_ver = oldver->AC_ver;
505              newver->ORB_ver = oldver->ORB_ver;              newver->ORB_ver = oldver->ORB_ver;
# Line 482  Int_t ItoRunInfo::Update(ULong64_t run, Line 510  Int_t ItoRunInfo::Update(ULong64_t run,
510            };            };
511          };          };
512          //          //
513          last_file_entry = first_file_entry + (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1);          last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1);
514          //          //
515        } else {        } else {
516          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);
517        };        };
518        //        //
519        file->cd();        file->cd();
# Line 493  Int_t ItoRunInfo::Update(ULong64_t run, Line 521  Int_t ItoRunInfo::Update(ULong64_t run,
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      //      //
# Line 516  Int_t ItoRunInfo::Update(ULong64_t run, Line 540  Int_t ItoRunInfo::Update(ULong64_t run,
540    return(0);    return(0);
541  }  }
542    
543  Int_t ItoRunInfo::Read(ULong64_t idRun){  Int_t ItoRunInfo::Read(UInt_t idRun){
544    //    //
545    isreadonly = true;    isreadonly = true;
546    //    //
# Line 543  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 567  Int_t ItoRunInfo::Read(ULong64_t idRun){
567      //      //
568      totnorun = newtree->GetEntries();      totnorun = newtree->GetEntries();
569      //      //
570      runlist = new TArrayL((Int_t)totnorun);      if ( totnorun > 500 ){
571          if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
572          return(-806);
573        };
574      //      //
575      first_file_entry = 0;      first_file_entry = 0;
576      //      //
# Line 551  Int_t ItoRunInfo::Read(ULong64_t idRun){ Line 578  Int_t ItoRunInfo::Read(ULong64_t idRun){
578        //        //
579        newtree->GetEntry(run);        newtree->GetEntry(run);
580        //        //
581        file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
582        //        //
583        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);
584        //        //
585        ID = newrun->ID;        CopyFromTo(newrun,(GL_RUN*)this,newver,version);
586        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 ){  
587          runlist->AddAt(newrun->ID,norun);          runlist->AddAt(newrun->ID,norun);
588          norun++;          norun++;
589        };        };
590        last_file_entry = first_file_entry + (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1);        last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1);
591      };      };
592    };    };
593    if ( debug ) printf("norun %i \n",(int)norun);    if ( debug ) printf("norun %i \n",(int)norun);
# Line 599  void ItoRunInfo::Close(){ Line 604  void ItoRunInfo::Close(){
604    updating = false;    updating = false;
605    first_file_entry = 0;    first_file_entry = 0;
606    last_file_entry = 0;    last_file_entry = 0;
607    file_entries = 0ULL;    file_entries = 0;
608    norun = 0;    norun = 0;
609    runlist = new TArrayL(0,NULL);    delete runlist;
610    file = new TFile();      //  file = new TFile();  
611      file = 0;  
612    if ( isreadonly ) newtree->Delete();    if ( isreadonly ) newtree->Delete();
613  }  }
614    
# Line 612  void ItoRunInfo::Clear(){ Line 618  void ItoRunInfo::Clear(){
618    
619  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){  UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
620    //    //
621    //  ItoRunInfo *run = new ItoRunInfo(file);    UInt_t startfrom = 0;
622      //
623      if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
624    //    //
625    for ( UInt_t nrun = 0; nrun < norun; nrun++){      if ( entry > (UInt_t)last_file_entry ){
626      //    run->GetRunInfo((ULong64_t)nrun);          for ( UInt_t nrun = 0; nrun < norun; nrun++){  
627      //    printf("nrun = %i runlist = %llu \n",nrun,(ULong64_t)runlist->At(nrun));        if ( ID == (UInt_t)runlist->At(nrun) ) {
628      GetRunInfo((ULong64_t)runlist->At(nrun));          startfrom = nrun+1;
629      //    printf("entry %i first %i last %i \n",entry,(UInt_t)first_file_entry,(UInt_t)last_file_entry );          break;
630          };
631        };
632      } else {
633        startfrom = 0;
634      };
635      //
636      if ( startfrom >= norun ) startfrom = 0;
637      //
638     retry:
639      //
640      for ( UInt_t nrun = startfrom; nrun < norun; nrun++){  
641        GetRunInfo((UInt_t)runlist->At(nrun));
642      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);  
643        return((UInt_t)runlist->At(nrun));        return((UInt_t)runlist->At(nrun));
644      };      };
645    };    };
646    //  run->newtree->Delete();    if ( startfrom ){
647    //  delete run;      startfrom = 0;
648        goto retry;
649      };
650      printf(" ERROR! run not found \n");
651    return(0);    return(0);
652  }  }
653    
654  Int_t ItoRunInfo::GetRunInfo(ULong64_t run){  Int_t ItoRunInfo::GetRunInfo(UInt_t run){
655    Bool_t found = false;    Bool_t found = false;
656    SoftInfo *nwver = new SoftInfo();    SoftInfo *nwver = new SoftInfo();
657    GL_RUN *nwrun = new GL_RUN();    GL_RUN *nwrun = new GL_RUN();
# Line 647  Int_t ItoRunInfo::GetRunInfo(ULong64_t r Line 667  Int_t ItoRunInfo::GetRunInfo(ULong64_t r
667    for ( UInt_t nrun = 0; nrun < totnorun; nrun++){      for ( UInt_t nrun = 0; nrun < totnorun; nrun++){  
668      newtree->GetEntry(nrun);      newtree->GetEntry(nrun);
669      //      //
670      if ( nwrun->ID == run || run == 0ULL ){      if ( nwrun->ID == run || run == 0 ){
671        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;  
672        found = true;        found = true;
673        last_file_entry = first_file_entry + (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1);        last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1);
674      };      };
675      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);
676    };    };
677    delete nwver;    delete nwver;
678    delete nwrun;    delete nwrun;
679    if ( found ) return(0);    if ( found ) return(0);
680    return(-800);    return(-800);
681  }  }
682    

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

  ViewVC Help
Powered by ViewVC 1.1.23