CMS 3D CMS Logo

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

#include <PFBlockBasedIsolation.h>

Public Member Functions

std::vector< reco::PFCandidateRefcalculate (math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle)
 
 PFBlockBasedIsolation ()
 
void setup (const edm::ParameterSet &conf)
 
 ~PFBlockBasedIsolation ()
 

Private Member Functions

bool elementPassesCleaning (const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
 
const reco::PFBlockElementClustergetHighestEtECALCluster (const reco::PFCandidate &pfCand)
 
bool passesCleaningChargedHadron (const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
 
bool passesCleaningNeutralHadron (const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
 
bool passesCleaningPhoton (const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
 

Private Attributes

double coneSize_
 

Detailed Description

Definition at line 33 of file PFBlockBasedIsolation.h.

Constructor & Destructor Documentation

◆ PFBlockBasedIsolation()

PFBlockBasedIsolation::PFBlockBasedIsolation ( )

Definition at line 22 of file PFBlockBasedIsolation.cc.

22  {
23  // Default Constructor.
24 }

◆ ~PFBlockBasedIsolation()

PFBlockBasedIsolation::~PFBlockBasedIsolation ( )

Definition at line 27 of file PFBlockBasedIsolation.cc.

27 {}

Member Function Documentation

◆ calculate()

std::vector< reco::PFCandidateRef > PFBlockBasedIsolation::calculate ( math::XYZTLorentzVectorD  p4,
const reco::PFCandidateRef  pfEGCand,
const edm::Handle< reco::PFCandidateCollection pfCandidateHandle 
)

Definition at line 31 of file PFBlockBasedIsolation.cc.

34  {
35  std::vector<reco::PFCandidateRef> myVec;
36 
37  math::XYZVector candidateMomentum(p4.px(), p4.py(), p4.pz());
38  math::XYZVector candidateDirection = candidateMomentum.Unit();
39 
40  const reco::PFCandidate::ElementsInBlocks& theElementsInpfEGcand = (*pfEGCand).elementsInBlocks();
41  reco::PFCandidate::ElementsInBlocks::const_iterator ieg = theElementsInpfEGcand.begin();
42  const reco::PFBlockRef egblock = ieg->first;
43 
44  unsigned nObj = pfCandidateHandle->size();
45  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
46  reco::PFCandidateRef pfCandRef(reco::PFCandidateRef(pfCandidateHandle, lCand));
47 
48  float dR = 0.0;
49  if (coneSize_ < 10.0) {
50  dR = deltaR(candidateDirection.Eta(), candidateDirection.Phi(), pfCandRef->eta(), pfCandRef->phi());
51  if (dR > coneSize_)
52  continue;
53  }
54 
55  const reco::PFCandidate::ElementsInBlocks& theElementsInPFcand = pfCandRef->elementsInBlocks();
56 
57  bool elementFound = false;
58  for (reco::PFCandidate::ElementsInBlocks::const_iterator ipf = theElementsInPFcand.begin();
59  ipf < theElementsInPFcand.end();
60  ++ipf) {
61  if (ipf->first == egblock && !elementFound) {
62  for (ieg = theElementsInpfEGcand.begin(); ieg < theElementsInpfEGcand.end(); ++ieg) {
63  if (ipf->second == ieg->second && !elementFound) {
64  if (elementPassesCleaning(pfCandRef, pfEGCand)) {
65  myVec.push_back(pfCandRef);
66  elementFound = true;
67  }
68  }
69  }
70  }
71  }
72  }
73 
74  return myVec;
75 }

References coneSize_, PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, elementPassesCleaning(), and p4.

Referenced by ParticleBasedIsoProducer::produce().

◆ elementPassesCleaning()

bool PFBlockBasedIsolation::elementPassesCleaning ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 77 of file PFBlockBasedIsolation.cc.

78  {
79  if (pfCand->particleId() == reco::PFCandidate::h)
80  return passesCleaningChargedHadron(pfCand, pfEGCand);
81  else if (pfCand->particleId() == reco::PFCandidate::h0)
82  return passesCleaningNeutralHadron(pfCand, pfEGCand);
83  else if (pfCand->particleId() == reco::PFCandidate::gamma)
84  return passesCleaningPhoton(pfCand, pfEGCand);
85  else
86  return true; //doesnt really matter here as if its not a photon,neutral or charged it wont be included in isolation
87 }

References reco::PFCandidate::gamma, reco::PFCandidate::h, reco::PFCandidate::h0, passesCleaningChargedHadron(), passesCleaningNeutralHadron(), and passesCleaningPhoton().

Referenced by calculate().

◆ getHighestEtECALCluster()

const reco::PFBlockElementCluster * PFBlockBasedIsolation::getHighestEtECALCluster ( const reco::PFCandidate pfCand)
private

Definition at line 129 of file PFBlockBasedIsolation.cc.

129  {
130  float maxECALEt = -1;
131  const reco::PFBlockElement* maxEtECALCluster = nullptr;
132  const reco::PFCandidate::ElementsInBlocks& elementsInPFCand = pfCand.elementsInBlocks();
133  for (auto& elemIndx : elementsInPFCand) {
134  const reco::PFBlockElement* elem =
135  elemIndx.second < elemIndx.first->elements().size() ? &elemIndx.first->elements()[elemIndx.second] : nullptr;
136  if (elem && elem->type() == reco::PFBlockElement::ECAL && elem->clusterRef()->pt() > maxECALEt) {
137  maxECALEt = elem->clusterRef()->pt();
138  maxEtECALCluster = elem;
139  }
140  }
141  return dynamic_cast<const reco::PFBlockElementCluster*>(maxEtECALCluster);
142 }

References reco::PFBlockElement::clusterRef(), reco::PFBlockElement::ECAL, reco::PFCandidate::elementsInBlocks(), and reco::PFBlockElement::type().

Referenced by passesCleaningPhoton().

◆ passesCleaningChargedHadron()

bool PFBlockBasedIsolation::passesCleaningChargedHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 90 of file PFBlockBasedIsolation.cc.

91  {
92  return true;
93 }

Referenced by elementPassesCleaning().

◆ passesCleaningNeutralHadron()

bool PFBlockBasedIsolation::passesCleaningNeutralHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 98 of file PFBlockBasedIsolation.cc.

99  {
100  return true;
101 }

Referenced by elementPassesCleaning().

◆ passesCleaningPhoton()

bool PFBlockBasedIsolation::passesCleaningPhoton ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 104 of file PFBlockBasedIsolation.cc.

105  {
106  bool passesCleaning = false;
107  const reco::PFBlockElementCluster* ecalClusWithMaxEt = getHighestEtECALCluster(*pfCand);
108  if (ecalClusWithMaxEt) {
109  if (ecalClusWithMaxEt->superClusterRef().isNonnull() &&
110  ecalClusWithMaxEt->superClusterRef()->seed()->seed() ==
111  pfEGCand->superClusterRef()
112  ->seed()
113  ->seed()) { //being sure to match, some concerned about different collections, shouldnt be but to be safe
114  passesCleaning = true;
115  } else {
116  for (auto cluster : pfEGCand->superClusterRef()->clusters()) {
117  //the PF clusters there are in two different collections so cant reference match
118  //but we can match on the seed id, no clusters can share a seed so if the seeds are
119  //equal, it must be the same cluster
120  if (ecalClusWithMaxEt->clusterRef()->seed() == cluster->seed()) {
121  passesCleaning = true;
122  }
123  } //end of loop over clusters
124  }
125  } //end of null check for highest ecal cluster
126  return passesCleaning;
127 }

References reco::PFBlockElementCluster::clusterRef(), getHighestEtECALCluster(), edm::Ref< C, T, F >::isNonnull(), and reco::PFBlockElementCluster::superClusterRef().

Referenced by elementPassesCleaning().

◆ setup()

void PFBlockBasedIsolation::setup ( const edm::ParameterSet conf)

Definition at line 29 of file PFBlockBasedIsolation.cc.

29 { coneSize_ = conf.getParameter<double>("coneSize"); }

References coneSize_, and edm::ParameterSet::getParameter().

Referenced by ParticleBasedIsoProducer::beginRun().

Member Data Documentation

◆ coneSize_

double PFBlockBasedIsolation::coneSize_
private

Definition at line 55 of file PFBlockBasedIsolation.h.

Referenced by calculate(), and setup().

PFBlockBasedIsolation::getHighestEtECALCluster
const reco::PFBlockElementCluster * getHighestEtECALCluster(const reco::PFCandidate &pfCand)
Definition: PFBlockBasedIsolation.cc:129
reco::PFCandidate::h
Definition: PFCandidate.h:45
PFBlockBasedIsolation::passesCleaningPhoton
bool passesCleaningPhoton(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
Definition: PFBlockBasedIsolation.cc:104
reco::PFCandidate::elementsInBlocks
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:636
PFBlockBasedIsolation::passesCleaningNeutralHadron
bool passesCleaningNeutralHadron(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
Definition: PFBlockBasedIsolation.cc:98
edm::Ref< PFBlockCollection >
reco::PFBlockElementCluster::superClusterRef
const SuperClusterRef & superClusterRef() const
Definition: PFBlockElementCluster.h:30
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
reco::PFCandidate::ElementsInBlocks
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:378
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
p4
double p4[4]
Definition: TauolaWrapper.h:92
reco::PFCandidate::gamma
Definition: PFCandidate.h:48
PFBlockBasedIsolation::coneSize_
double coneSize_
Definition: PFBlockBasedIsolation.h:55
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
PFBlockBasedIsolation::elementPassesCleaning
bool elementPassesCleaning(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
Definition: PFBlockBasedIsolation.cc:77
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::PFCandidate::h0
Definition: PFCandidate.h:49
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
reco::PFBlockElementCluster::clusterRef
const PFClusterRef & clusterRef() const override
Definition: PFBlockElementCluster.h:29
reco::PFBlockElement::type
Type type() const
Definition: PFBlockElement.h:69
PFBlockBasedIsolation::passesCleaningChargedHadron
bool passesCleaningChargedHadron(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
Definition: PFBlockBasedIsolation.cc:90
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
reco::PFBlockElement::clusterRef
virtual const PFClusterRef & clusterRef() const
Definition: PFBlockElement.h:90