CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ----
172  void setTrackIso(float trackIso) { setIsolation(pat::TrackIso, trackIso); }
174  void setEcalIso(float caloIso) { setIsolation(pat::EcalIso, caloIso); }
176  void setHcalIso(float caloIso) { setIsolation(pat::HcalIso, caloIso); }
178  void setUserIso(float value, uint8_t index = 0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
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));
236  }
237 
239  template <class LeptonType>
242  }
243 
245  template <class LeptonType>
248  }
249 
251  template <class LeptonType>
254  }
255 
257  template <class LeptonType>
259 } // namespace pat
260 
261 #endif
void ecalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:210
float ecalIso() const
Definition: Lepton.h:144
const IsoDeposit * trackIsoDeposit() const
Definition: Lepton.h:203
const reco::GenParticle * genLepton() const
Definition: Lepton.h:39
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:115
void trackIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:209
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Lepton.h:221
Lepton()
default constructor
Definition: Lepton.h:230
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:285
const IsoDeposit * hcalIsoDeposit() const
Definition: Lepton.h:205
float userIso(uint8_t index=0) const
Definition: Lepton.h:168
void hcalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:211
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
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
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:743
#define embed
Definition: AMPTWrapper.h:188
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
const PFIsolation & miniPFIsolation() const
Definition: Lepton.h:216
float particleIso() const
Definition: Lepton.h:153
float neutralHadronIso() const
Definition: Lepton.h:159
float puChargedHadronIso() const
Definition: Lepton.h:165
void setGenLepton(const reco::GenParticleRef &gl, bool embed=false)
Definition: Lepton.h:41
~Lepton() override
destructor
Definition: Lepton.h:258
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable #index.
Definition: Lepton.h:178
Analysis-level lepton class.
Definition: Lepton.h:29
tuple key
prepare the HTCondor submission files and eventually submit them
math::XYZPoint Point
point in the space
Definition: Particle.h:25
const IsoDeposit * ecalIsoDeposit() const
Definition: Lepton.h:204
float trackIso() const
Definition: Lepton.h:134
IsoDepositPairs isoDeposits_
Definition: Lepton.h:222
float userIsolation(const std::string &key) const
Definition: Lepton.h:74
unsigned int index
index type
Definition: Candidate.h:50
float userIsolation(IsolationKeys key) const
Definition: Lepton.h:48
std::vector< float > isolations_
Definition: Lepton.h:223
float photonIso() const
Definition: Lepton.h:162
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:217
float caloIso() const
Definition: Lepton.h:139
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Definition: Lepton.h:212
float hcalIso() const
Definition: Lepton.h:149
PFIsolation miniPFIsolation_
Definition: Lepton.h:225
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Lepton.h:172
Templated PAT object container.
Definition: PATObject.h:43
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Lepton.h:174
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Lepton.h:176
float chargedHadronIso() const
Definition: Lepton.h:156
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Definition: Lepton.h:206
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
Lepton< LeptonType > * clone() const override
Definition: Lepton.h:37