CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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&)
73  {
74  clear();
75  active_ = true;
76  }
77 
78  void
79  MESetChannel::book(DQMStore::IBooker&)
80  {
81  clear();
82  active_ = true;
83  }
84 
85  bool
86  MESetChannel::retrieve(DQMStore const&, std::string*/* = 0*/) const
87  {
88  checkDirectory();
89 
90  active_ = true;
91  return true;
92  }
93 
94  void
95  MESetChannel::clear() const
96  {
97  MESet::clear();
98  dqmStore_->rmdir(path_.substr(0, path_.find_last_of('/')));
99  meTable_.clear();
100  }
101 
102  void
103  MESetChannel::fill(DetId const& _id, double _w/* = 1.*/, double, double)
104  {
105  if(!active_) return;
106 
107  unsigned iME(preparePlot_(getIndex_(_id)));
108  if(iME == unsigned(-1)) return;
109  checkME_(iME);
110 
111  mes_[iME]->Fill(0.5, _w);
112  }
113 
114  void
115  MESetChannel::fill(EcalElectronicsId const& _id, double _w/* = 1.*/, double, double)
116  {
117  if(!active_) return;
118 
119  unsigned iME(preparePlot_(getIndex_(_id)));
120  if(iME == unsigned(-1)) return;
121  checkME_(iME);
122 
123  mes_[iME]->Fill(0.5, _w);
124  }
125 
126  void
127  MESetChannel::setBinContent(DetId const& _id, double _content)
128  {
129  if(!active_) return;
130 
131  unsigned iME(preparePlot_(getIndex_(_id)));
132  if(iME == unsigned(-1)) return;
133  checkME_(iME);
134 
135  mes_[iME]->setBinContent(1, _content);
136  }
137 
138  void
139  MESetChannel::setBinContent(EcalElectronicsId const& _id, double _content)
140  {
141  if(!active_) return;
142 
143  unsigned iME(preparePlot_(getIndex_(_id)));
144  if(iME == unsigned(-1)) return;
145  checkME_(iME);
146 
147  mes_[iME]->setBinContent(1, _content);
148  }
149 
150  void
151  MESetChannel::setBinError(DetId const& _id, double _error)
152  {
153  if(!active_) return;
154 
155  unsigned iME(preparePlot_(getIndex_(_id)));
156  if(iME == unsigned(-1)) return;
157  checkME_(iME);
158 
159  mes_[iME]->setBinError(1, _error);
160  }
161 
162  void
163  MESetChannel::setBinError(EcalElectronicsId const& _id, double _error)
164  {
165  if(!active_) return;
166 
167  unsigned iME(preparePlot_(getIndex_(_id)));
168  if(iME == unsigned(-1)) return;
169  checkME_(iME);
170 
171  mes_[iME]->setBinError(1, _error);
172  }
173 
174  void
175  MESetChannel::setBinEntries(DetId const& _id, double _entries)
176  {
177  if(!active_) return;
178 
179  unsigned iME(preparePlot_(getIndex_(_id)));
180  if(iME == unsigned(-1)) return;
181  checkME_(iME);
182 
183  mes_[iME]->setBinEntries(1, _entries);
184  }
185 
186  void
187  MESetChannel::setBinEntries(EcalElectronicsId const& _id, double _entries)
188  {
189  if(!active_) return;
190 
191  unsigned iME(preparePlot_(getIndex_(_id)));
192  if(iME == unsigned(-1)) return;
193  checkME_(iME);
194 
195  mes_[iME]->setBinEntries(1, _entries);
196  }
197 
198  double
199  MESetChannel::getBinContent(DetId const& _id, int) const
200  {
201  if(!active_) return 0.;
202 
203  unsigned iME(findPlot_(getIndex_(_id)));
204  if(iME == unsigned(-1)) return 0.;
205  checkME_(iME);
206 
207  return mes_[iME]->getBinContent(1);
208  }
209 
210  double
211  MESetChannel::getBinContent(EcalElectronicsId const& _id, int) const
212  {
213  if(!active_) return 0.;
214 
215  unsigned iME(findPlot_(getIndex_(_id)));
216  if(iME == unsigned(-1)) return 0.;
217  checkME_(iME);
218 
219  return mes_[iME]->getBinContent(1);
220  }
221 
222  double
223  MESetChannel::getBinError(DetId const& _id, int) const
224  {
225  if(!active_) return 0.;
226 
227  unsigned iME(findPlot_(getIndex_(_id)));
228  if(iME == unsigned(-1)) return 0.;
229  checkME_(iME);
230 
231  return mes_[iME]->getBinError(1);
232  }
233 
234  double
235  MESetChannel::getBinError(EcalElectronicsId const& _id, int) const
236  {
237  if(!active_) return 0.;
238 
239  unsigned iME(findPlot_(getIndex_(_id)));
240  if(iME == unsigned(-1)) return 0.;
241  checkME_(iME);
242 
243  return mes_[iME]->getBinError(1);
244  }
245 
246  double
247  MESetChannel::getBinEntries(DetId const& _id, int) const
248  {
249  if(!active_) return 0.;
250 
251  unsigned iME(findPlot_(getIndex_(_id)));
252  if(iME == unsigned(-1)) return 0.;
253  checkME_(iME);
254 
255  return mes_[iME]->getBinEntries(1);
256  }
257 
258  double
259  MESetChannel::getBinEntries(EcalElectronicsId const& _id, int) const
260  {
261  if(!active_) return 0.;
262 
263  unsigned iME(findPlot_(getIndex_(_id)));
264  if(iME == unsigned(-1)) return 0.;
265  checkME_(iME);
266 
267  return mes_[iME]->getBinEntries(1);
268  }
269 
270  void
271  MESetChannel::reset(double _content/* = 0.*/, double _err/* = 0.*/, double _entries/* = 0.*/)
272  {
273  if(!active_) return;
274 
275  if(_content == 0. && _entries == 0.){
276  mes_.clear();
277  meTable_.clear();
278  dqmStore_->rmdir(path_);
279  return;
280  }
281 
282  unsigned nME(mes_.size());
283  for(unsigned iME(0); iME < nME; iME++){
284  mes_[iME]->setBinContent(1, _content);
285  mes_[iME]->setBinError(1, _err);
287  mes_[iME]->setBinEntries(1, _entries);
288  }
289  }
290 
291  void
292  MESetChannel::checkDirectory() const
293  {
294  using namespace std;
295 
296  vector<MonitorElement*> storeMEs(dqmStore_->getContents(path_));
297 
298  unsigned nME(storeMEs.size());
299  for(unsigned iME(0); iME < nME; iME++){
300  MonitorElement* me(storeMEs[iME]);
301  if(find(mes_.begin(), mes_.end(), me) != mes_.end()) continue;
302 
303  uint32_t id(binning::idFromName(me->getName()));
304  if(id != 0){
305  mes_.push_back(me);
306  meTable_[id] = mes_.size() - 1;
307  }
308  }
309  }
310 
311  unsigned
312  MESetChannel::preparePlot_(uint32_t _rawId) const
313  {
314  if(_rawId == 0) return -1;
315 
316  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(_rawId));
317  if(tableItr == meTable_.end()){
318  if(meTable_.size() == maxTableSize){
319  edm::LogWarning("EcalDQM") << "max table size";
320  return -1;
321  }
322 
323  std::string name(binning::channelName(_rawId, btype_));
324  std::string pwd(dqmStore_->pwd());
325  dqmStore_->setCurrentFolder(path_);
326 
327  MonitorElement* me(0);
328  if(kind_ == MonitorElement::DQM_KIND_TH1F)
329  me = dqmStore_->book1D(name, name, 1, 0., 1.);
330  else
331  me = dqmStore_->bookProfile(name, name, 1, 0., 1., -std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
332 
333  dqmStore_->setCurrentFolder(pwd);
334 
335  if(me){
336  mes_.push_back(me);
337  tableItr = meTable_.insert(std::pair<uint32_t, unsigned>(_rawId, mes_.size() - 1)).first;
338  }
339  }
340  if(tableItr == meTable_.end()){
341  edm::LogError("EcalDQM") << "insertion error";
342  return -1;
343  }
344 
345  return tableItr->second;
346  }
347 
348  unsigned
349  MESetChannel::findPlot_(uint32_t _rawId) const
350  {
351  if(_rawId == 0) return -1;
352 
353  std::map<uint32_t, unsigned>::const_iterator tableItr(meTable_.find(_rawId));
354 
355  if(tableItr == meTable_.end()) return -1;
356 
357  return tableItr->second;
358  }
359 
360  uint32_t
361  MESetChannel::getIndex_(DetId const& _id) const
362  {
363  int subdet(_id.subdetId());
364 
365  switch(btype_){
366  case binning::kCrystal:
367  if(isCrystalId(_id)) return getElectronicsMap()->getElectronicsId(_id).rawId();
368  else if(_id.subdetId() == EcalLaserPnDiode){
369  EcalPnDiodeDetId pnid(_id);
370  return EcalElectronicsId(pnid.iDCCId(), pnid.iPnId() < 6 ? 69 : 70, 1, (pnid.iPnId() - 1) % 5 + 1).rawId();
371  }
372  break;
373 
375  if(subdet == EcalTriggerTower){
376  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
377  if(ids.size() > 0){
378  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(ids[0]));
379  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
380  }
381  }
382  else if(isCrystalId(_id)){
383  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
384  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
385  }
386  break;
387 
389  if(isCrystalId(_id)){
390  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(_id));
391  return EcalElectronicsId(eid.dccId(), eid.towerId(), 1, 1).rawId();
392  }
393  else if(isEcalScDetId(_id)){
394  std::pair<int, int> dccsc(getElectronicsMap()->getDCCandSC(EcalScDetId(_id)));
395  return EcalElectronicsId(dccsc.first, dccsc.second, 1, 1).rawId();
396  }
397  else if(subdet == EcalTriggerTower && !isEndcapTTId(_id)){
398  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
399  if(ids.size() > 0){
400  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(ids[0]));
401  return EcalElectronicsId(eid.dccId(), eid.towerId(), 1, 1).rawId();
402  }
403  }
404  break;
405 
406  case binning::kTCC:
407  return tccId(_id) + binning::nDCC;
408 
409  case binning::kDCC:
410  return dccId(_id);
411 
412  default:
413  break;
414  }
415 
416  return 0;
417  }
418 
419  uint32_t
420  MESetChannel::getIndex_(EcalElectronicsId const& _id) const
421  {
422  switch(btype_){
423  case binning::kCrystal:
424  return _id.rawId();
425 
427  {
428  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
429  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
430  }
431 
433  return EcalElectronicsId(_id.dccId(), _id.towerId(), 1, 1).rawId();
434 
435  case binning::kTCC:
436  return tccId(_id) + binning::nDCC;
437 
438  case binning::kDCC:
439  return _id.dccId();
440 
441  default:
442  break;
443  }
444 
445  return 0;
446  }
447 }
448 
449 #endif
string fill
Definition: lumiContext.py:319
virtual void clear() const
Definition: MESet.cc:93
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
EcalElectronicsMapping const * getElectronicsMap()
unsigned tccId(DetId const &)
int towerId() const
get the tower id
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool isEndcapTTId(DetId const &)
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
tuple path
else: Piece not in the list, fine.
const T & max(const T &a, const T &b)
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
uint32_t idFromName(std::string const &)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::string channelName(uint32_t, BinningType _btype=kDCC)
uint32_t rawId() const
bool isEcalScDetId(DetId const &)
Definition: DetId.h:18
std::string & path_
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool isCrystalId(DetId const &)
virtual MESet & operator=(MESet const &)
Definition: MESet.cc:70
unsigned dccId(DetId const &)
void reset(double vett[256])
Definition: TPedValues.cc:11
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...