Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-12 02:41:34

0001 // Original author: Marco Rovere
0002 
0003 // user include files
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/LayerClusterToCaloParticleAssociator.h"
0015 #include "LCToCPAssociatorByEnergyScoreImpl.h"
0016 
0017 class LCToCPAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> {
0018 public:
0019   explicit LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &);
0020   ~LCToCPAssociatorByEnergyScoreProducer() 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 LCToCPAssociatorByEnergyScoreProducer::LCToCPAssociatorByEnergyScoreProducer(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   // Register the product
0039   produces<hgcal::LayerClusterToCaloParticleAssociator>();
0040 }
0041 
0042 LCToCPAssociatorByEnergyScoreProducer::~LCToCPAssociatorByEnergyScoreProducer() {}
0043 
0044 void LCToCPAssociatorByEnergyScoreProducer::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 =
0053       std::make_unique<LCToCPAssociatorByEnergyScoreImpl>(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap);
0054   auto toPut = std::make_unique<hgcal::LayerClusterToCaloParticleAssociator>(std::move(impl));
0055   iEvent.put(std::move(toPut));
0056 }
0057 
0058 void LCToCPAssociatorByEnergyScoreProducer::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("layerClusterAssociatorByEnergyScore", desc);
0064 }
0065 
0066 //define this as a plug-in
0067 DEFINE_FWK_MODULE(LCToCPAssociatorByEnergyScoreProducer);