CMS 3D CMS Logo

MESetChannel.cc
Go to the documentation of this file.
1 // Class removed until concurrency issue is finalized
2 #if 0
3 
6 
9 
11 
12 #include <limits>
13 #include <iomanip>
14 
15 namespace ecaldqm
16 {
17  static const unsigned maxTableSize(100);
18 
19  MESetChannel::MESetChannel(std::string const& _fullPath, binning::ObjectType _otype, binning::BinningType _btype, MonitorElement::Kind _kind) :
20  MESet(_fullPath, _otype, _btype, _kind),
21  meTable_()
22  {
23  switch(kind_){
26  break;
27  default:
28  throw_("Unsupported MonitorElement kind");
29  }
30 
31  switch(btype_){
32  case binning::kCrystal:
35  case binning::kTCC:
36  case binning::kDCC:
37  break;
38  default:
39  throw_("MESetChannel configured with wrong binning type");
40  }
41  }
42 
43  MESetChannel::MESetChannel(MESetChannel const& _orig) :
44  MESet(_orig),
45  meTable_(_orig.meTable_)
46  {
47  }
48 
49  MESetChannel::~MESetChannel()
50  {
51  }
52 
53  MESet&
54  MESetChannel::operator=(MESet const& _rhs)
55  {
56  MESetChannel const* pRhs(dynamic_cast<MESetChannel const*>(&_rhs));
57  if(pRhs) meTable_ = pRhs->meTable_;
58  return MESet::operator=(_rhs);
59  }
60 
61  MESet*
62  MESetChannel::clone(std::string const& _path/* = ""*/) const
63  {
65  if(_path != "") path_ = _path;
66  MESet* copy(new MESetChannel(*this));
67  path_ = path;
68  return copy;
69  }
70 
71  void
72  MESetChannel::book(DQMStore::IBooker&)
73  {
74  clear();
75  active_ = true;
76  }
77 
78  bool
79  MESetChannel::retrieve(DQMStore::IGetter&, std::string*/* = 0*/) const
80  {
81  checkDirectory();
82 
83  active_ = true;
84  return true;
85  }
86 
87  void
88  MESetChannel::clear() const
89  {
90  MESet::clear();
91  dqmStore_->rmdir(path_.substr(0, path_.find_last_of('/')));
92  meTable_.clear();
93  }
94 
95  void
96  MESetChannel::fill(DetId const& _id, double _w/* = 1.*/, double, double)
97  {
98  if(!active_) return;
99 
100  unsigned iME(preparePlot_(getIndex_(_id)));
101  if(iME == unsigned(-1)) return;
102  checkME_(iME);
103 
104  mes_[iME]->Fill(0.5, _w);
105  }
106 
107  void
108  MESetChannel::fill(EcalElectronicsId const& _id, double _w/* = 1.*/, double, double)
109  {
110  if(!active_) return;
111 
112  unsigned iME(preparePlot_(getIndex_(_id)));
113  if(iME == unsigned(-1)) return;
114  checkME_(iME);
115 
116  mes_[iME]->Fill(0.5, _w);
117  }
118 
119  void
120  MESetChannel::setBinContent(DetId const& _id, double _content)
121  {
122  if(!active_) return;
123 
124  unsigned iME(preparePlot_(getIndex_(_id)));
125  if(iME == unsigned(-1)) return;
126  checkME_(iME);
127 
128  mes_[iME]->setBinContent(1, _content);
129  }
130 
131  void
132  MESetChannel::setBinContent(EcalElectronicsId const& _id, double _content)
133  {
134  if(!active_) return;
135 
136  unsigned iME(preparePlot_(getIndex_(_id)));
137  if(iME == unsigned(-1)) return;
138  checkME_(iME);
139 
140  mes_[iME]->setBinContent(1, _content);
141  }
142 
143  void
144  MESetChannel::setBinError(DetId const& _id, double _error)
145  {
146  if(!active_) return;
147 
148  unsigned iME(preparePlot_(getIndex_(_id)));
149  if(iME == unsigned(-1)) return;
150  checkME_(iME);
151 
152  mes_[iME]->setBinError(1, _error);
153  }
154 
155  void
156  MESetChannel::setBinError(EcalElectronicsId const& _id, double _error)
157  {
158  if(!active_) return;
159 
160  unsigned iME(preparePlot_(getIndex_(_id)));
161  if(iME == unsigned(-1)) return;
162  checkME_(iME);
163 
164  mes_[iME]->setBinError(1, _error);
165  }
166 
167  void
168  MESetChannel::setBinEntries(DetId const& _id, double _entries)
169  {
170  if(!active_) return;
171 
172  unsigned iME(preparePlot_(getIndex_(_id)));
173  if(iME == unsigned(-1)) return;
174  checkME_(iME);
175 
176  mes_[iME]->setBinEntries(1, _entries);
177  }
178 
179  void
180  MESetChannel::setBinEntries(EcalElectronicsId const& _id, double _entries)
181  {
182  if(!active_) return;
183 
184  unsigned iME(preparePlot_(getIndex_(_id)));
185  if(iME == unsigned(-1)) return;
186  checkME_(iME);
187 
188  mes_[iME]->setBinEntries(1, _entries);
189  }
190 
191  double
192  MESetChannel::getBinContent(DetId const& _id, int) const
193  {
194  if(!active_) return 0.;
195 
196  unsigned iME(findPlot_(getIndex_(_id)));
197  if(iME == unsigned(-1)) return 0.;
198  checkME_(iME);
199 
200  return mes_[iME]->getBinContent(1);
201  }
202 
203  double
204  MESetChannel::getBinContent(EcalElectronicsId const& _id, int) const
205  {
206  if(!active_) return 0.;
207 
208  unsigned iME(findPlot_(getIndex_(_id)));
209  if(iME == unsigned(-1)) return 0.;
210  checkME_(iME);
211 
212  return mes_[iME]->getBinContent(1);
213  }
214 
215  double
216  MESetChannel::getBinError(DetId const& _id, int) const
217  {
218  if(!active_) return 0.;
219 
220  unsigned iME(findPlot_(getIndex_(_id)));
221  if(iME == unsigned(-1)) return 0.;
222  checkME_(iME);
223 
224  return mes_[iME]->getBinError(1);
225  }
226 
227  double
228  MESetChannel::getBinError(EcalElectronicsId const& _id, int) const
229  {
230  if(!active_) return 0.;
231 
232  unsigned iME(findPlot_(getIndex_(_id)));
233  if(iME == unsigned(-1)) return 0.;
234  checkME_(iME);
235 
236  return mes_[iME]->getBinError(1);
237  }
238 
239  double
240  MESetChannel::getBinEntries(DetId const& _id, int) const
241  {
242  if(!active_) return 0.;
243 
244  unsigned iME(findPlot_(getIndex_(_id)));
245  if(iME == unsigned(-1)) return 0.;
246  checkME_(iME);
247 
248  return mes_[iME]->getBinEntries(1);
249  }
250 
251  double
252  MESetChannel::getBinEntries(EcalElectronicsId const& _id, int) const
253  {
254  if(!active_) return 0.;
255 
256  unsigned iME(findPlot_(getIndex_(_id)));
257  if(iME == unsigned(-1)) return 0.;
258  checkME_(iME);
259 
260  return mes_[iME]->getBinEntries(1);
261  }
262 
263  void
264  MESetChannel::reset(double _content/* = 0.*/, double _err/* = 0.*/, double _entries/* = 0.*/)
265  {
266  if(!active_) return;
267 
268  if(_content == 0. && _entries == 0.){
269  mes_.clear();
270  meTable_.clear();
271  dqmStore_->rmdir(path_);
272  return;
273  }
274 
275  unsigned nME(mes_.size());
276  for(unsigned iME(0); iME < nME; iME++){
277  mes_[iME]->setBinContent(1, _content);
278  mes_[iME]->setBinError(1, _err);
279  if(kind_ == MonitorElement::Kind::TPROFILE)
280  mes_[iME]->setBinEntries(1, _entries);
281  }
282  }
283 
284  void
285  MESetChannel::checkDirectory() const
286  {
287  using namespace std;
288 
289  vector<MonitorElement*> storeMEs(dqmStore_->getContents(path_));
290 
291  unsigned nME(storeMEs.size());
292  for(unsigned iME(0); iME < nME; iME++){
293  MonitorElement* me(storeMEs[iME]);
294  if(find(mes_.begin(), mes_.end(), me) != mes_.end()) continue;
295 
296  uint32_t id(binning::idFromName(me->getName()));
297  if(id != 0){
298  mes_.push_back(me);
299  meTable_[id] = mes_.size() - 1;
300  }
301  }
302  }
303 
304  unsigned
305  MESetChannel::preparePlot_(uint32_t _rawId) const
306  {
307  if(_rawId == 0) return -1;
308 
309  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(_rawId));
310  if(tableItr == meTable_.end()){
311  if(meTable_.size() == maxTableSize){
312  edm::LogWarning("EcalDQM") << "max table size";
313  return -1;
314  }
315 
316  std::string name(binning::channelName(_rawId, btype_));
317  std::string pwd(dqmStore_->pwd());
318  dqmStore_->setCurrentFolder(path_);
319 
320  MonitorElement* me(0);
321  if(kind_ == MonitorElement::Kind::TH1F)
322  me = dqmStore_->book1D(name, name, 1, 0., 1.);
323  else
324  me = dqmStore_->bookProfile(name, name, 1, 0., 1., -std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
325 
326  dqmStore_->setCurrentFolder(pwd);
327 
328  if(me){
329  mes_.push_back(me);
330  tableItr = meTable_.insert(std::pair<uint32_t, unsigned>(_rawId, mes_.size() - 1)).first;
331  }
332  }
333  if(tableItr == meTable_.end()){
334  edm::LogError("EcalDQM") << "insertion error";
335  return -1;
336  }
337 
338  return tableItr->second;
339  }
340 
341  unsigned
342  MESetChannel::findPlot_(uint32_t _rawId) const
343  {
344  if(_rawId == 0) return -1;
345 
346  std::map<uint32_t, unsigned>::const_iterator tableItr(meTable_.find(_rawId));
347 
348  if(tableItr == meTable_.end()) return -1;
349 
350  return tableItr->second;
351  }
352 
353  uint32_t
354  MESetChannel::getIndex_(DetId const& _id) const
355  {
356  int subdet(_id.subdetId());
357 
358  switch(btype_){
359  case binning::kCrystal:
360  if(isCrystalId(_id)) return getElectronicsMap()->getElectronicsId(_id).rawId();
361  else if(_id.subdetId() == EcalLaserPnDiode){
362  EcalPnDiodeDetId pnid(_id);
363  return EcalElectronicsId(pnid.iDCCId(), pnid.iPnId() < 6 ? 69 : 70, 1, (pnid.iPnId() - 1) % 5 + 1).rawId();
364  }
365  break;
366 
368  if(subdet == EcalTriggerTower){
369  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
370  if(ids.size() > 0){
371  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(ids[0]));
372  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
373  }
374  }
375  else if(isCrystalId(_id)){
376  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
377  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
378  }
379  break;
380 
382  if(isCrystalId(_id)){
383  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(_id));
384  return EcalElectronicsId(eid.dccId(), eid.towerId(), 1, 1).rawId();
385  }
386  else if(isEcalScDetId(_id)){
387  std::pair<int, int> dccsc(getElectronicsMap()->getDCCandSC(EcalScDetId(_id)));
388  return EcalElectronicsId(dccsc.first, dccsc.second, 1, 1).rawId();
389  }
390  else if(subdet == EcalTriggerTower && !isEndcapTTId(_id)){
391  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
392  if(ids.size() > 0){
393  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(ids[0]));
394  return EcalElectronicsId(eid.dccId(), eid.towerId(), 1, 1).rawId();
395  }
396  }
397  break;
398 
399  case binning::kTCC:
400  return tccId(_id) + binning::nDCC;
401 
402  case binning::kDCC:
403  return dccId(_id);
404 
405  default:
406  break;
407  }
408 
409  return 0;
410  }
411 
412  uint32_t
413  MESetChannel::getIndex_(EcalElectronicsId const& _id) const
414  {
415  switch(btype_){
416  case binning::kCrystal:
417  return _id.rawId();
418 
420  {
421  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
422  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
423  }
424 
426  return EcalElectronicsId(_id.dccId(), _id.towerId(), 1, 1).rawId();
427 
428  case binning::kTCC:
429  return tccId(_id) + binning::nDCC;
430 
431  case binning::kDCC:
432  return _id.dccId();
433 
434  default:
435  break;
436  }
437 
438  return 0;
439  }
440 }
441 
442 #endif
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool isEndcapTTId(DetId const &)
int towerId() const
get the tower id
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
uint32_t idFromName(std::string const &)
bool isEcalScDetId(DetId const &)
Definition: DetId.h:17
uint32_t rawId() const
std::string & path_
unsigned tccId(DetId const &, EcalElectronicsMapping const *)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool isCrystalId(DetId const &)
std::string channelName(EcalElectronicsMapping const *, uint32_t, BinningType _btype=kDCC)
virtual MESet & operator=(MESet const &)
Definition: MESet.cc:64
void clear(EGIsoObj &c)
Definition: egamma.h:82
Log< level::Warning, false > LogWarning
void reset(double vett[256])
Definition: TPedValues.cc:11
virtual void clear() const
Definition: MESet.cc:84
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...