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