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