Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-06 03:10:52

0001 // user include files
0002 #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerCondDataRecords.h"
0003 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0004 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/ServiceRegistry/interface/Service.h"
0013 
0014 //
0015 //
0016 // class decleration
0017 //
0018 class SiPhase2BadStripChannelReader : public edm::global::EDAnalyzer<> {
0019 public:
0020   explicit SiPhase2BadStripChannelReader(const edm::ParameterSet&);
0021   ~SiPhase2BadStripChannelReader() override = default;
0022   void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0023 
0024   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025 
0026 private:
0027   const bool printverbose_;
0028   const int printdebug_;
0029   const std::string label_;
0030   const edm::ESGetToken<SiStripBadStrip, SiPhase2OuterTrackerBadStripRcd> badStripToken_;
0031 };
0032 
0033 SiPhase2BadStripChannelReader::SiPhase2BadStripChannelReader(const edm::ParameterSet& iConfig)
0034     : printverbose_(iConfig.getUntrackedParameter<bool>("printVerbose", false)),
0035       printdebug_(iConfig.getUntrackedParameter<int>("printDebug", 1)),
0036       label_(iConfig.getUntrackedParameter<std::string>("label", "")),
0037       badStripToken_(esConsumes(edm::ESInputTag{"", label_})) {}
0038 
0039 void SiPhase2BadStripChannelReader::analyze(edm::StreamID,
0040                                             edm::Event const& iEvent,
0041                                             edm::EventSetup const& iSetup) const {
0042   const auto& payload = &iSetup.getData(badStripToken_);
0043 
0044   edm::LogInfo("SiPhase2BadStripChannelReader")
0045       << "[SiPhase2BadStripChannelReader::analyze] End Reading SiStriBadStrip with label " << label_ << std::endl;
0046 
0047   const TrackerTopology* ttopo = nullptr;
0048 
0049   std::stringstream ss;
0050   if (printverbose_) {
0051     payload->printDebug(ss, ttopo);
0052   }
0053 
0054   std::vector<uint32_t> detIds;
0055   payload->getDetIds(detIds);
0056 
0057   int countMessages{0};
0058   for (const auto& d : detIds) {
0059     SiStripBadStrip::Range range = payload->getRange(d);
0060     for (std::vector<unsigned int>::const_iterator badChannel = range.first; badChannel != range.second; ++badChannel) {
0061       const auto& firstStrip = payload->decodePhase2(*badChannel).firstStrip;
0062       const auto& range = payload->decodePhase2(*badChannel).range;
0063 
0064       if (printverbose_) {
0065         ss << "DetId= " << d << " Channel=" << payload->decodePhase2(*badChannel).firstStrip << ":"
0066            << payload->decodePhase2(*badChannel).range << std::endl;
0067       }
0068 
0069       if (countMessages < printdebug_) {
0070         for (unsigned int index = 0; index < range; index++) {
0071           std::pair<int, int> badStrip = Phase2TrackerDigi::channelToPixel(firstStrip + index);
0072           ss << "DetId= " << d << " Channel= " << firstStrip + index << " -> strip (row,col)=(" << badStrip.first << ","
0073              << badStrip.second << ")" << std::endl;
0074         }
0075       }  // if doesn't exceed the maximum printout level
0076     }    // loop over the range
0077     countMessages++;
0078   }  // loop over the detids
0079 
0080   edm::LogInfo("SiPhase2BadStripChannelReader") << ss.str() << std::endl;
0081 }
0082 
0083 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0084 void SiPhase2BadStripChannelReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0085   edm::ParameterSetDescription desc;
0086   desc.setComment("Module to read SiStripBadStrip Payloads through SiPhase2OuterTrackerBadStripRcd");
0087   desc.addUntracked<bool>("printVerbose", false)->setComment("if active, very verbose output");
0088   desc.addUntracked<int>("printDebug", 1)->setComment("tunes the amount of debug level print-outs");
0089   desc.addUntracked<std::string>("label", "")->setComment("label from which to read the payload");
0090   descriptions.addWithDefaultLabel(desc);
0091 }
0092 
0093 //define this as a plug-in
0094 DEFINE_FWK_MODULE(SiPhase2BadStripChannelReader);