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 ( )

Definition at line 22 of file PFBlockBasedIsolation.cc.

22  {
23  // Default Constructor.
24 }
PFBlockBasedIsolation::~PFBlockBasedIsolation ( )

Definition at line 27 of file PFBlockBasedIsolation.cc.

27 {}

Member Function Documentation

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.

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

Referenced by ParticleBasedIsoProducer::produce().

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 }
bool elementPassesCleaning(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:378
double p4[4]
Definition: TauolaWrapper.h:92
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
bool PFBlockBasedIsolation::elementPassesCleaning ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 77 of file PFBlockBasedIsolation.cc.

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

Referenced by calculate().

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 }
bool passesCleaningNeutralHadron(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
bool passesCleaningPhoton(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
bool passesCleaningChargedHadron(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
const reco::PFBlockElementCluster * PFBlockBasedIsolation::getHighestEtECALCluster ( const reco::PFCandidate pfCand)
private

Definition at line 129 of file PFBlockBasedIsolation.cc.

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

Referenced by passesCleaningPhoton().

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 }
Abstract base class for a PFBlock element (track, cluster...)
virtual const PFClusterRef & clusterRef() const
Type type() const
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:378
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:636
bool PFBlockBasedIsolation::passesCleaningChargedHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 90 of file PFBlockBasedIsolation.cc.

Referenced by elementPassesCleaning().

91  {
92  return true;
93 }
bool PFBlockBasedIsolation::passesCleaningNeutralHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 98 of file PFBlockBasedIsolation.cc.

Referenced by elementPassesCleaning().

99  {
100  return true;
101 }
bool PFBlockBasedIsolation::passesCleaningPhoton ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 104 of file PFBlockBasedIsolation.cc.

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

Referenced by elementPassesCleaning().

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 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const PFClusterRef & clusterRef() const override
const SuperClusterRef & superClusterRef() const
const reco::PFBlockElementCluster * getHighestEtECALCluster(const reco::PFCandidate &pfCand)
void PFBlockBasedIsolation::setup ( const edm::ParameterSet conf)

Definition at line 29 of file PFBlockBasedIsolation.cc.

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

Referenced by ParticleBasedIsoProducer::beginRun().

29 { coneSize_ = conf.getParameter<double>("coneSize"); }
T getParameter(std::string const &) const

Member Data Documentation

double PFBlockBasedIsolation::coneSize_
private

Definition at line 55 of file PFBlockBasedIsolation.h.

Referenced by calculate(), and setup().