CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripBadComponentsDQMServiceReader.cc
Go to the documentation of this file.
2 
6 
7 #include <iostream>
8 #include <cstdio>
9 #include <sys/time.h>
10 
11 using namespace std;
12 
14  : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", true)),
16  badStripToken_(esConsumes()) {}
17 
19 
21  //Retrieve tracker topology from geometry
22  const auto& tTopo = iSetup.getData(tTopoToken_);
23 
24  uint32_t FedErrorMask = 1; // bit 0
25  uint32_t DigiErrorMask = 2; // bit 1
26  uint32_t ClusterErrorMask = 4; // bit 2
27 
28  const auto& siStripBadStrip = iSetup.getData(badStripToken_);
29  edm::LogInfo("SiStripBadComponentsDQMServiceReader")
30  << "[SiStripBadComponentsDQMServiceReader::analyze] End Reading SiStripBadStrip" << std::endl;
31 
32  std::vector<uint32_t> detid;
33  siStripBadStrip.getDetIds(detid);
34 
35  std::stringstream ss;
36 
37  // ss << " detid" << " \t\t\t" << "FED error" << " \t" << "Digi test failed" << " \t" << "Cluster test failed" << std::endl;
38 
39  ss << "subdet layer stereo side \t detId \t\t Errors" << std::endl;
40 
41  for (size_t id = 0; id < detid.size(); id++) {
42  SiStripBadStrip::Range range = siStripBadStrip.getRange(detid[id]);
43 
44  for (int it = 0; it < range.second - range.first; it++) {
45  unsigned int value = (*(range.first + it));
46  ss << detIdToString(detid[id], tTopo) << "\t" << detid[id] << "\t";
47 
48  uint32_t flag = static_cast<uint32_t>(siStripBadStrip.decode(value).flag);
49 
50  printError(ss, ((flag & FedErrorMask) == FedErrorMask), "Fed error, ");
51  printError(ss, ((flag & DigiErrorMask) == DigiErrorMask), "Digi error, ");
52  printError(ss, ((flag & ClusterErrorMask) == ClusterErrorMask), "Cluster error");
53  ss << std::endl;
54 
55  if (printdebug_) {
56  ss << " firstBadStrip " << siStripBadStrip.decode(value).firstStrip << "\t "
57  << " NconsecutiveBadStrips " << siStripBadStrip.decode(value).range << "\t " // << std::endl;
58  << " flag " << siStripBadStrip.decode(value).flag << "\t "
59  << " packed integer " << std::hex << value << std::dec << "\t " << std::endl;
60  }
61  }
62  ss << std::endl;
63  }
64  edm::LogInfo("SiStripBadComponentsDQMServiceReader") << ss.str();
65 }
66 
68  const bool error,
69  const std::string& errorText) {
70  if (error) {
71  ss << errorText << "\t ";
72  } else {
73  ss << "\t\t ";
74  }
75 }
76 
78  std::string detector;
79  int layer = 0;
80  int stereo = 0;
81  int side = -1;
82 
83  // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
84  switch (detid.subdetId()) {
85  case StripSubdetector::TIB: {
86  detector = "TIB";
87  layer = tTopo.tibLayer(detid.rawId());
88  stereo = tTopo.tibStereo(detid.rawId());
89  break;
90  }
91  case StripSubdetector::TOB: {
92  detector = "TOB";
93  layer = tTopo.tobLayer(detid.rawId());
94  stereo = tTopo.tobStereo(detid.rawId());
95  break;
96  }
97  case StripSubdetector::TEC: {
98  // is this module in TEC+ or TEC-?
99  side = tTopo.tecSide(detid.rawId());
100  detector = "TEC";
101  layer = tTopo.tecWheel(detid.rawId());
102  stereo = tTopo.tecStereo(detid.rawId());
103  break;
104  }
105  case StripSubdetector::TID: {
106  // is this module in TID+ or TID-?
107  side = tTopo.tidSide(detid.rawId());
108  detector = "TID";
109  layer = tTopo.tidWheel(detid.rawId());
110  stereo = tTopo.tidStereo(detid.rawId());
111  break;
112  }
113  }
114  std::string name(detector + "\t" + std::to_string(layer) + "\t" + std::to_string(stereo) + "\t");
115  if (side == 1) {
116  name += "-";
117  } else if (side == 2) {
118  name += "+";
119  }
120  // if( side != -1 ) {
121  // name += std::to_string(side);
122  // }
123 
124  return name;
125 }
static constexpr auto TEC
std::string detIdToString(DetId detid, const TrackerTopology &tTopo)
unsigned int tibLayer(const DetId &id) const
uint16_t *__restrict__ id
void printError(std::stringstream &ss, const bool error, const std::string &errorText)
uint32_t tobStereo(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::string to_string(const V &value)
Definition: OMSAccess.h:71
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
unsigned int tidWheel(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
unsigned int tidSide(const DetId &id) const
uint32_t tidStereo(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcd > badStripToken_
static constexpr auto TOB
Log< level::Info, false > LogInfo
Definition: DetId.h:17
static constexpr auto TIB
std::pair< ContainerIterator, ContainerIterator > Range
uint32_t tecStereo(const DetId &id) const
void analyze(const edm::Event &, const edm::EventSetup &) override
uint32_t tibStereo(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
static constexpr auto TID
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const