29 #include <unordered_map> 36 :
public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
102 usesResource(
"DQMStore");
103 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo::Deleting SiStripDcsInfo ";
120 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo:: Begining of Run";
129 std::vector<int> FedsInIds = sumFED->m_fed_in;
130 for (
unsigned int it = 0; it < FedsInIds.size(); ++it) {
131 int fedID = FedsInIds[it];
132 if (fedID >= siStripFedIdMin && fedID <= siStripFedIdMax)
149 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo::beginLuminosityBlock";
156 subDetME.second.FaultyDetectors.clear();
163 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo::endLuminosityBlock";
173 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo::EndRun";
179 subDetME.second.FaultyDetectors.clear();
194 if (!strip_dir.empty())
204 if (!strip_dir.empty())
210 subDetME.DcsFractionME = dqm_store.
bookFloat(me_name);
220 LogDebug(
"SiStripDcsInfo") <<
"SiStripDcsInfo::readCabling : " 221 <<
" Change in Cache";
224 std::vector<uint32_t> SelectedDetIds;
226 LogDebug(
"SiStripDcsInfo") <<
" SiStripDcsInfo::readCabling : " 227 <<
" Total Detectors " << SelectedDetIds.size();
231 it->second.TotalDetectors = 0;
234 for (std::vector<uint32_t>::const_iterator idetid = SelectedDetIds.begin(); idetid != SelectedDetIds.end();
236 uint32_t detId = *idetid;
237 if (detId == 0 || detId == 0xFFFFFFFF)
244 iPos->second.TotalDetectors++;
254 const auto& detVOff =
256 std::vector<uint32_t> FaultyDetIds;
257 detVOff.getDetIds(FaultyDetIds);
258 LogDebug(
"SiStripDcsInfo") <<
" SiStripDcsInfo::readStatus : " 259 <<
" Faulty Detectors " << FaultyDetIds.size();
261 for (std::vector<uint32_t>::const_iterator ihvoff = FaultyDetIds.begin(); ihvoff != FaultyDetIds.end(); ++ihvoff) {
262 uint32_t detId_hvoff = (*ihvoff);
270 std::vector<uint32_t>::iterator ibad =
271 std::find(iPos->second.FaultyDetectors.begin(), iPos->second.FaultyDetectors.end(), detId_hvoff);
272 if (ibad == iPos->second.FaultyDetectors.end())
273 iPos->second.FaultyDetectors.push_back(detId_hvoff);
285 float total_det = 0.0;
286 float faulty_det = 0.0;
289 int total_subdet = subDetMEs.TotalDetectors;
290 int faulty_subdet = subDetMEs.FaultyDetectors.size();
294 fraction = 1.0 - faulty_subdet * 1.0 / total_subdet;
295 subDetMEs.DcsFractionME->Reset();
296 subDetMEs.DcsFractionME->Fill(
fraction);
297 edm::LogInfo(
"SiStripDcsInfo") <<
" SiStripDcsInfo::fillStatus : Sub Detector " <<
name <<
" Total Number " 298 << total_subdet <<
" Faulty ones " << faulty_subdet;
299 total_det += total_subdet;
300 faulty_det += faulty_subdet;
305 fraction = 1 - faulty_det / total_det;
314 for (
auto const detId_faulty :
pr.second.FaultyDetectors) {
315 pr.second.NLumiDetectorIsFaulty[detId_faulty]++;
329 pr.second.DcsFractionME->Reset();
330 pr.second.DcsFractionME->Fill(-1.0);
346 auto const& lumiCountBadModules =
pr.second.NLumiDetectorIsFaulty;
347 for (
auto const [ibad, nBadLumi] : lumiCountBadModules) {
350 std::string bad_module_folder = mechanical_dir +
"/" +
pr.second.folder_name +
355 std::ostringstream detid_str;
357 std::string full_path = bad_module_folder +
"/" + detid_str.str();
static void setBadModuleFlag(std::string &hname, uint16_t &flg)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup) override
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
void bookStatus(DQMStore &dqm_store)
const SiStripDetCabling * detCabling_
edm::ESGetToken< SiStripDetVOff, SiStripDetVOffRcd > detVOffToken2_
SiStripDcsInfo(const edm::ParameterSet &ps)
edm::ESGetToken< SiStripDetVOff, SiStripDetVOffRcd > detVOffToken0_
void setCurrentFolder(std::string const &fullpath) override
std::optional< T > tryToGet() const
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
std::string pwd() override
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken2_
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool IsConnected(const uint32_t &det_id) const
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
void fillStatus(DQMStore &dqm_store)
std::map< std::string, SubDetMEs > SubDetMEsMap
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
const std::string subdet_tag("SubDet")
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
MonitorElement * DcsFractionME
UseScope< MonitorElementData::Scope::LUMI > UseLumiScope
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Info, false > LogInfo
static constexpr float MaxAcceptableBadDcsLumi_
void readCabling(edm::EventSetup const &)
void readStatus(edm::EventSetup const &, int transition)
unsigned long long m_cacheIDDcs_
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
MonitorElement * DcsFraction_
virtual MonitorElement * get(std::string const &fullpath) const
bool check(const edm::EventSetup &iSetup)
static void getSubDetectorTag(uint32_t det_id, std::string &subdet_tag, const TrackerTopology *tTopo)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken3_
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void analyze(edm::Event const &, edm::EventSetup const &) override
static bool goToDir(DQMStore &dqm_store, std::string const &name)
std::unordered_map< uint32_t, uint16_t > NLumiDetectorIsFaulty
edm::ESGetToken< SiStripDetVOff, SiStripDetVOffRcd > detVOffToken1_
std::vector< uint32_t > FaultyDetectors
void addBadModules(DQMStore &dqm_store)
dqm::harvesting::MonitorElement MonitorElement
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken1_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken0_
static constexpr float MinAcceptableDcsDetFrac_
static void getTopFolderPath(DQMStore &dqm_store, std::string const &top_dir, std::string &path)
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void fillDummyStatus(DQMStore &dqm_store)
dqm::harvesting::DQMStore DQMStore