CMS 3D CMS Logo

Lepton.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_Lepton_h
5 #define DataFormats_PatCandidates_Lepton_h
6 
25 
26 namespace pat {
27 
28  template <class LeptonType>
29  class Lepton : public PATObject<LeptonType> {
30  public:
31  Lepton();
32  Lepton(const LeptonType &aLepton);
33  Lepton(const edm::RefToBase<LeptonType> &aLeptonRef);
34  Lepton(const edm::Ptr<LeptonType> &aLeptonRef);
35  ~Lepton() override;
36 
37  Lepton<LeptonType> *clone() const override { return new Lepton<LeptonType>(*this); }
38 
40 
41  void setGenLepton(const reco::GenParticleRef &gl, bool embed = false) {
43  }
44 
45  //============ BEGIN ISOLATION BLOCK =====
49  if (key >= 0) {
50  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
51  //<< "Isolation corresponding to key "
52  //<< key << " was not stored for this particle.";
53  if (size_t(key) >= isolations_.size())
54  return -1.0;
55  return isolations_[key];
56  } else
57  switch (key) {
58  case pat::CaloIso:
59  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
60  //<< "CaloIso Isolation was not stored for this particle.";
61  if (isolations_.size() <= pat::HcalIso)
62  return -1.0;
64  default:
65  return -1.0;
66  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
67  //<< key << " was not stored for this particle.";
68  }
69  }
74  float userIsolation(const std::string &key) const {
75  // remove leading namespace specifier
76  std::string prunedKey = (key.find("pat::") == 0) ? std::string(key, 5) : key;
77  if (prunedKey == "TrackIso")
79  if (prunedKey == "EcalIso")
81  if (prunedKey == "HcalIso")
83  if (prunedKey == "PfAllParticleIso")
85  if (prunedKey == "PfChargedHadronIso")
87  if (prunedKey == "PfNeutralHadronIso")
89  if (prunedKey == "PfGammaIso")
91  if (prunedKey == "User1Iso")
93  if (prunedKey == "User2Iso")
95  if (prunedKey == "User3Iso")
97  if (prunedKey == "User4Iso")
99  if (prunedKey == "User5Iso")
101  if (prunedKey == "UserBaseIso")
103  if (prunedKey == "CaloIso")
104  return userIsolation(pat::CaloIso);
105  if (prunedKey == "PfPUChargedHadronIso")
107  //throw cms::Excepton("Missing Data")
108  //<< "Isolation corresponding to key "
109  //<< key << " was not stored for this particle.";
110  return -1.0;
111  }
116  if (key >= 0) {
117  if (size_t(key) >= isolations_.size())
118  isolations_.resize(key + 1, -1.0);
119  isolations_[key] = value;
120  } else {
121  throw cms::Exception("Illegal Argument")
122  << "The key for which you're setting isolation does not correspond "
123  << "to an individual isolation but to the sum of more independent isolations "
124  << "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n"
125  << "Please set up each component independly.\n";
126  }
127  }
128 
129  // ---- specific getters ----
134  float trackIso() const { return userIsolation(pat::TrackIso); }
139  float caloIso() const { return userIsolation(pat::CaloIso); }
144  float ecalIso() const { return userIsolation(pat::EcalIso); }
149  float hcalIso() const { return userIsolation(pat::HcalIso); }
150 
162  float photonIso() const { return userIsolation(pat::PfGammaIso); }
168  float userIso(uint8_t index = 0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
169 
170  // ---- specific setters ----
179 
180  //============ BEGIN ISODEPOSIT BLOCK =====
183  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end(); it != ed; ++it) {
184  if (it->first == key)
185  return &it->second;
186  }
187  return nullptr;
188  }
189 
192  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
193  for (; it != ed; ++it) {
194  if (it->first == key) {
195  it->second = dep;
196  return;
197  }
198  }
199  isoDeposits_.push_back(std::make_pair(key, dep));
200  }
201 
202  // ---- specific getters ----
204  const IsoDeposit *ecalIsoDeposit() const { return isoDeposit(pat::EcalIso); }
205  const IsoDeposit *hcalIsoDeposit() const { return isoDeposit(pat::HcalIso); }
206  const IsoDeposit *userIsoDeposit(uint8_t index = 0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
207 
208  // ---- specific setters ----
212  void userIsoDeposit(const IsoDeposit &dep, uint8_t index = 0) {
214  }
215 
216  const PFIsolation &miniPFIsolation() const { return miniPFIsolation_; }
217  void setMiniPFIsolation(PFIsolation const &iso) { miniPFIsolation_ = iso; }
218 
219  protected:
220  // --- Isolation and IsoDeposit related datamebers ---
221  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
223  std::vector<float> isolations_;
224 
226  };
227 
229  template <class LeptonType>
231  // no common constructor, so initialize the candidate manually
232  this->setCharge(0);
233  this->setP4(reco::Particle::LorentzVector(0, 0, 0, 0));
234  this->setVertex(reco::Particle::Point(0, 0, 0));
235  this->setMiniPFIsolation(pat::PFIsolation());
236  }
237 
239  template <class LeptonType>
241  this->setMiniPFIsolation(pat::PFIsolation());
242  }
243 
245  template <class LeptonType>
247  this->setMiniPFIsolation(pat::PFIsolation());
248  }
249 
251  template <class LeptonType>
253  this->setMiniPFIsolation(pat::PFIsolation());
254  }
255 
257  template <class LeptonType>
259 } // namespace pat
260 
261 #endif
pat::User3Iso
Definition: Isolation.h:19
embed
#define embed
Definition: AMPTWrapper.h:188
pat::EcalIso
Definition: Isolation.h:11
PFIsolation.h
pat::Lepton::userIso
float userIso(uint8_t index=0) const
Definition: Lepton.h:168
pat::Lepton::setGenLepton
void setGenLepton(const reco::GenParticleRef &gl, bool embed=false)
Definition: Lepton.h:41
pat::Lepton::ecalIso
float ecalIso() const
Definition: Lepton.h:144
Lepton
Definition: Lepton.py:1
pat::Lepton::ecalIsoDeposit
void ecalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:210
reco::GenParticle
Definition: GenParticle.h:21
pat::Lepton::IsoDepositPairs
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Lepton.h:221
pat::Lepton::caloIso
float caloIso() const
Definition: Lepton.h:139
pat::Lepton
Analysis-level lepton class.
Definition: Lepton.h:29
pat::Lepton::setIsolation
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:115
pat::PfAllParticleIso
Definition: Isolation.h:13
pat::Lepton::userIsolation
float userIsolation(IsolationKeys key) const
Definition: Lepton.h:48
pat::User5Iso
Definition: Isolation.h:21
pat::Lepton::miniPFIsolation
const PFIsolation & miniPFIsolation() const
Definition: Lepton.h:216
pat::Lepton::puChargedHadronIso
float puChargedHadronIso() const
Definition: Lepton.h:165
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
edm::Ref< GenParticleCollection >
pat::User4Iso
Definition: Isolation.h:20
pat::User1Iso
Definition: Isolation.h:17
pat::Lepton::isoDeposit
const IsoDeposit * isoDeposit(IsolationKeys key) const
Returns the IsoDeposit associated with some key, or a null pointer if it is not available.
Definition: Lepton.h:182
pat::PfChargedHadronIso
Definition: Isolation.h:14
pat::Lepton::photonIso
float photonIso() const
Definition: Lepton.h:162
pat::PATObject
Templated PAT object container.
Definition: PATObject.h:48
pat::Lepton::setIsoDeposit
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Lepton.h:191
Particle.h
pat::Lepton::genLepton
const reco::GenParticle * genLepton() const
Definition: Lepton.h:39
Isolation.h
pat::Lepton::isoDeposits_
IsoDepositPairs isoDeposits_
Definition: Lepton.h:222
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pat::Lepton::~Lepton
~Lepton() override
destructor
Definition: Lepton.h:258
pat::Lepton::userIsoDeposit
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Definition: Lepton.h:206
pat::Lepton::neutralHadronIso
float neutralHadronIso() const
Definition: Lepton.h:159
pat::Lepton::userIsoDeposit
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Definition: Lepton.h:212
pat::User2Iso
Definition: Isolation.h:18
pat::PfGammaIso
Definition: Isolation.h:16
btagElecInJet_cfi.Lepton
Lepton
Definition: btagElecInJet_cfi.py:8
pat::Lepton::chargedHadronIso
float chargedHadronIso() const
Definition: Lepton.h:156
pat::UserBaseIso
Definition: Isolation.h:22
pat::Lepton::ecalIsoDeposit
const IsoDeposit * ecalIsoDeposit() const
Definition: Lepton.h:204
pat::TrackIso
Definition: Isolation.h:10
pat::HcalIso
Definition: Isolation.h:12
value
Definition: value.py:1
pat::PfNeutralHadronIso
Definition: Isolation.h:15
pat::Lepton::setMiniPFIsolation
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:217
pat
Definition: HeavyIon.h:7
pat::PATObject::setGenParticleRef
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:748
pat::PfPUChargedHadronIso
Definition: Isolation.h:24
edm::Ptr
Definition: AssociationVector.h:31
pat::PFIsolation
Definition: PFIsolation.h:12
WDecay::LeptonType
LeptonType
Definition: TopGenEvent.h:27
pat::Lepton::setTrackIso
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Lepton.h:172
pat::Lepton::trackIso
float trackIso() const
Definition: Lepton.h:134
pat::Lepton::userIsolation
float userIsolation(const std::string &key) const
Definition: Lepton.h:74
pat::Lepton::hcalIsoDeposit
const IsoDeposit * hcalIsoDeposit() const
Definition: Lepton.h:205
pat::IsolationKeys
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
pat::PATObject::genParticle
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:290
pat::Lepton::trackIsoDeposit
void trackIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:209
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Exception
Definition: hltDiff.cc:246
pat::Lepton::isolations_
std::vector< float > isolations_
Definition: Lepton.h:223
reco::Candidate::index
unsigned int index
index type
Definition: Candidate.h:50
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::RefToBase
Definition: AssociativeIterator.h:54
pat::CaloIso
Definition: Isolation.h:23
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
pat::Lepton::clone
Lepton< LeptonType > * clone() const override
Definition: Lepton.h:37
pat::Lepton::particleIso
float particleIso() const
Definition: Lepton.h:153
pat::Lepton::hcalIso
float hcalIso() const
Definition: Lepton.h:149
pat::Lepton::trackIsoDeposit
const IsoDeposit * trackIsoDeposit() const
Definition: Lepton.h:203
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::Lepton::miniPFIsolation_
PFIsolation miniPFIsolation_
Definition: Lepton.h:225
pat::Lepton::hcalIsoDeposit
void hcalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:211
pat::Lepton::setUserIso
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable #index.
Definition: Lepton.h:178
pat::Lepton::setHcalIso
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Lepton.h:176
pat::Lepton::setEcalIso
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Lepton.h:174
pat::Lepton::Lepton
Lepton()
default constructor
Definition: Lepton.h:230
PATObject.h