CMS 3D CMS Logo

DQWorkerClient.cc
Go to the documentation of this file.
2 
8 
13 
14 #include <sstream>
15 
16 namespace ecaldqm
17 {
19  DQWorker(),
20  sources_(),
21  qualitySummaries_(),
22  hasLumiPlots_(false),
23  statusManager_(nullptr)
24  {
25  }
26 
27  /*static*/
28  void
30  {
32  _desc.addWildcardUntracked<std::vector<std::string> >("*");
33 
34  edm::ParameterSetDescription sourceParameters;
35  edm::ParameterSetDescription sourceNodeParameters;
36  fillMESetDescriptions(sourceNodeParameters);
37  sourceParameters.addNode(edm::ParameterWildcard<edm::ParameterSetDescription>("*", edm::RequireZeroOrMore, false, sourceNodeParameters));
38  _desc.addUntracked("sources", sourceParameters);
39  }
40 
41 
42  void
44  {
45  DQWorker::setME(_ps);
46 
47  // Flags the Client ME to run as lumibased:
48  // In offline mode will save the ME client at the end of the LS
49  // See: EcalDQMonitorClient::dqmEndLuminosityBlock
50  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
51  if(mItr->second->getLumiFlag()){
52  hasLumiPlots_ = true;
53  break;
54  }
55  }
56 
57  }
58 
59 
60  void
62  {
63  std::vector<std::string> const& sourceNames(_params.getParameterNames());
64 
65  for(unsigned iS(0); iS < sourceNames.size(); iS++){
66  std::string name(sourceNames[iS]);
67  edm::ParameterSet const& params(_params.getUntrackedParameterSet(name));
68 
69  if(onlineMode_ && params.getUntrackedParameter<bool>("online")) continue;
70 
71  sources_.insert(name, createMESet(params));
72  }
73 
74  if(verbosity_ > 1){
75  std::stringstream ss;
76  ss << name_ << ": Using ";
77  for(MESetCollection::const_iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
78  ss << sItr->first << " ";
79  ss << "as sources";
80  edm::LogInfo("EcalDQM") << ss.str();
81  }
82  }
83 
84  void
86  {
87 // MESetChannel class removed until concurrency issue is finalized
88 #if 0
89  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
90  if(!sItr->second->getLumiFlag()) continue;
91  MESetChannel const* channel(dynamic_cast<MESetChannel const*>(sItr->second));
92  if(channel) channel->checkDirectory();
93  }
94 #endif
95  }
96 
97  void
99  {
100  DQWorker::bookMEs(_ibooker);
101  resetMEs();
102  }
103 
104  void
106  {
108  releaseSource();
109  }
110 
111  void
113  {
114  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
115  sItr->second->clear();
116  }
117 
118  bool
120  {
121  std::string failedPath;
122  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
123  if(!onlineMode_ && _type == kLumi && !sItr->second->getLumiFlag()) continue;
124  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << name_ << ": Retrieving source " << sItr->first;
125  if(!sItr->second->retrieve(_igetter, &failedPath)){
126  if(verbosity_ > 1) edm::LogWarning("EcalDQM") << name_ << ": Could not find source " << sItr->first << "@" << failedPath;
127  return false;
128  }
129  }
130 
131  return true;
132  }
133 
134  void
136  {
137  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
138  MESet* meset(mItr->second);
139 
140  // Protects Trend-type Client MEs from being reset at the end of the LS
141  // See: EcalDQMonitorClient::runWorkers
142  if(meset->getBinType() == ecaldqm::binning::kTrend)
143  continue;
144 
145  if(qualitySummaries_.find(mItr->first) != qualitySummaries_.end()){
146  MESetMulti* multi(dynamic_cast<MESetMulti*>(meset));
147  if(multi){
148  for(unsigned iS(0); iS < multi->getMultiplicity(); ++iS){
149  multi->use(iS);
150  if(multi->getKind() == MonitorElement::DQM_KIND_TH2F){
151  multi->resetAll(-1.);
152  multi->reset(kUnknown);
153  }
154  else
155  multi->reset(-1.);
156  }
157  }
158  else{
159  if(meset->getKind() == MonitorElement::DQM_KIND_TH2F){
160  meset->resetAll(-1.);
161  meset->reset(kUnknown);
162  }
163  else
164  meset->reset(-1.);
165  }
166  }
167  else
168  meset->reset();
169  }
170  }
171 
172  void
174  {
175  for (auto const& meset : MEs_) {
176  int i = 0;
177  while (auto me = meset.second->getME(i)) {
178  if (me->getLumiFlag()) {
179  std::cout << "+++ reset " << me->getFullname() << "\n";
180  // reset per-lumi histograms in offline harvesting so that they only show
181  // data of the current lumisection.
182  me->Reset();
183  }
184  i++;
185  }
186  }
187  }
188 
189  void
190  DQWorkerClient::towerAverage_(MESet& _target, MESet const& _source, float _threshold)
191  {
192  bool isQuality(_threshold > 0.);
193 
194  MESet::iterator tEnd(_target.end());
195  for(MESet::iterator tItr(_target.beginChannel()); tItr != tEnd; tItr.toNextChannel()){
196  DetId towerId(tItr->getId());
197 
198  std::vector<DetId> cryIds;
199  if(towerId.subdetId() == EcalTriggerTower)
201  else{
203  }
204 
205  if(cryIds.empty()) return;
206 
207  float mean(0.);
208  float nValid(0.);
209  bool masked(false);
210  for(unsigned iId(0); iId < cryIds.size(); ++iId){
211  float content(_source.getBinContent(cryIds[iId]));
212  if(isQuality){
213  if(content < 0. || content == 2.) continue;
214  if(content == 5.) masked = true;
215  else{
216  nValid += 1;
217  if(content > 2.){
218  masked = true;
219  mean += content - 3.;
220  }
221  else
222  mean += content;
223  }
224  }
225  else{
226  mean += content;
227  nValid += 1.;
228  }
229  }
230 
231  if(isQuality){
232  if(nValid < 1.) tItr->setBinContent(masked ? 5. : 2.);
233  else{
234  mean /= nValid;
235  if(mean < _threshold) tItr->setBinContent(masked ? 3. : 0.);
236  else tItr->setBinContent(masked ? 4. : 1.);
237  }
238  }
239  else
240  tItr->setBinContent(nValid < 1. ? 0. : mean / nValid);
241  }
242  }
243 
244 }
MonitorElement::Kind getKind() const
Definition: MESet.h:94
void towerAverage_(MESet &, MESet const &, float)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void reset(double=0., double=0., double=0.) override
Definition: MESetMulti.cc:120
#define nullptr
bool retrieveSource(DQMStore::IGetter &, ProcessType)
virtual void releaseMEs()
Definition: DQWorker.cc:60
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
const_iterator & toNextChannel()
Definition: MESet.h:290
unsigned getMultiplicity() const
Definition: MESetMulti.h:118
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void use(unsigned) const
Definition: MESetMulti.cc:130
std::set< std::string > qualitySummaries_
virtual double getBinContent(DetId const &, int=0) const
Definition: MESet.h:71
static void fillDescriptions(edm::ParameterSetDescription &)
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
void resetAll(double=0., double=0., double=0.) override
Definition: MESetMulti.cc:125
virtual const_iterator beginChannel() const
Definition: MESet.h:324
virtual void reset(double=0., double=0., double=0.)
Definition: MESet.cc:98
std::vector< std::string > getParameterNames() const
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:66
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
unsigned towerId(DetId const &)
MESetCollection sources_
Definition: DetId.h:18
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:41
void releaseMEs() override
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:19
MESetCollection MEs_
Definition: DQWorker.h:75
binning::BinningType getBinType() const
Definition: MESet.h:93
virtual void resetAll(double=0., double=0., double=0.)
Definition: MESet.cc:105
void setSource(edm::ParameterSet const &) override
void bookMEs(DQMStore::IBooker &) override
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
virtual const_iterator end() const
Definition: MESet.h:322
std::vector< DetId > scConstituents(EcalScDetId const &)
void setME(edm::ParameterSet const &_ps) final
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:17
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:143
std::string name_
Definition: DQWorker.h:74