ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/interface/BaseMod.h
Revision: 1.16
Committed: Mon Mar 23 22:15:13 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008
Changes since 1.15: +1 -2 lines
Log Message:
Cosmetics

File Contents

# User Rev Content
1 loizides 1.6 //--------------------------------------------------------------------------------------------------
2 loizides 1.16 // $Id: BaseMod.h,v 1.15 2008/12/10 14:20:26 loizides Exp $
3 loizides 1.2 //
4     // BaseMod
5     //
6 loizides 1.8 // This TAM module is the base module for all our TAM modules. It defines a couple of useful
7     // getters to retrieve information from the underlying framework code, such as the EventHeader,
8     // RunInfo or Trigger information.
9 loizides 1.2 //
10     // Authors: C.Loizides
11 loizides 1.6 //--------------------------------------------------------------------------------------------------
12 loizides 1.2
13 loizides 1.7 #ifndef MITANA_TREEMOD_BASEMOD_H
14     #define MITANA_TREEMOD_BASEMOD_H
15 loizides 1.1
16     #include "MitAna/TAM/interface/TAModule.h"
17 loizides 1.8 #include "MitAna/TreeMod/interface/Selector.h"
18     #include "MitAna/DataTree/interface/Collections.h"
19     #include "MitAna/DataTree/interface/TriggerName.h"
20     #include "MitAna/DataTree/interface/TriggerObject.h"
21 loizides 1.1
22     namespace mithep
23     {
24 loizides 1.5 class Selector;
25 loizides 1.12 class HLTFwkMod;
26 loizides 1.5
27 loizides 1.1 class BaseMod : public TAModule {
28     public:
29 loizides 1.12 BaseMod(const char *name="BaseMod", const char *title="Base analysis module");
30 loizides 1.4
31     protected:
32 loizides 1.14 template <class T> void AddTH1(T *&ptr, const char *name, const char *title,
33     Int_t nbins, Double_t xmin, Double_t xmax);
34     template <class T> void AddTH2(T *&ptr, const char *name, const char *title,
35     Int_t nbinsx, Double_t xmin, Double_t xmax,
36     Int_t nbinsy, Double_t ymin, Double_t ymax);
37     void IncNEventsProcessed() { ++fNEventsProc; }
38 loizides 1.9 const EventHeader *GetEventHeader() const { return GetSel()->GetEventHeader(); }
39 loizides 1.14 Bool_t GetFillHist() const { return fFillHist; }
40 loizides 1.12 const HLTFwkMod *GetHltFwkMod() const { return fHltFwkMod; }
41     const TriggerObjectCol *GetHLTObjects(const char *name) const;
42     const TriggerObjectsTable *GetHLTObjectsTable() const;
43     const TriggerTable *GetHLTTable() const;
44 loizides 1.14 Int_t GetNEventsProcessed() const { return fNEventsProc; }
45 loizides 1.13 template <class T> const T *GetObjThisEvt(const char *name) const;
46 loizides 1.10 template <class T> T *GetObjThisEvt(const char *name);
47 loizides 1.13 template <class T> const T *GetPublicObj(const char *name) const;
48 loizides 1.10 template <class T> T *GetPublicObj(const char *name);
49 loizides 1.9 const RunInfo *GetRunInfo() const { return GetSel()->GetRunInfo(); }
50     const Selector *GetSel() const;
51 loizides 1.12 Bool_t HasHLTInfo() const;
52 loizides 1.13 template <class T> void ReqBranch(const char *bname, const T *&address);
53 loizides 1.9 Bool_t ValidRunInfo() const { return GetSel()->ValidRunInfo(); }
54     void SaveNEventsProcessed(const char *name="hDEvents");
55 loizides 1.14 void SetFillHist(Bool_t b) { fFillHist = b; }
56 loizides 1.9
57     private:
58 loizides 1.14 Bool_t fFillHist; //=true then fill histos (def=0)
59 loizides 1.12 mutable const HLTFwkMod *fHltFwkMod; //!pointer to HLTFwdMod
60     const TString fHltFwkModName; //!name of HLTFwkMod
61 loizides 1.14 Int_t fNEventsProc; //!number of events
62 loizides 1.1
63 loizides 1.15 ClassDef(BaseMod, 1) // Base TAM module
64 loizides 1.1 };
65 loizides 1.6 }
66 loizides 1.4
67 loizides 1.6 //--------------------------------------------------------------------------------------------------
68 loizides 1.14 template <class T>
69     inline void mithep::BaseMod::AddTH1(T *&ptr, const char *name, const char *title,
70     Int_t nbins, Double_t xmin, Double_t xmax)
71     {
72     // Create ROOT histogram and add it to the output list.
73    
74     ptr = new T(name, title, nbins, xmin, xmax);
75     ptr->Sumw2();
76     AddOutput(ptr);
77     }
78    
79     //--------------------------------------------------------------------------------------------------
80     template <class T>
81     inline void mithep::BaseMod::AddTH2(T *&ptr, const char *name, const char *title,
82     Int_t nbinsx, Double_t xmin, Double_t xmax,
83     Int_t nbinsy, Double_t ymin, Double_t ymax)
84     {
85     // Create ROOT histogram and add it to the output list.
86    
87     ptr = new T(name, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
88     ptr->Sumw2();
89     AddOutput(ptr);
90     }
91    
92     //--------------------------------------------------------------------------------------------------
93 loizides 1.8 inline const mithep::TriggerObjectCol *mithep::BaseMod::GetHLTObjects(const char *name) const
94     {
95     // Get pointer to HLT TriggerObjects collection with given name for the current event.
96    
97     return (dynamic_cast<const TriggerObjectCol *>(FindObjThisEvt(name)));
98     }
99    
100     //--------------------------------------------------------------------------------------------------
101 loizides 1.10 template <class T>
102 loizides 1.13 inline const T *mithep::BaseMod::GetObjThisEvt(const char *name) const
103     {
104     // Get published object for the current event.
105    
106     T *ret = dynamic_cast<T*>(FindObjThisEvt(name));
107     if (!ret) {
108     SendError(kWarning, "GetObjThisEvent",
109     "Could not obtain object with name %s and type %s for current event!",
110     name, T::Class_Name());
111     }
112     return ret;
113     }
114    
115     //--------------------------------------------------------------------------------------------------
116     template <class T>
117 loizides 1.10 inline T *mithep::BaseMod::GetObjThisEvt(const char *name)
118     {
119     // Get published object for the current event.
120    
121     T *ret = dynamic_cast<T*>(FindObjThisEvt(name));
122     if (!ret) {
123     SendError(kWarning, "GetObjThisEvent",
124     "Could not obtain object with name %s and type %s for current event!",
125     name, T::Class_Name());
126     }
127     return ret;
128     }
129    
130     //--------------------------------------------------------------------------------------------------
131     template <class T>
132 loizides 1.13 inline const T *mithep::BaseMod::GetPublicObj(const char *name) const
133     {
134     // Get public object.
135    
136    
137     T *ret = dynamic_cast<T*>(FindPublicObj(name));
138     if (!ret) {
139     SendError(kWarning, "GetPublicObject",
140     "Could not obtain public object with name %s and type %s!",
141     name, T::Class_Name());
142     }
143     return ret;
144     }
145    
146     //--------------------------------------------------------------------------------------------------
147     template <class T>
148 loizides 1.10 inline T *mithep::BaseMod::GetPublicObj(const char *name)
149     {
150     // Get public object.
151    
152 loizides 1.11
153 loizides 1.10 T *ret = dynamic_cast<T*>(FindPublicObj(name));
154     if (!ret) {
155     SendError(kWarning, "GetPublicObject",
156     "Could not obtain public object with name %s and type %s!",
157     name, T::Class_Name());
158     }
159     return ret;
160     }
161    
162     //--------------------------------------------------------------------------------------------------
163 loizides 1.6 inline const mithep::Selector *mithep::BaseMod::GetSel() const
164     {
165 loizides 1.8 // Get pointer to selector.
166    
167 loizides 1.6 return static_cast<const Selector*>(GetSelector());
168 loizides 1.1 }
169 loizides 1.13
170     //--------------------------------------------------------------------------------------------------
171     template <class T>
172     inline void mithep::BaseMod::ReqBranch(const char *bname, const T *&address)
173     {
174     // Requests that the branch with the specified name be made available
175     // during processing and that it be read in to the address specified.
176    
177     TAModule::ReqBranch(bname, const_cast<T*&>(address));
178     }
179 loizides 1.1 #endif