File indexing completed on 2021-05-12 02:41:35
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/LayerClusterToSimClusterAssociator.h"
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0025
0026 #include "FWCore/Utilities/interface/EDGetToken.h"
0027
0028
0029
0030
0031
0032 class LCToSCAssociatorEDProducer : public edm::global::EDProducer<> {
0033 public:
0034 explicit LCToSCAssociatorEDProducer(const edm::ParameterSet &);
0035 ~LCToSCAssociatorEDProducer() 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<reco::CaloClusterCollection> LCCollectionToken_;
0042 edm::EDGetTokenT<hgcal::LayerClusterToSimClusterAssociator> associatorToken_;
0043 };
0044
0045 LCToSCAssociatorEDProducer::LCToSCAssociatorEDProducer(const edm::ParameterSet &pset) {
0046 produces<hgcal::SimToRecoCollectionWithSimClusters>();
0047 produces<hgcal::RecoToSimCollectionWithSimClusters>();
0048
0049 SCCollectionToken_ = consumes<SimClusterCollection>(pset.getParameter<edm::InputTag>("label_scl"));
0050 LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lcl"));
0051 associatorToken_ =
0052 consumes<hgcal::LayerClusterToSimClusterAssociator>(pset.getParameter<edm::InputTag>("associator"));
0053 }
0054
0055 LCToSCAssociatorEDProducer::~LCToSCAssociatorEDProducer() {}
0056
0057
0058
0059
0060
0061
0062 void LCToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0063 using namespace edm;
0064
0065 edm::Handle<hgcal::LayerClusterToSimClusterAssociator> theAssociator;
0066 iEvent.getByToken(associatorToken_, theAssociator);
0067
0068 Handle<SimClusterCollection> SCCollection;
0069 iEvent.getByToken(SCCollectionToken_, SCCollection);
0070
0071 Handle<reco::CaloClusterCollection> LCCollection;
0072 iEvent.getByToken(LCCollectionToken_, LCCollection);
0073
0074
0075 LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0076 hgcal::RecoToSimCollectionWithSimClusters recSimColl = theAssociator->associateRecoToSim(LCCollection, SCCollection);
0077
0078 LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0079 hgcal::SimToRecoCollectionWithSimClusters simRecColl = theAssociator->associateSimToReco(LCCollection, SCCollection);
0080
0081 auto rts = std::make_unique<hgcal::RecoToSimCollectionWithSimClusters>(recSimColl);
0082 auto str = std::make_unique<hgcal::SimToRecoCollectionWithSimClusters>(simRecColl);
0083
0084 iEvent.put(std::move(rts));
0085 iEvent.put(std::move(str));
0086 }
0087
0088
0089 DEFINE_FWK_MODULE(LCToSCAssociatorEDProducer);