Ignore:
Timestamp:
11/05/01 10:35:36 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1003 r1030  
    8787{
    8888
    89    MParContainer *named = (MParContainer*)TObject::Clone(newname);
     89   MParContainer *named = (MParContainer*)TObject::Clone();
    9090   if (newname && strlen(newname)) named->SetName(newname);
    9191   return named;
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1014 r1030  
    9898    MParContainer(const MParContainer &named);
    9999    MParContainer& operator=(const MParContainer& rhs);
     100    virtual ~MParContainer() {}
    100101
    101     void SetLogStream(MLog *lg) { fLog = lg; }
     102    virtual TObject    *Clone(const char *newname="") const;
     103    virtual Int_t       Compare(const TObject *obj) const;
     104    virtual void        Copy(TObject &named);
     105    virtual void        FillBuffer(char *&buffer);
    102106
    103     virtual TObject *Clone(const char *newname="") const;
    104     virtual Int_t    Compare(const TObject *obj) const;
    105     virtual void     Copy(TObject &named);
    106     virtual void     FillBuffer(char *&buffer);
    107     virtual const char  *GetName() const  { return fName.Data(); }
    108     virtual const char  *GetTitle() const { return fTitle.Data(); }
    109     virtual ULong_t  Hash()               { return fName.Hash(); }
    110     virtual Bool_t   IsSortable() const   { return kTRUE; }
    111     virtual void     SetName(const char *name); // *MENU*
    112     virtual void     SetObject(const char *name, const char *title);
    113     virtual void     SetTitle(const char *title=""); // *MENU*
    114     virtual void     ls(Option_t *option="") const;
    115     virtual void     Print(Option_t *option="") const;
    116     virtual Int_t    Sizeof() const;
     107    virtual const char *GetName() const    { return fName.Data(); }
     108    virtual const char *GetTitle() const   { return fTitle.Data(); }
     109    virtual ULong_t     Hash()             { return fName.Hash(); }
     110    virtual Bool_t      IsSortable() const { return kTRUE; }
    117111
    118     virtual void     Reset() {  }
     112    virtual void        SetName(const char *name); // *MENU*
     113    virtual void        SetObject(const char *name, const char *title);
     114    virtual void        SetTitle(const char *title=""); // *MENU*
     115    virtual void        ls(Option_t *option="") const;
     116    virtual void        Print(Option_t *option="") const;
     117    virtual Int_t       Sizeof() const;
    119118
     119    virtual void   SetLogStream(MLog *lg) { fLog = lg; }
     120    virtual void   Reset() { }
    120121    virtual Bool_t IsReadyToSave()                   { return fReadyToSave; }
    121122    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r1014 r1030  
    2424{
    2525private:
    26     TOrdCollection *fContainer; // Collection of Parameter and Data Containers
     26    TOrdCollection *fContainer;  // Collection of Parameter and Data Containers
    2727    TOrdCollection *fAutodelete; // All what this list contains is deleted in the destructor
    2828
     
    3636    MParList(MParList &ts);
    3737
    38     ~MParList();
     38    virtual ~MParList();
    3939
    4040    Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r1020 r1030  
    7878MReadTree::MReadTree(const char *tname, const char *fname,
    7979                     const char *name, const char *title)
    80     : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
     80    : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
    8181{
    8282    fName  = name  ? name  : "MReadTree";
     
    165165// --------------------------------------------------------------------------
    166166//
    167 // This is the implementation of the Auto Enabling Scheme.
    168 // For more information see MTask::AddBranchToList.
    169 // This function loops over all tasks in the tasklist and enables
    170 // all branches which are requested by the tasks.
    171 //
    172 // To enable 'unknown' branches which are not in the Branchlist of
    173 // the tasks you can call EnableBranch
     167// Checks whether a branch with the given name exists in the chain
     168// and sets the branch status of this branch corresponding to status.
     169//
     170void MReadTree::SetBranchStatus(TObject *branch, Bool_t status)
     171{
     172    //
     173    // Get branch name
     174    //
     175    const char *name = branch->GetName();
     176
     177    //
     178    // Check whether this branch really exists
     179    //
     180    if (!fChain->GetBranch(name))
     181        return;
     182
     183    //
     184    // Set the branch status
     185    //
     186    fChain->SetBranchStatus(name, status);
     187    *fLog << (status ? "Enabled" : "Disabled");
     188    *fLog << " subbranch '" << name << "'." << endl;
     189}
     190
     191// --------------------------------------------------------------------------
     192//
     193// Set the status of all branches in the list to status.
     194//
     195void MReadTree::SetBranchStatus(const TOrdCollection *list, Bool_t status)
     196{
     197    //
     198    // Loop over all subbranches in this master branch
     199    //
     200    TIter Next(list);
     201
     202    TObject *obj;
     203    while ((obj=Next()))
     204        SetBranchStatus(obj, status);
     205}
     206
     207// --------------------------------------------------------------------------
     208//
     209//  This is the implementation of the Auto Enabling Scheme.
     210//  For more information see MTask::AddBranchToList.
     211//  This function loops over all tasks in the tasklist and enables
     212//  all branches which are requested by the tasks.
     213//
     214//  To enable 'unknown' branches which are not in the Branchlist of
     215//  the tasks you can call EnableBranch
    174216//
    175217void MReadTree::EnableBranches(MParList *plist)
    176218{
    177     //
    178     // if auto enabling is off reject the request
    179     //
    180     if (!fAutoEnable)
    181         return;
    182 
    183219    //
    184220    // check whether branch choosing must be switched on
     
    198234
    199235    //
    200     // Loo over all tasks in the task list.
     236    // Loop over all tasks in the task list.
    201237    //
    202238    MTask *task;
    203239    TIter NextTask(tlist->GetList());
    204240    while ((task=(MTask*)NextTask()))
    205     {
    206         //
    207         // Loop over all branches of this task
    208         //
    209         TNamed *branch;
    210         TIter NextBranch(task->GetListOfBranches());
    211         while ((branch=(TNamed*)NextBranch()))
    212         {
    213             //
    214             // Get branch name to enable and enable the branch
    215             //
    216             const char *name = branch->GetName();
    217 
    218             *fLog << "Enabeling '" << name << "'." << endl;
    219 
    220             fChain->SetBranchStatus(name, kTRUE);
    221         }
    222     }
     241        SetBranchStatus(task->GetListOfBranches(), kTRUE);
     242}
     243
     244// --------------------------------------------------------------------------
     245//
     246//  The disables all subbranches of the given master branch.
     247//
     248void MReadTree::DisableSubBranches(TBranch *branch)
     249{
     250    //
     251    // This is not necessary, it would work without. But the output
     252    // may confuse the user...
     253    //
     254    if (fAutoEnable || fBranchChoosing)
     255        return;
     256
     257    SetBranchStatus(branch->GetListOfBranches(), kFALSE);
    223258}
    224259
     
    244279    if (!fNumEntries)
    245280    {
    246         *fLog << dbginf << "No entries found in chain (file/s)." << endl;
     281        *fLog << dbginf << "No entries found in file(s)." << endl;
    247282        return kFALSE;
    248283    }
     
    276311        if (fVetoList->FindObject(name))
    277312        {
    278             *fLog << "Branch " << name << " has veto... skipped." << endl;
     313            *fLog << "Master branch " << name << " has veto... skipped." << endl;
     314            DisableSubBranches(branch);
    279315            continue;
    280316        }
     
    299335            //
    300336            *fLog << dbginf << "Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl;
     337            DisableSubBranches(branch);
    301338            continue;
    302339        }
     
    308345        fChain->SetBranchAddress(name, pcont);
    309346
    310         *fLog << "Branch " << name << " setup for reading." << endl;
     347        *fLog << "Master branch address " << name << " setup for reading." << endl;
    311348
    312349        num++;
    313350    }
    314351
    315     *fLog << "MReadTree setup " << num << " branches." << endl;
    316 
    317     EnableBranches(pList);
    318 
     352    *fLog << "MReadTree setup " << num << " master branches addresses." << endl;
     353
     354    //
     355    // If auto enabling scheme isn't disabled, do auto enabling
     356    //
     357    if (fAutoEnable)
     358        EnableBranches(pList);
     359
     360    //
     361    // If a progress bar is given set its range.
     362    //
    319363    if (fProgress)
    320364        fProgress->SetRange(0, fNumEntries);
     
    351395Bool_t MReadTree::DecEventNum(UInt_t dec)
    352396{
    353     //!
    354     //! this function makes Process() read the event one (or more) before
    355     //! the actual position (event) in the tree
    356     //!
    357     if (fNumEntry < dec/*+1*/)
    358     {
    359         *fLog << "MReadTree::SetPrevEvent: WARNING: " << fNumEntry/*-1*/ << "-" << dec << " out of Range." << endl;
     397    if (fNumEntry-dec >= fNumEntries)
     398    {
     399        *fLog << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-";
     400        *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range." << endl;
    360401        return kFALSE;
    361402    }
    362403
    363     fNumEntry -= dec/*+1*/;
     404    fNumEntry -= dec;
    364405    return kTRUE;
    365406}
     
    372413Bool_t MReadTree::IncEventNum(UInt_t inc)
    373414{
    374     //!
    375     //! this function makes Process() read the next (or more) after
    376     //! the actual position (event) in the tree
    377     //! (Be careful: IncEventNum() or IncEventNum(1) does not chenge anything
    378     //!  in the standard behaviour of the task)
    379     //!
    380     if (fNumEntry+inc/*-1*/ >= fNumEntries)
    381     {
    382         *fLog << "MReadTree::SkipEvents: WARNING: " << fNumEntry/*-1*/ << "+" << inc << " out of Range." << endl;
     415    if (fNumEntry+inc >= fNumEntries)
     416    {
     417        *fLog << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+";
     418        *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range." << endl;
    383419        return kFALSE;
    384420    }
    385421
    386     fNumEntry += inc/*-1*/;
     422    fNumEntry += inc;
    387423    return kTRUE;
    388424}
     
    390426// --------------------------------------------------------------------------
    391427//
    392 // this function makes Process() read event number nr next
     428// This function makes Process() read event number nr next
    393429//
    394430// Remark: You can use this function after instatiating you MReadTree-object
     
    397433Bool_t MReadTree::SetEventNum(UInt_t nr)
    398434{
    399     if (nr>=fNumEntries)
    400     {
    401         *fLog << "MReadTree::SetEventNum: WARNING: " << nr << " out of Range." << endl;
     435    if (nr >= fNumEntries)
     436    {
     437        *fLog << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl;
    402438        return kFALSE;
    403439    }
     
    409445// --------------------------------------------------------------------------
    410446//
    411 // If you don't want that an object is created for this branch
    412 // and/or the branch address is set in the Preprocessing of
    413 // MReadTree use VetoBranch. This saves mainly memory space.
     447//  For the branch with the given name:
     448//   1) no object is automatically created
     449//   2) the branch address for this branch is not set
     450//      (because we lack the object, see 1)
     451//   3) The whole branch (exactly: all its subbranches) are disabled
     452//      this means are not read in memory by TTree:GetEntry
    414453//
    415454void MReadTree::VetoBranch(const char *name)
  • trunk/MagicSoft/Mars/mbase/MReadTree.h

    r1020 r1030  
    77
    88class TChain;
     9class TBranch;
    910class TGProgressBar;
    1011
     
    2223    TOrdCollection *fVetoList; // List of Branches which are not allowed to get enabled
    2324
    24     TGProgressBar *fProgress; // Possible display of status
     25    TGProgressBar  *fProgress; // Possible display of status
    2526
     27    void SetBranchStatus(const TOrdCollection *list, Bool_t status);
     28    void SetBranchStatus(TObject *branch, Bool_t status);
     29
     30    void DisableSubBranches(TBranch *b);
    2631    void EnableBranches(MParList *plist);
    2732    void EnableBranchChoosing();
    2833
     34    Bool_t PreProcess(MParList *pList);
     35    Bool_t Process();
     36 
    2937public:
    3038    MReadTree(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL);
    3139    ~MReadTree();
    3240
    33     Bool_t PreProcess(MParList *pList);
    34     Bool_t Process();
     41    Int_t  AddFile(const char *fname);
     42    void   DisableAutoScheme() { fAutoEnable = kFALSE; }
     43    void   EnableBranch(const char *name);
     44    void   VetoBranch(const char *name);
    3545
    3646    void   SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
    37 
    38     Int_t  AddFile(const char *fname);
    39     void   VetoBranch(const char *name);
    40 
    41     void   EnableBranch(const char *name);
    4247
    4348    Bool_t GetEvent();
     
    5055    UInt_t GetEntries() const  { return fNumEntries; }
    5156
    52     void   DisableAutoScheme() { fAutoEnable = kFALSE; }
    53 
    54     ClassDef(MReadTree, 0)      // Reads one tree
     57    ClassDef(MReadTree, 0)      // Reads a tree from file(s)
    5558};
    5659
Note: See TracChangeset for help on using the changeset viewer.