Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef DataFormats_PatCandidates_Lepton_h
00006 #define DataFormats_PatCandidates_Lepton_h
00007
00023 #include "DataFormats/Candidate/interface/Particle.h"
00024 #include "DataFormats/PatCandidates/interface/PATObject.h"
00025 #include "DataFormats/PatCandidates/interface/Isolation.h"
00026
00027
00028 namespace pat {
00029
00030
00031 template <class LeptonType>
00032 class Lepton : public PATObject<LeptonType> {
00033
00034 public:
00035
00036 Lepton();
00037 Lepton(const LeptonType & aLepton);
00038 Lepton(const edm::RefToBase<LeptonType> & aLeptonRef);
00039 Lepton(const edm::Ptr<LeptonType> & aLeptonRef);
00040 virtual ~Lepton();
00041
00042 virtual Lepton<LeptonType> * clone() const { return new Lepton<LeptonType>(*this); }
00043
00044 const reco::GenParticle * genLepton() const { return PATObject<LeptonType>::genParticle(); }
00045
00046 void setGenLepton(const reco::GenParticleRef & gl, bool embed=false) { PATObject<LeptonType>::setGenParticleRef(gl, embed); }
00047
00048
00051 float userIsolation(IsolationKeys key) const {
00052 if (key >= 0) {
00053
00054
00055
00056 if (size_t(key) >= isolations_.size()) return -1.0;
00057 return isolations_[key];
00058 } else switch (key) {
00059 case pat::CaloIso:
00060
00061
00062 if (isolations_.size() <= pat::HcalIso) return -1.0;
00063 return isolations_[pat::EcalIso] + isolations_[pat::HcalIso];
00064 default:
00065 return -1.0;
00066
00067
00068 }
00069 }
00074 float userIsolation(const std::string& key) const {
00075
00076 std::string prunedKey = ( key.find("pat::") == 0 ) ? std::string(key, 5) : key;
00077 if ( prunedKey == "TrackIso" ) return userIsolation(pat::TrackIso);
00078 if ( prunedKey == "EcalIso" ) return userIsolation(pat::EcalIso);
00079 if ( prunedKey == "HcalIso" ) return userIsolation(pat::HcalIso);
00080 if ( prunedKey == "PfAllParticleIso" ) return userIsolation(pat::PfAllParticleIso);
00081 if ( prunedKey == "PfChargedHadronIso" ) return userIsolation(pat::PfChargedHadronIso);
00082 if ( prunedKey == "PfNeutralHadronIso" ) return userIsolation(pat::PfNeutralHadronIso);
00083 if ( prunedKey == "PfGammaIso" ) return userIsolation(pat::PfGammaIso);
00084 if ( prunedKey == "User1Iso" ) return userIsolation(pat::User1Iso);
00085 if ( prunedKey == "User2Iso" ) return userIsolation(pat::User2Iso);
00086 if ( prunedKey == "User3Iso" ) return userIsolation(pat::User3Iso);
00087 if ( prunedKey == "User4Iso" ) return userIsolation(pat::User4Iso);
00088 if ( prunedKey == "User5Iso" ) return userIsolation(pat::User5Iso);
00089 if ( prunedKey == "UserBaseIso" ) return userIsolation(pat::UserBaseIso);
00090 if ( prunedKey == "CaloIso" ) return userIsolation(pat::CaloIso);
00091 if ( prunedKey == "PfPUChargedHadronIso" ) return userIsolation(pat::PfPUChargedHadronIso);
00092
00093
00094
00095 return -1.0;
00096 }
00100 void setIsolation(IsolationKeys key, float value) {
00101 if (key >= 0) {
00102 if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
00103 isolations_[key] = value;
00104 } else {
00105 throw cms::Exception("Illegal Argument") <<
00106 "The key for which you're setting isolation does not correspond " <<
00107 "to an individual isolation but to the sum of more independent isolations " <<
00108 "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
00109 "Please set up each component independly.\n";
00110 }
00111 }
00112
00113
00118 float trackIso() const { return userIsolation(pat::TrackIso); }
00123 float caloIso() const { return userIsolation(pat::CaloIso); }
00128 float ecalIso() const { return userIsolation(pat::EcalIso); }
00133 float hcalIso() const { return userIsolation(pat::HcalIso); }
00134
00137 float particleIso() const { return userIsolation(pat::PfAllParticleIso); }
00140 float chargedHadronIso() const { return userIsolation(pat::PfChargedHadronIso); }
00143 float neutralHadronIso() const { return userIsolation(pat::PfNeutralHadronIso); }
00146 float photonIso() const { return userIsolation(pat::PfGammaIso); }
00149 float puChargedHadronIso() const { return userIsolation(pat::PfPUChargedHadronIso); }
00152 float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
00153
00154
00156 void setTrackIso(float trackIso) { setIsolation(pat::TrackIso, trackIso); }
00158 void setEcalIso(float caloIso) { setIsolation(pat::EcalIso, caloIso); }
00160 void setHcalIso(float caloIso) { setIsolation(pat::HcalIso, caloIso); }
00162 void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
00163
00164
00165
00167 const IsoDeposit * isoDeposit(IsolationKeys key) const {
00168 for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00169 it != ed; ++it)
00170 {
00171 if (it->first == key) return & it->second;
00172 }
00173 return 0;
00174 }
00175
00177 void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep) {
00178 IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00179 for (; it != ed; ++it) {
00180 if (it->first == key) { it->second = dep; return; }
00181 }
00182 isoDeposits_.push_back(std::make_pair(key,dep));
00183 }
00184
00185
00186 const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
00187 const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
00188 const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
00189 const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
00190
00191
00192 void trackIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::TrackIso,dep); }
00193 void ecalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::EcalIso, dep); }
00194 void hcalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::HcalIso, dep); }
00195 void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
00196
00197
00198 protected:
00199
00200 typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
00201 IsoDepositPairs isoDeposits_;
00202 std::vector<float> isolations_;
00203 };
00204
00205
00207 template <class LeptonType>
00208 Lepton<LeptonType>::Lepton() :
00209 PATObject<LeptonType>(LeptonType()) {
00210
00211 this->setCharge(0);
00212 this->setP4(reco::Particle::LorentzVector(0, 0, 0, 0));
00213 this->setVertex(reco::Particle::Point(0, 0, 0));
00214 }
00215
00216
00218 template <class LeptonType>
00219 Lepton<LeptonType>::Lepton(const LeptonType & aLepton) :
00220 PATObject<LeptonType>(aLepton) {
00221 }
00222
00223
00225 template <class LeptonType>
00226 Lepton<LeptonType>::Lepton(const edm::RefToBase<LeptonType> & aLeptonRef) :
00227 PATObject<LeptonType>(aLeptonRef) {
00228 }
00229
00230
00232 template <class LeptonType>
00233 Lepton<LeptonType>::Lepton(const edm::Ptr<LeptonType> & aLeptonRef) :
00234 PATObject<LeptonType>(aLeptonRef) {
00235 }
00236
00237
00239 template <class LeptonType>
00240 Lepton<LeptonType>::~Lepton() {
00241 }
00242 }
00243
00244 #endif