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