File indexing completed on 2024-07-02 00:53:17
0001 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/Framework/interface/LuminosityBlock.h"
0007
0008 #include "DataFormats/Luminosity/interface/PixelClusterCounts.h"
0009
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013
0014 namespace {
0015 struct Empty {};
0016 }
0017 class PixelClusterCountsAuditor : public edm::global::EDAnalyzer<edm::LuminosityBlockCache<Empty>> {
0018 public:
0019 PixelClusterCountsAuditor(edm::ParameterSet const& iPSet);
0020
0021 void analyze(edm::StreamID id, edm::Event const&, edm::EventSetup const&) const final {}
0022 std::shared_ptr<Empty> globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const final;
0023
0024 void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const final;
0025
0026 static void fillDescriptions(edm::ConfigurationDescriptions&);
0027
0028 private:
0029 std::vector<edm::EDGetTokenT<reco::PixelClusterCounts>> tokens_;
0030 };
0031
0032 PixelClusterCountsAuditor::PixelClusterCountsAuditor(edm::ParameterSet const& iPSet) {
0033 auto tags = iPSet.getUntrackedParameter<std::vector<edm::InputTag>>("counts");
0034 tokens_.reserve(tags.size());
0035 for (auto const& t : tags) {
0036 tokens_.emplace_back(consumes<reco::PixelClusterCounts, edm::InLumi>(t));
0037 }
0038 }
0039 void PixelClusterCountsAuditor::fillDescriptions(edm::ConfigurationDescriptions& iConfig) {
0040 edm::ParameterSetDescription desc;
0041 desc.addUntracked<std::vector<edm::InputTag>>("counts")->setComment(
0042 "Which PixelClusterCounts to retrieve from the LuminosityBlock");
0043 iConfig.addDefault(desc);
0044 }
0045
0046 std::shared_ptr<Empty> PixelClusterCountsAuditor::globalBeginLuminosityBlock(edm::LuminosityBlock const& iLumi,
0047 edm::EventSetup const&) const {
0048 for (auto t : tokens_) {
0049 auto h = iLumi.getHandle(t);
0050 auto prov = h.provenance();
0051 auto const& c = *h;
0052 edm::LogSystem("PixelClusterCountsAudit")
0053 .format("Branch: {}\n readCounts: {}\n readRocCounts: {}\n readEvents: {}\n readModID: {}\n readRocID: {}",
0054 prov->branchName(),
0055 c.readCounts().size(),
0056 c.readRocCounts().size(),
0057 c.readEvents().size(),
0058 c.readModID().size(),
0059 c.readRocID().size());
0060 }
0061 return {};
0062 }
0063
0064 void PixelClusterCountsAuditor::globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const {}
0065
0066 DEFINE_FWK_MODULE(PixelClusterCountsAuditor);