Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:28

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "CondFormats/DataRecord/interface/SiStripBadStripRcd.h"
0008 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0009 
0010 #include <iostream>
0011 #include <cstdio>
0012 #include <sys/time.h>
0013 
0014 class SiStripBadStripReader : public edm::one::EDAnalyzer<> {
0015 public:
0016   explicit SiStripBadStripReader(const edm::ParameterSet& iConfig)
0017       : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", false)), badStripToken_(esConsumes()) {}
0018 
0019   ~SiStripBadStripReader() override;
0020 
0021   void analyze(const edm::Event&, const edm::EventSetup&) override;
0022 
0023 private:
0024   const bool printdebug_;
0025   const edm::ESGetToken<SiStripBadStrip, SiStripBadStripRcd> badStripToken_;
0026 };
0027 
0028 SiStripBadStripReader::~SiStripBadStripReader() = default;
0029 
0030 void SiStripBadStripReader::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
0031   const auto& badStrip = iSetup.getData(badStripToken_);
0032   edm::LogInfo("SiStripBadStripReader") << "[SiStripBadStripReader::analyze] End Reading SiStripBadStrip" << std::endl;
0033 
0034   std::vector<uint32_t> detid;
0035   badStrip.getDetIds(detid);
0036 
0037   if (printdebug_)
0038     for (size_t id = 0; id < detid.size(); id++) {
0039       SiStripBadStrip::Range range = badStrip.getRange(detid[id]);
0040 
0041       for (int it = 0; it < range.second - range.first; it++) {
0042         unsigned int value = (*(range.first + it));
0043         edm::LogInfo("SiStripBadStripReader") << "detid " << detid[id] << " \t"
0044                                               << " firstBadStrip " << badStrip.decode(value).firstStrip << "\t "
0045                                               << " NconsecutiveBadStrips " << badStrip.decode(value).range << "\t "
0046                                               << " flag " << badStrip.decode(value).flag << "\t "
0047                                               << " packed integer " << std::hex << value << std::dec
0048                                               << "\t "
0049                                               //<< badStrip.getBadStrips(range)     << " \t"
0050                                               << std::endl;
0051       }
0052     }
0053 }
0054 
0055 #include "FWCore/PluginManager/interface/ModuleDef.h"
0056 #include "FWCore/Framework/interface/MakerMacros.h"
0057 DEFINE_FWK_MODULE(SiStripBadStripReader);