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