CMS 3D CMS Logo

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