ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/interface/OutputMod.h
Revision: 1.3
Committed: Wed Dec 3 17:44:05 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.2: +47 -23 lines
Log Message:
First quite complete implementation. Needs tests.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.3 // $Id: OutputMod.h,v 1.2 2008/12/02 09:34:16 loizides Exp $
3 loizides 1.1 //
4     // OutputMod
5     //
6 loizides 1.3 // This TAM module writes selected events and selected branches to a new output file.
7 loizides 1.1 //
8     // Authors: C.Paus, C.Loizides
9     //--------------------------------------------------------------------------------------------------
10    
11     #ifndef MITANA_TREEMOD_OUTPUTMOD_H
12     #define MITANA_TREEMOD_OUTPUTMOD_H
13    
14     #include "MitAna/TreeMod/interface/BaseMod.h"
15     #include "MitAna/DataTree/interface/Collections.h"
16     #include <TString.h>
17     #include <TRegexp.h>
18 loizides 1.3 #include <map>
19 loizides 1.1
20     namespace mithep
21     {
22     class TreeWriter;
23     class EventHeader;
24 loizides 1.2 class RunInfo;
25     class LAHeader;
26     class HLTFwkMod;
27 loizides 1.1
28     class OutputMod : public BaseMod
29     {
30     public:
31     OutputMod(const char *name = "OutputMod", const char *title = "Output module");
32     ~OutputMod() {}
33    
34     void Drop(const char *bname);
35     void Keep(const char *bname);
36 loizides 1.2 void CheckTamBranches(Bool_t b) { fCheckTamBr = b; }
37     void KeepTamBranches(Bool_t b) { fKeepTamBr = b; }
38 loizides 1.3 void SetTreeName(const char *name) { fTreeName = name; }
39     void SetFileName(const char *name) { fPrefix = name; }
40     void SetPathName(const char *name) { fPathName = name; }
41     void SetMaxFileSize(UInt_t m) { fMaxSize = m; }
42     void SetDefCompression(UInt_t l) { fCompLevel = l; }
43     void SetDefSplitLevel(UInt_t l) { fSplitLevel = l; }
44     void SetDefBranchSize(UInt_t s) { fBranchSize = s; }
45 loizides 1.1
46     protected:
47     void BeginRun();
48 loizides 1.3 Bool_t Notify();
49 loizides 1.1 void Process();
50 loizides 1.3 void ProcessAll();
51 loizides 1.1 void SlaveBegin();
52     void SlaveTerminate();
53    
54 loizides 1.2 TString fTreeName; //tree name
55 loizides 1.3 TString fPrefix; //file prefix for filename
56     TString fPathName; //path name to be used
57     UInt_t fMaxSize; //maximum file size [MB]
58     UInt_t fCompLevel; //compression levels
59     UInt_t fSplitLevel; //default split levels
60     UInt_t fBranchSize; //default branch sizes [Byte]
61 loizides 1.2 Bool_t fDoReset; //=true then reset pointers
62     Bool_t fCheckTamBr; //=true then check TAM loaded branches
63     Bool_t fKeepTamBr; //=true then keep TAM loaded branches
64     StringVec fCmdList; //list of keep/drop statements
65 loizides 1.1
66     private:
67     void CheckAndAddBranch(const char *bname, const char *cname);
68 loizides 1.2 void CheckAndResolveDep(Bool_t solve=kFALSE);
69 loizides 1.1 Bool_t IsAcceptedBranch(const char *bname);
70 loizides 1.3 void FillAllEventHeader(Bool_t isremoved);
71     void FillL1Info();
72     void FillHltInfo();
73 loizides 1.2 UInt_t GetNBranches() const { return fBrNameList.Entries(); }
74 loizides 1.1 void LoadBranches();
75     void RequestBranch(const char *bname);
76     void SetupBranches();
77    
78 loizides 1.3 TreeWriter *fTreeWriter; //!tree writer holding trees and writing the files
79     EventHeader *fEventHeader; //!my event header (written)
80     EventHeader *fAllEventHeader; //!my all event header (written)
81     RunInfo *fRunInfo; //!my run info
82     LAHeader *fLaHeader; //!my look ahead header
83     std::vector<TRegexp> fCmdReList; //!branch list from fCmdList
84     std::vector<Bool_t> fCmdDeList; //!keep/drop list from fCmdList
85     StringVec fBrNameList; //!branch list to be kept
86     StringVec fBrClassList; //!corresponding class list
87     TObject** fBranches; //!branches to be written
88     const UInt_t fNBranchesMax; //!maximum number of supported top-level branches
89     TTree *fRunTree; //!runinfo tree
90     TTree *fLATree; //!look-ahead tree
91     TTree *fAllTree; //!all-event-header tree
92     TTree *fAllTreeIn; //!all-event-header tree (input)
93     TTree *fL1Tree; //L1 trigger tree (not owned)
94     TTree *fHltTree; //HLT trigger tree (not owned)
95     Int_t fRunEntries; //number of run info entries
96     std::map<UInt_t,Int_t> fRunmap; //map between run number and entry number
97     Int_t fOrigL1Entry; //entry for original tree when table was copied
98     Int_t fL1Entries; //number of l1 info entries
99     Int_t fOrigHltEntry; //entry for original tree when table was copied
100     Int_t fHltEntries; //number of hlt info entries
101     UShort_t fFileNum; //file number of current file
102    
103     friend class Selector;
104 loizides 1.1
105     ClassDef(OutputMod,1) // Output module
106     };
107     }
108    
109     //--------------------------------------------------------------------------------------------------
110     inline void mithep::OutputMod::Drop(const char *bname)
111     {
112     // Add branch name to be dropped (can be regular expression)
113    
114     fCmdList.AddCopy(std::string(Form("drop %s", bname)));
115     }
116    
117     //--------------------------------------------------------------------------------------------------
118     inline void mithep::OutputMod::Keep(const char *bname)
119     {
120     // Add branch name to be kept (can be regular expression)
121    
122     fCmdList.AddCopy(std::string(Form("keep %s", bname)));
123     }
124     #endif