File indexing completed on 2024-05-29 23:13:09
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/LayerClusterToSimTracksterAssociator.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 LCToSimTSAssociatorEDProducer : public edm::global::EDProducer<> {
0034 public:
0035 explicit LCToSimTSAssociatorEDProducer(const edm::ParameterSet &);
0036 ~LCToSimTSAssociatorEDProducer() override;
0037
0038 private:
0039 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0040
0041 edm::EDGetTokenT<reco::CaloClusterCollection> LCCollectionToken_;
0042 edm::EDGetTokenT<ticl::TracksterCollection> SimTSCollectionToken_;
0043 edm::EDGetTokenT<ticl::LayerClusterToSimTracksterAssociator> associatorToken_;
0044
0045 edm::EDGetTokenT<CaloParticleCollection> CPCollectionToken_;
0046 edm::InputTag associatorCP_;
0047 edm::EDGetTokenT<ticl::RecoToSimCollection> associationMapLCToCPToken_;
0048 edm::EDGetTokenT<ticl::SimToRecoCollection> associationMapCPToLCToken_;
0049
0050 edm::EDGetTokenT<SimClusterCollection> SCCollectionToken_;
0051 edm::InputTag associatorSC_;
0052 edm::EDGetTokenT<ticl::RecoToSimCollectionWithSimClusters> associationMapLCToSCToken_;
0053 edm::EDGetTokenT<ticl::SimToRecoCollectionWithSimClusters> associationMapSCToLCToken_;
0054 };
0055
0056 LCToSimTSAssociatorEDProducer::LCToSimTSAssociatorEDProducer(const edm::ParameterSet &pset)
0057 : LCCollectionToken_(consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lc"))),
0058 SimTSCollectionToken_(consumes<ticl::TracksterCollection>(pset.getParameter<edm::InputTag>("label_simTst"))),
0059 associatorToken_(
0060 consumes<ticl::LayerClusterToSimTracksterAssociator>(pset.getParameter<edm::InputTag>("associator"))),
0061 CPCollectionToken_(consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"))),
0062 associatorCP_(pset.getParameter<edm::InputTag>("associator_cp")),
0063 associationMapLCToCPToken_(consumes<ticl::RecoToSimCollection>(associatorCP_)),
0064 associationMapCPToLCToken_(consumes<ticl::SimToRecoCollection>(associatorCP_)),
0065 SCCollectionToken_(consumes<SimClusterCollection>(pset.getParameter<edm::InputTag>("label_scl"))),
0066 associatorSC_(pset.getParameter<edm::InputTag>("associator_sc")),
0067 associationMapLCToSCToken_(consumes<ticl::RecoToSimCollectionWithSimClusters>(associatorSC_)),
0068 associationMapSCToLCToken_(consumes<ticl::SimToRecoCollectionWithSimClusters>(associatorSC_)) {
0069 produces<ticl::SimTracksterToRecoCollection>();
0070 produces<ticl::RecoToSimTracksterCollection>();
0071 }
0072
0073 LCToSimTSAssociatorEDProducer::~LCToSimTSAssociatorEDProducer() {}
0074
0075
0076
0077
0078
0079
0080 void LCToSimTSAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0081 using namespace edm;
0082
0083 edm::Handle<ticl::LayerClusterToSimTracksterAssociator> theAssociator;
0084 iEvent.getByToken(associatorToken_, theAssociator);
0085
0086 Handle<reco::CaloClusterCollection> LCCollection;
0087 iEvent.getByToken(LCCollectionToken_, LCCollection);
0088
0089 Handle<ticl::TracksterCollection> SimTSCollection;
0090 iEvent.getByToken(SimTSCollectionToken_, SimTSCollection);
0091
0092 Handle<CaloParticleCollection> CPCollection;
0093 iEvent.getByToken(CPCollectionToken_, CPCollection);
0094 const auto &LCToCPsColl = iEvent.get(associationMapLCToCPToken_);
0095 const auto &CPToLCsColl = iEvent.get(associationMapCPToLCToken_);
0096
0097 Handle<SimClusterCollection> SCCollection;
0098 iEvent.getByToken(SCCollectionToken_, SCCollection);
0099 const auto &LCToSCsColl = iEvent.get(associationMapLCToSCToken_);
0100 const auto &SCToLCsColl = iEvent.get(associationMapSCToLCToken_);
0101
0102
0103 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0104 ticl::RecoToSimTracksterCollection recSimColl = theAssociator->associateRecoToSim(
0105 LCCollection, SimTSCollection, CPCollection, LCToCPsColl, SCCollection, LCToSCsColl);
0106
0107 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0108 ticl::SimTracksterToRecoCollection simRecColl = theAssociator->associateSimToReco(
0109 LCCollection, SimTSCollection, CPCollection, CPToLCsColl, SCCollection, SCToLCsColl);
0110
0111 auto rts = std::make_unique<ticl::RecoToSimTracksterCollection>(recSimColl);
0112 auto str = std::make_unique<ticl::SimTracksterToRecoCollection>(simRecColl);
0113
0114 iEvent.put(std::move(rts));
0115 iEvent.put(std::move(str));
0116 }
0117
0118
0119 DEFINE_FWK_MODULE(LCToSimTSAssociatorEDProducer);