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

Constructor & Destructor Documentation

PFBlockBasedIsolation::PFBlockBasedIsolation ( )

Definition at line 24 of file PFBlockBasedIsolation.cc.

24  {
25  // Default Constructor.
26 }
PFBlockBasedIsolation::~PFBlockBasedIsolation ( )

Definition at line 32 of file PFBlockBasedIsolation.cc.

33 {
34 
35 }

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

References coneSize_, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, and elementPassesCleaning().

Referenced by ParticleBasedIsoProducer::produce().

45  {
46 
47  std::vector<reco::PFCandidateRef> myVec;
48 
49  math::XYZVector candidateMomentum(p4.px(),p4.py(),p4.pz());
50  math::XYZVector candidateDirection=candidateMomentum.Unit();
51 
52  const reco::PFCandidate::ElementsInBlocks& theElementsInpfEGcand = (*pfEGCand).elementsInBlocks();
53  reco::PFCandidate::ElementsInBlocks::const_iterator ieg = theElementsInpfEGcand.begin();
54  const reco::PFBlockRef egblock = ieg->first;
55 
56 
57  unsigned nObj = pfCandidateHandle->size();
58  for(unsigned int lCand=0; lCand < nObj; lCand++) {
59 
60  reco::PFCandidateRef pfCandRef(reco::PFCandidateRef(pfCandidateHandle,lCand));
61 
62  float dR = 0.0;
63  if( coneSize_ < 10.0 ) {
64  dR = deltaR(candidateDirection.Eta(), candidateDirection.Phi(), pfCandRef->eta(), pfCandRef->phi());
65  if ( dR> coneSize_ ) continue;
66  }
67 
68  const reco::PFCandidate::ElementsInBlocks& theElementsInPFcand = pfCandRef->elementsInBlocks();
69 
70  bool elementFound=false;
71  for (reco::PFCandidate::ElementsInBlocks::const_iterator ipf = theElementsInPFcand.begin(); ipf<theElementsInPFcand.end(); ++ipf) {
72 
73  if ( ipf->first == egblock && !elementFound ) {
74 
75  for (ieg = theElementsInpfEGcand.begin(); ieg<theElementsInpfEGcand.end(); ++ieg) {
76  if ( ipf->second == ieg->second && !elementFound ) {
77  if(elementPassesCleaning(pfCandRef,pfEGCand)){
78  myVec.push_back(pfCandRef);
79  elementFound=true;
80  }
81  }
82  }
83 
84 
85 
86  }
87  }
88 
89 
90 
91  }
92 
93 
94 
95  return myVec;
96 
97 
98 
99  }
bool elementPassesCleaning(const reco::PFCandidateRef &pfCand, const reco::PFCandidateRef &pfEGCand)
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:386
double p4[4]
Definition: TauolaWrapper.h:92
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
bool PFBlockBasedIsolation::elementPassesCleaning ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 102 of file PFBlockBasedIsolation.cc.

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

Referenced by calculate().

103 {
104  if(pfCand->particleId()==reco::PFCandidate::h) return passesCleaningChargedHadron(pfCand,pfEGCand);
105  else if(pfCand->particleId()==reco::PFCandidate::h0) return passesCleaningNeutralHadron(pfCand,pfEGCand);
106  else if(pfCand->particleId()==reco::PFCandidate::gamma) return passesCleaningPhoton(pfCand,pfEGCand);
107  else return true; //doesnt really matter here as if its not a photon,neutral or charged it wont be included in isolation
108 }
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 149 of file PFBlockBasedIsolation.cc.

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

Referenced by passesCleaningPhoton().

150 {
151  float maxECALEt =-1;
152  const reco::PFBlockElement* maxEtECALCluster=nullptr;
153  const reco::PFCandidate::ElementsInBlocks& elementsInPFCand = pfCand.elementsInBlocks();
154  for(auto& elemIndx : elementsInPFCand){
155  const reco::PFBlockElement* elem = elemIndx.second<elemIndx.first->elements().size() ? &elemIndx.first->elements()[elemIndx.second] : nullptr;
156  if(elem && elem->type()==reco::PFBlockElement::ECAL && elem->clusterRef()->pt()>maxECALEt){
157  maxECALEt = elem->clusterRef()->pt();
158  maxEtECALCluster = elem;
159  }
160 
161  }
162  return dynamic_cast<const reco::PFBlockElementCluster*>(maxEtECALCluster);
163 
164 }
Abstract base class for a PFBlock element (track, cluster...)
virtual const PFClusterRef & clusterRef() const
Type type() const
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:386
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:682
bool PFBlockBasedIsolation::passesCleaningChargedHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 111 of file PFBlockBasedIsolation.cc.

Referenced by elementPassesCleaning().

112 {
113  return true;
114 }
bool PFBlockBasedIsolation::passesCleaningNeutralHadron ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 119 of file PFBlockBasedIsolation.cc.

Referenced by elementPassesCleaning().

120 {
121  return true;
122 }
bool PFBlockBasedIsolation::passesCleaningPhoton ( const reco::PFCandidateRef pfCand,
const reco::PFCandidateRef pfEGCand 
)
private

Definition at line 125 of file PFBlockBasedIsolation.cc.

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

Referenced by elementPassesCleaning().

126 {
127  bool passesCleaning=false;
128  const reco::PFBlockElementCluster* ecalClusWithMaxEt = getHighestEtECALCluster(*pfCand);
129  if(ecalClusWithMaxEt){
130  if(ecalClusWithMaxEt->superClusterRef().isNonnull() &&
131  ecalClusWithMaxEt->superClusterRef()->seed()->seed()==pfEGCand->superClusterRef()->seed()->seed()){ //being sure to match, some concerned about different collections, shouldnt be but to be safe
132  passesCleaning=true;
133  }else{
134  for(auto cluster : pfEGCand->superClusterRef()->clusters()){
135  //the PF clusters there are in two different collections so cant reference match
136  //but we can match on the seed id, no clusters can share a seed so if the seeds are
137  //equal, it must be the same cluster
138  if(ecalClusWithMaxEt->clusterRef()->seed()==cluster->seed()) {
139  passesCleaning=true;
140  }
141  }//end of loop over clusters
142  }
143  }//end of null check for highest ecal cluster
144  return passesCleaning;
145 
146 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
const PFClusterRef & clusterRef() const
const SuperClusterRef & superClusterRef() const
const reco::PFBlockElementCluster * getHighestEtECALCluster(const reco::PFCandidate &pfCand)
void PFBlockBasedIsolation::setup ( const edm::ParameterSet conf)

Definition at line 38 of file PFBlockBasedIsolation.cc.

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

Referenced by ParticleBasedIsoProducer::beginRun().

38  {
39 
40  coneSize_ = conf.getParameter<double>("coneSize");
41 
42 }
T getParameter(std::string const &) const

Member Data Documentation

double PFBlockBasedIsolation::coneSize_
private

Definition at line 68 of file PFBlockBasedIsolation.h.

Referenced by calculate(), and setup().