File indexing completed on 2024-04-06 12:20:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/global/EDProducer.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/Utilities/interface/EDGetToken.h"
0025 #include "FWCore/Utilities/interface/EDPutToken.h"
0026 #include "FWCore/Utilities/interface/InputTag.h"
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028
0029 #include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
0030 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0031 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0032
0033 #include "DataFormats/L1Trigger/interface/BXVector.h"
0034
0035 #include "DataFormats/L1TCalorimeter/interface/CaloEmCand.h"
0036 #include "DataFormats/L1TCalorimeter/interface/CaloRegion.h"
0037
0038 #include "DataFormats/Math/interface/LorentzVector.h"
0039
0040 #include <vector>
0041
0042 namespace l1t {
0043
0044 class L1TCaloRCTToUpgradeConverter : public edm::global::EDProducer<> {
0045 public:
0046 explicit L1TCaloRCTToUpgradeConverter(const edm::ParameterSet& ps);
0047
0048 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0049
0050 private:
0051 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0052
0053
0054
0055 edm::EDGetTokenT<L1CaloRegionCollection> const rgnToken_;
0056 edm::EDGetTokenT<L1CaloEmCollection> const emToken_;
0057
0058 edm::EDPutTokenT<CaloRegionBxCollection> const rgnPutToken_;
0059 edm::EDPutTokenT<CaloEmCandBxCollection> const emPutToken_;
0060 };
0061
0062 }
0063
0064 using namespace l1t;
0065
0066 L1TCaloRCTToUpgradeConverter::L1TCaloRCTToUpgradeConverter(const edm::ParameterSet& ps)
0067 : rgnToken_{consumes<L1CaloRegionCollection>(ps.getParameter<edm::InputTag>("regionTag"))},
0068 emToken_{consumes<L1CaloEmCollection>(ps.getParameter<edm::InputTag>("emTag"))},
0069 rgnPutToken_{produces<CaloRegionBxCollection>()},
0070 emPutToken_{produces<CaloEmCandBxCollection>()} {}
0071
0072
0073 void L1TCaloRCTToUpgradeConverter::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0074
0075
0076
0077 BXVector<CaloEmCand> emcands;
0078 BXVector<CaloRegion> regions;
0079
0080
0081 auto const& ems = iEvent.get(emToken_);
0082 auto const& rgns = iEvent.get(rgnToken_);
0083
0084
0085 int firstBx = 0;
0086 int lastBx = 0;
0087 for (auto const& em : ems) {
0088 int bx = em.bx();
0089 if (bx < firstBx)
0090 firstBx = bx;
0091 if (bx > lastBx)
0092 lastBx = bx;
0093 }
0094
0095 emcands.setBXRange(firstBx, lastBx);
0096 regions.setBXRange(firstBx, lastBx);
0097
0098 const ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > p4(0, 0, 0, 0);
0099
0100
0101 for (auto const& em : ems) {
0102
0103
0104
0105
0106
0107
0108
0109 CaloEmCand EmCand(p4, (int)em.rank(), (int)em.regionId().ieta(), (int)em.regionId().iphi(), (int)em.index());
0110
0111 EmCand.setHwIso((int)em.isolated());
0112
0113
0114
0115 emcands.push_back(em.bx(), EmCand);
0116 }
0117
0118
0119 for (auto const& rgn : rgns) {
0120
0121
0122
0123
0124
0125
0126 bool tauVeto = rgn.fineGrain();
0127 int hwQual = (int)tauVeto;
0128
0129
0130
0131 CaloRegion region(p4,
0132 0.,
0133 0.,
0134 (int)rgn.et(),
0135 (int)rgn.id().ieta(),
0136 (int)rgn.id().iphi(),
0137 hwQual,
0138 0,
0139 0);
0140
0141
0142 regions.push_back(rgn.bx(), region);
0143 }
0144
0145 iEvent.emplace(emPutToken_, std::move(emcands));
0146 iEvent.emplace(rgnPutToken_, std::move(regions));
0147 }
0148
0149
0150 void L1TCaloRCTToUpgradeConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0151 edm::ParameterSetDescription desc;
0152 desc.add<edm::InputTag>("regionTag");
0153 desc.add<edm::InputTag>("emTag");
0154 descriptions.addDefault(desc);
0155 }
0156
0157
0158 DEFINE_FWK_MODULE(L1TCaloRCTToUpgradeConverter);