00001
00002
00003
00004
00005 #include "DataFormats/PatCandidates/interface/Electron.h"
00006 #include "FWCore/Utilities/interface/Exception.h"
00007
00008 using namespace pat;
00009
00010
00012 Electron::Electron() :
00013 Lepton<ElectronType>(),
00014 embeddedGsfTrack_(false),
00015 embeddedSuperCluster_(false),
00016 embeddedTrack_(false),
00017 scSigmaEtaEta_(0),
00018 scSigmaIEtaIEta_(0),
00019 scE1x5_(0),
00020 scE2x5Max_(0),
00021 scE5x5_(0)
00022 {
00023 }
00024
00025
00027 Electron::Electron(const ElectronType & anElectron) :
00028 Lepton<ElectronType>(anElectron),
00029 embeddedGsfTrack_(false),
00030 embeddedSuperCluster_(false),
00031 embeddedTrack_(false),
00032 scSigmaEtaEta_(0),
00033 scSigmaIEtaIEta_(0),
00034 scE1x5_(0),
00035 scE2x5Max_(0),
00036 scE5x5_(0)
00037 {
00038 }
00039
00040
00042 Electron::Electron(const edm::RefToBase<ElectronType> & anElectronRef) :
00043 Lepton<ElectronType>(anElectronRef),
00044 embeddedGsfTrack_(false),
00045 embeddedSuperCluster_(false),
00046 embeddedTrack_(false),
00047 scSigmaEtaEta_(0),
00048 scSigmaIEtaIEta_(0),
00049 scE1x5_(0),
00050 scE2x5Max_(0),
00051 scE5x5_(0)
00052 {
00053 }
00054
00056 Electron::Electron(const edm::Ptr<ElectronType> & anElectronRef) :
00057 Lepton<ElectronType>(anElectronRef),
00058 embeddedGsfTrack_(false),
00059 embeddedSuperCluster_(false),
00060 embeddedTrack_(false),
00061 scSigmaEtaEta_(0),
00062 scSigmaIEtaIEta_(0),
00063 scE1x5_(0),
00064 scE2x5Max_(0),
00065 scE5x5_(0)
00066 {
00067 }
00068
00069
00071 Electron::~Electron() {
00072 }
00073
00074
00076 reco::GsfTrackRef Electron::gsfTrack() const {
00077 if (embeddedGsfTrack_) {
00078 return reco::GsfTrackRef(&gsfTrack_, 0);
00079 } else {
00080 return ElectronType::gsfTrack();
00081 }
00082 }
00083
00084
00086 reco::SuperClusterRef Electron::superCluster() const {
00087 if (embeddedSuperCluster_) {
00088 return reco::SuperClusterRef(&superCluster_, 0);
00089 } else {
00090 return ElectronType::superCluster();
00091 }
00092 }
00093
00094
00096 reco::TrackRef Electron::track() const {
00097 if (embeddedTrack_) {
00098 return reco::TrackRef(&track_, 0);
00099 } else {
00100 return ElectronType::track();
00101 }
00102 }
00103
00105 void Electron::embedGsfTrack() {
00106 gsfTrack_.clear();
00107 if (ElectronType::gsfTrack().isNonnull()) {
00108 gsfTrack_.push_back(*ElectronType::gsfTrack());
00109 embeddedGsfTrack_ = true;
00110 }
00111 }
00112
00113
00115 void Electron::embedSuperCluster() {
00116 superCluster_.clear();
00117 if (ElectronType::superCluster().isNonnull()) {
00118 superCluster_.push_back(*ElectronType::superCluster());
00119 embeddedSuperCluster_ = true;
00120 }
00121 }
00122
00123
00125 void Electron::embedTrack() {
00126 track_.clear();
00127 if (ElectronType::track().isNonnull()) {
00128 track_.push_back(*ElectronType::track());
00129 embeddedTrack_ = true;
00130 }
00131 }
00132
00133
00134 float Electron::electronID(const std::string & name) const {
00135 for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
00136 if (it->first == name) return it->second;
00137 }
00138 cms::Exception ex("Key not found");
00139 ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
00140 ex << "The available IDs are: ";
00141 for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
00142 ex << "'" << it->first << "' ";
00143 }
00144 ex << ".\n";
00145 throw ex;
00146 }
00147
00148 bool Electron::isElectronIDAvailable(const std::string & name) const {
00149 for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
00150 if (it->first == name) return true;
00151 }
00152 return false;
00153 }
00155 void Electron::setClusterShapes (const float& scSigmaEtaEta, const float& scSigmaIEtaIEta,
00156 const float& scE1x5, const float& scE2x5Max, const float& scE5x5)
00157 {
00158 scSigmaEtaEta_ = scSigmaEtaEta ;
00159 scSigmaIEtaIEta_ = scSigmaIEtaIEta ;
00160 scE1x5_ = scE1x5 ;
00161 scE2x5Max_ = scE2x5Max ;
00162 scE5x5_ = scE5x5 ;
00163 }
00164
00165
00167 reco::PFCandidateRef Electron::pfCandidateRef() const {
00168 if (embeddedPFCandidate_) {
00169 return reco::PFCandidateRef(&pfCandidate_, 0);
00170 } else {
00171 return pfCandidateRef_;
00172 }
00173 }
00175 void Electron::embedPFCandidate() {
00176 pfCandidate_.clear();
00177 if ( pfCandidateRef_.isAvailable() && pfCandidateRef_.isNonnull()) {
00178 pfCandidate_.push_back( *pfCandidateRef_ );
00179 embeddedPFCandidate_ = true;
00180 }
00181 }
00182
00183