CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::PFCandidate &cand) const
 
double resolution (const reco::PFCandidate &cand) const
 

Private Attributes

double ecalCone_
 
double finalHcalCone_
 
double hcalCone_
 
double maxSigmas_
 
std::auto_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 63 of file RecoTauIsolationMasking.cc.

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

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

Definition at line 72 of file RecoTauIsolationMasking.cc.

72 {}

Member Function Documentation

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

Definition at line 163 of file RecoTauIsolationMasking.cc.

References reco::deltaR(), reco::PFCandidate::e, ecalCone_, reco::PFCandidate::gamma, reco::PFCandidate::h0, hcalCone_, reco::LeafCandidate::p4(), reco::PFCandidate::particleId(), and reco::PFCandidate::positionAtECALEntrance().

Referenced by mask().

164  {
165  double openingDR = reco::deltaR(track.positionAtECALEntrance(), cand.p4());
166  if (cand.particleId() == reco::PFCandidate::h0) {
167  return (openingDR < hcalCone_);
168  } else if (cand.particleId() == reco::PFCandidate::gamma ||
169  cand.particleId() == reco::PFCandidate::e) {
170  return openingDR < ecalCone_;
171  } else {
172  edm::LogWarning("IsoMask::inCone (bad pf id)")
173  << "Unknown PF ID: " << cand.particleId()
174  << " " << reco::PFCandidate::e;
175  }
176  return -1;
177 }
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:363
virtual ParticleType particleId() const
Definition: PFCandidate.h:369
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
RecoTauIsolationMasking::IsoMaskResult reco::tau::RecoTauIsolationMasking::mask ( const reco::PFTau tau) const

Return a new isolation collections with masking applied.

Definition at line 75 of file RecoTauIsolationMasking.cc.

References filterCSVwithJSON::copy, reco::LeafCandidate::energy(), finalHcalCone_, reco::tau::RecoTauIsolationMasking::IsoMaskResult::gammas, reco::tau::RecoTauIsolationMasking::IsoMaskResult::h0s, inCone(), reco::PFTau::isolationPFGammaCands(), reco::PFTau::isolationPFNeutrHadrCands(), maxSigmas_, convertSQLitetoXML_cfg::output, resolution(), resolutions_, reco::PFTau::signalPFChargedHadrCands(), MCScenario_CRAFT1_22X::sorter(), mathSSE::sqrt(), and Clusterizer1DCommons::square().

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

Definition at line 145 of file RecoTauIsolationMasking.cc.

References reco::PFCandidate::e, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::PFCandidate::gamma, reco::PFCandidate::h0, reco::PFCandidate::particleId(), reco::LeafCandidate::phi(), and resolutions_.

Referenced by mask().

146  {
147  if (cand.particleId() == reco::PFCandidate::h0) {
148  // NB for HCAL it returns relative energy
149  return cand.energy()*resolutions_->getEnergyResolutionHad(cand.energy(),
150  cand.eta(), cand.phi());
151  } else if (cand.particleId() == reco::PFCandidate::gamma) {
152  return resolutions_->getEnergyResolutionEm(cand.energy(), cand.eta());
153  } else if (cand.particleId() == reco::PFCandidate::e) {
154  // FIXME what is the electron resolution??
155  return 0.15;
156  } else {
157  edm::LogWarning("IsoMask::res (bad pf id)")
158  << "Unknown PF ID: " << cand.particleId();
159  }
160  return -1;
161 }
virtual float phi() const
momentum azimuthal angle
std::auto_ptr< PFEnergyResolution > resolutions_
virtual double energy() const
energy
virtual float eta() const
momentum pseudorapidity
virtual ParticleType particleId() const
Definition: PFCandidate.h:369
void reco::tau::RecoTauIsolationMasking::setMaxSigmas ( double  maxSigmas)
inline

Definition at line 36 of file RecoTauIsolationMasking.h.

References maxSigmas_.

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::auto_ptr<PFEnergyResolution> reco::tau::RecoTauIsolationMasking::resolutions_
private

Definition at line 48 of file RecoTauIsolationMasking.h.

Referenced by mask(), and resolution().