CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  tTopoToken_(esConsumes<edm::Transition::BeginRun>()),
47  detCablingToken_(esConsumes<edm::Transition::BeginRun>()),
48  qualityToken_(esConsumes<edm::Transition::BeginRun>(
49  edm::ESInputTag{"", iConfig.getParameter<std::string>("StripQualityLabel")})) {
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  if (!qualityWatcher_.check(eSetup))
63  return;
64 
65  const auto tTopo = &eSetup.getData(tTopoToken_);
66 
69 
70  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
71  << " Reading SiStripQuality " << std::endl;
72 
75  uint32_t detid;
76 
77  if (rbegin == rend)
78  return;
79 
80  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
81  detid = rp->detid;
82  // Check consistency in DetId
83  if (detid == 0 || detid == 0xFFFFFFFF) {
84  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
85  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
86  continue;
87  }
88  // check if the detid is connected in cabling
89  if (!detCabling_->IsConnected(detid)) {
90  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::bookHistograms : "
91  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
92  continue;
93  }
94 
95  MonitorElement *det_me;
96 
97  int nStrip = detCabling_->nApvPairs(detid) * 256;
98 
99  // use SistripHistoId for producing histogram id (and title)
101  // create SiStripFolderOrganizer
103  // set appropriate folder using SiStripFolderOrganizer
104  folder_organizer.setDetectorFolder(detid,
105  tTopo); // pass the detid to this method
106 
107  std::string hid;
108  hid = hidmanager.createHistoId("StripQualityFromCondDB", "det", detid);
109 
110  det_me = ibooker.book1D(hid, hid, nStrip, 0.5, nStrip + 0.5);
111  det_me->setAxisTitle("Strip Number", 1);
112  det_me->setAxisTitle("Quality Flag from CondDB ", 2);
113  QualityMEs.insert(std::make_pair(detid, det_me));
114  }
115 }
116 
117 // ------------ method called to produce the data ------------
119  if (!qualityWatcher_.check(eSetup))
120  return;
121 
122  const auto tTopo = &eSetup.getData(tTopoToken_);
125 
126  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "
127  << " Reading SiStripQuality " << std::endl;
128 
131  uint32_t detid;
132 
133  if (rbegin == rend)
134  return;
135 
136  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
137  detid = rp->detid;
138  // Check consistency in DetId
139  if (detid == 0 || detid == 0xFFFFFFFF) {
140  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
141  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
142  continue;
143  }
144  // check if the detid is connected in cabling
145  if (!detCabling_->IsConnected(detid)) {
146  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze : "
147  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
148  continue;
149  }
150  MonitorElement *me = getQualityME(detid, tTopo);
152  stripQuality_->getDataVectorBegin() + rp->iend);
153  SiStripBadStrip::ContainerIterator it = range.first;
154  for (; it != range.second; ++it) {
155  unsigned int value = (*it);
156  short str_start = stripQuality_->decode(value).firstStrip;
157  short str_end = str_start + stripQuality_->decode(value).range;
158  for (short isr = str_start; isr < str_end + 1; isr++) {
159  if (isr <= (me->getNbinsX() - 1))
160  me->Fill(isr + 1, 1.0);
161  }
162  }
163  }
164 }
165 //
166 // -- End Run
167 //
169  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
171  if (outputMEsInRootFile) {
172  dqmStore_->save(outputFileName);
173  }
174 }
175 //
176 // -- End Job
177 //
179  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::EndJob: "
180  << " Finishing!! ";
181 }
182 //
183 // -- End Job
184 //
186  const TrackerTopology *tTopo) {
187  std::map<uint32_t, MonitorElement *>::iterator pos = QualityMEs.find(idet);
188  MonitorElement *det_me = nullptr;
189  if (pos != QualityMEs.end()) {
190  det_me = pos->second;
191  det_me->Reset();
192  } else {
193  // this should never happen because of bookHistograms()
194  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::getQualityME : "
195  << "Wrong DetId !!!!!! " << idet << " No ME found!";
196  }
197  return det_me;
198 }
unsigned short range
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::map< uint32_t, MonitorElement * > QualityMEs
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< unsigned int >::const_iterator ContainerIterator
bool IsConnected(const uint32_t &det_id) const
Registry::const_iterator RegistryIterator
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
Log< level::Error, false > LogError
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
const uint16_t range(const Frame &aFrame)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
void Fill(long long x)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
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
RegistryIterator getRegistryVectorEnd() const
virtual int getNbinsX() const
get # of bins in X-axis
void analyze(const edm::Event &, const edm::EventSetup &) override
Transition
Definition: Transition.h:12
const SiStripDetCabling * detCabling_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
ContainerIterator getDataVectorBegin() const
SiStripHistoId hidmanager
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)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripFolderOrganizer folder_organizer
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) const
SiStripMonitorQuality(const edm::ParameterSet &)
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:784
std::pair< ContainerIterator, ContainerIterator > Range
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
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_
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)