CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripBadModuleFedErrService.cc
Go to the documentation of this file.
1 
6 
7 #include "boost/cstdint.hpp"
8 #include "boost/lexical_cast.hpp"
9 
10 #include <cctype>
11 #include <time.h>
12 
13 #include <iostream>
14 #include <sstream>
15 #include <string>
16 #include <vector>
17 
18 using namespace std;
19 
22  iConfig_(iConfig)
23 {
24  edm::LogInfo("SiStripBadModuleFedErrService") << "[SiStripBadModuleFedErrService::SiStripBadModuleFedErrService]";
25 }
26 
28 {
29  edm::LogInfo("SiStripBadModuleFedErrService") << "[SiStripBadModuleFedErrService::~SiStripBadModuleFedErrService]";
30 }
31 
33 {
34  ss << "Run " << getRunNumber() << std::endl;
35  obj_->printSummary(ss);
36 }
37 
39 {
40  std::stringstream localString;
41  getMetaDataString(localString);
42  if( ss == localString.str() ) return false;
43 
44  return true;
45 }
46 
48 
49 
51 
52  bool readFlag = iConfig_.getParameter<bool>("ReadFromFile");
54 
55 
56  if (readFlag && !openRequestedFile()) return obj_;
57 
58  dqmStore_->cd();
59 
60  std::string dname = "SiStrip/ReadoutView";
61  std::string hpath = dname;
62  hpath += "/FedIdVsApvId";
63  if (dqmStore_->dirExists(dname)) {
64  MonitorElement* me = dqmStore_->get(hpath);
65  if (me) {
66  std::vector<std::pair<uint16_t, uint16_t>> channelList;
67  getFedBadChannelList(me, channelList);
68  uint16_t fId_last = 9999;
69  uint16_t fChan_last = 9999;
70  std::map< uint32_t , std::set<int> > detectorMap;
71  for (std::vector<std::pair<uint16_t, uint16_t>>::iterator it = channelList.begin(); it != channelList.end(); it++) {
72  uint16_t fId = it->first;
73 
74  uint16_t fChan = it->second/2;
75  if (fId == fId_last && fChan == fChan_last) continue;
76 
77  FedChannelConnection channel = cabling->fedConnection(fId, fChan);
78  const uint32_t detId = channel.detId();
79  const uint16_t ipair = channel.apvPairNumber();
80  detectorMap[detId].insert(ipair);
81  }
82  for (std::map< uint32_t , std::set<int> >::iterator im = detectorMap.begin(); im != detectorMap.end(); im++) {
83  const uint32_t detId = im->first;
84  std::set<int> pairs = im->second;
85  SiStripQuality::InputVector theSiStripVector;
86  unsigned short firstBadStrip = 0;
87  unsigned short fNconsecutiveBadStrips = 0;
88  unsigned int theBadStripRange;
89  int last_pair = -1;
90  for (std::set<int>::iterator ip = pairs.begin(); ip != pairs.end(); ip++) {
91  if (last_pair == -1) {
92  firstBadStrip = (*ip) * 128 * 2;
93  fNconsecutiveBadStrips = 128*2;
94  } else if ((*ip) - last_pair > 1) {
95  theBadStripRange = obj_->encode(firstBadStrip,fNconsecutiveBadStrips);
96  theSiStripVector.push_back(theBadStripRange);
97  firstBadStrip = (*ip) * 128 * 2;
98  fNconsecutiveBadStrips = 128*2;
99  } else {
100  fNconsecutiveBadStrips += 128*2;
101  }
102  last_pair = (*ip);
103  }
104  theBadStripRange = obj_->encode(firstBadStrip,fNconsecutiveBadStrips);
105  theSiStripVector.push_back(theBadStripRange);
106 
107  edm::LogInfo("SiStripBadModuleFedErrService") << " SiStripBadModuleFedErrService::readBadComponentsFromFed "
108  << " detid " << detId
109  << " firstBadStrip " << firstBadStrip
110  << " NconsecutiveBadStrips " << fNconsecutiveBadStrips
111  << " packed integer " << std::hex << theBadStripRange << std::dec;
112  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
113  if ( !obj_->put(detId,range) ) {
114  edm::LogError("SiStripBadModuleFedErrService")<<"[SiStripBadModuleFedErrService::readBadComponentsFromFed] detid already exists"<<std::endl;
115  }
116  }
117  obj_->cleanUp();
118  }
119  }
120  return obj_;
121 }
122 
123 
125 
127 
128  edm::LogInfo("SiStripBadModuleFedErrService") << "[SiStripBadModuleFedErrService::openRequestedFile] Accessing root File" << fileName;
129 
130  if (!dqmStore_->load(fileName, DQMStore::OpenRunDirs::StripRunDirs, true) ) {
131  edm::LogError("SiStripBadModuleFedErrService")<<"[SiStripBadModuleFedErrService::openRequestedFile] Requested file " << fileName << "Can not be opened!! ";
132  return false;
133  } else return true;
134 }
135 
137  edm::LogInfo("SiStripBadModuleFedErrService") << "[SiStripBadModuleFedErrService::getRunNumber] " << iConfig_.getParameter<uint32_t>("RunNumber");
138  return iConfig_.getParameter<uint32_t>("RunNumber");
139 }
140 void SiStripBadModuleFedErrService::getFedBadChannelList(MonitorElement* me, std::vector<std::pair<uint16_t,uint16_t> >& list) {
141  float cutoff = iConfig_.getParameter<double>("BadStripCutoff");
142  if (me->kind() == MonitorElement::DQM_KIND_TH2F) {
143  TH2F* th2 = me->getTH2F();
144  float entries = getProcessedEvents();
145  if (!entries) entries = th2->GetBinContent(th2->GetMaximumBin());
146  for (uint16_t i = 1; i < th2->GetNbinsY()+1; i++) {
147  for (uint16_t j = 1; j < th2->GetNbinsX()+1; j++) {
148  if (th2->GetBinContent(j,i) > cutoff * entries) {
149  edm::LogInfo("SiStripBadModuleFedErrService") << " [SiStripBadModuleFedErrService::getFedBadChannelList] :: FedId & Channel " << th2->GetYaxis()->GetBinLowEdge(i) << " " << th2->GetXaxis()->GetBinLowEdge(j);
150  list.push_back(std::pair<uint16_t, uint16_t>(th2->GetYaxis()->GetBinLowEdge(i), th2->GetXaxis()->GetBinLowEdge(j)));
151  }
152  }
153  }
154  }
155 }
157 
158  dqmStore_->cd();
159 
160  std::string dname = "SiStrip/ReadoutView";
161  std::string hpath = dname;
162  hpath += "/nTotalBadActiveChannels";
163  if (dqmStore_->dirExists(dname)) {
164  MonitorElement* me = dqmStore_->get(hpath);
165  if (me) return (me->getEntries());
166  }
167  return 0;
168 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool cleanUp(bool force=false)
void printSummary(std::stringstream &ss) const
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
uint16_t apvPairNumber() const
double getEntries(void) const
get # of entries
void getMetaDataString(std::stringstream &ss)
Used to fill the logDB.
const uint32_t & detId() const
SiStripBadModuleFedErrService(const edm::ParameterSet &, const edm::ActivityRegistry &)
Class containning control, module, detector and connection information, at the level of a FED channel...
int j
Definition: DBlmapReader.cc:9
Kind kind(void) const
Get the type of the monitor element.
SiStripBadStrip * readBadComponentsFromFed(const SiStripFedCabling *cabling)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void getFedBadChannelList(MonitorElement *me, std::vector< std::pair< uint16_t, uint16_t >> &list)
std::pair< ContainerIterator, ContainerIterator > Range
virtual bool checkForCompatibility(std::string ss)
Check is the transfer is needed.
TH2F * getTH2F(void) const
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
Container InputVector