CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripHitEfficiencyHarvester.cc
Go to the documentation of this file.
1 // user includes
23 
24 //system includes
25 #include <sstream>
26 
27 // ROOT includes
28 #include "TEfficiency.h"
29 
30 // custom made printout
31 #define LOGPRINT edm::LogPrint("SiStripHitEfficiencyHarvester")
32 
34 public:
36  ~SiStripHitEfficiencyHarvester() override = default;
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
38 
39  void endRun(edm::Run const&, edm::EventSetup const&) override;
41 
42 private:
43  const bool isAtPCL_;
45  const unsigned int nTEClayers_;
46  const double threshold_;
47  const int nModsMin_;
48  const double tkMapMin_;
50 
55 
56  std::unique_ptr<TrackerTopology> tTopo_;
57  std::unique_ptr<TkDetMap> tkDetMap_;
58  std::unique_ptr<SiStripQuality> stripQuality_;
59  std::vector<DetId> stripDetIds_;
60 
61  void writeBadStripPayload(const SiStripQuality& quality) const;
62  void printTotalStatistics(const std::array<long, 23>& layerFound, const std::array<long, 23>& layerTotal) const;
63  void printAndWriteBadModules(const SiStripQuality& quality, const SiStripDetInfo& detInfo) const;
64  bool checkMapsValidity(const std::vector<MonitorElement*>& maps, const std::string& type) const;
65  void makeSummary(DQMStore::IGetter& getter, TFileService& fs) const;
66  void makeSummaryVsBX(DQMStore::IGetter& getter, TFileService& fs) const;
67  void makeSummaryVsLumi(DQMStore::IGetter& getter) const;
68  void makeSummaryVsCM(DQMStore::IGetter& getter, TFileService& fs) const;
69 };
70 
72  : isAtPCL_(conf.getParameter<bool>("isAtPCL")),
73  showRings_(conf.getUntrackedParameter<bool>("ShowRings", false)),
74  autoIneffModTagging_(conf.getUntrackedParameter<bool>("AutoIneffModTagging", false)),
75  doStoreOnDB_(conf.getParameter<bool>("doStoreOnDB")),
76  nTEClayers_(showRings_ ? 7 : 9), // number of rings or wheels
77  threshold_(conf.getParameter<double>("Threshold")),
78  nModsMin_(conf.getParameter<int>("nModsMin")),
79  tkMapMin_(conf.getUntrackedParameter<double>("TkMapMin", 0.9)),
80  title_(conf.getParameter<std::string>("Title")),
81  record_(conf.getParameter<std::string>("Record")),
82  tTopoToken_(esConsumes<edm::Transition::EndRun>()),
83  tkDetMapToken_(esConsumes<edm::Transition::EndRun>()),
84  stripQualityToken_(esConsumes<edm::Transition::EndRun>()),
85  tkGeomToken_(esConsumes<edm::Transition::EndRun>()) {}
86 
88  if (!tTopo_) {
89  tTopo_ = std::make_unique<TrackerTopology>(iSetup.getData(tTopoToken_));
90  }
91  if (!tkDetMap_) {
92  tkDetMap_ = std::make_unique<TkDetMap>(iSetup.getData(tkDetMapToken_));
93  }
94  if (!stripQuality_) {
95  stripQuality_ = std::make_unique<SiStripQuality>(iSetup.getData(stripQualityToken_));
96  }
97  if (stripDetIds_.empty()) {
98  const auto& tkGeom = iSetup.getData(tkGeomToken_);
99  for (const auto& det : tkGeom.detUnits()) {
100  if (dynamic_cast<const StripGeomDetUnit*>(det)) {
101  stripDetIds_.push_back(det->geographicalId());
102  }
103  }
104  }
105 }
106 
107 bool SiStripHitEfficiencyHarvester::checkMapsValidity(const std::vector<MonitorElement*>& maps,
108  const std::string& type) const {
109  std::vector<bool> isAvailable;
110  isAvailable.reserve(maps.size());
112  maps.begin() + 1, maps.end(), std::back_inserter(isAvailable), [](auto& x) { return !(x == nullptr); });
113 
114  int count{0};
115  for (const auto& it : isAvailable) {
116  count++;
117  LogDebug("SiStripHitEfficiencyHarvester") << " layer: " << count << " " << it << std::endl;
118  if (it)
119  LogDebug("SiStripHitEfficiencyHarvester") << "resolving to " << maps[count]->getName() << std::endl;
120  }
121 
122  // check on the input TkHistoMap
123  bool areMapsAvailable{true};
124  int layerCount{0};
125  for (const auto& it : isAvailable) {
126  layerCount++;
127  if (!it) {
128  edm::LogError("SiStripHitEfficiencyHarvester")
129  << type << " TkHistoMap for layer " << layerCount << " was not found.\n -> Aborting!";
130  areMapsAvailable = false;
131  break;
132  }
133  }
134  return areMapsAvailable;
135 }
136 
139  LOGPRINT << "A module is bad if efficiency < " << threshold_ << " and has at least " << nModsMin_ << " nModsMin.";
140  else
141  LOGPRINT << "A module is bad if the upper limit on the efficiency is < to the avg in the layer - " << threshold_
142  << " and has at least " << nModsMin_ << " nModsMin.";
143 
144  auto h_module_total = std::make_unique<TkHistoMap>(tkDetMap_.get());
145  h_module_total->loadTkHistoMap("AlCaReco/SiStripHitEfficiency", "perModule_total");
146  auto h_module_found = std::make_unique<TkHistoMap>(tkDetMap_.get());
147  h_module_found->loadTkHistoMap("AlCaReco/SiStripHitEfficiency", "perModule_found");
148 
149  // collect how many layers are missing
150  const auto& totalMaps = h_module_total->getAllMaps();
151  const auto& foundMaps = h_module_found->getAllMaps();
152 
153  LogDebug("SiStripHitEfficiencyHarvester")
154  << "totalMaps.size(): " << totalMaps.size() << " foundMaps.size() " << foundMaps.size() << std::endl;
155 
156  // check on the input TkHistoMaps
157  bool isTotalMapAvailable = this->checkMapsValidity(totalMaps, std::string("Total"));
158  bool isFoundMapAvailable = this->checkMapsValidity(foundMaps, std::string("Found"));
159 
160  LogDebug("SiStripHitEfficiencyHarvester")
161  << "isTotalMapAvailable: " << isTotalMapAvailable << " isFoundMapAvailable " << isFoundMapAvailable << std::endl;
162 
163  // no input TkHistoMaps -> early return
164  if (!isTotalMapAvailable or !isFoundMapAvailable)
165  return;
166 
167  LogDebug("SiStripHitEfficiencyHarvester")
168  << "Entries in total TkHistoMap for layer 3: " << h_module_total->getMap(3)->getEntries() << ", found "
169  << h_module_found->getMap(3)->getEntries();
170 
171  std::vector<MonitorElement*> hEffInLayer(std::size_t(1), nullptr);
172  hEffInLayer.reserve(23);
173  for (std::size_t i = 1; i != 23; ++i) {
174  hEffInLayer.push_back(
175  booker.book1D(Form("eff_layer%i", int(i)), Form("Module efficiency in layer %i", int(i)), 201, 0, 1.005));
176  }
177  std::array<long, 23> layerTotal{};
178  std::array<long, 23> layerFound{};
179  layerTotal.fill(0);
180  layerFound.fill(0);
181 
183  // Effiency calculation, bad module tagging, and tracker maps //
185 
186  TrackerMap tkMap{" Detector Inefficiency "};
187  TrackerMap tkMapBad{" Inefficient Modules "};
188  TrackerMap tkMapEff{title_};
189  TrackerMap tkMapNum{" Detector numerator "};
190  TrackerMap tkMapDen{" Detector denominator "};
191  std::map<unsigned int, double> badModules;
192 
193  for (auto det : stripDetIds_) {
194  auto layer = ::checkLayer(det, tTopo_.get());
195  const auto num = h_module_found->getValue(det);
196  const auto denom = h_module_total->getValue(det);
197  if (denom) {
198  const auto eff = num / denom;
199  hEffInLayer[layer]->Fill(eff);
200  if (!autoIneffModTagging_) {
201  if ((denom >= nModsMin_) && (eff < threshold_)) {
202  // We have a bad module, put it in the list!
203  badModules[det] = eff;
204  tkMapBad.fillc(det, 255, 0, 0);
205  LOGPRINT << "Layer " << layer << " (" << ::layerName(layer, showRings_, nTEClayers_) << ") module "
206  << det.rawId() << " efficiency: " << eff << " , " << num << "/" << denom;
207  } else {
208  //Fill the bad list with empty results for every module
209  tkMapBad.fillc(det, 255, 255, 255);
210  }
211  if (eff < threshold_)
212  LOGPRINT << "Layer " << layer << " (" << ::layerName(layer, showRings_, nTEClayers_) << ") module "
213  << det.rawId() << " efficiency: " << eff << " , " << num << "/" << denom;
214 
215  if (denom < nModsMin_) {
216  LOGPRINT << "Layer " << layer << " (" << ::layerName(layer, showRings_, nTEClayers_) << ") module "
217  << det.rawId() << " is under occupancy at " << denom;
218  }
219  }
220  //Put any module into the TKMap
221  tkMap.fill(det, 1. - eff);
222  tkMapEff.fill(det, eff);
223  tkMapNum.fill(det, num);
224  tkMapDen.fill(det, denom);
225 
226  layerTotal[layer] += denom;
227  layerFound[layer] += num;
228  }
229  }
230 
231  if (autoIneffModTagging_) {
232  for (Long_t i = 1; i <= 22; i++) {
233  //Compute threshold to use for each layer
234  hEffInLayer[i]->getTH1()->GetXaxis()->SetRange(
235  3, hEffInLayer[i]->getNbinsX() + 1); // Remove from the avg modules below 1%
236  const double layer_min_eff = hEffInLayer[i]->getMean() - std::max(2.5 * hEffInLayer[i]->getRMS(), threshold_);
237  LOGPRINT << "Layer " << i << " threshold for bad modules: <" << layer_min_eff
238  << " (layer mean: " << hEffInLayer[i]->getMean() << " rms: " << hEffInLayer[i]->getRMS() << ")";
239 
240  hEffInLayer[i]->getTH1()->GetXaxis()->SetRange(1, hEffInLayer[i]->getNbinsX() + 1);
241 
242  for (auto det : stripDetIds_) {
243  const auto layer = ::checkLayer(det, tTopo_.get());
244  if (layer == i) {
245  const auto num = h_module_found->getValue(det);
246  const auto denom = h_module_total->getValue(det);
247  if (denom) {
248  const auto eff = num / denom;
249  const auto eff_up = TEfficiency::Bayesian(denom, num, .99, 1, 1, true);
250 
251  if ((denom >= nModsMin_) && (eff_up < layer_min_eff)) {
252  //We have a bad module, put it in the list!
253  badModules[det] = eff;
254  tkMapBad.fillc(det, 255, 0, 0);
255  } else {
256  //Fill the bad list with empty results for every module
257  tkMapBad.fillc(det, 255, 255, 255);
258  }
259  if (eff_up < layer_min_eff + 0.08) // printing message also for modules sligthly above (8%) the limit
260 
261  LOGPRINT << "Layer " << layer << " (" << ::layerName(layer, showRings_, nTEClayers_) << ") module "
262  << det.rawId() << " efficiency: " << eff << " , " << num << "/" << denom
263  << " , upper limit: " << eff_up;
264  if (denom < nModsMin_) {
265  LOGPRINT << "Layer " << layer << " (" << ::layerName(layer, showRings_, nTEClayers_) << ") module "
266  << det.rawId() << " layer " << layer << " is under occupancy at " << denom;
267  }
268  }
269  }
270  }
271  }
272  }
273 
274  tkMap.save(true, 0, 0, "SiStripHitEffTKMap_NEW.png");
275  tkMapBad.save(true, 0, 0, "SiStripHitEffTKMapBad_NEW.png");
276  tkMapEff.save(true, tkMapMin_, 1., "SiStripHitEffTKMapEff_NEW.png");
277  tkMapNum.save(true, 0, 0, "SiStripHitEffTKMapNum_NEW.png");
278  tkMapDen.save(true, 0, 0, "SiStripHitEffTKMapDen_NEW.png");
279 
280  const auto detInfo =
282  SiStripQuality pQuality{detInfo};
283  //This is the list of the bad strips, use to mask out entire APVs
284  //Now simply go through the bad hit list and mask out things that
285  //are bad!
286  for (const auto it : badModules) {
287  const auto det = it.first;
288  std::vector<unsigned int> badStripList;
289  //We need to figure out how many strips are in this particular module
290  //To Mask correctly!
291  const auto nStrips = detInfo.getNumberOfApvsAndStripLength(det).first * sistrip::STRIPS_PER_APV;
292  LOGPRINT << "Number of strips module " << det << " is " << nStrips;
293  badStripList.push_back(pQuality.encode(0, nStrips, 0));
294  //Now compact into a single bad module
295  LOGPRINT << "ID1 shoudl match list of modules above " << det;
296  pQuality.compact(det, badStripList);
297  pQuality.put(det, SiStripQuality::Range(badStripList.begin(), badStripList.end()));
298  }
299  pQuality.fillBadComponents();
300  if (doStoreOnDB_) {
301  writeBadStripPayload(pQuality);
302  } else {
303  edm::LogInfo("SiStripHitEfficiencyHarvester") << "Will not produce payload!";
304  }
305 
306  printTotalStatistics(layerFound, layerTotal); // statistics by layer and subdetector
307  //LOGPRINT << "\n-----------------\nNew IOV starting from run " << e.id().run() << " event " << e.id().event()
308  // << " lumiBlock " << e.luminosityBlock() << " time " << e.time().value() << "\n-----------------\n";
309  printAndWriteBadModules(pQuality, detInfo); // TODO
310 
311  if (!isAtPCL_) {
313  makeSummary(getter, *fs); // TODO
314  makeSummaryVsBX(getter, *fs); // TODO
315  makeSummaryVsCM(getter, *fs); // TODO
316  }
317 
318  makeSummaryVsLumi(getter); // TODO
319 }
320 
321 void SiStripHitEfficiencyHarvester::printTotalStatistics(const std::array<long, 23>& layerFound,
322  const std::array<long, 23>& layerTotal) const {
323  //Calculate the statistics by layer
324  int totalfound = 0;
325  int totaltotal = 0;
326  double layereff;
327  int subdetfound[5];
328  int subdettotal[5];
329 
330  for (Long_t i = 1; i < 5; i++) {
331  subdetfound[i] = 0;
332  subdettotal[i] = 0;
333  }
334 
335  for (Long_t i = 1; i <= 22; i++) {
336  layereff = double(layerFound[i]) / double(layerTotal[i]);
337  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers_) << ") has total efficiency "
338  << layereff << " " << layerFound[i] << "/" << layerTotal[i];
339  totalfound += layerFound[i];
340  totaltotal += layerTotal[i];
341  if (i < 5) {
342  subdetfound[1] += layerFound[i];
343  subdettotal[1] += layerTotal[i];
344  }
345  if (i >= 5 && i < 11) {
346  subdetfound[2] += layerFound[i];
347  subdettotal[2] += layerTotal[i];
348  }
349  if (i >= 11 && i < 14) {
350  subdetfound[3] += layerFound[i];
351  subdettotal[3] += layerTotal[i];
352  }
353  if (i >= 14) {
354  subdetfound[4] += layerFound[i];
355  subdettotal[4] += layerTotal[i];
356  }
357  }
358 
359  LOGPRINT << "The total efficiency is " << double(totalfound) / double(totaltotal);
360  LOGPRINT << " TIB: " << double(subdetfound[1]) / subdettotal[1] << " " << subdetfound[1] << "/"
361  << subdettotal[1];
362  LOGPRINT << " TOB: " << double(subdetfound[2]) / subdettotal[2] << " " << subdetfound[2] << "/"
363  << subdettotal[2];
364  LOGPRINT << " TID: " << double(subdetfound[3]) / subdettotal[3] << " " << subdetfound[3] << "/"
365  << subdettotal[3];
366  LOGPRINT << " TEC: " << double(subdetfound[4]) / subdettotal[4] << " " << subdetfound[4] << "/"
367  << subdettotal[4];
368 }
369 
371  SiStripBadStrip pBadStrip{};
372  const auto pQdvBegin = quality.getDataVectorBegin();
373  for (auto rIt = quality.getRegistryVectorBegin(); rIt != quality.getRegistryVectorEnd(); ++rIt) {
374  const auto range = SiStripBadStrip::Range(pQdvBegin + rIt->ibegin, pQdvBegin + rIt->iend);
375  if (!pBadStrip.put(rIt->detid, range))
376  edm::LogError("SiStripHitEfficiencyHarvester") << "detid already exists in SiStripBadStrip";
377  }
379  if (poolDbService.isAvailable()) {
380  poolDbService->writeOneIOV(pBadStrip, poolDbService->currentTime(), record_);
381  } else {
382  throw cms::Exception("PoolDBService required");
383  }
384 }
385 
387  // use goodlayer_total/found and alllayer_total/found, collapse side and/or ring if needed
388 }
389 
391  // use found/totalVsBx_layer%i [0,23)
392 }
393 
395  for (unsigned int iLayer = 1; iLayer != (showRings_ ? 20 : 22); ++iLayer) {
396  auto hfound =
397  getter.get(fmt::format("AlCaReco/SiStripHitEfficiency/layerfound_vsLumi_layer_{}", iLayer))->getTH1F();
398  auto htotal =
399  getter.get(fmt::format("AlCaReco/SiStripHitEfficiency/layertotal_vsLumi_layer_{}", iLayer))->getTH1F();
400 
401  if (hfound == nullptr or htotal == nullptr) {
402  if (hfound == nullptr)
403  edm::LogError("SiStripHitEfficiencyHarvester")
404  << fmt::format("AlCaReco/SiStripHitEfficiency/layerfound_vsLumi_layer_{}", iLayer) << " was not found!";
405  if (htotal == nullptr)
406  edm::LogError("SiStripHitEfficiencyHarvester")
407  << fmt::format("AlCaReco/SiStripHitEfficiency/layertotal_vsLumi_layer_{}", iLayer) << " was not found!";
408  // no input histograms -> continue in the loop
409  continue;
410  }
411 
412  if (!hfound->GetSumw2())
413  hfound->Sumw2();
414  if (!htotal->GetSumw2())
415  htotal->Sumw2();
416  for (Long_t i = 0; i != hfound->GetNbinsX() + 1; ++i) {
417  if (hfound->GetBinContent(i) == 0)
418  hfound->SetBinContent(i, 1e-6);
419  if (htotal->GetBinContent(i) == 0)
420  htotal->SetBinContent(i, 1);
421  }
422  LogDebug("SiStripHitEfficiencyHarvester")
423  << "Total hits for layer " << iLayer << " (vs lumi): " << htotal->GetEntries() << ", found "
424  << hfound->GetEntries();
425  }
426  // continue
427 }
428 
430 
431 namespace {
432  void setBadComponents(int i,
433  int comp,
435  std::stringstream ssV[4][19],
436  int nBad[4][19][4],
437  int nAPV) {
438  ssV[i][comp] << "\n\t\t " << bc.detid << " \t " << bc.BadModule << " \t " << ((bc.BadFibers) & 0x1) << " ";
439  if (nAPV == 4)
440  ssV[i][comp] << "x " << ((bc.BadFibers >> 1) & 0x1);
441 
442  if (nAPV == 6)
443  ssV[i][comp] << ((bc.BadFibers >> 1) & 0x1) << " " << ((bc.BadFibers >> 2) & 0x1);
444  ssV[i][comp] << " \t " << ((bc.BadApvs) & 0x1) << " " << ((bc.BadApvs >> 1) & 0x1) << " ";
445  if (nAPV == 4)
446  ssV[i][comp] << "x x " << ((bc.BadApvs >> 2) & 0x1) << " " << ((bc.BadApvs >> 3) & 0x1);
447  if (nAPV == 6)
448  ssV[i][comp] << ((bc.BadApvs >> 2) & 0x1) << " " << ((bc.BadApvs >> 3) & 0x1) << " " << ((bc.BadApvs >> 4) & 0x1)
449  << " " << ((bc.BadApvs >> 5) & 0x1) << " ";
450 
451  if (bc.BadApvs) {
452  nBad[i][0][2] += ((bc.BadApvs >> 5) & 0x1) + ((bc.BadApvs >> 4) & 0x1) + ((bc.BadApvs >> 3) & 0x1) +
453  ((bc.BadApvs >> 2) & 0x1) + ((bc.BadApvs >> 1) & 0x1) + ((bc.BadApvs) & 0x1);
454  nBad[i][comp][2] += ((bc.BadApvs >> 5) & 0x1) + ((bc.BadApvs >> 4) & 0x1) + ((bc.BadApvs >> 3) & 0x1) +
455  ((bc.BadApvs >> 2) & 0x1) + ((bc.BadApvs >> 1) & 0x1) + ((bc.BadApvs) & 0x1);
456  }
457  if (bc.BadFibers) {
458  nBad[i][0][1] += ((bc.BadFibers >> 2) & 0x1) + ((bc.BadFibers >> 1) & 0x1) + ((bc.BadFibers) & 0x1);
459  nBad[i][comp][1] += ((bc.BadFibers >> 2) & 0x1) + ((bc.BadFibers >> 1) & 0x1) + ((bc.BadFibers) & 0x1);
460  }
461  if (bc.BadModule) {
462  nBad[i][0][0]++;
463  nBad[i][comp][0]++;
464  }
465  }
466 } // namespace
467 
469  const SiStripDetInfo& detInfo) const {
471  //try to write out what's in the quality record
473  int nTkBadComp[4]; //k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
474  int nBadComp[4][19][4];
475  //legend: nBadComp[i][j][k]= SubSystem i, layer/disk/wheel j, BadModule/Fiber/Apv k
476  // i: 0=TIB, 1=TID, 2=TOB, 3=TEC
477  // k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
478  std::stringstream ssV[4][19];
479 
480  for (int i = 0; i < 4; ++i) {
481  nTkBadComp[i] = 0;
482  for (int j = 0; j < 19; ++j) {
483  ssV[i][j].str("");
484  for (int k = 0; k < 4; ++k)
485  nBadComp[i][j][k] = 0;
486  }
487  }
488 
489  for (const auto& bc : quality.getBadComponentList()) {
490  // Full Tk
491  if (bc.BadModule)
492  nTkBadComp[0]++;
493  if (bc.BadFibers)
494  nTkBadComp[1] += ((bc.BadFibers >> 2) & 0x1) + ((bc.BadFibers >> 1) & 0x1) + ((bc.BadFibers) & 0x1);
495  if (bc.BadApvs)
496  nTkBadComp[2] += ((bc.BadApvs >> 5) & 0x1) + ((bc.BadApvs >> 4) & 0x1) + ((bc.BadApvs >> 3) & 0x1) +
497  ((bc.BadApvs >> 2) & 0x1) + ((bc.BadApvs >> 1) & 0x1) + ((bc.BadApvs) & 0x1);
498  // single subsystem
499  DetId det(bc.detid);
500  if ((det.subdetId() >= SiStripSubdetector::TIB) && (det.subdetId() <= SiStripSubdetector::TEC)) {
501  const auto nAPV = detInfo.getNumberOfApvsAndStripLength(det).first;
502  switch (det.subdetId()) {
504  setBadComponents(0, tTopo_->tibLayer(det), bc, ssV, nBadComp, nAPV);
505  break;
508  (tTopo_->tidSide(det) == 2 ? tTopo_->tidWheel(det) : tTopo_->tidWheel(det) + 3),
509  bc,
510  ssV,
511  nBadComp,
512  nAPV);
513  break;
515  setBadComponents(2, tTopo_->tobLayer(det), bc, ssV, nBadComp, nAPV);
516  break;
519  (tTopo_->tecSide(det) == 2 ? tTopo_->tecWheel(det) : tTopo_->tecWheel(det) + 9),
520  bc,
521  ssV,
522  nBadComp,
523  nAPV);
524  break;
525  default:
526  break;
527  }
528  }
529  }
530  // single strip info
531  for (auto rp = quality.getRegistryVectorBegin(); rp != quality.getRegistryVectorEnd(); ++rp) {
532  DetId det{rp->detid};
533  int subdet = -999;
534  int component = -999;
535  switch (det.subdetId()) {
537  subdet = 0;
538  component = tTopo_->tibLayer(det);
539  break;
541  subdet = 1;
542  component = tTopo_->tidSide(det) == 2 ? tTopo_->tidWheel(det) : tTopo_->tidWheel(det) + 3;
543  break;
545  subdet = 2;
546  component = tTopo_->tobLayer(det);
547  break;
549  subdet = 3;
550  component = tTopo_->tecSide(det) == 2 ? tTopo_->tecWheel(det) : tTopo_->tecWheel(det) + 9;
551  break;
552  default:
553  break;
554  }
555 
556  const auto pQdvBegin = quality.getDataVectorBegin();
557  const auto sqrange = SiStripQuality::Range(pQdvBegin + rp->ibegin, pQdvBegin + rp->iend);
558  float percentage = 0;
559  for (int it = 0; it < sqrange.second - sqrange.first; it++) {
560  unsigned int range = quality.decode(*(sqrange.first + it)).range;
561  nTkBadComp[3] += range;
562  nBadComp[subdet][0][3] += range;
563  nBadComp[subdet][component][3] += range;
564  percentage += range;
565  }
566  if (percentage != 0)
567  percentage /= (sistrip::STRIPS_PER_APV * detInfo.getNumberOfApvsAndStripLength(det).first);
568  if (percentage > 1)
569  edm::LogError("SiStripHitEfficiencyHarvester") << "PROBLEM detid " << det.rawId() << " value " << percentage;
570  }
571 
572  // printout
573  std::ostringstream ss;
574  ss << "\n-----------------\nGlobal Info\n-----------------";
575  ss << "\nBadComp \t Modules \tFibers "
576  "\tApvs\tStrips\n----------------------------------------------------------------";
577  ss << "\nTracker:\t\t" << nTkBadComp[0] << "\t" << nTkBadComp[1] << "\t" << nTkBadComp[2] << "\t" << nTkBadComp[3];
578  ss << "\nTIB:\t\t\t" << nBadComp[0][0][0] << "\t" << nBadComp[0][0][1] << "\t" << nBadComp[0][0][2] << "\t"
579  << nBadComp[0][0][3];
580  ss << "\nTID:\t\t\t" << nBadComp[1][0][0] << "\t" << nBadComp[1][0][1] << "\t" << nBadComp[1][0][2] << "\t"
581  << nBadComp[1][0][3];
582  ss << "\nTOB:\t\t\t" << nBadComp[2][0][0] << "\t" << nBadComp[2][0][1] << "\t" << nBadComp[2][0][2] << "\t"
583  << nBadComp[2][0][3];
584  ss << "\nTEC:\t\t\t" << nBadComp[3][0][0] << "\t" << nBadComp[3][0][1] << "\t" << nBadComp[3][0][2] << "\t"
585  << nBadComp[3][0][3];
586  ss << "\n";
587 
588  for (int i = 1; i < 5; ++i)
589  ss << "\nTIB Layer " << i << " :\t\t" << nBadComp[0][i][0] << "\t" << nBadComp[0][i][1] << "\t" << nBadComp[0][i][2]
590  << "\t" << nBadComp[0][i][3];
591  ss << "\n";
592  for (int i = 1; i < 4; ++i)
593  ss << "\nTID+ Disk " << i << " :\t\t" << nBadComp[1][i][0] << "\t" << nBadComp[1][i][1] << "\t" << nBadComp[1][i][2]
594  << "\t" << nBadComp[1][i][3];
595  for (int i = 4; i < 7; ++i)
596  ss << "\nTID- Disk " << i - 3 << " :\t\t" << nBadComp[1][i][0] << "\t" << nBadComp[1][i][1] << "\t"
597  << nBadComp[1][i][2] << "\t" << nBadComp[1][i][3];
598  ss << "\n";
599  for (int i = 1; i < 7; ++i)
600  ss << "\nTOB Layer " << i << " :\t\t" << nBadComp[2][i][0] << "\t" << nBadComp[2][i][1] << "\t" << nBadComp[2][i][2]
601  << "\t" << nBadComp[2][i][3];
602  ss << "\n";
603  for (int i = 1; i < 10; ++i)
604  ss << "\nTEC+ Disk " << i << " :\t\t" << nBadComp[3][i][0] << "\t" << nBadComp[3][i][1] << "\t" << nBadComp[3][i][2]
605  << "\t" << nBadComp[3][i][3];
606  for (int i = 10; i < 19; ++i)
607  ss << "\nTEC- Disk " << i - 9 << " :\t\t" << nBadComp[3][i][0] << "\t" << nBadComp[3][i][1] << "\t"
608  << nBadComp[3][i][2] << "\t" << nBadComp[3][i][3];
609  ss << "\n";
610 
611  ss << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
612  "Apvs\n----------------------------------------------------------------";
613  for (int i = 1; i < 5; ++i)
614  ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
615  ss << "\n";
616  for (int i = 1; i < 4; ++i)
617  ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
618  for (int i = 4; i < 7; ++i)
619  ss << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
620  ss << "\n";
621  for (int i = 1; i < 7; ++i)
622  ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
623  ss << "\n";
624  for (int i = 1; i < 10; ++i)
625  ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
626  for (int i = 10; i < 19; ++i)
627  ss << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
628 
629  LOGPRINT << ss.str();
630 
631  // store also bad modules in log file
632  std::ofstream badModules;
633  badModules.open("BadModules_NEW.log");
634  badModules << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
635  "Apvs\n----------------------------------------------------------------";
636  for (int i = 1; i < 5; ++i)
637  badModules << "\nTIB Layer " << i << " :" << ssV[0][i].str();
638  badModules << "\n";
639  for (int i = 1; i < 4; ++i)
640  badModules << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
641  for (int i = 4; i < 7; ++i)
642  badModules << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
643  badModules << "\n";
644  for (int i = 1; i < 7; ++i)
645  badModules << "\nTOB Layer " << i << " :" << ssV[2][i].str();
646  badModules << "\n";
647  for (int i = 1; i < 10; ++i)
648  badModules << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
649  for (int i = 10; i < 19; ++i)
650  badModules << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
651  badModules.close();
652 }
653 
656  desc.add<bool>("isAtPCL", false);
657  desc.add<bool>("doStoreOnDB", false);
658  desc.add<std::string>("Record", "SiStripBadStrip");
659  desc.add<double>("Threshold", 0.1);
660  desc.add<std::string>("Title", "Hit Efficiency");
661  desc.add<int>("nModsMin", 5);
662  desc.addUntracked<bool>("AutoIneffModTagging", false);
663  desc.addUntracked<double>("TkMapMin", 0.9);
664  desc.addUntracked<bool>("ShowRings", false);
665  descriptions.addWithDefaultLabel(desc);
666 }
667 
unsigned short range
bool checkMapsValidity(const std::vector< MonitorElement * > &maps, const std::string &type) const
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::vector< BadComponent > & getBadComponentList() const
constexpr char const * layerName[numberOfLayers]
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::unique_ptr< TrackerTopology > tTopo_
void endRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual TH1F * getTH1F() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
string quality
void writeBadStripPayload(const SiStripQuality &quality) const
Log< level::Error, false > LogError
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
void makeSummary(DQMStore::IGetter &getter, TFileService &fs) const
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
RegistryIterator getRegistryVectorEnd() const
void printTotalStatistics(const std::array< long, 23 > &layerFound, const std::array< long, 23 > &layerTotal) const
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
void makeSummaryVsBX(DQMStore::IGetter &getter, TFileService &fs) const
bool isAvailable() const
Definition: Service.h:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Transition
Definition: Transition.h:12
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
SiStripDetInfo read(std::string filePath)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
SiStripHitEfficiencyHarvester(const edm::ParameterSet &)
ContainerIterator getDataVectorBegin() const
Log< level::Info, false > LogInfo
Definition: DetId.h:17
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Constants and enumerated types for FED/FEC systems.
~SiStripHitEfficiencyHarvester() override=default
RegistryIterator getRegistryVectorBegin() const
static const uint16_t STRIPS_PER_APV
void makeSummaryVsCM(DQMStore::IGetter &getter, TFileService &fs) const
std::pair< ContainerIterator, ContainerIterator > Range
std::unique_ptr< SiStripQuality > stripQuality_
static constexpr char const *const kDefaultFile
void makeSummaryVsLumi(DQMStore::IGetter &getter) const
void printAndWriteBadModules(const SiStripQuality &quality, const SiStripDetInfo &detInfo) const
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
#define str(s)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_
data decode(const unsigned int &value) const
Definition: Run.h:45
#define LogDebug(id)
unsigned transform(const HcalDetId &id, unsigned transformCode)