CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

pat::Electron Class Reference

Analysis-level electron class. More...

#include <DataFormats/PatCandidates/interface/Electron.h>

Inheritance diagram for pat::Electron:
pat::Lepton< reco::GsfElectron > pat::PATObject< reco::GsfElectron > reco::GsfElectron reco::RecoCandidate reco::LeafCandidate reco::Candidate

List of all members.

Public Types

typedef std::pair< std::string,
float > 
IdPair
enum  IPTYPE {
  None = 0, PV2D = 1, PV3D = 2, BS2D = 3,
  BS3D = 4
}
typedef enum pat::Electron::IPTYPE IpType

Public Member Functions

float caloIso () const
virtual Electronclone () const
 required reimplementation of the Candidate's clone method
virtual reco::GsfElectronCoreRef core () const
 override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElectron client methods
double dB (IpType type=None) const
const LorentzVectorecalDrivenMomentum () const
float ecalIso () const
double edB (IpType type=None) const
 Electron (const edm::Ptr< reco::GsfElectron > &anElectronRef)
 constructor from a Ptr to a reco electron
 Electron (const reco::GsfElectron &anElectron)
 constructor from a reco electron
 Electron (const edm::RefToBase< reco::GsfElectron > &anElectronRef)
 constructor from a RefToBase to a reco electron (to be superseded by Ptr counterpart)
 Electron ()
 default constructor
float electronID (const std::string &name) const
const std::vector< IdPair > & electronIDs () const
void embedGsfElectronCore ()
 method to store the electron's core internally
void embedGsfTrack ()
 method to store the electron's GsfTrack internally
void embedPFCandidate ()
 embed the PFCandidate pointed to by pfCandidateRef_
void embedSuperCluster ()
 method to store the electron's SuperCluster internally
void embedTrack ()
 method to store the electron's Track internally
reco::GsfTrackRef gsfTrack () const
 override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster
float hcalIso () const
bool isElectronIDAvailable (const std::string &name) const
 Returns true if a specific ID is available in this pat::Electron.
size_t numberOfSourceCandidatePtrs () const
reco::PFCandidateRef pfCandidateRef () const
 reference to the source PFCandidates
void setDB (double dB, double edB, IpType type=None)
void setEcalDrivenMomentum (const Candidate::LorentzVector &mom)
void setElectronIDs (const std::vector< IdPair > &ids)
void setPFCandidateRef (const reco::PFCandidateRef &ref)
 add a reference to the source IsolatedPFCandidate
reco::CandidatePtr sourceCandidatePtr (size_type i) const
 get the candidate pointer with index i
reco::SuperClusterRef superCluster () const
 override the reco::GsfElectron::superCluster method, to access the internal storage of the supercluster
reco::TrackRef track () const
 override the reco::GsfElectron::track method, to access the internal storage of the track
float trackIso () const
virtual ~Electron ()
 destructor

Protected Member Functions

void initImpactParameters ()

Protected Attributes

bool cachedDB_
std::vector< bool > cachedIP_
double dB_
LorentzVector ecalDrivenMomentum_
 ECAL-driven momentum.
double edB_
std::vector< double > eip_
std::vector< IdPairelectronIDs_
bool embeddedGsfElectronCore_
bool embeddedGsfTrack_
bool embeddedPFCandidate_
 true if the IsolatedPFCandidate is embedded
bool embeddedSuperCluster_
bool embeddedTrack_
std::vector
< reco::GsfElectronCore
gsfElectronCore_
std::vector< reco::GsfTrackgsfTrack_
std::vector< double > ip_
reco::PFCandidateCollection pfCandidate_
reco::PFCandidateRef pfCandidateRef_
std::vector< reco::SuperClustersuperCluster_
std::vector< reco::Tracktrack_

Friends

std::ostream & reco::operator<< (std::ostream &out, const pat::Electron &obj)
 pipe operator (introduced to use pat::Electron with PFTopProjectors)

Detailed Description

Analysis-level electron class.

pat::Electron implements the analysis-level electron class within the 'pat' namespace.

Please post comments and questions to the Physics Tools hypernews: https://hypernews.cern.ch/HyperNews/CMS/get/physTools.html

Author:
Steven Lowette, Giovanni Petrucciani, Frederic Ronga
Version:
Id:
Electron.h,v 1.34 2011/06/08 20:40:18 rwolf Exp

Definition at line 50 of file Electron.h.


Member Typedef Documentation

