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 19 of file PFBlockBasedIsolation.h.

Constructor & Destructor Documentation

◆ PFBlockBasedIsolation()

PFBlockBasedIsolation::PFBlockBasedIsolation ( )

Definition at line 12 of file PFBlockBasedIsolation.cc.

12  {
13  // Default Constructor.
14 }

◆ ~PFBlockBasedIsolation()

PFBlockBasedIsolation::~PFBlockBasedIsolation ( )

Definition at line 17 of file PFBlockBasedIsolation.cc.

17 {}

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 21 of file PFBlockBasedIsolation.cc.

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

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

◆ elementPassesCleaning()

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

Definition at line 67 of file PFBlockBasedIsolation.cc.

68  {
69  if (pfCand->particleId() == reco::PFCandidate::h)
70  return passesCleaningChargedHadron(pfCand, pfEGCand);
71  else if (pfCand->particleId() == reco::PFCandidate::h0)
72  return passesCleaningNeutralHadron(pfCand, pfEGCand);
73  else if (pfCand->particleId() == reco::PFCandidate::gamma)
74  return passesCleaningPhoton(pfCand, pfEGCand);
75  else
76  return true; //doesnt really matter here as if its not a photon,neutral or charged it wont be included in isolation
77 }

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 119 of file PFBlockBasedIsolation.cc.

119  {
120  float maxECALEt = -1;
121  const reco::PFBlockElement* maxEtECALCluster = nullptr;
122  const reco::PFCandidate::ElementsInBlocks& elementsInPFCand = pfCand.elementsInBlocks();
123  for (auto& elemIndx : elementsInPFCand) {
124  const reco::PFBlockElement* elem =
125  elemIndx.second < elemIndx.first->elements().size() ? &elemIndx.first->elements()[elemIndx.second] : nullptr;
126  if (elem && elem->type() == reco::PFBlockElement::ECAL && elem->clusterRef()->pt() > maxECALEt) {
127  maxECALEt = elem->clusterRef()->pt();
128  maxEtECALCluster = elem;
129  }
130  }
131  return dynamic_cast<const reco::PFBlockElementCluster*>(maxEtECALCluster);
132 }

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 80 of file PFBlockBasedIsolation.cc.

81  {
82  return true;
83 }

Referenced by elementPassesCleaning().

◆ passesCleaningNeutralHadron()

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

Definition at line 88 of file PFBlockBasedIsolation.cc.

89  {
90  return true;
91 }

Referenced by elementPassesCleaning().

◆ passesCleaningPhoton()

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

Definition at line 94 of file PFBlockBasedIsolation.cc.

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

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 19 of file PFBlockBasedIsolation.cc.

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

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

Member Data Documentation

◆ coneSize_

double PFBlockBasedIsolation::coneSize_
private

Definition at line 41 of file PFBlockBasedIsolation.h.

Referenced by calculate(), and setup().

PFBlockBasedIsolation::getHighestEtECALCluster
const reco::PFBlockElementCluster * getHighestEtECALCluster(const reco::PFCandidate &pfCand)
Definition: PFBlockBasedIsolation.cc:119
reco::PFCandidate::h
Definition: PFCandidate.h:46
PFBlockBasedIsolation::passesCleaningPhoton
bool passesCleaningPhoton(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
Definition: PFBlockBasedIsolation.cc:94
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:88
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:379
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:49
PFBlockBasedIsolation::coneSize_
double coneSize_
Definition: PFBlockBasedIsolation.h:41
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:67
reco::PFCandidate::h0
Definition: PFCandidate.h:50
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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:80
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
reco::PFBlockElement::clusterRef
virtual const PFClusterRef & clusterRef() const
Definition: PFBlockElement.h:90