CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQWorkerClient.cc
Go to the documentation of this file.
1 #include "../interface/DQWorkerClient.h"
2 
8 
13 
14 #include <sstream>
15 
16 namespace ecaldqm
17 {
19  DQWorker(),
20  sources_(),
21  qualitySummaries_(),
22  hasLumiPlots_(false),
23  statusManager_(0)
24  {
25  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
26  if(mItr->second->getLumiFlag()){
27  hasLumiPlots_ = true;
28  break;
29  }
30  }
31  }
32 
33  /*static*/
34  void
36  {
38  _desc.addWildcardUntracked<std::vector<std::string> >("*");
39 
40  edm::ParameterSetDescription sourceParameters;
41  edm::ParameterSetDescription sourceNodeParameters;
42  fillMESetDescriptions(sourceNodeParameters);
43  sourceParameters.addNode(edm::ParameterWildcard<edm::ParameterSetDescription>("*", edm::RequireZeroOrMore, false, sourceNodeParameters));
44  _desc.addUntracked("sources", sourceParameters);
45  }
46 
47  void
49  {
50  std::vector<std::string> const& sourceNames(_params.getParameterNames());
51 
52  for(unsigned iS(0); iS < sourceNames.size(); iS++){
53  std::string name(sourceNames[iS]);
54  edm::ParameterSet const& params(_params.getUntrackedParameterSet(name));
55 
56  if(onlineMode_ && params.getUntrackedParameter<bool>("online")) continue;
57 
58  sources_.insert(name, createMESet(params));
59  }
60 
61  if(verbosity_ > 1){
62  std::stringstream ss;
63  ss << name_ << ": Using ";
64  for(MESetCollection::const_iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
65  ss << sItr->first << " ";
66  ss << "as sources";
67  edm::LogInfo("EcalDQM") << ss.str();
68  }
69  }
70 
71  void
73  {
74 // MESetChannel class removed until concurrency issue is finalized
75 #if 0
76  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
77  if(!sItr->second->getLumiFlag()) continue;
78  MESetChannel const* channel(dynamic_cast<MESetChannel const*>(sItr->second));
79  if(channel) channel->checkDirectory();
80  }
81 #endif
82  }
83 
84  void
86  {
87  DQWorker::bookMEs(_ibooker);
88  resetMEs();
89  }
90 
91  void
93  {
95  releaseSource();
96  }
97 
98  void
100  {
101  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
102  sItr->second->clear();
103  }
104 
105  bool
107  {
108  std::string failedPath;
109  for(MESetCollection::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
110  if(!onlineMode_ && _type == kLumi && !sItr->second->getLumiFlag()) continue;
111  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << name_ << ": Retrieving source " << sItr->first;
112  if(!sItr->second->retrieve(_igetter, &failedPath)){
113  if(verbosity_ > 1) edm::LogWarning("EcalDQM") << name_ << ": Could not find source " << sItr->first << "@" << failedPath;
114  return false;
115  }
116  }
117 
118  return true;
119  }
120 
121  void
123  {
124  for(MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr){
125  MESet* meset(mItr->second);
126 
127  if(qualitySummaries_.find(mItr->first) != qualitySummaries_.end()){
128  MESetMulti* multi(dynamic_cast<MESetMulti*>(meset));
129  if(multi){
130  for(unsigned iS(0); iS < multi->getMultiplicity(); ++iS){
131  multi->use(iS);
132  if(multi->getKind() == MonitorElement::DQM_KIND_TH2F){
133  multi->resetAll(-1.);
134  multi->reset(kUnknown);
135  }
136  else
137  multi->reset(-1.);
138  }
139  }
140  else{
141  if(meset->getKind() == MonitorElement::DQM_KIND_TH2F){
142  meset->resetAll(-1.);
143  meset->reset(kUnknown);
144  }
145  else
146  meset->reset(-1.);
147  }
148  }
149  else
150  meset->reset();
151  }
152  }
153 
154  void
155  DQWorkerClient::towerAverage_(MESet& _target, MESet const& _source, float _threshold)
156  {
157  bool isQuality(_threshold > 0.);
158 
159  MESet::iterator tEnd(_target.end());
160  for(MESet::iterator tItr(_target.beginChannel()); tItr != tEnd; tItr.toNextChannel()){
161  DetId towerId(tItr->getId());
162 
163  std::vector<DetId> cryIds;
164  if(towerId.subdetId() == EcalTriggerTower)
166  else{
168  }
169 
170  if(cryIds.size() == 0) return;
171 
172  float mean(0.);
173  float nValid(0.);
174  bool masked(false);
175  for(unsigned iId(0); iId < cryIds.size(); ++iId){
176  float content(_source.getBinContent(cryIds[iId]));
177  if(isQuality){
178  if(content < 0. || content == 2.) continue;
179  if(content == 5.) masked = true;
180  else{
181  nValid += 1;
182  if(content > 2.){
183  masked = true;
184  mean += content - 3.;
185  }
186  else
187  mean += content;
188  }
189  }
190  else{
191  mean += content;
192  nValid += 1.;
193  }
194  }
195 
196  if(isQuality){
197  if(nValid < 1.) tItr->setBinContent(masked ? 5. : 2.);
198  else{
199  mean /= nValid;
200  if(mean < _threshold) tItr->setBinContent(masked ? 3. : 0.);
201  else tItr->setBinContent(masked ? 4. : 1.);
202  }
203  }
204  else
205  tItr->setBinContent(nValid < 1. ? 0. : mean / nValid);
206  }
207  }
208 
209 }
MonitorElement::Kind getKind() const
Definition: MESet.h:95
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:132
bool retrieveSource(DQMStore::IGetter &, ProcessType)
virtual void releaseMEs()
Definition: DQWorker.cc:77
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
const_iterator & toNextChannel()
Definition: MESet.h:271
unsigned getMultiplicity() const
Definition: MESetMulti.h:81
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void use(unsigned) const
Definition: MESetMulti.cc:146
std::set< std::string > qualitySummaries_
virtual double getBinContent(DetId const &, int=0) const
Definition: MESet.h:72
static void fillDescriptions(edm::ParameterSetDescription &)
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
void resetAll(double=0., double=0., double=0.) override
Definition: MESetMulti.cc:139
virtual const_iterator beginChannel() const
Definition: MESet.h:291
virtual void reset(double=0., double=0., double=0.)
Definition: MESet.cc:110
std::vector< std::string > getParameterNames() const
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:85
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
void releaseMEs() override
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:31
MESetCollection MEs_
Definition: DQWorker.h:75
virtual void resetAll(double=0., double=0., double=0.)
Definition: MESet.cc:118
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:286
std::vector< DetId > scConstituents(EcalScDetId const &)
volatile std::atomic< bool > shutdown_flag false
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:19
void fillMESetDescriptions(edm::ParameterSetDescription &)
Definition: MESetUtils.cc:129
std::string name_
Definition: DQWorker.h:74