Changeset 965 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
10/16/01 15:10:43 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/getCollArea.C

    r948 r965  
    2424
    2525
    26 void getCollArea(char *filename = "data/gamma_15_on.root" )
     26void getCollArea(char *filename = "camera.root")
    2727{
    2828    // FIXME: Harald, you should tell the people what the result of
     
    5555    //
    5656    MReadTree reader("Events", filename);
     57    reader.UseLeaf("fImpact");
     58    reader.UseLeaf("fEnergy");
     59    reader.UseLeaf("fNumFirstLevel");
    5760    tasklist.AddToList(&reader);
    5861
    5962    MMcCollectionAreaCalc effi;
    6063    tasklist.AddToList(&effi);
     64
     65    MTask task;
     66    tasklist.AddToList(&task);
     67
    6168
    6269    //
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r963 r965  
    3838// MReadTree::SetEventNum after instantiating your MReadTree-object.       //
    3939//                                                                         //
     40// To make reading much faster (up to a factor of 10 to 20) you can        //
     41// ensure that only the data you are really processing is enabled by       //
     42// calling MReadTree::UseLeaf.                                             //
     43//                                                                         //
     44// Later we'll use TChain::SetNotify to notify MReadTree if the TChain     //
     45// starts to read a new file.                                              //
     46//                                                                         //
    4047/////////////////////////////////////////////////////////////////////////////
    4148
     
    6774//
    6875MReadTree::MReadTree(const char *tname, const char *fname,
    69                      const char *name, const char *title) : fNumEntry(0)
     76                     const char *name, const char *title)
     77    : fNumEntry(0), fLeafEnabled(kFALSE)
    7078{
    7179    *fName  = name  ? name  : "MReadTree";
     
    113121//  anymore, tree wich are not existing in the first file are never read)
    114122//
    115 /*Int_t*/ void MReadTree::AddFile(const char *fname)
     123//  Name may use the wildcarding notation, eg "xxx*.root" means all files
     124//  starting with xxx in the current file system directory.
     125//
     126Int_t MReadTree::AddFile(const char *fname)
    116127{
    117128    //
     
    121132    // returns the number of file which were added
    122133    //
    123     /*return  root >3.0*/ fChain->Add(fname);
     134    return fChain->Add(fname);
     135}
     136
     137// --------------------------------------------------------------------------
     138//
     139// The first time this function is called all leafes/branches are disabled
     140// and the given branch/leaf is enabled. By enabling only the branches you
     141// are processing you can speed up your calculation many times (up to
     142// a factor of 10 or 20)
     143//
     144void MReadTree::UseLeaf(const char *name)
     145{
     146    if (!fLeafEnabled)
     147    {
     148        *fLog << "Leaf choosing method enabled (only enabled leaves are read)." << endl;
     149        fChain->SetBranchStatus("*", kFALSE);
     150        fLeafEnabled = kTRUE;
     151    }
     152
     153    fChain->SetBranchStatus(name, kTRUE);
    124154}
    125155
     
    170200        // Get Name of Branch
    171201        //
    172         const char *name  = branch->GetName();
     202        const char *name = branch->GetName();
    173203
    174204        //
     
    208238        //
    209239        fChain->SetBranchAddress(name, pcont);
     240
    210241        *fLog << "Branch " << name << " enabled for reading." << endl;
    211242
     
    227258Bool_t MReadTree::Process()
    228259{
    229     //
    230     // check for end of file
    231     //
    232     if (fNumEntry>=fNumEntries)
    233         return kFALSE;
    234 
    235     //
    236     // get entry
    237     //
    238     fChain->GetEntry(fNumEntry);
    239 
    240     fNumEntry++;
    241 
    242     return kTRUE;
     260    return fChain->GetEntry(fNumEntry++, 0) == 0 ? kFALSE : kTRUE;
    243261}
    244262
     
    249267Bool_t MReadTree::GetEvent()
    250268{
    251     fChain->GetEntry(fNumEntry);
    252 
    253     return kTRUE;
     269    return fChain->GetEntry(fNumEntry) == 0 ? kFALSE : kTRUE;
    254270}
    255271
  • trunk/MagicSoft/Mars/mbase/MReadTree.h

    r760 r965  
    2121    UInt_t   fNumEntries; // Number of Events in Tree
    2222
     23    Bool_t   fLeafEnabled; // Flag whether UseLeaf is called the first time or not
     24
    2325    Bool_t HasVeto(const char *name) const;
    2426
     
    3032    Bool_t Process();
    3133
    32     void AddFile(const char *fname);
    33     void VetoBranch(const char *name);
     34    Int_t AddFile(const char *fname);
     35    void  VetoBranch(const char *name);
     36
     37    void UseLeaf(const char *name);
    3438
    3539    Bool_t GetEvent();
Note: See TracChangeset for help on using the changeset viewer.