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 
32 
33 // std
34 #include <algorithm>
35 #include <cmath>
36 #include <cstdlib>
37 #include <numeric>
38 
40  : dqmStore_(edm::Service<DQMStore>().operator->()),
41  conf_(iConfig),
42  tTopoToken_(esConsumes<edm::Transition::BeginRun>()),
43  detCablingToken_(esConsumes<edm::Transition::BeginRun>()),
44  qualityToken_(esConsumes<edm::Transition::BeginRun>(
45  edm::ESInputTag{"", iConfig.getParameter<std::string>("StripQualityLabel")})) {
46  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
47  << " Constructing....... ";
48 }
49 
51  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality "
52  << " Destructing....... ";
53 }
54 //
56  const edm::Run &run,
57  const edm::EventSetup &eSetup) {
58  if (!qualityWatcher_.check(eSetup))
59  return;
60 
61  const auto tTopo = &eSetup.getData(tTopoToken_);
62 
65 
66  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
67  << " Reading SiStripQuality " << std::endl;
68 
71  uint32_t detid;
72 
73  if (rbegin == rend)
74  return;
75 
76  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
77  detid = rp->detid;
78  // Check consistency in DetId
79  if (detid == 0 || detid == 0xFFFFFFFF) {
80  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
81  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
82  continue;
83  }
84  // check if the detid is connected in cabling
85  if (!detCabling_->IsConnected(detid)) {
86  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
87  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
88  continue;
89  }
90 
91  MonitorElement *det_me;
92 
93  int nStrip = detCabling_->nApvPairs(detid) * 256;
94 
95  // use SistripHistoId for producing histogram id (and title)
96  SiStripHistoId hidmanager;
97  // create SiStripFolderOrganizer
98  SiStripFolderOrganizer folder_organizer;
99  // set appropriate folder using SiStripFolderOrganizer
100  folder_organizer.setDetectorFolder(detid,
101  tTopo); // pass the detid to this method
102 
103  std::string hid;
104  hid = hidmanager.createHistoId("StripQualityFromCondDB", "det", detid);
105 
106  det_me = ibooker.book1D(hid, hid, nStrip, 0.5, nStrip + 0.5);
107  det_me->setAxisTitle("Strip Number", 1);
108  det_me->setAxisTitle("Quality Flag from CondDB ", 2);
109  QualityMEs.insert(std::make_pair(detid, det_me));
110  }
111 }
112 
113 // ------------ method called to produce the data ------------
115  if (!qualityWatcher_.check(eSetup))
116  return;
117 
118  const auto tTopo = &eSetup.getData(tTopoToken_);
121 
122  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
123  << " Reading SiStripQuality " << std::endl;
124 
127  uint32_t detid;
128 
129  if (rbegin == rend)
130  return;
131 
132  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
133  detid = rp->detid;
134  // Check consistency in DetId
135  if (detid == 0 || detid == 0xFFFFFFFF) {
136  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
137  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
138  continue;
139  }
140  // check if the detid is connected in cabling
141  if (!detCabling_->IsConnected(detid)) {
142  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
143  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
144  continue;
145  }
146  MonitorElement *me = getQualityME(detid, tTopo);
148  stripQuality_->getDataVectorBegin() + rp->iend);
150  for (; it != range.second; ++it) {
151  unsigned int value = (*it);
152  short str_start = stripQuality_->decode(value).firstStrip;
153  short str_end = str_start + stripQuality_->decode(value).range;
154  for (short isr = str_start; isr < str_end + 1; isr++) {
155  if (isr <= (me->getNbinsX() - 1))
156  me->Fill(isr + 1, 1.0);
157  }
158  }
159  }
160 }
161 //
162 // -- End Run
163 //
165  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
167  if (outputMEsInRootFile) {
169  }
170 }
171 //
172 // -- End Job
173 //
175  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::EndJob: "
176  << " Finishing!! ";
177 }
178 //
179 // -- End Job
180 //
182  const TrackerTopology *tTopo) {
183  std::map<uint32_t, MonitorElement *>::iterator pos = QualityMEs.find(idet);
184  MonitorElement *det_me = nullptr;
185  if (pos != QualityMEs.end()) {
186  det_me = pos->second;
187  det_me->Reset();
188  } else {
189  // this should never happen because of bookHistograms()
190  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::getQualityME : "
191  << "Wrong DetId !!!!!! " << idet << " No ME found!";
192  }
193  return det_me;
194 }
unsigned short range
ContainerIterator getDataVectorBegin() const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::map< uint32_t, MonitorElement * > QualityMEs
std::vector< unsigned int >::const_iterator ContainerIterator
Registry::const_iterator RegistryIterator
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
Log< level::Error, false > LogError
bool IsConnected(const uint32_t &det_id) const
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
Transition
Definition: Transition.h:12
RegistryIterator getRegistryVectorEnd() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const SiStripDetCabling * detCabling_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: value.py:1
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
const SiStripQuality * stripQuality_
Log< level::Info, false > LogInfo
unsigned short firstStrip
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
SiStripMonitorQuality(const edm::ParameterSet &)
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:824
HLT enums.
std::pair< ContainerIterator, ContainerIterator > Range
data decode(const unsigned int &value) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) override
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) 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)