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 
31 namespace reco {
39 
40  public:
41 
43  enum ParticleType {
44  X=0, // undefined
45  h, // charged hadron
46  e, // electron
47  mu, // muon
48  gamma, // photon
49  h0, // neutral hadron
50  h_HF, // HF tower identified as a hadron
51  egamma_HF // HF tower identified as an EM particle
52  };
53 
54  enum Flags {
55  NORMAL=0,
72  };
73 
74 
75  enum PFVertexType {
84  };
85 
86 
88  PFCandidate();
89 
91  PFCandidate( const PFCandidatePtr& sourcePtr );
92 
93  /* PFCandidate( Charge q, */
94  /* const LorentzVector & p4, */
95  /* ParticleType particleId, */
96  /* reco::PFBlockRef blockRef ); */
98  const LorentzVector & p4,
100 
102  PFCandidate( const PFCandidate&);
103 
105  virtual ~PFCandidate();
106 
108 
110  virtual PFCandidate * clone() const;
111 
112 
113  /* /// set source ref */
114  /* void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
115 
116  /* size_type numberOfSourceCandidateRefs() const {return 1;} */
117 
118  /* CandidateBaseRef sourceCandidateRef( size_type i ) const { */
119  /* return CandidateBaseRef(sourceRef_); */
120  /* } */
121 
123  void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
124 
125  size_t numberOfSourceCandidatePtrs() const {
126  return 1;
127  }
128 
130  return sourcePtr_;
131  }
132 
137  ParticleType translatePdgIdToType(int pdgid) const;
138 
141 
142 
144  /* void addElement( const reco::PFBlockElement* element ); */
145 
147  void addElementInBlock( const reco::PFBlockRef& blockref,
148  unsigned elementIndex );
149 
151  void setTrackRef(const reco::TrackRef& ref);
152 
155  reco::TrackRef trackRef() const;
156 
158  void setGsfTrackRef(const reco::GsfTrackRef& ref);
159 
163 
165  void setMuonRef(const reco::MuonRef& ref);
166 
169  reco::MuonRef muonRef() const;
170 
171 
172 
173 
176 
180 
182  void setConversionRef(const reco::ConversionRef& ref);
183 
186 
189 
192 
195 
198 
200  void setEcalEnergy( float eeRaw, float eeCorr ) {
201  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
202 
204  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
205 
207  double rawEcalEnergy() const { return rawEcalEnergy_;}
208 
210  void setHcalEnergy( float ehRaw, float ehCorr ) {
211  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
212 
214  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
215 
217  double rawHcalEnergy() const { return rawHcalEnergy_;}
218 
220  void setHoEnergy( float eoRaw, float eoCorr ) {
221  rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
222 
224  double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
225 
227  double rawHoEnergy() const { return rawHoEnergy_;}
228 
230  void setGsfElectronRef (const reco::GsfElectronRef & ref);
231 
232  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
233 
236 
238  void setPhotonRef(const reco::PhotonRef& phRef);
239 
241  reco::PhotonRef photonRef() const;
242 
245 
248 
251 
254 
256  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
257 
259  double pS1Energy() const { return ps1Energy_;}
260 
262  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
263 
265  double pS2Energy() const { return ps2Energy_;}
266 
268  void rescaleMomentum( double rescaleFactor );
269 
271  void setFlag(Flags theFlag, bool value);
272 
274  bool flag(Flags theFlag) const;
275 
277  void setDeltaP(double dp ) {deltaP_ = dp;}
278 
280  double deltaP() const { return deltaP_;}
281 
282  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
283 
289 
290 
291  void set_mva_e_pi( float mva ){ mva_e_pi_=mva;}
292 
294  float mva_e_pi() const { return mva_e_pi_;}
295 
296 
298  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
299 
301  float mva_e_mu() const { return mva_e_mu_;}
302 
304  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
305 
307  float mva_pi_mu() const { return mva_pi_mu_;}
308 
309 
311  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
312 
314  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
315 
317  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
318 
320  float mva_nothing_nh() const { return mva_nothing_nh_;}
321 
322 
324  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
325 
327  float mva_gamma_nh() const { return mva_gamma_nh_;}
328 
332  }
333 
336 
340  }
341 
343 
345  return muonTrackType_;
346  }
347 
351  }
352 
356 
357 
359  /* const std::vector<unsigned>& elementIndices() const { */
360  /* return elementIndices_; */
361  /* } */
363  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
364  /* {return elements_;} */
365 
367  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
368  typedef std::vector< ElementInBlock > ElementsInBlocks;
369 
371  typedef std::vector<unsigned> Elements;
372 
373  const ElementsInBlocks& elementsInBlocks() const;
374 
375  static const float bigMva_;
376 
377  friend std::ostream& operator<<( std::ostream& out,
378  const PFCandidate& c );
379 
380  //Tips on setting the vertex efficiently
381  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
382  //of one of the refs stored by this class. The PFVertexType enum gives the current list
383  //of possible references. For these references, use the setVeretxSource method and NOT
384  //the setVertex method. If none of the available refs have the vertex that you want for this
385  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
386  // vertex that is the same as one of the refs in this class, you should just extend the enum
387  // and modify the vertex() method accordingly.
389 
390  virtual void setVertex( const math::XYZPoint& p) {
392  }
393 
394  virtual const Point & vertex() const;
395  virtual double vx() const {return vertex().x();}
396  virtual double vy() const {return vertex().y();}
397  virtual double vz() const {return vertex().z();}
398 
399  private:
401  virtual bool overlap( const Candidate & ) const;
402 
403  void setFlag(unsigned shift, unsigned flag, bool value);
404 
405  bool flag(unsigned shift, unsigned flag) const;
406 
407 
408 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
409  mutable std::atomic<ElementsInBlocks*> elementsInBlocks_;
410 #else
412 #endif
415 
417  /* PFCandidateRef sourceRef_; */
419 
420 
424 
426  float ecalERatio_;
427 
429  float hcalERatio_;
430 
432  float hoERatio_;
433 
436 
439 
442 
444  float ps1Energy_;
445 
447  float ps2Energy_;
448 
450  unsigned flags_;
451 
453  float deltaP_;
454 
456 
458  float mva_e_pi_;
459 
461  float mva_e_mu_;
462 
464  float mva_pi_mu_;
465 
468 
471 
474 
477 
478 
479  //more efficiently stored refs
480  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
481  const edm::RefCore& iCore, size_t iKey,
482  const edm::EDProductGetter*);
483  bool getRefInfo(unsigned int iMask, unsigned int iBit,
484  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
485 
486 
487  const edm::EDProductGetter* getter_; //transient
488  unsigned short storedRefsBitPattern_;
489  std::vector<unsigned long long> refsInfo_;
490  std::vector<const void *> refsCollectionCache_;
491 
492  };
493 
495  struct PFParticleIdTag { };
496 
499  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
500 
504 
505  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
506 
507 
508 }
509 
510 #endif
type
Definition: HCALResponse.h:21
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:204
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:453
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:262
int i
Definition: DBlmapReader.cc:9
virtual double p() const
magnitude of momentum vector
virtual double vz() const
z coordinate of vertex position
Definition: PFCandidate.h:397
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:277
friend std::ostream & operator<<(std::ostream &out, const PFCandidate &c)
void setPs1Energy(float e1)
set corrected PS1 energy
Definition: PFCandidate.h:256
ParticleType
particle types
Definition: PFCandidate.h:43
reco::Muon::MuonTrackType muonTrackType_
Definition: PFCandidate.h:423
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:487
void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef &ref)
set the PF Photon Extra Ref
Definition: PFCandidate.cc:632
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:207
void setGsfElectronRef(const reco::GsfElectronRef &ref)
set GsfElectronRef
Definition: PFCandidate.cc:565
void setFlag(Flags theFlag, bool value)
set a given flag
Definition: PFCandidate.cc:281
bool getRefInfo(unsigned int iMask, unsigned int iBit, edm::ProductID &oProdID, size_t &oIndex, size_t &aIndex) const
Definition: PFCandidate.cc:397
void set_mva_e_mu(float mva)
set mva for electron-muon discrimination
Definition: PFCandidate.h:298
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:257
void set_mva_nothing_gamma(float mva)
set mva for gamma detection
Definition: PFCandidate.h:311
size_t size_type
Definition: Candidate.h:34
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:330
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:314
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:429
int pdgId_
PDG identifier.
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:438
const reco::Muon::MuonTrackType bestMuonTrackType() const
get the Best Muon Track Ref
Definition: PFCandidate.h:344
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:202
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:450
double rawHoEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:227
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:461
static const float bigMva_
Definition: PFCandidate.h:375
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:125
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:470
virtual void setVertex(const math::XYZPoint &p)
set vertex
Definition: PFCandidate.h:390
float hoERatio_
corrected HO energy ratio (corrected/raw)
Definition: PFCandidate.h:432
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:370
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:123
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:588
float mva_gamma_nh_
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:473
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:426
Point vertex_
vertex position
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:464
particle ID component tag
Definition: PFCandidate.h:495
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:349
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:368
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:301
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:395
void set_mva_e_pi(float mva)
Definition: PFCandidate.h:291
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:435
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:429
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:458
reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const
Definition: PFCandidate.cc:515
void set_mva_pi_mu(float mva)
set mva for pi-muon discrimination
Definition: PFCandidate.h:304
CandidatePtr sourceCandidatePtr(size_type i) const
Definition: PFCandidate.h:129
void set_mva_nothing_nh(float mva)
set mva for neutral hadron detection
Definition: PFCandidate.h:317
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:259
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:489
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:307
void setDisplacedVertexRef(const reco::PFDisplacedVertexRef &ref, Flags flag)
set displaced vertex reference
Definition: PFCandidate.cc:471
float mva_nothing_nh() const
mva for neutral hadron detection
Definition: PFCandidate.h:320
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< unsigned > Elements
Definition: PFCandidate.h:371
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:388
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:444
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
Definition: PFCandidate.cc:207
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
Definition: PFCandidate.h:338
void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef &ref)
set the PF Electron Extra Ref
Definition: PFCandidate.cc:575
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:252
reco::PhotonRef photonRef() const
return a reference to the corresponding Photon if any
Definition: PFCandidate.cc:584
ParticleType
bool flag(Flags theFlag) const
return a given flag
Definition: PFCandidate.cc:291
math::XYZPoint Point
unsigned short storedRefsBitPattern_
Definition: PFCandidate.h:488
int translateTypeToPdgId(ParticleType type) const
Definition: PFCandidate.cc:234
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:570
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:643
float rawHoEnergy_
raw HO energy
Definition: PFCandidate.h:441
void rescaleMomentum(double rescaleFactor)
particle momentum *= rescaleFactor
Definition: PFCandidate.cc:274
virtual ~PFCandidate()
destructor
Definition: PFCandidate.cc:198
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:446
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:200
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:294
tuple out
Definition: dbtoconf.py:99
double hoEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:224
reco::PFCandidateElectronExtraRef electronExtraRef() const
return a reference to the electron extra
Definition: PFCandidate.cc:580
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidate.cc:450
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:600
void setConversionRef(const reco::ConversionRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:526
void set_mva_gamma_nh(float mva)
set mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:324
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:396
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:220
PFCandidate & operator=(PFCandidate const &)
Definition: PFCandidate.cc:160
std::atomic< ElementsInBlocks * > elementsInBlocks_
Definition: PFCandidate.h:409
PFVertexType vertexType_
Definition: PFCandidate.h:455
void setHoEnergy(float eoRaw, float eoCorr)
set corrected Hcal energy
Definition: PFCandidate.h:220
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:418
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
reco::VertexCompositeCandidateRef v0Ref() const
return a reference to the original conversion
Definition: PFCandidate.cc:560
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:432
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
return indices of elements used in the block
Definition: PFCandidate.h:367
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:476
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:467
reco::PFCandidateEGammaExtraRef egammaExtraRef() const
return a reference to the EGamma extra
Definition: PFCandidate.cc:592
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:467
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:637
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:214
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:265
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:447
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:616
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:555
float mva_gamma_nh() const
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:327
virtual ParticleType particleId() const
Definition: PFCandidate.h:355
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:412
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:675
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Elements elementsStorage_
Definition: PFCandidate.h:414
reco::ConversionRef conversionRef() const
return a reference to the original conversion
Definition: PFCandidate.cc:550
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy
Definition: PFCandidate.h:210
int Charge
electric charge type
Definition: LeafCandidate.h:26
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:490
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:280
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:217
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:596
#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:357