CMS 3D CMS Logo

SiStripMonitorQuality.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorQuality
4 // Class: SiStripMonitorQuality
5 //
14 //
15 // Original Author: Suchandra Dutta
16 // Created: Fri Dec 7 20:50 CET 2007
17 //
18 //
19 
21 
24 
31 
34 
37 
38 // std
39 #include <algorithm>
40 #include <cmath>
41 #include <cstdlib>
42 #include <numeric>
43 
45  : dqmStore_(edm::Service<DQMStore>().operator->()),
46  conf_(iConfig),
47  m_cacheID_(0)
48 
49 {
50  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
51  << " Constructing....... ";
52 }
53 
55  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
56  << " Destructing....... ";
57 }
58 //
60  const edm::Run &run,
61  const edm::EventSetup &eSetup) {
62  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
63  if (m_cacheID_ == cacheID)
64  return;
65 
66  // Retrieve tracker topology from geometry
68  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
69  const TrackerTopology *const tTopo = tTopoHandle.product();
70 
71  m_cacheID_ = cacheID;
72 
73  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
74  eSetup.get<SiStripQualityRcd>().get(quality_label, stripQuality_);
75  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
76 
77  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
78  << " Reading SiStripQuality " << std::endl;
79 
82  uint32_t detid;
83 
84  if (rbegin == rend)
85  return;
86 
87  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
88  detid = rp->detid;
89  // Check consistency in DetId
90  if (detid == 0 || detid == 0xFFFFFFFF) {
91  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
92  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
93  continue;
94  }
95  // check if the detid is connected in cabling
96  if (!detCabling_->IsConnected(detid)) {
97  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
98  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
99  continue;
100  }
101 
102  MonitorElement *det_me;
103 
104  int nStrip = detCabling_->nApvPairs(detid) * 256;
105 
106  // use SistripHistoId for producing histogram id (and title)
107  SiStripHistoId hidmanager;
108  // create SiStripFolderOrganizer
109  SiStripFolderOrganizer folder_organizer;
110  // set appropriate folder using SiStripFolderOrganizer
111  folder_organizer.setDetectorFolder(detid,
112  tTopo); // pass the detid to this method
113 
114  std::string hid;
115  hid = hidmanager.createHistoId("StripQualityFromCondDB", "det", detid);
116 
117  det_me = ibooker.book1D(hid, hid, nStrip, 0.5, nStrip + 0.5);
118  ibooker.tag(det_me, detid);
119  det_me->setAxisTitle("Strip Number", 1);
120  det_me->setAxisTitle("Quality Flag from CondDB ", 2);
121  QualityMEs.insert(std::make_pair(detid, det_me));
122  }
123 }
124 
125 // ------------ method called to produce the data ------------
127  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
128  if (m_cacheID_ == cacheID)
129  return;
130 
131  // Retrieve tracker topology from geometry
132  edm::ESHandle<TrackerTopology> tTopoHandle;
133  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
134  const TrackerTopology *const tTopo = tTopoHandle.product();
135 
136  m_cacheID_ = cacheID;
137 
138  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
139  eSetup.get<SiStripQualityRcd>().get(quality_label, stripQuality_);
140  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
141 
142  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
143  << " Reading SiStripQuality " << std::endl;
144 
147  uint32_t detid;
148 
149  if (rbegin == rend)
150  return;
151 
152  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
153  detid = rp->detid;
154  // Check consistency in DetId
155  if (detid == 0 || detid == 0xFFFFFFFF) {
156  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
157  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
158  continue;
159  }
160  // check if the detid is connected in cabling
161  if (!detCabling_->IsConnected(detid)) {
162  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
163  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
164  continue;
165  }
166  MonitorElement *me = getQualityME(detid, tTopo);
168  stripQuality_->getDataVectorBegin() + rp->iend);
169  SiStripBadStrip::ContainerIterator it = range.first;
170  for (; it != range.second; ++it) {
171  unsigned int value = (*it);
172  short str_start = stripQuality_->decode(value).firstStrip;
173  short str_end = str_start + stripQuality_->decode(value).range;
174  for (short isr = str_start; isr < str_end + 1; isr++) {
175  if (isr <= (me->getNbinsX() - 1))
176  me->Fill(isr + 1, 1.0);
177  }
178  }
179  }
180 }
181 //
182 // -- End Run
183 //
185  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
187  if (outputMEsInRootFile) {
188  // dqmStore_->showDirStructure();
189  dqmStore_->save(outputFileName);
190  }
191 }
192 //
193 // -- End Job
194 //
196  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::EndJob: "
197  << " Finishing!! ";
198 }
199 //
200 // -- End Job
201 //
203  std::map<uint32_t, MonitorElement *>::iterator pos = QualityMEs.find(idet);
204  MonitorElement *det_me = nullptr;
205  if (pos != QualityMEs.end()) {
206  det_me = pos->second;
207  det_me->Reset();
208  } else {
209  // this should never happen because of bookHistograms()
210  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::getQualityME : "
211  << "Wrong DetId !!!!!! " << idet << " No ME found!";
212  }
213  return det_me;
214 }
unsigned short range
T getParameter(std::string const &) const
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
std::map< uint32_t, MonitorElement * > QualityMEs
std::vector< unsigned int >::const_iterator ContainerIterator
edm::ESHandle< SiStripQuality > stripQuality_
bool IsConnected(const uint32_t &det_id) const
Registry::const_iterator RegistryIterator
void Fill(long long x)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
RegistryIterator getRegistryVectorEnd() const
edm::ESHandle< SiStripDetCabling > detCabling_
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:283
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: value.py:1
void Reset()
reset ME (ie. contents, errors, etc)
ContainerIterator getDataVectorBegin() const
unsigned short firstStrip
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2465
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) const
SiStripMonitorQuality(const edm::ParameterSet &)
HLT enums.
std::pair< ContainerIterator, ContainerIterator > Range
T get() const
Definition: EventSetup.h:71
unsigned long long m_cacheID_
int getNbinsX() const
get # of bins in X-axis
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:86
data decode(const unsigned int &value) const
Definition: Run.h:45