File indexing completed on 2024-05-29 23:13:08
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 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0027 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
0028
0029 #include "FWCore/Utilities/interface/EDGetToken.h"
0030
0031
0032
0033
0034
0035 class LCToCPAssociatorEDProducer : public edm::global::EDProducer<> {
0036 public:
0037 explicit LCToCPAssociatorEDProducer(const edm::ParameterSet &);
0038 ~LCToCPAssociatorEDProducer() override;
0039
0040 private:
0041 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0042
0043 edm::EDGetTokenT<CaloParticleCollection> CPCollectionToken_;
0044 edm::EDGetTokenT<reco::CaloClusterCollection> LCCollectionToken_;
0045 edm::EDGetTokenT<ticl::LayerClusterToCaloParticleAssociator> associatorToken_;
0046 };
0047
0048 LCToCPAssociatorEDProducer::LCToCPAssociatorEDProducer(const edm::ParameterSet &pset) {
0049 produces<ticl::SimToRecoCollection>();
0050 produces<ticl::RecoToSimCollection>();
0051
0052 CPCollectionToken_ = consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"));
0053 LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lc"));
0054 associatorToken_ =
0055 consumes<ticl::LayerClusterToCaloParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
0056 }
0057
0058 LCToCPAssociatorEDProducer::~LCToCPAssociatorEDProducer() {}
0059
0060
0061
0062
0063
0064
0065 void LCToCPAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0066 using namespace edm;
0067
0068 edm::Handle<ticl::LayerClusterToCaloParticleAssociator> theAssociator;
0069 iEvent.getByToken(associatorToken_, theAssociator);
0070
0071 Handle<CaloParticleCollection> CPCollection;
0072 iEvent.getByToken(CPCollectionToken_, CPCollection);
0073
0074 Handle<reco::CaloClusterCollection> LCCollection;
0075 iEvent.getByToken(LCCollectionToken_, LCCollection);
0076
0077
0078 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0079 ticl::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(LCCollection, CPCollection);
0080
0081 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0082 ticl::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(LCCollection, CPCollection);
0083
0084 auto rts = std::make_unique<ticl::RecoToSimCollection>(recSimColl);
0085 auto str = std::make_unique<ticl::SimToRecoCollection>(simRecColl);
0086
0087 iEvent.put(std::move(rts));
0088 iEvent.put(std::move(str));
0089 }
0090
0091
0092 DEFINE_FWK_MODULE(LCToCPAssociatorEDProducer);