CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQWorker.cc
Go to the documentation of this file.
2 
4 
9 
11 
12 namespace ecaldqm
13 {
15  name_(""),
16  MEs_(),
17  timestamp_(),
18  verbosity_(0),
19  onlineMode_(false),
20  willConvertToEDM_(true)
21  {
22  }
23 
25  {
26  }
27 
28  /*static*/
29  void
31  {
32  _desc.addUntracked<bool>("onlineMode", false);
33  _desc.addUntracked<bool>("willConvertToEDM", true);
34 
35  edm::ParameterSetDescription meParameters;
36  edm::ParameterSetDescription meNodeParameters;
37  fillMESetDescriptions(meNodeParameters);
38  meParameters.addNode(edm::ParameterWildcard<edm::ParameterSetDescription>("*", edm::RequireZeroOrMore, false, meNodeParameters));
39  _desc.addUntracked("MEs", meParameters);
40 
41  edm::ParameterSetDescription workerParameters;
42  workerParameters.setUnknown();
43  _desc.addUntracked("params", workerParameters);
44  }
45 
46  void
47  DQWorker::initialize(std::string const& _name, edm::ParameterSet const& _commonParams)
48  {
49  name_ = _name;
50  onlineMode_ = _commonParams.getUntrackedParameter<bool>("onlineMode");
51  willConvertToEDM_ = _commonParams.getUntrackedParameter<bool>("willConvertToEDM");
52  }
53 
54  void
56  {
57  std::vector<std::string> const& MENames(_meParams.getParameterNames());
58 
59  for(unsigned iME(0); iME != MENames.size(); iME++){
60  std::string name(MENames[iME]);
61  edm::ParameterSet const& params(_meParams.getUntrackedParameterSet(name));
62 
63  if(!onlineMode_ && params.getUntrackedParameter<bool>("online")) continue;
64 
65  try{
66  MEs_.insert(name, createMESet(params));
67  }
68  catch(std::exception&){
69  edm::LogError("EcalDQM") << "Exception caught while constructing MESet " << name;
70  throw;
71  }
72  }
73  }
74 
75  void
77  {
78  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr)
79  mItr->second->clear();
80  }
81 
82  void
84  {
85  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
86  MESet* me(mItr->second);
87  if(me->isActive()) continue;
88  me->book(_booker);
89  }
90  }
91 
92  void
94  {
95  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
96  MESet* me(mItr->second);
97  if(me->isActive()) continue;
98  me->book(_booker);
99  }
100  }
101 
102  void
103  DQWorker::print_(std::string const& _message, int _threshold/* = 0*/) const
104  {
105  if(verbosity_ > _threshold)
106  edm::LogInfo("EcalDQM") << name_ << ": " << _message;
107  }
108 
109 
110  DQWorker*
111  WorkerFactoryStore::getWorker(std::string const& _name, int _verbosity, edm::ParameterSet const& _commonParams, edm::ParameterSet const& _workerParams) const
112  {
113  DQWorker* worker(workerFactories_.at(_name)());
114  worker->setVerbosity(_verbosity);
115  worker->initialize(_name, _commonParams);
116  worker->setME(_workerParams.getUntrackedParameterSet("MEs"));
117  if(_workerParams.existsAs<edm::ParameterSet>("sources", false))
118  worker->setSource(_workerParams.getUntrackedParameterSet("sources"));
119  if(_workerParams.existsAs<edm::ParameterSet>("params", false))
120  worker->setParams(_workerParams.getUntrackedParameterSet("params"));
121  return worker;
122  }
123 
124  /*static*/
127  {
128  static WorkerFactoryStore workerFactoryStore;
129  return &workerFactoryStore;
130  }
131 
132 }
133 
T getUntrackedParameter(std::string const &, T const &) const
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:111
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool willConvertToEDM_
Definition: DQWorker.h:83
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:126
virtual void releaseMEs()
Definition: DQWorker.cc:76
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
virtual void book(DQMStore &)
Definition: MESet.h:42
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:103
virtual void bookMEs(DQMStore &)
Definition: DQWorker.cc:83
std::vector< std::string > getParameterNames() const
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:55
void initialize(std::string const &_name, edm::ParameterSet const &)
Definition: DQWorker.cc:47
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:103
bool isActive() const
Definition: MESet.h:97
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:30
MESetCollection MEs_
Definition: DQWorker.h:76
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:46
void setVerbosity(int _verbosity)
Definition: DQWorker.h:41
volatile std::atomic< bool > shutdown_flag false
virtual ~DQWorker()
Definition: DQWorker.cc:24
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:19
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:129
std::string name_
Definition: DQWorker.h:75
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:45