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/TracksterToSimClusterAssociator.h"
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "DataFormats/HGCalReco/interface/Trackster.h"
0025
0026 #include "FWCore/Utilities/interface/EDGetToken.h"
0027
0028
0029
0030
0031
0032 class TSToSCAssociatorEDProducer : public edm::global::EDProducer<> {
0033 public:
0034 explicit TSToSCAssociatorEDProducer(const edm::ParameterSet &);
0035 ~TSToSCAssociatorEDProducer() override;
0036
0037 private:
0038 void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
0039
0040 edm::EDGetTokenT<SimClusterCollection> SCCollectionToken_;
0041 edm::EDGetTokenT<ticl::TracksterCollection> TSCollectionToken_;
0042 edm::EDGetTokenT<reco::CaloClusterCollection> LCCollectionToken_;
0043 edm::EDGetTokenT<ticl::TracksterToSimClusterAssociator> associatorToken_;
0044 };
0045
0046 TSToSCAssociatorEDProducer::TSToSCAssociatorEDProducer(const edm::ParameterSet &pset) {
0047 produces<ticl::SimToRecoCollectionTracksters>();
0048 produces<ticl::RecoToSimCollectionTracksters>();
0049
0050 SCCollectionToken_ = consumes<SimClusterCollection>(pset.getParameter<edm::InputTag>("label_scl"));
0051 TSCollectionToken_ = consumes<ticl::TracksterCollection>(pset.getParameter<edm::InputTag>("label_tst"));
0052 LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lcl"));
0053 associatorToken_ = consumes<ticl::TracksterToSimClusterAssociator>(pset.getParameter<edm::InputTag>("associator"));
0054 }
0055
0056 TSToSCAssociatorEDProducer::~TSToSCAssociatorEDProducer() {}
0057
0058
0059
0060
0061
0062
0063 void TSToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0064 using namespace edm;
0065
0066 edm::Handle<ticl::TracksterToSimClusterAssociator> theAssociator;
0067 iEvent.getByToken(associatorToken_, theAssociator);
0068
0069 Handle<SimClusterCollection> SCCollection;
0070 iEvent.getByToken(SCCollectionToken_, SCCollection);
0071
0072 Handle<ticl::TracksterCollection> TSCollection;
0073 iEvent.getByToken(TSCollectionToken_, TSCollection);
0074
0075 Handle<reco::CaloClusterCollection> LCCollection;
0076 iEvent.getByToken(LCCollectionToken_, LCCollection);
0077
0078
0079 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0080 ticl::RecoToSimCollectionTracksters recSimColl =
0081 theAssociator->associateRecoToSim(TSCollection, LCCollection, SCCollection);
0082
0083 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0084 ticl::SimToRecoCollectionTracksters simRecColl =
0085 theAssociator->associateSimToReco(TSCollection, LCCollection, SCCollection);
0086
0087 auto rts = std::make_unique<ticl::RecoToSimCollectionTracksters>(recSimColl);
0088 auto str = std::make_unique<ticl::SimToRecoCollectionTracksters>(simRecColl);
0089
0090 iEvent.put(std::move(rts));
0091 iEvent.put(std::move(str));
0092 }
0093
0094
0095 DEFINE_FWK_MODULE(TSToSCAssociatorEDProducer);