|
| 1 | +// Original author: Leonardo Cristella |
| 2 | + |
| 3 | +// user include files |
| 4 | +#include "FWCore/Framework/interface/Frameworkfwd.h" |
| 5 | +#include "FWCore/Framework/interface/global/EDProducer.h" |
| 6 | + |
| 7 | +#include "FWCore/Framework/interface/Event.h" |
| 8 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 9 | + |
| 10 | +#include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 11 | +#include "FWCore/Utilities/interface/EDGetToken.h" |
| 12 | +#include "FWCore/Utilities/interface/ESGetToken.h" |
| 13 | + |
| 14 | +#include "SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h" |
| 15 | +#include "TSToSimTSAssociatorByEnergyScoreImpl.h" |
| 16 | + |
| 17 | +class TSToSimTSAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { |
| 18 | +public: |
| 19 | + explicit TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &); |
| 20 | + ~TSToSimTSAssociatorByEnergyScoreProducer() override; |
| 21 | + |
| 22 | + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); |
| 23 | + |
| 24 | +private: |
| 25 | + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; |
| 26 | + edm::EDGetTokenT<std::unordered_map<DetId, const HGCRecHit *>> hitMap_; |
| 27 | + edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometry_; |
| 28 | + const bool hardScatterOnly_; |
| 29 | + std::shared_ptr<hgcal::RecHitTools> rhtools_; |
| 30 | +}; |
| 31 | + |
| 32 | +TSToSimTSAssociatorByEnergyScoreProducer::TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) |
| 33 | + : hitMap_(consumes<std::unordered_map<DetId, const HGCRecHit *>>(ps.getParameter<edm::InputTag>("hitMapTag"))), |
| 34 | + caloGeometry_(esConsumes<CaloGeometry, CaloGeometryRecord>()), |
| 35 | + hardScatterOnly_(ps.getParameter<bool>("hardScatterOnly")) { |
| 36 | + rhtools_.reset(new hgcal::RecHitTools()); |
| 37 | + |
| 38 | + // Register the product |
| 39 | + produces<hgcal::TracksterToSimTracksterAssociator>(); |
| 40 | +} |
| 41 | + |
| 42 | +TSToSimTSAssociatorByEnergyScoreProducer::~TSToSimTSAssociatorByEnergyScoreProducer() {} |
| 43 | + |
| 44 | +void TSToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID, |
| 45 | + edm::Event &iEvent, |
| 46 | + const edm::EventSetup &es) const { |
| 47 | + edm::ESHandle<CaloGeometry> geom = es.getHandle(caloGeometry_); |
| 48 | + rhtools_->setGeometry(*geom); |
| 49 | + |
| 50 | + const auto hitMap = &iEvent.get(hitMap_); |
| 51 | + |
| 52 | + auto impl = std::make_unique<TSToSimTSAssociatorByEnergyScoreImpl>( |
| 53 | + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); |
| 54 | + auto toPut = std::make_unique<hgcal::TracksterToSimTracksterAssociator>(std::move(impl)); |
| 55 | + iEvent.put(std::move(toPut)); |
| 56 | +} |
| 57 | + |
| 58 | +void TSToSimTSAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { |
| 59 | + edm::ParameterSetDescription desc; |
| 60 | + desc.add<edm::InputTag>("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); |
| 61 | + desc.add<bool>("hardScatterOnly", true); |
| 62 | + |
| 63 | + cfg.add("simTracksterAssociatorByEnergyScore", desc); |
| 64 | +} |
| 65 | + |
| 66 | +//define this as a plug-in |
| 67 | +DEFINE_FWK_MODULE(TSToSimTSAssociatorByEnergyScoreProducer); |
0 commit comments