CMS 3D CMS Logo

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",
43  tTopoToken_(iC.esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()) {
44  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::SiStripBadComponentsDQMService]";
45 }
46 
48  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService]";
49 }
50 
52  trackerTopo_ = &setup.getData(tTopoToken_);
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  for (const auto& im : subdet_folder) {
96  const std::string dname = mechanicalview_dir + "/" + im;
97  getter.cd();
98  if (!getter.dirExists(dname))
99  continue;
100  getter.cd(dname);
101 
102  std::vector<std::string> module_folders;
103  getModuleFolderList(getter, dname, module_folders);
104 
105  const std::string bad_module_folder = dname + "/" + "BadModuleList";
106  getter.cd();
107  if (getter.dirExists(bad_module_folder)) {
108  for (const MonitorElement* me : getter.getContents(bad_module_folder)) {
109  std::cout << me->getName() << " " << me->getIntValue() << std::endl;
110  uint32_t detId = std::stoul(me->getName());
111  short flag = me->getIntValue();
112 
113  std::vector<unsigned int> theSiStripVector;
114 
115  unsigned short firstBadStrip = 0, NconsecutiveBadStrips = 0;
116  unsigned int theBadStripRange;
117 
118  // for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){
119 
120  // firstBadStrip=(*is)*128;
121  NconsecutiveBadStrips = detInfo.getNumberOfApvsAndStripLength(detId).first * 128;
122 
123  theBadStripRange = m_obj.encode(firstBadStrip, NconsecutiveBadStrips, flag);
124 
125  LogDebug("SiStripBadComponentsDQMService") << "detid " << detId << " \t"
126  << ", flag " << flag << std::endl;
127 
128  theSiStripVector.push_back(theBadStripRange);
129  // }
130 
131  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
132  if (!m_obj.put(detId, range)) {
133  edm::LogError("SiStripBadFiberBuilder")
134  << "[SiStripBadFiberBuilder::analyze] detid already exists" << std::endl;
135  }
136  }
137  }
138  }
139  getter.cd();
140 }
141 
143 
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
void initES(const edm::EventSetup &) override
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::string fullPath() const
Definition: FileInPath.cc:161
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:769
Log< level::Error, false > LogError
T getUntrackedParameter(std::string const &, T const &) const
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
SiStripPopConBadComponentsHandlerFromDQM(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
std::pair< ContainerIterator, ContainerIterator > Range
static constexpr char const *const kDefaultFile
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)
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:625
#define LogDebug(id)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739