CMS 3D CMS Logo

MESetNonObject.cc
Go to the documentation of this file.
2 
3 namespace ecaldqm {
5  binning::ObjectType _otype,
8  binning::AxisSpecs const *_xaxis /* = 0*/,
9  binning::AxisSpecs const *_yaxis /* = 0*/,
10  binning::AxisSpecs const *_zaxis /* = 0*/)
11  : MESet(_fullPath, _otype, _btype, _kind),
12  xaxis_(_xaxis ? new binning::AxisSpecs(*_xaxis) : nullptr),
13  yaxis_(_yaxis ? new binning::AxisSpecs(*_yaxis) : nullptr),
14  zaxis_(_zaxis ? new binning::AxisSpecs(*_zaxis) : nullptr) {}
15 
17  : MESet(_orig),
18  xaxis_(_orig.xaxis_ ? new binning::AxisSpecs(*_orig.xaxis_) : nullptr),
19  yaxis_(_orig.yaxis_ ? new binning::AxisSpecs(*_orig.yaxis_) : nullptr),
20  zaxis_(_orig.zaxis_ ? new binning::AxisSpecs(*_orig.zaxis_) : nullptr) {}
21 
23  delete xaxis_;
24  delete yaxis_;
25  delete zaxis_;
26  }
27 
29  delete xaxis_;
30  delete yaxis_;
31  delete zaxis_;
32  xaxis_ = nullptr;
33  yaxis_ = nullptr;
34  zaxis_ = nullptr;
35 
36  MESetNonObject const *pRhs(dynamic_cast<MESetNonObject const *>(&_rhs));
37  if (pRhs) {
38  if (pRhs->xaxis_)
39  xaxis_ = new binning::AxisSpecs(*pRhs->xaxis_);
40  if (pRhs->yaxis_)
41  yaxis_ = new binning::AxisSpecs(*pRhs->yaxis_);
42  if (pRhs->zaxis_)
43  zaxis_ = new binning::AxisSpecs(*pRhs->zaxis_);
44  }
45  return MESet::operator=(_rhs);
46  }
47 
48  MESet *MESetNonObject::clone(std::string const &_path /* = ""*/) const {
50  if (!_path.empty())
51  path_ = _path;
52  MESet *copy(new MESetNonObject(*this));
53  path_ = path;
54  return copy;
55  }
56 
58  using namespace std;
59 
60  clear();
61 
62  if (path_.find('%') != string::npos)
63  throw_("book() called with incompletely formed path");
64 
65  size_t slashPos(path_.find_last_of('/'));
66  string name(path_.substr(slashPos + 1));
67  _ibooker.setCurrentFolder(path_.substr(0, slashPos));
68  auto oldscope = MonitorElementData::Scope::RUN;
69  if (lumiFlag_)
70  oldscope = _ibooker.setScope(MonitorElementData::Scope::LUMI);
71 
72  MonitorElement *me(nullptr);
73 
74  switch (kind_) {
76  me = _ibooker.bookFloat(name);
77  break;
78 
80  if (!xaxis_)
81  throw_("No xaxis found for MESetNonObject");
82 
83  if (xaxis_->edges)
84  me = _ibooker.book1D(name, name, xaxis_->nbins, xaxis_->edges);
85  else
86  me = _ibooker.book1D(name, name, xaxis_->nbins, xaxis_->low, xaxis_->high);
87  } break;
88 
90  if (!xaxis_)
91  throw_("No xaxis found for MESetNonObject");
92 
93  double ylow, yhigh;
94  if (!yaxis_) {
97  } else {
98  ylow = yaxis_->low;
99  yhigh = yaxis_->high;
100  }
101  if (xaxis_->edges) {
102  // DQMStore bookProfile interface uses double* for bin edges
103  double *edges(new double[xaxis_->nbins + 1]);
105  me = _ibooker.bookProfile(name, name, xaxis_->nbins, edges, ylow, yhigh, "");
106  delete[] edges;
107  } else
108  me = _ibooker.bookProfile(name, name, xaxis_->nbins, xaxis_->low, xaxis_->high, ylow, yhigh, "");
109  } break;
110 
112  if (!xaxis_ || !yaxis_)
113  throw_("No x/yaxis found for MESetNonObject");
114 
115  if (!xaxis_->edges || !yaxis_->edges) // unlike MESetEcal, if either of X or Y is not set as
116  // variable, binning will be fixed
117  me = _ibooker.book2D(
119  else
120  me = _ibooker.book2D(name, name, xaxis_->nbins, xaxis_->edges, yaxis_->nbins, yaxis_->edges);
121  } break;
122 
124  if (!xaxis_ || !yaxis_)
125  throw_("No x/yaxis found for MESetNonObject");
126  if (xaxis_->edges || yaxis_->edges)
127  throw_("Variable bin size for 2D profile not implemented");
128 
129  double high(0.), low(0.);
130  if (zaxis_) {
131  low = zaxis_->low;
132  high = zaxis_->high;
133  } else {
136  }
137 
138  me = _ibooker.bookProfile2D(name,
139  name,
140  xaxis_->nbins,
141  xaxis_->low,
142  xaxis_->high,
143  yaxis_->nbins,
144  yaxis_->low,
145  yaxis_->high,
146  low,
147  high,
148  "");
149  } break;
150 
151  default:
152  throw_("Unsupported MonitorElement kind");
153  }
154 
155  if (xaxis_) {
156  me->setAxisTitle(xaxis_->title, 1);
157  if (xaxis_->labels) {
158  for (int iBin(1); iBin <= xaxis_->nbins; ++iBin)
159  me->setBinLabel(iBin, xaxis_->labels[iBin - 1], 1);
160  }
161  }
162  if (yaxis_) {
163  me->setAxisTitle(yaxis_->title, 2);
164  if (yaxis_->labels) {
165  for (int iBin(1); iBin <= yaxis_->nbins; ++iBin)
166  me->setBinLabel(iBin, yaxis_->labels[iBin - 1], 2);
167  }
168  }
169  if (zaxis_) {
170  me->setAxisTitle(zaxis_->title, 3);
171  if (zaxis_->labels) {
172  for (int iBin(1); iBin <= zaxis_->nbins; ++iBin)
173  me->setBinLabel(iBin, zaxis_->labels[iBin - 1], 3);
174  }
175  }
176 
177  if (lumiFlag_)
178  _ibooker.setScope(oldscope);
179 
180  mes_.push_back(me);
181 
182  active_ = true;
183  }
184 
185  bool MESetNonObject::retrieve(DQMStore::IGetter &_igetter, std::string *_failedPath /* = 0*/) const {
186  mes_.clear();
187 
188  MonitorElement *me(_igetter.get(path_));
189  if (!me) {
190  if (_failedPath)
191  *_failedPath = path_;
192  return false;
193  }
194 
195  mes_.push_back(me);
196 
197  active_ = true;
198  return true;
199  }
200 
201  void MESetNonObject::fill(double _x, double _wy /* = 1.*/, double _w /* = 1.*/) {
202  if (!active_)
203  return;
204 
205  if (mes_.empty() || !mes_[0])
206  return;
207 
208  switch (kind_) {
210  mes_[0]->Fill(_x);
211  break;
214  mes_[0]->Fill(_x, _wy);
215  break;
218  mes_[0]->Fill(_x, _wy, _w);
219  break;
220  default:
221  break;
222  }
223  }
224 
225  void MESetNonObject::setBinContent(int _bin, double _content) {
226  if (!active_)
227  return;
229  return;
230 
231  if (mes_.empty() || !mes_[0])
232  return;
233 
234  mes_[0]->setBinContent(_bin, _content);
235  }
236 
237  void MESetNonObject::setBinError(int _bin, double _error) {
238  if (!active_)
239  return;
241  return;
242 
243  if (mes_.empty() || !mes_[0])
244  return;
245 
246  mes_[0]->setBinError(_bin, _error);
247  }
248 
249  void MESetNonObject::setBinEntries(int _bin, double _entries) {
250  if (!active_)
251  return;
253  return;
254 
255  if (mes_.empty() || !mes_[0])
256  return;
257 
258  mes_[0]->setBinEntries(_bin, _entries);
259  }
260 
261  double MESetNonObject::getBinContent(int _bin, int) const {
262  if (!active_)
263  return 0.;
265  return 0.;
266 
267  if (mes_.empty() || !mes_[0])
268  return 0.;
269 
270  return mes_[0]->getBinContent(_bin);
271  }
272 
275  return mes_[0]->getFloatValue();
276  else
277  return 0.;
278  }
279 
280  double MESetNonObject::getBinError(int _bin, int) const {
281  if (!active_)
282  return 0.;
284  return 0.;
285 
286  if (mes_.empty() || !mes_[0])
287  return 0.;
288 
289  return mes_[0]->getBinError(_bin);
290  }
291 
292  double MESetNonObject::getBinEntries(int _bin, int) const {
293  if (!active_)
294  return 0.;
296  return 0.;
297 
298  if (mes_.empty() || !mes_[0])
299  return 0.;
300 
301  return mes_[0]->getBinEntries(_bin);
302  }
303 
304  int MESetNonObject::findBin(double _x, double _y /* = 0.*/) const {
305  if (!active_)
306  return 0;
307 
308  if (mes_.empty() || !mes_[0])
309  return 0;
310 
312  return mes_[0]->getTH1()->FindBin(_x);
314  return mes_[0]->getTH1()->FindBin(_x, _y);
315  else
316  return 0;
317  }
318 
320  return (xaxis_ && xaxis_->edges) || (yaxis_ && yaxis_->edges) || (zaxis_ && zaxis_->edges);
321  }
322 } // namespace ecaldqm
ecaldqm::MESet::throw_
void throw_(std::string const &_message) const
Definition: MESet.h:121
ecaldqm
Definition: DQWorker.h:24
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
ecaldqm::MESetNonObject::xaxis_
const binning::AxisSpecs * xaxis_
Definition: MESetNonObject.h:47
dqm::implementation::IBooker::setScope
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
Definition: DQMStore.cc:46
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
MonitorElementData::Kind::TH1F
ecaldqm::MESet::operator=
virtual MESet & operator=(MESet const &)
Definition: MESet.cc:64
dqm::implementation::IBooker::bookProfile2D
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
ecaldqm::binning::AxisSpecs::labels
std::string * labels
Definition: MESetBinningUtils.h:76
ecaldqm::MESetNonObject
Definition: MESetNonObject.h:7
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
ecaldqm::MESetNonObject::fill
void fill(double, double=1., double=1.) override
Definition: MESetNonObject.cc:201
ecaldqm::binning::AxisSpecs::edges
float * edges
Definition: MESetBinningUtils.h:75
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
MonitorElementData::Kind::TH2F
ecaldqm::MESetNonObject::setBinEntries
void setBinEntries(int, double) override
Definition: MESetNonObject.cc:249
ecaldqm::MESetNonObject::zaxis_
const binning::AxisSpecs * zaxis_
Definition: MESetNonObject.h:49
ecaldqm::MESetNonObject::getBinContent
double getBinContent(int, int=0) const override
Definition: MESetNonObject.cc:261
ecaldqm::MESetNonObject::getBinEntries
double getBinEntries(int, int=0) const override
Definition: MESetNonObject.cc:292
ecaldqm::MESetNonObject::findBin
int findBin(double, double=0.) const
Definition: MESetNonObject.cc:304
ecaldqm::MESetNonObject::getFloatValue
double getFloatValue() const
Definition: MESetNonObject.cc:273
ecaldqm::binning::AxisSpecs::low
float low
Definition: MESetBinningUtils.h:74
ecaldqm::binning::AxisSpecs::nbins
int nbins
Definition: MESetBinningUtils.h:73
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
ecaldqm::MESetNonObject::book
void book(DQMStore::IBooker &) override
Definition: MESetNonObject.cc:57
ecaldqm::MESetNonObject::~MESetNonObject
~MESetNonObject() override
Definition: MESetNonObject.cc:22
ecaldqm::MESet::active_
bool active_
Definition: MESet.h:133
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ecaldqm::MESetNonObject::clone
MESet * clone(std::string const &="") const override
Definition: MESetNonObject.cc:48
ecaldqm::binning::AxisSpecs::title
std::string title
Definition: MESetBinningUtils.h:77
listHistos.binning
binning
Definition: listHistos.py:43
ecaldqm::binning::ObjectType
ObjectType
Definition: MESetBinningUtils.h:17
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MonitorElementData::Kind
Kind
Definition: MonitorElementCollection.h:129
ecaldqm::MESet::path_
std::string path_
Definition: MESet.h:125
ecaldqm::MESetNonObject::setBinError
void setBinError(int, double) override
Definition: MESetNonObject.cc:237
ecaldqm::MESetNonObject::yaxis_
const binning::AxisSpecs * yaxis_
Definition: MESetNonObject.h:48
ecaldqm::binning::AxisSpecs
Definition: MESetBinningUtils.h:72
SelectiveReadoutTask_cfi.edges
edges
Definition: SelectiveReadoutTask_cfi.py:107
ecaldqm::MESetNonObject::retrieve
bool retrieve(DQMStore::IGetter &, std::string *=nullptr) const override
Definition: MESetNonObject.cc:185
ecaldqm::MESet::mes_
std::vector< MonitorElement * > mes_
Definition: MESet.h:123
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
std
Definition: JetResolutionObject.h:76
MonitorElementData::Kind::TPROFILE2D
ecaldqm::MESet::clear
virtual void clear() const
Definition: MESet.cc:84
ecaldqm::MESetNonObject::operator=
MESet & operator=(MESet const &) override
Definition: MESetNonObject.cc:28
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ecaldqm::binning::AxisSpecs::high
float high
Definition: MESetBinningUtils.h:74
MESetNonObject.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
ecaldqm::MESetNonObject::getBinError
double getBinError(int, int=0) const override
Definition: MESetNonObject.cc:280
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ecaldqm::binning::BinningType
BinningType
Definition: MESetBinningUtils.h:40
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
ecaldqm::MESet::kind_
MonitorElement::Kind kind_
Definition: MESet.h:128
ecaldqm::MESetNonObject::setBinContent
void setBinContent(int, double) override
Definition: MESetNonObject.cc:225
btvTracks_cfi._content
_content
Definition: btvTracks_cfi.py:5
MonitorElementData::Kind::TPROFILE
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
MonitorElementData::Kind::REAL
ecaldqm::MESetNonObject::MESetNonObject
MESetNonObject(std::string const &, binning::ObjectType, binning::BinningType, MonitorElement::Kind, binning::AxisSpecs const *=nullptr, binning::AxisSpecs const *=nullptr, binning::AxisSpecs const *=nullptr)
Definition: MESetNonObject.cc:4
ecaldqm::MESetNonObject::isVariableBinning
bool isVariableBinning() const override
Definition: MESetNonObject.cc:319
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
ecaldqm::MESet::lumiFlag_
bool lumiFlag_
Definition: MESet.h:129
ecaldqm::MESet
Definition: MESet.h:27