CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ParticleBasedIsoProducer Class Reference

#include <ParticleBasedIsoProducer.h>

Inheritance diagram for ParticleBasedIsoProducer:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &r, edm::EventSetup const &es) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
 ParticleBasedIsoProducer (const edm::ParameterSet &conf)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~ParticleBasedIsoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::ParameterSet conf_
 
std::string electronCollection_
 
edm::InputTag electronProducer_
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronProducerT_
 
edm::InputTag electronTmpProducer_
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronTmpProducerT_
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidates_
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfEgammaCandidates_
 
std::string photonCollection_
 
edm::InputTag photonProducer_
 
edm::EDGetTokenT< reco::PhotonCollectionphotonProducerT_
 
edm::InputTag photonTmpProducer_
 
edm::EDGetTokenT< reco::PhotonCollectionphotonTmpProducerT_
 
PFBlockBasedIsolationthePFBlockBasedIsolation_
 
edm::EDGetTokenT< edm::ValueMap< reco::GsfElectronRef > > valMapPFCandToEle_
 
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_
 
std::string valueMapElePFCandIso_
 
std::string valueMapPFCandEle_
 
std::string valueMapPFCandPhoton_
 
std::string valueMapPhoPFCandIso_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 17 of file ParticleBasedIsoProducer.h.

Constructor & Destructor Documentation

ParticleBasedIsoProducer::ParticleBasedIsoProducer ( const edm::ParameterSet conf)

Definition at line 8 of file ParticleBasedIsoProducer.cc.

References conf_, electronProducer_, electronProducerT_, electronTmpProducer_, electronTmpProducerT_, edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, pfCandidates_, pfEgammaCandidates_, photonProducer_, photonProducerT_, photonTmpProducer_, photonTmpProducerT_, AlCaHLTBitMon_QueryRunRegistry::string, valMapPFCandToEle_, valMapPFCandToPhoton_, valueMapElePFCandIso_, valueMapPFCandEle_, valueMapPFCandPhoton_, and valueMapPhoPFCandIso_.

8  : conf_(conf) {
9  photonTmpProducer_ = conf_.getParameter<edm::InputTag>("photonTmpProducer");
10  photonProducer_ = conf_.getParameter<edm::InputTag>("photonProducer");
11  electronProducer_ = conf_.getParameter<edm::InputTag>("electronProducer");
12  electronTmpProducer_ = conf_.getParameter<edm::InputTag>("electronTmpProducer");
13 
14  photonProducerT_ = consumes<reco::PhotonCollection>(photonProducer_);
15 
16  photonTmpProducerT_ = consumes<reco::PhotonCollection>(photonTmpProducer_);
17 
18  electronProducerT_ = consumes<reco::GsfElectronCollection>(electronProducer_);
19 
20  electronTmpProducerT_ = consumes<reco::GsfElectronCollection>(electronTmpProducer_);
21 
22  pfCandidates_ = consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfCandidates"));
23 
24  pfEgammaCandidates_ = consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfEgammaCandidates"));
25 
27  valueMapPFCandEle_ = conf_.getParameter<std::string>("valueMapEleToEG");
28 
30  consumes<edm::ValueMap<reco::PhotonRef>>(edm::InputTag("gedPhotonsTmp", valueMapPFCandPhoton_));
31 
33  consumes<edm::ValueMap<reco::GsfElectronRef>>(edm::InputTag("gedGsfElectronsTmp", valueMapPFCandEle_));
34 
35  valueMapPhoPFCandIso_ = conf_.getParameter<std::string>("valueMapPhoPFblockIso");
36  valueMapElePFCandIso_ = conf_.getParameter<std::string>("valueMapElePFblockIso");
37 
38  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapPhoPFCandIso_);
39  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapElePFCandIso_);
40 }
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PhotonCollection > photonTmpProducerT_
edm::EDGetTokenT< reco::GsfElectronCollection > electronProducerT_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
edm::EDGetTokenT< edm::ValueMap< reco::GsfElectronRef > > valMapPFCandToEle_
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_
ParticleBasedIsoProducer::~ParticleBasedIsoProducer ( )
override

Definition at line 42 of file ParticleBasedIsoProducer.cc.

42 {}

Member Function Documentation

void ParticleBasedIsoProducer::beginRun ( edm::Run const &  r,
edm::EventSetup const &  es 
)
override
void ParticleBasedIsoProducer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
override

Definition at line 50 of file ParticleBasedIsoProducer.cc.

References thePFBlockBasedIsolation_.

50  {
52 }
PFBlockBasedIsolation * thePFBlockBasedIsolation_
void ParticleBasedIsoProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 54 of file ParticleBasedIsoProducer.cc.

