CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EgammaHLTTrackIsolation Class Reference

#include <RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTTrackIsolation.h>

List of all members.

Public Member Functions

 EgammaHLTTrackIsolation (double egTrkIso_PtMin, double egTrkIso_ConeSize, double egTrkIso_ZSpan, double egTrkIso_RSpan, double egTrkIso_VetoConeSize, double egTrkIso_stripBarrel=0, double egTrkIso_stripEndcap=0)
std::pair< int, float > electronIsolation (const reco::Track *const tr, const reco::TrackCollection *isoTracks)
 Get number of tracks and Pt sum of tracks inside an isolation cone for electrons.
std::pair< int, float > electronIsolation (const reco::Track *const tr, const reco::TrackCollection *isoTracks, GlobalPoint vertex)
std::pair< int, float > electronIsolation (const reco::Track *const tr, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)
float electronPtSum (const reco::Track *const tr, const reco::TrackCollection *isoTracks)
 Get Pt sum of tracks inside an isolation cone for electrons.
float electronPtSum (const reco::Track *const tr, const reco::TrackCollection *isoTracks, GlobalPoint vertex)
float electronPtSum (const reco::Track *const tr, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)
int electronTrackCount (const reco::Track *const tr, const reco::TrackCollection *isoTracks)
 Get number of tracks inside an isolation cone for electrons.
int electronTrackCount (const reco::Track *const tr, const reco::TrackCollection *isoTracks, GlobalPoint vertex)
double getConeSize ()
 Get isolation cone size.
double getPtMin ()
 Get pt cut for itracks.
double getRspan ()
 Get maximum transverse distance of ivertex from beam line.
double getvetoConesize ()
 Get veto cone size.
double getZspan ()
 Get maximum ivertex z-coordinate spread.
std::pair< int, float > photonIsolation (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, bool useVertex)
std::pair< int, float > photonIsolation (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, GlobalPoint vertex)
std::pair< int, float > photonIsolation (const reco::RecoCandidate *const recocand, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)
float photonPtSum (const reco::RecoCandidate *const recocand, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)
float photonPtSum (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, GlobalPoint vertex)
float photonPtSum (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, bool useVertex)
int photonTrackCount (const reco::RecoCandidate *const recocand, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)
int photonTrackCount (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, bool useVertex)
int photonTrackCount (const reco::RecoCandidate *const recocand, const reco::TrackCollection *isoTracks, GlobalPoint vertex)

Private Member Functions

std::pair< int, float > findIsoTracks (GlobalVector mom, GlobalPoint vtx, const reco::TrackCollection *isoTracks, bool isElectron, bool useVertex=true)
std::pair< int, float > findIsoTracksWithoutEle (GlobalVector mom, GlobalPoint vtx, const reco::ElectronCollection *allEle, const reco::TrackCollection *isoTracks)

Private Attributes

double conesize
double ptMin
double rspan
double stripBarrel
double stripEndcap
double vetoConesize
double zspan

Detailed Description

Description: Number of tracks inside an isolation cone, with con geometry defined by ptMin, conesize, rspan and zspan. Usage: <usage>

Definition at line 48 of file EgammaHLTTrackIsolation.h.


Constructor & Destructor Documentation

EgammaHLTTrackIsolation::EgammaHLTTrackIsolation ( double  egTrkIso_PtMin,
double  egTrkIso_ConeSize,
double  egTrkIso_ZSpan,
double  egTrkIso_RSpan,
double  egTrkIso_VetoConeSize,
double  egTrkIso_stripBarrel = 0,
double  egTrkIso_stripEndcap = 0 
) [inline]

Definition at line 54 of file EgammaHLTTrackIsolation.h.

                                                         :
    ptMin(egTrkIso_PtMin),
    conesize(egTrkIso_ConeSize),
    zspan(egTrkIso_ZSpan),
    rspan(egTrkIso_RSpan),
    vetoConesize(egTrkIso_VetoConeSize),
    stripBarrel(egTrkIso_stripBarrel),
    stripEndcap(egTrkIso_stripEndcap)
  {
      
      /*
        std::cout << "EgammaHLTTrackIsolation instance:"
        << " ptMin=" << ptMin << " "
        << " conesize="<< conesize << " "
        << " zspan=" << zspan << " "
        << " rspan=" << rspan << " "
        << " vetoConesize="<< vetoConesize
        << std::endl;    
      */
    }

