Ignore:
Timestamp:
12/05/03 16:06:34 (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

    r2206 r2607  
    190190    //MReadTree::Notify();
    191191
    192     *fLog << err << "ERROR - ReInit of '" << tlist->GetName() << "' failed." << endl;
     192    *fLog << err << "ERROR - ReInit of '" << tlist->GetDescriptor() << "' failed." << endl;
    193193    return kFALSE;
    194194}
  • trunk/MagicSoft/Mars/mfileio/MReadReports.cc

    r2604 r2607  
    7070#include "MTime.h"
    7171#include "MParList.h"
    72 #include "MReadTree.h"
    7372#include "MTaskList.h"
     73
     74#include "MReadMarsFile.h"
    7475
    7576ClassImp(MReadReports);
     
    124125// name in time.
    125126//
    126 // All calls to AddTree _must_ be before the calls to AddFile!
    127 //
    128 void MReadReports::AddTree(const char *tree, const char *time)
     127// All calls to AddTree _must_ be BEFORE the calls to AddFile!
     128//
     129void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
    129130{
    130131    /*
     
    136137    }
    137138    */
    138     MReadTree *t = new MReadTree(tree);
     139
     140    if (master && TestBit(kHasMaster))
     141    {
     142        *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl;
     143        master = kFALSE;
     144    }
     145
     146    MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree);
    139147    t->SetName(tree);
    140148    t->SetTitle(time?time:"");
     149    if (master)
     150        t->SetBit(kHasMaster);
    141151
    142152    if (!fEnableAutoScheme)
     
    154164// Schedule a file or several files (using widcards) for reading.
    155165//
    156 // All calls to AddTree _must_ be before the calls to AddFile!
     166// All calls to AddTree _must_ be BEFORE the calls to AddFile!
    157167//
    158168Int_t MReadReports::AddFile(const char *fname, Int_t entries)
     
    188198    while ((tree=(MReadTree*)NextT()))
    189199    {
     200        if (((TChain*)tree->fChain)->GetListOfFiles()->GetEntries()==0)
     201        {
     202            *fLog << warn << "No files for Tree " << tree->GetName() << "... skipped." << endl;
     203            continue;
     204        }
     205
    190206        TString tn(tree->GetTitle());
    191207        if (tn.IsNull())
     
    224240    }
    225241
    226     fPos.Set(i);
     242    fPosEntry.Set(i);
    227243
    228244    return fTrees->CallPreProcess(plist);
     
    241257// --------------------------------------------------------------------------
    242258//
     259// Do not use if fChains->GetSize()==0 !!!
     260//
     261Int_t MReadReports::FindNextTime()
     262{
     263    Int_t i=0;
     264
     265    TIter NextC(fChains);
     266    TChain *c=0;
     267
     268    Int_t nmin=0;
     269    MTime tmin(**GetTime((TChain*)NextC()));
     270
     271    while ((c=(TChain*)NextC()))
     272    {
     273        MTime &t = **GetTime(c);
     274        i++;
     275
     276        if (t >= tmin)
     277            continue;
     278
     279        tmin = t;
     280        nmin = i;
     281    }
     282    return nmin;
     283}
     284
     285/*
     286Bool_t MReadReports::Notify()
     287{
     288    Bool_t same = kTRUE;
     289    for (int i=1; i<fPosTree.GetSize(); i++)
     290        if (fPosTree[i]!=fPosTree[0])
     291        {
     292            same = kFALSE;
     293            break;
     294        }
     295
     296    Int_t tn = chain->GetTreeNumber();
     297
     298    Bool_t read=kFALSE;
     299    if (fPosTree[nmin] != tn)
     300    {
     301        fPosTree[nmin] = tn;
     302        read = kTRUE;
     303    }
     304
     305    if (!same || !read)
     306        return kTRUE;
     307
     308
     309    *fLog << dbg << "Read Run Headers!" << endl;
     310
     311    return kTRUE;
     312}
     313*/
     314
     315// --------------------------------------------------------------------------
     316//
    243317// Check which is the next tree to read from. Read an event from this tree.
    244318// Sets the StreamId accordingly.
     
    248322    while (fChains->GetSize())
    249323    {
    250         Int_t i=0;
    251 
    252         MTime tmin;
    253 
    254         Int_t nmin=0;
    255 
    256         TIter NextC(fChains);
    257         TChain *c=0;
    258         while ((c=(TChain*)NextC()))
     324        const Int_t nmin=FindNextTime();
     325
     326        TChain *chain = (TChain*)fChains->At(nmin);
     327
     328        //Int_t before = chain->GetTreeNumber();
     329        if (chain->GetEntry(++fPosEntry[nmin])>0)
    259330        {
    260             MTime &t = **GetTime(c);
    261 
    262             if (i==0)
    263                 tmin = t;
    264 
    265             if (t < tmin)
     331            MTask *task = (MTask*)fTrees->GetList()->At(nmin);
     332
     333            if (task->CallProcess())
    266334            {
    267                 tmin = t;
    268                 nmin = i;
     335                fList->SetStreamId(task->GetName());
     336                return kTRUE;
    269337            }
    270             i++;
    271         }
    272 
    273         TChain *chain = (TChain*)fChains->At(nmin);
    274 
    275         chain->GetEntry(++fPos[nmin]);
    276 
    277         // FIXME: Use Stream ID and call CallProcess() ?
    278         Bool_t rc = ((MTask*)fTrees->GetList()->At(nmin))->CallProcess();
    279         if (rc)
    280         {
    281             fList->SetStreamId(fTrees->GetList()->At(nmin)->GetName());
    282             return kTRUE;
    283338        }
    284339
  • trunk/MagicSoft/Mars/mfileio/MReadReports.h

    r2604 r2607  
    1717{
    1818private:
    19     MTaskList *fTrees;  // Hold the trees which are scheduled for reading
    20     TList     *fChains; // Hold TChains to read the times in advance
     19    MTaskList *fTrees;    // Hold the trees which are scheduled for reading
     20    TList     *fChains;   // Hold TChains to read the times in advance
    2121
    22     TArrayL    fPos;    // Store the position in each tree/chain
     22    TArrayL    fPosEntry; // Store the position in each tree/chain
     23    TArrayL    fPosTree;  // Number of Tree in file.
    2324
    24     MTask     *fList;   // pointer to the task list to set the stream id
     25    MTask     *fList;     // pointer to the task list to set the stream id
    2526
    2627    Bool_t     fEnableAutoScheme;
    2728
    2829    MTime** GetTime(TChain *c) const;
     30    Int_t   FindNextTime();
    2931
    3032    UInt_t  GetEntries() { return 0; }
     
    3436    Int_t   PostProcess();
    3537
     38    //Bool_t  Notify();
     39
     40    enum {
     41        //MReadTree::kChainWasChanged = BIT(14)
     42        kHasMaster = BIT(15)
     43    };
     44
    3645public:
    3746    MReadReports();
    3847    ~MReadReports();
    3948
    40     void  AddTree(const char *tree, const char *time=NULL);
     49    void  AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE);
     50    void  AddTree(const char *tree, Bool_t master)
     51    {
     52        AddTree(tree, NULL, master);
     53    }
    4154    Int_t AddFile(const char *fname, Int_t entries=-1);
    4255    void  AddToBranchList(const char *name);
     
    4457    void  PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
    4558
    46     void  EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; }
     59    void  EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree!
    4760
    4861    ClassDef(MReadReports, 0) // Reads events and reports from a root file ordered in time
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r2532 r2607  
    192192                continue;
    193193
    194             *fLog << err << "ERROR - File corrupttion detected:" << endl;
     194            *fLog << err << "ERROR - File corruption detected:" << endl;
    195195            *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
    196196            *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
     
    232232    *fLog << GetNumEntry()-1 << ")" << endl;
    233233
    234     //fNotify->Notify();
     234    if (!fNotify)
     235        return kTRUE;
     236
     237    TIter Next(fNotify);
     238    TObject *o=NULL;
     239    while ((o=Next()))
     240        if (!o->Notify())
     241        {
     242            *fLog << err << "Calling Notify() for object " << o->GetName() << " failed... abort." << endl;
     243            return kFALSE;
     244        }
    235245
    236246    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.