CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFCandidate.h
Go to the documentation of this file.
1 #ifndef ParticleFlowCandidate_PFCandidate_h
2 #define ParticleFlowCandidate_PFCandidate_h
3 
9 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
10 #include <atomic>
11 #endif
12 #include <iosfwd>
13 
15 
32 namespace reco {
40 
41  public:
42 
44  enum ParticleType {
45  X=0, // undefined
46  h, // charged hadron
47  e, // electron
48  mu, // muon
49  gamma, // photon
50  h0, // neutral hadron
51  h_HF, // HF tower identified as a hadron
52  egamma_HF // HF tower identified as an EM particle
53  };
54 
55  enum Flags {
56  NORMAL=0,
73  };
74 
75 
76  enum PFVertexType {
85  };
86 
87 
89  PFCandidate();
90 
92  PFCandidate( const PFCandidatePtr& sourcePtr );
93 
94  /* PFCandidate( Charge q, */
95  /* const LorentzVector & p4, */
96  /* ParticleType particleId, */
97  /* reco::PFBlockRef blockRef ); */
99  const LorentzVector & p4,
101 
103  PFCandidate( const PFCandidate&);
104 
106  virtual ~PFCandidate();
107 
109 
111  virtual PFCandidate * clone() const;
112 
113 
114  /* /// set source ref */
115  /* void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
116 
117  /* size_type numberOfSourceCandidateRefs() const {return 1;} */
118 
119  /* CandidateBaseRef sourceCandidateRef( size_type i ) const { */
120  /* return CandidateBaseRef(sourceRef_); */
121  /* } */
122 
124  void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
125 
126  size_t numberOfSourceCandidatePtrs() const {
127  return 1;
128  }
129 
131  return sourcePtr_;
132  }
133 
138  ParticleType translatePdgIdToType(int pdgid) const;
139 
142 
143 
145  /* void addElement( const reco::PFBlockElement* element ); */
146 
148  void addElementInBlock( const reco::PFBlockRef& blockref,
149  unsigned elementIndex );
150 
152  void setTrackRef(const reco::TrackRef& ref);
153 
156  reco::TrackRef trackRef() const;
157 
160  virtual const reco::Track * bestTrack() const {
161  if ( (abs(pdgId()) == 11 || pdgId() == 22) && gsfTrackRef().isNonnull() && gsfTrackRef().isAvailable() )
162  return &(*gsfTrackRef());
163  else if ( trackRef().isNonnull() && trackRef().isAvailable() )
164  return &(*trackRef());
165  else
166  return nullptr;
167  }
168 
170  void setGsfTrackRef(const reco::GsfTrackRef& ref);
171 
175 
177  void setMuonRef(const reco::MuonRef& ref);
178 
181  reco::MuonRef muonRef() const;
182 
183 
184 
185 
188 
192 
194  void setConversionRef(const reco::ConversionRef& ref);
195 
198 
201 
204 
207 
210 
212  void setEcalEnergy( float eeRaw, float eeCorr ) {
213  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
214 
216  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
217 
219  double rawEcalEnergy() const { return rawEcalEnergy_;}
220 
222  void setHcalEnergy( float ehRaw, float ehCorr ) {
223  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
224 
226  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
227 
229  double rawHcalEnergy() const { return rawHcalEnergy_;}
230 
232  void setHoEnergy( float eoRaw, float eoCorr ) {
233  rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
234 
236  double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
237 
239  double rawHoEnergy() const { return rawHoEnergy_;}
240 
242  void setGsfElectronRef (const reco::GsfElectronRef & ref);
243 
244  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
245 
248 
250  void setPhotonRef(const reco::PhotonRef& phRef);
251 
253  reco::PhotonRef photonRef() const;
254 
257 
260 
263 
266 
268  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
269 
271  double pS1Energy() const { return ps1Energy_;}
272 
274  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
275 
277  double pS2Energy() const { return ps2Energy_;}
278 
280  void rescaleMomentum( double rescaleFactor );
281 
283  void setFlag(Flags theFlag, bool value);
284 
286  bool flag(Flags theFlag) const;
287 
289  void setDeltaP(double dp ) {deltaP_ = dp;}
290 
292  double deltaP() const { return deltaP_;}
293 
294  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
295 
301 
302  void set_mva_Isolated( float mvaI ){ mva_Isolated_=mvaI;}
303  // mva for isolated electrons
304  float mva_Isolated() const { return mva_Isolated_;}
305 
306  void set_mva_e_pi( float mvaNI ){ mva_e_pi_=mvaNI;}
308  float mva_e_pi() const { return mva_e_pi_;}
309 
311  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
312 
314  float mva_e_mu() const { return mva_e_mu_;}
315 
317  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
318 
320  float mva_pi_mu() const { return mva_pi_mu_;}
321 
322 
324  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
325 
327  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
328 
330  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
331 
333  float mva_nothing_nh() const { return mva_nothing_nh_;}
334 
335 
337  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
338 
340  float mva_gamma_nh() const { return mva_gamma_nh_;}
341 
345  }
346 
349 
353  }
354 
356 
358  return muonTrackType_;
359  }
360 
364  }
365 
369 
370 
372  /* const std::vector<unsigned>& elementIndices() const { */
373  /* return elementIndices_; */
374  /* } */
376  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
377  /* {return elements_;} */
378 
380  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
381  typedef std::vector< ElementInBlock > ElementsInBlocks;
382 
384  typedef std::vector<unsigned> Elements;
385 
386  const ElementsInBlocks& elementsInBlocks() const;
387 
388  static const float bigMva_;
389 
390  friend std::ostream& operator<<( std::ostream& out,
391  const PFCandidate& c );
392 
393  //Tips on setting the vertex efficiently
394  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
395  //of one of the refs stored by this class. The PFVertexType enum gives the current list
396  //of possible references. For these references, use the setVeretxSource method and NOT
397  //the setVertex method. If none of the available refs have the vertex that you want for this
398  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
399  // vertex that is the same as one of the refs in this class, you should just extend the enum
400  // and modify the vertex() method accordingly.
402 
403  virtual void setVertex( const math::XYZPoint& p) {
405  }
406 
407  virtual const Point & vertex() const;
408  virtual double vx() const {return vertex().x();}
409  virtual double vy() const {return vertex().y();}
410  virtual double vz() const {return vertex().z();}
411 
412  private:
414  virtual bool overlap( const Candidate & ) const;
415 
416  void setFlag(unsigned shift, unsigned flag, bool value);
417 
418  bool flag(unsigned shift, unsigned flag) const;
419 
420 
421 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
422  mutable std::atomic<ElementsInBlocks*> elementsInBlocks_;
423 #else
425 #endif
428 
430  /* PFCandidateRef sourceRef_; */
432 
433 
437 
439  float ecalERatio_;
440 
442  float hcalERatio_;
443 
445  float hoERatio_;
446 
449 
452 
455 
457  float ps1Energy_;
458 
460  float ps2Energy_;
461 
463  unsigned flags_;
464 
466  float deltaP_;
467 
469 
470  // mva for isolated electrons
472 
474  float mva_e_pi_;
475 
477  float mva_e_mu_;
478 
480  float mva_pi_mu_;
481 
484 
487 
490 
493 
494 
495  //more efficiently stored refs
496  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
497  const edm::RefCore& iCore, size_t iKey,
498  const edm::EDProductGetter*);
499  bool getRefInfo(unsigned int iMask, unsigned int iBit,
500  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
501 
502 
503  const edm::EDProductGetter* getter_; //transient
504  unsigned short storedRefsBitPattern_;
505  std::vector<unsigned long long> refsInfo_;
506  std::vector<const void *> refsCollectionCache_;
507 
508  };
509 
511  struct PFParticleIdTag { };
512 
515  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
516 
520 
521  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
522 
523 
524 }
525 
526 #endif
bool isAvailable() const
Definition: Ref.h:276
type
Definition: HCALResponse.h:21
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:216
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:466
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:274
int i
Definition: DBlmapReader.cc:9
virtual double vz() const
z coordinate of vertex position
Definition: PFCandidate.h:410
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:289
friend std::ostream & operator<<(std::ostream &out, const PFCandidate &c)
void setPs1Energy(float e1)
set corrected PS1 energy
Definition: PFCandidate.h:268
ParticleType
particle types
Definition: PFCandidate.h:44
reco::Muon::MuonTrackType muonTrackType_
Definition: PFCandidate.h:436
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:503
void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef &ref)
set the PF Photon Extra Ref
Definition: PFCandidate.cc:636
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:219
void setGsfElectronRef(const reco::GsfElectronRef &ref)
set GsfElectronRef
Definition: PFCandidate.cc:569
void setFlag(Flags theFlag, bool value)
set a given flag
Definition: PFCandidate.cc:285
bool getRefInfo(unsigned int iMask, unsigned int iBit, edm::ProductID &oProdID, size_t &oIndex, size_t &aIndex) const
Definition: PFCandidate.cc:401
void set_mva_e_mu(float mva)
set mva for electron-muon discrimination
Definition: PFCandidate.h:311
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:184
virtual bool overlap(const Candidate &) const
Polymorphic overlap.
Definition: PFCandidate.cc:261
void set_mva_nothing_gamma(float mva)
set mva for gamma detection
Definition: PFCandidate.h:324
size_t size_type
Definition: Candidate.h:34
virtual double p() const GCC11_FINAL
magnitude of momentum vector
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:343
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:327
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:442
int pdgId_
PDG identifier.
virtual int pdgId() const GCC11_FINAL
PDG identifier.
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:451
const reco::Muon::MuonTrackType bestMuonTrackType() const
get the Best Muon Track Ref
Definition: PFCandidate.h:357
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:206
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:463
double rawHoEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:239
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:477
static const float bigMva_
Definition: PFCandidate.h:388
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:126
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:486
virtual void setVertex(const math::XYZPoint &p)
set vertex
Definition: PFCandidate.h:403
float hoERatio_
corrected HO energy ratio (corrected/raw)
Definition: PFCandidate.h:445
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:383
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:124
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
reco::PFCandidatePhotonExtraRef photonExtraRef() const
return a reference to the photon extra
Definition: PFCandidate.cc:592
float mva_gamma_nh_
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:489
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:439
Point vertex_
vertex position
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:480
particle ID component tag
Definition: PFCandidate.h:511
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:362
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:381
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:314
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:408
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:448
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:474
reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const
Definition: PFCandidate.cc:519
void set_mva_pi_mu(float mva)
set mva for pi-muon discrimination
Definition: PFCandidate.h:317
CandidatePtr sourceCandidatePtr(size_type i) const
Definition: PFCandidate.h:130
void set_mva_nothing_nh(float mva)
set mva for neutral hadron detection
Definition: PFCandidate.h:330
void set_mva_e_pi(float mvaNI)
Definition: PFCandidate.h:306
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:271
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:505
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:320
void setDisplacedVertexRef(const reco::PFDisplacedVertexRef &ref, Flags flag)
set displaced vertex reference
Definition: PFCandidate.cc:475
float mva_nothing_nh() const
mva for neutral hadron detection
Definition: PFCandidate.h:333
float mva_Isolated() const
Definition: PFCandidate.h:304
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< unsigned > Elements
Definition: PFCandidate.h:384
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:401
void set_mva_Isolated(float mvaI)
Definition: PFCandidate.h:302
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:457
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
Definition: PFCandidate.cc:211
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
Definition: PFCandidate.h:351
void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef &ref)
set the PF Electron Extra Ref
Definition: PFCandidate.cc:579
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:256
reco::PhotonRef photonRef() const
return a reference to the corresponding Photon if any
Definition: PFCandidate.cc:588
ParticleType
bool flag(Flags theFlag) const
return a given flag
Definition: PFCandidate.cc:295
math::XYZPoint Point
unsigned short storedRefsBitPattern_
Definition: PFCandidate.h:504
int translateTypeToPdgId(ParticleType type) const
Definition: PFCandidate.cc:238
GET_CANDIDATE_COMPONENT(PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::GsfElectronRef gsfElectronRef() const
return a reference to the corresponding GsfElectron if any
Definition: PFCandidate.cc:574
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:647
float rawHoEnergy_
raw HO energy
Definition: PFCandidate.h:454
void rescaleMomentum(double rescaleFactor)
particle momentum *= rescaleFactor
Definition: PFCandidate.cc:278
virtual ~PFCandidate()
destructor
Definition: PFCandidate.cc:202
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:212
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:308
tuple out
Definition: dbtoconf.py:99
Float e1
Definition: deltaR.h:22
double hoEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:236
reco::PFCandidateElectronExtraRef electronExtraRef() const
return a reference to the electron extra
Definition: PFCandidate.cc:584
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidate.cc:454
PFCandidate()
default constructor
Definition: PFCandidate.cc:31
auto dp
Definition: deltaR.h:24
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setPhotonRef(const reco::PhotonRef &phRef)
set ref to the corresponding reco::Photon if any
Definition: PFCandidate.cc:604
void setConversionRef(const reco::ConversionRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:530
void set_mva_gamma_nh(float mva)
set mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:337
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:409
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:224
Float e2
Definition: deltaR.h:23
PFCandidate & operator=(PFCandidate const &)
Definition: PFCandidate.cc:163
std::atomic< ElementsInBlocks * > elementsInBlocks_
Definition: PFCandidate.h:422
PFVertexType vertexType_
Definition: PFCandidate.h:468
void setHoEnergy(float eoRaw, float eoCorr)
set corrected Hcal energy
Definition: PFCandidate.h:232
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:431
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
reco::VertexCompositeCandidateRef v0Ref() const
return a reference to the original conversion
Definition: PFCandidate.cc:564
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:436
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
return indices of elements used in the block
Definition: PFCandidate.h:380
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:492
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:483
reco::PFCandidateEGammaExtraRef egammaExtraRef() const
return a reference to the EGamma extra
Definition: PFCandidate.cc:596
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:471
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:641
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:226
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:277
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:460
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:620
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:38
void setV0Ref(const reco::VertexCompositeCandidateRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:559
float mva_gamma_nh() const
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:340
virtual ParticleType particleId() const
Definition: PFCandidate.h:368
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:416
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:679
virtual const reco::Track * bestTrack() const
Definition: PFCandidate.h:160
Elements elementsStorage_
Definition: PFCandidate.h:427
reco::ConversionRef conversionRef() const
return a reference to the original conversion
Definition: PFCandidate.cc:554
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy
Definition: PFCandidate.h:222
int Charge
electric charge type
Definition: LeafCandidate.h:26
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:506
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:292
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:229
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:32
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:600
void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid, const edm::RefCore &iCore, size_t iKey, const edm::EDProductGetter *)
Definition: PFCandidate.cc:361