References PFBlockBasedIsolation::calculate(), electronProducerT_, electronTmpProducerT_, edm::Event::getByToken(), edm::Ref< C, T, F >::isNonnull(), eostools::move(), pfCandidates_, pfEgammaCandidates_, photonProducerT_, photonTmpProducerT_, edm::Handle< T >::product(), edm::Event::put(), thePFBlockBasedIsolation_, valMapPFCandToEle_, valMapPFCandToPhoton_, valueMapElePFCandIso_, and valueMapPhoPFCandIso_.

54  {
56  theEvent.getByToken(photonProducerT_, photonHandle);
57 
59  theEvent.getByToken(photonTmpProducerT_, photonTmpHandle);
60 
62  theEvent.getByToken(electronTmpProducerT_, electronTmpHandle);
63 
65  theEvent.getByToken(electronProducerT_, electronHandle);
66 
67  edm::Handle<reco::PFCandidateCollection> pfEGCandidateHandle;
68  // Get the PF refined cluster collection
69  theEvent.getByToken(pfEgammaCandidates_, pfEGCandidateHandle);
70 
72  // Get the PF candidates collection
73  theEvent.getByToken(pfCandidates_, pfCandidateHandle);
74 
75  edm::ValueMap<reco::PhotonRef> pfEGCandToPhotonMap;
76  edm::Handle<edm::ValueMap<reco::PhotonRef>> pfEGCandToPhotonMapHandle;
77  theEvent.getByToken(valMapPFCandToPhoton_, pfEGCandToPhotonMapHandle);
78  pfEGCandToPhotonMap = *(pfEGCandToPhotonMapHandle.product());
79 
80  edm::ValueMap<reco::GsfElectronRef> pfEGCandToElectronMap;
81  edm::Handle<edm::ValueMap<reco::GsfElectronRef>> pfEGCandToElectronMapHandle;
82  theEvent.getByToken(valMapPFCandToEle_, pfEGCandToElectronMapHandle);
83  pfEGCandToElectronMap = *(pfEGCandToElectronMapHandle.product());
84 
85  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecPho;
86 
88  // std::cout << " ParticleBasedIsoProducer photonHandle size " << photonHandle->size() << std::endl;
89  for (unsigned int lSC = 0; lSC < photonTmpHandle->size(); lSC++) {
90  reco::PhotonRef phoRef(reco::PhotonRef(photonTmpHandle, lSC));
91 
92  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this photon
93  unsigned nObj = pfEGCandidateHandle->size();
94  reco::PFCandidateRef pfEGCandRef;
95 
96  std::vector<reco::PFCandidateRef> pfCandIsoPairPho;
97  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
98  pfEGCandRef = reco::PFCandidateRef(pfEGCandidateHandle, lCand);
99  reco::PhotonRef myPho = (pfEGCandToPhotonMap)[pfEGCandRef];
100 
101  if (myPho.isNonnull()) {
102  //std::cout << "ParticleBasedIsoProducer photons PF SC " << pfEGCandRef->superClusterRef()->energy() << " Photon SC " << myPho->superCluster()->energy() << std::endl;
103  if (myPho != phoRef)
104  continue;
105  // std::cout << " ParticleBasedIsoProducer photons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
106  pfCandIsoPairPho = thePFBlockBasedIsolation_->calculate(myPho->p4(), pfEGCandRef, pfCandidateHandle);
107 
109  // for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairPho.begin(); iPair<pfCandIsoPairPho.end(); iPair++) {
110  // float dR= deltaR(myPho->eta(), myPho->phi(), (*iPair)->eta(), (*iPair)->phi() );
111  // std::cout << " ParticleBasedIsoProducer photons checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << std::endl;
112  // }
113  }
114  }
115 
116  pfCandIsoPairVecPho.push_back(pfCandIsoPairPho);
117  }
118 
120  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecEle;
121  // std::cout << " ParticleBasedIsoProducer electronHandle size " << electronHandle->size() << std::endl;
122  for (unsigned int lSC = 0; lSC < electronTmpHandle->size(); lSC++) {
123  reco::GsfElectronRef eleRef(reco::GsfElectronRef(electronTmpHandle, lSC));
124 
125  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this electron
126  unsigned nObj = pfEGCandidateHandle->size();
127  reco::PFCandidateRef pfEGCandRef;
128 
129  std::vector<reco::PFCandidateRef> pfCandIsoPairEle;
130  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
131  pfEGCandRef = reco::PFCandidateRef(pfEGCandidateHandle, lCand);
132  reco::GsfElectronRef myEle = (pfEGCandToElectronMap)[pfEGCandRef];
133 
134  if (myEle.isNonnull()) {
135  // std::cout << "ParticleBasedIsoProducer Electorns PF SC " << pfEGCandRef->superClusterRef()->energy() << " Electron SC " << myEle->superCluster()->energy() << std::endl;
136  if (myEle != eleRef)
137  continue;
138 
139  //math::XYZVector candidateMomentum(myEle->p4().px(),myEle->p4().py(),myEle->p4().pz());
140  //math::XYZVector myDir=candidateMomentum.Unit();
141  // std::cout << " ParticleBasedIsoProducer Electrons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
142  // std::cout << " Ele direction " << myDir << " eta " << myEle->eta() << " phi " << myEle->phi() << std::endl;
143  pfCandIsoPairEle = thePFBlockBasedIsolation_->calculate(myEle->p4(), pfEGCandRef, pfCandidateHandle);
145  //for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairEle.begin(); iPair<pfCandIsoPairEle.end(); iPair++) {
146  // float dR= deltaR(myEle->eta(), myEle->phi(), (*iPair)->eta(), (*iPair)->phi() );
147  // std::cout << " ParticleBasedIsoProducer Electron checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << " eta " << (*iPair)->eta() << " phi " << (*iPair)->phi() << std::endl;
148  // }
149  }
150  }
151 
152  pfCandIsoPairVecEle.push_back(pfCandIsoPairEle);
153  }
154 
155  auto phoToPFCandIsoMap_p = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
156  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerPhotons(*phoToPFCandIsoMap_p);
157 
159  fillerPhotons.insert(photonHandle, pfCandIsoPairVecPho.begin(), pfCandIsoPairVecPho.end());
160  fillerPhotons.fill();
161  theEvent.put(std::move(phoToPFCandIsoMap_p), valueMapPhoPFCandIso_);
162 
163  auto eleToPFCandIsoMap_p = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
164  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerElectrons(*eleToPFCandIsoMap_p);
165 
167  fillerElectrons.insert(electronHandle, pfCandIsoPairVecEle.begin(), pfCandIsoPairVecEle.end());
168  fillerElectrons.fill();
169  theEvent.put(std::move(eleToPFCandIsoMap_p), valueMapElePFCandIso_);
170 }
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
PFBlockBasedIsolation * thePFBlockBasedIsolation_
std::vector< reco::PFCandidateRef > calculate(math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle)
edm::EDGetTokenT< reco::PhotonCollection > photonTmpProducerT_
edm::EDGetTokenT< reco::GsfElectronCollection > electronProducerT_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
edm::EDGetTokenT< edm::ValueMap< reco::GsfElectronRef > > valMapPFCandToEle_
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
T const * product() const
Definition: Handle.h:69
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_

