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 
23 
30 
33 
36 
37 // std
38 #include <algorithm>
39 #include <cmath>
40 #include <cstdlib>
41 #include <numeric>
42 
44  : dqmStore_(edm::Service<DQMStore>().operator->()),
45  conf_(iConfig),
46  m_cacheID_(0)
47 
48 {
49  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
50  << " Constructing....... ";
51 }
52 
54  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
55  << " Destructing....... ";
56 }
57 //
59  const edm::Run &run,
60  const edm::EventSetup &eSetup) {
61  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
62  if (m_cacheID_ == cacheID)
63  return;
64 
65  // Retrieve tracker topology from geometry
67  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
68  const TrackerTopology *const tTopo = tTopoHandle.product();
69 
70  m_cacheID_ = cacheID;
71 
72  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
73  eSetup.get<SiStripQualityRcd>().get(quality_label, stripQuality_);
74  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
75 
76  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
77  << " Reading SiStripQuality " << std::endl;
78 
81  uint32_t detid;
82 
83  if (rbegin == rend)
84  return;
85 
86  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
87  detid = rp->detid;
88  // Check consistency in DetId
89  if (detid == 0 || detid == 0xFFFFFFFF) {
90  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
91  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
92  continue;
93  }
94  // check if the detid is connected in cabling
95  if (!detCabling_->IsConnected(detid)) {
96  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
97  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
98  continue;
99  }
100 
101  MonitorElement *det_me;
102 
103  int nStrip = detCabling_->nApvPairs(detid) * 256;
104 
105  // use SistripHistoId for producing histogram id (and title)
106  SiStripHistoId hidmanager;
107  // create SiStripFolderOrganizer
108  SiStripFolderOrganizer folder_organizer;
109  // set appropriate folder using SiStripFolderOrganizer
110  folder_organizer.setDetectorFolder(detid,
111  tTopo); // pass the detid to this method
112 
113  std::string hid;
114  hid = hidmanager.createHistoId("StripQualityFromCondDB", "det", detid);
115 
116  det_me = ibooker.book1D(hid, hid, nStrip, 0.5, nStrip + 0.5);
117  det_me->setAxisTitle("Strip Number", 1);
118  det_me->setAxisTitle("Quality Flag from CondDB ", 2);
119  QualityMEs.insert(std::make_pair(detid, det_me));
120  }
121 }
122 
123 // ------------ method called to produce the data ------------
125  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
126  if (m_cacheID_ == cacheID)
127  return;
128 
129  // Retrieve tracker topology from geometry
130  edm::ESHandle<TrackerTopology> tTopoHandle;
131  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
132  const TrackerTopology *const tTopo = tTopoHandle.product();
133 
134  m_cacheID_ = cacheID;
135 
136  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
137  eSetup.get<SiStripQualityRcd>().get(quality_label, stripQuality_);
138  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
139 
140  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
141  << " Reading SiStripQuality " << std::endl;
142 
145  uint32_t detid;
146 
147  if (rbegin == rend)
148  return;
149 
150  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
151  detid = rp->detid;
152  // Check consistency in DetId
153  if (detid == 0 || detid == 0xFFFFFFFF) {
154  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
155  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
156  continue;
157  }
158  // check if the detid is connected in cabling
159  if (!detCabling_->IsConnected(detid)) {
160  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
161  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
162  continue;
163  }
164  MonitorElement *me = getQualityME(detid, tTopo);
166  stripQuality_->getDataVectorBegin() + rp->iend);
167  SiStripBadStrip::ContainerIterator it = range.first;
168  for (; it != range.second; ++it) {
169  unsigned int value = (*it);
170  short str_start = stripQuality_->decode(value).firstStrip;
171  short str_end = str_start + stripQuality_->decode(value).range;
172  for (short isr = str_start; isr < str_end + 1; isr++) {
173  if (isr <= (me->getNbinsX() - 1))
174  me->Fill(isr + 1, 1.0);
175  }
176  }
177  }
178 }
179 //
180 // -- End Run
181 //
183  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
185  if (outputMEsInRootFile) {
186  // dqmStore_->showDirStructure();
187  dqmStore_->save(outputFileName);
188  }
189 }
190 //
191 // -- End Job
192 //
194  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::EndJob: "
195  << " Finishing!! ";
196 }
197 //
198 // -- End Job
199 //
201  const TrackerTopology *tTopo) {
202  std::map<uint32_t, MonitorElement *>::iterator pos = QualityMEs.find(idet);
203  MonitorElement *det_me = nullptr;
204  if (pos != QualityMEs.end()) {
205  det_me = pos->second;
206  det_me->Reset();
207  } else {
208  // this should never happen because of bookHistograms()
209  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::getQualityME : "
210  << "Wrong DetId !!!!!! " << idet << " No ME found!";
211  }
212  return det_me;
213 }
unsigned short range
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
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
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
void Fill(long long x)
virtual void Reset()
reset ME (ie. contents, errors, etc)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
RegistryIterator getRegistryVectorEnd() const
virtual int getNbinsX() const
get # of bins in X-axis
edm::ESHandle< SiStripDetCabling > detCabling_
void analyze(const edm::Event &, const edm::EventSetup &) override
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: value.py:1
ContainerIterator getDataVectorBegin() const
unsigned short firstStrip
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
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:73
unsigned long long m_cacheID_
void dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) override
T const * product() const
Definition: ESHandle.h:86
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:2244
data decode(const unsigned int &value) const
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)