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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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::ParticleBasedIsoProducer ( const edm::ParameterSet conf)

Definition at line 8 of file ParticleBasedIsoProducer.cc.

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 
29  valMapPFCandToPhoton_ = consumes<edm::ValueMap<reco::PhotonRef>>({"gedPhotonsTmp", valueMapPFCandPhoton_});
30 
32  consumes<edm::ValueMap<reco::GsfElectronRef>>({"gedGsfElectronValueMapsTmp", valueMapPFCandEle_});
33 
34  valueMapPhoPFCandIso_ = conf_.getParameter<std::string>("valueMapPhoPFblockIso");
35  valueMapElePFCandIso_ = conf_.getParameter<std::string>("valueMapElePFblockIso");
36 
37  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapPhoPFCandIso_);
38  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapElePFCandIso_);
39 }

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

◆ ~ParticleBasedIsoProducer()

ParticleBasedIsoProducer::~ParticleBasedIsoProducer ( )
override

Definition at line 41 of file ParticleBasedIsoProducer.cc.

41 {}

Member Function Documentation

◆ beginRun()

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

◆ endRun()

void ParticleBasedIsoProducer::endRun ( edm::Run const &  run,
edm::EventSetup const &  c 
)
override

Definition at line 49 of file ParticleBasedIsoProducer.cc.

49  {
51 }

References thePFBlockBasedIsolation_.

◆ produce()

void ParticleBasedIsoProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 53 of file ParticleBasedIsoProducer.cc.

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

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_.

Member Data Documentation

◆ conf_

edm::ParameterSet ParticleBasedIsoProducer::conf_
private

Definition at line 27 of file ParticleBasedIsoProducer.h.

Referenced by beginRun(), and ParticleBasedIsoProducer().

◆ electronCollection_

std::string ParticleBasedIsoProducer::electronCollection_
private

Definition at line 29 of file ParticleBasedIsoProducer.h.

◆ electronProducer_

edm::InputTag ParticleBasedIsoProducer::electronProducer_
private

Definition at line 34 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ electronProducerT_

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

Definition at line 39 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ electronTmpProducer_

edm::InputTag ParticleBasedIsoProducer::electronTmpProducer_
private

Definition at line 35 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ electronTmpProducerT_

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

Definition at line 40 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ pfCandidates_

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

Definition at line 42 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ pfEgammaCandidates_

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

Definition at line 41 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ photonCollection_

std::string ParticleBasedIsoProducer::photonCollection_
private

Definition at line 28 of file ParticleBasedIsoProducer.h.

◆ photonProducer_

edm::InputTag ParticleBasedIsoProducer::photonProducer_
private

Definition at line 31 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ photonProducerT_

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

Definition at line 37 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ photonTmpProducer_

edm::InputTag ParticleBasedIsoProducer::photonTmpProducer_
private

Definition at line 32 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ photonTmpProducerT_

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

Definition at line 38 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ thePFBlockBasedIsolation_

PFBlockBasedIsolation* ParticleBasedIsoProducer::thePFBlockBasedIsolation_
private

Definition at line 51 of file ParticleBasedIsoProducer.h.

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

◆ valMapPFCandToEle_

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

Definition at line 44 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valMapPFCandToPhoton_

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

Definition at line 43 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valueMapElePFCandIso_

std::string ParticleBasedIsoProducer::valueMapElePFCandIso_
private

Definition at line 49 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valueMapPFCandEle_

std::string ParticleBasedIsoProducer::valueMapPFCandEle_
private

Definition at line 48 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ valueMapPFCandPhoton_

std::string ParticleBasedIsoProducer::valueMapPFCandPhoton_
private

Definition at line 46 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

◆ valueMapPhoPFCandIso_

std::string ParticleBasedIsoProducer::valueMapPhoPFCandIso_
private

Definition at line 47 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

ParticleBasedIsoProducer::valueMapElePFCandIso_
std::string valueMapElePFCandIso_
Definition: ParticleBasedIsoProducer.h:49
ParticleBasedIsoProducer::pfEgammaCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
Definition: ParticleBasedIsoProducer.h:41
ParticleBasedIsoProducer::valueMapPhoPFCandIso_
std::string valueMapPhoPFCandIso_
Definition: ParticleBasedIsoProducer.h:47
ParticleBasedIsoProducer::photonTmpProducer_
edm::InputTag photonTmpProducer_
Definition: ParticleBasedIsoProducer.h:32
ParticleBasedIsoProducer::photonProducerT_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
Definition: ParticleBasedIsoProducer.h:37
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ParticleBasedIsoProducer::thePFBlockBasedIsolation_
PFBlockBasedIsolation * thePFBlockBasedIsolation_
Definition: ParticleBasedIsoProducer.h:51
PFBlockBasedIsolation::calculate
std::vector< reco::PFCandidateRef > calculate(math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle)
Definition: PFBlockBasedIsolation.cc:21
ParticleBasedIsoProducer::photonProducer_
edm::InputTag photonProducer_
Definition: ParticleBasedIsoProducer.h:31
edm::Handle< reco::PhotonCollection >
PFBlockBasedIsolation::setup
void setup(const edm::ParameterSet &conf)
Definition: PFBlockBasedIsolation.cc:19
edm::Ref< PhotonCollection >
ParticleBasedIsoProducer::photonTmpProducerT_
edm::EDGetTokenT< reco::PhotonCollection > photonTmpProducerT_
Definition: ParticleBasedIsoProducer.h:38
ParticleBasedIsoProducer::conf_
edm::ParameterSet conf_
Definition: ParticleBasedIsoProducer.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
particleBasedIsoProducer_cfi.pfBlockBasedIsolationSetUp
pfBlockBasedIsolationSetUp
Definition: particleBasedIsoProducer_cfi.py:18
edm::ParameterSet
Definition: ParameterSet.h:47
ParticleBasedIsoProducer::valMapPFCandToPhoton_
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_
Definition: ParticleBasedIsoProducer.h:43
ParticleBasedIsoProducer::electronTmpProducerT_
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
Definition: ParticleBasedIsoProducer.h:40
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::PFCandidateRef
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
Definition: PFCandidateFwd.h:24
ParticleBasedIsoProducer::electronProducer_
edm::InputTag electronProducer_
Definition: ParticleBasedIsoProducer.h:34
ParticleBasedIsoProducer::valMapPFCandToEle_
edm::EDGetTokenT< edm::ValueMap< reco::GsfElectronRef > > valMapPFCandToEle_
Definition: ParticleBasedIsoProducer.h:44
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap
Definition: ValueMap.h:107
ParticleBasedIsoProducer::valueMapPFCandPhoton_
std::string valueMapPFCandPhoton_
Definition: ParticleBasedIsoProducer.h:46
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParticleBasedIsoProducer::pfCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
Definition: ParticleBasedIsoProducer.h:42
ParticleBasedIsoProducer::electronProducerT_
edm::EDGetTokenT< reco::GsfElectronCollection > electronProducerT_
Definition: ParticleBasedIsoProducer.h:39
PFBlockBasedIsolation
Definition: PFBlockBasedIsolation.h:19
ParticleBasedIsoProducer::valueMapPFCandEle_
std::string valueMapPFCandEle_
Definition: ParticleBasedIsoProducer.h:48
edm::InputTag
Definition: InputTag.h:15
ParticleBasedIsoProducer::electronTmpProducer_
edm::InputTag electronTmpProducer_
Definition: ParticleBasedIsoProducer.h:35