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  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)
100  SiStripHistoId hidmanager;
101  // create SiStripFolderOrganizer
102  SiStripFolderOrganizer folder_organizer;
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);
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) {
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 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
MessageLogger.h
SiStripFolderOrganizer.h
SiStripHistoId.h
ESInputTag
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
pos
Definition: PixelAliasList.h:18
SiStripMonitorQuality::qualityWatcher_
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
Definition: SiStripMonitorQuality.h:70
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:59
SiStripMonitorQuality::conf_
edm::ParameterSet conf_
Definition: SiStripMonitorQuality.h:60
DQMStore.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
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
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:728
Service.h
SiStripMonitorQuality::detCabling_
const SiStripDetCabling * detCabling_
Definition: SiStripMonitorQuality.h:61
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
SiStripMonitorQuality::stripQuality_
const SiStripQuality * stripQuality_
Definition: SiStripMonitorQuality.h:62
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
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:784
SiStripMonitorQuality::qualityToken_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
Definition: SiStripMonitorQuality.h:69
SiStripMonitorQuality::dqmEndRun
void dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripMonitorQuality.cc:168
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
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:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripMonitorQuality::getQualityME
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
Definition: SiStripMonitorQuality.cc:185
SiStripMonitorQuality::~SiStripMonitorQuality
~SiStripMonitorQuality() override
Definition: SiStripMonitorQuality.cc:54
SiStripHistoId::createHistoId
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
Definition: SiStripHistoId.cc:26
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripMonitorQuality::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripMonitorQuality.h:67
SiStripFolderOrganizer::setDetectorFolder
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
Definition: SiStripFolderOrganizer.cc:202
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
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:178
SiStripFolderOrganizer
Definition: SiStripFolderOrganizer.h:27
SiStripDetCabling::nApvPairs
const uint16_t nApvPairs(uint32_t det_id) const
Definition: SiStripDetCabling.cc:209
SiStripQuality.h
SiStripQualityRcd.h
SiStripMonitorQuality::detCablingToken_
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
Definition: SiStripMonitorQuality.h:68
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripBadStrip::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripBadStrip.h:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
SiStripMonitorQuality::dqmStore_
DQMStore * dqmStore_
Definition: SiStripMonitorQuality.h:59
SiStripBadStrip::data::range
unsigned short range
Definition: SiStripBadStrip.h:34
SiStripDetCablingRcd.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
SiStripMonitorQuality::SiStripMonitorQuality
SiStripMonitorQuality(const edm::ParameterSet &)
Definition: SiStripMonitorQuality.cc:43
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
SiStripMonitorQuality::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripMonitorQuality.cc:118
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
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98