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

Contents of /DarthVader/RunInfo/src/RunInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (show annotations) (download)
Mon Nov 26 08:01:15 2007 UTC (17 years ago) by mocchiut
Branch: MAIN
CVS Tags: v5r00
Changes since 1.16: +2 -2 lines
Compilation bug fixed

1 //
2 #include <sstream>
3 //
4 #include <TObject.h>
5 #include <TChain.h>
6 #include <TSystem.h>
7 #include <TSystemFile.h>
8 #include <TArrayI.h>
9 #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 Clear();
26 }
27
28 void SoftInfo::Clear(Option_t *t){
29 TRIG_ver = "";
30 TOF_ver = "";
31 AC_ver = "";
32 TRK_ver = "";
33 ORB_ver = "";
34 CAL_ver = "";
35 ND_ver = "";
36 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() {
92 reprocessing = false;
93 updating = false;
94 isreadonly = true;
95 first_file_entry = 0;
96 last_file_entry = 0;
97 file_entries = 0;
98 totnorun = 0;
99 this->GL_RUN::Clear();
100 version = new SoftInfo();
101 norun = 0;
102 runlist = new TArrayI(500);
103 file = NULL;
104 newtree = new TTree();
105 }
106
107 ItoRunInfo::ItoRunInfo(TFile *processFl){
108 //
109 file=(TFile*)processFl;
110 dbc=NULL;
111 processFolder = "";
112 idRun = 0;
113 Detector = "NONE";
114 //
115 reprocessing = false;
116 updating = false;
117 first_file_entry = 0;
118 last_file_entry = 0;
119 file_entries = 0;
120 version = new SoftInfo();
121 // glrun = new GL_RUN();
122 norun = 0;
123 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
150 ItoRunInfo::ItoRunInfo(TSQLServer *db, TFile *processFl, TString processFld){
151 //
152 file=(TFile*)processFl;
153 dbc=(TSQLServer*)db;
154 processFolder = processFld;
155 //
156 reprocessing = false;
157 updating = false;
158 first_file_entry = 0;
159 last_file_entry = 0;
160 file_entries = 0;
161 version = new SoftInfo();
162 norun = 0;
163 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(UInt_t run, TString Detector, TString Version){
224 //
225 isreadonly = false;
226 idRun = run;
227 //
228 Bool_t debug = false;
229 //
230 Bool_t ismydir = false;
231 //
232 if ( !strcmp(processFolder.Data(),"") ){
233 processFolder = "runinfoFolder";
234 ismydir = true;
235 };
236 //
237 GL_RUN *oldrun = new GL_RUN();
238 GL_RUN *newrun = new GL_RUN();
239 SoftInfo *oldver = new SoftInfo();
240 SoftInfo *newver = new SoftInfo();
241 //
242 this->GL_RUN::Clear();
243 version->Clear();
244 //
245 norun = 0;
246 //
247 Bool_t found = false;
248 Int_t error = 0;
249 //
250 TTree *oldtree = 0;
251 //
252 // Try to get the tree Run in the processed file
253 //
254 oldtree = (TTree*)file->Get("Run");
255 //
256 // Look for detector's versions if we are updating a single detector
257 //
258 if ( debug ) printf("Detector -%s- \n",Detector.Data());
259 if ( !strcmp(Detector.Data(),"NONE") ){
260 version->TRIG_ver = Version;
261 version->TOF_ver = Version;
262 version->AC_ver = Version;
263 version->TRK_ver = Version;
264 version->ORB_ver = Version;
265 version->CAL_ver = Version;
266 version->S4_ver = Version;
267 version->DV_ver = Version;
268 version->ND_ver = Version;
269 } else {
270 if ( !strcmp(Detector.Data(),"TRIG") ) version->TRIG_ver = Version;
271 if ( !strcmp(Detector.Data(),"TOF") ) version->TOF_ver = Version;
272 if ( !strcmp(Detector.Data(),"AC") ) version->AC_ver = Version;
273 if ( !strcmp(Detector.Data(),"TRK") ) version->TRK_ver = Version;
274 if ( !strcmp(Detector.Data(),"CALO") ) version->CAL_ver = Version;
275 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;
278 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") && strcmp(Detector.Data(),"DV") ) return(-804);
280 };
281 //
282 if ( !oldtree ) {
283 //
284 if ( strcmp(Detector.Data(),"NONE") ) return(-803);
285 updating = false;
286 if ( debug ) printf(" RunInfo: creating Run tree in this file\n");
287 //
288 } else {
289 //
290 updating = true;
291 if ( debug ) printf(" RunInfo: updating versioning information \n");
292 //
293 };
294 //
295 file->cd();
296 //
297 // Prepare a new tree to upgrade the contents of the old tree
298 //
299 newtree = new TTree("Run-new","PAMELA Level2 data from the GL_RUN table");
300 newtree->Branch("RunInfo","GL_RUN",&newrun);
301 newtree->Branch("SoftInfo","SoftInfo",&newver);
302 //
303 //
304 if ( !updating ){
305 if ( idRun == 0 ){
306 if ( debug ) printf("\n RUNINFO - ERROR: reprocessing data but no RunInfo tree in Level2 file. \n");
307 return(-805);
308 };
309 //
310 error = Query_GL_RUN(idRun, dbc);
311 //
312 if ( error ){
313 if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");
314 return(error);
315 };
316 if ( ID == 0 ){
317 if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
318 return(-5);
319 };
320 //
321 //
322 CopyFromTo((GL_RUN*)this,newrun,version,newver);
323 //
324 // fill the tree;
325 //
326 newtree->Fill();
327 //
328 totnorun = 1;
329 reprocessing = false;
330 first_file_entry = 0;
331 if ( EV_TO >= EV_FROM ) last_file_entry = (UInt_t)(EV_TO - EV_FROM);
332 norun = 1;
333 runlist->AddAt((Int_t)ID,0);
334 //
335 newtree->SetName("Run");
336 //
337 file->cd();
338 //
339 delete newver;
340 delete newrun;
341 delete oldver;
342 delete oldrun;
343 //
344 return(0);
345 //
346 } else {
347 //
348 //
349 oldtree->SetBranchAddress("RunInfo",&oldrun);
350 oldtree->SetBranchAddress("SoftInfo",&oldver);
351 //
352 totnorun = oldtree->GetEntries();
353 //
354 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;
360 //
361 for ( UInt_t run = 0; run < totnorun; run++){
362 //
363 oldtree->GetEntry(run);
364 //
365 CopyFromTo(oldrun,newrun,oldver,newver);
366 //
367 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);
370 //
371 if ( idRun == 0 || idRun == newrun->ID ) {
372 //
373 if ( debug ) printf(" Updating run number %u \n",idRun);
374 //
375 found = true;
376 //
377 runlist->AddAt(newrun->ID,norun);
378 norun++;
379 //
380 if ( !strcmp(Detector.Data(),"NONE") ){
381 //
382 // update infromations querying the DB
383 //
384 error = Query_GL_RUN(newrun->ID, dbc);
385 //
386 if ( error ){
387 if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n");
388 return(error);
389 };
390 //
391 CopyFromTo((GL_RUN*)this,newrun,NULL,NULL);
392 //
393 } else {
394 //
395 if ( !strcmp(Detector.Data(),"TRIG") ){
396 newver->TRIG_ver = version->TRIG_ver;
397 newver->TOF_ver = oldver->TOF_ver;
398 newver->AC_ver = oldver->AC_ver;
399 newver->TRK_ver = oldver->TRK_ver;
400 newver->ORB_ver = oldver->ORB_ver;
401 newver->CAL_ver = oldver->CAL_ver;
402 newver->S4_ver = oldver->S4_ver;
403 newver->DV_ver = oldver->DV_ver;
404 newver->ND_ver = oldver->ND_ver;
405 if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true;
406 };
407 if ( !strcmp(Detector.Data(),"TOF") ){
408 newver->TRIG_ver = oldver->TRIG_ver;
409 newver->TOF_ver = version->TOF_ver;
410 newver->AC_ver = oldver->AC_ver;
411 newver->TRK_ver = oldver->TRK_ver;
412 newver->ORB_ver = oldver->ORB_ver;
413 newver->CAL_ver = oldver->CAL_ver;
414 newver->DV_ver = oldver->DV_ver;
415 newver->S4_ver = oldver->S4_ver;
416 newver->ND_ver = oldver->ND_ver;
417 if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true;
418 };
419 if ( !strcmp(Detector.Data(),"AC") ){
420 newver->TRIG_ver = oldver->TRIG_ver;
421 newver->TOF_ver = oldver->TOF_ver;
422 newver->TRK_ver = oldver->TRK_ver;
423 newver->ORB_ver = oldver->ORB_ver;
424 newver->CAL_ver = oldver->CAL_ver;
425 newver->DV_ver = oldver->DV_ver;
426 newver->S4_ver = oldver->S4_ver;
427 newver->ND_ver = oldver->ND_ver;
428 newver->AC_ver = version->AC_ver;
429 if ( strcmp(oldver->AC_ver.Data(),"") ) reprocessing = true;
430 };
431 if ( !strcmp(Detector.Data(),"TRK") ){
432 newver->TRIG_ver = oldver->TRIG_ver;
433 newver->TOF_ver = oldver->TOF_ver;
434 newver->CAL_ver = oldver->CAL_ver;
435 newver->ORB_ver = oldver->ORB_ver;
436 newver->DV_ver = oldver->DV_ver;
437 newver->S4_ver = oldver->S4_ver;
438 newver->ND_ver = oldver->ND_ver;
439 newver->AC_ver = oldver->AC_ver;
440 newver->TRK_ver = version->TRK_ver;
441 if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true;
442 };
443 if ( !strcmp(Detector.Data(),"ORB") ){
444 newver->TRIG_ver = oldver->TRIG_ver;
445 newver->TOF_ver = oldver->TOF_ver;
446 newver->CAL_ver = oldver->CAL_ver;
447 newver->TRK_ver = oldver->TRK_ver;
448 newver->DV_ver = oldver->DV_ver;
449 newver->S4_ver = oldver->S4_ver;
450 newver->ND_ver = oldver->ND_ver;
451 newver->AC_ver = oldver->AC_ver;
452 newver->ORB_ver = version->ORB_ver;
453 if ( strcmp(oldver->ORB_ver.Data(),"") ) reprocessing = true;
454 };
455 if ( !strcmp(Detector.Data(),"CALO") ){
456 newver->TRIG_ver = oldver->TRIG_ver;
457 newver->TOF_ver = oldver->TOF_ver;
458 newver->DV_ver = oldver->DV_ver;
459 newver->S4_ver = oldver->S4_ver;
460 newver->ORB_ver = oldver->ORB_ver;
461 newver->ND_ver = oldver->ND_ver;
462 newver->AC_ver = oldver->AC_ver;
463 newver->TRK_ver = oldver->TRK_ver;
464 newver->CAL_ver = version->CAL_ver;
465 if ( strcmp(oldver->CAL_ver.Data(),"") ) reprocessing = true;
466 };
467 if ( !strcmp(Detector.Data(),"S4") ){
468 newver->TRIG_ver = oldver->TRIG_ver;
469 newver->TOF_ver = oldver->TOF_ver;
470 newver->ND_ver = oldver->ND_ver;
471 newver->AC_ver = oldver->AC_ver;
472 newver->TRK_ver = oldver->TRK_ver;
473 newver->ORB_ver = oldver->ORB_ver;
474 newver->CAL_ver = oldver->CAL_ver;
475 newver->DV_ver = oldver->DV_ver;
476 newver->S4_ver = version->S4_ver;
477 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") ){
492 newver->TRIG_ver = oldver->TRIG_ver;
493 newver->TOF_ver = oldver->TOF_ver;
494 newver->DV_ver = oldver->DV_ver;
495 newver->S4_ver = oldver->S4_ver;
496 newver->AC_ver = oldver->AC_ver;
497 newver->ORB_ver = oldver->ORB_ver;
498 newver->TRK_ver = oldver->TRK_ver;
499 newver->CAL_ver = oldver->CAL_ver;
500 newver->ND_ver = version->ND_ver;
501 if ( strcmp(oldver->ND_ver.Data(),"") ) reprocessing = true;
502 };
503 };
504 //
505 if ( oldrun->EV_TO >= oldrun->EV_FROM ) last_file_entry = first_file_entry + (oldrun->EV_TO - oldrun->EV_FROM + 1);
506 //
507 } else {
508 if ( !found ) first_file_entry += (oldrun->EV_TO - oldrun->EV_FROM + 1);
509 };
510 //
511 file->cd();
512 newtree->Fill();
513 //
514 };
515 //
516 file->cd();
517 if ( oldtree ) oldtree->Delete("all");
518 newtree->SetName("Run");
519 //
520 delete newver;
521 delete newrun;
522 delete oldver;
523 delete oldrun;
524 //
525 if ( !found ){
526 if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %u \n",idRun);
527 return(-5);
528 };
529 //
530 // newtree->Write();
531 };
532 return(0);
533 }
534
535 Int_t ItoRunInfo::Read(UInt_t idRun){
536 //
537 isreadonly = true;
538 //
539 Bool_t debug = false;
540 //
541 SoftInfo *newver = new SoftInfo();
542 GL_RUN *newrun = new GL_RUN();
543 //
544 // Try to get the tree Run in the processed file
545 //
546 newtree = (TTree*)file->Get("Run");
547 //
548 if ( !newtree ) {
549 //
550 printf("\n RUNINFO - ERROR: no RunInfo tree in Level2 file. \n");
551 return(-801);
552 //
553 } else {
554 //
555 printf(" RunInfo: opening RunInfo tree \n");
556 //
557 newtree->SetBranchAddress("RunInfo",&newrun);
558 newtree->SetBranchAddress("SoftInfo",&newver);
559 //
560 totnorun = newtree->GetEntries();
561 //
562 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;
568 //
569 for ( UInt_t run = 0; run < totnorun; run++){
570 //
571 newtree->GetEntry(run);
572 //
573 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);
576 //
577 CopyFromTo(newrun,(GL_RUN*)this,newver,version);
578 if ( idRun == ID || idRun == 0 ){
579 runlist->AddAt(newrun->ID,norun);
580 norun++;
581 };
582 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);
586 Int_t error = 0;
587 error = GetRunInfo(idRun);
588 delete newver;
589 delete newrun;
590 if ( error ) return(error);
591 return(0);
592 }
593
594 void ItoRunInfo::Close(){
595 reprocessing = false;
596 updating = false;
597 first_file_entry = 0;
598 last_file_entry = 0;
599 file_entries = 0;
600 norun = 0;
601 delete runlist;
602 // file = new TFile();
603 file = 0;
604 if ( isreadonly ) newtree->Delete();
605 }
606
607 void ItoRunInfo::Clear(Option_t *t){
608 if ( newtree ) newtree->Delete();
609 }
610
611 UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){
612 //
613 UInt_t startfrom = 0;
614 //
615 if ( entry >= (UInt_t)first_file_entry && entry <= (UInt_t)last_file_entry ) return(ID);
616 //
617 if ( entry > (UInt_t)last_file_entry ){
618 for ( UInt_t nrun = 0; nrun < norun; nrun++){
619 if ( ID == (UInt_t)runlist->At(nrun) ) {
620 startfrom = nrun+1;
621 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 ){
635 return((UInt_t)runlist->At(nrun));
636 };
637 };
638 if ( startfrom ){
639 startfrom = 0;
640 goto retry;
641 };
642 printf(" ERROR! run not found \n");
643 return(0);
644 }
645
646 Int_t ItoRunInfo::GetRunInfo(UInt_t run){
647 Bool_t found = false;
648 SoftInfo *nwver = new SoftInfo();
649 GL_RUN *nwrun = new GL_RUN();
650 //
651 newtree->SetBranchAddress("RunInfo",&nwrun);
652 newtree->SetBranchAddress("SoftInfo",&nwver);
653 //
654 last_file_entry = 0;
655 first_file_entry = 0;
656 //
657 totnorun = newtree->GetEntries();
658 //
659 for ( UInt_t nrun = 0; nrun < totnorun; nrun++){
660 newtree->GetEntry(nrun);
661 //
662 if ( nwrun->ID == run || run == 0 ){
663 CopyFromTo(nwrun,(GL_RUN*)this,nwver,version);
664 found = true;
665 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_TO - nwrun->EV_FROM + 1);
668 };
669 delete nwver;
670 delete nwrun;
671 if ( found ) return(0);
672 return(-800);
673 }
674

  ViewVC Help
Powered by ViewVC 1.1.23