/[PAMELA software]/DarthVader/RunInfo/src/RunInfo.cpp
ViewVC logotype

Annotation of /DarthVader/RunInfo/src/RunInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations) (download)
Tue Oct 24 07:31:50 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.11: +2 -1 lines
Another bug in LoadRunInfoTree method fixed

1 mocchiut 1.1 //
2     #include <sstream>
3     //
4     #include <TObject.h>
5 mocchiut 1.8 #include <TChain.h>
6 mocchiut 1.1 #include <TSystem.h>
7 mocchiut 1.8 #include <TSystemFile.h>
8     #include <TArrayI.h>
9 mocchiut 1.1 #include <TFile.h>
10     #include <TTree.h>
11     #include <TDirectory.h>
12     #include <TSQLServer.h>
13     #include <TSQLRow.h>
14     #include <TSQLResult.h>
15     //
16     #include <GLTables.h>
17     #include <RunInfo.h>
18     ClassImp(SoftInfo);
19     ClassImp(ItoRunInfo);
20     //
21     using namespace std;
22     //
23    
24     SoftInfo::SoftInfo() {
25     TRIG_ver = "";
26     TOF_ver = "";
27     AC_ver = "";
28     TRK_ver = "";
29     ORB_ver = "";
30     CAL_ver = "";
31     ND_ver = "";
32     S4_ver = "";
33     }
34    
35 mocchiut 1.8 void SoftInfo::Clear(){
36     TRIG_ver = "";
37     TOF_ver = "";
38     AC_ver = "";
39     TRK_ver = "";
40     ORB_ver = "";
41     CAL_ver = "";
42     ND_ver = "";
43     S4_ver = "";
44     }
45    
46    
47 pam-fi 1.6 /**
48     * Fills a struct cSoftInfo with values from a SoftInfo object (to put data into a F77 common).
49     */
50     void SoftInfo::GetLevel2Struct(cSoftInfo *l2) const{
51     l2->FillTrigWith(TRIG_ver);
52     l2->FillTofWith(TOF_ver);
53     l2->FillAcWith(AC_ver);
54     l2->FillTrkWith(TRK_ver);
55     l2->FillOrbWith(ORB_ver);
56     l2->FillCalWith(CAL_ver);
57     l2->FillNdWith(ND_ver);
58     l2->FillS4With(S4_ver);
59     }
60     /***********************/
61    
62 mocchiut 1.1 ItoRunInfo::ItoRunInfo() {
63     reprocessing = false;
64     updating = false;
65     isreadonly = true;
66     first_file_entry = 0;
67     last_file_entry = 0;
68 mocchiut 1.8 file_entries = 0;
69     totnorun = 0;
70     this->GL_RUN::Clear();
71 mocchiut 1.1 version = new SoftInfo();
72     norun = 0;
73 mocchiut 1.8 runlist = new TArrayI(500);
74     file = NULL;
75 mocchiut 1.1 newtree = new TTree();
76     }
77    
78     ItoRunInfo::ItoRunInfo(TFile *processFl){
79     //
80     file=(TFile*)processFl;
81     dbc=NULL;
82     processFolder = "";
83 mocchiut 1.8 idRun = 0;
84 mocchiut 1.1 Detector = "NONE";
85     //
86     reprocessing = false;
87     updating = false;
88     first_file_entry = 0;
89     last_file_entry = 0;
90 mocchiut 1.8 file_entries = 0;
91 mocchiut 1.1 version = new SoftInfo();
92     norun = 0;
93     totnorun = 0;
94 mocchiut 1.8 runlist = new TArrayI(500);
95     //
96     }
97    
98    
99    
100     TChain *ItoRunInfo::LoadRunInfoTree(TList *fl){
101     //
102     TChain *Tout=0;
103     //
104     TChain *RI = 0;
105 mocchiut 1.11 RI = new TChain("Run");
106 mocchiut 1.8 // loop over files and create chains
107     TIter next(fl);
108     TSystemFile *questo = 0;
109     while ( (questo = (TSystemFile*) next()) ) {
110     TString name = questo->GetName();
111     RI->Add(name);
112     };
113     //
114 mocchiut 1.12 RI->SetBranchAddress("RunInfo", GetPointerToRI());
115     RI->SetBranchAddress("SoftInfo", GetPointerToSI());
116 mocchiut 1.8 Tout = RI;
117     //
118     return Tout;
119 mocchiut 1.1 //
120     }
121    
122     ItoRunInfo::ItoRunInfo(TSQLServer *db, TFile *processFl, TString processFld){
123     //
124     file=(TFile*)processFl;
125     dbc=(TSQLServer*)db;
126     processFolder = processFld;
127     //
128     reprocessing = false;
129     updating = false;
130     first_file_entry = 0;
131     last_file_entry = 0;
132 mocchiut 1.8 file_entries = 0;
133 mocchiut 1.1 version = new SoftInfo();
134     norun = 0;
135     totnorun = 0;
136 mocchiut 1.8 runlist = new TArrayI(500);
137     //
138     }
139    
140     void ItoRunInfo::CopyFromTo(GL_RUN *glrun,GL_RUN *newrun,SoftInfo *sinfo, SoftInfo *newver){
141 mocchiut 1.1 //
142 mocchiut 1.8 if ( glrun && newrun ){
143     //
144 mocchiut 1.9 // printf("copy \n");
145     //
146 mocchiut 1.8 newrun->ID = glrun->ID ;
147     newrun->ID_RUN_FRAG = glrun-> ID_RUN_FRAG ;
148     newrun->ID_ROOT_L0 = glrun->ID_ROOT_L0 ;
149     newrun->ID_ROOT_L2 = glrun->ID_ROOT_L2 ;
150     newrun->RUNHEADER_TIME = glrun->RUNHEADER_TIME ;
151     newrun->RUNTRAILER_TIME = glrun->RUNTRAILER_TIME ;
152     newrun->EV_FROM = glrun->EV_FROM ;
153     newrun->EV_TO = glrun->EV_TO ;
154     newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED ;
155     newrun->EFF_WRK_SCHEDULE = glrun->EFF_WRK_SCHEDULE ;
156     newrun->PRH_VAR_TRG_MODE_A = glrun->PRH_VAR_TRG_MODE_A ;
157     newrun->PRH_VAR_TRG_MODE_B = glrun->PRH_VAR_TRG_MODE_B ;
158     newrun->ACQ_BUILD_INFO =glrun->ACQ_BUILD_INFO ;
159     newrun->ACQ_VAR_INFO = glrun->ACQ_VAR_INFO ;
160     newrun->RUNHEADER_OBT = glrun->RUNHEADER_OBT ;
161     newrun->RUNTRAILER_OBT = glrun->RUNTRAILER_OBT ;
162     newrun->RUNHEADER_PKT = glrun->RUNHEADER_PKT ;
163     newrun->RUNTRAILER_PKT = glrun->RUNTRAILER_PKT ;
164     newrun->NEVENTS = glrun->NEVENTS ;
165     newrun->LAST_TIMESYNC = glrun->LAST_TIMESYNC ;
166     newrun->OBT_TIMESYNC = glrun->OBT_TIMESYNC ;
167     newrun->COMPILATIONTIMESTAMP = glrun->COMPILATIONTIMESTAMP ;
168     newrun->FAV_WRK_SCHEDULE = glrun->FAV_WRK_SCHEDULE ;
169     newrun->RM_ACQ_AFTER_CALIB = glrun->RM_ACQ_AFTER_CALIB ;
170     newrun->RM_ACQ_SETTING_MODE = glrun->RM_ACQ_SETTING_MODE ;
171     newrun->PKT_COUNTER = glrun->PKT_COUNTER ;
172     newrun->PKT_READY_COUNTER = glrun->PKT_READY_COUNTER ;
173     newrun->TRK_CALIB_USED = glrun->TRK_CALIB_USED ;
174     newrun->CAL_DSP_MASK = glrun->CAL_DSP_MASK ;
175     newrun->BOOT_NUMBER = glrun->BOOT_NUMBER ;
176     newrun->VALIDATION = glrun->VALIDATION ;
177     //
178     };
179     //
180     if ( newver && sinfo ){
181     //
182     newver->TRIG_ver = sinfo->TRIG_ver;
183     newver->TOF_ver = sinfo->TOF_ver;
184     newver->AC_ver = sinfo->AC_ver;
185     newver->TRK_ver = sinfo->TRK_ver;
186     newver->ORB_ver = sinfo->ORB_ver;
187     newver->CAL_ver = sinfo->CAL_ver;
188     newver->S4_ver = sinfo->S4_ver;
189     newver->ND_ver = sinfo->ND_ver;
190     //
191     };
192 mocchiut 1.1 }
193    
194 mocchiut 1.8 Int_t ItoRunInfo::Update(UInt_t run, TString Detector, TString Version){
195 mocchiut 1.1 //
196     isreadonly = false;
197     idRun = run;
198     //
199 mocchiut 1.10 Bool_t debug = false;
200 mocchiut 1.1 //
201     Bool_t ismydir = false;
202     //
203     if ( !strcmp(processFolder.Data(),"") ){
204     processFolder = "runinfoFolder";
205     ismydir = true;
206     };
207     //
208     GL_RUN *oldrun = new GL_RUN();
209     GL_RUN *newrun = new GL_RUN();
210     SoftInfo *oldver = new SoftInfo();
211     SoftInfo *newver = new SoftInfo();
212     //
213 mocchiut 1.8 this->GL_RUN::Clear();
214     version->Clear();
215 mocchiut 1.1 //
216     norun = 0;
217     //
218     Bool_t found = false;
219     Int_t error = 0;
220     //
221     TTree *oldtree = 0;
222     //
223     // Try to get the tree Run in the processed file
224     //
225     oldtree = (TTree*)file->Get("Run");
226     //
227     // Look for detector's versions if we are updating a single detector
228     //
229     if ( debug ) printf("Detector -%s- \n",Detector.Data());
230     if ( !strcmp(Detector.Data(),"NONE") ){
231     version->TRIG_ver = Version;
232     version->TOF_ver = Version;
233     version->AC_ver = Version;
234     version->TRK_ver = Version;
235     version->ORB_ver = Version;
236     version->CAL_ver = Version;
237     version->S4_ver = Version;
238     version->ND_ver = Version;
239     } else {
240     if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;
241     if ( !strcmp(Detector.Data(),"TOF") ) version->TOF_ver = Version;
242     if ( !strcmp(Detector.Data(),"AC") ) version->AC_ver = Version;
243     if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
244     if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
245     if ( !strcmp(Detector.Data(),"S4") ) version->S4_ver = Version;
246     if ( !strcmp(Detector.Data(),"ND") ) version->ND_ver = Version;
247     if ( !strcmp(Detector.Data(),"ORB") ) version->ORB_ver = Version;
248     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);
249     };
250     //
251     if ( !oldtree ) {
252     //
253     if ( strcmp(Detector.Data(),"NONE") ) return(-803);
254     updating = false;
255     if ( debug ) printf(" RunInfo: creating Run tree in this file\n");
256     //
257     } else {
258     //
259     updating = true;
260     if ( debug ) printf(" RunInfo: updating versioning information \n");
261     //
262     };
263     //
264     file->cd();
265     //
266     // Prepare a new tree to upgrade the contents of the old tree
267     //
268     newtree = new TTree("Run-new","PAMELA Level2 data from the GL_RUN table");
269     newtree->Branch("RunInfo","GL_RUN",&newrun);
270     newtree->Branch("SoftInfo","SoftInfo",&newver);
271     //
272     //
273     if ( !updating ){
274 mocchiut 1.8 if ( idRun == 0 ){
275 mocchiut 1.1 if ( debug ) printf("\n RUNINFO - ERROR: reprocessing data but no RunInfo tree in Level2 file. \n");
276 mocchiut 1.2 return(-805);
277 mocchiut 1.1 };
278     //
279     error = Query_GL_RUN(idRun, dbc);
280     //
281     if ( error ){
282     if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");
283     return(error);
284     };
285 mocchiut 1.8 if ( ID == 0 ){
286     if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
287 mocchiut 1.1 return(-5);
288     };
289     //
290     //
291 mocchiut 1.8 CopyFromTo((GL_RUN*)this,newrun,version,newver);
292 mocchiut 1.1 //
293     // fill the tree;
294     //
295     newtree->Fill();
296     //
297     totnorun = 1;
298     reprocessing = false;
299     first_file_entry = 0;
300 mocchiut 1.8 last_file_entry = (UInt_t)(EV_TO - EV_FROM);
301 mocchiut 1.1 norun = 1;
302 mocchiut 1.8 runlist->AddAt((Int_t)ID,0);
303 mocchiut 1.1 //
304     newtree->SetName("Run");
305     //
306     file->cd();
307 mocchiut 1.8 //
308 mocchiut 1.3 delete newver;
309     delete newrun;
310     delete oldver;
311     delete oldrun;
312 mocchiut 1.1 //
313     return(0);
314     //
315     } else {
316     //
317     //
318     oldtree->SetBranchAddress("RunInfo",&oldrun);
319     oldtree->SetBranchAddress("SoftInfo",&oldver);
320     //
321     totnorun = oldtree->GetEntries();
322     //
323 mocchiut 1.7 if ( totnorun > 500 ){
324     if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
325     return(-806);
326     };
327 mocchiut 1.1 //
328     found = false;
329     //
330     for ( UInt_t run = 0; run < totnorun; run++){
331     //
332     oldtree->GetEntry(run);
333     //
334 mocchiut 1.8 CopyFromTo(oldrun,newrun,oldver,newver);
335 mocchiut 1.1 //
336 mocchiut 1.8 file_entries += (oldrun->EV_TO - oldrun->EV_FROM + 1);
337 mocchiut 1.1 //
338     if ( debug ) printf("totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID);
339     //
340 mocchiut 1.8 if ( idRun == 0 || idRun == newrun->ID ) {
341 mocchiut 1.1 //
342 mocchiut 1.8 if ( debug ) printf(" Updating run number %u \n",idRun);
343 mocchiut 1.1 //
344     found = true;
345     //
346     runlist->AddAt(newrun->ID,norun);
347     norun++;
348     //
349     if ( !strcmp(Detector.Data(),"NONE") ){
350     //
351     // update infromations querying the DB
352     //
353     error = Query_GL_RUN(newrun->ID, dbc);
354     //
355     if ( error ){
356     if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");
357     return(error);
358     };
359     //
360 mocchiut 1.8 CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
361     //
362 mocchiut 1.1 } else {
363     //
364     if ( !strcmp(Detector.Data(),"TRIG") ){
365     newver->TRIG_ver = version->TRIG_ver;
366     newver->TOF_ver = oldver->TOF_ver;
367     newver->AC_ver = oldver->AC_ver;
368     newver->TRK_ver = oldver->TRK_ver;
369     newver->ORB_ver = oldver->ORB_ver;
370     newver->CAL_ver = oldver->CAL_ver;
371     newver->S4_ver = oldver->S4_ver;
372     newver->ND_ver = oldver->ND_ver;
373     if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
374     };
375     if ( !strcmp(Detector.Data(),"TOF") ){
376     newver->TRIG_ver = oldver->TRIG_ver;
377     newver->TOF_ver = version->TOF_ver;
378     newver->AC_ver = oldver->AC_ver;
379     newver->TRK_ver = oldver->TRK_ver;
380     newver->ORB_ver = oldver->ORB_ver;
381     newver->CAL_ver = oldver->CAL_ver;
382     newver->S4_ver = oldver->S4_ver;
383     newver->ND_ver = oldver->ND_ver;
384     if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;
385     };
386     if ( !strcmp(Detector.Data(),"AC") ){
387     newver->TRIG_ver = oldver->TRIG_ver;
388     newver->TOF_ver = oldver->TOF_ver;
389     newver->TRK_ver = oldver->TRK_ver;
390     newver->ORB_ver = oldver->ORB_ver;
391     newver->CAL_ver = oldver->CAL_ver;
392     newver->S4_ver = oldver->S4_ver;
393     newver->ND_ver = oldver->ND_ver;
394     newver->AC_ver = version->AC_ver;
395     if ( strcmp(oldver->AC_ver.Data(),"") ) reprocessing = true;
396     };
397     if ( !strcmp(Detector.Data(),"TRK") ){
398     newver->TRIG_ver = oldver->TRIG_ver;
399     newver->TOF_ver = oldver->TOF_ver;
400     newver->CAL_ver = oldver->CAL_ver;
401     newver->ORB_ver = oldver->ORB_ver;
402     newver->S4_ver = oldver->S4_ver;
403     newver->ND_ver = oldver->ND_ver;
404     newver->AC_ver = oldver->AC_ver;
405     newver->TRK_ver = version->TRK_ver;
406     if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true;
407     };
408     if ( !strcmp(Detector.Data(),"ORB") ){
409     newver->TRIG_ver = oldver->TRIG_ver;
410     newver->TOF_ver = oldver->TOF_ver;
411     newver->CAL_ver = oldver->CAL_ver;
412     newver->TRK_ver = oldver->TRK_ver;
413     newver->S4_ver = oldver->S4_ver;
414     newver->ND_ver = oldver->ND_ver;
415     newver->AC_ver = oldver->AC_ver;
416     newver->ORB_ver = version->ORB_ver;
417 mocchiut 1.3 if ( strcmp(oldver->ORB_ver.Data(),"") ) reprocessing = true;
418 mocchiut 1.1 };
419     if ( !strcmp(Detector.Data(),"CALO") ){
420     newver->TRIG_ver = oldver->TRIG_ver;
421     newver->TOF_ver = oldver->TOF_ver;
422     newver->S4_ver = oldver->S4_ver;
423     newver->ORB_ver = oldver->ORB_ver;
424     newver->ND_ver = oldver->ND_ver;
425     newver->AC_ver = oldver->AC_ver;
426     newver->TRK_ver = oldver->TRK_ver;
427     newver->CAL_ver = version->CAL_ver;
428     if ( strcmp(oldver->CAL_ver.Data(),"") ) reprocessing = true;
429     };
430     if ( !strcmp(Detector.Data(),"S4") ){
431     newver->TRIG_ver = oldver->TRIG_ver;
432     newver->TOF_ver = oldver->TOF_ver;
433     newver->ND_ver = oldver->ND_ver;
434     newver->AC_ver = oldver->AC_ver;
435     newver->TRK_ver = oldver->TRK_ver;
436     newver->ORB_ver = oldver->ORB_ver;
437     newver->CAL_ver = oldver->CAL_ver;
438     newver->S4_ver = version->S4_ver;
439     if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true;
440     };
441     if ( !strcmp(Detector.Data(),"ND") ){
442     newver->TRIG_ver = oldver->TRIG_ver;
443     newver->TOF_ver = oldver->TOF_ver;
444     newver->S4_ver = oldver->S4_ver;
445     newver->AC_ver = oldver->AC_ver;
446     newver->ORB_ver = oldver->ORB_ver;
447     newver->TRK_ver = oldver->TRK_ver;
448     newver->CAL_ver = oldver->CAL_ver;
449     newver->ND_ver = version->ND_ver;
450     if ( strcmp(oldver->ND_ver.Data(),"") ) reprocessing = true;
451     };
452     };
453     //
454 mocchiut 1.8 last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1);
455 mocchiut 1.1 //
456     } else {
457 mocchiut 1.8 if ( !found ) first_file_entry += (oldrun->EV_TO - oldrun->EV_FROM + 1);
458 mocchiut 1.1 };
459     //
460     file->cd();
461     newtree->Fill();
462     //
463     };
464     //
465     file->cd();
466     if ( oldtree ) oldtree->Delete("all");
467     newtree->SetName("Run");
468 mocchiut 1.8 //
469 mocchiut 1.3 delete newver;
470     delete newrun;
471     delete oldver;
472     delete oldrun;
473 mocchiut 1.1 //
474     if ( !found ){
475 mocchiut 1.8 if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
476 mocchiut 1.1 return(-5);
477     };
478     //
479     // newtree->Write();
480     };
481     return(0);
482     }
483    
484 mocchiut 1.8 Int_t ItoRunInfo::Read(UInt_t idRun){
485 mocchiut 1.1 //
486     isreadonly = true;
487     //
488     Bool_t debug = false;
489     //
490     SoftInfo *newver = new SoftInfo();
491     GL_RUN *newrun = new GL_RUN();
492     //
493     // Try to get the tree Run in the processed file
494     //
495     newtree = (TTree*)file->Get("Run");
496     //
497     if ( !newtree ) {
498     //
499     printf("\n RUNINFO - ERROR: no RunInfo tree in Level2 file. \n");
500     return(-801);
501     //
502     } else {
503     //
504     printf(" RunInfo: opening RunInfo tree \n");
505     //
506     newtree->SetBranchAddress("RunInfo",&newrun);
507     newtree->SetBranchAddress("SoftInfo",&newver);
508     //
509     totnorun = newtree->GetEntries();
510     //
511 mocchiut 1.7 if ( totnorun > 500 ){
512     if ( debug ) printf("\n RUNINFO - ERROR: can not handle more than 500 runs!\n");
513     return(-806);
514     };
515 mocchiut 1.1 //
516     first_file_entry = 0;
517     //
518     for ( UInt_t run = 0; run < totnorun; run++){
519     //
520     newtree->GetEntry(run);
521     //
522 mocchiut 1.8 file_entries += (newrun->EV_TO - newrun->EV_FROM + 1);
523 mocchiut 1.1 //
524     if ( debug ) printf("totnorun %i newrun->ID %i \n",(int)totnorun,(int)newrun->ID);
525     //
526 mocchiut 1.8 CopyFromTo(newrun,(GL_RUN*)this,newver,version);
527     if ( idRun == ID || idRun == 0 ){
528 mocchiut 1.1 runlist->AddAt(newrun->ID,norun);
529     norun++;
530     };
531 mocchiut 1.8 last_file_entry = first_file_entry + (newrun->EV_TO - newrun->EV_FROM + 1);
532 mocchiut 1.1 };
533     };
534     if ( debug ) printf("norun %i \n",(int)norun);
535     Int_t error = 0;
536     error = GetRunInfo(idRun);
537 mocchiut 1.3 delete newver;
538     delete newrun;
539 mocchiut 1.1 if ( error ) return(error);
540     return(0);
541     }
542    
543     void ItoRunInfo::Close(){
544     reprocessing = false;
545     updating = false;
546     first_file_entry = 0;
547     last_file_entry = 0;
548 mocchiut 1.8 file_entries = 0;
549 mocchiut 1.1 norun = 0;
550 mocchiut 1.7 delete runlist;
551 mocchiut 1.1 file = new TFile();
552     if ( isreadonly ) newtree->Delete();
553     }
554    
555     void ItoRunInfo::Clear(){
556     if ( newtree ) newtree->Delete();
557     }
558    
559     UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
560     //
561 mocchiut 1.5 UInt_t startfrom = 0;
562     //
563     if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
564 mocchiut 1.1 //
565 mocchiut 1.5 if ( entry > (UInt_t)last_file_entry ){
566     for ( UInt_t nrun = 0; nrun < norun; nrun++){
567 mocchiut 1.8 if ( ID == (UInt_t)runlist->At(nrun) ) {
568 mocchiut 1.5 startfrom = nrun+1;
569     break;
570     };
571     };
572     } else {
573     startfrom = 0;
574     };
575     //
576     if ( startfrom >= norun ) startfrom = 0;
577     //
578     retry:
579     //
580     for ( UInt_t nrun = startfrom; nrun < norun; nrun++){
581 mocchiut 1.8 GetRunInfo((UInt_t)runlist->At(nrun));
582 mocchiut 1.4 if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ){
583     return((UInt_t)runlist->At(nrun));
584 mocchiut 1.1 };
585     };
586 mocchiut 1.5 if ( startfrom ){
587     startfrom = 0;
588     goto retry;
589     };
590     printf(" ERROR! run not found \n");
591 mocchiut 1.1 return(0);
592     }
593    
594 mocchiut 1.8 Int_t ItoRunInfo::GetRunInfo(UInt_t run){
595 mocchiut 1.1 Bool_t found = false;
596     SoftInfo *nwver = new SoftInfo();
597     GL_RUN *nwrun = new GL_RUN();
598     //
599     newtree->SetBranchAddress("RunInfo",&nwrun);
600     newtree->SetBranchAddress("SoftInfo",&nwver);
601     //
602     last_file_entry = 0;
603     first_file_entry = 0;
604     //
605     totnorun = newtree->GetEntries();
606     //
607     for ( UInt_t nrun = 0; nrun < totnorun; nrun++){
608     newtree->GetEntry(nrun);
609     //
610 mocchiut 1.8 if ( nwrun->ID == run || run == 0 ){
611     CopyFromTo(nwrun,(GL_RUN*)this,nwver,version);
612 mocchiut 1.1 found = true;
613 mocchiut 1.8 last_file_entry = first_file_entry + (nwrun->EV_TO - nwrun->EV_FROM + 1);
614 mocchiut 1.1 };
615 mocchiut 1.8 if ( !found ) first_file_entry += (nwrun->EV_TO - nwrun->EV_FROM + 1);
616 mocchiut 1.1 };
617 mocchiut 1.3 delete nwver;
618     delete nwrun;
619 mocchiut 1.4 if ( found ) return(0);
620 mocchiut 1.1 return(-800);
621     }
622 mocchiut 1.5

  ViewVC Help
Powered by ViewVC 1.1.23