CMS 3D CMS Logo

Electron.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_Electron_h
5 #define DataFormats_PatCandidates_Electron_h
6 
28 
34 
35 // Define typedefs for convenience
36 namespace pat {
37  class Electron;
38  typedef std::vector<Electron> ElectronCollection;
41 }
42 
43 namespace reco {
45  std::ostream& operator<<(std::ostream& out, const pat::Electron& obj);
46 }
47 
48 // Class definition
49 namespace pat {
50  class PATElectronSlimmer;
51 
52  class Electron : public Lepton<reco::GsfElectron> {
53 
54  public:
55 
56  typedef std::pair<std::string,float> IdPair;
57 
59  Electron();
61  Electron(const reco::GsfElectron & anElectron);
63  Electron(const edm::RefToBase<reco::GsfElectron> & anElectronRef);
65  Electron(const edm::Ptr<reco::GsfElectron> & anElectronRef);
67  ~Electron() override;
68 
70  Electron * clone() const override { return new Electron(*this); }
71 
72  // ---- methods for content embedding ----
74  reco::GsfElectronCoreRef core() const override;
76  reco::GsfTrackRef gsfTrack() const override;
78  reco::SuperClusterRef superCluster() const override;
80  reco::SuperClusterRef parentSuperCluster() const override;
82  reco::TrackRef track() const override;
84  reco::TrackRef closestCtfTrackRef() const override;
86  reco::CaloClusterPtr seed() const;
87 
88  //method to access the basic clusters
89  const std::vector<reco::CaloCluster>& basicClusters() const { return basicClusters_ ; }
90  //method to access the preshower clusters
91  const std::vector<reco::CaloCluster>& preshowerClusters() const { return preshowerClusters_ ; }
92  //method to access the pflow basic clusters
93  const std::vector<reco::CaloCluster>& pflowBasicClusters() const { return pflowBasicClusters_ ; }
94  //method to access the pflow preshower clusters
95  const std::vector<reco::CaloCluster>& pflowPreshowerClusters() const { return pflowPreshowerClusters_ ; }
96 
97  using reco::RecoCandidate::track; // avoid hiding the base implementation
99  void embedGsfElectronCore();
101  void embedGsfTrack();
103  void embedSuperCluster();
105  void embedPflowSuperCluster();
107  void embedSeedCluster();
109  void embedBasicClusters();
111  void embedPreshowerClusters();
117  void embedTrack();
120 
121  // ---- methods for electron ID ----
123  // For cut-based IDs, the value map has the following meaning:
124  // 0: fails,
125  // 1: passes electron ID only,
126  // 2: passes electron Isolation only,
127  // 3: passes electron ID and Isolation only,
128  // 4: passes conversion rejection,
129  // 5: passes conversion rejection and ID,
130  // 6: passes conversion rejection and Isolation,
131  // 7: passes the whole selection.
132  // For more details have a look at:
133  // https://twiki.cern.ch/twiki/bin/view/CMS/SimpleCutBasedEleID
134  // https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCategoryBasedElectronID
135  // Note: an exception is thrown if the specified ID is not available
136  float electronID(const std::string& name) const;
137  float electronID(const char* name) const { return electronID( std::string(name) );}
139  bool isElectronIDAvailable(const std::string& name) const;
140  bool isElectronIDAvailable(const char* name) const {
141  return isElectronIDAvailable(std::string(name));
142  }
144  const std::vector<IdPair> & electronIDs() const { return electronIDs_; }
146  void setElectronIDs(const std::vector<IdPair> & ids) { electronIDs_ = ids; }
147 
148  // ---- overload of isolation functions ----
150  float trackIso() const { return dr04TkSumPt(); }
152  float ecalIso() const { return dr04EcalRecHitSumEt(); }
154  float hcalIso() const { return dr04HcalTowerSumEt(); }
156  float caloIso() const { return ecalIso()+hcalIso(); }
158  float puppiChargedHadronIso() const {return puppiChargedHadronIso_; }
159  float puppiNeutralHadronIso() const {return puppiNeutralHadronIso_; }
160  float puppiPhotonIso() const {return puppiPhotonIso_; }
162  float puppiNoLeptonsChargedHadronIso() const {return puppiNoLeptonsChargedHadronIso_; }
163  float puppiNoLeptonsNeutralHadronIso() const {return puppiNoLeptonsNeutralHadronIso_; }
164  float puppiNoLeptonsPhotonIso() const {return puppiNoLeptonsPhotonIso_; }
166  void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_)
167  {
168  puppiChargedHadronIso_ = chargedhadrons_;
169  puppiNeutralHadronIso_ = neutralhadrons_;
170  puppiPhotonIso_ = photons_;
171 
172  }
174  void setIsolationPUPPINoLeptons(float chargedhadrons_, float neutralhadrons_, float photons_)
175  {
176  puppiNoLeptonsChargedHadronIso_ = chargedhadrons_;
177  puppiNoLeptonsNeutralHadronIso_ = neutralhadrons_;
178  puppiNoLeptonsPhotonIso_ = photons_;
179 
180  }
181  // ---- PF specific methods ----
182  bool isPF() const{ return isPF_; }
183  void setIsPF(bool hasPFCandidate) { isPF_ = hasPFCandidate ; }
184 
186  reco::PFCandidateRef pfCandidateRef() const;
189  pfCandidateRef_ = ref;
190  }
192  void embedPFCandidate();
194  size_t numberOfSourceCandidatePtrs() const override {
195  return (pfCandidateRef_.isNonnull() ? 1 : 0) + associatedPackedFCandidateIndices_.size();
196  }
198  reco::CandidatePtr sourceCandidatePtr( size_type i ) const override;
199 
200  // ---- embed various impact parameters with errors ----
201  typedef enum IPTYPE { PV2D = 0, PV3D = 1, BS2D = 2, BS3D = 3, PVDZ = 4, IpTypeSize = 5 } IpType;
203  double dB(IPTYPE type) const;
205  double edB(IPTYPE type) const;
207  double dB() const { return std::abs(dB(PV2D)); }
209  double edB() const { return std::abs(edB(PV2D)); }
211  void setDB(double dB, double edB, IPTYPE type);
212 
213  // ---- Momentum estimate specific methods ----
214  const LorentzVector & ecalDrivenMomentum() const {return ecalDrivenMomentum_;}
215  void setEcalDrivenMomentum(const Candidate::LorentzVector& mom) {ecalDrivenMomentum_=mom;}
216 
218  friend std::ostream& reco::operator<<(std::ostream& out, const pat::Electron& obj);
219 
222  float sigmaIetaIphi() const { return sigmaIetaIphi_; }
224  float full5x5_sigmaIetaIphi() const { return full5x5_sigmaIetaIphi_; }
226  double ip3d() const { return ip3d_; }
228  void setMvaVariables( double sigmaIetaIphi, double ip3d );
229  void full5x5_setSigmaIetaIphi(float sigmaIetaIphi) { full5x5_sigmaIetaIphi_ = sigmaIetaIphi; }
230 
231  const EcalRecHitCollection * recHits() const { return &recHits_;}
232 
235  double ecalRegressionEnergy() const { return ecalRegressionEnergy_;}
236  double ecalRegressionError() const { return ecalRegressionError_;}
238  double ecalTrackRegressionEnergy() const { return ecalTrackRegressionEnergy_; }
239  double ecalTrackRegressionError() const { return ecalTrackRegressionError_; }
241  void setEcalRegressionEnergy(double val, double err) { ecalRegressionEnergy_ = val; ecalRegressionError_ = err; }
243  void setEcalTrackRegressionEnergy(double val, double err) { ecalTrackRegressionEnergy_ = val; ecalTrackRegressionError_ = err; }
244 
246  void setEcalScale(double val) { ecalScale_= val ;}
247  void setEcalSmear(double val) { ecalSmear_= val;}
248  void setEcalRegressionScale(double val) { ecalRegressionScale_ = val ;}
249  void setEcalRegressionSmear(double val) { ecalRegressionSmear_ = val;}
250  void setEcalTrackRegressionScale(double val) { ecalTrackRegressionScale_ = val;}
251  void setEcalTrackRegressionSmear(double val) { ecalTrackRegressionSmear_ = val;}
252 
254  double ecalScale() const { return ecalScale_ ;}
255  double ecalSmear() const { return ecalSmear_;}
256  double ecalRegressionScale() const { return ecalRegressionScale_ ;}
257  double ecalRegressionSmear() const { return ecalRegressionSmear_ ;}
258  double ecalTrackRegressionScale() const { return ecalTrackRegressionScale_ ;}
259  double ecalTrackRegressionSmear() const { return ecalTrackRegressionSmear_ ;}
261  bool passConversionVeto() const { return passConversionVeto_; }
262  void setPassConversionVeto( bool flag ) { passConversionVeto_ = flag; }
263 
265  edm::RefVector<pat::PackedCandidateCollection> associatedPackedPFCandidates() const ;
267  template<typename T>
269  T beginIndexItr,
270  T endIndexItr) {
271  packedPFCandidates_ = refprod;
272  associatedPackedFCandidateIndices_.clear();
273  associatedPackedFCandidateIndices_.insert(associatedPackedFCandidateIndices_.end(),
274  beginIndexItr,
275  endIndexItr);
276  }
277 
278  friend class PATElectronSlimmer;
279 
280  protected:
282  void initImpactParameters();
283 
284  // ---- for content embedding ----
288  std::vector<reco::GsfElectronCore> gsfElectronCore_;
292  std::vector<reco::GsfTrack> gsfTrack_;
298  std::vector<reco::SuperCluster> superCluster_;
302  std::vector<reco::CaloCluster> basicClusters_;
304  std::vector<reco::CaloCluster> preshowerClusters_;
306  std::vector<reco::CaloCluster> pflowBasicClusters_;
308  std::vector<reco::CaloCluster> pflowPreshowerClusters_;
310  std::vector<reco::SuperCluster> pflowSuperCluster_;
314  std::vector<reco::Track> track_;
318  std::vector<reco::CaloCluster> seedCluster_;
323 
324  // ---- electron ID's holder ----
326  std::vector<IdPair> electronIDs_;
327 
328  // ---- PF specific members ----
329  bool isPF_;
336 
337  // ---- specific members : Momentum estimates ----
340 
342  float sigmaIetaIphi_, full5x5_sigmaIetaIphi_;
343  double ip3d_;
344 
350 
352  double ecalScale_;
353  double ecalSmear_;
354 
357 
360 
365 
370 
373 
374  // ---- cached impact parameters ----
376  uint8_t cachedIP_;
378  float ip_[IpTypeSize];
380  float eip_[IpTypeSize];
381 
382  // ---- link to PackedPFCandidates
384  std::vector<uint16_t> associatedPackedFCandidateIndices_;
385  };
386 }
387 
388 #endif
float trackIso() const
Overload of pat::Lepton::trackIso(); returns the value of the summed track pt in a cone of deltaR<0...
Definition: Electron.h:150
type
Definition: HCALResponse.h:21
float puppiNoLeptonsChargedHadronIso() const
returns PUPPINoLeptons isolations
Definition: Electron.h:162
double ecalTrackRegressionSmear() const
Definition: Electron.h:259
double ecalTrackRegressionScale() const
Definition: Electron.h:258
uint8_t cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:376
bool embeddedTrack_
True if electron&#39;s track is stored internally.
Definition: Electron.h:312
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron&#39;s gsfTrack internally.
Definition: Electron.h:292
double ecalRegressionEnergy_
output of regression
Definition: Electron.h:346
embedPFCandidate
embed in AOD externally stored the electron&#39;s pflow preshower clusters
void setElectronIDs(const std::vector< IdPair > &ids)
Store multiple electron ID values, discarding existing ones. The first one in the list becomes the &#39;d...
Definition: Electron.h:146
double dB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) ...
Definition: Electron.h:207
double ecalScale() const
get scale corrections /smearings
Definition: Electron.h:254
size_t size_type
Definition: Candidate.h:30
double ecalScale_
scale corrections and smearing applied or to be be applied. Initialized to -99999.
Definition: Electron.h:352
float puppiChargedHadronIso_
PUPPI isolations.
Definition: Electron.h:362
double ip3d() const
ip3d
Definition: Electron.h:226
const LorentzVector & ecalDrivenMomentum() const
Definition: Electron.h:214
embedPreshowerClusters
embed in AOD externally stored the electron&#39;s basic clusters
embedGsfTrack
embed in AOD externally stored gsf electron core
float caloIso() const
Overload of pat::Lepton::caloIso(); returns the sum of ecalIso() and hcalIso.
Definition: Electron.h:156
const std::vector< reco::CaloCluster > & basicClusters() const
Definition: Electron.h:89
embedPflowSuperCluster
embed in AOD externally stored supercluster
Electron * clone() const override
required reimplementation of the Candidate&#39;s clone method
Definition: Electron.h:70
Definition: __init__.py:1
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Electron.h:188
embedRecHits
embed in AOD externally stored track (note: gsf electrons don&#39;t have a track)
void full5x5_setSigmaIetaIphi(float sigmaIetaIphi)
Definition: Electron.h:229
void setPassConversionVeto(bool flag)
Definition: Electron.h:262
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:298
Slimmer of PAT Electrons.
double ecalTrackRegressionSmear_
Definition: Electron.h:359
double ecalRegressionScale() const
Definition: Electron.h:256
std::vector< reco::Track > track_
Place to store electron&#39;s track internally.
Definition: Electron.h:314
electronID
electronId to be used for probe the following types are available:
void setEcalDrivenMomentum(const Candidate::LorentzVector &mom)
Definition: Electron.h:215
bool embeddedGsfElectronCore_
True if electron&#39;s gsfElectronCore is stored internally.
Definition: Electron.h:286
double ecalRegressionSmear() const
Definition: Electron.h:257
const EcalRecHitCollection * recHits() const
Definition: Electron.h:231
const std::vector< reco::CaloCluster > & pflowBasicClusters() const
Definition: Electron.h:93
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:306
float electronID(const char *name) const
Definition: Electron.h:137
virtual reco::TrackRef track() const
reference to a Track
Definition: HeavyIon.h:7
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Electron.h:383
float puppiNeutralHadronIso() const
Definition: Electron.h:159
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:302
embedBasicClusters
embed in AOD externally stored the electron&#39;s seedcluster
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Electron.h:384
size_t numberOfSourceCandidatePtrs() const override
get the number of non-null PFCandidates
Definition: Electron.h:194
double ecalRegressionSmear_
Definition: Electron.h:356
edm::RefVector< ElectronCollection > ElectronRefVector
Definition: Electron.h:40
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Electron.h:304
embedTrack
embed in AOD externally stored particle flow candidate
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:320
float puppiNoLeptonsPhotonIso() const
Definition: Electron.h:164
float puppiNoLeptonsChargedHadronIso_
PUPPINoLeptons isolations.
Definition: Electron.h:367
double edB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) ...
Definition: Electron.h:209
double ecalTrackRegressionError_
Definition: Electron.h:349
enum pat::Electron::IPTYPE IpType
void setEcalTrackRegressionSmear(double val)
Definition: Electron.h:251
void setIsolationPUPPINoLeptons(float chargedhadrons_, float neutralhadrons_, float photons_)
sets PUPPINoLeptons isolations
Definition: Electron.h:174
std::ostream & operator<<(std::ostream &out, const strbitset::index_type &r)
Definition: strbitset.cc:27
bool passConversionVeto_
conversion veto
Definition: Electron.h:372
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:316
edm::AtomicPtrCache< std::vector< reco::SuperCluster > > superClusterRelinked_
Place to temporarily store the electron&#39;s supercluster after relinking the seed to it...
Definition: Electron.h:300
const std::vector< reco::CaloCluster > & pflowPreshowerClusters() const
Definition: Electron.h:95
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< IdPair > & electronIDs() const
Returns all the electron IDs in the form of <name,value> pairs. The &#39;default&#39; ID is the first in the ...
Definition: Electron.h:144
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron&#39;s gsfElectronCore internally.
Definition: Electron.h:288
double ecalTrackRegressionEnergy() const
regression2
Definition: Electron.h:238
double ip3d_
Definition: Electron.h:343
float puppiNoLeptonsPhotonIso_
Definition: Electron.h:369
float puppiNoLeptonsNeutralHadronIso_
Definition: Electron.h:368
float full5x5_sigmaIetaIphi() const
sigmaIEtaIPhi (from full 5x5 non-ZS clusters without fractions, a la 5.3.X)
Definition: Electron.h:224
double ecalTrackRegressionEnergy_
Definition: Electron.h:347
double ecalRegressionError() const
Definition: Electron.h:236
bool isPF() const
Definition: Electron.h:182
double ecalTrackRegressionError() const
Definition: Electron.h:239
embedSeedCluster
embed in AOD externally stored supercluster
float ecalIso() const
Overload of pat::Lepton::ecalIso(); returns the value of the summed Et of all recHits in the ecal in ...
Definition: Electron.h:152
double ecalRegressionError_
Definition: Electron.h:348
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:322
void setEcalTrackRegressionEnergy(double val, double err)
set regression2
Definition: Electron.h:243
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True...
Definition: Electron.h:333
void setEcalScale(double val)
set scale corrections / smearings
Definition: Electron.h:246
void setEcalRegressionScale(double val)
Definition: Electron.h:248
bool embeddedGsfTrack_
True if electron&#39;s gsfTrack is stored internally.
Definition: Electron.h:290
edm::Ref< ElectronCollection > ElectronRef
Definition: Electron.h:39
void setIsPF(bool hasPFCandidate)
Definition: Electron.h:183
bool isElectronIDAvailable(const char *name) const
Definition: Electron.h:140
double ecalSmear() const
Definition: Electron.h:255
float puppiNoLeptonsNeutralHadronIso() const
Definition: Electron.h:163
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:296
float puppiPhotonIso_
Definition: Electron.h:364
float puppiPhotonIso() const
Definition: Electron.h:160
void setEcalRegressionSmear(double val)
Definition: Electron.h:249
Analysis-level electron class.
Definition: Electron.h:52
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:326
void setEcalSmear(double val)
Definition: Electron.h:247
bool passConversionVeto() const
vertex fit combined with missing number of hits method
Definition: Electron.h:261
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
reco::PFCandidateRef pfCandidateRef_
reference to the IsolatedPFCandidate this has been built from; null if this has been built from a sta...
Definition: Electron.h:335
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:294
float puppiNeutralHadronIso_
Definition: Electron.h:363
fixed size matrix
embedSuperCluster
embed in AOD externally stored gsf track
void setEcalTrackRegressionScale(double val)
Definition: Electron.h:250
embedPflowPreshowerClusters
embed in AOD externally stored the electron&#39;s pflow basic clusters
double ecalRegressionScale_
Definition: Electron.h:355
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:308
double ecalSmear_
Definition: Electron.h:353
std::pair< std::string, float > IdPair
Definition: Electron.h:56
float sigmaIetaIphi() const
Definition: Electron.h:222
float puppiChargedHadronIso() const
returns PUPPI isolations
Definition: Electron.h:158
const std::vector< reco::CaloCluster > & preshowerClusters() const
Definition: Electron.h:91
void setAssociatedPackedPFCandidates(const edm::RefProd< pat::PackedCandidateCollection > &refprod, T beginIndexItr, T endIndexItr)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Electron.h:268
Definition: Lepton.py:1
LorentzVector ecalDrivenMomentum_
ECAL-driven momentum.
Definition: Electron.h:339
embedPflowBasicClusters
embed in AOD externally stored the electron&#39;s preshower clusters
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:331
long double T
double ecalTrackRegressionScale_
Definition: Electron.h:358
double ecalRegressionEnergy() const
Definition: Electron.h:235
void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_)
sets PUPPI isolations
Definition: Electron.h:166
void setEcalRegressionEnergy(double val, double err)
set regression1
Definition: Electron.h:241
math::PtEtaPhiELorentzVectorF LorentzVector
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:310
float hcalIso() const
Overload of pat::Lepton::hcalIso(); returns the value of the summed Et of all caloTowers in the hcal ...
Definition: Electron.h:154
float sigmaIetaIphi_
additional missing mva variables : 14/04/2012
Definition: Electron.h:342
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:318