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.
3 
5 
7 
8 namespace ecaldqm
9 {
10  MESetChannel::MESetChannel(std::string const& _fullpath, MEData const& _data, bool _readOnly/* = false*/) :
11  MESet(_fullpath, _data, _readOnly),
12  meTable_()
13  {
14  }
15 
17  {
18  }
19 
20  bool
22  {
23  active_ = true;
24  return true;
25  }
26 
27  void
29  {
30  MESet::clear();
32  mes_.clear();
33  meTable_.clear();
34  }
35 
36  void
37  MESetChannel::fill(DetId const& _id, double _w/* = 1.*/, double, double)
38  {
39  uint32_t rawId(getIndex_(_id));
40 
41  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(rawId));
42  if(tableItr == meTable_.end()){
44  tableItr = append_(name, rawId);
45  }
46  if(tableItr == meTable_.end()) return;
47 
48  mes_.at(tableItr->second)->Fill(0.5, _w);
49  }
50 
51  void
52  MESetChannel::fill(EcalElectronicsId const& _id, double _w/* = 1.*/, double, double)
53  {
54  uint32_t rawId(getIndex_(_id));
55 
56  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(rawId));
57  if(tableItr == meTable_.end()){
59  tableItr = append_(name, rawId);
60  }
61  if(tableItr == meTable_.end()) return;
62 
63  mes_.at(tableItr->second)->Fill(0.5, _w);
64  }
65 
66  void
67  MESetChannel::setBinContent(DetId const& _id, double _content, double _err/* = 0.*/)
68  {
69  uint32_t rawId(getIndex_(_id));
70 
71  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(rawId));
72  if(tableItr == meTable_.end()){
74  tableItr = append_(name, rawId);
75  }
76  if(tableItr == meTable_.end()) return;
77 
78  mes_.at(tableItr->second)->setBinContent(1, _content);
79  mes_.at(tableItr->second)->setBinError(1, _err);
80  }
81 
82  void
83  MESetChannel::setBinContent(EcalElectronicsId const& _id, double _content, double _err/* = 0.*/)
84  {
85  uint32_t rawId(getIndex_(_id));
86 
87  std::map<uint32_t, unsigned>::iterator tableItr(meTable_.find(rawId));
88  if(tableItr == meTable_.end()){
90  tableItr = append_(name, rawId);
91  }
92  if(tableItr == meTable_.end()) return;
93 
94  mes_.at(tableItr->second)->setBinContent(1, _content);
95  mes_.at(tableItr->second)->setBinError(1, _err);
96  }
97 
98  void
99  MESetChannel::reset(double _content/* = 0.*/, double _err/* = 0.*/, double _entries/* = 0.*/)
100  {
101  if(readOnly_) return;
102 
103  if(_content == 0. && _entries == 0.){
104  mes_.clear();
105  meTable_.clear();
106  dqmStore_->rmdir(dir_);
107  return;
108  }
109 
110  for(unsigned iME(0); iME < mes_.size(); iME++){
111  mes_[iME]->setBinContent(1, _content);
112  mes_[iME]->setBinContent(1, _err);
114  mes_[iME]->setBinEntries(1, _entries);
115  }
116  }
117 
118  double
119  MESetChannel::getBinContent(DetId const& _id, int) const
120  {
121  uint32_t rawId(getIndex_(_id));
122 
123  std::map<uint32_t, unsigned>::const_iterator tableItr(meTable_.find(rawId));
124 
125  if(tableItr == meTable_.end()) return 0.;
126 
127  return mes_.at(tableItr->second)->getBinContent(1);
128  }
129 
130  double
132  {
133  uint32_t rawId(getIndex_(_id));
134 
135  std::map<uint32_t, unsigned>::const_iterator tableItr(meTable_.find(rawId));
136 
137  if(tableItr == meTable_.end()) return 0.;
138 
139  return mes_.at(tableItr->second)->getBinContent(1);
140  }
141 
142  void
144  {
145  using namespace std;
146 
147  vector<MonitorElement*> storeMEs(dqmStore_->getContents(dir_));
148  for(vector<MonitorElement*>::iterator storeItr(storeMEs.begin()); storeItr != storeMEs.end(); ++storeItr){
149  if(find(mes_.begin(), mes_.end(), *storeItr) != mes_.end()) continue;
150 
151  uint32_t id(binService_->idFromName((*storeItr)->getName()));
152  if(id != 0){
153  mes_.push_back(*storeItr);
154  meTable_[id] = mes_.size() - 1;
155  }
156  }
157  }
158 
159  std::map<uint32_t, unsigned>::iterator
160  MESetChannel::append_(std::string const& _name, uint32_t _rawId)
161  {
164 
165  MonitorElement* me(dqmStore_->book1D(_name, _name, 1, 0., 1.));
166 
168 
169  if(!me) return meTable_.end();
170 
171  mes_.push_back(me);
172  std::pair<std::map<uint32_t, unsigned>::iterator, bool> ins(meTable_.insert(std::pair<uint32_t, unsigned>(_rawId, mes_.size() - 1)));
173 
174  return ins.first;
175  }
176 
177  uint32_t
178  MESetChannel::getIndex_(DetId const& _id) const
179  {
180  switch(data_->btype){
182  return getElectronicsMap()->getElectronicsId(_id).rawId();
184  {
185  if(_id.subdetId() == EcalTriggerTower){
186  EcalTrigTowerDetId ttid(_id);
187  return EcalTriggerElectronicsId(getElectronicsMap()->TCCid(ttid), getElectronicsMap()->iTT(ttid), 1, 1).rawId();
188  }
189  else{
190  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
191  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
192  }
193  }
195  {
196  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(_id));
197  return EcalElectronicsId(eid.dccId(), eid.towerId(), 1, 1).rawId();
198  }
199  case BinService::kTCC:
200  {
201  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
202  return BinService::nDCC + teid.tccId();
203  }
204  case BinService::kDCC:
205  {
206  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(_id));
207  return eid.dccId();
208  }
209  default:
210  throw cms::Exception("InvalidConfiguration") << "MESetChannel configured with bin type " << data_->btype;
211  return 0;
212  }
213  }
214 
215  uint32_t
217  {
218  switch(data_->btype){
220  return _id.rawId();
222  {
223  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
224  return EcalTriggerElectronicsId(teid.tccId(), teid.ttId(), 1, 1).rawId();
225  }
227  return EcalElectronicsId(_id.dccId(), _id.towerId(), 1, 1).rawId();
228  case BinService::kTCC:
229  {
230  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(_id));
231  return BinService::nDCC + teid.tccId();
232  }
233  case BinService::kDCC:
234  return _id.dccId();
235  default:
236  throw cms::Exception("InvalidConfiguration") << "MESetChannel configured with bin type " << data_->btype;
237  return 0;
238  }
239  }
240 
241 }
std::string channelName(uint32_t, BinningType _btype=kDCC) const
const EcalElectronicsMapping * getElectronicsMap()
bool readOnly_
Definition: MESet.h:136
int tccId() const
get the DCC (Ecal Local DCC value not global one) id
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void reset(double _content=0., double _err=0., double _entries=0.)
Definition: MESetChannel.cc:99
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
virtual void clear() const
Definition: MESet.cc:59
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
MonitorElement::Kind kind
Definition: MESet.h:24
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
std::map< uint32_t, unsigned > meTable_
Definition: MESetChannel.h:42
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static DQMStore * dqmStore_
Definition: MESet.h:127
std::vector< MonitorElement * > mes_
Definition: MESetChannel.h:41
std::string dir_
Definition: MESet.h:131
int ttId() const
get the tower id
std::map< uint32_t, unsigned >::iterator append_(std::string const &, uint32_t)
bool retrieve() const
Definition: MESetChannel.cc:21
BinService::BinningType btype
Definition: MESet.h:23
tuple ins
Definition: cuy.py:312
uint32_t getIndex_(DetId const &) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1652
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
double getBinContent(DetId const &, int _bin=0) const
uint32_t rawId() const
void checkDirectory() const
Definition: DetId.h:18
void clear() const
Definition: MESetChannel.cc:28
static BinService const * binService_
Definition: MESet.h:126
MESetChannel(std::string const &, MEData const &, bool _readOnly=false)
Definition: MESetChannel.cc:10
bool active_
Definition: MESet.h:135
uint32_t idFromName(std::string const &) const
MEData const * data_
Definition: MESet.h:133
void fill(DetId const &, double _w=1., double _unused1=0., double _unused2=0.)
Definition: MESetChannel.cc:37
void setBinContent(DetId const &, double, double _err=0.)
Definition: MESetChannel.cc:67
void name(std::map< std::string, std::string > const &) const
Definition: MESet.cc:240
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
const std::string & pwd(void) const
Definition: DQMStore.cc:556