ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataUtil/src/TreeWriter.cc
(Generate patch)

Comparing UserCode/MitAna/DataUtil/src/TreeWriter.cc (file contents):
Revision 1.3 by loizides, Thu Jun 5 07:55:55 2008 UTC vs.
Revision 1.6 by loizides, Tue Jun 24 14:05:03 2008 UTC

# Line 14 | Line 14 | using namespace mithep;
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  
# Line 179 | Line 179 | MyTree *TreeWriter::AddOrGetMyTree(const
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);
# Line 239 | Line 240 | const char *TreeWriter::CName(void *obj)
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();
# Line 260 | Line 261 | Bool_t TreeWriter::EndEvent(Bool_t dores
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  
# Line 282 | Line 284 | Bool_t TreeWriter::EndEvent(Bool_t dores
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;
# Line 434 | Line 439 | void TreeWriter::SetAutoFill(const char
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   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines