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 
27 namespace pat {
28 
29 
30  template <class LeptonType>
31  class Lepton : public PATObject<LeptonType> {
32 
33  public:
34 
35  Lepton();
36  Lepton(const LeptonType & aLepton);
37  Lepton(const edm::RefToBase<LeptonType> & aLeptonRef);
38  Lepton(const edm::Ptr<LeptonType> & aLeptonRef);
39  virtual ~Lepton();
40 
41  virtual Lepton<LeptonType> * clone() const { return new Lepton<LeptonType>(*this); }
42 
44 
46 
47  //============ BEGIN ISOLATION BLOCK =====
51  if (key >= 0) {
52  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
53  //<< "Isolation corresponding to key "
54  //<< key << " was not stored for this particle.";
55  if (size_t(key) >= isolations_.size()) return -1.0;
56  return isolations_[key];
57  } else 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) return -1.0;
63  default:
64  return -1.0;
65  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
66  //<< key << " was not stored for this particle.";
67  }
68  }
73  float userIsolation(const std::string& key) const {
74  // remove leading namespace specifier
75  std::string prunedKey = ( key.find("pat::") == 0 ) ? std::string(key, 5) : key;
76  if ( prunedKey == "TrackIso" ) return userIsolation(pat::TrackIso);
77  if ( prunedKey == "EcalIso" ) return userIsolation(pat::EcalIso);
78  if ( prunedKey == "HcalIso" ) return userIsolation(pat::HcalIso);
79  if ( prunedKey == "PfAllParticleIso" ) return userIsolation(pat::PfAllParticleIso);
80  if ( prunedKey == "PfChargedHadronIso" ) return userIsolation(pat::PfChargedHadronIso);
81  if ( prunedKey == "PfNeutralHadronIso" ) return userIsolation(pat::PfNeutralHadronIso);
82  if ( prunedKey == "PfGammaIso" ) return userIsolation(pat::PfGammaIso);
83  if ( prunedKey == "User1Iso" ) return userIsolation(pat::User1Iso);
84  if ( prunedKey == "User2Iso" ) return userIsolation(pat::User2Iso);
85  if ( prunedKey == "User3Iso" ) return userIsolation(pat::User3Iso);
86  if ( prunedKey == "User4Iso" ) return userIsolation(pat::User4Iso);
87  if ( prunedKey == "User5Iso" ) return userIsolation(pat::User5Iso);
88  if ( prunedKey == "UserBaseIso" ) return userIsolation(pat::UserBaseIso);
89  if ( prunedKey == "CaloIso" ) return userIsolation(pat::CaloIso);
90  if ( prunedKey == "PfPUChargedHadronIso" ) return userIsolation(pat::PfPUChargedHadronIso);
91  //throw cms::Excepton("Missing Data")
92  //<< "Isolation corresponding to key "
93  //<< key << " was not stored for this particle.";
94  return -1.0;
95  }
100  if (key >= 0) {
101  if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
102  isolations_[key] = value;
103  } else {
104  throw cms::Exception("Illegal Argument") <<
105  "The key for which you're setting isolation does not correspond " <<
106  "to an individual isolation but to the sum of more independent isolations " <<
107  "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
108  "Please set up each component independly.\n";
109  }
110  }
111 
112  // ---- specific getters ----
117  float trackIso() const { return userIsolation(pat::TrackIso); }
122  float caloIso() const { return userIsolation(pat::CaloIso); }
127  float ecalIso() const { return userIsolation(pat::EcalIso); }
132  float hcalIso() const { return userIsolation(pat::HcalIso); }
133 
145  float photonIso() const { return userIsolation(pat::PfGammaIso); }
151  float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
152 
153  // ---- specific setters ----
155  void setTrackIso(float trackIso) { setIsolation(pat::TrackIso, trackIso); }
157  void setEcalIso(float caloIso) { setIsolation(pat::EcalIso, caloIso); }
159  void setHcalIso(float caloIso) { setIsolation(pat::HcalIso, caloIso); }
161  void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
162 
163 
164  //============ BEGIN ISODEPOSIT BLOCK =====
167  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
168  it != ed; ++it)
169  {
170  if (it->first == key) return & it->second;
171  }
172  return 0;
173  }
174 
177  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
178  for (; it != ed; ++it) {
179  if (it->first == key) { it->second = dep; return; }
180  }
181  isoDeposits_.push_back(std::make_pair(key,dep));
182  }
183 
184  // ---- specific getters ----
185  const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
186  const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
187  const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
188  const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
189 
190  // ---- specific setters ----
194  void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
195 
196  const PFIsolation& miniPFIsolation() const { return miniPFIsolation_; }
197  void setMiniPFIsolation(PFIsolation const& iso) { miniPFIsolation_ = iso; }
198 
199  protected:
200  // --- Isolation and IsoDeposit related datamebers ---
201  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
202  IsoDepositPairs isoDeposits_;
203  std::vector<float> isolations_;
204 
206  };
207 
208 
210  template <class LeptonType>
213  // no common constructor, so initialize the candidate manually
214  this->setCharge(0);
215  this->setP4(reco::Particle::LorentzVector(0, 0, 0, 0));
216  this->setVertex(reco::Particle::Point(0, 0, 0));
218  }
219 
220 
222  template <class LeptonType>
224  PATObject<LeptonType>(aLepton) {
226  }
227 
228 
230  template <class LeptonType>
232  PATObject<LeptonType>(aLeptonRef) {
234  }
235 
236 
238  template <class LeptonType>
240  PATObject<LeptonType>(aLeptonRef) {
242  }
243 
244 
246  template <class LeptonType>
248  }
249 }
250 
251 #endif
void ecalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:192
float ecalIso() const
Definition: Lepton.h:127
const IsoDeposit * trackIsoDeposit() const
Definition: Lepton.h:185
const reco::GenParticle * genLepton() const
Definition: Lepton.h:43
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:99
void trackIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:191
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Lepton.h:201
Lepton()
default constructor
Definition: Lepton.h:211
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:244
const IsoDeposit * hcalIsoDeposit() const
Definition: Lepton.h:187
float userIso(uint8_t index=0) const
Definition: Lepton.h:151
void hcalIsoDeposit(const IsoDeposit &dep)
Definition: Lepton.h:193
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:166
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:671
#define embed
Definition: AMPTWrapper.h:178
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:176
Definition: HeavyIon.h:7
const PFIsolation & miniPFIsolation() const
Definition: Lepton.h:196
float particleIso() const
Definition: Lepton.h:136
float neutralHadronIso() const
Definition: Lepton.h:142
float puChargedHadronIso() const
Definition: Lepton.h:148
void setGenLepton(const reco::GenParticleRef &gl, bool embed=false)
Definition: Lepton.h:45
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable #index.
Definition: Lepton.h:161
Analysis-level lepton class.
Definition: Lepton.h:31
math::XYZPoint Point
point in the space
Definition: Particle.h:25
virtual Lepton< LeptonType > * clone() const
Definition: Lepton.h:41
const IsoDeposit * ecalIsoDeposit() const
Definition: Lepton.h:186
Definition: value.py:1
float trackIso() const
Definition: Lepton.h:117
IsoDepositPairs isoDeposits_
Definition: Lepton.h:202
float userIsolation(const std::string &key) const
Definition: Lepton.h:73
unsigned int index
index type
Definition: Candidate.h:51
float userIsolation(IsolationKeys key) const
Definition: Lepton.h:50
std::vector< float > isolations_
Definition: Lepton.h:203
float photonIso() const
Definition: Lepton.h:145
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:197
float caloIso() const
Definition: Lepton.h:122
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Definition: Lepton.h:194
float hcalIso() const
Definition: Lepton.h:132
PFIsolation miniPFIsolation_
Definition: Lepton.h:205
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Lepton.h:155
virtual ~Lepton()
destructor
Definition: Lepton.h:247
Templated PAT object container.
Definition: PATObject.h:49
Definition: Lepton.py:1
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Lepton.h:157
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Lepton.h:159
float chargedHadronIso() const
Definition: Lepton.h:139
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Definition: Lepton.h:188
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21