File indexing completed on 2024-05-29 23:13:10
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/TracksterToSimTracksterHitLCAssociator.h"
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "DataFormats/HGCalReco/interface/Trackster.h"
0025 #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h"
0026
0027 #include "FWCore/Utilities/interface/EDGetToken.h"
0028
0029 class TSToSimTSHitLCAssociatorEDProducer : public edm::global::EDProducer<> {
0030 public:
0031 explicit TSToSimTSHitLCAssociatorEDProducer(const edm::ParameterSet &);
0032 ~TSToSimTSHitLCAssociatorEDProducer() override;
0033
0034 private:
0035 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0036
0037 edm::EDGetTokenT<ticl::TracksterCollection> TSCollectionToken_;
0038 edm::EDGetTokenT<ticl::TracksterCollection> SimTSCollectionToken_;
0039 edm::EDGetTokenT<ticl::TracksterCollection> SimTSFromCPCollectionToken_;
0040 edm::EDGetTokenT<reco::CaloClusterCollection> LCCollectionToken_;
0041 edm::EDGetTokenT<SimClusterCollection> SCCollectionToken_;
0042 edm::EDGetTokenT<CaloParticleCollection> CPCollectionToken_;
0043 edm::EDGetTokenT<std::map<uint, std::vector<uint>>> simTrackstersMap_;
0044 ticl::validationType valType_;
0045 edm::EDGetTokenT<ticl::TracksterToSimTracksterHitLCAssociator> associatorToken_;
0046 };
0047
0048 TSToSimTSHitLCAssociatorEDProducer::TSToSimTSHitLCAssociatorEDProducer(const edm::ParameterSet &pset) {
0049 produces<ticl::SimToRecoCollectionSimTracksters>("simToReco");
0050 produces<ticl::RecoToSimCollectionSimTracksters>("recoToSim");
0051
0052 TSCollectionToken_ = consumes<ticl::TracksterCollection>(pset.getParameter<edm::InputTag>("label_tst"));
0053 SimTSCollectionToken_ = consumes<ticl::TracksterCollection>(pset.getParameter<edm::InputTag>("label_simTst"));
0054 LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lcl"));
0055 SCCollectionToken_ = consumes<SimClusterCollection>(pset.getParameter<edm::InputTag>("label_scl"));
0056 CPCollectionToken_ = consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"));
0057 associatorToken_ =
0058 consumes<ticl::TracksterToSimTracksterHitLCAssociator>(pset.getParameter<edm::InputTag>("associator"));
0059 }
0060
0061 TSToSimTSHitLCAssociatorEDProducer::~TSToSimTSHitLCAssociatorEDProducer() {}
0062
0063 void TSToSimTSHitLCAssociatorEDProducer::produce(edm::StreamID,
0064 edm::Event &iEvent,
0065 const edm::EventSetup &iSetup) const {
0066 using namespace edm;
0067
0068 edm::Handle<ticl::TracksterToSimTracksterHitLCAssociator> theAssociator;
0069 iEvent.getByToken(associatorToken_, theAssociator);
0070
0071 Handle<ticl::TracksterCollection> TSCollection;
0072 iEvent.getByToken(TSCollectionToken_, TSCollection);
0073
0074 Handle<ticl::TracksterCollection> SimTSCollection;
0075 iEvent.getByToken(SimTSCollectionToken_, SimTSCollection);
0076
0077 Handle<reco::CaloClusterCollection> LCCollection;
0078 iEvent.getByToken(LCCollectionToken_, LCCollection);
0079
0080 Handle<SimClusterCollection> SCCollection;
0081 iEvent.getByToken(SCCollectionToken_, SCCollection);
0082
0083 Handle<CaloParticleCollection> CPCollection;
0084 iEvent.getByToken(CPCollectionToken_, CPCollection);
0085
0086
0087 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0088
0089 ticl::RecoToSimCollectionSimTracksters recSimColl =
0090 theAssociator->associateRecoToSim(TSCollection, LCCollection, SCCollection, CPCollection, SimTSCollection);
0091
0092 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0093 ticl::SimToRecoCollectionSimTracksters simRecColl =
0094 theAssociator->associateSimToReco(TSCollection, LCCollection, SCCollection, CPCollection, SimTSCollection);
0095
0096 auto rts = std::make_unique<ticl::RecoToSimCollectionSimTracksters>(recSimColl);
0097 auto str = std::make_unique<ticl::SimToRecoCollectionSimTracksters>(simRecColl);
0098
0099 iEvent.put(std::move(rts), "recoToSim");
0100 iEvent.put(std::move(str), "simToReco");
0101 }
0102
0103 DEFINE_FWK_MODULE(TSToSimTSHitLCAssociatorEDProducer);