CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
48  edm::ParameterSetDescription workerParameters;
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]);
76  edm::ParameterSet const &params(_meParams.getUntrackedParameterSet(name));
77 
78  if (!onlineMode_ && params.getUntrackedParameter<bool>("online"))
79  continue;
80 
81  try {
82  MEs_.insert(name, createMESet(params));
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 
119  if (!edso_.electronicsMap)
120  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
121  return edso_.electronicsMap;
122  }
123 
125  if (!edso_.trigtowerMap)
126  throw cms::Exception("InvalidCall") << "TrigTowerConstituentsMap not initialized";
127  return edso_.trigtowerMap;
128  }
129 
131  if (!edso_.geometry)
132  throw cms::Exception("InvalidCall") << "CaloGeometry not initialized";
133  return edso_.geometry;
134  }
135 
137  if (!edso_.topology)
138  throw cms::Exception("InvalidCall") << "CaloTopology not initialized";
139  return edso_.topology;
140  }
141 
143  if (!edso_.electronicsMap)
144  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
145  if (!edso_.trigtowerMap)
146  throw cms::Exception("InvalidCall") << "TrigTowerConstituentsMap not initialized";
147  if (!edso_.geometry)
148  throw cms::Exception("InvalidCall") << "CaloGeometry not initialized";
149  if (!edso_.topology)
150  throw cms::Exception("InvalidCall") << "CaloTopology not initialized";
151  return edso_;
152  }
153 
154  void DQWorker::print_(std::string const &_message, int _threshold /* = 0*/) const {
155  if (verbosity_ > _threshold)
156  edm::LogInfo("EcalDQM") << name_ << ": " << _message;
157  }
158 
160  int _verbosity,
161  edm::ParameterSet const &_commonParams,
162  edm::ParameterSet const &_workerParams) const {
163  DQWorker *worker(workerFactories_.at(_name)());
164  worker->setVerbosity(_verbosity);
165  worker->initialize(_name, _commonParams);
166  worker->setME(_workerParams.getUntrackedParameterSet("MEs"));
167  if (_workerParams.existsAs<edm::ParameterSet>("sources", false))
168  worker->setSource(_workerParams.getUntrackedParameterSet("sources"));
169  if (_workerParams.existsAs<edm::ParameterSet>("params", false))
170  worker->setParams(_workerParams.getUntrackedParameterSet("params"));
171  return worker;
172  }
173 
174  /*static*/
176  static WorkerFactoryStore workerFactoryStore;
177  return &workerFactoryStore;
178  }
179 
180 } // namespace ecaldqm
T getUntrackedParameter(std::string const &, T const &) const
void setSetupObjectsEndLumi(edm::EventSetup const &)
Definition: DQWorker.cc:111
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomHandleEndLumi
Definition: DQWorker.h:110
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > elecMapHandleEndLumi
Definition: DQWorker.h:108
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:159
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void insert(const std::string &key, MESet *ptr)
Definition: MESet.h:387
bool willConvertToEDM_
Definition: DQWorker.h:133
EcalDQMSetupObjects edso_
Definition: DQWorker.h:136
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:175
virtual void releaseMEs()
Definition: DQWorker.cc:90
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomHandle
Definition: DQWorker.h:105
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Log< level::Error, false > LogError
CaloTopology const * GetTopology()
Definition: DQWorker.cc:136
bool getData(T &iHolder) const
Definition: EventSetup.h:128
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:124
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:154
std::vector< std::string > getParameterNames() const
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
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:142
auto end() const
Definition: MESet.h:393
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:157
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > elecMapHandle
Definition: DQWorker.h:103
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:37
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapHandleEndLumi
Definition: DQWorker.h:109
EcalTrigTowerConstituentsMap const * trigtowerMap
Definition: MESet.h:35
MESetCollection MEs_
Definition: DQWorker.h:125
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:62
edm::ESGetToken< CaloTopology, CaloTopologyRecord > topoHandle
Definition: DQWorker.h:106
CaloTopology const * topology
Definition: MESet.h:37
void setTokens(edm::ConsumesCollector &)
Definition: DQWorker.cc:53
edm::ESGetToken< CaloTopology, CaloTopologyRecord > topoHandleEndLumi
Definition: DQWorker.h:111
CaloGeometry const * geometry
Definition: MESet.h:36
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:118
void setVerbosity(int _verbosity)
Definition: DQWorker.h:57
void setSetupObjects(edm::EventSetup const &)
Definition: DQWorker.cc:104
CaloGeometry const * GetGeometry()
Definition: DQWorker.cc:130
virtual ~DQWorker() noexcept(false)
Definition: DQWorker.cc:34
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:18
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapHandle
Definition: DQWorker.h:104
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:144
std::string name_
Definition: DQWorker.h:124
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:61