typedef std::pair<std::string,float> pat::Electron::IdPair

Definition at line 54 of file Electron.h.


Member Enumeration Documentation

Enumerator:
None 
PV2D 
PV3D 
BS2D 
BS3D 

Definition at line 166 of file Electron.h.

{ None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4 } IpType;       

Constructor & Destructor Documentation

Electron::Electron ( )

default constructor

Definition at line 13 of file Electron.cc.

References initImpactParameters().

Referenced by clone().

Electron::Electron ( const reco::GsfElectron anElectron)

constructor from a reco electron

constructor from reco::GsfElectron

Definition at line 29 of file Electron.cc.

References initImpactParameters().

Electron::Electron ( const edm::RefToBase< reco::GsfElectron > &  anElectronRef)

constructor from a RefToBase to a reco electron (to be superseded by Ptr counterpart)

constructor from ref to reco::GsfElectron

Definition at line 45 of file Electron.cc.

References initImpactParameters().

                                                                      :
    Lepton<reco::GsfElectron>(anElectronRef),
    embeddedGsfElectronCore_(false),
    embeddedGsfTrack_(false),
    embeddedSuperCluster_(false),
    embeddedTrack_(false),
    embeddedPFCandidate_(false),
    ecalDrivenMomentum_(anElectronRef->p4()),
    cachedDB_(false),
    dB_(0.0),
    edB_(0.0)
{
  initImpactParameters();
}
Electron::Electron ( const edm::Ptr< reco::GsfElectron > &  anElectronRef)

constructor from a Ptr to a reco electron

constructor from Ptr to reco::GsfElectron

Definition at line 61 of file Electron.cc.

References initImpactParameters().

                                                                :
    Lepton<reco::GsfElectron>(anElectronRef),
    embeddedGsfElectronCore_(false),
    embeddedGsfTrack_(false),
    embeddedSuperCluster_(false),
    embeddedTrack_(false),
    embeddedPFCandidate_(false),
    ecalDrivenMomentum_(anElectronRef->p4()),
    cachedDB_(false),
    dB_(0.0),
    edB_(0.0)
{
  initImpactParameters();
}
Electron::~Electron ( ) [virtual]

destructor

Definition at line 77 of file Electron.cc.

                    {
}

Member Function Documentation

float pat::Electron::caloIso ( ) const [inline]

Overload of pat::Lepton::trackIso(); returns the sum of ecalIso() and hcalIso

Reimplemented from pat::Lepton< reco::GsfElectron >.

Definition at line 128 of file Electron.h.

References ecalIso(), and hcalIso().

{ return ecalIso()+hcalIso(); }
virtual Electron* pat::Electron::clone ( void  ) const [inline, virtual]

required reimplementation of the Candidate's clone method

Reimplemented from pat::Lepton< reco::GsfElectron >.

Definition at line 68 of file Electron.h.

References Electron().

{ return new Electron(*this); }
reco::GsfElectronCoreRef Electron::core ( ) const [virtual]

override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElectron client methods

Reimplemented from reco::GsfElectron.

Definition at line 117 of file Electron.cc.

References embeddedGsfElectronCore_, and gsfElectronCore_.

double Electron::dB ( IpType  type_ = None) const

dB gives the impact parameter wrt the beamline. If this is not cached it is not meaningful, since it relies on the distance to the beamline.

Definition at line 237 of file Electron.cc.

References cachedDB_, cachedIP_, dB_, ip_, max(), and None.

Referenced by WenuPlots::analyze(), ElectronVPlusJetsIDSelectionFunctor::firstDataCuts(), ZeePlots::ReturnCandVar(), setDB(), and PFElectronSelector::spring11Cuts().

                                      {
  // preserve old functionality exactly
  if (type_ == None){
    if ( cachedDB_ ) {
      return dB_;
    } else {
      return std::numeric_limits<double>::max();
    }
  }
  // more IP types (new)
  else if ( cachedIP_[type_] ) {
    return ip_[type_];
  } else {
    return std::numeric_limits<double>::max();
  }
}
const LorentzVector& pat::Electron::ecalDrivenMomentum ( ) const [inline]

Definition at line 172 of file Electron.h.

References ecalDrivenMomentum_.

float pat::Electron::ecalIso ( ) const [inline]

Overload of pat::Lepton::trackIso(); returns the value of the summed Et of all recHits in the ecal in a cone of deltaR<0.4

Reimplemented from pat::Lepton< reco::GsfElectron >.

