Changeset 756 for trunk


Ignore:
Timestamp:
04/19/01 16:12:03 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r755 r756  
    55   * mbase/MParList.cc:
    66     - added stripping of the string after last semicolon (classname)
    7      
     7
     8   * mbase/MReadTree.cc:
     9     - added Veto funtionality to PreProcess
     10     - added HasVeto
     11     - added fVetoList
     12     - added VetoBranch
    813
    914
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r752 r756  
    4343#include <TFile.h>
    4444#include <TChain.h>
     45#include <TArrayC.h>
    4546#include <TObjArray.h>
    4647
     
    6061    *fTitle = title ? title : "Task to loop over all events in one single tree";
    6162
     63    fVetoList = new TArrayC;
    6264    //
    6365    // open the input stream
     
    7375{
    7476    delete fChain;
     77    delete fVetoList;
    7578}
    7679
     
    129132        // Get Name of Branch
    130133        //
    131         const char *name = branch->GetName();
     134        const char *name  = branch->GetName();
     135
     136        //
     137        // Check if enabeling the branch is allowed
     138        //
     139        if (HasVeto(name))
     140            continue;
    132141
    133142        //
     
    258267}
    259268
     269// --------------------------------------------------------------------------
     270//
     271// This function checks if the Branch Name is part of the Veto List.
     272// This means, that the preprocess doesn't enable the branch.
     273//
     274Bool_t MReadTree::HasVeto(const char *name) const
     275{
     276    const size_t nlen = strlen(name)+1;
     277
     278    char  *pos = fVetoList->GetArray();
     279    size_t len = fVetoList->GetSize();
     280
     281    //
     282    // now we compare the 'strings' in the list word by word
     283    // (string or word in this context means a zero terminated
     284    // array of chars
     285    //
     286
     287    for (;;)
     288    {
     289        //
     290        // Search for the first byte of the name
     291        //
     292        char *c = (char*)memchr(pos, name[0], len);
     293
     294        //
     295        // if we don't find the first byte, the list cannot contain 'name'
     296        //
     297        if (!c)
     298            return kFALSE;
     299
     300        //
     301        // calculate and check how many bytes remains in the list
     302        //
     303        len -= c-pos;
     304
     305        //
     306        // if there are not enough bytes to match the query we are done
     307        //
     308        if (len<nlen)
     309            return kFALSE;
     310
     311        //
     312        // check if the next 'nlen' byte (including the trailing '\0'
     313        // are matching
     314        //
     315        if (!memcmp(c, name, nlen))
     316            return kTRUE;
     317
     318        //
     319        // we didn't find the string, goto the next 'string'
     320        //
     321        pos = (char*)memchr(c, '\0', len);
     322
     323        //
     324        // check if there is a 'next' string really
     325        //
     326        if (!pos)
     327            return kFALSE;
     328
     329        //
     330        // calculate the remaining length
     331        //
     332        len -= pos-c;
     333
     334        //
     335        // if there are not enough bytes to match the query we are done
     336        //
     337        if (len<nlen)
     338            return kFALSE;
     339    }
     340}
     341
     342
     343// --------------------------------------------------------------------------
     344//
     345// If you don't want that a branch is enabled within the PreProcess you
     346// can set a veto for enabeling the branch. (This means also the
     347// corresponding object won't be created automatically)
     348//
     349void MReadTree::VetoBranch(const char *name)
     350{
     351    //
     352    // Add this file as the last entry of the list
     353    // (including the trailing '\0')
     354    //
     355    const int sz  = fVetoList->GetSize();
     356    const int tsz = strlen(name)+1;
     357
     358    fVetoList->Set(sz+tsz);
     359
     360    memcpy(fVetoList->GetArray()+sz, name, tsz);
     361}
Note: See TracChangeset for help on using the changeset viewer.