Member Function Documentation

std::pair< int, float > EgammaHLTTrackIsolation::electronIsolation ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks 
)

Get number of tracks and Pt sum of tracks inside an isolation cone for electrons.

Definition at line 20 of file EgammaHLTTrackIsolation.cc.

References findIsoTracks(), reco::TrackBase::momentum(), AlCaHLTBitMon_ParallelJobs::p, and reco::TrackBase::vertex().

Referenced by electronPtSum(), and electronTrackCount().

{
  GlobalPoint vtx(0,0,tr->vertex().z());
  reco::Track::Vector p = tr->momentum();
  GlobalVector mom( p.x(), p.y(), p.z() );
  return findIsoTracks(mom,vtx,isoTracks,true);
}
std::pair< int, float > EgammaHLTTrackIsolation::electronIsolation ( const reco::Track *const  tr,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
)

Definition at line 38 of file EgammaHLTTrackIsolation.cc.

References findIsoTracksWithoutEle(), reco::TrackBase::momentum(), AlCaHLTBitMon_ParallelJobs::p, and reco::TrackBase::vertex().

{
  GlobalPoint vtx(0,0,tr->vertex().z());
  reco::Track::Vector p = tr->momentum();
  GlobalVector mom( p.x(), p.y(), p.z() );
  return findIsoTracksWithoutEle(mom,vtx,allEle,isoTracks);
}
std::pair< int, float > EgammaHLTTrackIsolation::electronIsolation ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
)

Definition at line 29 of file EgammaHLTTrackIsolation.cc.

References findIsoTracks(), reco::TrackBase::momentum(), AlCaHLTBitMon_ParallelJobs::p, and PV3DBase< T, PVType, FrameType >::z().

{ 
  // Just to insure consistency with no-vertex-code
  GlobalPoint vtx(0,0,zvtx.z());
  reco::Track::Vector p = tr->momentum();
  GlobalVector mom( p.x(), p.y(), p.z() );
  return findIsoTracks(mom,vtx,isoTracks,true);
}
float EgammaHLTTrackIsolation::electronPtSum ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks 
) [inline]

Get Pt sum of tracks inside an isolation cone for electrons.

Definition at line 111 of file EgammaHLTTrackIsolation.h.

References electronIsolation().

Referenced by egHLT::OffHelper::fillIsolData(), and EgammaHLTElectronTrackIsolationProducers::produce().

  {return electronIsolation(tr,isoTracks).second;}
float EgammaHLTTrackIsolation::electronPtSum ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
) [inline]

Definition at line 113 of file EgammaHLTTrackIsolation.h.

References electronIsolation().

  {return electronIsolation(tr,isoTracks,vertex).second;}
float EgammaHLTTrackIsolation::electronPtSum ( const reco::Track *const  tr,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
) [inline]

Definition at line 115 of file EgammaHLTTrackIsolation.h.

References electronIsolation().

  {return electronIsolation(tr,allEle,isoTracks).second;} 
int EgammaHLTTrackIsolation::electronTrackCount ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
) [inline]

Definition at line 97 of file EgammaHLTTrackIsolation.h.

References electronIsolation().

  {return electronIsolation(tr,isoTracks,vertex).first;}
int EgammaHLTTrackIsolation::electronTrackCount ( const reco::Track *const  tr,
const reco::TrackCollection isoTracks 
) [inline]

Get number of tracks inside an isolation cone for electrons.

Definition at line 95 of file EgammaHLTTrackIsolation.h.

References electronIsolation().

  {return electronIsolation(tr,isoTracks).first;}
std::pair< int, float > EgammaHLTTrackIsolation::findIsoTracks ( GlobalVector  mom,
GlobalPoint  vtx,
const reco::TrackCollection isoTracks,
bool  isElectron,
bool  useVertex = true 
) [private]

Definition at line 83 of file EgammaHLTTrackIsolation.cc.

References PV3DBase< T, PVType, FrameType >::eta(), M_PI, ntrack, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), ptMin, dttmaxenums::R, rspan, mathSSE::sqrt(), stripBarrel, stripEndcap, vetoConesize, PV3DBase< T, PVType, FrameType >::z(), and zspan.