Member Data Documentation

edm::ParameterSet ParticleBasedIsoProducer::conf_
private

Definition at line 27 of file ParticleBasedIsoProducer.h.

Referenced by beginRun(), and ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::electronCollection_
private

Definition at line 29 of file ParticleBasedIsoProducer.h.

edm::InputTag ParticleBasedIsoProducer::electronProducer_
private

Definition at line 34 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

edm::EDGetTokenT<reco::GsfElectronCollection> ParticleBasedIsoProducer::electronProducerT_
private

Definition at line 39 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::InputTag ParticleBasedIsoProducer::electronTmpProducer_
private

Definition at line 35 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

edm::EDGetTokenT<reco::GsfElectronCollection> ParticleBasedIsoProducer::electronTmpProducerT_
private

Definition at line 40 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::EDGetTokenT<reco::PFCandidateCollection> ParticleBasedIsoProducer::pfCandidates_
private

Definition at line 42 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::EDGetTokenT<reco::PFCandidateCollection> ParticleBasedIsoProducer::pfEgammaCandidates_
private

Definition at line 41 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::photonCollection_
private

Definition at line 28 of file ParticleBasedIsoProducer.h.

edm::InputTag ParticleBasedIsoProducer::photonProducer_
private

Definition at line 31 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

edm::EDGetTokenT<reco::PhotonCollection> ParticleBasedIsoProducer::photonProducerT_
private

Definition at line 37 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::InputTag ParticleBasedIsoProducer::photonTmpProducer_
private

Definition at line 32 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

edm::EDGetTokenT<reco::PhotonCollection> ParticleBasedIsoProducer::photonTmpProducerT_
private

Definition at line 38 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

PFBlockBasedIsolation* ParticleBasedIsoProducer::thePFBlockBasedIsolation_
private

Definition at line 51 of file ParticleBasedIsoProducer.h.

Referenced by beginRun(), endRun(), and produce().

edm::EDGetTokenT<edm::ValueMap<reco::GsfElectronRef> > ParticleBasedIsoProducer::valMapPFCandToEle_
private

Definition at line 44 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::EDGetTokenT<edm::ValueMap<reco::PhotonRef> > ParticleBasedIsoProducer::valMapPFCandToPhoton_
private

Definition at line 43 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::valueMapElePFCandIso_
private

Definition at line 49 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::valueMapPFCandEle_
private

Definition at line 48 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::valueMapPFCandPhoton_
private

Definition at line 46 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::valueMapPhoPFCandIso_
private

Definition at line 47 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().