CMS 3D CMS Logo

DQWorker.cc
Go to the documentation of this file.
2 
4 
9 
11 
16 
22 
23 namespace ecaldqm {
25  : name_(""),
26  MEs_(),
27  booked_(false),
28  timestamp_(),
29  verbosity_(0),
30  onlineMode_(false),
31  willConvertToEDM_(true),
32  edso_() {}
33 
34  DQWorker::~DQWorker() noexcept(false) {}
35 
36  /*static*/
38  _desc.addUntracked<bool>("onlineMode", false);
39  _desc.addUntracked<bool>("willConvertToEDM", true);
40 
41  edm::ParameterSetDescription meParameters;
42  edm::ParameterSetDescription meNodeParameters;
43  fillMESetDescriptions(meNodeParameters);
44  meParameters.addNode(
46  _desc.addUntracked("MEs", meParameters);
47 
49  workerParameters.setUnknown();
50  _desc.addUntracked("params", workerParameters);
51  }
52 
58 
63  }
64 
65  void DQWorker::initialize(std::string const &_name, edm::ParameterSet const &_commonParams) {
66  name_ = _name;
67  onlineMode_ = _commonParams.getUntrackedParameter<bool>("onlineMode");
68  willConvertToEDM_ = _commonParams.getUntrackedParameter<bool>("willConvertToEDM");
69  }
70 
71  void DQWorker::setME(edm::ParameterSet const &_meParams) {
72  std::vector<std::string> const &MENames(_meParams.getParameterNames());
73 
74  for (unsigned iME(0); iME != MENames.size(); iME++) {
75  std::string name(MENames[iME]);
77 
78  if (!onlineMode_ && params.getUntrackedParameter<bool>("online"))
79  continue;
80 
81  try {
83  } catch (std::exception &) {
84  edm::LogError("EcalDQM") << "Exception caught while constructing MESet " << name;
85  throw;
86  }
87  }
88  }
89 
91  for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr)
92  mItr->second->clear();
93  booked_ = false;
94  }
95 
97  if (booked_)
98  return;
99  for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr)
100  mItr->second->book(_booker, GetElectronicsMap());
101  booked_ = true;
102  }
103 
109  }
110 
116  }
117 
118  bool DQWorker::checkElectronicsMap(bool doThrow /* = true*/) {
119  if (edso_.electronicsMap)
120  return true;
121  if (doThrow)
122  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
123  return false;
124  }
125 
126  bool DQWorker::checkTrigTowerMap(bool doThrow /* = true*/) {
127  if (edso_.trigtowerMap)
128  return true;
129  if (doThrow)
130  throw cms::Exception("InvalidCall") << "TrigTowerConstituentsMap not initialized";
131  return false;
132  }
133 
134  bool DQWorker::checkGeometry(bool doThrow /* = true*/) {
135  if (edso_.geometry)
136  return true;
137  if (doThrow)
138  throw cms::Exception("InvalidCall") << "CaloGeometry not initialized";
139  return false;
140  }
141 
142  bool DQWorker::checkTopology(bool doThrow /* = true*/) {
143  if (edso_.topology)
144  return true;
145  if (doThrow)
146  throw cms::Exception("InvalidCall") << "CaloTopology not initialized";
147  return false;
148  }
149 
152  return edso_.electronicsMap;
153  }
154 
157  return edso_.trigtowerMap;
158  }
159 
161  checkGeometry();
162  return edso_.geometry;
163  }
164 
166  checkTopology();
167  return edso_.topology;
168  }
169 
173  checkGeometry();
174  checkTopology();
175  return edso_;
176  }
177 
178  void DQWorker::print_(std::string const &_message, int _threshold /* = 0*/) const {
179  if (verbosity_ > _threshold)
180  edm::LogInfo("EcalDQM") << name_ << ": " << _message;
181  }
182 
184  int _verbosity,
185  edm::ParameterSet const &_commonParams,
186  edm::ParameterSet const &_workerParams) const {
187  DQWorker *worker(workerFactories_.at(_name)());
188  worker->setVerbosity(_verbosity);
189  worker->initialize(_name, _commonParams);
190  worker->setME(_workerParams.getUntrackedParameterSet("MEs"));
191  if (_workerParams.existsAs<edm::ParameterSet>("sources", false))
192  worker->setSource(_workerParams.getUntrackedParameterSet("sources"));
193  if (_workerParams.existsAs<edm::ParameterSet>("params", false))
194  worker->setParams(_workerParams.getUntrackedParameterSet("params"));
195  return worker;
196  }
197 
198  /*static*/
200  static WorkerFactoryStore workerFactoryStore;
201  return &workerFactoryStore;
202  }
203 
204 } // namespace ecaldqm
void setSetupObjectsEndLumi(edm::EventSetup const &)
Definition: DQWorker.cc:111
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomHandleEndLumi
Definition: DQWorker.h:116
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > elecMapHandleEndLumi
Definition: DQWorker.h:114
auto end() const
Definition: MESet.h:393
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:178
bool checkElectronicsMap(bool=true)
Definition: DQWorker.cc:118
void insert(const std::string &key, MESet *ptr)
Definition: MESet.h:387
bool willConvertToEDM_
Definition: DQWorker.h:139
EcalDQMSetupObjects edso_
Definition: DQWorker.h:142
bool checkGeometry(bool=true)
Definition: DQWorker.cc:134
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:199
virtual void releaseMEs()
Definition: DQWorker.cc:90
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomHandle
Definition: DQWorker.h:111
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
Log< level::Error, false > LogError
CaloTopology const * GetTopology()
Definition: DQWorker.cc:165
CaloGeometry const * GetGeometry()
Definition: DQWorker.cc:160
T getUntrackedParameter(std::string const &, T const &) const
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:183
bool getData(T &iHolder) const
Definition: EventSetup.h:122
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:96
EcalElectronicsMapping const * electronicsMap
Definition: MESet.h:34
MESetColletionType::iterator iterator
Definition: MESet.h:384
Log< level::Info, false > LogInfo
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:71
void initialize(std::string const &_name, edm::ParameterSet const &)
Definition: DQWorker.cc:65
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:163
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > elecMapHandle
Definition: DQWorker.h:109
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:37
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapHandleEndLumi
Definition: DQWorker.h:115
EcalTrigTowerConstituentsMap const * trigtowerMap
Definition: MESet.h:35
MESetCollection MEs_
Definition: DQWorker.h:131
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:62
edm::ESGetToken< CaloTopology, CaloTopologyRecord > topoHandle
Definition: DQWorker.h:112
CaloTopology const * topology
Definition: MESet.h:37
void setTokens(edm::ConsumesCollector &)
Definition: DQWorker.cc:53
edm::ESGetToken< CaloTopology, CaloTopologyRecord > topoHandleEndLumi
Definition: DQWorker.h:117
CaloGeometry const * geometry
Definition: MESet.h:36
void setVerbosity(int _verbosity)
Definition: DQWorker.h:57
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:155
void setSetupObjects(edm::EventSetup const &)
Definition: DQWorker.cc:104
virtual ~DQWorker() noexcept(false)
Definition: DQWorker.cc:34
bool checkTrigTowerMap(bool=true)
Definition: DQWorker.cc:126
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:18
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapHandle
Definition: DQWorker.h:110
std::vector< std::string > getParameterNames() const
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:144
std::string name_
Definition: DQWorker.h:130
bool checkTopology(bool=true)
Definition: DQWorker.cc:142
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:61