CMS 3D CMS Logo

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