1 |
mocchiut |
1.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 |
mocchiut |
1.2 |
return(-805); |
248 |
mocchiut |
1.1 |
}; |
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 |
|
|
// |
306 |
|
|
return(0); |
307 |
|
|
// |
308 |
|
|
} else { |
309 |
|
|
// |
310 |
|
|
// temprfile = new TFile(temprname.str().c_str(),"READ"); |
311 |
|
|
// oldtree = (TTree*)temprfile->Get("Run-old"); |
312 |
|
|
// |
313 |
|
|
oldtree->SetBranchAddress("RunInfo",&oldrun); |
314 |
|
|
oldtree->SetBranchAddress("SoftInfo",&oldver); |
315 |
|
|
// |
316 |
|
|
totnorun = oldtree->GetEntries(); |
317 |
|
|
// |
318 |
|
|
runlist = new TArrayL((Int_t)totnorun); |
319 |
|
|
// |
320 |
|
|
found = false; |
321 |
|
|
// |
322 |
|
|
for ( UInt_t run = 0; run < totnorun; run++){ |
323 |
|
|
// |
324 |
|
|
oldtree->GetEntry(run); |
325 |
|
|
// |
326 |
|
|
newrun->ID = oldrun->ID; |
327 |
|
|
newrun->ID_REG_RUN = oldrun->ID_REG_RUN; |
328 |
|
|
newrun->ID_REG_RUN_L2 = oldrun->ID_REG_RUN_L2; |
329 |
|
|
newrun->RUNHEADER_TIME = oldrun->RUNHEADER_TIME; |
330 |
|
|
newrun->RUNTRAILER_TIME = oldrun->RUNTRAILER_TIME; |
331 |
|
|
newrun->EV_REG_PHYS_FROM = oldrun->EV_REG_PHYS_FROM; |
332 |
|
|
newrun->EV_REG_PHYS_TO = oldrun->EV_REG_PHYS_TO; |
333 |
|
|
newrun->EV_REG_RUNHEADER = oldrun->EV_REG_RUNHEADER; |
334 |
|
|
newrun->EV_REG_RUNTRAILER = oldrun->EV_REG_RUNTRAILER; |
335 |
|
|
newrun->TRK_CALIB_USED = oldrun->TRK_CALIB_USED; |
336 |
|
|
newrun->EFF_WRK_SCHEDULE = oldrun->EFF_WRK_SCHEDULE; |
337 |
|
|
newrun->PRH_VAR_TRG_MODE_A = oldrun->PRH_VAR_TRG_MODE_A; |
338 |
|
|
newrun->PRH_VAR_TRG_MODE_B = oldrun->PRH_VAR_TRG_MODE_B; |
339 |
|
|
newrun->ACQ_BUILD_INFO = oldrun->ACQ_BUILD_INFO; |
340 |
|
|
newrun->ACQ_VAR_INFO = oldrun->ACQ_VAR_INFO; |
341 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
342 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
343 |
|
|
newver->AC_ver = oldver->AC_ver; |
344 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
345 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
346 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
347 |
|
|
newver->S4_ver = oldver->S4_ver; |
348 |
|
|
newver->ND_ver = oldver->ND_ver; |
349 |
|
|
// |
350 |
|
|
file_entries += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1); |
351 |
|
|
// |
352 |
|
|
if ( debug ) printf("totnorun %i idRun %i newrun->ID %i \n",(int)totnorun,(int)idRun,(int)newrun->ID); |
353 |
|
|
// |
354 |
|
|
if ( idRun == 0ULL || idRun == newrun->ID ) { |
355 |
|
|
// |
356 |
|
|
if ( debug ) printf(" Updating run number %llu \n",idRun); |
357 |
|
|
// |
358 |
|
|
found = true; |
359 |
|
|
// |
360 |
|
|
runlist->AddAt(newrun->ID,norun); |
361 |
|
|
norun++; |
362 |
|
|
// |
363 |
|
|
if ( !strcmp(Detector.Data(),"NONE") ){ |
364 |
|
|
// |
365 |
|
|
// update infromations querying the DB |
366 |
|
|
// |
367 |
|
|
error = Query_GL_RUN(newrun->ID, dbc); |
368 |
|
|
// |
369 |
|
|
if ( error ){ |
370 |
|
|
if ( debug ) printf("\n RUNINFO - ERROR: Query_GL_RUN exited with non zero error\n"); |
371 |
|
|
return(error); |
372 |
|
|
}; |
373 |
|
|
// |
374 |
|
|
newrun->ID = ID; |
375 |
|
|
newrun->ID_REG_RUN = ID_REG_RUN; |
376 |
|
|
newrun->ID_REG_RUN_L2 = ID_REG_RUN_L2; |
377 |
|
|
newrun->RUNHEADER_TIME = RUNHEADER_TIME; |
378 |
|
|
newrun->RUNTRAILER_TIME = RUNTRAILER_TIME; |
379 |
|
|
newrun->EV_REG_PHYS_FROM = EV_REG_PHYS_FROM; |
380 |
|
|
newrun->EV_REG_PHYS_TO = EV_REG_PHYS_TO; |
381 |
|
|
newrun->EV_REG_RUNHEADER = EV_REG_RUNHEADER; |
382 |
|
|
newrun->EV_REG_RUNTRAILER = EV_REG_RUNTRAILER; |
383 |
|
|
newrun->TRK_CALIB_USED = TRK_CALIB_USED; |
384 |
|
|
newrun->EFF_WRK_SCHEDULE = EFF_WRK_SCHEDULE; |
385 |
|
|
newrun->PRH_VAR_TRG_MODE_A = PRH_VAR_TRG_MODE_A; |
386 |
|
|
newrun->PRH_VAR_TRG_MODE_B = PRH_VAR_TRG_MODE_B; |
387 |
|
|
newrun->ACQ_BUILD_INFO = ACQ_BUILD_INFO; |
388 |
|
|
newrun->ACQ_VAR_INFO = ACQ_VAR_INFO; |
389 |
|
|
} else { |
390 |
|
|
// |
391 |
|
|
if ( !strcmp(Detector.Data(),"TRIG") ){ |
392 |
|
|
newver->TRIG_ver = version->TRIG_ver; |
393 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
394 |
|
|
newver->AC_ver = oldver->AC_ver; |
395 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
396 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
397 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
398 |
|
|
newver->S4_ver = oldver->S4_ver; |
399 |
|
|
newver->ND_ver = oldver->ND_ver; |
400 |
|
|
if ( strcmp(oldver->TRIG_ver.Data(),"") ) reprocessing = true; |
401 |
|
|
}; |
402 |
|
|
if ( !strcmp(Detector.Data(),"TOF") ){ |
403 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
404 |
|
|
newver->TOF_ver = version->TOF_ver; |
405 |
|
|
newver->AC_ver = oldver->AC_ver; |
406 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
407 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
408 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
409 |
|
|
newver->S4_ver = oldver->S4_ver; |
410 |
|
|
newver->ND_ver = oldver->ND_ver; |
411 |
|
|
if ( strcmp(oldver->TOF_ver.Data(),"") ) reprocessing = true; |
412 |
|
|
}; |
413 |
|
|
if ( !strcmp(Detector.Data(),"AC") ){ |
414 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
415 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
416 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
417 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
418 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
419 |
|
|
newver->S4_ver = oldver->S4_ver; |
420 |
|
|
newver->ND_ver = oldver->ND_ver; |
421 |
|
|
newver->AC_ver = version->AC_ver; |
422 |
|
|
if ( strcmp(oldver->AC_ver.Data(),"") ) reprocessing = true; |
423 |
|
|
}; |
424 |
|
|
if ( !strcmp(Detector.Data(),"TRK") ){ |
425 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
426 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
427 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
428 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
429 |
|
|
newver->S4_ver = oldver->S4_ver; |
430 |
|
|
newver->ND_ver = oldver->ND_ver; |
431 |
|
|
newver->AC_ver = oldver->AC_ver; |
432 |
|
|
newver->TRK_ver = version->TRK_ver; |
433 |
|
|
if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true; |
434 |
|
|
}; |
435 |
|
|
if ( !strcmp(Detector.Data(),"ORB") ){ |
436 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
437 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
438 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
439 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
440 |
|
|
newver->S4_ver = oldver->S4_ver; |
441 |
|
|
newver->ND_ver = oldver->ND_ver; |
442 |
|
|
newver->AC_ver = oldver->AC_ver; |
443 |
|
|
newver->ORB_ver = version->ORB_ver; |
444 |
|
|
if ( strcmp(oldver->TRK_ver.Data(),"") ) reprocessing = true; |
445 |
|
|
}; |
446 |
|
|
if ( !strcmp(Detector.Data(),"CALO") ){ |
447 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
448 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
449 |
|
|
newver->S4_ver = oldver->S4_ver; |
450 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
451 |
|
|
newver->ND_ver = oldver->ND_ver; |
452 |
|
|
newver->AC_ver = oldver->AC_ver; |
453 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
454 |
|
|
newver->CAL_ver = version->CAL_ver; |
455 |
|
|
if ( strcmp(oldver->CAL_ver.Data(),"") ) reprocessing = true; |
456 |
|
|
}; |
457 |
|
|
if ( !strcmp(Detector.Data(),"S4") ){ |
458 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
459 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
460 |
|
|
newver->ND_ver = oldver->ND_ver; |
461 |
|
|
newver->AC_ver = oldver->AC_ver; |
462 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
463 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
464 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
465 |
|
|
newver->S4_ver = version->S4_ver; |
466 |
|
|
if ( strcmp(oldver->S4_ver.Data(),"") ) reprocessing = true; |
467 |
|
|
}; |
468 |
|
|
if ( !strcmp(Detector.Data(),"ND") ){ |
469 |
|
|
newver->TRIG_ver = oldver->TRIG_ver; |
470 |
|
|
newver->TOF_ver = oldver->TOF_ver; |
471 |
|
|
newver->S4_ver = oldver->S4_ver; |
472 |
|
|
newver->AC_ver = oldver->AC_ver; |
473 |
|
|
newver->ORB_ver = oldver->ORB_ver; |
474 |
|
|
newver->TRK_ver = oldver->TRK_ver; |
475 |
|
|
newver->CAL_ver = oldver->CAL_ver; |
476 |
|
|
newver->ND_ver = version->ND_ver; |
477 |
|
|
if ( strcmp(oldver->ND_ver.Data(),"") ) reprocessing = true; |
478 |
|
|
}; |
479 |
|
|
}; |
480 |
|
|
// |
481 |
|
|
last_file_entry = first_file_entry + (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1); |
482 |
|
|
// |
483 |
|
|
} else { |
484 |
|
|
if ( !found ) first_file_entry += (oldrun->EV_REG_PHYS_TO - oldrun->EV_REG_PHYS_FROM + 1); |
485 |
|
|
}; |
486 |
|
|
// |
487 |
|
|
file->cd(); |
488 |
|
|
newtree->Fill(); |
489 |
|
|
// |
490 |
|
|
}; |
491 |
|
|
// |
492 |
|
|
// temprfile->Close(); |
493 |
|
|
// gSystem->Unlink(temprname.str().c_str()); |
494 |
|
|
// if ( ismydir ) gSystem->Unlink(tempdir.str().c_str()); |
495 |
|
|
file->cd(); |
496 |
|
|
if ( oldtree ) oldtree->Delete("all"); |
497 |
|
|
newtree->SetName("Run"); |
498 |
|
|
// file->Write("Run"); |
499 |
|
|
// newtree->Delete(); |
500 |
|
|
// |
501 |
|
|
if ( !found ){ |
502 |
|
|
if ( debug ) printf("\n RUNINFO - ERROR: no run with ID_RUN = %llu \n",idRun); |
503 |
|
|
return(-5); |
504 |
|
|
}; |
505 |
|
|
// |
506 |
|
|
// newtree->Write(); |
507 |
|
|
}; |
508 |
|
|
return(0); |
509 |
|
|
} |
510 |
|
|
|
511 |
|
|
Int_t ItoRunInfo::Read(ULong64_t idRun){ |
512 |
|
|
// |
513 |
|
|
isreadonly = true; |
514 |
|
|
// |
515 |
|
|
Bool_t debug = false; |
516 |
|
|
// |
517 |
|
|
SoftInfo *newver = new SoftInfo(); |
518 |
|
|
GL_RUN *newrun = new GL_RUN(); |
519 |
|
|
// |
520 |
|
|
// Try to get the tree Run in the processed file |
521 |
|
|
// |
522 |
|
|
newtree = (TTree*)file->Get("Run"); |
523 |
|
|
// |
524 |
|
|
if ( !newtree ) { |
525 |
|
|
// |
526 |
|
|
printf("\n RUNINFO - ERROR: no RunInfo tree in Level2 file. \n"); |
527 |
|
|
return(-801); |
528 |
|
|
// |
529 |
|
|
} else { |
530 |
|
|
// |
531 |
|
|
printf(" RunInfo: opening RunInfo tree \n"); |
532 |
|
|
// |
533 |
|
|
newtree->SetBranchAddress("RunInfo",&newrun); |
534 |
|
|
newtree->SetBranchAddress("SoftInfo",&newver); |
535 |
|
|
// |
536 |
|
|
totnorun = newtree->GetEntries(); |
537 |
|
|
// |
538 |
|
|
runlist = new TArrayL((Int_t)totnorun); |
539 |
|
|
// |
540 |
|
|
first_file_entry = 0; |
541 |
|
|
// |
542 |
|
|
for ( UInt_t run = 0; run < totnorun; run++){ |
543 |
|
|
// |
544 |
|
|
newtree->GetEntry(run); |
545 |
|
|
// |
546 |
|
|
file_entries += (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1); |
547 |
|
|
// |
548 |
|
|
if ( debug ) printf("totnorun %i newrun->ID %i \n",(int)totnorun,(int)newrun->ID); |
549 |
|
|
// |
550 |
|
|
ID = newrun->ID; |
551 |
|
|
ID_REG_RUN = newrun->ID_REG_RUN; |
552 |
|
|
ID_REG_RUN_L2 = newrun->ID_REG_RUN_L2; |
553 |
|
|
RUNHEADER_TIME = newrun->RUNHEADER_TIME; |
554 |
|
|
RUNTRAILER_TIME = newrun->RUNTRAILER_TIME; |
555 |
|
|
EV_REG_PHYS_FROM = newrun->EV_REG_PHYS_FROM; |
556 |
|
|
EV_REG_PHYS_TO = newrun->EV_REG_PHYS_TO; |
557 |
|
|
EV_REG_RUNHEADER = newrun->EV_REG_RUNHEADER; |
558 |
|
|
EV_REG_RUNTRAILER = newrun->EV_REG_RUNTRAILER; |
559 |
|
|
TRK_CALIB_USED = newrun->TRK_CALIB_USED; |
560 |
|
|
EFF_WRK_SCHEDULE = newrun->EFF_WRK_SCHEDULE; |
561 |
|
|
PRH_VAR_TRG_MODE_A = newrun->PRH_VAR_TRG_MODE_A; |
562 |
|
|
PRH_VAR_TRG_MODE_B = newrun->PRH_VAR_TRG_MODE_B; |
563 |
|
|
ACQ_BUILD_INFO = newrun->ACQ_BUILD_INFO; |
564 |
|
|
ACQ_VAR_INFO = newrun->ACQ_VAR_INFO; |
565 |
|
|
version->TRIG_ver = newver->TRIG_ver; |
566 |
|
|
version->TOF_ver = newver->TOF_ver; |
567 |
|
|
version->AC_ver = newver->AC_ver; |
568 |
|
|
version->TRK_ver = newver->TRK_ver; |
569 |
|
|
version->ORB_ver = newver->ORB_ver; |
570 |
|
|
version->CAL_ver = newver->CAL_ver; |
571 |
|
|
version->S4_ver = newver->S4_ver; |
572 |
|
|
version->ND_ver = newver->ND_ver; |
573 |
|
|
if ( idRun == ID || idRun == 0ULL ){ |
574 |
|
|
runlist->AddAt(newrun->ID,norun); |
575 |
|
|
norun++; |
576 |
|
|
}; |
577 |
|
|
last_file_entry = first_file_entry + (newrun->EV_REG_PHYS_TO - newrun->EV_REG_PHYS_FROM + 1); |
578 |
|
|
}; |
579 |
|
|
}; |
580 |
|
|
if ( debug ) printf("norun %i \n",(int)norun); |
581 |
|
|
Int_t error = 0; |
582 |
|
|
error = GetRunInfo(idRun); |
583 |
|
|
if ( error ) return(error); |
584 |
|
|
return(0); |
585 |
|
|
} |
586 |
|
|
|
587 |
|
|
void ItoRunInfo::Close(){ |
588 |
|
|
reprocessing = false; |
589 |
|
|
updating = false; |
590 |
|
|
first_file_entry = 0; |
591 |
|
|
last_file_entry = 0; |
592 |
|
|
file_entries = 0ULL; |
593 |
|
|
norun = 0; |
594 |
|
|
runlist = new TArrayL(0,NULL); |
595 |
|
|
file = new TFile(); |
596 |
|
|
if ( isreadonly ) newtree->Delete(); |
597 |
|
|
} |
598 |
|
|
|
599 |
|
|
void ItoRunInfo::Clear(){ |
600 |
|
|
if ( newtree ) newtree->Delete(); |
601 |
|
|
} |
602 |
|
|
|
603 |
|
|
UInt_t ItoRunInfo::GetRunForEntry(UInt_t entry){ |
604 |
|
|
// |
605 |
|
|
ItoRunInfo *run = new ItoRunInfo(); |
606 |
|
|
// |
607 |
|
|
for ( UInt_t nrun = 0; nrun < norun; nrun++){ |
608 |
|
|
run->GetRunInfo((ULong64_t)nrun); |
609 |
|
|
if ( entry >= (UInt_t)run->first_file_entry && entry <= (UInt_t)run->last_file_entry ){ |
610 |
|
|
run->newtree->Delete(); |
611 |
|
|
return(nrun); |
612 |
|
|
}; |
613 |
|
|
}; |
614 |
|
|
run->newtree->Delete(); |
615 |
|
|
return(0); |
616 |
|
|
} |
617 |
|
|
|
618 |
|
|
Int_t ItoRunInfo::GetRunInfo(ULong64_t run){ |
619 |
|
|
Bool_t found = false; |
620 |
|
|
SoftInfo *nwver = new SoftInfo(); |
621 |
|
|
GL_RUN *nwrun = new GL_RUN(); |
622 |
|
|
// |
623 |
|
|
newtree->SetBranchAddress("RunInfo",&nwrun); |
624 |
|
|
newtree->SetBranchAddress("SoftInfo",&nwver); |
625 |
|
|
// |
626 |
|
|
last_file_entry = 0; |
627 |
|
|
first_file_entry = 0; |
628 |
|
|
// |
629 |
|
|
totnorun = newtree->GetEntries(); |
630 |
|
|
// |
631 |
|
|
for ( UInt_t nrun = 0; nrun < totnorun; nrun++){ |
632 |
|
|
newtree->GetEntry(nrun); |
633 |
|
|
// |
634 |
|
|
if ( nwrun->ID == run || run == 0ULL ){ |
635 |
|
|
ID = nwrun->ID; |
636 |
|
|
ID_REG_RUN = nwrun->ID_REG_RUN; |
637 |
|
|
ID_REG_RUN_L2 = nwrun->ID_REG_RUN_L2; |
638 |
|
|
RUNHEADER_TIME = nwrun->RUNHEADER_TIME; |
639 |
|
|
RUNTRAILER_TIME = nwrun->RUNTRAILER_TIME; |
640 |
|
|
EV_REG_PHYS_FROM = nwrun->EV_REG_PHYS_FROM; |
641 |
|
|
EV_REG_PHYS_TO = nwrun->EV_REG_PHYS_TO; |
642 |
|
|
EV_REG_RUNHEADER = nwrun->EV_REG_RUNHEADER; |
643 |
|
|
EV_REG_RUNTRAILER = nwrun->EV_REG_RUNTRAILER; |
644 |
|
|
TRK_CALIB_USED = nwrun->TRK_CALIB_USED; |
645 |
|
|
EFF_WRK_SCHEDULE = nwrun->EFF_WRK_SCHEDULE; |
646 |
|
|
PRH_VAR_TRG_MODE_A = nwrun->PRH_VAR_TRG_MODE_A; |
647 |
|
|
PRH_VAR_TRG_MODE_B = nwrun->PRH_VAR_TRG_MODE_B; |
648 |
|
|
ACQ_BUILD_INFO = nwrun->ACQ_BUILD_INFO; |
649 |
|
|
ACQ_VAR_INFO = nwrun->ACQ_VAR_INFO; |
650 |
|
|
version->TRIG_ver = nwver->TRIG_ver; |
651 |
|
|
version->TOF_ver = nwver->TOF_ver; |
652 |
|
|
version->AC_ver = nwver->AC_ver; |
653 |
|
|
version->TRK_ver = nwver->TRK_ver; |
654 |
|
|
version->ORB_ver = nwver->ORB_ver; |
655 |
|
|
version->CAL_ver = nwver->CAL_ver; |
656 |
|
|
version->S4_ver = nwver->S4_ver; |
657 |
|
|
version->ND_ver = nwver->ND_ver; |
658 |
|
|
found = true; |
659 |
|
|
last_file_entry = first_file_entry + (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1); |
660 |
|
|
}; |
661 |
|
|
if ( !found ) first_file_entry += (nwrun->EV_REG_PHYS_TO - nwrun->EV_REG_PHYS_FROM + 1); |
662 |
|
|
}; |
663 |
|
|
if ( found ) return(0); |
664 |
|
|
return(-800); |
665 |
|
|
} |