CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripBadComponentsDQMServiceReader.cc
Go to the documentation of this file.
3 
5 
6 #include <iostream>
7 #include <stdio.h>
8 #include <sys/time.h>
9 
10 #include <boost/lexical_cast.hpp>
11 
12 using namespace std;
13 
15  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug",true)){}
16 
18 
20 {
21  uint32_t FedErrorMask = 1; // bit 0
22  uint32_t DigiErrorMask = 2; // bit 1
23  uint32_t ClusterErrorMask = 4; // bit 2
24 
25  edm::ESHandle<SiStripBadStrip> SiStripBadStrip_;
26  iSetup.get<SiStripBadStripRcd>().get(SiStripBadStrip_);
27  edm::LogInfo("SiStripBadComponentsDQMServiceReader") << "[SiStripBadComponentsDQMServiceReader::analyze] End Reading SiStripBadStrip" << std::endl;
28 
29  std::vector<uint32_t> detid;
30  SiStripBadStrip_->getDetIds(detid);
31 
32  std::stringstream ss;
33 
34  // ss << " detid" << " \t\t\t" << "FED error" << " \t" << "Digi test failed" << " \t" << "Cluster test failed" << std::endl;
35 
36  ss << "subdet layer stereo side \t detId \t\t Errors" << std::endl;
37 
38  for (size_t id=0;id<detid.size();id++) {
39  SiStripBadStrip::Range range=SiStripBadStrip_->getRange(detid[id]);
40 
41  for(int it=0;it<range.second-range.first;it++){
42  unsigned int value=(*(range.first+it));
43  ss << detIdToString(detid[id]) << "\t" << detid[id] << "\t";
44 
45  uint32_t flag = boost::lexical_cast<uint32_t>(SiStripBadStrip_->decode(value).flag);
46 
47  printError( ss, ((flag & FedErrorMask) == FedErrorMask), "Fed error, " );
48  printError( ss, ((flag & DigiErrorMask) == DigiErrorMask), "Digi error, " );
49  printError( ss, ((flag & ClusterErrorMask) == ClusterErrorMask), "Cluster error" );
50  ss << std::endl;
51 
52  if (printdebug_) {
53  ss << " firstBadStrip " << SiStripBadStrip_->decode(value).firstStrip << "\t "
54  << " NconsecutiveBadStrips " << SiStripBadStrip_->decode(value).range << "\t " // << std::endl;
55  << " flag " << SiStripBadStrip_->decode(value).flag << "\t "
56  << " packed integer " << std::hex << value << std::dec << "\t " << std::endl;
57  }
58  }
59  ss << std::endl;
60  }
61  edm::LogInfo("SiStripBadComponentsDQMServiceReader") << ss.str();
62 }
63 
64 void SiStripBadComponentsDQMServiceReader::printError( std::stringstream & ss, const bool error, const std::string & errorText)
65 {
66  if( error ) {
67  ss << errorText << "\t ";
68  }
69  else {
70  ss << "\t\t ";
71  }
72 }
73 
75 {
76  std::string detector;
77  int layer = 0;
78  int stereo = 0;
79  int side = -1;
80 
81  // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
82  switch (detid.subdetId()) {
84  {
85  TIBDetId theTIBDetId(detid.rawId());
86  detector = "TIB";
87  layer = theTIBDetId.layer();
88  stereo = theTIBDetId.stereo();
89  break;
90  }
92  {
93  TOBDetId theTOBDetId(detid.rawId());
94  detector = "TOB";
95  layer = theTOBDetId.layer();
96  stereo = theTOBDetId.stereo();
97  break;
98  }
100  {
101  TECDetId theTECDetId(detid.rawId());
102  // is this module in TEC+ or TEC-?
103  side = theTECDetId.side();
104  detector = "TEC";
105  layer = theTECDetId.wheel();
106  stereo = theTECDetId.stereo();
107  break;
108  }
110  {
111  TIDDetId theTIDDetId(detid.rawId());
112  // is this module in TID+ or TID-?
113  side = theTIDDetId.side();
114  detector = "TID";
115  layer = theTIDDetId.wheel();
116  stereo = theTIDDetId.stereo();
117  break;
118  }
119  }
120  std::string name( detector + "\t" + boost::lexical_cast<string>(layer) + "\t" + boost::lexical_cast<string>(stereo) + "\t" );
121  if( side == 1 ) {
122  name += "-";
123  }
124  else if ( side == 2 ) {
125  name += "+";
126  }
127 // if( side != -1 ) {
128 // name += boost::lexical_cast<string>(side);
129 // }
130 
131  return name;
132 }
long int flag
Definition: mlp_lapack.h:47
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
void printError(std::stringstream &ss, const bool error, const std::string &errorText)
unsigned int side() const
positive or negative id
Definition: TECDetId.h:47
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: DetId.h:20
unsigned int side() const
positive or negative id
Definition: TIDDetId.h:45
const T & get() const
Definition: EventSetup.h:55
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
std::pair< ContainerIterator, ContainerIterator > Range