CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ParticleBasedIsoProducer Class Reference

#include <ParticleBasedIsoProducer.h>

Inheritance diagram for ParticleBasedIsoProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &r, edm::EventSetup const &es) override
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 
 ParticleBasedIsoProducer (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
 ~ParticleBasedIsoProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::ParameterSet conf_
 
std::string electronCollection_
 
edm::InputTag electronProducer_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
electronProducerT_
 
edm::InputTag electronTmpProducer_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
electronTmpProducerT_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidates_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfEgammaCandidates_
 
std::string photonCollection_
 
edm::InputTag photonProducer_
 
edm::EDGetTokenT
< reco::PhotonCollection
photonProducerT_
 
edm::InputTag photonTmpProducer_
 
edm::EDGetTokenT
< reco::PhotonCollection
photonTmpProducerT_
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 18 of file ParticleBasedIsoProducer.h.

Constructor & Destructor Documentation

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

Definition at line 10 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_.

10  : conf_(conf) {
11 
12  photonTmpProducer_ = conf_.getParameter<edm::InputTag>("photonTmpProducer");
13  photonProducer_ = conf_.getParameter<edm::InputTag>("photonProducer");
14  electronProducer_ = conf_.getParameter<edm::InputTag>("electronProducer");
15  electronTmpProducer_ = conf_.getParameter<edm::InputTag>("electronTmpProducer");
16 
18  consumes<reco::PhotonCollection>(photonProducer_);
19 
20 
22  consumes<reco::PhotonCollection>(photonTmpProducer_);
23 
24 
26  consumes<reco::GsfElectronCollection>(electronProducer_);
27 
29  consumes<reco::GsfElectronCollection>(electronTmpProducer_);
30 
31  pfCandidates_ =
32  consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfCandidates"));
33 
35  consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfEgammaCandidates"));
36 
37  valueMapPFCandPhoton_ = conf_.getParameter<std::string>("valueMapPhoToEG");
38  valueMapPFCandEle_ = conf_.getParameter<std::string>("valueMapEleToEG");
39 
41  consumes<edm::ValueMap<reco::PhotonRef> >(edm::InputTag("gedPhotonsTmp",valueMapPFCandPhoton_));
42 
44  consumes<edm::ValueMap<reco::GsfElectronRef> >(edm::InputTag("gedGsfElectronsTmp",valueMapPFCandEle_));
45 
46  valueMapPhoPFCandIso_ = conf_.getParameter<std::string>("valueMapPhoPFblockIso");
47  valueMapElePFCandIso_ = conf_.getParameter<std::string>("valueMapElePFblockIso");
48 
49 
50  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > > (valueMapPhoPFCandIso_);
51  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > > (valueMapElePFCandIso_);
52 
53 }
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 ( )

Definition at line 55 of file ParticleBasedIsoProducer.cc.

55  {
56 
57 
58 }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 61 of file ParticleBasedIsoProducer.cc.

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

61  {
62 
64  edm::ParameterSet pfBlockBasedIsolationSetUp = conf_.getParameter<edm::ParameterSet>("pfBlockBasedIsolationSetUp");
65  thePFBlockBasedIsolation_ ->setup(pfBlockBasedIsolationSetUp);
66 
67 }
T getParameter(std::string const &) const
void setup(const edm::ParameterSet &conf)
PfBlockBasedIsolation * thePFBlockBasedIsolation_
void ParticleBasedIsoProducer::endRun ( edm::Run const &  run,
edm::EventSetup const &  c 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 69 of file ParticleBasedIsoProducer.cc.

References thePFBlockBasedIsolation_.

69  {
70 
72 
73 }
PfBlockBasedIsolation * thePFBlockBasedIsolation_
void ParticleBasedIsoProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 77 of file ParticleBasedIsoProducer.cc.

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

77  {
78 
80  theEvent.getByToken(photonProducerT_,photonHandle);
81 
83  theEvent.getByToken(photonTmpProducerT_,photonTmpHandle);
84 
86  theEvent.getByToken(electronTmpProducerT_,electronTmpHandle);
87 
89  theEvent.getByToken(electronProducerT_,electronHandle);
90 
91  edm::Handle<reco::PFCandidateCollection> pfEGCandidateHandle;
92  // Get the PF refined cluster collection
93  theEvent.getByToken(pfEgammaCandidates_,pfEGCandidateHandle);
94 
96  // Get the PF candidates collection
97  theEvent.getByToken(pfCandidates_,pfCandidateHandle);
98 
99  edm::ValueMap<reco::PhotonRef> pfEGCandToPhotonMap;
100  edm::Handle<edm::ValueMap<reco::PhotonRef> > pfEGCandToPhotonMapHandle;
101  theEvent.getByToken(valMapPFCandToPhoton_,pfEGCandToPhotonMapHandle);
102  pfEGCandToPhotonMap = *(pfEGCandToPhotonMapHandle.product());
103 
104  edm::ValueMap<reco::GsfElectronRef> pfEGCandToElectronMap;
105  edm::Handle<edm::ValueMap<reco::GsfElectronRef> > pfEGCandToElectronMapHandle;
106  theEvent.getByToken(valMapPFCandToEle_,pfEGCandToElectronMapHandle);
107  pfEGCandToElectronMap = *(pfEGCandToElectronMapHandle.product());
108 
109  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecPho;
110 
112  // std::cout << " ParticleBasedIsoProducer photonHandle size " << photonHandle->size() << std::endl;
113  for(unsigned int lSC=0; lSC < photonTmpHandle->size(); lSC++) {
114 
115  reco::PhotonRef phoRef(reco::PhotonRef(photonTmpHandle, lSC));
116 
117  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this photon
118  unsigned nObj = pfEGCandidateHandle->size();
119  reco::PFCandidateRef pfEGCandRef;
120 
121  std::vector<reco::PFCandidateRef> pfCandIsoPairPho;
122  for(unsigned int lCand=0; lCand < nObj; lCand++) {
123  pfEGCandRef=reco::PFCandidateRef(pfEGCandidateHandle,lCand);
124  reco::PhotonRef myPho= (pfEGCandToPhotonMap)[pfEGCandRef];
125 
126  if ( myPho.isNonnull() ) {
127  //std::cout << "ParticleBasedIsoProducer photons PF SC " << pfEGCandRef->superClusterRef()->energy() << " Photon SC " << myPho->superCluster()->energy() << std::endl;
128  if (myPho != phoRef) continue;
129  // std::cout << " ParticleBasedIsoProducer photons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
130  pfCandIsoPairPho=thePFBlockBasedIsolation_->calculate (myPho->p4(), pfEGCandRef, pfCandidateHandle);
131 
133  // for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairPho.begin(); iPair<pfCandIsoPairPho.end(); iPair++) {
134  // float dR= deltaR(myPho->eta(), myPho->phi(), (*iPair)->eta(), (*iPair)->phi() );
135  // std::cout << " ParticleBasedIsoProducer photons checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << std::endl;
136  // }
137 
138 
139  }
140 
141  }
142 
143  pfCandIsoPairVecPho.push_back(pfCandIsoPairPho);
144  }
145 
146 
147 
149  std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecEle;
150  // std::cout << " ParticleBasedIsoProducer electronHandle size " << electronHandle->size() << std::endl;
151  for(unsigned int lSC=0; lSC < electronTmpHandle->size(); lSC++) {
152  reco::GsfElectronRef eleRef(reco::GsfElectronRef(electronTmpHandle, lSC));
153 
154  // loop over the unbiased candidates to retrieve the ref to the unbiased candidate corresponding to this electron
155  unsigned nObj = pfEGCandidateHandle->size();
156  reco::PFCandidateRef pfEGCandRef;
157 
158  std::vector<reco::PFCandidateRef> pfCandIsoPairEle;
159  for(unsigned int lCand=0; lCand < nObj; lCand++) {
160  pfEGCandRef=reco::PFCandidateRef(pfEGCandidateHandle,lCand);
161  reco::GsfElectronRef myEle= (pfEGCandToElectronMap)[pfEGCandRef];
162 
163  if ( myEle.isNonnull() ) {
164  // std::cout << "ParticleBasedIsoProducer Electorns PF SC " << pfEGCandRef->superClusterRef()->energy() << " Electron SC " << myEle->superCluster()->energy() << std::endl;
165  if (myEle != eleRef) continue;
166 
167  //math::XYZVector candidateMomentum(myEle->p4().px(),myEle->p4().py(),myEle->p4().pz());
168  //math::XYZVector myDir=candidateMomentum.Unit();
169  // std::cout << " ParticleBasedIsoProducer Electrons This is my egammaunbiased guy energy " << pfEGCandRef->superClusterRef()->energy() << std::endl;
170  // std::cout << " Ele direction " << myDir << " eta " << myEle->eta() << " phi " << myEle->phi() << std::endl;
171  pfCandIsoPairEle=thePFBlockBasedIsolation_->calculate (myEle->p4(), pfEGCandRef, pfCandidateHandle);
173  //for ( std::vector<reco::PFCandidateRef>::const_iterator iPair=pfCandIsoPairEle.begin(); iPair<pfCandIsoPairEle.end(); iPair++) {
174  // float dR= deltaR(myEle->eta(), myEle->phi(), (*iPair)->eta(), (*iPair)->phi() );
175  // std::cout << " ParticleBasedIsoProducer Electron checking the pfCand bool pair " << (*iPair)->particleId() << " dR " << dR << " pt " << (*iPair)->pt() << " eta " << (*iPair)->eta() << " phi " << (*iPair)->phi() << std::endl;
176  // }
177 
178 
179  }
180 
181  }
182 
183  pfCandIsoPairVecEle.push_back(pfCandIsoPairEle);
184 }
185 
186 
187 
188 
189 
190  std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef>> >
191  phoToPFCandIsoMap_p(new edm::ValueMap<std::vector<reco::PFCandidateRef>>());
193  fillerPhotons(*phoToPFCandIsoMap_p);
194 
196  fillerPhotons.insert(photonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
197  fillerPhotons.fill();
198  theEvent.put(phoToPFCandIsoMap_p,valueMapPhoPFCandIso_);
199 
200 
201  std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef>> >
202  eleToPFCandIsoMap_p(new edm::ValueMap<std::vector<reco::PFCandidateRef>>());
204  fillerElectrons(*eleToPFCandIsoMap_p);
205 
207  fillerElectrons.insert(electronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
208  fillerElectrons.fill();
209  theEvent.put(eleToPFCandIsoMap_p,valueMapElePFCandIso_);
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 }
edm::EDGetTokenT< reco::GsfElectronCollection > electronTmpProducerT_
edm::EDGetTokenT< reco::PhotonCollection > photonTmpProducerT_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::EDGetTokenT< reco::GsfElectronCollection > electronProducerT_
std::vector< reco::PFCandidateRef > calculate(math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle)
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:81
PfBlockBasedIsolation * thePFBlockBasedIsolation_
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
edm::EDGetTokenT< edm::ValueMap< reco::PhotonRef > > valMapPFCandToPhoton_

Member Data Documentation

edm::ParameterSet ParticleBasedIsoProducer::conf_
private

Definition at line 31 of file ParticleBasedIsoProducer.h.

Referenced by beginRun(), and ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::electronCollection_
private

Definition at line 33 of file ParticleBasedIsoProducer.h.

edm::InputTag ParticleBasedIsoProducer::electronProducer_
private

Definition at line 38 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

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

Definition at line 43 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::InputTag ParticleBasedIsoProducer::electronTmpProducer_
private

Definition at line 39 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

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

Definition at line 44 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

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

Definition at line 46 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

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

Definition at line 45 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::photonCollection_
private

Definition at line 32 of file ParticleBasedIsoProducer.h.

edm::InputTag ParticleBasedIsoProducer::photonProducer_
private

Definition at line 35 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

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

Definition at line 41 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

edm::InputTag ParticleBasedIsoProducer::photonTmpProducer_
private

Definition at line 36 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

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

Definition at line 42 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

PfBlockBasedIsolation* ParticleBasedIsoProducer::thePFBlockBasedIsolation_
private

Definition at line 55 of file ParticleBasedIsoProducer.h.

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

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

Definition at line 48 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

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

Definition at line 47 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::valueMapElePFCandIso_
private

Definition at line 53 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().

std::string ParticleBasedIsoProducer::valueMapPFCandEle_
private

Definition at line 52 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::valueMapPFCandPhoton_
private

Definition at line 50 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer().

std::string ParticleBasedIsoProducer::valueMapPhoPFCandIso_
private

Definition at line 51 of file ParticleBasedIsoProducer.h.

Referenced by ParticleBasedIsoProducer(), and produce().