Definition at line 121 of file Electron.h.

References reco::GsfElectron::dr04EcalRecHitSumEt().

Referenced by caloIso().

{ return dr04EcalRecHitSumEt(); }
double Electron::edB ( IpType  type_ = None) const

edB gives the uncertainty on the impact parameter wrt the beamline. If this is not cached it is not meaningful, since it relies on the distance to the beamline.

Definition at line 257 of file Electron.cc.

References cachedDB_, cachedIP_, edB_, eip_, max(), and None.

Referenced by ElectronVPlusJetsIDSelectionFunctor::firstDataCuts(), and setDB().

                                       {
  // preserve old functionality exactly
  if (type_ == None) {
    if ( cachedDB_ ) {
      return edB_;
    } else {
      return std::numeric_limits<double>::max();
    }
  }
  // more IP types (new)
  else if ( cachedIP_[type_] ) {
    return eip_[type_];
  } else {
    return std::numeric_limits<double>::max();
  }

}
float Electron::electronID ( const std::string &  name) const

Returns a specific electron ID associated to the pat::Electron given its name For cut-based IDs, the value map has the following meaning: 0: fails 1: passes electron ID only 2: passes electron Isolation only 3: passes electron ID and Isolation only 4: passes conversion rejection 5: passes conversion rejection and ID 6: passes conversion rejection and Isolation 7: passes the whole selection For more details have a look at: https://twiki.cern.ch/twiki/bin/view/CMS/SimpleCutBasedEleID https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCategoryBasedElectronID Note: an exception is thrown if the specified ID is not available

Definition at line 184 of file Electron.cc.

References electronIDs_.

Referenced by WenuPlots::analyze(), WenuPlots::CheckCuts(), ZeePlots::CheckCuts1(), ZeePlots::CheckCuts2(), and PFElectronSelector::spring11Cuts().

                                                       {
    for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
        if (it->first == name) return it->second;
    }
    cms::Exception ex("Key not found");
    ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
    ex << "The available IDs are: ";
    for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
        ex << "'" << it->first << "' ";
    }
    ex << ".\n";
    throw ex;
}
const std::vector<IdPair>& pat::Electron::electronIDs ( ) const [inline]

Returns all the electron IDs in the form of <name,value> pairs The 'default' ID is the first in the list

Definition at line 109 of file Electron.h.

References electronIDs_.

{ return electronIDs_; }
void Electron::embedGsfElectronCore ( )

method to store the electron's core internally

method to store the electron's gsfElectronCore internally

Definition at line 146 of file Electron.cc.

References reco::GsfElectron::core(), embeddedGsfElectronCore_, and gsfElectronCore_.

Referenced by pat::PATElectronProducer::fillElectron(), and pat::PATElectronProducer::fillElectron2().

void Electron::embedGsfTrack ( )

method to store the electron's GsfTrack internally

method to store the electron's gsfTrack internally

Definition at line 155 of file Electron.cc.

References embeddedGsfTrack_, reco::GsfElectron::gsfTrack(), and gsfTrack_.

Referenced by pat::PATElectronProducer::fillElectron(), and pat::PATElectronProducer::fillElectron2().

                             {
  gsfTrack_.clear();
  if (reco::GsfElectron::gsfTrack().isNonnull()) {
      gsfTrack_.push_back(*reco::GsfElectron::gsfTrack());
      embeddedGsfTrack_ = true;
  }
}
void Electron::embedPFCandidate ( )

embed the PFCandidate pointed to by pfCandidateRef_

embed the IsolatedPFCandidate pointed to by pfCandidateRef_

Definition at line 215 of file Electron.cc.

References embeddedPFCandidate_, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), pfCandidate_, and pfCandidateRef_.

Referenced by pat::PATElectronProducer::produce().

void Electron::embedSuperCluster ( )

method to store the electron's SuperCluster internally

method to store the electron's supercluster internally

Definition at line 165 of file Electron.cc.

References embeddedSuperCluster_, reco::GsfElectron::superCluster(), and superCluster_.

Referenced by pat::PATElectronProducer::fillElectron(), and pat::PATElectronProducer::fillElectron2().

void Electron::embedTrack ( )

method to store the electron's Track internally

method to store the electron's track internally

Definition at line 175 of file Electron.cc.

References embeddedTrack_, reco::RecoCandidate::track(), and track_.