Referenced by electronIsolation(), and photonIsolation().

{

  // Check that reconstructed tracks fit within cone boundaries,
  // (Note: tracks will not always stay within boundaries)
  int ntrack = 0;
  float ptSum = 0.;

  for(reco::TrackCollection::const_iterator trItr = isoTracks->begin(); trItr != isoTracks->end(); ++trItr){

    GlobalPoint ivtx(trItr->vertex().x(),trItr->vertex().y(),trItr->vertex().z());
    reco::Track::Vector ip = trItr->momentum();
    GlobalVector imom ( ip.x(), ip.y(), ip.z());

    float pt = imom.perp();
    float dperp = 0.;
    float dz = 0.;
    float deta = 0.;
    float dphi = 0.;
    if (useVertex) {
      dperp = ivtx.perp()-vtx.perp();
      dz = ivtx.z()-vtx.z();
      deta = imom.eta()-mom.eta();
      dphi = imom.phi()-mom.phi();
    } else {
      //in case of unkown photon vertex, modify direction of photon to point from
      //current track vertex to sc instead of from (0.,0.,0.) to sc.  In this 
      //way, all tracks are considered based on direction alone.
      GlobalVector mom_temp = mom - GlobalVector(ivtx.x(),ivtx.y(),ivtx.z());
      deta = imom.eta()-mom_temp.eta();
      dphi = imom.phi()-mom_temp.phi();
    }
    // Correct dmom_phi's from [-2pi,2pi] to [-pi,pi]
    if (dphi>M_PI) dphi = dphi - 2*M_PI;
    else if (dphi<-M_PI) dphi = dphi + 2*M_PI;

    float R = sqrt( dphi*dphi + deta*deta );

    // Apply boundary cut
    // bool selected=false;

    // if (pt > ptMin && R < conesize &&
    //  fabs(dperp) < rspan && fabs(dz) < zspan) selected=true;
  
    // if (selected) {
    //  ntrack++;
    //  if (!isElectron || R > vetoConesize) ptSum+=pt; //to exclude electron track
    // }
    // float theVetoVar = R;
    // if (isElectron) theVetoVar = R;  
    
    //hmm how do I figure out if this is barrel or endcap?
    //abs(mom.eta())<1.5 is the obvious choice but that will be electron not detector eta for electrons
    //well lets leave it as that for now, its what reco does (well with eta=1.479)
    double innerStrip = fabs(mom.eta())<1.479 ? stripBarrel : stripEndcap;
    
    if (pt > ptMin && R < conesize && R > vetoConesize &&
        fabs(dperp) < rspan && fabs(dz) < zspan &&
        fabs(deta) >=innerStrip) {
      ntrack++;
      ptSum+=pt; 
    }
  }

  // if (isElectron) ntrack-=1; //to exclude electron track

  return (std::pair<int,float>(ntrack,ptSum));

}
std::pair< int, float > EgammaHLTTrackIsolation::findIsoTracksWithoutEle ( GlobalVector  mom,
GlobalPoint  vtx,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
) [private]

Definition at line 153 of file EgammaHLTTrackIsolation.cc.

References conesize, PV3DBase< T, PVType, FrameType >::eta(), M_PI, ntrack, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), ptMin, dttmaxenums::R, rspan, mathSSE::sqrt(), stripBarrel, stripEndcap, vetoConesize, PV3DBase< T, PVType, FrameType >::z(), and zspan.

Referenced by electronIsolation(), and photonIsolation().

