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 //
58 void SiStripMonitorQuality::bookHistograms(DQMStore::IBooker &ibooker,
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_);
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_);
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);
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) {
187  }
188 }
189 //
190 // -- End Job
191 //
193  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::EndJob: "
194  << " Finishing!! ";
195 }
196 //
197 // -- End Job
198 //
200  const TrackerTopology *tTopo) {
201  std::map<uint32_t, MonitorElement *>::iterator pos = QualityMEs.find(idet);
202  MonitorElement *det_me = nullptr;
203  if (pos != QualityMEs.end()) {
204  det_me = pos->second;
205  det_me->Reset();
206  } else {
207  // this should never happen because of bookHistograms()
208  edm::LogError("SiStripMonitorQuality") << "SiStripMonitorQuality::getQualityME : "
209  << "Wrong DetId !!!!!! " << idet << " No ME found!";
210  }
211  return det_me;
212 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
MessageLogger.h
SiStripFolderOrganizer.h
SiStripHistoId.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
pos
Definition: PixelAliasList.h:18
edm::LogInfo
Definition: MessageLogger.h:254
SiStripBadStrip::decode
data decode(const unsigned int &value) const
Definition: SiStripBadStrip.h:78
SiStripMonitorQuality::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: SiStripMonitorQuality.cc:58
SiStripMonitorQuality::conf_
edm::ParameterSet conf_
Definition: SiStripMonitorQuality.h:60
DQMStore.h
SiStripMonitorQuality::QualityMEs
std::map< uint32_t, MonitorElement * > QualityMEs
Definition: SiStripMonitorQuality.h:64
SiStripBadStrip::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripBadStrip.h:73
Utilities.operator
operator
Definition: Utilities.py:24
SiStripMonitorQuality.h
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripDetCabling.h
SiStripBadStrip::getRegistryVectorBegin
RegistryIterator getRegistryVectorBegin() const
Definition: SiStripBadStrip.h:75
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:727
Service.h
SiStripQualityRcd
Definition: SiStripDependentRecords.h:56
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:354
edm::ESHandle< TrackerTopology >
Service
reco_skim_cfg_mod.outputFileName
outputFileName
Definition: reco_skim_cfg_mod.py:15
SiStripDetCabling::IsConnected
bool IsConnected(const uint32_t &det_id) const
Definition: SiStripDetCabling.cc:375
SiStripDetCablingRcd
Definition: SiStripDependentRecords.h:19
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:760
SiStripMonitorQuality::dqmEndRun
void dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripMonitorQuality.cc:182
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
SiStripMonitorQuality::stripQuality_
edm::ESHandle< SiStripQuality > stripQuality_
Definition: SiStripMonitorQuality.h:62
iEvent
int iEvent
Definition: GenABIO.cc:224
SiStripBadStrip::data::firstStrip
unsigned short firstStrip
Definition: SiStripBadStrip.h:33
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:57
SiStripMonitorQuality::getQualityME
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
Definition: SiStripMonitorQuality.cc:199
SiStripMonitorQuality::~SiStripMonitorQuality
~SiStripMonitorQuality() override
Definition: SiStripMonitorQuality.cc:53
get
#define get
SiStripHistoId::createHistoId
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
Definition: SiStripHistoId.cc:26
SiStripFolderOrganizer::setDetectorFolder
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
Definition: SiStripFolderOrganizer.cc:202
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiStripHistoId
Definition: SiStripHistoId.h:25
SiStripMonitorQuality
Definition: SiStripMonitorQuality.h:46
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripMonitorQuality::endJob
void endJob() override
Definition: SiStripMonitorQuality.cc:192
SiStripFolderOrganizer
Definition: SiStripFolderOrganizer.h:27
SiStripDetCabling::nApvPairs
const uint16_t nApvPairs(uint32_t det_id) const
Definition: SiStripDetCabling.cc:209
SiStripQuality.h
SiStripQualityRcd.h
EventSetup.h
SiStripBadStrip::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripBadStrip.h:55
SiStripMonitorQuality::detCabling_
edm::ESHandle< SiStripDetCabling > detCabling_
Definition: SiStripMonitorQuality.h:61
SiStripMonitorQuality::dqmStore_
DQMStore * dqmStore_
Definition: SiStripMonitorQuality.h:59
SiStripBadStrip::data::range
unsigned short range
Definition: SiStripBadStrip.h:34
SiStripDetCablingRcd.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
SiStripMonitorQuality::SiStripMonitorQuality
SiStripMonitorQuality(const edm::ParameterSet &)
Definition: SiStripMonitorQuality.cc:43
edm::Event
Definition: Event.h:73
SiStripMonitorQuality::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripMonitorQuality.cc:124
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
SiStripBadStrip::ContainerIterator
std::vector< unsigned int >::const_iterator ContainerIterator
Definition: SiStripBadStrip.h:52
SiStripBadStrip::getRegistryVectorEnd
RegistryIterator getRegistryVectorEnd() const
Definition: SiStripBadStrip.h:76
SiStripMonitorQuality::m_cacheID_
unsigned long long m_cacheID_
Definition: SiStripMonitorQuality.h:67