Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-12 23:19:29

0001 // system include files
0002 #include <memory>
0003 #include <string>
0004 
0005 // user include files
0006 #include "FWCore/Framework/interface/global/EDProducer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013 
0014 #include "Geometry/MTDCommonData/interface/MTDTopologyMode.h"
0015 #include "Geometry/Records/interface/MTDDigiGeometryRecord.h"
0016 #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
0017 #include "Geometry/Records/interface/MTDTopologyRcd.h"
0018 #include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
0019 
0020 #include "MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl.h"
0021 
0022 //
0023 // Class declaration
0024 //
0025 
0026 class MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer : public edm::global::EDProducer<> {
0027 public:
0028   explicit MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer(const edm::ParameterSet &);
0029   ~MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer() override;
0030 
0031   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0032 
0033 private:
0034   void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0035   const double energyCut_;
0036   const double timeCut_;
0037   edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> geomToken_;
0038   edm::ESGetToken<MTDTopology, MTDTopologyRcd> topoToken_;
0039 };
0040 
0041 MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer::MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer(
0042     const edm::ParameterSet &ps)
0043     : energyCut_(ps.getParameter<double>("energyCut")), timeCut_(ps.getParameter<double>("timeCut")) {
0044   geomToken_ = esConsumes<MTDGeometry, MTDDigiGeometryRecord>();
0045   topoToken_ = esConsumes<MTDTopology, MTDTopologyRcd>();
0046 
0047   // Register the product
0048   produces<reco::MtdRecoClusterToSimLayerClusterAssociator>();
0049 }
0050 
0051 MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer::~MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer() {}
0052 
0053 void MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer::produce(edm::StreamID,
0054                                                                       edm::Event &iEvent,
0055                                                                       const edm::EventSetup &es) const {
0056   auto geometryHandle = es.getTransientHandle(geomToken_);
0057   const MTDGeometry *geom = geometryHandle.product();
0058 
0059   auto topologyHandle = es.getTransientHandle(topoToken_);
0060   const MTDTopology *topology = topologyHandle.product();
0061 
0062   mtd::MTDGeomUtil geomTools_;
0063   geomTools_.setGeometry(geom);
0064   geomTools_.setTopology(topology);
0065 
0066   auto impl = std::make_unique<MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl>(
0067       iEvent.productGetter(), energyCut_, timeCut_, geomTools_);
0068   auto toPut = std::make_unique<reco::MtdRecoClusterToSimLayerClusterAssociator>(std::move(impl));
0069   iEvent.put(std::move(toPut));
0070 }
0071 
0072 void MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) {
0073   edm::ParameterSetDescription desc;
0074   desc.add<double>("energyCut", 5.);
0075   desc.add<double>("timeCut", 10.);
0076 
0077   cfg.add("mtdRecoClusterToSimLayerClusterAssociatorByHits", desc);
0078 }
0079 
0080 //define this as a plug-in
0081 DEFINE_FWK_MODULE(MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer);