CMS 3D CMS Logo

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

#include <EgammaHLTPFPhotonIsolationProducer.h>

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

Public Member Functions

 EgammaHLTPFPhotonIsolationProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTPFPhotonIsolationProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Attributes

bool doRhoCorrection_
 
double drMax_
 
double drVetoBarrel_
 
double drVetoEndcap_
 
float effectiveAreaBarrel_
 
float effectiveAreaEndcap_
 
edm::EDGetTokenT< reco::ElectronCollectionelectronProducer_
 
double energyBarrel_
 
double energyEndcap_
 
double etaStripBarrel_
 
double etaStripEndcap_
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidateProducer_
 
int pfToUse_
 
edm::EDGetTokenT< reco::RecoEcalCandidateCollectionrecoEcalCandidateProducer_
 
float rhoMax_
 
edm::EDGetTokenT< double > rhoProducer_
 
float rhoScale_
 
bool useSCRefs_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 32 of file EgammaHLTPFPhotonIsolationProducer.h.

Constructor & Destructor Documentation

EgammaHLTPFPhotonIsolationProducer::EgammaHLTPFPhotonIsolationProducer ( const edm::ParameterSet config)
explicit
Author
Matteo Sani (UCSD)

$Id:

Definition at line 32 of file EgammaHLTPFPhotonIsolationProducer.cc.

References doRhoCorrection_, drMax_, drVetoBarrel_, drVetoEndcap_, effectiveAreaBarrel_, effectiveAreaEndcap_, electronProducer_, energyBarrel_, energyEndcap_, etaStripBarrel_, etaStripEndcap_, edm::ParameterSet::getParameter(), pfCandidateProducer_, pfToUse_, recoEcalCandidateProducer_, rhoMax_, rhoProducer_, rhoScale_, and useSCRefs_.

32  {
33 
34  pfCandidateProducer_ = consumes<reco::PFCandidateCollection>(config.getParameter<edm::InputTag>("pfCandidatesProducer"));
35 
36  useSCRefs_ = config.getParameter<bool>("useSCRefs");
37 
38  drMax_ = config.getParameter<double>("drMax");
39  drVetoBarrel_ = config.getParameter<double>("drVetoBarrel");
40  drVetoEndcap_ = config.getParameter<double>("drVetoEndcap");
41  etaStripBarrel_ = config.getParameter<double>("etaStripBarrel");
42  etaStripEndcap_ = config.getParameter<double>("etaStripEndcap");
43  energyBarrel_ = config.getParameter<double>("energyBarrel");
44  energyEndcap_ = config.getParameter<double>("energyEndcap");
45  pfToUse_ = config.getParameter<int>("pfCandidateType");
46 
47  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
48  if (doRhoCorrection_)
49  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
50 
51  rhoMax_ = config.getParameter<double>("rhoMax");
52  rhoScale_ = config.getParameter<double>("rhoScale");
53  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
54  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
55 
56  if(useSCRefs_) {
57  produces < reco::RecoEcalCandidateIsolationMap >();
58  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
59  } else {
60  produces < reco::ElectronIsolationMap >();
61  electronProducer_ = consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("electronProducer"));
62  }
63 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateProducer_
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
EgammaHLTPFPhotonIsolationProducer::~EgammaHLTPFPhotonIsolationProducer ( )
inlineoverride

Definition at line 35 of file EgammaHLTPFPhotonIsolationProducer.h.

References fillDescriptions().

35 {};

Member Function Documentation

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

Definition at line 65 of file EgammaHLTPFPhotonIsolationProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

65  {
67  desc.add<edm::InputTag>("electronProducer", edm::InputTag("hltEle27WP80PixelMatchElectronsL1SeededPF"));
68  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
69  desc.add<edm::InputTag>("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg"));
70  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
71  desc.add<bool>("doRhoCorrection", false);
72  desc.add<double>("rhoMax", 9.9999999E7);
73  desc.add<double>("rhoScale", 1.0);
74  desc.add<double>("effectiveAreaBarrel", 0.101);
75  desc.add<double>("effectiveAreaEndcap", 0.046);
76  desc.add<bool>("useSCRefs", false);
77  desc.add<double>("drMax", 0.3);
78  desc.add<double>("drVetoBarrel", 0.0);
79  desc.add<double>("drVetoEndcap", 0.0);
80  desc.add<double>("etaStripBarrel", 0.0);
81  desc.add<double>("etaStripEndcap", 0.0);
82  desc.add<double>("energyBarrel", 0.0);
83  desc.add<double>("energyEndcap", 0.0);
84  desc.add<int>("pfCandidateType", 4);
85  descriptions.add(("hltEgammaHLTPFPhotonIsolationProducer"), desc);
86 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void EgammaHLTPFPhotonIsolationProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 88 of file EgammaHLTPFPhotonIsolationProducer.cc.

References b, reco::PFBlockElement::clusterRef(), deltaR(), particleFlow_cfi::dEta, doRhoCorrection_, PATTauDiscriminationAgainstElectronDeadECAL_cfi::dR, drMax_, drVetoBarrel_, drVetoEndcap_, reco::PFBlockElement::ECAL, effectiveAreaBarrel_, effectiveAreaEndcap_, electronProducer_, allElectronIsolations_cfi::elements, energyBarrel_, energyEndcap_, etaStripBarrel_, etaStripEndcap_, edm::Event::getByToken(), mps_fire::i, edm::AssociationMap< Tag >::insert(), edm::Ref< C, T, F >::isNull(), pfCandidateProducer_, pfToUse_, edm::Handle< T >::product(), edm::Event::put(), recoEcalCandidateProducer_, rho, rhoMax_, rhoProducer_, rhoScale_, reco::PFBlockElement::type(), and useSCRefs_.

88  {
89 
90  edm::Handle<double> rhoHandle;
91  double rho = 0.0;
92  if (doRhoCorrection_) {
93  iEvent.getByToken(rhoProducer_, rhoHandle);
94  rho = *(rhoHandle.product());
95  }
96 
97  if (rho > rhoMax_)
98  rho = rhoMax_;
99 
100  rho = rho*rhoScale_;
101 
105 
106  iEvent.getByToken(pfCandidateProducer_, pfHandle);
107 
108  if(useSCRefs_) {
109 
110  iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle);
111  reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoecalcandHandle);
112 
113  float dRVeto = -1.;
114  float etaStrip = -1;
115 
116  for (unsigned int iReco = 0; iReco < recoecalcandHandle->size(); iReco++) {
117  reco::RecoEcalCandidateRef candRef(recoecalcandHandle, iReco);
118 
119  if (fabs(candRef->eta()) < 1.479) {
120  dRVeto = drVetoBarrel_;
121  etaStrip = etaStripBarrel_;
122  } else {
123  dRVeto = drVetoEndcap_;
124  etaStrip = etaStripEndcap_;
125  }
126 
127  float sum = 0;
128 
129  // Loop over the PFCandidates
130  for(unsigned i=0; i<pfHandle->size(); i++) {
131  reco::PFCandidateRef pfc(pfHandle, i);
132 
133  //require that the PFCandidate is a photon
134  if (pfc->particleId() == pfToUse_) {
135 
136  if (fabs(candRef->eta()) < 1.479) {
137  if (fabs(pfc->pt()) < energyBarrel_)
138  continue;
139  } else {
140  if (fabs(pfc->energy()) < energyEndcap_)
141  continue;
142  }
143 
144  // Shift the RecoEcalCandidate direction vector according to the PF vertex
145  math::XYZPoint pfvtx = pfc->vertex();
146  math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - pfvtx.x(),
147  candRef->superCluster()->y() - pfvtx.y(),
148  candRef->superCluster()->z() - pfvtx.z());
149 
150  float dEta = fabs(candDirectionWrtVtx.Eta() - pfc->momentum().Eta());
151  if(dEta < etaStrip) continue;
152 
153  float dR = deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc->momentum().Eta(), pfc->momentum().Phi());
154  if(dR > drMax_ || dR < dRVeto) continue;
155 
156  // Exclude PF photons which clusters are part of the candidate
157  bool clusterOverlap = false;
158  for(unsigned b=0; b<pfc->elementsInBlocks().size(); b++){
159  reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first;
160  unsigned elementIndex = pfc->elementsInBlocks()[b].second;
161  if(blockRef.isNull()) continue;
162  const edm::OwnVector< reco::PFBlockElement >& elements = blockRef->elements();
163  const reco::PFBlockElement& pfbe(elements[elementIndex]);
164  if( pfbe.type() == reco::PFBlockElement::ECAL ){
165  const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef();
166  if(myPFClusterRef.isNull()) continue;
167  for(reco::CaloCluster_iterator it = candRef->superCluster()->clustersBegin(); it != candRef->superCluster()->clustersEnd(); ++it){
168  if( myPFClusterRef->seed() == (*it)->seed() ){
169  clusterOverlap = true;
170  break;
171  }
172  }
173  }
174  if(clusterOverlap) break;
175  }
176  if(clusterOverlap) continue;
177 
178  sum += pfc->pt();
179  }
180  }
181 
182  if (doRhoCorrection_) {
183  if (fabs(candRef->eta()) < 1.479)
184  sum = sum - rho*effectiveAreaBarrel_;
185  else
186  sum = sum - rho*effectiveAreaEndcap_;
187  }
188 
189  recoEcalCandMap.insert(candRef, sum);
190  }
191  iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandMap));
192 
193  } else {
194 
195  iEvent.getByToken(electronProducer_,electronHandle);
196  reco::ElectronIsolationMap eleMap(electronHandle);
197 
198  float dRVeto = -1.;
199  float etaStrip = -1;
200 
201  for(unsigned int iEl=0; iEl<electronHandle->size(); iEl++) {
202  reco::ElectronRef eleRef(electronHandle, iEl);
203 
204  if (fabs(eleRef->eta()) < 1.479) {
205  dRVeto = drVetoBarrel_;
206  etaStrip = etaStripBarrel_;
207  } else {
208  dRVeto = drVetoEndcap_;
209  etaStrip = etaStripEndcap_;
210  }
211 
212  float sum = 0;
213 
214  // Loop over the PFCandidates
215  for(unsigned i=0; i<pfHandle->size(); i++) {
216  reco::PFCandidateRef pfc(pfHandle, i);
217 
218  //require that the PFCandidate is a photon
219  if (pfc->particleId() == pfToUse_) {
220 
221  if (fabs(eleRef->eta()) < 1.479) {
222  if (fabs(pfc->pt()) < energyBarrel_)
223  continue;
224  } else {
225  if (fabs(pfc->energy()) < energyEndcap_)
226  continue;
227  }
228 
229  float dEta = fabs(eleRef->eta() - pfc->momentum().Eta());
230  if(dEta < etaStrip)
231  continue;
232 
233  float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc->momentum().Eta(), pfc->momentum().Phi());
234  if(dR > drMax_ || dR < dRVeto)
235  continue;
236 
237  // Exclude PF photons which clusters are part of the electron supercluster
238  bool clusterOverlap = false;
239  for(unsigned b=0; b<pfc->elementsInBlocks().size(); b++){
240  reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first;
241  unsigned elementIndex = pfc->elementsInBlocks()[b].second;
242  if(blockRef.isNull()) continue;
243  const edm::OwnVector< reco::PFBlockElement >& elements = blockRef->elements();
244  const reco::PFBlockElement& pfbe(elements[elementIndex]);
245  if( pfbe.type() == reco::PFBlockElement::ECAL ){
246  const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef();
247  if(myPFClusterRef.isNull()) continue;
248  for(reco::CaloCluster_iterator it = eleRef->superCluster()->clustersBegin(); it != eleRef->superCluster()->clustersEnd(); ++it){
249  if( myPFClusterRef->seed() == (*it)->seed() ){
250  clusterOverlap = true;
251  break;
252  }
253  }
254  }
255  if(clusterOverlap) break;
256  }
257  if(clusterOverlap) continue;
258 
259  sum += pfc->pt();
260  }
261  }
262 
263  if (doRhoCorrection_) {
264  if (fabs(eleRef->eta()) < 1.479)
265  sum = sum - rho*effectiveAreaBarrel_;
266  else
267  sum = sum - rho*effectiveAreaEndcap_;
268  }
269 
270  eleMap.insert(eleRef, sum);
271  }
272  iEvent.put(std::make_unique<reco::ElectronIsolationMap>(eleMap));
273  }
274 }
Abstract base class for a PFBlock element (track, cluster...)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateProducer_
bool isNull() const
Checks for null.
Definition: Ref.h:250
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
T const * product() const
Definition: Handle.h:81
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double b
Definition: hdecay.h:120
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_

Member Data Documentation

bool EgammaHLTPFPhotonIsolationProducer::doRhoCorrection_
private
double EgammaHLTPFPhotonIsolationProducer::drMax_
private
double EgammaHLTPFPhotonIsolationProducer::drVetoBarrel_
private
double EgammaHLTPFPhotonIsolationProducer::drVetoEndcap_
private
float EgammaHLTPFPhotonIsolationProducer::effectiveAreaBarrel_
private
float EgammaHLTPFPhotonIsolationProducer::effectiveAreaEndcap_
private
edm::EDGetTokenT<reco::ElectronCollection> EgammaHLTPFPhotonIsolationProducer::electronProducer_
private
double EgammaHLTPFPhotonIsolationProducer::energyBarrel_
private
double EgammaHLTPFPhotonIsolationProducer::energyEndcap_
private
double EgammaHLTPFPhotonIsolationProducer::etaStripBarrel_
private
double EgammaHLTPFPhotonIsolationProducer::etaStripEndcap_
private
edm::EDGetTokenT<reco::PFCandidateCollection> EgammaHLTPFPhotonIsolationProducer::pfCandidateProducer_
private
int EgammaHLTPFPhotonIsolationProducer::pfToUse_
private
edm::EDGetTokenT<reco::RecoEcalCandidateCollection> EgammaHLTPFPhotonIsolationProducer::recoEcalCandidateProducer_
private
float EgammaHLTPFPhotonIsolationProducer::rhoMax_
private
edm::EDGetTokenT<double> EgammaHLTPFPhotonIsolationProducer::rhoProducer_
private
float EgammaHLTPFPhotonIsolationProducer::rhoScale_
private
bool EgammaHLTPFPhotonIsolationProducer::useSCRefs_
private