Ignore:
Timestamp:
10/30/02 17:09:31 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r1527 r1568  
    9898MReadTree::MReadTree(const char *tname, const char *fname,
    9999                     const char *name, const char *title)
    100     : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
     100    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
    101101{
    102102    fName  = name  ? name  : "MReadTree";
     
    119119
    120120    if (fname)
    121         fChain->Add(fname);
     121        if (fChain->Add(fname)>0)
     122            SetBit(kChainWasChanged);
    122123}
    123124
     
    198199    // returns the number of file which were added
    199200    //
    200     return fChain->Add(fname);
     201
     202    const Int_t numfiles = fChain->Add(fname);
     203
     204    if (numfiles>0)
     205        SetBit(kChainWasChanged);
     206
     207    return numfiles;
    201208}
    202209
     
    215222    while ((obj=Next()))
    216223        rc += AddFile(obj->GetTitle());
     224
     225    if (rc>0)
     226        SetBit(kChainWasChanged);
    217227
    218228    return rc;
     
    391401    }
    392402*/
     403}
     404
     405// --------------------------------------------------------------------------
     406//
     407//  If the chain has been changed (by calling AddFile or using a file
     408//  in the constructors argument) the number of entries is newly
     409//  calculated from the files in the chain - this may take a while.
     410//  The number of entries is returned.
     411//
     412UInt_t MReadTree::GetEntries()
     413{
     414    if (TestBit(kChainWasChanged))
     415    {
     416        fNumEntries = (UInt_t)fChain->GetEntries();
     417        ResetBit(kChainWasChanged);
     418    }
     419    return fNumEntries;
    393420}
    394421
     
    433460    // get number of events in this tree
    434461    //
    435     fNumEntries = (UInt_t)fChain->GetEntries();
    436 
    437     if (!fNumEntries)
     462    if (!GetEntries())
    438463    {
    439464        *fLog << warn << dbginf << "No entries found in file(s)" << endl;
     
    616641    //
    617642#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01)
    618     if (fNumEntry >= fNumEntries)
     643    if (fNumEntry >= GetEntries())
    619644        return kFALSE;
    620645#endif
     
    666691Bool_t MReadTree::DecEventNum(UInt_t dec)
    667692{
    668     if (fNumEntry-dec >= fNumEntries)
     693    if (fNumEntry-dec >= GetEntries())
    669694    {
    670695        *fLog << warn << GetDescriptor() << ": DecEventNum, WARNING - Event " << fNumEntry << "-";
     
    684709Bool_t MReadTree::IncEventNum(UInt_t inc)
    685710{
    686     if (fNumEntry+inc >= fNumEntries)
     711    if (fNumEntry+inc >= GetEntries())
    687712    {
    688713        *fLog << warn << GetDescriptor() << ": IncEventNum, WARNING - Event " << fNumEntry << "+";
     
    704729Bool_t MReadTree::SetEventNum(UInt_t nr)
    705730{
    706     if (nr >= fNumEntries)
     731    if (nr >= GetEntries())
    707732    {
    708733        *fLog << warn << GetDescriptor() << ": SetEventNum, WARNING - " << nr << " out of Range." << endl;
Note: See TracChangeset for help on using the changeset viewer.