CMS 3D CMS Logo

SiStripHitEffData.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripHitEfficiency_SiStripHitEffData_h
2 #define CalibTracker_SiStripHitEfficiency_SiStripHitEffData_h
3 
7 #include <unordered_map>
8 
10 public:
12 
14  for (const auto& [id, count] : fedErrorCounts) {
15  FEDErrorOccupancy->fill(id, count);
16  }
17  }
18 
19  void fillMapFromTkMap(const int nevents, const float threshold, const std::vector<DetId>& stripDetIds) {
20  const auto& Maps = FEDErrorOccupancy->getAllMaps();
21  std::vector<bool> isThere;
22  isThere.reserve(Maps.size());
23  std::transform(Maps.begin() + 1, Maps.end(), std::back_inserter(isThere), [](auto& x) { return !(x == nullptr); });
24 
25  int count{0};
26  for (const auto& it : isThere) {
27  count++;
28  LogTrace("SiStripHitEffData") << " layer: " << count << " " << it << std::endl;
29  if (it)
30  LogTrace("SiStripHitEffData") << "resolving to " << Maps[count]->getName()
31  << " with entries: " << Maps[count]->getEntries() << std::endl;
32  // color the map
33  Maps[count]->setOption("colz");
34  }
35 
36  for (const auto& det : stripDetIds) {
37  const auto& counts = FEDErrorOccupancy->getValue(det);
38 
39  if (counts > 0) {
40  float fraction = counts / nevents;
41 
42  LogTrace("SiStripHitEffData") << det.rawId() << " has " << counts << " counts, " << fraction * 100
43  << "% fraction of the " << nevents << " events processed" << std::endl;
44 
45  if (fraction > threshold) {
46  fedErrorCounts.insert(std::make_pair(det, 1));
47  }
48  } // do not check functioning modules
49  }
50  // the map has been loaded
51  m_isLoaded = true;
52  }
53 
54  const bool checkFedError(const DetId det) {
55  if (m_isLoaded) {
56  return (fedErrorCounts.find(det) == fedErrorCounts.end());
57  } else {
58  throw cms::Exception("LogicError") << __PRETTY_FUNCTION__ << "cannot check DetId when map not filled";
59  }
60  }
61 
63  std::unordered_map<uint32_t, int> fedErrorCounts;
64  std::unique_ptr<TkHistoMap> FEDErrorOccupancy;
65 
66 private:
67  bool m_isLoaded;
68 };
69 
70 #endif
std::unordered_map< uint32_t, int > fedErrorCounts
std::unique_ptr< TkHistoMap > FEDErrorOccupancy
#define LogTrace(id)
const bool checkFedError(const DetId det)
dqm::reco::MonitorElement * EventStats
Definition: DetId.h:17
void fillMapFromTkMap(const int nevents, const float threshold, const std::vector< DetId > &stripDetIds)
unsigned transform(const HcalDetId &id, unsigned transformCode)