Ignore:
Timestamp:
05/20/03 10:19:41 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2120 r2123  
    138138    TChainElement *element = NULL;
    139139    while ((element=(TChainElement*)Next()))
    140         delete (MParContainer**)element->GetBaddress();
     140        if (element->GetBaddress())
     141            delete (MParContainer**)element->GetBaddress();
    141142
    142143    //
     
    155156// --------------------------------------------------------------------------
    156157//
     158// This check whether all branches in the tree have the same size. If
     159// this is not the case the events in the different branches cannot
     160// be ordered correctly.
     161//
     162Bool_t MReadTree::CheckBranchSize()
     163{
     164    TArrayI entries(fChain->GetStatus()->GetSize());
     165    Int_t num=0;
     166
     167    // Loop over all branches which have a corresponding container
     168    TIter Next(fChain->GetStatus());
     169
     170    TChainElement *element = NULL;
     171    while ((element=(TChainElement*)Next()))
     172    {
     173        // Get branch name and find pointer to corresponding branch
     174        const TString name = element->GetName();
     175        const TBranch *b = fChain->FindBranch(name);
     176
     177        // Skip element without corresponding branches (like "*")
     178        if (!b)
     179            continue;
     180
     181        entries[num++] = (Int_t)b->GetEntries();
     182    }
     183
     184    // Check the number of entries of the branches pair-wise
     185    for (int i=0; i<num; i++)
     186        for (int j=i; j<num; j++)
     187        {
     188            if (entries[i]==entries[j])
     189                continue;
     190
     191            *fLog << err << "ERROR - File corrupttion detected:" << endl;
     192            *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
     193            *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
     194            *fLog << "  at least two branches in the same tree (" << fChain->GetName() << ") have different" << endl;
     195            *fLog << "  number of entries. Sorry, but this file (" << GetFileName() << ")" << endl;
     196            *fLog << "  is unusable." << endl;
     197            return kFALSE;
     198        }
     199
     200    return kTRUE;
     201}
     202
     203// --------------------------------------------------------------------------
     204//
    157205//  If the owner flag is set all TObjects which are scheduled via
    158206//  AddNotify are deleted by the destructor of MReadTree
     
    171219Bool_t MReadTree::Notify()
    172220{
    173     *fLog << inf << GetDescriptor() << ": Notify '" << fChain->GetName();
    174     *fLog << "' (before processing event #" << GetNumEntry()-1 << ")" << endl;
     221    //
     222    // Do a consistency check for all branches
     223    //
     224    if (!CheckBranchSize())
     225        return kFALSE;
     226
     227    *fLog << inf << GetDescriptor() << ": Switching to #" << GetFileIndex();
     228    *fLog << " '" << GetFileName() << "' (before event #";
     229    *fLog << GetNumEntry()-1 << ")" << endl;
    175230
    176231    //fNotify->Notify();
     
    542597
    543598    Int_t num=0;
     599
    544600    //
    545601    // loop over all tasks for processing
     
    622678
    623679    //
     680    // Do a consistency check for all branches
     681    //
     682//    if (!CheckBranchSize())
     683//        return kFALSE;
     684
     685    //
    624686    // If auto enabling scheme isn't disabled, do auto enabling
    625687    //
Note: See TracChangeset for help on using the changeset viewer.