/[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.13 - (hide annotations) (download)
Thu Nov 2 12:32:58 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.12: +7 -8 lines
R2-D2 moved to YodaProfiler package

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

  ViewVC Help
Powered by ViewVC 1.1.23