ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/interface/OutputMod.h
Revision: 1.11
Committed: Fri Jul 17 19:18:34 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.10: +17 -10 lines
Log Message:
First attempt to store add output. NOt finished.

File Contents

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