14 |
|
ClassImp(mithep::TreeWriter) |
15 |
|
|
16 |
|
//__________________________________________________________________________________________________ |
17 |
< |
TreeWriter::TreeWriter(const char *tname, Bool_t doreset) |
18 |
< |
: TNamed(tname,Form("%s written by mithep::TreeWriter", tname)), |
19 |
< |
fBaseURL("."), |
20 |
< |
fPrefix("mithep"), |
21 |
< |
fFileNumber(0), |
22 |
< |
fCompressLevel(9), |
23 |
< |
fDefBrSize(64*1024), |
24 |
< |
fDefSL(99), |
25 |
< |
fMaxSize((Long64_t)(0.99 * TTree::GetMaxTreeSize())), |
26 |
< |
fkMinFreeSpace(1024*1024), |
27 |
< |
fkMinAvgSize(10*1024), |
28 |
< |
fEvtObjNum(-1), |
29 |
< |
fIsInit(kFALSE), |
30 |
< |
fDoObjNumReset(doreset), |
31 |
< |
fFile(0), |
32 |
< |
fTrees(0) |
17 |
> |
TreeWriter::TreeWriter(const char *tname, Bool_t doreset) : |
18 |
> |
TNamed(tname,Form("%s written by mithep::TreeWriter", tname)), |
19 |
> |
fBaseURL("."), |
20 |
> |
fPrefix("mithep"), |
21 |
> |
fFileNumber(0), |
22 |
> |
fCompressLevel(9), |
23 |
> |
fDefBrSize(64*1024), |
24 |
> |
fDefSL(99), |
25 |
> |
fMaxSize((Long64_t)(0.99 * TTree::GetMaxTreeSize())), |
26 |
> |
fkMinFreeSpace(1024*1024), |
27 |
> |
fkMinAvgSize(10*1024), |
28 |
> |
fEvtObjNum(-1), |
29 |
> |
fIsInit(kFALSE), |
30 |
> |
fDoObjNumReset(doreset), |
31 |
> |
fFile(0), |
32 |
> |
fTrees(0) |
33 |
|
{ |
34 |
|
// Constructor. |
35 |
|
|
179 |
|
// present tree. |
180 |
|
|
181 |
|
MyTree *tree = dynamic_cast<MyTree*>(fTrees.FindObject(tn)); |
182 |
< |
if (tree) return tree; |
182 |
> |
if (tree) |
183 |
> |
return tree; |
184 |
|
|
185 |
|
TDirectory::TContext context(fFile); |
186 |
|
tree = new MyTree(tn, tn); |
240 |
|
// Dereference void* pointer into TObject* pointer |
241 |
|
|
242 |
|
TObject *tobj = dynamic_cast<TObject*>(*(TObject**)obj); |
243 |
< |
if(tobj==0) { |
243 |
> |
if (tobj==0) { |
244 |
|
Fatal("ClassName", "Given void* ptr can not be dereferenced into TObject*"); |
245 |
|
} |
246 |
|
return tobj->ClassName(); |
261 |
|
Int_t r = 0; |
262 |
|
for (Int_t i=0;i<fTrees.GetEntries();++i) { |
263 |
|
MyTree *mt = static_cast<MyTree*>(fTrees.At(i)); |
264 |
< |
if (mt->GetAutoFill()==0) continue; |
264 |
> |
if (mt->GetAutoFill()==0) |
265 |
> |
continue; |
266 |
|
r += mt->Fill(); |
267 |
|
} |
268 |
|
|
284 |
|
//------------------------------------------------------------------------------------------------- |
285 |
|
Long64_t TreeWriter::GetEntries(const char *tn) const |
286 |
|
{ |
287 |
< |
// |
287 |
> |
// Return entries of tree with given name. If no tree is given, return sum of entries |
288 |
> |
// of all trees. |
289 |
|
|
290 |
|
if (fTrees.GetEntries()==0) return -1; |
291 |
|
|
292 |
|
if (tn) { |
293 |
|
const TTree *mt=GetTree(tn); |
294 |
< |
if (mt) return mt->GetEntries(); |
295 |
< |
else return -1; |
294 |
> |
if (mt) |
295 |
> |
return mt->GetEntries(); |
296 |
> |
else |
297 |
> |
return -1; |
298 |
|
} |
299 |
|
|
300 |
|
Long64_t ret = 0; |
439 |
|
{ |
440 |
|
// Set auto-fill mode of tree with given name. |
441 |
|
|
442 |
< |
if (fTrees.GetEntries()==0) return; |
442 |
> |
if (fTrees.GetEntries()==0) |
443 |
> |
return; |
444 |
|
|
445 |
|
MyTree *mt = GetMyTree(tn); |
446 |
< |
if (!mt) return; |
446 |
> |
if (!mt) |
447 |
> |
return; |
448 |
|
|
449 |
|
mt->SetAutoFill(b); |
450 |
|
} |
451 |
|
|
452 |
+ |
|
453 |
+ |
//------------------------------------------------------------------------------------------------- |
454 |
+ |
void TreeWriter::SetMaxSize(Long64_t s) |
455 |
+ |
{ |
456 |
+ |
// Set maximum file size. Check if this exceeds the ROOT file size and if, |
457 |
+ |
// print a warning and adjust it. |
458 |
+ |
|
459 |
+ |
if (s>=(Long64_t)(0.99 * TTree::GetMaxTreeSize())) { |
460 |
+ |
Long64_t news = (Long64_t)(s/0.99); |
461 |
+ |
Warning("SetMaxSize", "Maximum tree size increased from %lld to %lld", |
462 |
+ |
TTree::GetMaxTreeSize(), news); |
463 |
+ |
TTree::SetMaxTreeSize(news); |
464 |
+ |
} |
465 |
+ |
|
466 |
+ |
fMaxSize=s; |
467 |
+ |
} |
468 |
+ |
|
469 |
|
//__________________________________________________________________________________________________ |
470 |
|
void TreeWriter::StoreObject(const TObject *obj) |
471 |
|
{ |