CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ParticleBasedIsoProducer Class Reference
Inheritance diagram for ParticleBasedIsoProducer:
edm::stream::EDProducer<>

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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_
 
std::unique_ptr< 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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 16 of file ParticleBasedIsoProducer.cc.

Constructor & Destructor Documentation

◆ ParticleBasedIsoProducer()

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

Definition at line 56 of file ParticleBasedIsoProducer.cc.

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

56  : conf_(conf) {
57  photonTmpProducer_ = conf_.getParameter<edm::InputTag>("photonTmpProducer");
58  photonProducer_ = conf_.getParameter<edm::InputTag>("photonProducer");
59  electronProducer_ = conf_.getParameter<edm::InputTag>("electronProducer");
60  electronTmpProducer_ = conf_.getParameter<edm::InputTag>("electronTmpProducer");
61 
62  photonProducerT_ = consumes<reco::PhotonCollection>(photonProducer_);
63 
64  photonTmpProducerT_ = consumes<reco::PhotonCollection>(photonTmpProducer_);
65 
66  electronProducerT_ = consumes<reco::GsfElectronCollection>(electronProducer_);
67 
68  electronTmpProducerT_ = consumes<reco::GsfElectronCollection>(electronTmpProducer_);
69 
70  pfCandidates_ = consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfCandidates"));
71 
72  pfEgammaCandidates_ = consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfEgammaCandidates"));
73 
75  valueMapPFCandEle_ = conf_.getParameter<std::string>("valueMapEleToEG");
76 
77  valMapPFCandToPhoton_ = consumes<edm::ValueMap<reco::PhotonRef>>({"gedPhotonsTmp", valueMapPFCandPhoton_});
78 
80  consumes<edm::ValueMap<reco::GsfElectronRef>>({"gedGsfElectronValueMapsTmp", valueMapPFCandEle_});
81 
82  valueMapPhoPFCandIso_ = conf_.getParameter<std::string>("valueMapPhoPFblockIso");
83  valueMapElePFCandIso_ = conf_.getParameter<std::string>("valueMapElePFblockIso");
84 
85  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapPhoPFCandIso_);
86  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(valueMapElePFCandIso_);
87 }
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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_

Member Function Documentation

◆ beginRun()

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

Definition at line 89 of file ParticleBasedIsoProducer.cc.

References conf_, edm::ParameterSet::getParameter(), and thePFBlockBasedIsolation_.

