Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:04

0001 #include "CommonTools/Utils/interface/LazyConstructed.h"
0002 #include "DataFormats/EgammaCandidates/interface/GsfElectronCore.h"
0003 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrack.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "DataFormats/Common/interface/ValueMap.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/Framework/interface/global/EDProducer.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "DataFormats/Common/interface/Handle.h"
0012 #include "DataFormats/TrackReco/interface/Track.h"
0013 #include "RecoEgamma/EgammaElectronAlgos/interface/GsfElectronTools.h"
0014 
0015 class LowPtGsfElectronCoreProducer : public edm::global::EDProducer<> {
0016 public:
0017   explicit LowPtGsfElectronCoreProducer(const edm::ParameterSet& conf);
0018 
0019   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0020 
0021   static void fillDescriptions(edm::ConfigurationDescriptions&);
0022 
0023 private:
0024   const edm::EDGetTokenT<reco::GsfPFRecTrackCollection> gsfPfRecTracksToken_;
0025   const edm::EDGetTokenT<reco::TrackCollection> ctfTracksToken_;
0026   const edm::EDGetTokenT<edm::ValueMap<reco::SuperClusterRef> > superClusterRefs_;
0027   const edm::EDPutTokenT<reco::GsfElectronCoreCollection> putToken_;
0028 };
0029 
0030 using reco::GsfPFRecTrackCollection;
0031 using reco::SuperClusterRef;
0032 
0033 LowPtGsfElectronCoreProducer::LowPtGsfElectronCoreProducer(const edm::ParameterSet& config)
0034     : gsfPfRecTracksToken_(mayConsume<GsfPFRecTrackCollection>(config.getParameter<edm::InputTag>("gsfPfRecTracks"))),
0035       ctfTracksToken_(consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("ctfTracks"))),
0036       superClusterRefs_(consumes<edm::ValueMap<SuperClusterRef> >(config.getParameter<edm::InputTag>("superClusters"))),
0037       putToken_(produces<reco::GsfElectronCoreCollection>()) {}
0038 
0039 void LowPtGsfElectronCoreProducer::produce(edm::StreamID, edm::Event& event, const edm::EventSetup&) const {
0040   // Output collection
0041   reco::GsfElectronCoreCollection electrons;
0042 
0043   // Init
0044   auto gsfPfRecTracksHandle = event.getHandle(gsfPfRecTracksToken_);
0045   auto ctfTracksHandle = event.getHandle(ctfTracksToken_);
0046   auto const& superClusterRefs = event.get(superClusterRefs_);
0047 
0048   auto ctfTrackVariables = makeLazy<edm::soa::EtaPhiTable>(*ctfTracksHandle);
0049 
0050   // Create ElectronCore objects
0051   for (size_t ipfgsf = 0; ipfgsf < gsfPfRecTracksHandle->size(); ++ipfgsf) {
0052     // Refs to GSF(PF) objects and SC
0053     reco::GsfPFRecTrackRef pfgsf(gsfPfRecTracksHandle, ipfgsf);
0054 
0055     // Use GsfElectronCore(gsf) constructor and store object via emplace
0056     electrons.emplace_back(pfgsf->gsfTrackRef());
0057 
0058     // Do not consider ECAL-driven objects
0059     if (electrons.back().ecalDrivenSeed()) {
0060       electrons.pop_back();
0061       continue;
0062     }
0063 
0064     // Add GSF(PF) track information
0065     auto ctfpair = egamma::getClosestCtfToGsf(electrons.back().gsfTrack(), ctfTracksHandle, ctfTrackVariables.value());
0066     electrons.back().setCtfTrack(ctfpair.first, ctfpair.second);
0067 
0068     // Add super cluster information
0069     electrons.back().setSuperCluster(superClusterRefs[pfgsf]);
0070   }
0071 
0072   event.emplace(putToken_, std::move(electrons));
0073 }
0074 
0075 //////////////////////////////////////////////////////////////////////////////////////////
0076 //
0077 void LowPtGsfElectronCoreProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078   edm::ParameterSetDescription desc;
0079   desc.add<edm::InputTag>("gsfPfRecTracks", {"lowPtGsfElePfGsfTracks"});
0080   desc.add<edm::InputTag>("ctfTracks", {"generalTracks"});
0081   desc.add<edm::InputTag>("superClusters", edm::InputTag("lowPtGsfElectronSuperClusters"));
0082   descriptions.add("lowPtGsfElectronCores", desc);
0083 }
0084 
0085 //////////////////////////////////////////////////////////////////////////////////////////
0086 //
0087 #include "FWCore/Framework/interface/MakerMacros.h"
0088 DEFINE_FWK_MODULE(LowPtGsfElectronCoreProducer);