CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripPopConBadComponentsDQM.cc
Go to the documentation of this file.
4 
12 public:
15 
18  // interface methods: implemented in template
19  void initES(const edm::EventSetup&) override;
20  void dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) override;
21  SiStripBadStrip* getObj() const override;
22 
23 protected:
24  std::string getMetaDataString() const override;
25 
26 private:
31 };
32 
34 
37 
41  fp_{iConfig.getUntrackedParameter<edm::FileInPath>("file",
44  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::SiStripBadComponentsDQMService]";
45 }
46 
48  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService]";
49 }
50 
53 }
54 
56  std::stringstream ss;
57  ss << SiStripDQMPopConSourceHandler<SiStripBadStrip>::getMetaDataString();
59  return ss.str();
60 }
61 
62 namespace {
63  void getModuleFolderList(SiStripPopConBadComponentsHandlerFromDQM::DQMStore::IGetter& getter,
64  const std::string& pwd,
65  std::vector<std::string>& mfolders) {
66  if (std::string::npos != pwd.find("module_")) {
67  // std::string mId = pwd.substr(pwd.find("module_")+7, 9);
68  mfolders.push_back(pwd);
69  } else {
70  for (const auto& subdir : getter.getSubdirs()) {
71  getter.cd(subdir);
72  getModuleFolderList(getter, subdir, mfolders);
73  getter.cd();
74  getter.cd(pwd);
75  }
76  }
77  }
78 } // namespace
79 
81  //*LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB*//
82 
84 
85  const auto detInfo = SiStripDetInfoFileReader::read(fp_.fullPath());
86 
87  getter.cd();
88 
89  const std::string mechanicalview_dir = "MechanicalView";
90  if (!getter.dirExists(mechanicalview_dir))
91  return;
92 
93  const std::vector<std::string> subdet_folder = {"TIB", "TOB", "TEC/side_1", "TEC/side_2", "TID/side_1", "TID/side_2"};
94 
95  int nDetsTotal = 0;
96  int nDetsWithErrorTotal = 0;
97  for (const auto& im : subdet_folder) {
98  const std::string dname = mechanicalview_dir + "/" + im;
99  getter.cd();
100  if (!getter.dirExists(dname))
101  continue;
102  getter.cd(dname);
103 
104  std::vector<std::string> module_folders;
105  getModuleFolderList(getter, dname, module_folders);
106  int nDets = module_folders.size();
107 
108  int nDetsWithError = 0;
109  const std::string bad_module_folder = dname + "/" + "BadModuleList";
110  getter.cd();
111  if (getter.dirExists(bad_module_folder)) {
112  for (const MonitorElement* me : getter.getContents(bad_module_folder)) {
113  nDetsWithError++;
114  std::cout << me->getName() << " " << me->getIntValue() << std::endl;
115  uint32_t detId = std::stoul(me->getName());
116  short flag = me->getIntValue();
117 
118  std::vector<unsigned int> theSiStripVector;
119 
120  unsigned short firstBadStrip = 0, NconsecutiveBadStrips = 0;
121  unsigned int theBadStripRange;
122 
123  // for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){
124 
125  // firstBadStrip=(*is)*128;
126  NconsecutiveBadStrips = detInfo.getNumberOfApvsAndStripLength(detId).first * 128;
127 
128  theBadStripRange = m_obj.encode(firstBadStrip, NconsecutiveBadStrips, flag);
129 
130  LogDebug("SiStripBadComponentsDQMService") << "detid " << detId << " \t"
131  << ", flag " << flag << std::endl;
132 
133  theSiStripVector.push_back(theBadStripRange);
134  // }
135 
136  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
137  if (!m_obj.put(detId, range)) {
138  edm::LogError("SiStripBadFiberBuilder")
139  << "[SiStripBadFiberBuilder::analyze] detid already exists" << std::endl;
140  }
141  }
142  }
143  nDetsTotal += nDets;
144  nDetsWithErrorTotal += nDetsWithError;
145  }
146  getter.cd();
147 }
148 
150 
T getUntrackedParameter(std::string const &, T const &) const
void initES(const edm::EventSetup &) override
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Log< level::Error, false > LogError
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
SiStripPopConBadComponentsHandlerFromDQM(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
std::pair< ContainerIterator, ContainerIterator > Range
std::string fullPath() const
Definition: FileInPath.cc:161
static constexpr char const *const kDefaultFile
tuple cout
Definition: gather_cfg.py:144
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)
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
#define LogDebug(id)