|
| 1 | +#include "FWCore/Framework/interface/global/EDAnalyzer.h" |
| 2 | +#include "FWCore/Framework/interface/Event.h" |
| 3 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 4 | +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" |
| 5 | +#include "FWCore/Utilities/interface/EDGetToken.h" |
| 6 | +#include "FWCore/Utilities/interface/InputTag.h" |
| 7 | +#include "FWCore/MessageLogger/interface/MessageLogger.h" |
| 8 | + |
| 9 | +#include "DataFormats/L1Trigger/interface/EtSum.h" |
| 10 | + |
| 11 | +#include <unordered_set> |
| 12 | +#include <vector> |
| 13 | + |
| 14 | +class L1TEtSumsPrinter : public edm::global::EDAnalyzer<> { |
| 15 | +public: |
| 16 | + explicit L1TEtSumsPrinter(const edm::ParameterSet&); |
| 17 | + |
| 18 | + static void fillDescriptions(edm::ConfigurationDescriptions&); |
| 19 | + |
| 20 | +private: |
| 21 | + void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override; |
| 22 | + |
| 23 | + edm::EDGetTokenT<l1t::EtSumBxCollection> const srcToken_; |
| 24 | + std::unordered_set<int> const etSumTypes_; |
| 25 | +}; |
| 26 | + |
| 27 | +L1TEtSumsPrinter::L1TEtSumsPrinter(const edm::ParameterSet& iConfig) |
| 28 | + : srcToken_{consumes(iConfig.getParameter<edm::InputTag>("src"))}, etSumTypes_{[](std::vector<int> const& vInts) { |
| 29 | + return std::unordered_set<int>{vInts.begin(), vInts.end()}; |
| 30 | + }(iConfig.getParameter<std::vector<int>>("etSumTypes"))} {} |
| 31 | + |
| 32 | +void L1TEtSumsPrinter::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const { |
| 33 | + auto const& etSums = iEvent.get(srcToken_); |
| 34 | + auto const& moduleLabel = moduleDescription().moduleLabel(); |
| 35 | + for (int ibx = etSums.getFirstBX(); ibx <= etSums.getLastBX(); ++ibx) { |
| 36 | + auto const size = etSums.size(ibx); |
| 37 | + for (uint idx = 0; idx < size; ++idx) { |
| 38 | + auto const& etSum = etSums.at(ibx, idx); |
| 39 | + if ((not etSumTypes_.empty()) and etSumTypes_.find(etSum.getType()) == etSumTypes_.end()) { |
| 40 | + continue; |
| 41 | + } |
| 42 | + |
| 43 | + edm::LogPrint("L1TEtSumsPrinter") << "[" << moduleLabel << "] etSums[" << ibx << "][" << idx |
| 44 | + << "] (type, hwPt) = (" << etSum.getType() << ", " << etSum.hwPt() << ")"; |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +void L1TEtSumsPrinter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 50 | + edm::ParameterSetDescription desc; |
| 51 | + desc.add<edm::InputTag>("src", edm::InputTag("gtStage2Digis:EtSum")) |
| 52 | + ->setComment("Input collection of type l1t::EtSumBxCollection"); |
| 53 | + desc.add<std::vector<int>>("etSumTypes", {}) |
| 54 | + ->setComment("If not empty, only the specified l1t::EtSumType values are considered"); |
| 55 | + descriptions.add("l1tEtSumsPrinter", desc); |
| 56 | +} |
| 57 | + |
| 58 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 59 | +DEFINE_FWK_MODULE(L1TEtSumsPrinter); |
0 commit comments