{

  // Check that reconstructed tracks fit within cone boundaries,
  // (Note: tracks will not always stay within boundaries)
  int iele = 0;
  int ntrack = 0;
  float ptSum = 0.;
  std::vector<float> etaele;
  std::vector<float> phiele;

  // std::cout << "allEle.size() = " << allEle->size() << std::endl;

  // Store ALL electrons eta and phi
  for (reco::ElectronCollection::const_iterator iElectron = allEle->begin(); iElectron != allEle->end(); iElectron++){
    iele++;
    reco::TrackRef anothereletrackref = iElectron->track();
    etaele.push_back(anothereletrackref->momentum().eta());
    phiele.push_back(anothereletrackref->momentum().phi());
    // std::cout << "Electron " << iele << ": phi = " << anothereletrackref->momentum().phi() << ", eta = " << anothereletrackref->momentum().eta() << std::endl; 
  }
  
  for(reco::TrackCollection::const_iterator trItr = isoTracks->begin(); trItr != isoTracks->end(); ++trItr){

    GlobalPoint ivtx(trItr->vertex().x(),trItr->vertex().y(),trItr->vertex().z());
    reco::Track::Vector ip = trItr->momentum();
    GlobalVector imom ( ip.x(), ip.y(), ip.z());

    float pt = imom.perp();
    float dperp = ivtx.perp()-vtx.perp();
    float dz = ivtx.z()-vtx.z();
    float deta = imom.eta()-mom.eta();
    float dphi = imom.phi()-mom.phi();
    
    // Correct dmom_phi's from [-2pi,2pi] to [-pi,pi]
    if (dphi>M_PI) dphi = dphi - 2*M_PI;
    else if (dphi<-M_PI) dphi = dphi + 2*M_PI;

    float R = sqrt( dphi*dphi + deta*deta );

    // Apply boundary cut
    bool selected=false;
    bool passedconeveto=true;

    //hmm how do I figure out if this is barrel or endcap?
    //abs(mom.eta())<1.5 is the obvious choice but that will be electron not detector eta for electrons
    //well lets leave it as that for now, its what reco does (well with eta=1.479)
    double innerStrip = fabs(mom.eta())<1.479 ? stripBarrel : stripEndcap;

    if (pt > ptMin && R < conesize &&
        fabs(dperp) < rspan && fabs(dz) < zspan && 
        fabs(deta) >=innerStrip) selected=true;
  
    // Check that NO electron is counted in the isolation
    for(unsigned int eleItr = 0; eleItr < etaele.size(); ++eleItr){
    
      deta = etaele[eleItr] - imom.eta();
      dphi = phiele[eleItr] - imom.phi();

      // Correct dmom_phi's from [-2pi,2pi] to [-pi,pi]
      if (dphi>M_PI) dphi = dphi - 2*M_PI;
      else if (dphi<-M_PI) dphi = dphi + 2*M_PI;

      R = sqrt( dphi*dphi + deta*deta );
      if (R < vetoConesize) passedconeveto=false;
    }

    if (selected && passedconeveto) {
      ntrack++;
      ptSum+=pt; //to exclude electron tracks
    }

  }

  // ntrack-=1; //to exclude electron track

  return (std::pair<int,float>(ntrack,ptSum));

}
double EgammaHLTTrackIsolation::getConeSize ( ) [inline]

Get isolation cone size.

Definition at line 132 of file EgammaHLTTrackIsolation.h.

References conesize.

{ return conesize; }
double EgammaHLTTrackIsolation::getPtMin ( ) [inline]

Get pt cut for itracks.

Definition at line 130 of file EgammaHLTTrackIsolation.h.

References ptMin.

{ return ptMin;}
double EgammaHLTTrackIsolation::getRspan ( ) [inline]

Get maximum transverse distance of ivertex from beam line.

Definition at line 136 of file EgammaHLTTrackIsolation.h.

References rspan.

{ return rspan; }
double EgammaHLTTrackIsolation::getvetoConesize ( ) [inline]

Get veto cone size.

Definition at line 138 of file EgammaHLTTrackIsolation.h.

References vetoConesize.

{ return vetoConesize; }
double EgammaHLTTrackIsolation::getZspan ( ) [inline]

Get maximum ivertex z-coordinate spread.

Definition at line 134 of file EgammaHLTTrackIsolation.h.

References zspan.

{return zspan; }
std::pair< int, float > EgammaHLTTrackIsolation::photonIsolation ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
bool  useVertex 
)

Get number of tracks and Pt sum of tracks inside an isolation cone for photons set useVertex=true to use PhotonCandidate vertex from EgammaPhotonVtxFinder set useVertex=false to consider all tracks for isolation

Definition at line 46 of file EgammaHLTTrackIsolation.cc.

References findIsoTracks(), pos, reco::RecoCandidate::superCluster(), and reco::LeafCandidate::vertex().

