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  }
169 
171  void setGsfTrackRef(const reco::GsfTrackRef& ref);
172 
176 
178  void setMuonRef(const reco::MuonRef& ref);
179 
182  reco::MuonRef muonRef() const;
183 
184 
185 
186 
189 
193 
195  void setConversionRef(const reco::ConversionRef& ref);
196 
199 
202 
205 
208 
211 
213  void setEcalEnergy( float eeRaw, float eeCorr ) {
214  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
215 
217  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
218 
220  double rawEcalEnergy() const { return rawEcalEnergy_;}
221 
223  void setHcalEnergy( float ehRaw, float ehCorr ) {
224  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
225 
227  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
228 
230  double rawHcalEnergy() const { return rawHcalEnergy_;}
231 
233  void setHoEnergy( float eoRaw, float eoCorr ) {
234  rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
235 
237  double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
238 
240  double rawHoEnergy() const { return rawHoEnergy_;}
241 
243  void setGsfElectronRef (const reco::GsfElectronRef & ref);
244 
245  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
246 
249 
251  void setPhotonRef(const reco::PhotonRef& phRef);
252 
254  reco::PhotonRef photonRef() const;
255 
258 
261 
264 
267 
269  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
270 
272  double pS1Energy() const { return ps1Energy_;}
273 
275  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
276 
278  double pS2Energy() const { return ps2Energy_;}
279 
281  void rescaleMomentum( double rescaleFactor );
282 
284  void setFlag(Flags theFlag, bool value);
285 
287  bool flag(Flags theFlag) const;
288 
290  void setDeltaP(double dp ) {deltaP_ = dp;}
291 
293  double deltaP() const { return deltaP_;}
294 
295  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
296 
302 
303  void set_mva_Isolated( float mvaI ){ mva_Isolated_=mvaI;}
304  // mva for isolated electrons
305  float mva_Isolated() const { return mva_Isolated_;}
306 
307  void set_mva_e_pi( float mvaNI ){ mva_e_pi_=mvaNI;}
309  float mva_e_pi() const { return mva_e_pi_;}
310 
312  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
313 
315  float mva_e_mu() const { return mva_e_mu_;}
316 
318  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
319 
321  float mva_pi_mu() const { return mva_pi_mu_;}
322 
323 
325  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
326 
328  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
329 
331  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
332 
334  float mva_nothing_nh() const { return mva_nothing_nh_;}
335 
336 
338  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
339 
341  float mva_gamma_nh() const { return mva_gamma_nh_;}
342 
346  }
347 
350 
354  }
355 
357 
359  return muonTrackType_;
360  }
361 
365  }
366 
370 
371 
373  /* const std::vector<unsigned>& elementIndices() const { */
374  /* return elementIndices_; */
375  /* } */
377  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
378  /* {return elements_;} */
379 
381  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
382  typedef std::vector< ElementInBlock > ElementsInBlocks;
383 
385  typedef std::vector<unsigned> Elements;
386 
387  const ElementsInBlocks& elementsInBlocks() const;
388 
389  static const float bigMva_;
390 
391  friend std::ostream& operator<<( std::ostream& out,
392  const PFCandidate& c );
393 
394  //Tips on setting the vertex efficiently
395  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
396  //of one of the refs stored by this class. The PFVertexType enum gives the current list
397  //of possible references. For these references, use the setVeretxSource method and NOT
398  //the setVertex method. If none of the available refs have the vertex that you want for this
399  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
400  // vertex that is the same as one of the refs in this class, you should just extend the enum
401  // and modify the vertex() method accordingly.
403 
404  virtual void setVertex( const math::XYZPoint& p) {
406  }
407 
408  virtual const Point & vertex() const;
409  virtual double vx() const {return vertex().x();}
410  virtual double vy() const {return vertex().y();}
411  virtual double vz() const {return vertex().z();}
412 
413  private:
415  virtual bool overlap( const Candidate & ) const;
416 
417  void setFlag(unsigned shift, unsigned flag, bool value);
418 
419  bool flag(unsigned shift, unsigned flag) const;
420 
421 
422 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
423  mutable std::atomic<ElementsInBlocks*> elementsInBlocks_;
424 #else
426 #endif
429 
431  /* PFCandidateRef sourceRef_; */
433 
434 
438 
440  float ecalERatio_;
441 
443  float hcalERatio_;
444 
446  float hoERatio_;
447 
450 
453 
456 
458  float ps1Energy_;
459 
461  float ps2Energy_;
462 
464  unsigned flags_;
465 
467  float deltaP_;
468 
470 
471  // mva for isolated electrons
473 
475  float mva_e_pi_;
476 
478  float mva_e_mu_;
479 
481  float mva_pi_mu_;
482 
485 
488 
491 
494 
495 
496  //more efficiently stored refs
497  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
498  const edm::RefCore& iCore, size_t iKey,
499  const edm::EDProductGetter*);
500  bool getRefInfo(unsigned int iMask, unsigned int iBit,
501  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
502 
503 
504  const edm::EDProductGetter* getter_; //transient
505  unsigned short storedRefsBitPattern_;
506  std::vector<unsigned long long> refsInfo_;
507  std::vector<const void *> refsCollectionCache_;
508 
509  };
510 
512  struct PFParticleIdTag { };
513 
516  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
517 
521 
522  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
523 
524 
525 }
526 
527 #endif
bool isAvailable() const
Definition: Ref.h:614
type
Definition: HCALResponse.h:21
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:217
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:467
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:275
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:411
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:290
friend std::ostream & operator<<(std::ostream &out, const PFCandidate &c)
void setPs1Energy(float e1)
set corrected PS1 energy
Definition: PFCandidate.h:269
ParticleType
particle types
Definition: PFCandidate.h:44
reco::Muon::MuonTrackType muonTrackType_
Definition: PFCandidate.h:437
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:504
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:220
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:312
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:325
size_t size_type
Definition: Candidate.h:34
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:344
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:328
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:443
int pdgId_
PDG identifier.
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:452
const reco::Muon::MuonTrackType bestMuonTrackType() const
get the Best Muon Track Ref
Definition: PFCandidate.h:358
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:206
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:464
double rawHoEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:240
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:478
static const float bigMva_
Definition: PFCandidate.h:389
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:127
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:487
virtual void setVertex(const math::XYZPoint &p)
set vertex
Definition: PFCandidate.h:404
float hoERatio_
corrected HO energy ratio (corrected/raw)
Definition: PFCandidate.h:446
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:384
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:490
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:440
Point vertex_
vertex position
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:481
particle ID component tag
Definition: PFCandidate.h:512
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:363
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:382
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:315
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:409
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:449
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:475
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:318
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:331
void set_mva_e_pi(float mvaNI)
Definition: PFCandidate.h:307
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:272
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:506
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:321
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:334
float mva_Isolated() const
Definition: PFCandidate.h:305
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< unsigned > Elements
Definition: PFCandidate.h:385
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:402
void set_mva_Isolated(float mvaI)
Definition: PFCandidate.h:303
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:458
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:352
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:505
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:455
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:213
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:309
tuple out
Definition: dbtoconf.py:99
double hoEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:237
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:338
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:410
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:224
PFCandidate & operator=(PFCandidate const &)
Definition: PFCandidate.cc:163
std::atomic< ElementsInBlocks * > elementsInBlocks_
Definition: PFCandidate.h:423
PFVertexType vertexType_
Definition: PFCandidate.h:469
void setHoEnergy(float eoRaw, float eoCorr)
set corrected Hcal energy
Definition: PFCandidate.h:233
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:432
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:381
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:493
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:484
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:227
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:278
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:461
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:341
virtual ParticleType particleId() const
Definition: PFCandidate.h:369
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
virtual const reco::Track * bestTrack() const
Definition: PFCandidate.h:161
Elements elementsStorage_
Definition: PFCandidate.h:428
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:223
int Charge
electric charge type
Definition: LeafCandidate.h:26
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:507
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:293
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:230
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
#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