Ignore:
Timestamp:
05/31/05 11:53:09 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
3 edited

Legend:

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

    r6499 r7115  
    165165// To be done: A flag(?) telling whether the headers can be skipped.
    166166//
    167 void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
     167void MReadReports::AddTree(const char *tree, const char *time, Type_t master)
    168168{
    169169    /*
     
    176176    */
    177177
    178     if (master && TestBit(kHasMaster))
     178    if (master==kMaster && TestBit(kHasMaster))
    179179    {
    180180        *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl;
    181         master = kFALSE;
    182     }
    183 
    184     MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree);
     181        master = kStandard;
     182    }
     183
     184    MReadTree *t = master==kMaster ? new MReadMarsFile(tree) : new MReadTree(tree);
    185185    t->SetName(tree);
    186186    t->SetTitle(time?time:"");
    187     if (master)
     187    if (master==kMaster)
    188188        SetBit(kHasMaster);
     189    if (master==kRequired)
     190        t->SetBit(kIsRequired);
    189191
    190192    if (!fEnableAutoScheme)
     
    219221
    220222    return n;
     223}
     224
     225// --------------------------------------------------------------------------
     226//
     227// Count the number of required trees and store the number if fNumRequired.
     228// Reset the kIsProcessed bit.
     229//
     230void MReadReports::ForceRequired()
     231{
     232    fNumRequired = 0;
     233
     234    TIter Next(fTrees->GetList());
     235    TObject *o=0;
     236    while ((o=Next()))
     237        if (o->TestBit(kIsRequired))
     238        {
     239            o->ResetBit(kIsProcessed);
     240            fNumRequired++;
     241        }
     242
     243    *fLog << dbg << "Number of required trees: " << fNumRequired << endl;
    221244}
    222245
     
    297320    fPosEntry.Set(i);
    298321
     322    // Force that with the next call to Process the required events are read
     323    ForceRequired();
     324    //fFirstReInit=kTRUE;
     325
     326    // Preprocess all tasks in fTrees
    299327    return fTrees->CallPreProcess(plist);
     328}
     329
     330// --------------------------------------------------------------------------
     331//
     332// If this is not the first ReInit after PreProcess force the required
     333// trees to be read first (call FirstRequired())
     334//
     335/*
     336Bool_t MReadReports::ReInit(MParList *plist)
     337{
     338    if (!fFirstReInit)
     339        ForceRequired();
     340    fFirstReInit=kFALSE;
     341    return kTRUE;
     342}
     343*/
     344
     345// --------------------------------------------------------------------------
     346//
     347// Return the number of the tree which is the next one to be read.
     348// The condition for this decision is the time-stamp.
     349//
     350Int_t MReadReports::FindNextTime()
     351{
     352    TIter NextC(fChains);
     353    TChain *c=0;
     354
     355    Int_t nmin=0;
     356    MTime tmin(**GetTime((TChain*)NextC()));
     357
     358    Int_t i=0;
     359
     360    while ((c=(TChain*)NextC()))
     361    {
     362        MTime &t = **GetTime(c);
     363        i++;
     364
     365        if (t >= tmin)
     366            continue;
     367
     368        tmin = t;
     369        nmin = i;
     370    }
     371    return nmin;
     372}
     373
     374// --------------------------------------------------------------------------
     375//
     376// Return the number of the tree which is the next one to be read.
     377// The condition for this decision kIsRequired but not kIsProcessed is set.
     378//
     379Int_t MReadReports::FindNextRequired()
     380{
     381    Int_t n = 0;
     382
     383    TIter Next(fTrees->GetList());
     384    TObject *o=0;
     385    while ((o=Next()))
     386    {
     387        if (o->TestBit(kIsRequired) && !o->TestBit(kIsProcessed))
     388        {
     389            o->SetBit(kIsProcessed);
     390            fNumRequired--;
     391            *fLog << dbg << "Reading from tree " << n << " " << o->GetName() << endl;
     392            return n;
     393        }
     394        n++;
     395    }
     396
     397    return -1;
    300398}
    301399
     
    312410// --------------------------------------------------------------------------
    313411//
    314 // Do not use if fChains->GetSize()==0 !!!
    315 //
    316 Int_t MReadReports::FindNextTime()
    317 {
    318     Int_t i=0;
    319 
    320     TIter NextC(fChains);
    321     TChain *c=0;
    322 
    323     Int_t nmin=0;
    324     MTime tmin(**GetTime((TChain*)NextC()));
    325 
    326     while ((c=(TChain*)NextC()))
    327     {
    328         MTime &t = **GetTime(c);
    329         i++;
    330 
    331         if (t >= tmin)
    332             continue;
    333 
    334         tmin = t;
    335         nmin = i;
    336     }
    337     return nmin;
    338 }
    339 
    340 /*
    341 Bool_t MReadReports::Notify()
    342 {
    343     Bool_t same = kTRUE;
    344     for (int i=1; i<fPosTree.GetSize(); i++)
    345         if (fPosTree[i]!=fPosTree[0])
    346         {
    347             same = kFALSE;
    348             break;
    349         }
    350 
    351     Int_t tn = chain->GetTreeNumber();
    352 
    353     Bool_t read=kFALSE;
    354     if (fPosTree[nmin] != tn)
    355     {
    356         fPosTree[nmin] = tn;
    357         read = kTRUE;
    358     }
    359 
    360     if (!same || !read)
    361         return kTRUE;
    362 
    363 
    364     *fLog << dbg << "Read Run Headers!" << endl;
    365 
    366     return kTRUE;
    367 }
    368 */
    369 
    370 // --------------------------------------------------------------------------
    371 //
    372412// Check which is the next tree to read from. Read an event from this tree.
    373413// Sets the StreamId accordingly.
     
    377417    while (fChains->GetSize())
    378418    {
    379         const Int_t nmin=FindNextTime();
     419        const Int_t nmin=FindNext();
     420        if (nmin<0)
     421        {
     422            *fLog << err << "MReadReports::Process: ERROR - Determination of next tree failed... abort." << endl;
     423            return kERROR;
     424        }
    380425
    381426        TChain *chain = (TChain*)fChains->At(nmin);
  • trunk/MagicSoft/Mars/mfileio/MReadReports.h

    r6499 r7115  
    1717class MReadReports : public MRead
    1818{
     19public:
     20    enum Type_t {
     21        kStandard,
     22        kMaster,
     23        kRequired
     24    };
     25
    1926private:
    2027    MTaskList *fTrees;    // Hold the trees which are scheduled for reading
     
    2532
    2633    Bool_t     fEnableAutoScheme;
     34    Int_t      fNumRequired;
     35    //Bool_t     fFirstReInit;
    2736
     37    void    ForceRequired();
    2838    MTime** GetTime(TChain *c) const;
    2939    Int_t   FindNextTime();
     40    Int_t   FindNextRequired();
     41    Int_t   FindNext() { return fNumRequired==0 ? FindNextTime() : FindNextRequired(); }
    3042
    3143    UInt_t  GetEntries();
    3244    TString GetFullFileName() const;
    3345
     46    //Bool_t  ReInit(MParList *plist);
    3447    Int_t   PreProcess(MParList *plist);
    3548    Int_t   Process();
     
    3750
    3851    enum {
    39         kHasMaster = BIT(14)
     52        kHasMaster   = BIT(14),
     53        kIsRequired  = BIT(22),
     54        kIsProcessed = BIT(23)
    4055    };
    4156
     
    4459    ~MReadReports();
    4560
    46     void  AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE);
    47     void  AddTree(const char *tree, Bool_t master)
     61    void  AddTree(const char *tree, const char *time=NULL, Type_t master=kStandard);
     62    void  AddTree(const char *tree, Type_t master)
    4863    {
    4964        AddTree(tree, NULL, master);
  • trunk/MagicSoft/Mars/mfileio/MReadTree.h

    r6499 r7115  
    3131
    3232    enum { kChainWasChanged = BIT(14) };
     33    // MReadReports::kIsRequired  = BIT(22)
     34    // MReadReports::kIsProcessed = BIT(23)
    3335
    3436private:
     
    4749
    4850    enum { kIsOwner = BIT(14) };
     51    // MReadReports::kIsRequired  = BIT(22)
     52    // MReadReports::kIsProcessed = BIT(23)
    4953
    5054public:
Note: See TracChangeset for help on using the changeset viewer.