CMS 3D CMS Logo

RunHistogramManager.h
Go to the documentation of this file.
1 #ifndef DPGAnalysis_SiStripTools_RunHistogramManager_H
2 #define DPGAnalysis_SiStripTools_RunHistogramManager_H
3 
4 #include <vector>
5 #include <map>
6 #include <string>
12 #include "TH2F.h"
13 #include "TProfile2D.h"
14 
15 class TH1F;
16 class TProfile;
17 
19 public:
21  virtual ~BaseHistoParams();
22 
23  // virtual void beginRun(const edm::Run& iRun, TFileDirectory& subrun);
24  virtual void beginRun(const unsigned int irun, TFileDirectory& subrun, const char* fillrun) = 0;
25 };
26 
27 template <class T>
28 class HistoParams : public BaseHistoParams {
29 public:
30  HistoParams(T** pointer,
31  const std::string type,
32  const std::string name,
33  const std::string title,
34  const unsigned int nbinx = -1,
35  const double xmin = -1.,
36  const double xmax = -1.,
37  const unsigned int nbiny = -1,
38  const double ymin = -1.,
39  const double ymax = -1.)
40  : BaseHistoParams(),
41  _pointer(pointer),
42  _type(type),
43  _name(name),
44  _title(title),
45  _nbinx(nbinx),
46  _xmin(xmin),
47  _xmax(xmax),
48  _nbiny(nbiny),
49  _ymin(ymin),
50  _ymax(ymax),
51  _runpointers() {}
52 
53  ~HistoParams() override {
54  delete _pointer;
55  LogDebug("Destructor") << "Destroy " << _name;
56  }
57 
58  void beginRun(const unsigned int irun, TFileDirectory& subrun, const char* fillrun) override {
59  if (_runpointers.find(irun) != _runpointers.end()) {
60  *_pointer = _runpointers[irun];
61  LogDebug("TH1Fbooked") << "Histogram " << _name.c_str() << " already exists " << _runpointers[irun];
62 
63  } else {
64  char title[400];
65  sprintf(title, "%s %s %d", _title.c_str(), fillrun, irun);
66 
67  _runpointers[irun] = subrun.make<T>(_name.c_str(), title, _nbinx, _xmin, _xmax);
68 
69  *_pointer = _runpointers[irun];
70  LogDebug("TH1Fbooked") << "Histogram " << _name.c_str() << " booked " << _runpointers[irun];
71  }
72  }
73 
74 private:
79  unsigned int _nbinx;
80  double _xmin;
81  double _xmax;
82  unsigned int _nbiny;
83  double _ymin;
84  double _ymax;
85  std::map<unsigned int, T*> _runpointers;
86 };
87 
88 template <>
89 class HistoParams<TH2F> : public BaseHistoParams {
90 public:
91  HistoParams(TH2F** pointer,
92  const std::string type,
93  const std::string name,
94  const std::string title,
95  const unsigned int nbinx = -1,
96  const double xmin = -1.,
97  const double xmax = -1.,
98  const unsigned int nbiny = -1,
99  const double ymin = -1.,
100  const double ymax = -1.)
101  : BaseHistoParams(),
102  _pointer(pointer),
103  _type(type),
104  _name(name),
105  _title(title),
106  _nbinx(nbinx),
107  _xmin(xmin),
108  _xmax(xmax),
109  _nbiny(nbiny),
110  _ymin(ymin),
111  _ymax(ymax),
112  _runpointers() {}
113 
114  ~HistoParams() override {
115  delete _pointer;
116  LogDebug("TH2FDestructor") << "Destroy " << _name;
117  }
118 
119  void beginRun(const unsigned int irun, TFileDirectory& subrun, const char* fillrun) override {
120  if (_runpointers.find(irun) != _runpointers.end()) {
121  *_pointer = _runpointers[irun];
122  LogDebug("TH2Fbooked") << "Histogram " << _name.c_str() << " already exists " << _runpointers[irun];
123 
124  } else {
125  char title[400];
126  sprintf(title, "%s %s %d", _title.c_str(), fillrun, irun);
127 
128  _runpointers[irun] = subrun.make<TH2F>(_name.c_str(), title, _nbinx, _xmin, _xmax, _nbiny, _ymin, _ymax);
129 
130  *_pointer = _runpointers[irun];
131  LogDebug("TH2Fbooked") << "Histogram " << _name.c_str() << " booked " << _runpointers[irun];
132  }
133  }
134 
135 private:
136  TH2F** _pointer;
140  unsigned int _nbinx;
141  double _xmin;
142  double _xmax;
143  unsigned int _nbiny;
144  double _ymin;
145  double _ymax;
146  std::map<unsigned int, TH2F*> _runpointers;
147 };
148 
149 template <>
150 class HistoParams<TProfile2D> : public BaseHistoParams {
151 public:
152  HistoParams(TProfile2D** pointer,
153  const std::string type,
154  const std::string name,
155  const std::string title,
156  const unsigned int nbinx = -1,
157  const double xmin = -1.,
158  const double xmax = -1.,
159  const unsigned int nbiny = -1,
160  const double ymin = -1.,
161  const double ymax = -1.)
162  : BaseHistoParams(),
163  _pointer(pointer),
164  _type(type),
165  _name(name),
166  _title(title),
167  _nbinx(nbinx),
168  _xmin(xmin),
169  _xmax(xmax),
170  _nbiny(nbiny),
171  _ymin(ymin),
172  _ymax(ymax),
173  _runpointers() {}
174 
175  ~HistoParams() override {
176  delete _pointer;
177  LogDebug("TProfile2DDestructor") << "Destroy " << _name;
178  }
179 
180  void beginRun(const unsigned int irun, TFileDirectory& subrun, const char* fillrun) override {
181  if (_runpointers.find(irun) != _runpointers.end()) {
182  *_pointer = _runpointers[irun];
183  LogDebug("TProfile2Dbooked") << "Histogram " << _name.c_str() << " already exists " << _runpointers[irun];
184 
185  } else {
186  char title[400];
187  sprintf(title, "%s %s %d", _title.c_str(), fillrun, irun);
188 
189  _runpointers[irun] = subrun.make<TProfile2D>(_name.c_str(), title, _nbinx, _xmin, _xmax, _nbiny, _ymin, _ymax);
190 
191  *_pointer = _runpointers[irun];
192  LogDebug("TProfile2Dbooked") << "Histogram " << _name.c_str() << " booked " << _runpointers[irun];
193  }
194  }
195 
196 private:
197  TProfile2D** _pointer;
201  unsigned int _nbinx;
202  double _xmin;
203  double _xmax;
204  unsigned int _nbiny;
205  double _ymin;
206  double _ymax;
207  std::map<unsigned int, TProfile2D*> _runpointers;
208 };
209 
211 public:
215 
216  TH1F** makeTH1F(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax);
217  TProfile** makeTProfile(
218  const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax);
219  TH2F** makeTH2F(const char* name,
220  const char* title,
221  const unsigned int nbinx,
222  const double xmin,
223  const double xmax,
224  const unsigned int nbiny,
225  const double ymin,
226  const double ymax);
227  TProfile2D** makeTProfile2D(const char* name,
228  const char* title,
229  const unsigned int nbinx,
230  const double xmin,
231  const double xmax,
232  const unsigned int nbiny,
233  const double ymin,
234  const double ymax);
235 
236  void beginRun(const edm::Run& iRun);
237  void beginRun(const edm::Run& iRun, TFileDirectory& subdir);
238  void beginRun(const unsigned int irun);
239  void beginRun(const unsigned int irun, TFileDirectory& subdir);
240 
241 private:
243  std::vector<BaseHistoParams*> _histograms;
245 };
246 
247 #endif // DPGAnalysis_SiStripTools_RunHistogramManager_H
HistoParams
Definition: RunHistogramManager.h:28
HistoParams< TProfile2D >::_runpointers
std::map< unsigned int, TProfile2D * > _runpointers
Definition: RunHistogramManager.h:207
BaseHistoParams::BaseHistoParams
BaseHistoParams()
Definition: RunHistogramManager.cc:11
HistoParams< TProfile2D >::_xmin
double _xmin
Definition: RunHistogramManager.h:202
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
MessageLogger.h
BaseHistoParams::beginRun
virtual void beginRun(const unsigned int irun, TFileDirectory &subrun, const char *fillrun)=0
HistoParams::_title
std::string _title
Definition: RunHistogramManager.h:78
edm::Run
Definition: Run.h:45
HistoParams::_nbinx
unsigned int _nbinx
Definition: RunHistogramManager.h:79
edm::EDGetTokenT< edm::ConditionsInRunBlock >
HistoParams::_ymax
double _ymax
Definition: RunHistogramManager.h:84
TFileDirectory::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileDirectory.h:53
RunHistogramManager::makeTH2F
TH2F ** makeTH2F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
Definition: RunHistogramManager.cc:64
HistoParams< TH2F >::_nbinx
unsigned int _nbinx
Definition: RunHistogramManager.h:140
RPCNoise_cfi.fillHistograms
fillHistograms
Definition: RPCNoise_cfi.py:8
HistoParams::~HistoParams
~HistoParams() override
Definition: RunHistogramManager.h:53
HistoParams< TProfile2D >::~HistoParams
~HistoParams() override
Definition: RunHistogramManager.h:175
HistoParams< TProfile2D >::_nbiny
unsigned int _nbiny
Definition: RunHistogramManager.h:204
HistoParams::_runpointers
std::map< unsigned int, T * > _runpointers
Definition: RunHistogramManager.h:85
HistoParams< TProfile2D >::_title
std::string _title
Definition: RunHistogramManager.h:200
TFileDirectory
Definition: TFileDirectory.h:24
RunHistogramManager::_histograms
std::vector< BaseHistoParams * > _histograms
Definition: RunHistogramManager.h:243
HistoParams< TH2F >::HistoParams
HistoParams(TH2F **pointer, const std::string type, const std::string name, const std::string title, const unsigned int nbinx=-1, const double xmin=-1., const double xmax=-1., const unsigned int nbiny=-1, const double ymin=-1., const double ymax=-1.)
Definition: RunHistogramManager.h:91
HistoParams::HistoParams
HistoParams(T **pointer, const std::string type, const std::string name, const std::string title, const unsigned int nbinx=-1, const double xmin=-1., const double xmax=-1., const unsigned int nbiny=-1, const double ymin=-1., const double ymax=-1.)
Definition: RunHistogramManager.h:30
BaseHistoParams::~BaseHistoParams
virtual ~BaseHistoParams()
Definition: RunHistogramManager.cc:13
HistoParams< TH2F >::_runpointers
std::map< unsigned int, TH2F * > _runpointers
Definition: RunHistogramManager.h:146
HistoParams< TProfile2D >::_ymax
double _ymax
Definition: RunHistogramManager.h:206
RunHistogramManager::_conditionsInRunToken
edm::EDGetTokenT< edm::ConditionsInRunBlock > _conditionsInRunToken
Definition: RunHistogramManager.h:244
RunHistogramManager
Definition: RunHistogramManager.h:210
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
RunHistogramManager::~RunHistogramManager
~RunHistogramManager()
Definition: RunHistogramManager.cc:45
HistoParams< TH2F >::~HistoParams
~HistoParams() override
Definition: RunHistogramManager.h:114
HistoParams< TH2F >::_title
std::string _title
Definition: RunHistogramManager.h:139
BaseHistoParams
Definition: RunHistogramManager.h:18
Run.h
HistoParams< TH2F >::_xmax
double _xmax
Definition: RunHistogramManager.h:142
HistoParams< TH2F >::_ymin
double _ymin
Definition: RunHistogramManager.h:144
HistoParams::_xmin
double _xmin
Definition: RunHistogramManager.h:80
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
RunHistogramManager::makeTH1F
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:33
HistoParams::_pointer
T ** _pointer
Definition: RunHistogramManager.h:75
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
HistoParams::beginRun
void beginRun(const unsigned int irun, TFileDirectory &subrun, const char *fillrun) override
Definition: RunHistogramManager.h:58
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
RunHistogramManager::makeTProfile2D
TProfile2D ** makeTProfile2D(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
Definition: RunHistogramManager.cc:82
HistoParams::_ymin
double _ymin
Definition: RunHistogramManager.h:83
RunHistogramManager::beginRun
void beginRun(const edm::Run &iRun)
Definition: RunHistogramManager.cc:101
HistoParams::_nbiny
unsigned int _nbiny
Definition: RunHistogramManager.h:82
HistoParams< TH2F >::_xmin
double _xmin
Definition: RunHistogramManager.h:141
HistoParams< TProfile2D >::HistoParams
HistoParams(TProfile2D **pointer, const std::string type, const std::string name, const std::string title, const unsigned int nbinx=-1, const double xmin=-1., const double xmax=-1., const unsigned int nbiny=-1, const double ymin=-1., const double ymax=-1.)
Definition: RunHistogramManager.h:152
HistoParams< TProfile2D >::_xmax
double _xmax
Definition: RunHistogramManager.h:203
HistoParams< TH2F >::beginRun
void beginRun(const unsigned int irun, TFileDirectory &subrun, const char *fillrun) override
Definition: RunHistogramManager.h:119
HistoParams< TProfile2D >::_name
std::string _name
Definition: RunHistogramManager.h:199
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
HistoParams< TH2F >::_name
std::string _name
Definition: RunHistogramManager.h:138
ConditionsInEdm.h
T
long double T
Definition: Basic3DVectorLD.h:48
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
HistoParams< TProfile2D >::_ymin
double _ymin
Definition: RunHistogramManager.h:205
HistoParams< TH2F >::_pointer
TH2F ** _pointer
Definition: RunHistogramManager.h:136
HistoParams< TProfile2D >::beginRun
void beginRun(const unsigned int irun, TFileDirectory &subrun, const char *fillrun) override
Definition: RunHistogramManager.h:180
HistoParams< TH2F >::_ymax
double _ymax
Definition: RunHistogramManager.h:145
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
RunHistogramManager::_fillHistograms
bool _fillHistograms
Definition: RunHistogramManager.h:242
HistoParams::_name
std::string _name
Definition: RunHistogramManager.h:77
HistoParams< TProfile2D >::_nbinx
unsigned int _nbinx
Definition: RunHistogramManager.h:201
HistoParams< TH2F >::_type
std::string _type
Definition: RunHistogramManager.h:137
HistoParams< TProfile2D >::_type
std::string _type
Definition: RunHistogramManager.h:198
HistoParams< TH2F >::_nbiny
unsigned int _nbiny
Definition: RunHistogramManager.h:143
ConsumesCollector.h
HistoParams::_type
std::string _type
Definition: RunHistogramManager.h:76
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
HistoParams::_xmax
double _xmax
Definition: RunHistogramManager.h:81
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
HistoParams< TProfile2D >::_pointer
TProfile2D ** _pointer
Definition: RunHistogramManager.h:197
RunHistogramManager::RunHistogramManager
RunHistogramManager(edm::ConsumesCollector &&iC, const bool fillHistograms=false)
Definition: RunHistogramManager.cc:28
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52