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
00050 float isolation(IsolationKeys key) const {
00051 if (key >= 0) {
00052
00053 if (size_t(key) >= isolations_.size()) return -1.0;
00054 return isolations_[key];
00055 } else switch (key) {
00056 case CaloIso:
00057
00058 if (isolations_.size() <= HCalIso) return -1.0;
00059 return isolations_[ECalIso] + isolations_[HCalIso];
00060 default:
00061 return -1.0;
00062
00063 }
00064 }
00065
00068 void setIsolation(IsolationKeys key, float value) {
00069 if (key >= 0) {
00070 if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
00071 isolations_[key] = value;
00072 } else {
00073 throw cms::Exception("Illegal Argument") <<
00074 "The key for which you're setting isolation does not correspond " <<
00075 "to an individual isolation but to the sum of more independent isolations " <<
00076 "(e.g. Calo = ECal + HCal), so you can't SET the value, just GET it.\n" <<
00077 "Please set up each component independly.\n";
00078 }
00079 }
00080
00081
00083 float trackIso() const { return isolation(TrackerIso); }
00085 float caloIso() const { return isolation(CaloIso); }
00087 float ecalIso() const { return isolation(ECalIso); }
00089 float hcalIso() const { return isolation(HCalIso); }
00090
00093 float particleIso() const { return isolation(ParticleIso); }
00095 float chargedParticleIso() const { return isolation(ChargedParticleIso); }
00097 float neutralParticleIso() const { return isolation(NeutralParticleIso); }
00099 float gammaParticleIso() const { return isolation(GammaParticleIso); }
00100
00102 float userIso(uint8_t index=0) const { return isolation(IsolationKeys(UserBaseIso + index)); }
00103
00104
00106 void setTrackIso(float trackIso) { setIsolation(TrackerIso, trackIso); }
00108 void setECalIso(float caloIso) { setIsolation(ECalIso, caloIso); }
00110 void setHCalIso(float caloIso) { setIsolation(HCalIso, caloIso); }
00112 void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
00113
00114
00115
00117 const IsoDeposit * isoDeposit(IsolationKeys key) const {
00118 for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00119 it != ed; ++it)
00120 {
00121 if (it->first == key) return & it->second;
00122 }
00123 return 0;
00124 }
00125
00127 void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep) {
00128 IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00129 for (; it != ed; ++it) {
00130 if (it->first == key) { it->second = dep; return; }
00131 }
00132 isoDeposits_.push_back(std::make_pair(key,dep));
00133 }
00134
00135
00136 const IsoDeposit * trackerIsoDeposit() const { return isoDeposit(TrackerIso); }
00137 const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(ECalIso); }
00138 const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(HCalIso); }
00139 const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
00140
00141
00142 void trackerIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(TrackerIso, dep); }
00143 void ecalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(ECalIso, dep); }
00144 void hcalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(HCalIso, dep); }
00145 void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
00146
00147
00148 protected:
00149
00150 typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
00151 IsoDepositPairs isoDeposits_;
00152 std::vector<float> isolations_;
00153 };
00154
00155
00157 template <class LeptonType>
00158 Lepton<LeptonType>::Lepton() :
00159 PATObject<LeptonType>(LeptonType()) {
00160
00161 this->setCharge(0);
00162 this->setP4(reco::Particle::LorentzVector(0, 0, 0, 0));
00163 this->setVertex(reco::Particle::Point(0, 0, 0));
00164 }
00165
00166
00168 template <class LeptonType>
00169 Lepton<LeptonType>::Lepton(const LeptonType & aLepton) :
00170 PATObject<LeptonType>(aLepton) {
00171 }
00172
00173
00175 template <class LeptonType>
00176 Lepton<LeptonType>::Lepton(const edm::RefToBase<LeptonType> & aLeptonRef) :
00177 PATObject<LeptonType>(aLeptonRef) {
00178 }
00179
00180
00182 template <class LeptonType>
00183 Lepton<LeptonType>::Lepton(const edm::Ptr<LeptonType> & aLeptonRef) :
00184 PATObject<LeptonType>(aLeptonRef) {
00185 }
00186
00187
00189 template <class LeptonType>
00190 Lepton<LeptonType>::~Lepton() {
00191 }
00192 }
00193
00194 #endif