1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file RunGlue.cpp |
3 |
|
|
* \author Emiliano Mocchiutti |
4 |
|
|
* |
5 |
|
|
* The file contains implementation of the methods to query the DB. |
6 |
|
|
*/ |
7 |
|
|
// |
8 |
mocchiut |
1.11 |
#include <sstream> |
9 |
|
|
#include <iostream> |
10 |
|
|
// |
11 |
|
|
#include <TFile.h> |
12 |
|
|
#include <TTree.h> |
13 |
|
|
#include <TTimeStamp.h> |
14 |
|
|
#include <TTreeCloner.h> |
15 |
mocchiut |
1.1 |
#include <RunGlue.h> |
16 |
|
|
// |
17 |
|
|
ClassImp(RunGlue); |
18 |
|
|
// |
19 |
|
|
using namespace std; |
20 |
|
|
|
21 |
|
|
RunGlue::RunGlue() { |
22 |
|
|
this->Clear(); |
23 |
|
|
} |
24 |
|
|
|
25 |
mocchiut |
1.11 |
RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi) { |
26 |
mocchiut |
1.1 |
fDBG = false; |
27 |
|
|
li = new PamLevel2(); |
28 |
mocchiut |
1.12 |
// li = 0; |
29 |
mocchiut |
1.1 |
this->Clear(); |
30 |
|
|
dbc = da; |
31 |
|
|
run = ru; |
32 |
|
|
dir = di; |
33 |
|
|
// |
34 |
mocchiut |
1.12 |
wd = gSystem->WorkingDirectory(); |
35 |
mocchiut |
1.1 |
// |
36 |
|
|
outdir = wrkdi; |
37 |
|
|
if ( !strcmp(outdir.Data(),"") ) outdir = wd; |
38 |
|
|
fList = 0; |
39 |
|
|
if ( run ){ |
40 |
|
|
runmode = true; |
41 |
|
|
} else { |
42 |
|
|
runmode = false; |
43 |
|
|
createlist = true; |
44 |
|
|
}; |
45 |
mocchiut |
1.16 |
fUpgrade = true; |
46 |
mocchiut |
1.1 |
// |
47 |
|
|
// lList = new TList(); |
48 |
|
|
// |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
void RunGlue::Clear() { |
52 |
|
|
fEnd = false; |
53 |
|
|
run = 0; |
54 |
|
|
dir = ""; |
55 |
|
|
outdir = ""; |
56 |
|
|
fFilename = ""; |
57 |
|
|
}; |
58 |
|
|
|
59 |
|
|
void RunGlue::Clean() { |
60 |
|
|
if ( !merged ) gSystem->Unlink(fFilename); |
61 |
|
|
lList->Delete(); |
62 |
|
|
delete Target; |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
void RunGlue::SetDebug(Bool_t dbg) { |
66 |
|
|
fDBG = dbg; |
67 |
|
|
}; |
68 |
|
|
|
69 |
|
|
void RunGlue::SetDList(TString list) { |
70 |
|
|
// |
71 |
|
|
RUN = true; |
72 |
|
|
// |
73 |
|
|
if (list.Contains("-RUN", TString::kIgnoreCase)) RUN = false; |
74 |
|
|
if (list.Contains("-ALL", TString::kIgnoreCase)) RUN = false; |
75 |
|
|
if (list.Contains("+RUN", TString::kIgnoreCase)) RUN = true; |
76 |
|
|
if (list.Contains("+ALL", TString::kIgnoreCase)) RUN = true; |
77 |
|
|
// |
78 |
|
|
fDList = list; |
79 |
mocchiut |
1.12 |
// li->SetWhichTrees(fDList); |
80 |
mocchiut |
1.1 |
// |
81 |
|
|
if ( DebugMode() ) printf(" Detector list is %s \n",fDList.Data()); |
82 |
|
|
// |
83 |
|
|
}; |
84 |
|
|
|
85 |
|
|
TList *RunGlue::GetRunList(){ |
86 |
mocchiut |
1.12 |
// |
87 |
mocchiut |
1.1 |
lList = new TList(); |
88 |
|
|
lList->Clear(); |
89 |
|
|
TString thisrun; |
90 |
|
|
TFile *su; |
91 |
|
|
// |
92 |
|
|
TSQLResult *pResult; |
93 |
|
|
TSQLRow *Row; |
94 |
|
|
// |
95 |
|
|
if ( run && runmode ){ |
96 |
|
|
// |
97 |
|
|
// Qurey the GL_RUN table to obtain RUN infos |
98 |
|
|
// |
99 |
|
|
GL_RUN *glrun = new GL_RUN(); |
100 |
|
|
glrun->Query_GL_RUN(run,dbc); |
101 |
|
|
// |
102 |
|
|
// convert RUNHEADER_TIME into a UTC date |
103 |
|
|
// |
104 |
|
|
GL_TIMESYNC *dbtime = new GL_TIMESYNC(); |
105 |
|
|
// |
106 |
|
|
TString UTC="UTC"; |
107 |
|
|
TString rhdate=dbtime->ConvertTime(UTC,glrun->RUNHEADER_TIME); |
108 |
|
|
// |
109 |
|
|
TDatime ti = TDatime(rhdate.Data()); |
110 |
|
|
// |
111 |
|
|
YY=(UInt_t)ti.GetYear(); |
112 |
|
|
MM=(UInt_t)ti.GetMonth(); |
113 |
|
|
DD=(UInt_t)ti.GetDay(); |
114 |
|
|
// |
115 |
|
|
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
116 |
|
|
// |
117 |
|
|
UInt_t lowerlimit = llim->GetSec(); |
118 |
mocchiut |
1.18 |
UInt_t upperlimit = lowerlimit + 86400; |
119 |
mocchiut |
1.1 |
// |
120 |
|
|
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
121 |
|
|
// |
122 |
|
|
YY -= 2000; |
123 |
|
|
stringstream tmpf; |
124 |
|
|
tmpf.str(""); |
125 |
|
|
tmpf << "L2PAM"; |
126 |
|
|
if ( YY < 10 ){ |
127 |
|
|
tmpf<< "0" << YY; |
128 |
|
|
} else { |
129 |
|
|
tmpf<< YY; |
130 |
|
|
}; |
131 |
|
|
if ( MM < 10 ){ |
132 |
|
|
tmpf<< "0" << MM; |
133 |
|
|
} else { |
134 |
|
|
tmpf<< MM; |
135 |
|
|
}; |
136 |
|
|
if ( DD < 10 ){ |
137 |
|
|
tmpf << "0" << DD << ".root"; |
138 |
|
|
} else { |
139 |
|
|
tmpf << DD << ".root"; |
140 |
|
|
}; |
141 |
|
|
TString fpath = ""; |
142 |
|
|
if ( !strcmp(outdir,"") ){ |
143 |
|
|
fpath="./"; |
144 |
|
|
} else { |
145 |
|
|
fpath += outdir; |
146 |
|
|
fpath += "/"; |
147 |
|
|
}; |
148 |
|
|
// |
149 |
|
|
fFilename = fpath + tmpf.str().c_str(); |
150 |
|
|
// |
151 |
|
|
printf(" Output filename is %s \n",fFilename.Data()); |
152 |
|
|
// |
153 |
mocchiut |
1.4 |
if ( !this->OpenFile() ){ |
154 |
|
|
fEnd = true; |
155 |
|
|
return(0); |
156 |
|
|
}; |
157 |
|
|
// |
158 |
|
|
stringstream myquery; |
159 |
|
|
myquery.str(""); |
160 |
|
|
myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit |
161 |
|
|
<< " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;"; |
162 |
|
|
// |
163 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
164 |
|
|
for( UInt_t r=0; r < 1000; r++){ |
165 |
|
|
Row = pResult->Next(); |
166 |
|
|
if( Row == NULL ) break; |
167 |
|
|
if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0)); |
168 |
|
|
// |
169 |
|
|
thisrun=dir+(TString)Row->GetField(0)+".Level2.root"; |
170 |
|
|
// |
171 |
|
|
if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data()); |
172 |
|
|
// |
173 |
|
|
su = TFile::Open(thisrun); |
174 |
|
|
if ( li->CheckLevel2File(thisrun) ){ |
175 |
|
|
lList->Add(su); |
176 |
|
|
} else { |
177 |
mocchiut |
1.12 |
if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0)); |
178 |
mocchiut |
1.4 |
}; |
179 |
|
|
// |
180 |
|
|
}; |
181 |
|
|
// |
182 |
|
|
// |
183 |
mocchiut |
1.1 |
delete glrun; |
184 |
|
|
delete dbtime; |
185 |
|
|
// |
186 |
|
|
}; |
187 |
|
|
// |
188 |
|
|
if ( strcmp(dir.Data(),"" )){ |
189 |
|
|
// |
190 |
|
|
if ( createlist ){ |
191 |
|
|
fList = new TList(); |
192 |
|
|
fDoneList = new TList(); |
193 |
|
|
fNlist = 0; |
194 |
|
|
fNlistdone = 0; |
195 |
|
|
// |
196 |
|
|
// read files in the directory |
197 |
|
|
// |
198 |
|
|
if ( DebugMode() ) printf("\n No input run given\n Check for existing root files. \n"); |
199 |
|
|
// |
200 |
|
|
TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(dir),dir); |
201 |
|
|
TList *temp = datadir->GetListOfFiles(); |
202 |
|
|
// |
203 |
|
|
TIter next(temp); |
204 |
|
|
TSystemFile *questo = 0; |
205 |
|
|
// |
206 |
|
|
while ( (questo = (TSystemFile*)next()) ) { |
207 |
|
|
TString name = questo->GetName(); |
208 |
|
|
if( name.EndsWith(".Level2.root") ){ |
209 |
|
|
char *fullpath0; |
210 |
|
|
gSystem->IsFileInIncludePath(name,&fullpath0); |
211 |
|
|
TString fullpath = fullpath0; |
212 |
|
|
// |
213 |
|
|
if ( DebugMode() ) printf(" fullpath = %s name %s \n",fullpath.Data(),name.Data()); |
214 |
|
|
// |
215 |
|
|
// |
216 |
|
|
su = TFile::Open(fullpath); |
217 |
|
|
if ( li->CheckLevel2File((TString)fullpath) ){ |
218 |
|
|
fList->Add(su); |
219 |
|
|
fNlist++; |
220 |
|
|
} else { |
221 |
|
|
if ( DebugMode() ) printf(" RUN %s DISCARDED \n",fullpath.Data()); |
222 |
|
|
}; |
223 |
|
|
// |
224 |
|
|
}; |
225 |
|
|
}; |
226 |
|
|
createlist = false; |
227 |
|
|
nrun = 0; |
228 |
|
|
}; |
229 |
|
|
// |
230 |
|
|
// |
231 |
|
|
// |
232 |
|
|
Bool_t stop = true; |
233 |
|
|
UInt_t drun = 0; |
234 |
|
|
while ( nrun < fNlist && stop ){ |
235 |
|
|
TString myrun = (TString)((TString)(gSystem->BaseName(((TFile*)fList->At(nrun))->GetName()))).ReplaceAll(".Level2.root",12,"",0); |
236 |
|
|
if ( DebugMode() ) printf(" nrun %u myrun is %s \n",nrun,(myrun.ReplaceAll(".Level2.root",12,"",0)).Data()); |
237 |
|
|
run = (UInt_t)(myrun.Atoi()); |
238 |
|
|
nrun++; |
239 |
|
|
// |
240 |
|
|
TString donerun = ""; |
241 |
|
|
for (UInt_t ll=0; ll<fNlistdone; ll++){ |
242 |
|
|
donerun = ""; |
243 |
|
|
donerun = (TString)((TString)(gSystem->BaseName(((TFile*)fDoneList->At(ll))->GetName()))).ReplaceAll(".Level2.root",12,"",0); |
244 |
|
|
if ( DebugMode() ) printf(" donerun is %s \n",(donerun.ReplaceAll(".Level2.root",12,"",0)).Data()); |
245 |
|
|
drun = (UInt_t)(donerun.Atoi()); |
246 |
|
|
// |
247 |
|
|
if ( run == drun ) goto jump; |
248 |
|
|
// |
249 |
|
|
}; |
250 |
|
|
// |
251 |
|
|
stop = false; |
252 |
|
|
// |
253 |
|
|
jump: |
254 |
|
|
drun = 0; |
255 |
|
|
// |
256 |
|
|
}; |
257 |
|
|
// |
258 |
|
|
if ( nrun >= fNlist && stop ){ |
259 |
|
|
fEnd = true; |
260 |
|
|
return(0); |
261 |
|
|
}; |
262 |
|
|
// |
263 |
|
|
// Qurey the GL_RUN table to obtain RUN infos |
264 |
|
|
// |
265 |
|
|
printf(" PROCESSING RUN %u AND ITS FRIENDS\n",run); |
266 |
|
|
GL_RUN *glrun = new GL_RUN(); |
267 |
|
|
glrun->Query_GL_RUN(run,dbc); |
268 |
|
|
// |
269 |
|
|
// convert RUNHEADER_TIME into a UTC date |
270 |
|
|
// |
271 |
|
|
GL_TIMESYNC *dbtime = new GL_TIMESYNC(); |
272 |
|
|
// |
273 |
|
|
TString UTC="UTC"; |
274 |
|
|
TString rhdate=dbtime->ConvertTime(UTC,glrun->RUNHEADER_TIME); |
275 |
|
|
// |
276 |
|
|
TDatime ti = TDatime(rhdate.Data()); |
277 |
|
|
// |
278 |
|
|
YY=(UInt_t)ti.GetYear(); |
279 |
|
|
MM=(UInt_t)ti.GetMonth(); |
280 |
|
|
DD=(UInt_t)ti.GetDay(); |
281 |
|
|
// |
282 |
|
|
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
283 |
|
|
// |
284 |
|
|
UInt_t lowerlimit = llim->GetSec(); |
285 |
mocchiut |
1.18 |
UInt_t upperlimit = lowerlimit + 86400; |
286 |
mocchiut |
1.1 |
// |
287 |
|
|
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
288 |
|
|
// |
289 |
|
|
YY -= 2000; |
290 |
|
|
stringstream tmpf; |
291 |
|
|
tmpf.str(""); |
292 |
|
|
tmpf << "L2PAM"; |
293 |
|
|
if ( YY < 10 ){ |
294 |
|
|
tmpf<< "0" << YY; |
295 |
|
|
} else { |
296 |
|
|
tmpf<< YY; |
297 |
|
|
}; |
298 |
|
|
if ( MM < 10 ){ |
299 |
|
|
tmpf<< "0" << MM; |
300 |
|
|
} else { |
301 |
|
|
tmpf<< MM; |
302 |
|
|
}; |
303 |
|
|
if ( DD < 10 ){ |
304 |
|
|
tmpf << "0" << DD << ".root"; |
305 |
|
|
} else { |
306 |
|
|
tmpf << DD << ".root"; |
307 |
|
|
}; |
308 |
|
|
TString fpath = ""; |
309 |
|
|
if ( !strcmp(outdir,"") ){ |
310 |
|
|
fpath="./"; |
311 |
|
|
} else { |
312 |
|
|
fpath += outdir; |
313 |
|
|
fpath += "/"; |
314 |
|
|
}; |
315 |
|
|
// |
316 |
|
|
fFilename = fpath + tmpf.str().c_str(); |
317 |
|
|
// |
318 |
|
|
printf(" Output filename is %s \n",fFilename.Data()); |
319 |
|
|
// |
320 |
mocchiut |
1.4 |
if ( !this->OpenFile() ) return(0); |
321 |
|
|
// |
322 |
|
|
stringstream myquery; |
323 |
|
|
myquery.str(""); |
324 |
|
|
myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit |
325 |
|
|
<< " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;"; |
326 |
|
|
// |
327 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
328 |
|
|
for( UInt_t r=0; r < 1000; r++){ |
329 |
|
|
Row = pResult->Next(); |
330 |
|
|
if( Row == NULL ) break; |
331 |
|
|
if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0)); |
332 |
|
|
// |
333 |
|
|
thisrun=dir+(TString)Row->GetField(0)+".Level2.root"; |
334 |
|
|
// |
335 |
|
|
if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data()); |
336 |
|
|
// |
337 |
|
|
su = TFile::Open(thisrun); |
338 |
|
|
if ( su ){ |
339 |
|
|
TFile *su0 = TFile::Open(thisrun); |
340 |
|
|
fDoneList->Add(su0); |
341 |
|
|
fNlistdone++; |
342 |
|
|
}; |
343 |
|
|
if ( li->CheckLevel2File(thisrun) ){ |
344 |
|
|
lList->Add(su); |
345 |
|
|
if ( DebugMode() ) printf(" RUN %s ADDED \n",Row->GetField(0)); |
346 |
|
|
} else { |
347 |
|
|
if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0)); |
348 |
|
|
}; |
349 |
|
|
// |
350 |
|
|
}; |
351 |
|
|
// |
352 |
mocchiut |
1.1 |
if ( DebugMode() ){ |
353 |
|
|
UInt_t ll = 0; |
354 |
|
|
while ( (TFile*)lList->At(ll) ){ |
355 |
|
|
TString donerun = ""; |
356 |
|
|
donerun = (TString)((TString)(gSystem->BaseName(((TFile*)lList->At(ll))->GetName()))).ReplaceAll(".Level2.root",12,"",0); |
357 |
|
|
printf(" XXX file is %s \n",donerun.Data()); |
358 |
|
|
ll++; |
359 |
|
|
// |
360 |
|
|
}; |
361 |
|
|
}; |
362 |
|
|
// |
363 |
|
|
delete glrun; |
364 |
|
|
delete dbtime; |
365 |
|
|
// |
366 |
|
|
}; |
367 |
|
|
// |
368 |
|
|
// is it the end? |
369 |
|
|
// |
370 |
|
|
if ( runmode ){ |
371 |
|
|
fEnd = true; |
372 |
|
|
} else { |
373 |
|
|
// |
374 |
|
|
// did we use all the run in the directory? if so exit |
375 |
|
|
// |
376 |
|
|
if ( nrun >= fNlist ) fEnd = true; |
377 |
|
|
}; |
378 |
|
|
// |
379 |
|
|
return(lList); |
380 |
|
|
}; |
381 |
|
|
|
382 |
|
|
Bool_t RunGlue::OpenFile(){ |
383 |
|
|
// |
384 |
mocchiut |
1.11 |
fOpen = false; |
385 |
|
|
printf(" Check if output file already exists \n"); |
386 |
mocchiut |
1.10 |
ifstream myfile; |
387 |
mocchiut |
1.11 |
myfile.open((this->GetFilename()).Data()); |
388 |
|
|
if ( myfile ){ |
389 |
mocchiut |
1.7 |
// Target = TFile::Open((this->GetFilename()).Data(), "READ" ); |
390 |
|
|
// |
391 |
|
|
// if ( Target ){ |
392 |
|
|
// Target->Close(); |
393 |
mocchiut |
1.11 |
myfile.close(); |
394 |
|
|
printf("Error opening target file, %s already exist!\n",(this->GetFilename()).Data()); |
395 |
mocchiut |
1.1 |
return(false); |
396 |
|
|
} else { |
397 |
|
|
// |
398 |
mocchiut |
1.16 |
// try to lock tables and work on a db level to avoid multiple file simultaneous access |
399 |
|
|
// |
400 |
|
|
stringstream oss; |
401 |
|
|
// |
402 |
|
|
if ( fUpgrade ){ |
403 |
|
|
oss.str(""); |
404 |
|
|
oss << "lock table GL_ROOT write;"; |
405 |
|
|
TSQLResult *result = 0; |
406 |
|
|
TSQLRow *row = 0; |
407 |
|
|
result = dbc->Query(oss.str().c_str()); |
408 |
|
|
oss.str(""); |
409 |
|
|
oss << "select ID from GL_ROOT where NAME='" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "';"; |
410 |
|
|
result = dbc->Query(oss.str().c_str()); |
411 |
|
|
row = result->Next(); |
412 |
|
|
if ( row ){ |
413 |
|
|
printf("Error opening target file (does %s exist? already in the DB? are the permissions ok?)\n",(this->GetFilename()).Data()); |
414 |
|
|
return(false); |
415 |
|
|
} else { |
416 |
|
|
oss.str(""); |
417 |
|
|
oss << "insert into GL_ROOT (PATH,NAME) values ('$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
418 |
|
|
result = dbc->Query(oss.str().c_str()); |
419 |
|
|
}; |
420 |
|
|
oss.str(""); |
421 |
|
|
oss << "unlock tables;"; |
422 |
|
|
result = dbc->Query(oss.str().c_str()); |
423 |
|
|
}; |
424 |
mocchiut |
1.15 |
// Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" ); |
425 |
|
|
Target = TFile::Open((this->GetFilename()).Data(), "NEW" ); |
426 |
|
|
// |
427 |
mocchiut |
1.1 |
printf(" Output file does not exist, creating it\n"); |
428 |
|
|
// |
429 |
mocchiut |
1.5 |
Long64_t maxsize = 99900000000LL; |
430 |
mocchiut |
1.1 |
// |
431 |
mocchiut |
1.15 |
if ( !Target || Target->IsZombie()) { |
432 |
|
|
printf("Error opening target file (does %s exist? are the permissions ok?)\n",(this->GetFilename()).Data()); |
433 |
|
|
// exit(1); |
434 |
|
|
return(false); |
435 |
|
|
} |
436 |
|
|
// |
437 |
|
|
Target->Write(); |
438 |
|
|
// |
439 |
mocchiut |
1.3 |
//fastMethod = kTRUE; |
440 |
|
|
fastMethod = kFALSE; |
441 |
mocchiut |
1.1 |
// |
442 |
|
|
// |
443 |
|
|
TTree::SetMaxTreeSize(maxsize); |
444 |
mocchiut |
1.13 |
// Target->SetCompressionLevel(2); |
445 |
|
|
Target->SetCompressionLevel(3); |
446 |
mocchiut |
1.12 |
//Target->SetCompressionLevel(5); |
447 |
mocchiut |
1.1 |
// |
448 |
mocchiut |
1.4 |
fOpen = true; |
449 |
mocchiut |
1.1 |
return(true); |
450 |
|
|
// |
451 |
|
|
}; |
452 |
|
|
// |
453 |
|
|
return(true); |
454 |
|
|
// |
455 |
|
|
}; |
456 |
|
|
|
457 |
|
|
|
458 |
|
|
void RunGlue::DeleteRunFiles(TList *dlist){ |
459 |
|
|
// |
460 |
|
|
TString donerun = ""; |
461 |
|
|
// |
462 |
|
|
printf(" Deleting runs: \n"); |
463 |
|
|
// |
464 |
|
|
UInt_t ll = 0; |
465 |
|
|
// |
466 |
|
|
while ( (TFile*)dlist->At(ll) ){ |
467 |
|
|
donerun = (TString)(((TFile*)dlist->At(ll))->GetName()); |
468 |
|
|
gSystem->Unlink(donerun); |
469 |
|
|
printf(" Deleted file is %s \n",donerun.Data()); |
470 |
|
|
ll++; |
471 |
|
|
// |
472 |
|
|
}; |
473 |
|
|
}; |
474 |
|
|
|
475 |
|
|
void RunGlue::UpdateDB(TList *dlist){ |
476 |
|
|
// |
477 |
|
|
TSQLResult *pResult; |
478 |
|
|
TSQLRow *Row; |
479 |
|
|
stringstream myquery; |
480 |
|
|
// |
481 |
|
|
TString donerun = ""; |
482 |
|
|
// |
483 |
|
|
if ( DebugMode() ) printf(" Updating GL_RUN: \n"); |
484 |
|
|
// |
485 |
|
|
UInt_t ll = 0; |
486 |
|
|
UInt_t idl2 = 0; |
487 |
mocchiut |
1.2 |
UInt_t idr = 0; |
488 |
mocchiut |
1.1 |
// |
489 |
|
|
// |
490 |
|
|
myquery.str(""); |
491 |
mocchiut |
1.2 |
myquery << "select ID from GL_RAW where NAME='level2 files';"; |
492 |
|
|
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
493 |
|
|
// |
494 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
495 |
|
|
if ( !pResult ){ |
496 |
|
|
printf(" ERROR QUERYING ON DB!\n"); |
497 |
|
|
return; |
498 |
|
|
}; |
499 |
|
|
Row = pResult->Next(); |
500 |
|
|
if( Row == NULL ){ |
501 |
|
|
printf(" ERROR QUERYING THE DB!\n"); |
502 |
|
|
return; |
503 |
|
|
} else { |
504 |
|
|
idr = (UInt_t)atoll(Row->GetField(0)); |
505 |
|
|
}; |
506 |
|
|
// |
507 |
|
|
myquery.str(""); |
508 |
mocchiut |
1.16 |
myquery << "select ID from GL_ROOT where NAME='" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "';"; |
509 |
mocchiut |
1.1 |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
510 |
|
|
// |
511 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
512 |
|
|
if ( !pResult ){ |
513 |
|
|
printf(" ERROR WRITING ON DB!\n"); |
514 |
|
|
return; |
515 |
|
|
}; |
516 |
mocchiut |
1.16 |
Row = pResult->Next(); |
517 |
|
|
if( Row == NULL ){ |
518 |
|
|
printf(" ERROR QUERYING THE DB!\n"); |
519 |
|
|
return; |
520 |
|
|
} else { |
521 |
|
|
idl2 = (UInt_t)atoll(Row->GetField(0)); |
522 |
|
|
}; |
523 |
mocchiut |
1.1 |
myquery.str(""); |
524 |
mocchiut |
1.16 |
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
525 |
|
|
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
526 |
|
|
myquery << "update GL_ROOT set ID_RAW=" << idr << " where ID=" << idl2 << ";"; |
527 |
mocchiut |
1.1 |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
528 |
|
|
// |
529 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
530 |
|
|
if ( !pResult ){ |
531 |
|
|
printf(" ERROR WRITING ON DB!\n"); |
532 |
|
|
return; |
533 |
|
|
}; |
534 |
|
|
// |
535 |
|
|
// |
536 |
|
|
// |
537 |
|
|
UInt_t drun = 0; |
538 |
|
|
// |
539 |
|
|
while ( (TFile*)dlist->At(ll) ){ |
540 |
|
|
donerun = ""; |
541 |
|
|
donerun = (TString)((TString)(gSystem->BaseName(((TFile*)dlist->At(ll))->GetName()))).ReplaceAll(".Level2.root",12,"",0); |
542 |
|
|
drun = (UInt_t)(donerun.Atoi()); |
543 |
|
|
// |
544 |
|
|
if ( DebugMode() ) printf(" Run is %s \n",donerun.Data()); |
545 |
|
|
// |
546 |
|
|
myquery.str(""); |
547 |
|
|
myquery << "update GL_RUN set ID_ROOT_L2=" << idl2 << " where ID=" << drun << ";"; |
548 |
|
|
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
549 |
|
|
// |
550 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
551 |
|
|
if ( !pResult ){ |
552 |
|
|
printf(" ERROR WRITING ON DB!\n"); |
553 |
|
|
return; |
554 |
|
|
}; |
555 |
|
|
// |
556 |
|
|
ll++; |
557 |
|
|
// |
558 |
|
|
}; |
559 |
|
|
}; |
560 |
|
|
|
561 |
|
|
// |
562 |
|
|
// method stolen to ROOT's "hadd" and modified |
563 |
|
|
// |
564 |
|
|
void RunGlue::MergeRootfile(TList *sourcelist) { |
565 |
|
|
// |
566 |
mocchiut |
1.12 |
merged = true; |
567 |
mocchiut |
1.1 |
// |
568 |
mocchiut |
1.17 |
// if ( li ) li->Delete(); |
569 |
|
|
PamLevel2 *nli = new PamLevel2(wd,sourcelist,fDList); |
570 |
|
|
nli->SetSELLI(2); |
571 |
mocchiut |
1.1 |
// |
572 |
mocchiut |
1.12 |
Target->cd(); |
573 |
mocchiut |
1.1 |
// |
574 |
mocchiut |
1.17 |
nli->CreateCloneTrees(Target); |
575 |
mocchiut |
1.19 |
// |
576 |
mocchiut |
1.20 |
/* nli->GetCloneTree("Tracker")->SetAutoSave(900000000000000LL); |
577 |
mocchiut |
1.19 |
nli->GetCloneTree("Trigger")->SetAutoSave(900000000000000LL); |
578 |
|
|
nli->GetCloneTree("Calorimeter")->SetAutoSave(900000000000000LL); |
579 |
|
|
nli->GetCloneTree("S4")->SetAutoSave(900000000000000LL); |
580 |
|
|
nli->GetCloneTree("Anticounter")->SetAutoSave(900000000000000LL); |
581 |
|
|
nli->GetCloneTree("NeutronD")->SetAutoSave(900000000000000LL); |
582 |
|
|
nli->GetCloneTree("OrbitalInfo")->SetAutoSave(900000000000000LL); |
583 |
|
|
nli->GetCloneTree("Run")->SetAutoSave(900000000000000LL); |
584 |
mocchiut |
1.20 |
nli->GetCloneTree("ToF")->SetAutoSave(900000000000000LL);*/ |
585 |
mocchiut |
1.19 |
// |
586 |
mocchiut |
1.17 |
ULong64_t nevents = nli->GetEntries(); |
587 |
mocchiut |
1.12 |
printf(" NEVENTS %llu \n",nevents); |
588 |
|
|
for(ULong64_t iev=0; iev<nevents; iev++){ |
589 |
mocchiut |
1.17 |
nli->Clear(); |
590 |
|
|
if( nli->GetEntry(iev) ){ |
591 |
|
|
nli->FillCloneTrees(); |
592 |
mocchiut |
1.12 |
}; |
593 |
|
|
}; |
594 |
|
|
Target->cd(); |
595 |
mocchiut |
1.17 |
nli->WriteCloneTrees(); |
596 |
mocchiut |
1.13 |
printf("Written file %s \n",Target->GetName()); |
597 |
mocchiut |
1.12 |
// Target->Write(); |
598 |
mocchiut |
1.14 |
// TTree *slist = (TTree*)Target->Get("SelectionList"); |
599 |
|
|
// slist->Delete("all"); |
600 |
mocchiut |
1.20 |
if ( !nli->GetCloneTree("ProcessingInfo") ){ |
601 |
|
|
TChain *P = new TChain("ProcessingInfo"); |
602 |
|
|
// loop over files and create chains |
603 |
|
|
TIter next(sourcelist); |
604 |
|
|
TSystemFile *questo = 0; |
605 |
|
|
while ((questo = (TSystemFile*) next())) { |
606 |
|
|
TString name = questo->GetName(); |
607 |
|
|
P->Add(name); |
608 |
|
|
} |
609 |
|
|
TTree *Pclone = P->CloneTree(); |
610 |
|
|
Target->cd(); |
611 |
|
|
Pclone->Write("ProcessingInfo",TObject::kOverwrite); |
612 |
|
|
P->Delete(); |
613 |
|
|
P=0; |
614 |
|
|
} |
615 |
|
|
// |
616 |
mocchiut |
1.12 |
Target->Close(); |
617 |
|
|
|
618 |
|
|
// // |
619 |
|
|
// TDirectory *target = Target; |
620 |
|
|
// // |
621 |
|
|
// if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath()); |
622 |
|
|
// // |
623 |
|
|
// TString path( (char*)strstr( target->GetPath(), ":" ) ); |
624 |
|
|
// path.Remove(0,2); |
625 |
|
|
// // |
626 |
|
|
// TDirectory *first_source = (TDirectory*)sourcelist->First(); |
627 |
|
|
// THashList allNames; |
628 |
|
|
// // |
629 |
|
|
// while ( first_source ){ |
630 |
|
|
// // |
631 |
|
|
// TDirectory *current_sourcedir = first_source->GetDirectory(path); |
632 |
|
|
// // |
633 |
|
|
// if ( !current_sourcedir ){ |
634 |
|
|
// first_source = (TDirectory*)sourcelist->After(first_source); |
635 |
|
|
// continue; |
636 |
|
|
// } |
637 |
|
|
// // |
638 |
|
|
// // loop over all keys in this directory |
639 |
|
|
// // |
640 |
|
|
// TChain *globChain = 0; |
641 |
|
|
// TIter nextkey( current_sourcedir->GetListOfKeys() ); |
642 |
|
|
// TKey *key = 0; |
643 |
|
|
// TKey *oldkey = 0; |
644 |
|
|
// TH1::AddDirectory(kFALSE); // gain time, do not add the objects in the list in memory |
645 |
|
|
// // |
646 |
|
|
// while ( (key = (TKey*)nextkey()) ) { |
647 |
|
|
// // |
648 |
|
|
// // printf(" target ls \n"); |
649 |
|
|
// // Target->ls(); |
650 |
|
|
// // |
651 |
|
|
// if ( current_sourcedir == target ) break; |
652 |
|
|
// // |
653 |
|
|
// if ( oldkey && !strcmp(oldkey->GetName(),key->GetName()) ) continue; //keep only the highest cycle number for each key |
654 |
|
|
// // |
655 |
|
|
// if ( allNames.FindObject(key->GetName()) ) continue; |
656 |
|
|
// // |
657 |
|
|
// if ( DebugMode() ) printf(" Key name is -%s- \n",key->GetName()); |
658 |
|
|
// // |
659 |
|
|
// // |
660 |
|
|
// // |
661 |
|
|
// if ( !strcmp(key->GetName(),"Tracker") && !li->IsTRK2() && !li->IsTRK1() && !li->IsTRKh() ) continue; |
662 |
|
|
// // |
663 |
|
|
// if ( !strcmp(key->GetName(),"Calorimeter") && !li->IsCAL2() && !li->IsCAL1() ) continue; |
664 |
|
|
// // |
665 |
|
|
// if ( !strcmp(key->GetName(),"ToF") && !li->IsTOF() ) continue; |
666 |
|
|
// // |
667 |
|
|
// if ( !strcmp(key->GetName(),"Trigger") && !li->IsTRG() ) continue; |
668 |
|
|
// // |
669 |
|
|
// if ( !strcmp(key->GetName(),"Anticounter") && !li->IsAC() ) continue; |
670 |
|
|
// // |
671 |
|
|
// if ( !strcmp(key->GetName(),"S4") && !li->IsS4() ) continue; |
672 |
|
|
// // |
673 |
|
|
// if ( !strcmp(key->GetName(),"NeutronD") && !li->IsND() ) continue; |
674 |
|
|
// // |
675 |
|
|
// if ( !strcmp(key->GetName(),"OrbitalInfo") && !li->IsORB() ) continue; |
676 |
|
|
// // |
677 |
|
|
// if ( !strcmp(key->GetName(),"Run") && !li->IsRUN() ) continue; |
678 |
|
|
// // |
679 |
|
|
// if ( strcmp(key->GetName(),"Calorimeter") && strcmp(key->GetName(),"Tracker") && strcmp(key->GetName(),"ToF") && strcmp(key->GetName(),"Trigger") && strcmp(key->GetName(),"Anticounter") && strcmp(key->GetName(),"S4") && strcmp(key->GetName(),"NeutronD") && strcmp(key->GetName(),"OrbitalInfo") && strcmp(key->GetName(),"Run") && strcmp(key->GetName(),"ProcessID0") ){ |
680 |
|
|
// if ( DebugMode() ) printf(" ERROR UNKNOWN KEY %s !\n",key->GetName()); |
681 |
|
|
// continue; |
682 |
|
|
// }; |
683 |
|
|
// // |
684 |
|
|
// printf(" 1 \n"); |
685 |
|
|
// allNames.Add(new TObjString(key->GetName())); |
686 |
|
|
// printf(" 2 \n"); |
687 |
|
|
// // |
688 |
|
|
// // read object from first source file |
689 |
|
|
// // |
690 |
|
|
// current_sourcedir->cd(); |
691 |
|
|
// TObject *obj = key->ReadObj(); |
692 |
|
|
// printf(" 3 \n"); |
693 |
|
|
// // |
694 |
|
|
// if ( obj->IsA()->InheritsFrom("TTree") ){ |
695 |
|
|
// // |
696 |
|
|
// // loop over all source files create a chain of Trees "globChain" |
697 |
|
|
// // |
698 |
|
|
// TString obj_name; |
699 |
|
|
// printf(" 4 \n"); |
700 |
|
|
// // |
701 |
|
|
// if ( path.Length() ) { |
702 |
|
|
// obj_name = path + "/" + obj->GetName(); |
703 |
|
|
// } else { |
704 |
|
|
// obj_name = obj->GetName(); |
705 |
|
|
// }; |
706 |
|
|
// // |
707 |
|
|
// globChain = new TChain(obj_name); |
708 |
|
|
// // |
709 |
|
|
// globChain->SetCacheSize(0); |
710 |
|
|
// // |
711 |
|
|
// printf(" 5 \n"); |
712 |
|
|
// globChain->Add(first_source->GetName()); |
713 |
|
|
// printf(" 6 \n"); |
714 |
|
|
// // |
715 |
|
|
// TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
716 |
|
|
// // |
717 |
|
|
// while ( nextsource ) { |
718 |
|
|
// // |
719 |
|
|
// //do not add to the list a file that does not contain this Tree |
720 |
|
|
// // |
721 |
|
|
// printf(" 7 \n"); |
722 |
|
|
// TFile *curf = TFile::Open(nextsource->GetName()); |
723 |
|
|
// // |
724 |
|
|
// if ( curf ) { |
725 |
|
|
// // |
726 |
|
|
// Bool_t mustAdd = kFALSE; |
727 |
|
|
// // |
728 |
|
|
// if (curf->FindKey(obj_name)) { |
729 |
|
|
// // |
730 |
|
|
// mustAdd = kTRUE; |
731 |
|
|
// // |
732 |
|
|
// } else { |
733 |
|
|
// // |
734 |
|
|
// //we could be more clever here. No need to import the object |
735 |
|
|
// //we are missing a function in TDirectory |
736 |
|
|
// // |
737 |
|
|
// TObject *aobj = curf->Get(obj_name); |
738 |
|
|
// // |
739 |
|
|
// if ( aobj ){ |
740 |
|
|
// mustAdd = kTRUE; |
741 |
|
|
// delete aobj; |
742 |
|
|
// }; |
743 |
|
|
// }; |
744 |
|
|
// if (mustAdd) { |
745 |
|
|
// printf(" 8 \n"); |
746 |
|
|
// globChain->Add(nextsource->GetName()); |
747 |
|
|
// printf(" 9 \n"); |
748 |
|
|
// }; |
749 |
|
|
// }; |
750 |
|
|
// delete curf; |
751 |
|
|
// nextsource = (TFile*)sourcelist->After(nextsource); |
752 |
|
|
// }; |
753 |
|
|
// // |
754 |
|
|
// printf(" 10 \n"); |
755 |
|
|
// delete nextsource; |
756 |
|
|
// printf(" 11 \n"); |
757 |
|
|
// // |
758 |
|
|
// } else { |
759 |
|
|
// // |
760 |
|
|
// // object is of no type that we know or can handle |
761 |
|
|
// // |
762 |
|
|
// if ( DebugMode() ) cout << "Unknown object type, name: " |
763 |
|
|
// << obj->GetName() << " title: " << obj->GetTitle() << endl; |
764 |
|
|
// }; |
765 |
|
|
// // |
766 |
|
|
// // now write the merged histogram (which is "in" obj) to the target file |
767 |
|
|
// // note that this will just store obj in the current directory level, |
768 |
|
|
// // which is not persistent until the complete directory itself is stored |
769 |
|
|
// // by "target->Write()" below |
770 |
|
|
// // |
771 |
|
|
// printf(" 12 \n"); |
772 |
|
|
// if ( obj ){ |
773 |
|
|
// // |
774 |
|
|
// target->cd(); |
775 |
|
|
// // |
776 |
|
|
// if( obj->IsA()->InheritsFrom("TTree") ) { |
777 |
|
|
// // |
778 |
|
|
// Long64_t nfiles = 0; |
779 |
|
|
// if ( fastMethod ){ |
780 |
|
|
// // globChain->Merge(target->GetFile(),0,"C keep fast"); |
781 |
|
|
// nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep fast"); |
782 |
|
|
// } else { |
783 |
|
|
// //globChain->Merge(target->GetFile(),0,"C keep"); |
784 |
|
|
// printf(" 13 %llu \n",globChain->GetEntries()); |
785 |
|
|
// nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep"); |
786 |
|
|
// printf(" 14 \n"); |
787 |
|
|
// }; |
788 |
|
|
// // |
789 |
|
|
// merged = true; |
790 |
|
|
// // |
791 |
|
|
// if ( DebugMode() ){ |
792 |
|
|
// printf(" Merged %i files\n",(int)nfiles); |
793 |
|
|
// globChain->ls(); |
794 |
|
|
// }; |
795 |
|
|
// // |
796 |
|
|
// delete globChain; |
797 |
|
|
// // return; |
798 |
|
|
// // |
799 |
|
|
// } else { |
800 |
|
|
// // |
801 |
|
|
// // obj->Write( key->GetName() ); // <================================================================================== |
802 |
|
|
// // |
803 |
|
|
// }; |
804 |
|
|
// }; |
805 |
|
|
// delete obj; |
806 |
|
|
// oldkey = key; |
807 |
|
|
// }; |
808 |
|
|
// // |
809 |
|
|
// first_source = (TDirectory*)sourcelist->After(first_source); |
810 |
|
|
// // |
811 |
|
|
// }; |
812 |
|
|
// // save modifications to target file |
813 |
|
|
// // |
814 |
|
|
// target->SaveSelf(kTRUE); |
815 |
|
|
// // |
816 |
mocchiut |
1.5 |
}; |
817 |
|
|
|
818 |
|
|
|
819 |
mocchiut |
1.14 |
// Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){ |
820 |
|
|
// // We must have been passed a file, we will use it |
821 |
|
|
// // later to reset the compression level of the branches. |
822 |
|
|
// if (!file) { |
823 |
|
|
// // FIXME: We need an error message here. |
824 |
|
|
// printf(" 19 \n"); |
825 |
|
|
// return 0; |
826 |
|
|
// } |
827 |
|
|
// printf(" 20 \n"); |
828 |
|
|
|
829 |
|
|
// // Options |
830 |
|
|
// Bool_t fastClone = kFALSE; |
831 |
|
|
// TString opt = option; |
832 |
|
|
// opt.ToLower(); |
833 |
|
|
// if (opt.Contains("fast")) { |
834 |
|
|
// fastClone = kTRUE; |
835 |
|
|
// printf(" 21 \n"); |
836 |
|
|
// } |
837 |
|
|
// // The chain tree must have a list of branches |
838 |
|
|
// // because we may try to change their basket |
839 |
|
|
// // size later. |
840 |
|
|
// TObjArray* lbranches = mychain->GetListOfBranches(); |
841 |
|
|
// if (!lbranches) { |
842 |
|
|
// // FIXME: We need an error message here. |
843 |
|
|
// printf(" 22 \n"); |
844 |
|
|
// return 0; |
845 |
|
|
// } |
846 |
|
|
|
847 |
|
|
// // file->cd(); |
848 |
|
|
// // The chain must have a current tree because |
849 |
|
|
// // that is the one we will clone. |
850 |
|
|
// // if (!fTree) { |
851 |
|
|
// // -- LoadTree() has not yet been called, no current tree. |
852 |
|
|
// // FIXME: We need an error message here. |
853 |
|
|
// // return 0; |
854 |
|
|
// // } |
855 |
|
|
|
856 |
|
|
// // Copy the chain's current tree without |
857 |
|
|
// // copying any entries, we will do that later. |
858 |
|
|
// printf(" 23 \n"); |
859 |
|
|
// TTree* newTree = mychain->CloneTree(0); |
860 |
|
|
// if (!newTree) { |
861 |
|
|
// // FIXME: We need an error message here. |
862 |
|
|
// printf(" 24 \n"); |
863 |
|
|
// return 0; |
864 |
|
|
// } |
865 |
|
|
// printf(" 25 \n"); |
866 |
|
|
|
867 |
|
|
|
868 |
|
|
// // Strip out the (potential) directory name. |
869 |
|
|
// // FIXME: The merged chain may or may not have the |
870 |
|
|
// // same name as the original chain. This is |
871 |
|
|
// // bad because the chain name determines the |
872 |
|
|
// // names of the trees in the chain by default. |
873 |
|
|
// printf(" 26 \n"); |
874 |
|
|
// newTree->SetName(gSystem->BaseName(mychain->GetName())); |
875 |
|
|
// printf(" 27 \n"); |
876 |
|
|
|
877 |
|
|
// // FIXME: Why do we do this? |
878 |
|
|
// // newTree->SetAutoSave(-1); |
879 |
|
|
// newTree->SetAutoSave(900000000000000LL); |
880 |
|
|
|
881 |
|
|
// printf(" 28 \n"); |
882 |
|
|
// // Circularity is incompatible with merging, it may |
883 |
|
|
// // force us to throw away entries, which is not what |
884 |
|
|
// // we are supposed to do. |
885 |
|
|
// newTree->SetCircular(0); |
886 |
|
|
|
887 |
|
|
// // Reset the compression level of the branches. |
888 |
|
|
// if (opt.Contains("c")) { |
889 |
|
|
// TBranch* branch = 0; |
890 |
|
|
// TIter nextb(newTree->GetListOfBranches()); |
891 |
|
|
// while ((branch = (TBranch*) nextb())) { |
892 |
|
|
// printf(" 29 \n"); |
893 |
|
|
// branch->SetCompressionLevel(file->GetCompressionLevel()); |
894 |
|
|
// } |
895 |
|
|
// } |
896 |
|
|
|
897 |
|
|
// printf(" 30 \n"); |
898 |
|
|
// // Reset the basket size of the branches. |
899 |
|
|
// if (basketsize > 1000) { |
900 |
|
|
// TBranch* branch = 0; |
901 |
|
|
// TIter nextb(newTree->GetListOfBranches()); |
902 |
|
|
// while ((branch = (TBranch*) nextb())) { |
903 |
|
|
// printf(" 31 \n"); |
904 |
|
|
// branch->SetBasketSize(basketsize); |
905 |
|
|
// } |
906 |
|
|
// } |
907 |
|
|
|
908 |
|
|
// printf(" 32 \n"); |
909 |
|
|
// Long64_t nentries = mychain->GetEntriesFast(); |
910 |
|
|
// //Long64_t nentries = mychain->GetEntries(); |
911 |
|
|
|
912 |
|
|
// // Copy the entries. |
913 |
|
|
// if (fastClone) { |
914 |
|
|
// // For each tree in the chain. |
915 |
|
|
// for (Long64_t i = 0; i < nentries; i += mychain->GetTree()->GetEntries()) { |
916 |
|
|
// if (mychain->LoadTree(i) < 0) { |
917 |
|
|
// break; |
918 |
|
|
// } |
919 |
|
|
// TTreeCloner cloner(mychain->GetTree(), newTree, option); |
920 |
|
|
// if (cloner.IsValid()) { |
921 |
|
|
// newTree->SetEntries(newTree->GetEntries() + mychain->GetTree()->GetEntries()); |
922 |
|
|
// cloner.Exec(); |
923 |
|
|
// } else { |
924 |
|
|
// if (mychain->GetFile()) { |
925 |
|
|
// printf("Merge Skipped file %s\n", mychain->GetFile()->GetName()); |
926 |
|
|
// // } else { |
927 |
|
|
// // Warning("Merge", "Skipped file number %d\n", fTreeNumber); |
928 |
|
|
// } |
929 |
|
|
// } |
930 |
|
|
// } |
931 |
|
|
// } else { |
932 |
|
|
// printf(" 33 %llu \n",nentries); |
933 |
|
|
// mychain->Print(); |
934 |
|
|
// for (Long64_t i = 0; i < nentries; i++) { |
935 |
|
|
// printf(" i %llu \n",i); |
936 |
|
|
// // for (Long64_t i = 0; i < 1; i++) { |
937 |
|
|
// if (mychain->GetEntry(i) <= 0) { |
938 |
|
|
// break; |
939 |
|
|
// } |
940 |
|
|
// newTree->Fill(); |
941 |
|
|
// } |
942 |
|
|
// printf(" 34 \n"); |
943 |
|
|
// } |
944 |
|
|
|
945 |
|
|
// // Write the new tree header. |
946 |
|
|
// printf(" 35 \n"); |
947 |
|
|
// newTree->Write(); |
948 |
|
|
|
949 |
|
|
// printf(" 36 \n"); |
950 |
|
|
// // Get our return value. |
951 |
|
|
// Int_t nfiles = newTree->GetFileNumber() + 1; |
952 |
|
|
|
953 |
|
|
// // Close and delete the current file of the new tree. |
954 |
|
|
// if (!opt.Contains("keep")) { |
955 |
|
|
// // FIXME: What happens to fDirectory in newTree here? |
956 |
|
|
// delete newTree->GetCurrentFile(); |
957 |
|
|
// } |
958 |
|
|
// return nfiles; |
959 |
|
|
// } |