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 {
86  };
87 
88 
90  PFCandidate();
91 
93  PFCandidate( const PFCandidatePtr& sourcePtr );
94 
95  /* PFCandidate( Charge q, */
96  /* const LorentzVector & p4, */
97  /* ParticleType particleId, */
98  /* reco::PFBlockRef blockRef ); */
100  const LorentzVector & p4,
102 
104  PFCandidate( const PFCandidate&);
105 
107  virtual ~PFCandidate();
108 
110 
112  virtual PFCandidate * clone() const;
113 
114 
115  /* /// set source ref */
116  /* void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
117 
118  /* size_type numberOfSourceCandidateRefs() const {return 1;} */
119 
120  /* CandidateBaseRef sourceCandidateRef( size_type i ) const { */
121  /* return CandidateBaseRef(sourceRef_); */
122  /* } */
123 
125  void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
126 
127  size_t numberOfSourceCandidatePtrs() const {
128  return 1;
129  }
130 
132  return sourcePtr_;
133  }
134 
139  ParticleType translatePdgIdToType(int pdgid) const;
140 
143 
144 
146  /* void addElement( const reco::PFBlockElement* element ); */
147 
149  void addElementInBlock( const reco::PFBlockRef& blockref,
150  unsigned elementIndex );
151 
153  void setTrackRef(const reco::TrackRef& ref);
154 
157  reco::TrackRef trackRef() const;
158 
161  virtual const reco::Track * bestTrack() const {
162  if ( (abs(pdgId()) == 11 || pdgId() == 22) && gsfTrackRef().isNonnull() && gsfTrackRef().isAvailable() )
163  return &(*gsfTrackRef());
164  else if ( trackRef().isNonnull() && trackRef().isAvailable() )
165  return &(*trackRef());
166  else
167  return nullptr;
168  }
170  virtual float dzError() const { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dzError(); else return 0; }
172  virtual float dxyError() const { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dxyError(); else return 0; }
173 
175  void setGsfTrackRef(const reco::GsfTrackRef& ref);
176 
180 
182  void setMuonRef(const reco::MuonRef& ref);
183 
186  reco::MuonRef muonRef() const;
187 
188 
189 
190 
193 
197 
199  void setConversionRef(const reco::ConversionRef& ref);
200 
203 
206 
209 
212 
215 
217  void setEcalEnergy( float eeRaw, float eeCorr ) {
218  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
219 
221  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
222 
224  double rawEcalEnergy() const { return rawEcalEnergy_;}
225 
227  void setHcalEnergy( float ehRaw, float ehCorr ) {
228  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
229 
231  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
232 
234  double rawHcalEnergy() const { return rawHcalEnergy_;}
235 
237  void setHoEnergy( float eoRaw, float eoCorr ) {
238  rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
239 
241  double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
242 
244  double rawHoEnergy() const { return rawHoEnergy_;}
245 
247  void setGsfElectronRef (const reco::GsfElectronRef & ref);
248 
249  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
250 
253 
255  void setPhotonRef(const reco::PhotonRef& phRef);
256 
258  reco::PhotonRef photonRef() const;
259 
262 
265 
268 
271 
273  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
274 
276  double pS1Energy() const { return ps1Energy_;}
277 
279  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
280 
282  double pS2Energy() const { return ps2Energy_;}
283 
285  void rescaleMomentum( double rescaleFactor );
286 
288  void setFlag(Flags theFlag, bool value);
289 
291  bool flag(Flags theFlag) const;
292 
294  void setDeltaP(double dp ) {deltaP_ = dp;}
295 
297  double deltaP() const { return deltaP_;}
298 
299  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
300 
306 
307  void set_mva_Isolated( float mvaI ){ mva_Isolated_=mvaI;}
308  // mva for isolated electrons
309  float mva_Isolated() const { return mva_Isolated_;}
310 
311  void set_mva_e_pi( float mvaNI ){ mva_e_pi_=mvaNI;}
313  float mva_e_pi() const { return mva_e_pi_;}
314 
316  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
317 
319  float mva_e_mu() const { return mva_e_mu_;}
320 
322  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
323 
325  float mva_pi_mu() const { return mva_pi_mu_;}
326 
327 
329  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
330 
332  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
333 
335  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
336 
338  float mva_nothing_nh() const { return mva_nothing_nh_;}
339 
340 
342  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
343 
345  float mva_gamma_nh() const { return mva_gamma_nh_;}
346 
350  }
351 
354 
358  }
359 
361 
363  return muonTrackType_;
364  }
365 
369  }
370 
373  virtual ParticleType particleId() const { return translatePdgIdToType(pdgId());}
374 
375 
377  /* const std::vector<unsigned>& elementIndices() const { */
378  /* return elementIndices_; */
379  /* } */
381  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
382  /* {return elements_;} */
383 
385  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
386  typedef std::vector< ElementInBlock > ElementsInBlocks;
387 
389  typedef std::vector<unsigned> Elements;
390 
391  const ElementsInBlocks& elementsInBlocks() const;
392 
393  static const float bigMva_;
394 
395  friend std::ostream& operator<<( std::ostream& out,
396  const PFCandidate& c );
397 
398  //Tips on setting the vertex efficiently
399  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
400  //of one of the refs stored by this class. The PFVertexType enum gives the current list
401  //of possible references. For these references, use the setVeretxSource method and NOT
402  //the setVertex method. If none of the available refs have the vertex that you want for this
403  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
404  // vertex that is the same as one of the refs in this class, you should just extend the enum
405  // and modify the vertex() method accordingly.
407 
408  virtual void setVertex( const math::XYZPoint& p) {
410  }
411 
412  virtual const Point & vertex() const;
413  virtual double vx() const {return vertex().x();}
414  virtual double vy() const {return vertex().y();}
415  virtual double vz() const {return vertex().z();}
416 
417  private:
419  virtual bool overlap( const Candidate & ) const;
420 
421  void setFlag(unsigned shift, unsigned flag, bool value);
422 
423  bool flag(unsigned shift, unsigned flag) const;
424 
425 
426 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
427  mutable std::atomic<ElementsInBlocks*> elementsInBlocks_;
428 #else
430 #endif
433 
435  /* PFCandidateRef sourceRef_; */
437 
438 
442 
444  float ecalERatio_;
445 
447  float hcalERatio_;
448 
450  float hoERatio_;
451 
454 
457 
460 
462  float ps1Energy_;
463 
465  float ps2Energy_;
466 
468  unsigned flags_;
469 
471  float deltaP_;
472 
474 
475  // mva for isolated electrons
477 
479  float mva_e_pi_;
480 
482  float mva_e_mu_;
483 
485  float mva_pi_mu_;
486 
489 
492 
495 
498 
499 
500  //more efficiently stored refs
501  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
502  const edm::RefCore& iCore, size_t iKey,
503  const edm::EDProductGetter*);
504  bool getRefInfo(unsigned int iMask, unsigned int iBit,
505  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
506 
507 
508  const edm::EDProductGetter* getter_; //transient
509  unsigned short storedRefsBitPattern_;
510  std::vector<unsigned long long> refsInfo_;
511  std::vector<const void *> refsCollectionCache_;
512 
513  };
514 
516  struct PFParticleIdTag { };
517 
520  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
521 
525 
526  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
527 
528 
529 }
530 
531 #endif
bool isAvailable() const
Definition: Ref.h:614
type
Definition: HCALResponse.h:21
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:221
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:471
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:279
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
virtual double p() const
magnitude of momentum vector
virtual double vz() const
z coordinate of vertex position
Definition: PFCandidate.h:415
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:294
friend std::ostream & operator<<(std::ostream &out, const PFCandidate &c)
void setPs1Energy(float e1)
set corrected PS1 energy
Definition: PFCandidate.h:273
ParticleType
particle types
Definition: PFCandidate.h:44
reco::Muon::MuonTrackType muonTrackType_
Definition: PFCandidate.h:441
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:508
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:224
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:316
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:182
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:329
size_t size_type
Definition: Candidate.h:30
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:348
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:332
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:447
double dxyError() const
error on dxy
Definition: TrackBase.h:749
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:456
const reco::Muon::MuonTrackType bestMuonTrackType() const
get the Best Muon Track Ref
Definition: PFCandidate.h:362
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:206
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:468
double rawHoEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:244
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:482
static const float bigMva_
Definition: PFCandidate.h:393
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:127
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:491
virtual void setVertex(const math::XYZPoint &p)
set vertex
Definition: PFCandidate.h:408
float hoERatio_
corrected HO energy ratio (corrected/raw)
Definition: PFCandidate.h:450
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:388
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:125
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:494
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:444
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:485
particle ID component tag
Definition: PFCandidate.h:516
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:367
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:386
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:319
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:413
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:453
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:479
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:322
CandidatePtr sourceCandidatePtr(size_type i) const
Definition: PFCandidate.h:131
void set_mva_nothing_nh(float mva)
set mva for neutral hadron detection
Definition: PFCandidate.h:335
void set_mva_e_pi(float mvaNI)
Definition: PFCandidate.h:311
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:276
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:510
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:325
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:338
float mva_Isolated() const
Definition: PFCandidate.h:309
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< unsigned > Elements
Definition: PFCandidate.h:389
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:406
void set_mva_Isolated(float mvaI)
Definition: PFCandidate.h:307
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:462
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:356
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:509
int translateTypeToPdgId(ParticleType type) const
Definition: PFCandidate.cc:238
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:459
virtual void setVertex(const Point &vertex)
set vertex
void rescaleMomentum(double rescaleFactor)
particle momentum *= rescaleFactor
Definition: PFCandidate.cc:278
virtual ~PFCandidate()
destructor
Definition: PFCandidate.cc:202
virtual float dxyError() const
uncertainty on dxy
Definition: PFCandidate.h:172
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:217
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:313
double dzError() const
error on dz
Definition: TrackBase.h:767
tuple out
Definition: dbtoconf.py:99
virtual float dzError() const
uncertainty on dz
Definition: PFCandidate.h:170
double hoEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:241
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
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:342
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:414
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:224
PFCandidate & operator=(PFCandidate const &)
Definition: PFCandidate.cc:163
std::atomic< ElementsInBlocks * > elementsInBlocks_
Definition: PFCandidate.h:427
PFVertexType vertexType_
Definition: PFCandidate.h:473
void setHoEnergy(float eoRaw, float eoCorr)
set corrected Hcal energy
Definition: PFCandidate.h:237
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:436
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:385
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:497
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:488
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:231
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:282
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:465
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:345
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:416
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:682
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
virtual const reco::Track * bestTrack() const
Definition: PFCandidate.h:161
Elements elementsStorage_
Definition: PFCandidate.h:432
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:227
int Charge
electric charge type
Definition: LeafCandidate.h:21
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:511
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:297
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:234
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:600
#define GET_CANDIDATE_COMPONENT(CAND, TYPE, FUN, TAG)
Definition: component.h:86
void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid, const edm::RefCore &iCore, size_t iKey, const edm::EDProductGetter *)
Definition: PFCandidate.cc:361