CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
reco::tau::RecoTauIsolationMasking Class Reference

#include <RecoTauIsolationMasking.h>

Classes

struct  IsoMaskResult
 

Public Member Functions

IsoMaskResult mask (const reco::PFTau &) const
 Return a new isolation collections with masking applied. More...
 
 RecoTauIsolationMasking (const edm::ParameterSet &pset)
 
void setMaxSigmas (double maxSigmas)
 
 ~RecoTauIsolationMasking ()
 

Private Member Functions

bool inCone (const reco::PFCandidate &track, const reco::Candidate &cand) const
 
double resolution (const reco::Candidate &cand) const
 

Private Attributes

double ecalCone_
 
double finalHcalCone_
 
double hcalCone_
 
double maxSigmas_
 
std::unique_ptr< PFEnergyResolutionresolutions_
 

Detailed Description

Definition at line 24 of file RecoTauIsolationMasking.h.

Constructor & Destructor Documentation

reco::tau::RecoTauIsolationMasking::RecoTauIsolationMasking ( const edm::ParameterSet pset)

Definition at line 62 of file RecoTauIsolationMasking.cc.

References ecalCone_, finalHcalCone_, edm::ParameterSet::getParameter(), hcalCone_, and maxSigmas_.

64  ecalCone_ = pset.getParameter<double>("ecalCone");
65  hcalCone_ = pset.getParameter<double>("hcalCone");
66  finalHcalCone_ = pset.getParameter<double>("finalHcalCone");
67  maxSigmas_ = pset.getParameter<double>("maxSigmas");
68 }
T getParameter(std::string const &) const
std::unique_ptr< PFEnergyResolution > resolutions_
reco::tau::RecoTauIsolationMasking::~RecoTauIsolationMasking ( )

Definition at line 71 of file RecoTauIsolationMasking.cc.

71 {}

Member Function Documentation

bool reco::tau::RecoTauIsolationMasking::inCone ( const reco::PFCandidate track,
const reco::Candidate cand 
) const
private

Definition at line 161 of file RecoTauIsolationMasking.cc.

References funct::abs(), reco::deltaR(), ecalCone_, hcalCone_, reco::Candidate::p4(), reco::Candidate::pdgId(), and reco::PFCandidate::positionAtECALEntrance().

Referenced by mask(), and setMaxSigmas().

162  {
163  double openingDR = reco::deltaR(track.positionAtECALEntrance(), cand.p4());
164  if (cand.pdgId() == 130) {
165  return (openingDR < hcalCone_);
166  } else if (cand.pdgId() == 22 ||
167  abs(cand.pdgId()) == 11) {
168  return openingDR < ecalCone_;
169  } else {
170  edm::LogWarning("IsoMask::inCone (bad pf id)")
171  << "Unknown PF PDG ID: " << cand.pdgId();
172  }
173  return -1;
174 }
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:368
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
RecoTauIsolationMasking::IsoMaskResult reco::tau::RecoTauIsolationMasking::mask ( const reco::PFTau tau) const

Return a new isolation collections with masking applied.

Definition at line 74 of file RecoTauIsolationMasking.cc.

References popcon2dropbox::copy(), reco::Candidate::energy(), finalHcalCone_, reco::tau::RecoTauIsolationMasking::IsoMaskResult::gammas, reco::tau::RecoTauIsolationMasking::IsoMaskResult::h0s, inCone(), reco::PFTau::isolationGammaCands(), reco::PFTau::isolationNeutrHadrCands(), maxSigmas_, convertSQLitetoXML_cfg::output, resolution(), resolutions_, reco::PFTau::signalChargedHadrCands(), reco::PFTau::signalPFChargedHadrCands(), MCScenario_CRAFT1_22X::sorter(), mathSSE::sqrt(), square(), and HiIsolationCommonParameters_cff::track.