Referenced by photonPtSum(), and photonTrackCount().

{

  if (useVertex) {
    GlobalPoint vtx(0,0,recocandidate->vertex().z());
    return photonIsolation(recocandidate,isoTracks,vtx);
  } else {
    reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
    GlobalVector mom(pos.x(),pos.y(),pos.z());
    return findIsoTracks(mom,GlobalPoint(),isoTracks,false,false);
  }

}
std::pair< int, float > EgammaHLTTrackIsolation::photonIsolation ( const reco::RecoCandidate *const  recocand,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
)

Definition at line 74 of file EgammaHLTTrackIsolation.cc.

References findIsoTracksWithoutEle(), pos, and reco::RecoCandidate::superCluster().

{

  reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
  GlobalVector mom(pos.x(),pos.y(),pos.z());
  return findIsoTracksWithoutEle(mom,GlobalPoint(),allEle,isoTracks);

}
std::pair< int, float > EgammaHLTTrackIsolation::photonIsolation ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
)

Definition at line 60 of file EgammaHLTTrackIsolation.cc.

References findIsoTracks(), pos, reco::RecoCandidate::superCluster(), and PV3DBase< T, PVType, FrameType >::z().

{

  // to insure consistency with no-free-vertex-code
  GlobalPoint vtx(0,0,zvtx.z());

  reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
  GlobalVector mom(pos.x()-vtx.x(),pos.y()-vtx.y(),pos.z()-vtx.z());

  return findIsoTracks(mom,vtx,isoTracks,false);

}
float EgammaHLTTrackIsolation::photonPtSum ( const reco::RecoCandidate *const  recocand,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
) [inline]

Definition at line 125 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

  {return photonIsolation(recocand,allEle,isoTracks).second;}
float EgammaHLTTrackIsolation::photonPtSum ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
bool  useVertex 
) [inline]

Get Pt sum of tracks inside an isolation cone for photons set useVertex=true to use Photon vertex from EgammaPhotonVtxFinder set useVertex=false to consider all tracks for isolation

Definition at line 121 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

Referenced by egHLT::OffHelper::fillIsolData(), and EgammaHLTPhotonTrackIsolationProducersRegional::produce().

  {return photonIsolation(recocand,isoTracks, useVertex).second;}
float EgammaHLTTrackIsolation::photonPtSum ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
) [inline]

Definition at line 123 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

  {return photonIsolation(recocand,isoTracks, vertex).second;}
int EgammaHLTTrackIsolation::photonTrackCount ( const reco::RecoCandidate *const  recocand,
const reco::ElectronCollection allEle,
const reco::TrackCollection isoTracks 
) [inline]

Definition at line 107 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

  {return photonIsolation(recocand,allEle,isoTracks).first;}
int EgammaHLTTrackIsolation::photonTrackCount ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
GlobalPoint  vertex 
) [inline]

Definition at line 105 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

  {return photonIsolation(recocand,isoTracks,vertex).first;}
int EgammaHLTTrackIsolation::photonTrackCount ( const reco::RecoCandidate *const  recocand,
const reco::TrackCollection isoTracks,
bool  useVertex 
) [inline]

Get number of tracks inside an isolation cone for photons set useVertex=true to use Photon vertex from EgammaPhotonVtxFinder set useVertex=false to consider all tracks for isolation

Definition at line 103 of file EgammaHLTTrackIsolation.h.

References photonIsolation().

Referenced by egHLT::OffHelper::fillIsolData(), and EgammaHLTPhotonTrackIsolationProducersRegional::produce().

  {return photonIsolation(recocand,isoTracks,useVertex).first;}

Member Data Documentation

Definition at line 147 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracksWithoutEle(), and getConeSize().

Definition at line 146 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracks(), findIsoTracksWithoutEle(), and getPtMin().

Definition at line 149 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracks(), findIsoTracksWithoutEle(), and getRspan().

Definition at line 153 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracks(), and findIsoTracksWithoutEle().

Definition at line 154 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracks(), and findIsoTracksWithoutEle().

Definition at line 148 of file EgammaHLTTrackIsolation.h.

Referenced by findIsoTracks(), findIsoTracksWithoutEle(), and getZspan().