Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-29 23:13:09

0001 //
0002 // Original Author:  Leonardo Cristella
0003 //         Created:  Thu Dec  3 10:52:11 CET 2020
0004 //
0005 //
0006 
0007 // system include files
0008 #include <memory>
0009 #include <string>
0010 
0011 // user include files
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 // class decleration
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<ticl::LayerClusterToSimClusterAssociator> associatorToken_;
0043 };
0044 
0045 LCToSCAssociatorEDProducer::LCToSCAssociatorEDProducer(const edm::ParameterSet &pset) {
0046   produces<ticl::SimToRecoCollectionWithSimClusters>();
0047   produces<ticl::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_ = consumes<ticl::LayerClusterToSimClusterAssociator>(pset.getParameter<edm::InputTag>("associator"));
0052 }
0053 
0054 LCToSCAssociatorEDProducer::~LCToSCAssociatorEDProducer() {}
0055 
0056 //
0057 // member functions
0058 //
0059 
0060 // ------------ method called to produce the data  ------------
0061 void LCToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0062   using namespace edm;
0063 
0064   edm::Handle<ticl::LayerClusterToSimClusterAssociator> theAssociator;
0065   iEvent.getByToken(associatorToken_, theAssociator);
0066 
0067   Handle<SimClusterCollection> SCCollection;
0068   iEvent.getByToken(SCCollectionToken_, SCCollection);
0069 
0070   Handle<reco::CaloClusterCollection> LCCollection;
0071   iEvent.getByToken(LCCollectionToken_, LCCollection);
0072 
0073   // associate LC and SC
0074   LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
0075   ticl::RecoToSimCollectionWithSimClusters recSimColl = theAssociator->associateRecoToSim(LCCollection, SCCollection);
0076 
0077   LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
0078   ticl::SimToRecoCollectionWithSimClusters simRecColl = theAssociator->associateSimToReco(LCCollection, SCCollection);
0079 
0080   auto rts = std::make_unique<ticl::RecoToSimCollectionWithSimClusters>(recSimColl);
0081   auto str = std::make_unique<ticl::SimToRecoCollectionWithSimClusters>(simRecColl);
0082 
0083   iEvent.put(std::move(rts));
0084   iEvent.put(std::move(str));
0085 }
0086 
0087 // define this as a plug-in
0088 DEFINE_FWK_MODULE(LCToSCAssociatorEDProducer);