CMS 3D CMS Logo

DQWorker.cc
Go to the documentation of this file.
2 
4 
9 
11 
12 namespace ecaldqm {
14  : name_(""), MEs_(), booked_(false), timestamp_(), verbosity_(0), onlineMode_(false), willConvertToEDM_(true) {}
15 
17 
18  /*static*/
20  _desc.addUntracked<bool>("onlineMode", false);
21  _desc.addUntracked<bool>("willConvertToEDM", true);
22 
23  edm::ParameterSetDescription meParameters;
24  edm::ParameterSetDescription meNodeParameters;
25  fillMESetDescriptions(meNodeParameters);
26  meParameters.addNode(
28  _desc.addUntracked("MEs", meParameters);
29 
30  edm::ParameterSetDescription workerParameters;
31  workerParameters.setUnknown();
32  _desc.addUntracked("params", workerParameters);
33  }
34 
35  void DQWorker::initialize(std::string const &_name, edm::ParameterSet const &_commonParams) {
36  name_ = _name;
37  onlineMode_ = _commonParams.getUntrackedParameter<bool>("onlineMode");
38  willConvertToEDM_ = _commonParams.getUntrackedParameter<bool>("willConvertToEDM");
39  }
40 
41  void DQWorker::setME(edm::ParameterSet const &_meParams) {
42  std::vector<std::string> const &MENames(_meParams.getParameterNames());
43 
44  for (unsigned iME(0); iME != MENames.size(); iME++) {
45  std::string name(MENames[iME]);
46  edm::ParameterSet const &params(_meParams.getUntrackedParameterSet(name));
47 
48  if (!onlineMode_ && params.getUntrackedParameter<bool>("online"))
49  continue;
50 
51  try {
52  MEs_.insert(name, createMESet(params));
53  } catch (std::exception &) {
54  edm::LogError("EcalDQM") << "Exception caught while constructing MESet " << name;
55  throw;
56  }
57  }
58  }
59 
61  for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr)
62  mItr->second->clear();
63  booked_ = false;
64  }
65 
67  if (booked_)
68  return;
69  for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr)
70  mItr->second->book(_booker);
71  booked_ = true;
72  }
73 
74  void DQWorker::print_(std::string const &_message, int _threshold /* = 0*/) const {
75  if (verbosity_ > _threshold)
76  edm::LogInfo("EcalDQM") << name_ << ": " << _message;
77  }
78 
80  int _verbosity,
81  edm::ParameterSet const &_commonParams,
82  edm::ParameterSet const &_workerParams) const {
83  DQWorker *worker(workerFactories_.at(_name)());
84  worker->setVerbosity(_verbosity);
85  worker->initialize(_name, _commonParams);
86  worker->setME(_workerParams.getUntrackedParameterSet("MEs"));
87  if (_workerParams.existsAs<edm::ParameterSet>("sources", false))
88  worker->setSource(_workerParams.getUntrackedParameterSet("sources"));
89  if (_workerParams.existsAs<edm::ParameterSet>("params", false))
90  worker->setParams(_workerParams.getUntrackedParameterSet("params"));
91  return worker;
92  }
93 
94  /*static*/
96  static WorkerFactoryStore workerFactoryStore;
97  return &workerFactoryStore;
98  }
99 
100 } // namespace ecaldqm
T getUntrackedParameter(std::string const &, T const &) const
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:79
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool willConvertToEDM_
Definition: DQWorker.h:83
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:95
virtual void releaseMEs()
Definition: DQWorker.cc:60
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:74
std::vector< std::string > getParameterNames() const
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:66
#define noexcept
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:41
void initialize(std::string const &_name, edm::ParameterSet const &)
Definition: DQWorker.cc:35
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:19
MESetCollection MEs_
Definition: DQWorker.h:75
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:46
void setVerbosity(int _verbosity)
Definition: DQWorker.h:41
virtual ~DQWorker()(false)
Definition: DQWorker.cc:16
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:17
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:143
std::string name_
Definition: DQWorker.h:74
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:45