74  {
75  IsoMaskResult output;
76 
77  typedef std::list<reco::CandidatePtr> CandList;
78  // Copy original iso collections.
79  std::copy(tau.isolationGammaCands().begin(),
80  tau.isolationGammaCands().end(), std::back_inserter(output.gammas));
81  std::copy(tau.isolationNeutrHadrCands().begin(),
82  tau.isolationNeutrHadrCands().end(),
83  std::back_inserter(output.h0s));
84 
85  std::vector<CandList*> courses;
86  courses.push_back(&(output.h0s));
87  courses.push_back(&(output.gammas));
88  // Mask using each one of the tracks
89  for(auto const& track : tau.signalPFChargedHadrCands()) {
90  double trackerEnergy = track->energy();
91  double linkedEcalEnergy = track->ecalEnergy();
92  double linkedHcalEnergy = track->hcalEnergy();
93  math::XYZPointF posAtCalo = track->positionAtECALEntrance();
94  // Get the linked calo energies & their errors
95  double linkedSumErrSquared = 0;
96  linkedSumErrSquared += square(
97  resolutions_->getEnergyResolutionEm(linkedEcalEnergy, posAtCalo.eta()));
98  linkedSumErrSquared += square(
99  resolutions_->getEnergyResolutionHad(
100  linkedHcalEnergy, posAtCalo.eta(), posAtCalo.phi()));
101 
102  // energyDelta is the difference between associated Calo and tracker energy
103  double energyDelta = linkedEcalEnergy + linkedHcalEnergy - trackerEnergy;
104 
105  // Sort the neutral hadrons by DR to the track
106  //DRSorter sorter(track->p4());
108 
109  for(auto* course : courses) {
110  // Sort by deltaR to the current track
111  course->sort(sorter);
112  CandList::iterator toEatIter = course->begin();
113  // While there are still candidates to eat in this course and they are
114  // within the cone.
115  while (toEatIter != course->end()) {
116  const reco::Candidate& toEat = **toEatIter;
117  double toEatEnergy = toEat.energy();
118  double toEatErrorSq = square(resolution(toEat));
119  // Check if we can absorb this candidate into the track.
120  if (inCone(*track, **toEatIter) &&
121  (energyDelta + toEatEnergy)/std::sqrt(
122  linkedSumErrSquared + toEatErrorSq) < maxSigmas_ ) {
123  energyDelta += toEatEnergy;
124  linkedSumErrSquared += toEatErrorSq;
125  toEatIter = course->erase(toEatIter);
126  } else {
127  // otherwise skip to the next one
128  ++toEatIter;
129  }
130  }
131  }
132  }
133  // Filter out any final HCAL objects with in cones about the tracks.
134  // This removes upward fluctuating HCAL objects
135  if (finalHcalCone_ > 0) {
136  MultiTrackDRFilter hcalFinalFilter(finalHcalCone_,
137  tau.signalChargedHadrCands());
138  std::remove_if(output.h0s.begin(), output.h0s.end(), hcalFinalFilter);
139  }
140  return output;
141 }
def copy(args, dbName)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
const std::vector< reco::CandidatePtr > & isolationGammaCands() const
Gamma candidates in isolation region.
Definition: PFTau.cc:93
virtual double energy() const =0
energy
T sqrt(T t)
Definition: SSEVec.h:18
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Definition: PFTau.cc:179
static double square(double x)
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:80
const std::vector< reco::CandidatePtr > & isolationNeutrHadrCands() const
Definition: PFTau.cc:91
bool inCone(const reco::PFCandidate &track, const reco::Candidate &cand) const
std::unique_ptr< PFEnergyResolution > resolutions_
double resolution(const reco::Candidate &cand) const
double reco::tau::RecoTauIsolationMasking::resolution ( const reco::Candidate cand) const
private

Definition at line 143 of file RecoTauIsolationMasking.cc.

References funct::abs(), reco::Candidate::energy(), reco::Candidate::eta(), reco::Candidate::pdgId(), reco::Candidate::phi(), and resolutions_.

Referenced by mask(), and setMaxSigmas().

144  {
145  if (cand.pdgId() == 130) {
146  // NB for HCAL it returns relative energy
147  return cand.energy()*resolutions_->getEnergyResolutionHad(cand.energy(),
148  cand.eta(), cand.phi());
149  } else if (cand.pdgId() == 22) {
150  return resolutions_->getEnergyResolutionEm(cand.energy(), cand.eta());
151  } else if (std::abs(cand.pdgId()) == 11) {
152  // FIXME what is the electron resolution??
153  return 0.15;
154  } else {
155  edm::LogWarning("IsoMask::res (bad pf id)")
156  << "Unknown PF PDG ID: " << cand.pdgId();
157  }
158  return -1;
159 }
virtual double energy() const =0
energy
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual double eta() const =0
momentum pseudorapidity
virtual double phi() const =0
momentum azimuthal angle
std::unique_ptr< PFEnergyResolution > resolutions_
void reco::tau::RecoTauIsolationMasking::setMaxSigmas ( double  maxSigmas)
inline

Member Data Documentation

double reco::tau::RecoTauIsolationMasking::ecalCone_
private

Definition at line 44 of file RecoTauIsolationMasking.h.

Referenced by inCone(), and RecoTauIsolationMasking().

double reco::tau::RecoTauIsolationMasking::finalHcalCone_
private

Definition at line 47 of file RecoTauIsolationMasking.h.

Referenced by mask(), and RecoTauIsolationMasking().

double reco::tau::RecoTauIsolationMasking::hcalCone_
private

Definition at line 45 of file RecoTauIsolationMasking.h.

Referenced by inCone(), and RecoTauIsolationMasking().

double reco::tau::RecoTauIsolationMasking::maxSigmas_
private

Definition at line 46 of file RecoTauIsolationMasking.h.

Referenced by mask(), RecoTauIsolationMasking(), and setMaxSigmas().

std::unique_ptr<PFEnergyResolution> reco::tau::RecoTauIsolationMasking::resolutions_
private

Definition at line 48 of file RecoTauIsolationMasking.h.

Referenced by mask(), and resolution().