File indexing completed on 2021-05-12 02:41:34
0001
0002
0003
0004
0005
0006
0007
0008 #include <memory>
0009 #include <string>
0010
0011
0012 #include "FWCore/Framework/interface/global/EDProducer.h"
0013
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020
0021 #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h"
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h"
0025 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0026
0027 #include "FWCore/Utilities/interface/EDGetToken.h"
0028
0029
0030
0031
0032
0033 class LCToCPAssociatorEDProducer : public edm::global::EDProducer<> {
0034 public:
0035 explicit LCToCPAssociatorEDProducer(const edm::ParameterSet &);
0036 ~LCToCPAssociatorEDProducer() override;
0037
0038 private:
0039 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0040
0041 edm::EDGetTokenT<CaloParticleCollection> CPCollectionToken_;
0042 edm::EDGetTokenT<reco::CaloClusterCollection> LCCollectionToken_;
0043 edm::EDGetTokenT<hgcal::LayerClusterToCaloParticleAssociator> associatorToken_;
0044 };
0045
0046 LCToCPAssociatorEDProducer::LCToCPAssociatorEDProducer(const edm::ParameterSet &pset) {
0047 produces<hgcal::SimToRecoCollection>();
0048 produces<hgcal::RecoToSimCollection>();
0049
0050 CPCollectionToken_ = consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"));
0051 LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lc"));
0052 associatorToken_ =
0053 consumes<hgcal::LayerClusterToCaloParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
0054 }
0055
0056 LCToCPAssociatorEDProducer::~LCToCPAssociatorEDProducer() {}
0057
0058
0059
0060
0061
0062
0063 void LCToCPAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0064 using namespace edm;
0065
0066 edm::Handle<hgcal::LayerClusterToCaloParticleAssociator> theAssociator;
0067 iEvent.getByToken(associatorToken_, theAssociator);
0068
0069 Handle<CaloParticleCollection> CPCollection;
0070 iEvent.getByToken(CPCollectionToken_, CPCollection);
0071
0072 Handle<reco::CaloClusterCollection> LCCollection;
0073 iEvent.getByToken(LCCollectionToken_, LCCollection);
0074
0075
0076 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0077 hgcal::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(LCCollection, CPCollection);
0078
0079 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0080 hgcal::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(LCCollection, CPCollection);
0081
0082 auto rts = std::make_unique<hgcal::RecoToSimCollection>(recSimColl);
0083 auto str = std::make_unique<hgcal::SimToRecoCollection>(simRecColl);
0084
0085 iEvent.put(std::move(rts));
0086 iEvent.put(std::move(str));
0087 }
0088
0089
0090 DEFINE_FWK_MODULE(LCToCPAssociatorEDProducer);