/[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.3 - (show annotations) (download)
Fri Jun 30 09:21:59 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r01beta
Changes since 1.2: +15 -1 lines
Memory leak bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23