Referenced by pat::PATElectronProducer::fillElectron(), and pat::PATElectronProducer::fillElectron2().

                          {
  track_.clear();
  if (reco::GsfElectron::track().isNonnull()) {
      track_.push_back(*reco::GsfElectron::track());
      embeddedTrack_ = true;
  }
}
reco::GsfTrackRef Electron::gsfTrack ( ) const [virtual]
float pat::Electron::hcalIso ( ) const [inline]

Overload of pat::Lepton::trackIso(); returns the value of the summed Et of all caloTowers in the hcal in a cone of deltaR<0.4

Reimplemented from pat::Lepton< reco::GsfElectron >.

Definition at line 125 of file Electron.h.

References reco::GsfElectron::dr04HcalTowerSumEt().

Referenced by caloIso().

{ return dr04HcalTowerSumEt(); }
void Electron::initImpactParameters ( ) [protected]

Definition at line 98 of file Electron.cc.

References cachedIP_, eip_, and ip_.

Referenced by Electron().

                                    {
  for (int i_ = 0; i_<5; ++i_){
    ip_.push_back(0.0);
    eip_.push_back(0.0);
    cachedIP_.push_back(false);
  }
}
bool Electron::isElectronIDAvailable ( const std::string &  name) const

Returns true if a specific ID is available in this pat::Electron.

Definition at line 198 of file Electron.cc.

References electronIDs_.

Referenced by WenuPlots::analyze().

                                                                 {
    for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
        if (it->first == name) return true;
    }
    return false;
}
size_t pat::Electron::numberOfSourceCandidatePtrs ( ) const [inline, virtual]

return the number of source Candidates ( the candidates used to construct this Candidate)

Reimplemented from reco::LeafCandidate.

Definition at line 141 of file Electron.h.

References edm::Ref< C, T, F >::isNonnull(), and pfCandidateRef_.

                                                 {
        return pfCandidateRef_.isNonnull() ? 1 : 0;
      }
reco::PFCandidateRef Electron::pfCandidateRef ( ) const

reference to the source PFCandidates

reference to the source PFCandidates null if this has been built from a standard electron

Definition at line 207 of file Electron.cc.

References embeddedPFCandidate_, pfCandidate_, and pfCandidateRef_.

Referenced by pat::PATElectronProducer::fillElectron(), pat::PATElectronProducer::fillElectron2(), and pat::PATElectronProducer::produce().

                                                  {
  if (embeddedPFCandidate_) {
    return reco::PFCandidateRef(&pfCandidate_, 0);
  } else {
    return pfCandidateRef_;
  }
}
void Electron::setDB ( double  dB,
double  edB,
IpType  type = None 
)

Definition at line 275 of file Electron.cc.

References cachedDB_, cachedIP_, dB(), dB_, edB(), edB_, eip_, ip_, and None.

Referenced by pat::PATElectronProducer::embedHighLevel(), and pat::PATElectronProducer::produce().

                                                      {
  if (type == None) { // Preserve  old functionality exactly
    dB_ = dB; edB_ = edB;
    cachedDB_ = true;
  } else {
    ip_[type] = dB; 
    eip_[type] = edB; 
    cachedIP_[type] = true;
  }
}
void pat::Electron::setEcalDrivenMomentum ( const Candidate::LorentzVector mom) [inline]

Definition at line 173 of file Electron.h.

References ecalDrivenMomentum_.

Referenced by pat::PATElectronProducer::fillElectron2().

void pat::Electron::setElectronIDs ( const std::vector< IdPair > &  ids) [inline]

Store multiple electron ID values, discarding existing ones The first one in the list becomes the 'default' electron id

Definition at line 112 of file Electron.h.

References electronIDs_.

Referenced by pat::PATElectronProducer::produce().

{ electronIDs_ = ids; }
void pat::Electron::setPFCandidateRef ( const reco::PFCandidateRef ref) [inline]

add a reference to the source IsolatedPFCandidate

Definition at line 135 of file Electron.h.

References pfCandidateRef_.

Referenced by pat::PATElectronProducer::produce().

                                                            {
        pfCandidateRef_ = ref;
      }
reco::CandidatePtr Electron::sourceCandidatePtr ( size_type  i) const [virtual]

get the candidate pointer with index i

reference to the parent PF candidate for use in TopProjector

Reimplemented from reco::LeafCandidate.

Definition at line 224 of file Electron.cc.

References embeddedPFCandidate_, edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), and pfCandidateRef_.

