Ignore:
Timestamp:
05/20/03 10:19:41 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
4 edited

Legend:

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

    r1965 r2123  
    142142    }
    143143
    144     *fLog << inf << "MReadMarsFile: Switching to #" << GetFileIndex();
    145     *fLog << " '" << GetFileName() << "' (before event #";
    146     *fLog << GetNumEntry()-1 << ")" << endl;
     144    if (!MReadTree::Notify())
     145        return kFALSE;
    147146
    148147    if (fDisplay)
  • 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    //
  • trunk/MagicSoft/Mars/mfileio/MReadTree.h

    r2117 r2123  
    3333    void EnableBranches(MParList *plist);
    3434    void EnableBranchChoosing();
     35
     36    Bool_t CheckBranchSize();
    3537
    3638    virtual void SetReadyToSave(Bool_t flag=kTRUE);
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r2120 r2123  
    140140void MWriteRootFile::Print(Option_t *) const
    141141{
    142     *fLog << all << underline << "File: " << GetFileName() << ":" << endl;
     142    *fLog << all << underline << "File: " << GetFileName() << endl;
     143
     144    if (fTrees.GetEntries()==0)
     145    {
     146        *fLog << " No contents." << endl;
     147        return;
     148    }
    143149
    144150    TTree *t = NULL;
    145151    TIter Next(&fTrees);
    146152    while ((t=(TTree*)Next()))
    147         *fLog << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
     153        *fLog << " " << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
    148154    *fLog << endl;
    149155}
Note: See TracChangeset for help on using the changeset viewer.