ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/interface/OutputMod.h
Revision: 1.12
Committed: Fri Jul 17 20:47:42 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010
Branch point for: Mit_025c_branch
Changes since 1.11: +9 -8 lines
Log Message:
Added support for arbitrary collections.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: OutputMod.h,v 1.11 2009/07/17 19:18:34 loizides Exp $
3 //
4 // OutputMod
5 //
6 // This TAM module writes selected events and selected branches to a new output file.
7 //
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/EventHeaderFwd.h"
16 #include <map>
17 #include <string>
18 #include <vector>
19 #include <TString.h>
20 #include <TRegexp.h>
21
22 namespace mithep
23 {
24 class TreeWriter;
25 class EventHeader;
26 class RunInfo;
27 class LAHeader;
28 class HLTFwkMod;
29 class BranchTable;
30
31 class OutputMod : public BaseMod
32 {
33 public:
34 OutputMod(const char *name = "OutputMod", const char *title = "Output module");
35
36 void AddNewBranch(const char *bname);
37 void Drop(const char *bname);
38 void Keep(const char *bname);
39 void SetCheckBrDep(Bool_t b) { fCheckBrDep = b; }
40 void SetDefBranchSize(UInt_t s) { fBranchSize = s; }
41 void SetDefCompression(UInt_t l) { fCompLevel = l; }
42 void SetDefSplitLevel(UInt_t l) { fSplitLevel = l; }
43 void SetFileName(const char *n) { fPrefix = n; }
44 void SetMaxFileSize(UInt_t m) { fMaxSize = m; }
45 void SetPathName(const char *n) { fPathName = n; }
46 void SetTreeName(const char *n) { fTreeName = n; }
47 void SetUseBrDep(Bool_t b) { fUseBrDep = b; }
48
49 protected:
50 void BeginRun();
51 void EndRun();
52 Bool_t Notify();
53 void Process();
54 void ProcessAll();
55 void SlaveBegin();
56 void SlaveTerminate();
57
58 TString fTreeName; //tree name
59 TString fPrefix; //file prefix for filename
60 TString fPathName; //path name to be used
61 UInt_t fMaxSize; //maximum file size [MB]
62 UInt_t fCompLevel; //compression levels
63 UInt_t fSplitLevel; //default split levels
64 UInt_t fBranchSize; //default branch sizes [Byte]
65 Bool_t fDoReset; //=true then reset pointers
66 Bool_t fCheckBrDep; //=true then check branch dependencies
67 Bool_t fUseBrDep; //=true then resolve branch dependencies
68 Bool_t fCheckTamBr; //=true then check TAM loaded branches
69 Bool_t fKeepTamBr; //=true then keep TAM loaded branches
70 std::vector<std::string> fCmdList; //list of keep/drop statements
71 std::vector<std::string> fAddList; //list of additional branches
72
73 private:
74 void CheckAndAddBranch(const char *bname, const char *cname);
75 Bool_t CheckAndResolveBranchDep();
76 void CheckAndResolveTAMDep(Bool_t solve=kFALSE);
77 Bool_t IsAcceptedBranch(const char *bname);
78 void FillAllEventHeader(Bool_t isremoved);
79 void FillHltInfo();
80 UInt_t GetNBranches() const { return fBrNameList.size(); }
81 void LoadBranches();
82 void RequestBranches();
83 void SetupBranches();
84
85 TreeWriter *fTreeWriter; //!tree writer holding trees + writing the files
86 EventHeader *fEventHeader; //!my event header (written)
87 EventHeader *fAllEventHeader; //!my all event header (written)
88 RunInfo *fRunInfo; //!my run info
89 LAHeader *fLaHeader; //!my look ahead header
90 BranchTable *fBranchTable; //!my branch table
91 std::vector<TRegexp> fCmdReList; //!branch list from fCmdList
92 std::vector<Bool_t> fCmdDeList; //!keep/drop list from fCmdList
93 std::vector<std::string> fBrNameList; //!branch list to be kept
94 std::vector<std::string> fBrClassList; //!corresponding class list
95 TObject** fBranches; //!branches to be written
96 const UInt_t fNBranchesMax; //!max number of supported top-level branches
97 TTree *fRunTree; //!runinfo tree
98 TTree *fLATree; //!look-ahead tree
99 TTree *fAllTree; //!all-event-header tree
100 const EventHeaderCol *fSkimmedIn; //!skimmed event headers (input)
101 TTree *fHltTree; //!HLT trigger tree (not owned)
102 std::vector<std::string> *fHLTTab; //!HLT trigger names
103 std::vector<std::string> *fHLTLab; //!HLT module labels
104 Int_t fRunEntries; //!number of run info entries
105 std::map<UInt_t,Int_t> fRunmap; //!map between run number and entry number
106 Int_t fHltEntries; //!number of hlt info entries
107 Short_t fFileNum; //!file number of current file
108 Long64_t fLastWrittenEvt; //!entry of last written event
109 Long64_t fLastSeenEvt; //!entry of last seen event
110 Long64_t fCounter; //!count number of events
111
112 friend class Selector;
113
114 ClassDef(OutputMod, 1) // Output module
115 };
116 }
117
118 //--------------------------------------------------------------------------------------------------
119 inline void mithep::OutputMod::AddNewBranch(const char *bname)
120 {
121 // Add new branch with given name. The content is taken
122 // from the public object list.
123
124 fAddList.push_back(std::string(bname));
125 }
126
127 //--------------------------------------------------------------------------------------------------
128 inline void mithep::OutputMod::Drop(const char *bname)
129 {
130 // Add branch name to be dropped (can be regular expression)
131
132 fCmdList.push_back(std::string(Form("drop %s", bname)));
133 }
134
135 //--------------------------------------------------------------------------------------------------
136 inline void mithep::OutputMod::Keep(const char *bname)
137 {
138 // Add branch name to be kept (can be regular expression)
139
140 fCmdList.push_back(std::string(Form("keep %s", bname)));
141 }
142 #endif