1 |
loizides |
1.6 |
//--------------------------------------------------------------------------------------------------
|
2 |
phedex |
1.17 |
// $Id: BaseMod.h,v 1.16 2009/03/23 22:15:13 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 |
phedex |
1.17 |
template <class T> void AddTH3(T *&ptr, const char *name, const char *title,
|
38 |
|
|
Int_t nbinsx, Double_t xmin, Double_t xmax,
|
39 |
|
|
Int_t nbinsy, Double_t ymin, Double_t ymax,
|
40 |
|
|
Int_t nbinsz, Double_t zmin, Double_t zmax);
|
41 |
loizides |
1.14 |
void IncNEventsProcessed() { ++fNEventsProc; }
|
42 |
loizides |
1.9 |
const EventHeader *GetEventHeader() const { return GetSel()->GetEventHeader(); }
|
43 |
loizides |
1.14 |
Bool_t GetFillHist() const { return fFillHist; }
|
44 |
loizides |
1.12 |
const HLTFwkMod *GetHltFwkMod() const { return fHltFwkMod; }
|
45 |
|
|
const TriggerObjectCol *GetHLTObjects(const char *name) const;
|
46 |
|
|
const TriggerObjectsTable *GetHLTObjectsTable() const;
|
47 |
|
|
const TriggerTable *GetHLTTable() const;
|
48 |
loizides |
1.14 |
Int_t GetNEventsProcessed() const { return fNEventsProc; }
|
49 |
loizides |
1.13 |
template <class T> const T *GetObjThisEvt(const char *name) const;
|
50 |
loizides |
1.10 |
template <class T> T *GetObjThisEvt(const char *name);
|
51 |
loizides |
1.13 |
template <class T> const T *GetPublicObj(const char *name) const;
|
52 |
loizides |
1.10 |
template <class T> T *GetPublicObj(const char *name);
|
53 |
loizides |
1.9 |
const RunInfo *GetRunInfo() const { return GetSel()->GetRunInfo(); }
|
54 |
|
|
const Selector *GetSel() const;
|
55 |
loizides |
1.12 |
Bool_t HasHLTInfo() const;
|
56 |
loizides |
1.13 |
template <class T> void ReqBranch(const char *bname, const T *&address);
|
57 |
loizides |
1.9 |
Bool_t ValidRunInfo() const { return GetSel()->ValidRunInfo(); }
|
58 |
|
|
void SaveNEventsProcessed(const char *name="hDEvents");
|
59 |
loizides |
1.14 |
void SetFillHist(Bool_t b) { fFillHist = b; }
|
60 |
loizides |
1.9 |
|
61 |
|
|
private:
|
62 |
loizides |
1.14 |
Bool_t fFillHist; //=true then fill histos (def=0)
|
63 |
loizides |
1.12 |
mutable const HLTFwkMod *fHltFwkMod; //!pointer to HLTFwdMod
|
64 |
|
|
const TString fHltFwkModName; //!name of HLTFwkMod
|
65 |
loizides |
1.14 |
Int_t fNEventsProc; //!number of events
|
66 |
loizides |
1.1 |
|
67 |
loizides |
1.15 |
ClassDef(BaseMod, 1) // Base TAM module
|
68 |
loizides |
1.1 |
};
|
69 |
loizides |
1.6 |
}
|
70 |
loizides |
1.4 |
|
71 |
loizides |
1.6 |
//--------------------------------------------------------------------------------------------------
|
72 |
loizides |
1.14 |
template <class T>
|
73 |
|
|
inline void mithep::BaseMod::AddTH1(T *&ptr, const char *name, const char *title,
|
74 |
|
|
Int_t nbins, Double_t xmin, Double_t xmax)
|
75 |
|
|
{
|
76 |
|
|
// Create ROOT histogram and add it to the output list.
|
77 |
|
|
|
78 |
|
|
ptr = new T(name, title, nbins, xmin, xmax);
|
79 |
|
|
ptr->Sumw2();
|
80 |
|
|
AddOutput(ptr);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
//--------------------------------------------------------------------------------------------------
|
84 |
|
|
template <class T>
|
85 |
|
|
inline void mithep::BaseMod::AddTH2(T *&ptr, const char *name, const char *title,
|
86 |
|
|
Int_t nbinsx, Double_t xmin, Double_t xmax,
|
87 |
|
|
Int_t nbinsy, Double_t ymin, Double_t ymax)
|
88 |
|
|
{
|
89 |
|
|
// Create ROOT histogram and add it to the output list.
|
90 |
|
|
|
91 |
|
|
ptr = new T(name, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
|
92 |
|
|
ptr->Sumw2();
|
93 |
|
|
AddOutput(ptr);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
//--------------------------------------------------------------------------------------------------
|
97 |
phedex |
1.17 |
template <class T>
|
98 |
|
|
inline void mithep::BaseMod::AddTH3(T *&ptr, const char *name, const char *title,
|
99 |
|
|
Int_t nbinsx, Double_t xmin, Double_t xmax,
|
100 |
|
|
Int_t nbinsy, Double_t ymin, Double_t ymax,
|
101 |
|
|
Int_t nbinsz, Double_t zmin, Double_t zmax)
|
102 |
|
|
{
|
103 |
|
|
// Create ROOT histogram and add it to the output list.
|
104 |
|
|
|
105 |
|
|
ptr = new T(name, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax, nbinsz, zmin, zmax);
|
106 |
|
|
ptr->Sumw2();
|
107 |
|
|
AddOutput(ptr);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
//--------------------------------------------------------------------------------------------------
|
111 |
loizides |
1.8 |
inline const mithep::TriggerObjectCol *mithep::BaseMod::GetHLTObjects(const char *name) const
|
112 |
|
|
{
|
113 |
|
|
// Get pointer to HLT TriggerObjects collection with given name for the current event.
|
114 |
|
|
|
115 |
|
|
return (dynamic_cast<const TriggerObjectCol *>(FindObjThisEvt(name)));
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
//--------------------------------------------------------------------------------------------------
|
119 |
loizides |
1.10 |
template <class T>
|
120 |
loizides |
1.13 |
inline const T *mithep::BaseMod::GetObjThisEvt(const char *name) const
|
121 |
|
|
{
|
122 |
|
|
// Get published object for the current event.
|
123 |
|
|
|
124 |
|
|
T *ret = dynamic_cast<T*>(FindObjThisEvt(name));
|
125 |
|
|
if (!ret) {
|
126 |
|
|
SendError(kWarning, "GetObjThisEvent",
|
127 |
|
|
"Could not obtain object with name %s and type %s for current event!",
|
128 |
|
|
name, T::Class_Name());
|
129 |
|
|
}
|
130 |
|
|
return ret;
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
//--------------------------------------------------------------------------------------------------
|
134 |
|
|
template <class T>
|
135 |
loizides |
1.10 |
inline T *mithep::BaseMod::GetObjThisEvt(const char *name)
|
136 |
|
|
{
|
137 |
|
|
// Get published object for the current event.
|
138 |
|
|
|
139 |
|
|
T *ret = dynamic_cast<T*>(FindObjThisEvt(name));
|
140 |
|
|
if (!ret) {
|
141 |
|
|
SendError(kWarning, "GetObjThisEvent",
|
142 |
|
|
"Could not obtain object with name %s and type %s for current event!",
|
143 |
|
|
name, T::Class_Name());
|
144 |
|
|
}
|
145 |
|
|
return ret;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
//--------------------------------------------------------------------------------------------------
|
149 |
|
|
template <class T>
|
150 |
loizides |
1.13 |
inline const T *mithep::BaseMod::GetPublicObj(const char *name) const
|
151 |
|
|
{
|
152 |
|
|
// Get public object.
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
T *ret = dynamic_cast<T*>(FindPublicObj(name));
|
156 |
|
|
if (!ret) {
|
157 |
|
|
SendError(kWarning, "GetPublicObject",
|
158 |
|
|
"Could not obtain public object with name %s and type %s!",
|
159 |
|
|
name, T::Class_Name());
|
160 |
|
|
}
|
161 |
|
|
return ret;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
//--------------------------------------------------------------------------------------------------
|
165 |
|
|
template <class T>
|
166 |
loizides |
1.10 |
inline T *mithep::BaseMod::GetPublicObj(const char *name)
|
167 |
|
|
{
|
168 |
|
|
// Get public object.
|
169 |
|
|
|
170 |
loizides |
1.11 |
|
171 |
loizides |
1.10 |
T *ret = dynamic_cast<T*>(FindPublicObj(name));
|
172 |
|
|
if (!ret) {
|
173 |
|
|
SendError(kWarning, "GetPublicObject",
|
174 |
|
|
"Could not obtain public object with name %s and type %s!",
|
175 |
|
|
name, T::Class_Name());
|
176 |
|
|
}
|
177 |
|
|
return ret;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
//--------------------------------------------------------------------------------------------------
|
181 |
loizides |
1.6 |
inline const mithep::Selector *mithep::BaseMod::GetSel() const
|
182 |
|
|
{
|
183 |
loizides |
1.8 |
// Get pointer to selector.
|
184 |
|
|
|
185 |
loizides |
1.6 |
return static_cast<const Selector*>(GetSelector());
|
186 |
loizides |
1.1 |
}
|
187 |
loizides |
1.13 |
|
188 |
|
|
//--------------------------------------------------------------------------------------------------
|
189 |
|
|
template <class T>
|
190 |
|
|
inline void mithep::BaseMod::ReqBranch(const char *bname, const T *&address)
|
191 |
|
|
{
|
192 |
|
|
// Requests that the branch with the specified name be made available
|
193 |
|
|
// during processing and that it be read in to the address specified.
|
194 |
|
|
|
195 |
|
|
TAModule::ReqBranch(bname, const_cast<T*&>(address));
|
196 |
|
|
}
|
197 |
loizides |
1.1 |
#endif
|