CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

reco::tau::RecoTauIsolationMasking Class Reference

#include <RecoTauIsolationMasking.h>

List of all members.

Classes

struct  IsoMaskResult

Public Member Functions

IsoMaskResult mask (const reco::PFTau &) const
 Return a new isolation collections with masking applied.
 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_.

                                :resolutions_(new PFEnergyResolution) {
  ecalCone_ = pset.getParameter<double>("ecalCone");
  hcalCone_ = pset.getParameter<double>("hcalCone");
  finalHcalCone_ = pset.getParameter<double>("finalHcalCone");
  maxSigmas_ = pset.getParameter<double>("maxSigmas");
}
reco::tau::RecoTauIsolationMasking::~RecoTauIsolationMasking ( )

Definition at line 72 of file RecoTauIsolationMasking.cc.

{}

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(), alignCSCRings::e, ecalCone_, reco::PFCandidate::gamma, reco::PFCandidate::h0, hcalCone_, reco::LeafCandidate::p4(), reco::PFCandidate::particleId(), and reco::PFCandidate::positionAtECALEntrance().

Referenced by mask().

                                       {
  double openingDR = reco::deltaR(track.positionAtECALEntrance(), cand.p4());
  if (cand.particleId() == reco::PFCandidate::h0) {
    return (openingDR < hcalCone_);
  } else if (cand.particleId() == reco::PFCandidate::gamma ||
      cand.particleId() == reco::PFCandidate::e) {
    return openingDR < ecalCone_;
  } else {
    edm::LogWarning("IsoMask::inCone (bad pf id)")
      << "Unknown PF ID: " << cand.particleId()
      << " " <<  reco::PFCandidate::e;
  }
  return -1;
}
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 edm::RefVector< C, T, F >::begin(), filterCSVwithJSON::copy, course, edm::RefVector< C, T, F >::end(), 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 reco::tau::square().

                                                        {
  IsoMaskResult output;

  typedef std::list<reco::PFCandidateRef> PFCandList;
  // Copy original iso collections.
  std::copy(tau.isolationPFGammaCands().begin(),
      tau.isolationPFGammaCands().end(), std::back_inserter(output.gammas));
  std::copy(tau.isolationPFNeutrHadrCands().begin(),
      tau.isolationPFNeutrHadrCands().end(),
      std::back_inserter(output.h0s));

  std::vector<PFCandList*> courses;
  courses.push_back(&(output.h0s));
  courses.push_back(&(output.gammas));
  // Mask using each one of the tracks
  BOOST_FOREACH(const reco::PFCandidateRef& track,
      tau.signalPFChargedHadrCands()) {
    double trackerEnergy = track->energy();
    double linkedEcalEnergy = track->ecalEnergy();
    double linkedHcalEnergy = track->hcalEnergy();
    math::XYZPointF posAtCalo = track->positionAtECALEntrance();
    // Get the linked calo energies & their errors
    double linkedSumErrSquared = 0;
    linkedSumErrSquared += square(
        resolutions_->getEnergyResolutionEm(linkedEcalEnergy, posAtCalo.eta()));
    linkedSumErrSquared += square(
        resolutions_->getEnergyResolutionHad(
          linkedHcalEnergy, posAtCalo.eta(), posAtCalo.phi()));

    // energyDelta is the difference between associated Calo and tracker energy
    double energyDelta = linkedEcalEnergy + linkedHcalEnergy - trackerEnergy;

    // Sort the neutral hadrons by DR to the track
    //DRSorter sorter(track->p4());
    PtSorter sorter;

    BOOST_FOREACH(PFCandList* course, courses) {
      // Sort by deltaR to the current track
      course->sort(sorter);
      PFCandList::iterator toEatIter = course->begin();
      // While there are still candidates to eat in this course and they are
      // within the cone.
      while (toEatIter != course->end()) {
        const reco::PFCandidate& toEat = **toEatIter;
        double toEatEnergy = toEat.energy();
        double toEatErrorSq = square(resolution(toEat));
        // Check if we can absorb this candidate into the track.
        if (inCone(*track, **toEatIter) &&
            (energyDelta + toEatEnergy)/std::sqrt(
              linkedSumErrSquared + toEatErrorSq) < maxSigmas_ ) {
          energyDelta += toEatEnergy;
          linkedSumErrSquared += toEatErrorSq;
          toEatIter = course->erase(toEatIter);
        } else {
          // otherwise skip to the next one
          ++toEatIter;
        }
      }
    }
  }
  // Filter out any final HCAL objects with in cones about the tracks.
  // This removes upward fluctuating HCAL objects
  if (finalHcalCone_ > 0) {
    MultiTrackDRFilter hcalFinalFilter(finalHcalCone_,
        tau.signalPFChargedHadrCands());
    std::remove_if(output.h0s.begin(), output.h0s.end(), hcalFinalFilter);
  }
  return output;
}
double reco::tau::RecoTauIsolationMasking::resolution ( const reco::PFCandidate cand) const [private]

Definition at line 145 of file RecoTauIsolationMasking.cc.

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

Referenced by mask().

                                       {
  if (cand.particleId() == reco::PFCandidate::h0) {
    // NB for HCAL it returns relative energy
    return cand.energy()*resolutions_->getEnergyResolutionHad(cand.energy(),
        cand.eta(), cand.phi());
  } else if (cand.particleId() == reco::PFCandidate::gamma) {
    return resolutions_->getEnergyResolutionEm(cand.energy(), cand.eta());
  } else if (cand.particleId() == reco::PFCandidate::e) {
    // FIXME what is the electron resolution??
    return 0.15;
  } else {
    edm::LogWarning("IsoMask::res (bad pf id)")
      << "Unknown PF ID: " << cand.particleId();
  }
  return -1;
}
void reco::tau::RecoTauIsolationMasking::setMaxSigmas ( double  maxSigmas) [inline]

Definition at line 36 of file RecoTauIsolationMasking.h.

References maxSigmas_.

{maxSigmas_ = maxSigmas;}

Member Data Documentation

Definition at line 44 of file RecoTauIsolationMasking.h.

Referenced by inCone(), and RecoTauIsolationMasking().

Definition at line 47 of file RecoTauIsolationMasking.h.

Referenced by mask(), and RecoTauIsolationMasking().

Definition at line 45 of file RecoTauIsolationMasking.h.

Referenced by inCone(), and RecoTauIsolationMasking().

Definition at line 46 of file RecoTauIsolationMasking.h.

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

Definition at line 48 of file RecoTauIsolationMasking.h.

Referenced by mask(), and resolution().