Ignore:
Timestamp:
11/15/01 11:07:21 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r1051 r1080  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
     18!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
    1919!
    2020!   Copyright: MAGIC Software Development, 2000-2001
     
    6363
    6464#include "MTime.h"
     65#include "MFilter.h"
    6566#include "MParList.h"
    6667#include "MTaskList.h"
     
    8687    fTitle = title ? title : "Task to loop over all events in one single tree";
    8788
    88     fVetoList = new TOrdCollection;
     89    fVetoList = new TList;
    8990    fVetoList->SetOwner();
    9091
    91     fNotify = new TOrdCollection;
     92    fNotify = new TList;
    9293
    9394    //
     
    9697    fChain = new TChain(tname);
    9798    fChain->SetNotify(this);
     99
     100    // root 3.02:
     101    // In TChain::Addfile remove the limitation that the file name must contain
     102    // the string ".root". ".root" is necessary only in case one wants to specify
     103    // a Tree in a subdirectory of a Root file with eg, the format:
    98104
    99105    if (fname)
     
    183189        return;
    184190
    185     *fLog << "Branch choosing method enabled (only enabled branches are read)." << endl;
     191    *fLog << inf << "Branch choosing method enabled (only enabled branches are read)." << endl;
    186192    fChain->SetBranchStatus("*", kFALSE);
    187193    fBranchChoosing = kTRUE;
     
    223229    //
    224230    fChain->SetBranchStatus(name, status);
    225     *fLog << (status ? "Enabled" : "Disabled");
     231    *fLog << inf << (status ? "Enabled" : "Disabled");
    226232    *fLog << " subbranch '" << name << "'." << endl;
    227233}
     
    231237// Set the status of all branches in the list to status.
    232238//
    233 void MReadTree::SetBranchStatus(const TOrdCollection *list, Bool_t status)
     239void MReadTree::SetBranchStatus(const TList *list, Bool_t status)
    234240{
    235241    //
     
    247253//  This is the implementation of the Auto Enabling Scheme.
    248254//  For more information see MTask::AddBranchToList.
    249 //  This function loops over all tasks in the tasklist and enables
    250 //  all branches which are requested by the tasks.
    251 //
    252 //  To enable 'unknown' branches which are not in the Branchlist of
     255//  This function loops over all tasks and its filters in the tasklist
     256//  and enables all branches which are requested by the tasks and its
     257//  filters.
     258//
     259//  To enable 'unknown' branches which are not in the branchlist of
    253260//  the tasks you can call EnableBranch
    254261//
     
    267274    if (!tlist)
    268275    {
    269         *fLog << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl;
     276        *fLog << warn << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl;
    270277        return;
    271278    }
    272279
    273280    //
    274     // Loop over all tasks in the task list.
     281    // Loop over all tasks iand its filters n the task list.
    275282    //
    276283    MTask *task;
    277284    TIter NextTask(tlist->GetList());
    278285    while ((task=(MTask*)NextTask()))
     286    {
    279287        SetBranchStatus(task->GetListOfBranches(), kTRUE);
     288        const MFilter *filter = task->GetFilter();
     289
     290        if (filter)
     291            SetBranchStatus(filter->GetListOfBranches(), kTRUE);
     292
     293    }
    280294}
    281295
     
    317331    if (!fNumEntries)
    318332    {
    319         *fLog << dbginf << "No entries found in file(s)." << endl;
     333        *fLog << warn << dbginf << "No entries found in file(s)." << endl;
    320334        return kFALSE;
    321335    }
     
    324338    // output logging information
    325339    //
    326     *fLog << fNumEntries << " entries found in file(s)." << endl;
     340    *fLog << inf << fNumEntries << " entries found in file(s)." << endl;
    327341
    328342    //
     
    354368        if (fVetoList->FindObject(oname))
    355369        {
    356             *fLog << "Master branch " << bname << " has veto... skipped." << endl;
     370            *fLog << inf << "Master branch " << bname << " has veto... skipped." << endl;
    357371            DisableSubBranches(branch);
    358372            continue;
     
    377391            // we cannot proceed reading this branch
    378392            //
    379             *fLog << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl;
     393            *fLog << warn << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl;
    380394            DisableSubBranches(branch);
    381395            continue;
     
    387401        //
    388402        fChain->SetBranchAddress(bname, pcont);
    389         *fLog << "Master branch address " << bname << " setup for reading." << endl;
     403        *fLog << inf << "Master branch address " << bname << " setup for reading." << endl;
    390404
    391405        //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl;
     
    395409    }
    396410
    397     *fLog << "MReadTree setup " << num << " master branches addresses." << endl;
     411    *fLog << inf << "MReadTree setup " << num << " master branches addresses." << endl;
    398412
    399413    //
     
    410424
    411425    return kTRUE;
     426}
     427
     428// --------------------------------------------------------------------------
     429//
     430//  Set the ready to save flag of all containers which branchaddresses are
     431//  set for. This is necessary to copy data.
     432//
     433void MReadTree::SetReadyToSave(Bool_t flag)
     434{
     435    TIter Next(fChain->GetStatus());
     436
     437    TChainElement *element = NULL;
     438    while ((element=(TChainElement*)Next()))
     439    {
     440        //
     441        // Check whether the branch is enabled
     442        //
     443        if (!element->GetStatus())
     444            continue;
     445
     446        //
     447        // Get the pointer to the pointer of the corresponding container
     448        //
     449        MParContainer **pcont = (MParContainer**)element->GetBaddress();
     450
     451        //
     452        // Check whether the pointer is not NULL
     453        //
     454        if (!pcont || !*pcont)
     455            continue;
     456
     457        //
     458        // Set the ready to save status of the container.
     459        //
     460        (*pcont)->SetReadyToSave(flag);
     461    }
     462
     463    //
     464    // Set the ready to save status of this task (used?), too
     465    //
     466    MTask::SetReadyToSave(flag);
    412467}
    413468
     
    421476Bool_t MReadTree::Process()
    422477{
     478    SetReadyToSave();
    423479    return fChain->GetEntry(fNumEntry++) != 0;
    424480}
     
    430486Bool_t MReadTree::GetEvent()
    431487{
     488    SetReadyToSave();
    432489    return fChain->GetEntry(fNumEntry) != 0;
    433490}
     
    442499    if (fNumEntry-dec >= fNumEntries)
    443500    {
    444         *fLog << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-";
     501        *fLog << warn << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-";
    445502        *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range." << endl;
    446503        return kFALSE;
     
    460517    if (fNumEntry+inc >= fNumEntries)
    461518    {
    462         *fLog << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+";
     519        *fLog << warn << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+";
    463520        *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range." << endl;
    464521        return kFALSE;
     
    480537    if (nr >= fNumEntries)
    481538    {
    482         *fLog << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl;
     539        *fLog << warn << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl;
    483540        return kFALSE;
    484541    }
     
    522579    fNotify->Add(obj);
    523580}
     581
     582void MReadTree::Print(Option_t *o) const
     583{
     584    *fLog << all << GetDescriptor() << dec << endl;
     585    *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl;
     586    *fLog << " Files:" << endl;
     587
     588    int i = 0;
     589    TIter Next(fChain->GetListOfFiles());
     590    TObject *obj = NULL;
     591    while ((obj=Next()))
     592        *fLog << " " << i++ << ") " << obj->GetName() << endl;
     593
     594    *fLog << " Entries: " << fNumEntries << endl;
     595    *fLog << " Next Entry: " << fNumEntry << endl;
     596}
Note: See TracChangeset for help on using the changeset viewer.