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 #include <iosfwd>
10 
12 
28 namespace reco {
36 
37  public:
38 
40  enum ParticleType {
41  X=0, // undefined
42  h, // charged hadron
43  e, // electron
44  mu, // muon
45  gamma, // photon
46  h0, // neutral hadron
47  h_HF, // HF tower identified as a hadron
48  egamma_HF // HF tower identified as an EM particle
49  };
50 
51  enum Flags {
52  NORMAL=0,
69  };
70 
71 
72  enum PFVertexType {
81  };
82 
83 
85  PFCandidate();
86 
88  PFCandidate( const PFCandidatePtr& sourcePtr );
89 
90  /* PFCandidate( Charge q, */
91  /* const LorentzVector & p4, */
92  /* ParticleType particleId, */
93  /* reco::PFBlockRef blockRef ); */
95  const LorentzVector & p4,
97 
99  virtual ~PFCandidate();
100 
102  virtual PFCandidate * clone() const;
103 
104 
105  /* /// set source ref */
106  /* void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
107 
108  /* size_type numberOfSourceCandidateRefs() const {return 1;} */
109 
110  /* CandidateBaseRef sourceCandidateRef( size_type i ) const { */
111  /* return CandidateBaseRef(sourceRef_); */
112  /* } */
113 
114  //using reco::Candidate::setSourceCandidatePtr;
115  void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
116 
117  size_t numberOfSourceCandidatePtrs() const {
118  return 1;
119  }
120 
122  return sourcePtr_;
123  }
124 
129  ParticleType translatePdgIdToType(int pdgid) const;
130 
133 
134 
136  /* void addElement( const reco::PFBlockElement* element ); */
137 
139  void addElementInBlock( const reco::PFBlockRef& blockref,
140  unsigned elementIndex );
141 
143  void setTrackRef(const reco::TrackRef& ref);
144 
147  reco::TrackRef trackRef() const;
148 
150  void setGsfTrackRef(const reco::GsfTrackRef& ref);
151 
155 
157  void setMuonRef(const reco::MuonRef& ref);
158 
161  reco::MuonRef muonRef() const;
162 
163 
164 
165 
168 
172 
174  void setConversionRef(const reco::ConversionRef& ref);
175 
178 
181 
184 
187 
190 
192  void setEcalEnergy( float eeRaw, float eeCorr ) {
193  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
194 
196  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
197 
199  double rawEcalEnergy() const { return rawEcalEnergy_;}
200 
202  void setHcalEnergy( float ehRaw, float ehCorr ) {
203  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
204 
206  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
207 
209  double rawHcalEnergy() const { return rawHcalEnergy_;}
210 
212  void setHoEnergy( float eoRaw, float eoCorr ) {
213  rawHoEnergy_ = eoRaw; hoERatio_= std::abs(eoRaw)<1.e-6 ? 1.0 : eoCorr/eoRaw;}
214 
216  double hoEnergy() const { return hoERatio_*rawHoEnergy_;}
217 
219  double rawHoEnergy() const { return rawHoEnergy_;}
220 
222  void setGsfElectronRef (const reco::GsfElectronRef & ref);
223 
224  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
225 
228 
230  void setPhotonRef(const reco::PhotonRef& phRef);
231 
233  reco::PhotonRef photonRef() const;
234 
237 
240 
243 
246 
248  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
249 
251  double pS1Energy() const { return ps1Energy_;}
252 
254  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
255 
257  double pS2Energy() const { return ps2Energy_;}
258 
260  void rescaleMomentum( double rescaleFactor );
261 
263  void setFlag(Flags theFlag, bool value);
264 
266  bool flag(Flags theFlag) const;
267 
269  void setDeltaP(double dp ) {deltaP_ = dp;}
270 
272  double deltaP() const { return deltaP_;}
273 
274  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
275 
281 
282 
283  void set_mva_e_pi( float mva ){ mva_e_pi_=mva;}
284 
286  float mva_e_pi() const { return mva_e_pi_;}
287 
288 
290  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
291 
293  float mva_e_mu() const { return mva_e_mu_;}
294 
296  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
297 
299  float mva_pi_mu() const { return mva_pi_mu_;}
300 
301 
303  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
304 
306  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
307 
309  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
310 
312  float mva_nothing_nh() const { return mva_nothing_nh_;}
313 
314 
316  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
317 
319  float mva_gamma_nh() const { return mva_gamma_nh_;}
320 
324  }
325 
328 
332  }
333 
335 
337  return muonTrackType_;
338  }
339 
343  }
344 
348 
349 
351  /* const std::vector<unsigned>& elementIndices() const { */
352  /* return elementIndices_; */
353  /* } */
355  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
356  /* {return elements_;} */
357 
359  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
360  typedef std::vector< ElementInBlock > ElementsInBlocks;
361 
363  typedef std::vector<unsigned> Elements;
364 
366 
367  if (elementsInBlocks_.size()!=blocksStorage_.size())
368  {
370  for(unsigned int icopy=0;icopy!=blocksStorage_.size();++icopy)
371  elementsInBlocks_[icopy]=std::make_pair(blocksStorage_[icopy],elementsStorage_[icopy]);
372  }
373  return elementsInBlocks_;
374  }
375 
376 
377 
378  static const float bigMva_;
379 
380  friend std::ostream& operator<<( std::ostream& out,
381  const PFCandidate& c );
382 
383  //Tips on setting the vertex efficiently
384  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
385  //of one of the refs stored by this class. The PFVertexType enum gives the current list
386  //of possible references. For these references, use the setVeretxSource method and NOT
387  //the setVertex method. If none of the available refs have the vertex that you want for this
388  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
389  // vertex that is the same as one of the refs in this class, you should just extend the enum
390  // and modify the vertex() method accordingly.
392 
393  virtual void setVertex( math::XYZPoint p) {
395  }
396 
397  virtual const Point & vertex() const;
398  virtual double vx() const {return vertex().x();}
399  virtual double vy() const {return vertex().y();}
400  virtual double vz() const {return vertex().z();}
401 
402  private:
404  virtual bool overlap( const Candidate & ) const;
405 
406  void setFlag(unsigned shift, unsigned flag, bool value);
407 
408  bool flag(unsigned shift, unsigned flag) const;
409 
410 
414 
416  /* PFCandidateRef sourceRef_; */
418 
419 
423 
425  float ecalERatio_;
426 
428  float hcalERatio_;
429 
431  float hoERatio_;
432 
435 
438 
441 
443  float ps1Energy_;
444 
446  float ps2Energy_;
447 
449  unsigned flags_;
450 
452  float deltaP_;
453 
455 
457  float mva_e_pi_;
458 
460  float mva_e_mu_;
461 
463  float mva_pi_mu_;
464 
467 
470 
473 
476 
477 
478  //more efficiently stored refs
479  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
480  const edm::RefCore& iCore, size_t iKey,
481  const edm::EDProductGetter*);
482  bool getRefInfo(unsigned int iMask, unsigned int iBit,
483  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
484 
485 
486  const edm::EDProductGetter* getter_; //transient
487  unsigned short storedRefsBitPattern_;
488  std::vector<unsigned long long> refsInfo_;
489  std::vector<const void *> refsCollectionCache_;
490 
491  };
492 
494  struct PFParticleIdTag { };
495 
498  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
499 
503 
504  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
505 
506 
507 }
508 
509 #endif
type
Definition: HCALResponse.h:21
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:196
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:452
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:254
int i
Definition: DBlmapReader.cc:9
virtual double vz() const
z coordinate of vertex position
Definition: PFCandidate.h:400
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:269
long int flag
Definition: mlp_lapack.h:47
friend std::ostream & operator<<(std::ostream &out, const PFCandidate &c)
void setPs1Energy(float e1)
set corrected PS1 energy
Definition: PFCandidate.h:248
ParticleType
particle types
Definition: PFCandidate.h:40
reco::Muon::MuonTrackType muonTrackType_
Definition: PFCandidate.h:422
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:486
void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef &ref)
set the PF Photon Extra Ref
Definition: PFCandidate.cc:552
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:199
void setGsfElectronRef(const reco::GsfElectronRef &ref)
set GsfElectronRef
Definition: PFCandidate.cc:485
void setFlag(Flags theFlag, bool value)
set a given flag
Definition: PFCandidate.cc:201
bool getRefInfo(unsigned int iMask, unsigned int iBit, edm::ProductID &oProdID, size_t &oIndex, size_t &aIndex) const
Definition: PFCandidate.cc:317
void set_mva_e_mu(float mva)
set mva for electron-muon discrimination
Definition: PFCandidate.h:290
virtual bool overlap(const Candidate &) const
Polymorphic overlap.
Definition: PFCandidate.cc:177
void set_mva_nothing_gamma(float mva)
set mva for gamma detection
Definition: PFCandidate.h:303
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:322
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:306
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:428
int pdgId_
PDG identifier.
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:437
const reco::Muon::MuonTrackType bestMuonTrackType() const
get the Best Muon Track Ref
Definition: PFCandidate.h:336
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:124
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:449
double rawHoEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:219
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:460
static const float bigMva_
Definition: PFCandidate.h:378
math::XYZTLorentzVector LorentzVector
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:117
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:469
ElementsInBlocks elementsInBlocks_
Definition: PFCandidate.h:411
#define abs(x)
Definition: mlp_lapack.h:159
float hoERatio_
corrected HO energy ratio (corrected/raw)
Definition: PFCandidate.h:431
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:362
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:115
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
reco::PFCandidatePhotonExtraRef photonExtraRef() const
return a reference to the photon extra
Definition: PFCandidate.cc:508
float mva_gamma_nh_
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:472
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:425
Point vertex_
vertex position
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:463
particle ID component tag
Definition: PFCandidate.h:494
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:341
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:360
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:293
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:398
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.h:365
void set_mva_e_pi(float mva)
Definition: PFCandidate.h:283
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:434
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:349
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:457
reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const
Definition: PFCandidate.cc:435
void set_mva_pi_mu(float mva)
set mva for pi-muon discrimination
Definition: PFCandidate.h:296
CandidatePtr sourceCandidatePtr(size_type i) const
Definition: PFCandidate.h:121
void set_mva_nothing_nh(float mva)
set mva for neutral hadron detection
Definition: PFCandidate.h:309
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:251
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:488
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:299
void setDisplacedVertexRef(const reco::PFDisplacedVertexRef &ref, Flags flag)
set displaced vertex reference
Definition: PFCandidate.cc:391
float mva_nothing_nh() const
mva for neutral hadron detection
Definition: PFCandidate.h:312
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
std::vector< unsigned > Elements
Definition: PFCandidate.h:363
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:391
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:443
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
Definition: PFCandidate.cc:129
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
Definition: PFCandidate.h:330
void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef &ref)
set the PF Electron Extra Ref
Definition: PFCandidate.cc:495
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:172
reco::PhotonRef photonRef() const
return a reference to the corresponding Photon if any
Definition: PFCandidate.cc:504
bool flag(Flags theFlag) const
return a given flag
Definition: PFCandidate.cc:211
math::XYZPoint Point
unsigned short storedRefsBitPattern_
Definition: PFCandidate.h:487
int translateTypeToPdgId(ParticleType type) const
Definition: PFCandidate.cc:154
GET_CANDIDATE_COMPONENT(PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag)
reco::GsfElectronRef gsfElectronRef() const
return a reference to the corresponding GsfElectron if any
Definition: PFCandidate.cc:490
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:563
float rawHoEnergy_
raw HO energy
Definition: PFCandidate.h:440
void rescaleMomentum(double rescaleFactor)
particle momentum *= rescaleFactor
Definition: PFCandidate.cc:194
virtual ~PFCandidate()
destructor
Definition: PFCandidate.cc:122
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:366
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:192
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:286
tuple out
Definition: dbtoconf.py:99
Float e1
Definition: deltaR.h:22
double hoEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:216
reco::PFCandidateElectronExtraRef electronExtraRef() const
return a reference to the electron extra
Definition: PFCandidate.cc:500
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidate.cc:370
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:13
virtual void setVertex(math::XYZPoint p)
Definition: PFCandidate.h:393
void setPhotonRef(const reco::PhotonRef &phRef)
set ref to the corresponding reco::Photon if any
Definition: PFCandidate.cc:520
void setConversionRef(const reco::ConversionRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:446
void set_mva_gamma_nh(float mva)
set mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:316
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:399
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:140
Float e2
Definition: deltaR.h:23
PFVertexType vertexType_
Definition: PFCandidate.h:454
void setHoEnergy(float eoRaw, float eoCorr)
set corrected Hcal energy
Definition: PFCandidate.h:212
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:417
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
reco::VertexCompositeCandidateRef v0Ref() const
return a reference to the original conversion
Definition: PFCandidate.cc:480
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:352
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
return indices of elements used in the block
Definition: PFCandidate.h:359
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:475
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:466
reco::PFCandidateEGammaExtraRef egammaExtraRef() const
return a reference to the EGamma extra
Definition: PFCandidate.cc:512
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:387
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:557
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:206
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:257
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:446
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:536
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:39
void setV0Ref(const reco::VertexCompositeCandidateRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:475
float mva_gamma_nh() const
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:319
virtual ParticleType particleId() const
Definition: PFCandidate.h:347
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:332
Elements elementsStorage_
Definition: PFCandidate.h:413
reco::ConversionRef conversionRef() const
return a reference to the original conversion
Definition: PFCandidate.cc:470
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy
Definition: PFCandidate.h:202
int Charge
electric charge type
Definition: LeafCandidate.h:24
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:489
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:272
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:209
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:30
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:516
void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid, const edm::RefCore &iCore, size_t iKey, const edm::EDProductGetter *)
Definition: PFCandidate.cc:277