File indexing completed on 2023-03-17 11:23:55
0001
0002
0003
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/global/EDProducer.h"
0006
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/Utilities/interface/EDGetToken.h"
0012 #include "FWCore/Utilities/interface/ESGetToken.h"
0013
0014 #include "SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h"
0015 #include "TSToSimTSAssociatorByEnergyScoreImpl.h"
0016
0017 class TSToSimTSAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> {
0018 public:
0019 explicit TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &);
0020 ~TSToSimTSAssociatorByEnergyScoreProducer() override;
0021
0022 static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0023
0024 private:
0025 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0026 edm::EDGetTokenT<std::unordered_map<DetId, const HGCRecHit *>> hitMap_;
0027 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometry_;
0028 const bool hardScatterOnly_;
0029 std::shared_ptr<hgcal::RecHitTools> rhtools_;
0030 };
0031
0032 TSToSimTSAssociatorByEnergyScoreProducer::TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps)
0033 : hitMap_(consumes<std::unordered_map<DetId, const HGCRecHit *>>(ps.getParameter<edm::InputTag>("hitMapTag"))),
0034 caloGeometry_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
0035 hardScatterOnly_(ps.getParameter<bool>("hardScatterOnly")) {
0036 rhtools_.reset(new hgcal::RecHitTools());
0037
0038
0039 produces<hgcal::TracksterToSimTracksterAssociator>();
0040 }
0041
0042 TSToSimTSAssociatorByEnergyScoreProducer::~TSToSimTSAssociatorByEnergyScoreProducer() {}
0043
0044 void TSToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID,
0045 edm::Event &iEvent,
0046 const edm::EventSetup &es) const {
0047 edm::ESHandle<CaloGeometry> geom = es.getHandle(caloGeometry_);
0048 rhtools_->setGeometry(*geom);
0049
0050 const auto hitMap = &iEvent.get(hitMap_);
0051
0052 auto impl = std::make_unique<TSToSimTSAssociatorByEnergyScoreImpl>(
0053 iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap);
0054 auto toPut = std::make_unique<hgcal::TracksterToSimTracksterAssociator>(std::move(impl));
0055 iEvent.put(std::move(toPut));
0056 }
0057
0058 void TSToSimTSAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) {
0059 edm::ParameterSetDescription desc;
0060 desc.add<edm::InputTag>("hitMapTag", edm::InputTag("hgcalRecHitMapProducer"));
0061 desc.add<bool>("hardScatterOnly", true);
0062
0063 cfg.add("simTracksterAssociatorByEnergyScore", desc);
0064 }
0065
0066
0067 DEFINE_FWK_MODULE(TSToSimTSAssociatorByEnergyScoreProducer);