CMS 3D CMS Logo

SiStripBadComponentsDQMServiceReader.cc
Go to the documentation of this file.
1 // system include files
2 #include <sstream>
3 #include <string>
4 #include <iostream>
5 #include <cstdio>
6 #include <sys/time.h>
7 
8 // user include files
22 
23 class TrackerTopology;
24 class SiStripBadStrip;
25 
27 public:
29  ~SiStripBadComponentsDQMServiceReader() override = default;
30 
31  void analyze(const edm::Event&, const edm::EventSetup&) override;
32 
33  void printError(std::stringstream& ss, const bool error, const std::string& errorText);
34 
35  std::string detIdToString(DetId detid, const TrackerTopology& tTopo);
36 
37 private:
38  const bool printdebug_;
41 };
42 
43 using namespace std;
44 
46  : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", true)),
47  tTopoToken_(esConsumes()),
48  badStripToken_(esConsumes()) {}
49 
51  //Retrieve tracker topology from geometry
52  const auto& tTopo = iSetup.getData(tTopoToken_);
53 
54  uint32_t FedErrorMask = 1; // bit 0
55  uint32_t DigiErrorMask = 2; // bit 1
56  uint32_t ClusterErrorMask = 4; // bit 2
57 
58  const auto& siStripBadStrip = iSetup.getData(badStripToken_);
59  edm::LogInfo("SiStripBadComponentsDQMServiceReader")
60  << "[SiStripBadComponentsDQMServiceReader::analyze] End Reading SiStripBadStrip" << std::endl;
61 
62  std::vector<uint32_t> detid;
63  siStripBadStrip.getDetIds(detid);
64 
65  std::stringstream ss;
66 
67  // ss << " detid" << " \t\t\t" << "FED error" << " \t" << "Digi test failed" << " \t" << "Cluster test failed" << std::endl;
68 
69  ss << "subdet layer stereo side \t detId \t\t Errors" << std::endl;
70 
71  for (size_t id = 0; id < detid.size(); id++) {
72  SiStripBadStrip::Range range = siStripBadStrip.getRange(detid[id]);
73 
74  for (int it = 0; it < range.second - range.first; it++) {
75  unsigned int value = (*(range.first + it));
76  ss << detIdToString(detid[id], tTopo) << "\t" << detid[id] << "\t";
77 
78  uint32_t flag = static_cast<uint32_t>(siStripBadStrip.decode(value).flag);
79 
80  printError(ss, ((flag & FedErrorMask) == FedErrorMask), "Fed error, ");
81  printError(ss, ((flag & DigiErrorMask) == DigiErrorMask), "Digi error, ");
82  printError(ss, ((flag & ClusterErrorMask) == ClusterErrorMask), "Cluster error");
83  ss << std::endl;
84 
85  if (printdebug_) {
86  ss << " firstBadStrip " << siStripBadStrip.decode(value).firstStrip << "\t "
87  << " NconsecutiveBadStrips " << siStripBadStrip.decode(value).range << "\t " // << std::endl;
88  << " flag " << siStripBadStrip.decode(value).flag << "\t "
89  << " packed integer " << std::hex << value << std::dec << "\t " << std::endl;
90  }
91  }
92  ss << std::endl;
93  }
94  edm::LogInfo("SiStripBadComponentsDQMServiceReader") << ss.str();
95 }
96 
98  const bool error,
99  const std::string& errorText) {
100  if (error) {
101  ss << errorText << "\t ";
102  } else {
103  ss << "\t\t ";
104  }
105 }
106 
109  int layer = 0;
110  int stereo = 0;
111  int side = -1;
112 
113  // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
114  switch (detid.subdetId()) {
115  case StripSubdetector::TIB: {
116  detector = "TIB";
117  layer = tTopo.tibLayer(detid.rawId());
118  stereo = tTopo.tibStereo(detid.rawId());
119  break;
120  }
121  case StripSubdetector::TOB: {
122  detector = "TOB";
123  layer = tTopo.tobLayer(detid.rawId());
124  stereo = tTopo.tobStereo(detid.rawId());
125  break;
126  }
127  case StripSubdetector::TEC: {
128  // is this module in TEC+ or TEC-?
129  side = tTopo.tecSide(detid.rawId());
130  detector = "TEC";
131  layer = tTopo.tecWheel(detid.rawId());
132  stereo = tTopo.tecStereo(detid.rawId());
133  break;
134  }
135  case StripSubdetector::TID: {
136  // is this module in TID+ or TID-?
137  side = tTopo.tidSide(detid.rawId());
138  detector = "TID";
139  layer = tTopo.tidWheel(detid.rawId());
140  stereo = tTopo.tidStereo(detid.rawId());
141  break;
142  }
143  }
144  std::string name(detector + "\t" + std::to_string(layer) + "\t" + std::to_string(stereo) + "\t");
145  if (side == 1) {
146  name += "-";
147  } else if (side == 2) {
148  name += "+";
149  }
150  // if( side != -1 ) {
151  // name += std::to_string(side);
152  // }
153 
154  return name;
155 }
156 
static constexpr auto TEC
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int tobLayer(const DetId &id) const
std::string detIdToString(DetId detid, const TrackerTopology &tTopo)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void printError(std::stringstream &ss, const bool error, const std::string &errorText)
uint32_t tidStereo(const DetId &id) const
unsigned int tidSide(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
std::string to_string(const V &value)
Definition: OMSAccess.h:77
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
uint32_t tobStereo(const DetId &id) const
unsigned int tecSide(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: value.py:1
static constexpr auto TOB
~SiStripBadComponentsDQMServiceReader() override=default
Log< level::Info, false > LogInfo
Definition: DetId.h:17
static constexpr auto TIB
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcd > badStripToken_
std::pair< ContainerIterator, ContainerIterator > Range
void analyze(const edm::Event &, const edm::EventSetup &) override
uint32_t tecStereo(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
static constexpr auto TID
uint32_t tibStereo(const DetId &id) const