CMS 3D CMS Logo

SiStripBadComponentInfo.cc
Go to the documentation of this file.
4 
6 
12 
14 
15 #include <cmath>
16 #include <cstdio>
17 #include <iomanip>
18 #include <iostream>
19 #include <sstream>
20 #include <string>
21 
22 //
23 // -- Contructor
24 //
26  : bookedStatus_(false), nSubSystem_(6), qualityLabel_(pSet.getParameter<std::string>("StripQualityLabel")) {
27  addBadCompFromFedErr_ = pSet.getUntrackedParameter<bool>("AddBadComponentsFromFedErrors", false);
28  fedErrCutoff_ = float(pSet.getUntrackedParameter<double>("FedErrorBadComponentsCutoff", 0.8));
29  // Create MessageSender
30  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo::Deleting SiStripBadComponentInfo ";
31 }
32 
34  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo::Deleting SiStripBadComponentInfo ";
35 }
36 
37 //
38 // -- Read Condition
39 //
41  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo:: Begining of Run";
42 
43  // Retrieve tracker topology from geometry
44  eSetup.get<TrackerTopologyRcd>().get(tTopo_);
46 
48  if (!addBadCompFromFedErr_) {
50  }
51 }
52 
54  auto const& BC = siStripQuality->getBadComponentList();
55 
56  for (size_t i = 0; i < BC.size(); ++i) {
57  int subdet = -999;
58  int component = -999;
59 
60  //&&&&&&&&&&&&&&&&&
61  // Single SubSyste
62  //&&&&&&&&&&&&&&&&&
63  int subDet = DetId(BC[i].detid).subdetId();
64  if (subDet == StripSubdetector::TIB) {
65  //&&&&&&&&&&&&&&&&&
66  // TIB
67  //&&&&&&&&&&&&&&&&&
68  subdet = 3;
69  component = tTopo_->tibLayer(BC[i].detid);
70  } else if (subDet == StripSubdetector::TID) {
71  //&&&&&&&&&&&&&&&&&
72  // TID
73  //&&&&&&&&&&&&&&&&&
74  if (tTopo_->tidSide(BC[i].detid) == 2)
75  subdet = 4;
76  else
77  subdet = 5;
78  component = tTopo_->tidWheel(BC[i].detid);
79  } else if (subDet == StripSubdetector::TOB) {
80  //&&&&&&&&&&&&&&&&&
81  // TOB
82  //&&&&&&&&&&&&&&&&&
83  subdet = 6;
84  component = tTopo_->tobLayer(BC[i].detid);
85  } else if (subDet == StripSubdetector::TEC) {
86  //&&&&&&&&&&&&&&&&&
87  // TEC
88  //&&&&&&&&&&&&&&&&&
89  if (tTopo_->tecSide(BC[i].detid) == 2)
90  subdet = 2;
91  else
92  subdet = 1;
93  component = tTopo_->tecWheel(BC[i].detid);
94  }
95  fillBadComponentMaps(subdet, component, BC[i]);
96  }
97 
98  //&&&&&&&&&&&&&&&&&&
99  // Single Strip Info
100  //&&&&&&&&&&&&&&&&&&
101 
102  SiStripQuality::RegistryIterator rbegin = siStripQuality->getRegistryVectorBegin();
104 
105  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
106  uint32_t detid = rp->detid;
107  int subdet = -999;
108  int component = -999;
109  DetId detectorId = DetId(detid);
110  int subDet = detectorId.subdetId();
111  if (subDet == StripSubdetector::TIB) {
112  subdet = 3;
113  component = tTopo_->tibLayer(detid);
114  } else if (subDet == StripSubdetector::TID) {
115  if (tTopo_->tidSide(detid) == 2)
116  subdet = 5;
117  else
118  subdet = 4;
119  component = tTopo_->tidWheel(detid);
120  } else if (subDet == StripSubdetector::TOB) {
121  subdet = 6;
122  component = tTopo_->tobLayer(detid);
123  } else if (subDet == StripSubdetector::TEC) {
124  if (tTopo_->tecSide(detid) == 2)
125  subdet = 2;
126  else
127  subdet = 1;
128  component = tTopo_->tecWheel(detid);
129  }
130 
131  SiStripQuality::Range sqrange = SiStripQuality::Range(siStripQuality->getDataVectorBegin() + rp->ibegin,
132  siStripQuality->getDataVectorBegin() + rp->iend);
133 
134  for (int it = 0; it < sqrange.second - sqrange.first; it++) {
135  unsigned int range = siStripQuality->decode(*(sqrange.first + it)).range;
136  float val = (mapBadStrip.find(std::make_pair(subdet, component)) != mapBadStrip.end())
137  ? mapBadStrip.at(std::make_pair(subdet, component))
138  : 0.;
139  val += range;
140  mapBadStrip[std::make_pair(subdet, component)] = val;
141  }
142  }
143 }
144 
146  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo:: End of Run";
147  checkBadComponents(eSetup);
148 }
149 
151  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo::dqmEndRun";
152  if (addBadCompFromFedErr_) {
153  auto mergedQuality = std::make_unique<SiStripQuality>(*siStripQuality_);
154  auto fedErrQuality = sistrip::badStripFromFedErr(igetter, *fedCabling_, fedErrCutoff_);
155  mergedQuality->add(fedErrQuality.get());
156  mergedQuality->cleanUp();
157  mergedQuality->fillBadComponents();
158  fillBadComponentMaps(mergedQuality.get());
159  }
160  bookBadComponentHistos(ibooker, igetter);
164 }
165 //
166 // -- Book MEs for SiStrip Dcs Fraction
167 //
169  if (!bookedStatus_) {
170  std::string strip_dir = "";
171  ibooker.cd();
172  // SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
173  if (igetter.dirExists("SiStrip")) {
174  ibooker.cd("SiStrip");
175  strip_dir = ibooker.pwd();
176  }
177  edm::LogInfo("SiStripBadComponentInfo")
178  << "SiStripBadComponentInfo::bookBadComponentHistos ==> " << strip_dir << " " << ibooker.pwd() << std::endl;
179  if (!strip_dir.empty())
180  ibooker.setCurrentFolder(strip_dir + "/EventInfo");
181  else
182  ibooker.setCurrentFolder("SiStrip/EventInfo");
183 
184  ibooker.cd();
185  if (!strip_dir.empty())
186  ibooker.setCurrentFolder(strip_dir + "/EventInfo/BadComponentContents");
187 
188  std::string hname, htitle;
189  hname = "BadAPVMap";
190  htitle = "SiStrip Bad APVs";
191  badAPVME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_ + 0.5, 10, 0.5, 10.5);
192  badAPVME_->setAxisTitle("Sub Detector Type", 1);
193  badAPVME_->setAxisTitle("Layer/Disc Number", 2);
194 
195  hname = "BadFiberMap";
196  htitle = "SiStrip Bad Fibers";
197  badFiberME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_ + 0.5, 10, 0.5, 10.5);
198  badFiberME_->setAxisTitle("Sub Detector Type", 1);
199  badFiberME_->setAxisTitle("Layer/Disc Number", 2);
200 
201  hname = "BadStripMap";
202  htitle = "SiStrip Bad Strips";
203  badStripME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_ + 0.5, 10, 0.5, 10.5);
204  badStripME_->setAxisTitle("Sub Detector Type", 1);
205  badStripME_->setAxisTitle("Layer/Disc Number", 2);
206 
207  std::vector<std::string> names;
208  names.push_back("TECB");
209  names.push_back("TECF");
210  names.push_back("TIB");
211  names.push_back("TIDB");
212  names.push_back("TIDF");
213  names.push_back("TOB");
214 
215  for (unsigned int i = 0; i < names.size(); i++) {
216  badAPVME_->setBinLabel(i + 1, names[i]);
217  badFiberME_->setBinLabel(i + 1, names[i]);
218  badStripME_->setBinLabel(i + 1, names[i]);
219  }
220 
221  bookedStatus_ = true;
222  ibooker.cd();
223  }
224 }
225 
227  auto index = std::make_pair(xbin, component);
228 
229  if (BC.BadApvs) {
230  int ntot = std::bitset<16>(BC.BadApvs & 0x3f).count();
231  float val = (mapBadAPV.find(index) != mapBadAPV.end()) ? mapBadAPV.at(index) : 0.;
232  val += ntot;
233  mapBadAPV[index] = val;
234  }
235  if (BC.BadFibers) {
236  int ntot = std::bitset<16>(BC.BadFibers & 0x7).count();
237  float val = (mapBadFiber.find(index) != mapBadFiber.end()) ? mapBadFiber.at(index) : 0.;
238  val += ntot;
239  mapBadFiber[index] = val;
240  }
241 }
242 void SiStripBadComponentInfo::createSummary(MonitorElement* me, const std::map<std::pair<int, int>, float>& map) {
243  for (int i = 1; i < nSubSystem_ + 1; i++) {
244  float sum = 0.0;
245  for (int k = 1; k < me->getNbinsY(); k++) {
246  auto index = std::make_pair(i, k);
247  if (map.find(index) != map.end()) {
248  me->setBinContent(i, k, map.at(index)); // fill the layer/wheel bins
249  sum += map.at(index);
250  }
251  }
252  me->setBinContent(i, me->getNbinsY(), sum); // fill the summary bin (last one)
253  }
254 }
SiStripBadComponentInfo::bookedStatus_
bool bookedStatus_
Definition: SiStripBadComponentInfo.h:67
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
SiStripFolderOrganizer.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
funct::false
false
Definition: Factorize.h:34
SiStripBadComponentInfo::SiStripBadComponentInfo
SiStripBadComponentInfo(edm::ParameterSet const &ps)
Constructor.
Definition: SiStripBadComponentInfo.cc:25
edm::Run
Definition: Run.h:45
SiStripBadComponentInfo::~SiStripBadComponentInfo
~SiStripBadComponentInfo() override
Definition: SiStripBadComponentInfo.cc:33
SiStripBadComponentInfo::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: SiStripBadComponentInfo.cc:145
SiStripBadComponentInfo::createSummary
void createSummary(MonitorElement *me, const std::map< std::pair< int, int >, float > &map)
Definition: SiStripBadComponentInfo.cc:242
edm::LogInfo
Definition: MessageLogger.h:254
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
SiStripBadStrip::decode
data decode(const unsigned int &value) const
Definition: SiStripBadStrip.h:78
SiStripBadComponentInfo::badStripME_
MonitorElement * badStripME_
Definition: SiStripBadComponentInfo.h:61
DQMStore.h
SiStripBadComponentInfo.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripBadStrip::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripBadStrip.h:73
SiStripBadComponentInfo::mapBadFiber
std::map< std::pair< int, int >, float > mapBadFiber
Definition: SiStripBadComponentInfo.h:64
SiStripUtility.h
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
DetId
Definition: DetId.h:17
MakerMacros.h
SiStripFedCablingRcd
Definition: SiStripCondDataRecords.h:22
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripQuality::getBadComponentList
const std::vector< BadComponent > & getBadComponentList() const
Definition: SiStripQuality.h:119
SiStripBadComponentInfo::siStripQuality_
edm::ESHandle< SiStripQuality > siStripQuality_
Definition: SiStripBadComponentInfo.h:71
SiStripBadStrip::getRegistryVectorBegin
RegistryIterator getRegistryVectorBegin() const
Definition: SiStripBadStrip.h:75
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripBadComponentInfo::fillBadComponentMaps
void fillBadComponentMaps(const SiStripQuality *siStripQuality)
Definition: SiStripBadComponentInfo.cc:53
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
SiStripBadComponentInfo::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: SiStripBadComponentInfo.cc:150
Service.h
SiStripQualityRcd
Definition: SiStripDependentRecords.h:56
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
sistrip::badStripFromFedErr
std::unique_ptr< SiStripQuality > badStripFromFedErr(dqm::harvesting::DQMStore::IGetter &dqmStore, const SiStripFedCabling &fedCabling, float cutoff)
SiStripBadComponentInfo::bookBadComponentHistos
void bookBadComponentHistos(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: SiStripBadComponentInfo.cc:168
dqmdumpme.k
k
Definition: dqmdumpme.py:60
dqm::implementation::NavigatorBase::pwd
virtual std::string pwd()
Definition: DQMStore.cc:16
SiStripQuality::BadComponent::BadFibers
unsigned short BadFibers
Definition: SiStripQuality.h:37
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
SiStripBadComponentInfo::mapBadAPV
std::map< std::pair< int, int >, float > mapBadAPV
Definition: SiStripBadComponentInfo.h:63
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripBadComponentInfo::badFiberME_
MonitorElement * badFiberME_
Definition: SiStripBadComponentInfo.h:60
SiStripBadComponentInfo
Definition: SiStripBadComponentInfo.h:41
TrackerTopology::tidSide
unsigned int tidSide(const DetId &id) const
Definition: TrackerTopology.h:190
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
SiStripQuality::BadComponent::BadApvs
unsigned short BadApvs
Definition: SiStripQuality.h:36
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
SiStripBadComponentInfo::addBadCompFromFedErr_
bool addBadCompFromFedErr_
Definition: SiStripBadComponentInfo.h:74
SiStripBadComponentInfo::fedErrCutoff_
float fedErrCutoff_
Definition: SiStripBadComponentInfo.h:75
SiStripQualityHelpers.h
SiStripBadComponentInfo::tTopo_
edm::ESHandle< TrackerTopology > tTopo_
Definition: SiStripBadComponentInfo.h:72
SiStripBadComponentInfo::nSubSystem_
int nSubSystem_
Definition: SiStripBadComponentInfo.h:68
TrackerTopology::tobLayer
unsigned int tobLayer(const DetId &id) const
Definition: TrackerTopology.h:147
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripQuality::BadComponent
Definition: SiStripQuality.h:34
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
SiStripBadComponentInfo::qualityLabel_
std::string qualityLabel_
Definition: SiStripBadComponentInfo.h:69
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
SiStripBadComponentInfo::checkBadComponents
void checkBadComponents(edm::EventSetup const &eSetup)
Definition: SiStripBadComponentInfo.cc:40
SiStripQualityRcd.h
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
SiStripBadComponentInfo::mapBadStrip
std::map< std::pair< int, int >, float > mapBadStrip
Definition: SiStripBadComponentInfo.h:65
SiStripBadStrip::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripBadStrip.h:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SiStripBadStrip::data::range
unsigned short range
Definition: SiStripBadStrip.h:34
genParticles_cff.map
map
Definition: genParticles_cff.py:11
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
SiStripBadComponentInfo::fedCabling_
edm::ESHandle< SiStripFedCabling > fedCabling_
Definition: SiStripBadComponentInfo.h:73
TrackerTopology::tecWheel
unsigned int tecWheel(const DetId &id) const
Definition: TrackerTopology.h:198
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
StripSubdetector.h
SiStripBadComponentInfo::badAPVME_
MonitorElement * badAPVME_
Definition: SiStripBadComponentInfo.h:59
SiStripBadStrip::getRegistryVectorEnd
RegistryIterator getRegistryVectorEnd() const
Definition: SiStripBadStrip.h:76
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:707
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
TrackerTopology::tibLayer
unsigned int tibLayer(const DetId &id) const
Definition: TrackerTopology.h:150
SiStripQuality
Definition: SiStripQuality.h:32
TrackerTopology::tecSide
unsigned int tecSide(const DetId &id) const
Definition: TrackerTopology.h:184