reco::SuperClusterRef Electron::superCluster ( ) const [virtual]

override the reco::GsfElectron::superCluster method, to access the internal storage of the supercluster

Reimplemented from reco::GsfElectron.

Definition at line 127 of file Electron.cc.

References embeddedSuperCluster_, and superCluster_.

Referenced by WenuPlots::analyze(), WenuPlots::CheckCut(), ZeePlots::CheckCut1(), ZeePlots::CheckCut1Inv(), ZeePlots::CheckCut2(), ZeePlots::CheckCut2Inv(), and WenuPlots::CheckCutInv().

reco::TrackRef Electron::track ( void  ) const [virtual]

override the reco::GsfElectron::track method, to access the internal storage of the track

Reimplemented from reco::RecoCandidate.

Definition at line 137 of file Electron.cc.

References embeddedTrack_, and track_.

                                   {
  if (embeddedTrack_) {
    return reco::TrackRef(&track_, 0);
  } else {
    return reco::GsfElectron::track();
  }
}
float pat::Electron::trackIso ( ) const [inline]

Overload of pat::Lepton::trackIso(); returns the value of the summed track pt in a cone of deltaR<0.4

Reimplemented from pat::Lepton< reco::GsfElectron >.

Definition at line 117 of file Electron.h.

References reco::GsfElectron::dr04TkSumPt().

{ return dr04TkSumPt(); }

Friends And Related Function Documentation

std::ostream& reco::operator<< ( std::ostream &  out,
const pat::Electron obj 
) [friend]

pipe operator (introduced to use pat::Electron with PFTopProjectors)


Member Data Documentation

bool pat::Electron::cachedDB_ [protected]

Definition at line 209 of file Electron.h.

Referenced by dB(), edB(), and setDB().

std::vector<bool> pat::Electron::cachedIP_ [protected]

Definition at line 214 of file Electron.h.

Referenced by dB(), edB(), initImpactParameters(), and setDB().

double pat::Electron::dB_ [protected]

Definition at line 210 of file Electron.h.

Referenced by dB(), and setDB().

ECAL-driven momentum.

Definition at line 206 of file Electron.h.

Referenced by ecalDrivenMomentum(), and setEcalDrivenMomentum().

double pat::Electron::edB_ [protected]

Definition at line 211 of file Electron.h.

Referenced by edB(), and setDB().

std::vector<double> pat::Electron::eip_ [protected]

Definition at line 216 of file Electron.h.

Referenced by edB(), initImpactParameters(), and setDB().

std::vector<IdPair> pat::Electron::electronIDs_ [protected]

Definition at line 192 of file Electron.h.

Referenced by electronID(), electronIDs(), isElectronIDAvailable(), and setElectronIDs().

Definition at line 182 of file Electron.h.

Referenced by core(), and embedGsfElectronCore().

Definition at line 184 of file Electron.h.

Referenced by embedGsfTrack(), and gsfTrack().

true if the IsolatedPFCandidate is embedded

Definition at line 196 of file Electron.h.

Referenced by embedPFCandidate(), pfCandidateRef(), and sourceCandidatePtr().

Definition at line 186 of file Electron.h.

Referenced by embedSuperCluster(), and superCluster().

Definition at line 188 of file Electron.h.

Referenced by embedTrack(), and track().

Definition at line 183 of file Electron.h.

Referenced by core(), and embedGsfElectronCore().

std::vector<reco::GsfTrack> pat::Electron::gsfTrack_ [protected]

Definition at line 185 of file Electron.h.

Referenced by embedGsfTrack(), and gsfTrack().

std::vector<double> pat::Electron::ip_ [protected]

Definition at line 215 of file Electron.h.

Referenced by dB(), initImpactParameters(), and setDB().

if embeddedPFCandidate_, a copy of the source IsolatedPFCandidate is stored in this vector

Definition at line 199 of file Electron.h.

Referenced by embedPFCandidate(), and pfCandidateRef().

reference to the IsolatedPFCandidate this has been built from null if this has been built from a standard electron

Definition at line 202 of file Electron.h.

Referenced by embedPFCandidate(), numberOfSourceCandidatePtrs(), pfCandidateRef(), setPFCandidateRef(), and sourceCandidatePtr().

Definition at line 187 of file Electron.h.

Referenced by embedSuperCluster(), and superCluster().

std::vector<reco::Track> pat::Electron::track_ [protected]

Definition at line 189 of file Electron.h.

Referenced by embedTrack(), and track().