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.9 by loizides, Thu Jul 3 08:22:18 2008 UTC vs.
Revision 1.11 by loizides, Sat Sep 27 06:14:05 2008 UTC

# Line 5 | Line 5
5   #include <TObject.h>
6   #include <TSystem.h>
7   #include <TProcessID.h>
8 + #include <TBranchRef.h>
9   #include "MitAna/DataUtil/interface/Debug.h"
10  
11   using namespace mithep;
# Line 228 | Line 229 | void TreeWriter::CloseFile()
229    for (Int_t i=0;i<fTrees.GetEntries();++i) {
230      MyTree *mt = static_cast<MyTree*>(fTrees.At(i));
231      mt->Write(mt->GetName(),TObject::kOverwrite);
232 <    mt->Reset();
232 >    // Backup and restore list of branch pointers from TRefTable (needed for autoloading)
233 >    if (mt->GetBranchRef()) {
234 >      TObjArray *parents = mt->GetBranchRef()->GetRefTable()->GetParents();
235 >      TObjArray parentsBak(*parents);
236 >      mt->Reset();
237 >      for (Int_t j=0; j<parentsBak.GetEntries(); ++j)
238 >        parents->Add(parentsBak.At(j));
239 >    }
240 >    else
241 >      mt->Reset();
242      mt->SetDirectory(0);  
243    }
244  
# Line 279 | Line 289 | Bool_t TreeWriter::EndEvent(Bool_t dores
289      if (fEvtObjNum<0) {
290        Error("EndEvent", "Object counter is zero. Did you call BeginEvent(kTRUE)?");
291      } else {
292 <      // Reset the TRef table. keep it from growing with each event (see doc)
292 >      // Reset the TRef table. Keep it from growing with each event (see doc)
293        TProcessID::SetObjectCount(fEvtObjNum);
294      }
295    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines