Ignore:
Timestamp:
04/24/03 11:58:54 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r1664 r2002  
    208208Bool_t MWriteRootFile::GetContainer(MParList *pList)
    209209{
     210    //
     211    // loop over all branches which are 'marked' as branches to get written.
     212    //
    210213    MRootFileBranch *entry;
    211214
    212     //
    213     // loop over all branches which are 'marked' as branches to get written.
    214     //
    215215    TIter Next(&fBranches);
    216216    while ((entry=(MRootFileBranch*)Next()))
     
    274274            fTrees.AddLast(tree);
    275275
     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
    276282            gDirectory = save;
    277283
     
    280286
    281287        //
     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        //
    282297        // 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)
    284298        // Add a pointer to the entry in the tree list to this branch-entry
    285299        //
    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);
    293301
    294302        //
     
    315323        branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
    316324
    317         *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl;
    318 
    319325        //
    320326        // If the branch couldn't be created we have a problem.
     
    325331            return kFALSE;
    326332        }
     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;
    327340    }
    328341    return kTRUE;
     
    333346// Checks all given containers (branch entries) for the write flag.
    334347// 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 corresponding
     348// All Trees which are marked to be filled are filled with all their
    336349// 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!
    337355// Be carefull: If only one container (corresponding to a branch) of a tree
    338356// has the write flag, all containers in this tree are filled!
     
    362380        // the corresponding tree entry.
    363381        //
    364         b->GetTree()->SetBit(kFillTree);
     382        if (b->TestBit(kIsNewTree))
     383            b->GetTree()->SetBit(kFillTree);
     384        else
     385            b->GetBranch()->Fill();
    365386    }
    366387
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h

    r1664 r2002  
    5757    void SetContainer(MParContainer *cont) { fContainer = cont; }
    5858    void SetTree(TTree *tree)              { fTree = tree; }
     59    void SetBranch(TBranch *branch)        { fBranch = branch; }
    5960
    6061    ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
     
    6970    TObjArray fTrees;     //!
    7071
     72    //UInt_t fNumEvents; //! Number of events written in a run
     73
    7174    void        CheckAndWrite() const;
    7275    Bool_t      IsFileOpen() const;
     
    7578
    7679    void StreamPrimitive(ofstream &out) const;
     80    //Bool_t ReInit(MParList *pList);
     81
     82    enum {
     83        kIsNewTree = BIT(15)
     84    };
    7785
    7886public:
Note: See TracChangeset for help on using the changeset viewer.