Changeset 1114 for trunk


Ignore:
Timestamp:
12/14/01 15:17:09 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1108 r1114  
    11                                                                  -*-*- END -*-*-
     2
     3 2001/12/14: Thomas Bretz
     4 
     5   * mbase/MReadMarsFile.[h,cc], mbase/MReadFild.[h,cc]:
     6     - corrected handling of ReInit/Notify (at the moment I assume
     7       one run per file)
     8     - made sure, that we don't get memory leaks when using MReadTree
     9       more than once because the pointer to the pointer isn't deleted.
     10     - added a small class MChain which enhances TChain by a function to
     11       reset fTree. This is used to control when notification are
     12       happening
     13
     14   * mbase/MTask.cc:
     15     - reset the number of executions before the preprocessing
     16
     17
    218
    319 2001/12/11: Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MReadMarsFile.cc

    r1100 r1114  
    3737
    3838#include "MLog.h"
     39#include "MLogManip.h"
     40
     41#include "MParList.h"
     42#include "MTaskList.h"
    3943
    4044ClassImp(MReadMarsFile);
     
    5660    //
    5761    fRun = new MReadTree("RunHeaders", fname);
     62
     63    //
     64    // This disables the auto scheme. because reading new runheader is done
     65    // at a low frequency we don't loose time if we always read all
     66    // runheaders
     67    //
    5868    fRun->DisableAutoScheme();
    5969}
     
    98108Bool_t MReadMarsFile::Notify()
    99109{
    100     if (GetEventNum() == 0)
    101         return kTRUE;
     110    //
     111    // Try to read the new run headers. If reading the new run header
     112    // was successfull call the ReInits
     113    //
     114    if (fRun->Process())
     115    {
     116        *fLog << inf << "MReadMarsFile: Switching to '" << GetFileName() << "' ";
     117        *fLog << "(before processing event #" << GetEventNum()-1 << ")" << endl;
    102118
    103     *fLog << "MReadMarsFile: Switching to next file '" << GetFileName() << "' ";
    104     *fLog << "(before Event #" << GetEventNum()-1 << ")" << endl;
    105     fRun->Process();
    106 
    107     MReadTree::Notify();
     119        fTaskList->ReInit();
     120        //MReadTree::Notify();
     121    }
     122    else
     123        *fLog << warn << "Warning: Cannot read new runheaders after reading event #" << GetEventNum() << endl;
    108124
    109125    return kTRUE;
     
    117133Bool_t MReadMarsFile::PreProcess(MParList *pList)
    118134{
     135    fTaskList = (MTaskList*)pList->FindObject("MTaskList");
     136
    119137    if (!fRun->PreProcess(pList))
    120         return kFALSE;
    121 
    122     if (!fRun->Process())
    123138        return kFALSE;
    124139
    125140    return MReadTree::PreProcess(pList);
    126141}
    127 
  • trunk/MagicSoft/Mars/mbase/MReadMarsFile.h

    r1035 r1114  
    66#endif
    77
     8class MTaskList;
     9
    810class MReadMarsFile : public MReadTree
    911{
    1012private:
    1113    MReadTree *fRun;
     14    MTaskList *fTaskList; //! Tasklist for reinitialization
    1215
    1316    Bool_t Notify();
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r1108 r1114  
    6969ClassImp(MReadTree);
    7070
     71class MChain : public TChain
     72{
     73public:
     74    MChain() : TChain() {}
     75    MChain(const char *name, const char *title="") : TChain(name, title) {}
     76
     77    void ResetTree() { fTree = 0; }
     78};
     79
    7180// --------------------------------------------------------------------------
    7281//
     
    95104    // open the input stream
    96105    //
    97     fChain = new TChain(tname);
    98     fChain->SetNotify(this);
     106    fChain = new MChain(tname);
    99107
    100108    // root 3.02:
     
    149157Bool_t MReadTree::Notify()
    150158{
    151     //
    152     // FIXME: This is correct!
    153     //
    154     //   fNotify->ForEach(TObject, Notify)();
    155 
    156     fTaskList->ReInit();
     159    *fLog << inf << "MReadTree: Notify '" << fChain->GetName() << "' ";
     160    *fLog << "(before processing event #" << GetEventNum()-1 << ")" << endl;
     161
     162    //fNotify->Notify();
    157163
    158164    return kTRUE;
     
    347353Bool_t MReadTree::PreProcess(MParList *pList)
    348354{
    349     fTaskList = (MTaskList*)pList->FindObject("MTaskList");
     355    //
     356    // Make sure, that all the following calls doesn't result in
     357    // Notifications. This may be dangerous, because the notified
     358    // tasks are not preprocessed.
     359    //
     360    fChain->SetNotify(NULL);
    350361
    351362    //
     
    365376    *fLog << inf << fNumEntries << " entries found in file(s)." << endl;
    366377
     378    *fLog << all << fChain->GetListOfBranches() << endl;
     379
    367380    //
    368381    // Get all branches of this tree and
     
    373386
    374387    Int_t num=0;
     388
     389
     390    *fLog << "Start..." << endl;
    375391    //
    376392    // loop over all tasks for processing
     
    382398        //
    383399        const char *bname = branch->GetName();
     400
     401        *fLog << all << bname << endl;
    384402
    385403        TString oname(bname);
     
    398416        }
    399417
     418        MParContainer *obj = pList->FindCreateObj(oname);
     419
     420        if (!obj)
     421        {
     422            //
     423            // if class is not existing in the (root) environment
     424            // we cannot proceed reading this branch
     425            //
     426            *fLog << warn << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl;
     427            DisableSubBranches(branch);
     428            continue;
     429        }
     430
    400431        //
    401432        // Create a pointer to the pointer to the object in which the
     
    403434        // object and we get the pointers from there to delete it.
    404435        //
    405         MParContainer **pcont = new MParContainer*;
     436        MParContainer **pcont= new MParContainer*;
    406437
    407438        //
     
    422453
    423454        //
     455        // Check whether a Pointer to a pointer already exists, if
     456        // we created one already delete it.
     457        //
     458        TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname);
     459        if (element)
     460            delete (MParContainer**)element->GetBaddress();
     461
     462        //
    424463        // here pcont is a pointer the to container in which the data from
    425464        // the actual branch should be stored - enable branch.
     
    447486    if (fProgress)
    448487        fProgress->SetRange(0, fNumEntries);
     488
     489    //
     490    // Now we can start notifying. Reset tree makes sure, that TChain thinks
     491    // that the correct file is not yet initialized and reinitilizes it
     492    // as soon as the first event is read. This is necessary to call
     493    // the notifiers when the first event is read, but after the
     494    // PreProcess-function.
     495    //
     496    fChain->ResetTree();
     497    fChain->SetNotify(this);
    449498
    450499    return kTRUE;
     
    501550Bool_t MReadTree::Process()
    502551{
     552    //
     553    // This is necessary due to a bug in TCHain::LoadTree in root.
     554    //
     555    if (fNumEntry >= fNumEntries)
     556        return kFALSE;
     557
    503558    Bool_t rc = fChain->GetEntry(fNumEntry++) != 0;
    504559
  • trunk/MagicSoft/Mars/mbase/MReadTree.h

    r1108 r1114  
    66#endif
    77
    8 class TChain;
     8class MChain;
    99class TBranch;
    10 class MTaskList;
    1110class TGProgressBar;
    1211
     
    1413{
    1514private:
    16     TChain *fChain;            // Pointer to tree
     15    MChain *fChain;            // Pointer to tree
    1716
    18     UInt_t  fNumEntry;         // Number of actual entry
    19     UInt_t  fNumEntries;       // Number of Events in Tree
     17    UInt_t  fNumEntry;         // Number of actual entry in chain
     18    UInt_t  fNumEntries;       // Number of Events in chain
    2019
    2120    Bool_t  fBranchChoosing;   // Flag for branch choosing method
     
    2524    TList  *fNotify;           // List of TObjects to notify when switching files
    2625
    27     MTaskList      *fTaskList; //! Tasklist for reinitialization
     26private:
    2827    TGProgressBar  *fProgress; //! Possible display of status
    2928
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r1108 r1114  
    134134Bool_t MTask::CallPreProcess(MParList *plist)
    135135{
     136    fNumExecutions = 0;
     137
    136138    if (!PreProcess(plist))
    137139        return kFALSE;
Note: See TracChangeset for help on using the changeset viewer.