Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:23:53

0001 // Original author: Leonardo Cristella
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/LayerClusterToSimTracksterAssociator.h"
0015 #include "LCToSimTSAssociatorByEnergyScoreImpl.h"
0016 
0017 class LCToSimTSAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> {
0018 public:
0019   explicit LCToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &);
0020   ~LCToSimTSAssociatorByEnergyScoreProducer() 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::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometry_;
0027   std::shared_ptr<hgcal::RecHitTools> rhtools_;
0028 };
0029 
0030 LCToSimTSAssociatorByEnergyScoreProducer::LCToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps)
0031     : caloGeometry_(esConsumes<CaloGeometry, CaloGeometryRecord>()) {
0032   rhtools_.reset(new hgcal::RecHitTools());
0033 
0034   // Register the product
0035   produces<hgcal::LayerClusterToSimTracksterAssociator>();
0036 }
0037 
0038 LCToSimTSAssociatorByEnergyScoreProducer::~LCToSimTSAssociatorByEnergyScoreProducer() {}
0039 
0040 void LCToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID,
0041                                                        edm::Event &iEvent,
0042                                                        const edm::EventSetup &es) const {
0043   edm::ESHandle<CaloGeometry> geom = es.getHandle(caloGeometry_);
0044   rhtools_->setGeometry(*geom);
0045 
0046   auto impl = std::make_unique<LCToSimTSAssociatorByEnergyScoreImpl>(iEvent.productGetter());
0047   auto toPut = std::make_unique<hgcal::LayerClusterToSimTracksterAssociator>(std::move(impl));
0048   iEvent.put(std::move(toPut));
0049 }
0050 
0051 void LCToSimTSAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) {
0052   edm::ParameterSetDescription desc;
0053   cfg.add("layerClusterSimTracksterAssociatorByEnergyScore", desc);
0054 }
0055 
0056 //define this as a plug-in
0057 DEFINE_FWK_MODULE(LCToSimTSAssociatorByEnergyScoreProducer);