Changeset 17867 for trunk/Mars


Ignore:
Timestamp:
05/16/14 11:52:02 (11 years ago)
Author:
tbretz
Message:
Added the possibility to limit the number of events written per branch per file.
Location:
trunk/Mars/mfileio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mfileio/MWriteRootFile.cc

    r14029 r17867  
    213213    Init(name, title);
    214214
     215    const Bool_t hasrule = fSplitRule.BeginsWith("s/") && fSplitRule.EndsWith("/");
     216    if (!hasrule)
     217        fSplitRule = "";
     218
    215219    //
    216220    // Open a TFile in dummy mode! This is necessary to be able to create
     
    218222    // a valid file. (Stupid workaround - but does a good job)
    219223    //
    220     fOut = OpenFile("/dev/null", option, ftitle, comp);
     224    const TString fname = hasrule ? "/dev/null" : rule;
     225    fOut = OpenFile(fname, option, ftitle, comp);
    221226}
    222227
     
    393398// is the name of the tree.
    394399//
    395 void MWriteRootFile::AddContainer(const char *cname, const char *tname, Bool_t must)
     400void MWriteRootFile::AddContainer(const char *cname, const char *tname, Bool_t must, Long64_t max)
    396401{
    397402    if (!fOut && !tname)
     
    412417    // add the entry to the list.
    413418    //
    414     MRootFileBranch *entry = new MRootFileBranch(AddSerialNumber(cname), tname, must);
     419    MRootFileBranch *entry = new MRootFileBranch(AddSerialNumber(cname), tname, must, max);
    415420    fBranches.AddLast(entry);
    416421
     
    429434// is the name of the tree.
    430435//
    431 void MWriteRootFile::AddContainer(MParContainer *cont, const char *tname, Bool_t must)
     436void MWriteRootFile::AddContainer(MParContainer *cont, const char *tname, Bool_t must, Long64_t max)
    432437{
    433438    if (!fOut && !tname)
     
    449454    // add the entry to the list.
    450455    //
    451     MRootFileBranch *entry = new MRootFileBranch(cont, tname, must);
     456    MRootFileBranch *entry = new MRootFileBranch(cont, tname, must, max);
    452457    fBranches.AddLast(entry);
    453458}
     
    712717            continue;
    713718
     719        if (b->GetMaxEntries()==b->GetTree()->GetEntries())
     720            continue;
     721
    714722        //
    715723        // If the write flag of the branch entry is set, set the write flag of
  • trunk/Mars/mfileio/MWriteRootFile.h

    r14447 r17867  
    2525
    2626    Bool_t         fMust;
     27    Long64_t       fMaxEntries;
    2728
    2829    void Init(const char *name, Bool_t must)
     
    3334
    3435public:
    35     MRootFileBranch() : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0)
     36    MRootFileBranch() : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0), fMaxEntries(0)
    3637    {
    3738        Init(NULL, kFALSE);
     
    3940    }
    4041
    41     MRootFileBranch(const char *cname, const char *tname=NULL, Bool_t must=kFALSE)
    42         : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0)
     42    MRootFileBranch(const char *cname, const char *tname=NULL, Bool_t must=kFALSE, Long64_t max=-1)
     43        : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0), fMaxEntries(max)
    4344    {
    4445        Init(tname, must);
     
    4647    }
    4748
    48     MRootFileBranch(MParContainer *cont, const char *tname=NULL, Bool_t must=kFALSE)
    49         : fTree(NULL), fBranch(NULL), fMust(0)
     49    MRootFileBranch(MParContainer *cont, const char *tname=NULL, Bool_t must=kFALSE, Long64_t max=-1)
     50        : fTree(NULL), fBranch(NULL), fMust(0), fMaxEntries(max)
    5051    {
    5152        Init(tname, must);
     
    5455    }
    5556
    56     TTree         *GetTree() const      { return fTree; }
    57     MParContainer *GetContainer() const { return fContainer; }
    58     void          *GetAddress()         { return &fContainer; }
    59     TBranch       *GetBranch() const    { return fBranch; }
    60     const char    *GetContName() const  { return fTitle; }
    61     Bool_t         MustHave() const     { return fMust; }
     57    TTree         *GetTree() const       { return fTree; }
     58    MParContainer *GetContainer() const  { return fContainer; }
     59    void          *GetAddress()          { return &fContainer; }
     60    TBranch       *GetBranch() const     { return fBranch; }
     61    const char    *GetContName() const   { return fTitle; }
     62    Bool_t         MustHave() const      { return fMust; }
     63    Long64_t         GetMaxEntries() const { return fMaxEntries; }
    6264
    6365    void SetContainer(MParContainer *cont) { fContainer = cont; }
     
    129131    ~MWriteRootFile();
    130132
    131     void AddContainer(const char *cname,   const char *tname=NULL, Bool_t must=kTRUE);
    132     void AddContainer(MParContainer *cont, const char *tname=NULL, Bool_t must=kTRUE);
     133    void AddContainer(const char *cname,   const char *tname=NULL, Bool_t must=kTRUE, Long64_t max=-1);
     134    void AddContainer(MParContainer *cont, const char *tname=NULL, Bool_t must=kTRUE, Long64_t max=-1);
    133135    void AddCopySource(const char *tname, const char *bname=NULL, Bool_t force=kTRUE);
    134136    void AddCopySource(const char *tname, Bool_t force)
Note: See TracChangeset for help on using the changeset viewer.