89  {
90  thePFBlockBasedIsolation_ = std::make_unique<PFBlockBasedIsolation>();
91  edm::ParameterSet pfBlockBasedIsolationSetUp = conf_.getParameter<edm::ParameterSet>("pfBlockBasedIsolationSetUp");
92  thePFBlockBasedIsolation_->setup(pfBlockBasedIsolationSetUp);
93 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< PFBlockBasedIsolation > thePFBlockBasedIsolation_

◆ fillDescriptions()

void ParticleBasedIsoProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 192 of file ParticleBasedIsoProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

192  {
193  // particleBasedIsolation
195  desc.add<std::string>("valueMapEleToEG", "");
196  desc.add<std::string>("valueMapPhoToEG", "valMapPFEgammaCandToPhoton");
197  desc.add<edm::InputTag>("electronTmpProducer", {"gedGsfElectronsTmp"});
198  desc.add<edm::InputTag>("pfCandidates", {"particleFlow"});
199  desc.add<std::string>("valueMapElePFblockIso", "gedGsfElectrons");
200  desc.add<edm::InputTag>("electronProducer", {"gedGsfElectrons"});
201  desc.add<edm::InputTag>("photonTmpProducer", {"gedPhotonsTmp"});
202  desc.add<edm::InputTag>("pfEgammaCandidates", {"particleFlowEGamma"});
203  {
205  psd0.add<std::string>("ComponentName", "pfBlockBasedIsolation");
206  psd0.add<double>("coneSize", 9999999999.);
207  desc.add<edm::ParameterSetDescription>("pfBlockBasedIsolationSetUp", psd0);
208  }
209  desc.add<edm::InputTag>("photonProducer", {"gedPhotons"});
210  desc.add<std::string>("valueMapPhoPFblockIso", "gedPhotons");
211  descriptions.add("particleBasedIsolation", desc);
212  // or use the following to generate the label from the module's C++ type
213  //descriptions.addWithDefaultLabel(desc);
214 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 95 of file ParticleBasedIsoProducer.cc.

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

95  {
96  auto photonHandle = theEvent.getHandle(photonProducerT_);
97  auto photonTmpHandle = theEvent.getHandle(photonTmpProducerT_);
98  auto electronTmpHandle = theEvent.getHandle(electronTmpProducerT_);
99  auto electronHandle = theEvent.getHandle(electronProducerT_);
100  auto pfEGCandidateHandle = theEvent.getHandle(pfEgammaCandidates_);
101  auto pfCandidateHandle = theEvent.getHandle(pfCandidates_);
102  auto const& pfEGCandToPhotonMap = theEvent.get(valMapPFCandToPhoton_);
103  auto const& pfEGCandToElectronMap = theEvent.get(valMapPFCandToEle_);
104 
105  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecPho;
106 
108  // std::cout << " ParticleBasedIsoProducer photonHandle size " << photonHandle->size() << std::endl;
109  for (unsigned int lSC = 0; lSC < photonTmpHandle->size(); lSC++) {
110  reco::PhotonRef phoRef(reco::PhotonRef(photonTmpHandle, lSC));
111 
112  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this photon
113  unsigned nObj = pfEGCandidateHandle->size();
114  reco::PFCandidateRef pfEGCandRef;
115 
116  std::vector<reco::PFCandidateRef> pfCandIsoPairPho;
117  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
118  pfEGCandRef = reco::PFCandidateRef(pfEGCandidateHandle, lCand);
119  const reco::PhotonRef& myPho = (pfEGCandToPhotonMap)[pfEGCandRef];
120 
121  if (myPho.isNonnull()) {
122  //std::cout << "ParticleBasedIsoProducer photons PF SC " << pfEGCandRef->superClusterRef()->energy() << " Photon SC " << myPho->superCluster()->energy() << std::endl;
123  if (myPho != phoRef)
124  continue;
125  // std::cout << " ParticleBasedIsoProducer photons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
126  pfCandIsoPairPho = thePFBlockBasedIsolation_->calculate(myPho->p4(), pfEGCandRef, pfCandidateHandle);
127 
129  // for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairPho.begin(); iPair<pfCandIsoPairPho.end(); iPair++) {
130  // float dR= deltaR(myPho->eta(), myPho->phi(), (*iPair)->eta(), (*iPair)->phi() );
131  // std::cout << " ParticleBasedIsoProducer photons checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << std::endl;
132  // }
133  }
134  }
135 
136  pfCandIsoPairVecPho.push_back(pfCandIsoPairPho);
137  }
138 
140  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecEle;
141  // std::cout << " ParticleBasedIsoProducer electronHandle size " << electronHandle->size() << std::endl;
142  for (unsigned int lSC = 0; lSC < electronTmpHandle->size(); lSC++) {
143  reco::GsfElectronRef eleRef(reco::GsfElectronRef(electronTmpHandle, lSC));
144 
145  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this electron
146  unsigned nObj = pfEGCandidateHandle->size();
147  reco::PFCandidateRef pfEGCandRef;
148 
149  std::vector<reco::PFCandidateRef> pfCandIsoPairEle;
150  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
151  pfEGCandRef = reco::PFCandidateRef(pfEGCandidateHandle, lCand);
152  const reco::GsfElectronRef& myEle = (pfEGCandToElectronMap)[pfEGCandRef];
153 
154  if (myEle.isNonnull()) {
155  // std::cout << "ParticleBasedIsoProducer Electorns PF SC " << pfEGCandRef->superClusterRef()->energy() << " Electron SC " << myEle->superCluster()->energy() << std::endl;
156  if (myEle != eleRef)
157  continue;
158 
159  //math::XYZVector candidateMomentum(myEle->p4().px(),myEle->p4().py(),myEle->p4().pz());
160  //math::XYZVector myDir=candidateMomentum.Unit();
161  // std::cout << " ParticleBasedIsoProducer Electrons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
162  // std::cout << " Ele direction " << myDir << " eta " << myEle->eta() << " phi " << myEle->phi() << std::endl;
163  pfCandIsoPairEle = thePFBlockBasedIsolation_->calculate(myEle->p4(), pfEGCandRef, pfCandidateHandle);
165  //for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairEle.begin(); iPair<pfCandIsoPairEle.end(); iPair++) {
166  // float dR= deltaR(myEle->eta(), myEle->phi(), (*iPair)->eta(), (*iPair)->phi() );
167  // std::cout << " ParticleBasedIsoProducer Electron checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << " eta " << (*iPair)->eta() << " phi " << (*iPair)->phi() << std::endl;
168  // }
169  }
170  }
171 
172  pfCandIsoPairVecEle.push_back(pfCandIsoPairEle);
173  }
174 
175  auto phoToPFCandIsoMap_p = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
176  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerPhotons(*phoToPFCandIsoMap_p);
177 
179  fillerPhotons.insert(photonHandle, pfCandIsoPairVecPho.begin(), pfCandIsoPairVecPho.end());
180  fillerPhotons.fill();
181  theEvent.put(std::move(phoToPFCandIsoMap_p), valueMapPhoPFCandIso_);
182 
183  auto eleToPFCandIsoMap_p = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
184  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerElectrons(*eleToPFCandIsoMap_p);
185 
187  fillerElectrons.insert(electronHandle, pfCandIsoPairVecEle.begin(), pfCandIsoPairVecEle.end());
188  fillerElectrons.fill();
189  theEvent.put(std::move(eleToPFCandIsoMap_p), valueMapElePFCandIso_);
190 }
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:232
edm::EDGetTokenT< reco::PhotonCollection > photonTmpProducerT_
edm::EDGetTokenT< reco::GsfElectronCollection > electronProducerT_
std::unique_ptr< PFBlockBasedIsolation > thePFBlockBasedIsolation_
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
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_

