ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/interface/OutputMod.h
Revision: 1.4
Committed: Thu Dec 4 13:55:06 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.3: +15 -11 lines
Log Message:
First validated version of OutputMod.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.4 // $Id: OutputMod.h,v 1.3 2008/12/03 17:44:05 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.4 void EndRun();
49 loizides 1.3 Bool_t Notify();
50 loizides 1.1 void Process();
51 loizides 1.3 void ProcessAll();
52 loizides 1.1 void SlaveBegin();
53     void SlaveTerminate();
54    
55 loizides 1.2 TString fTreeName; //tree name
56 loizides 1.3 TString fPrefix; //file prefix for filename
57     TString fPathName; //path name to be used
58     UInt_t fMaxSize; //maximum file size [MB]
59     UInt_t fCompLevel; //compression levels
60     UInt_t fSplitLevel; //default split levels
61     UInt_t fBranchSize; //default branch sizes [Byte]
62 loizides 1.2 Bool_t fDoReset; //=true then reset pointers
63     Bool_t fCheckTamBr; //=true then check TAM loaded branches
64     Bool_t fKeepTamBr; //=true then keep TAM loaded branches
65     StringVec fCmdList; //list of keep/drop statements
66 loizides 1.1
67     private:
68     void CheckAndAddBranch(const char *bname, const char *cname);
69 loizides 1.2 void CheckAndResolveDep(Bool_t solve=kFALSE);
70 loizides 1.1 Bool_t IsAcceptedBranch(const char *bname);
71 loizides 1.3 void FillAllEventHeader(Bool_t isremoved);
72     void FillL1Info();
73     void FillHltInfo();
74 loizides 1.4 UInt_t GetNBranches() const { return fBrNameList.Entries(); }
75 loizides 1.1 void LoadBranches();
76     void RequestBranch(const char *bname);
77     void SetupBranches();
78    
79 loizides 1.3 TreeWriter *fTreeWriter; //!tree writer holding trees and writing the files
80     EventHeader *fEventHeader; //!my event header (written)
81     EventHeader *fAllEventHeader; //!my all event header (written)
82     RunInfo *fRunInfo; //!my run info
83     LAHeader *fLaHeader; //!my look ahead header
84     std::vector<TRegexp> fCmdReList; //!branch list from fCmdList
85     std::vector<Bool_t> fCmdDeList; //!keep/drop list from fCmdList
86     StringVec fBrNameList; //!branch list to be kept
87     StringVec fBrClassList; //!corresponding class list
88     TObject** fBranches; //!branches to be written
89     const UInt_t fNBranchesMax; //!maximum number of supported top-level branches
90     TTree *fRunTree; //!runinfo tree
91     TTree *fLATree; //!look-ahead tree
92     TTree *fAllTree; //!all-event-header tree
93     TTree *fAllTreeIn; //!all-event-header tree (input)
94 loizides 1.4 TTree *fL1Tree; //!L1 trigger tree (not owned)
95     TTree *fHltTree; //!HLT trigger tree (not owned)
96     Int_t fRunEntries; //!number of run info entries
97     std::map<UInt_t,Int_t> fRunmap; //!map between run number and entry number
98     Int_t fOrigL1Entry; //!entry for original tree when table was copied
99     Int_t fL1Entries; //!number of l1 info entries
100     Int_t fOrigHltEntry; //!entry for original tree when table was copied
101     Int_t fHltEntries; //!number of hlt info entries
102     UShort_t fFileNum; //!file number of current file
103     Long64_t fLastWrittenEvt; //!entry of last written event
104     Long64_t fLastSeenEvt; //!entry of last seen event
105     Long64_t fCounter; //!count number of events
106 loizides 1.3
107     friend class Selector;
108 loizides 1.1
109     ClassDef(OutputMod,1) // Output module
110     };
111     }
112    
113     //--------------------------------------------------------------------------------------------------
114     inline void mithep::OutputMod::Drop(const char *bname)
115     {
116     // Add branch name to be dropped (can be regular expression)
117    
118     fCmdList.AddCopy(std::string(Form("drop %s", bname)));
119     }
120    
121     //--------------------------------------------------------------------------------------------------
122     inline void mithep::OutputMod::Keep(const char *bname)
123     {
124     // Add branch name to be kept (can be regular expression)
125    
126     fCmdList.AddCopy(std::string(Form("keep %s", bname)));
127     }
128     #endif