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