Member Data Documentation

◆ conf_

edm::ParameterSet ParticleBasedIsoProducer::conf_
private

Definition at line 26 of file ParticleBasedIsoProducer.cc.

Referenced by beginRun(), and ParticleBasedIsoProducer().

◆ electronCollection_

std::string ParticleBasedIsoProducer::electronCollection_
private

Definition at line 28 of file ParticleBasedIsoProducer.cc.

◆ electronProducer_

edm::InputTag ParticleBasedIsoProducer::electronProducer_
private

Definition at line 33 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ electronProducerT_

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

Definition at line 38 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ electronTmpProducer_

edm::InputTag ParticleBasedIsoProducer::electronTmpProducer_
private

Definition at line 34 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ electronTmpProducerT_

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

Definition at line 39 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ pfCandidates_

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

Definition at line 41 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ pfEgammaCandidates_

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

Definition at line 40 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ photonCollection_

std::string ParticleBasedIsoProducer::photonCollection_
private

Definition at line 27 of file ParticleBasedIsoProducer.cc.

◆ photonProducer_

edm::InputTag ParticleBasedIsoProducer::photonProducer_
private

Definition at line 30 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ photonProducerT_

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

Definition at line 36 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ photonTmpProducer_

edm::InputTag ParticleBasedIsoProducer::photonTmpProducer_
private

Definition at line 31 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ photonTmpProducerT_

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

Definition at line 37 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ thePFBlockBasedIsolation_

std::unique_ptr<PFBlockBasedIsolation> ParticleBasedIsoProducer::thePFBlockBasedIsolation_
private

Definition at line 50 of file ParticleBasedIsoProducer.cc.

Referenced by beginRun(), and produce().

◆ valMapPFCandToEle_

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

Definition at line 43 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valMapPFCandToPhoton_

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

Definition at line 42 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valueMapElePFCandIso_

std::string ParticleBasedIsoProducer::valueMapElePFCandIso_
private

Definition at line 48 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().

◆ valueMapPFCandEle_

std::string ParticleBasedIsoProducer::valueMapPFCandEle_
private

Definition at line 47 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ valueMapPFCandPhoton_

std::string ParticleBasedIsoProducer::valueMapPFCandPhoton_
private

Definition at line 45 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer().

◆ valueMapPhoPFCandIso_

std::string ParticleBasedIsoProducer::valueMapPhoPFCandIso_
private

Definition at line 46 of file ParticleBasedIsoProducer.cc.

Referenced by ParticleBasedIsoProducer(), and produce().