Changeset 2002 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 04/24/03 11:58:54 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r1664 r2002 208 208 Bool_t MWriteRootFile::GetContainer(MParList *pList) 209 209 { 210 // 211 // loop over all branches which are 'marked' as branches to get written. 212 // 210 213 MRootFileBranch *entry; 211 214 212 //213 // loop over all branches which are 'marked' as branches to get written.214 //215 215 TIter Next(&fBranches); 216 216 while ((entry=(MRootFileBranch*)Next())) … … 274 274 fTrees.AddLast(tree); 275 275 276 // 277 // If the tree does not already exist in the file mark this 278 // tree as a branch created by MWriteRootFile 279 // 280 entry->SetBit(kIsNewTree); 281 276 282 gDirectory = save; 277 283 … … 280 286 281 287 // 288 // In case the file is opened as 'UPDATE' the tree may still not 289 // be in the list. Because it neither was created previously, 290 // nor this time, so the corresponding entries is marked as a 291 // single branch to be filled. --> Add it to the list of trees. 292 // 293 if (!fTrees.FindObject(tree)) 294 fTrees.AddLast(tree); 295 296 // 282 297 // Now we have a valid tree. Search the list of trees for this tree 283 // (either it is already there, or we created and add it previously)284 298 // Add a pointer to the entry in the tree list to this branch-entry 285 299 // 286 TObject *obj; 287 TIter NextTree(&fTrees); 288 while ((obj=NextTree())) 289 { 290 if (obj == tree) 291 entry->SetTree((TTree*)obj); 292 } 300 entry->SetTree(tree); 293 301 294 302 // … … 315 323 branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress()); 316 324 317 *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl;318 319 325 // 320 326 // If the branch couldn't be created we have a problem. … … 325 331 return kFALSE; 326 332 } 333 334 // 335 // Tell the entry also which branch belongs to it (this is necessary 336 // for branches belonging to already existing tree, UPDATE-mode) 337 // 338 entry->SetBranch(branch); 339 *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl; 327 340 } 328 341 return kTRUE; … … 333 346 // Checks all given containers (branch entries) for the write flag. 334 347 // If the write flag is set the corresponding Tree is marked to get filled. 335 // All Trees which are marked to be filled are filled with the corresponding348 // All Trees which are marked to be filled are filled with all their 336 349 // branches. 350 // In case of a file opened in 'UPDATE' mode, single branches can be 351 // filled, too. WARNING - for the moment there is no check whether 352 // you filled the correct number of events into the branch, so that 353 // each of the other branches in the tree has the correct corresponding 354 // number of new entries in the new branch! 337 355 // Be carefull: If only one container (corresponding to a branch) of a tree 338 356 // has the write flag, all containers in this tree are filled! … … 362 380 // the corresponding tree entry. 363 381 // 364 b->GetTree()->SetBit(kFillTree); 382 if (b->TestBit(kIsNewTree)) 383 b->GetTree()->SetBit(kFillTree); 384 else 385 b->GetBranch()->Fill(); 365 386 } 366 387 -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
r1664 r2002 57 57 void SetContainer(MParContainer *cont) { fContainer = cont; } 58 58 void SetTree(TTree *tree) { fTree = tree; } 59 void SetBranch(TBranch *branch) { fBranch = branch; } 59 60 60 61 ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations … … 69 70 TObjArray fTrees; //! 70 71 72 //UInt_t fNumEvents; //! Number of events written in a run 73 71 74 void CheckAndWrite() const; 72 75 Bool_t IsFileOpen() const; … … 75 78 76 79 void StreamPrimitive(ofstream &out) const; 80 //Bool_t ReInit(MParList *pList); 81 82 enum { 83 kIsNewTree = BIT(15) 84 }; 77 85 78 86 public:
Note:
See TracChangeset
for help on using the changeset viewer.