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 
26 namespace reco {
34 
35  public:
36 
38  enum ParticleType {
39  X=0, // undefined
40  h, // charged hadron
41  e, // electron
42  mu, // muon
43  gamma, // photon
44  h0, // neutral hadron
45  h_HF, // HF tower identified as a hadron
46  egamma_HF // HF tower identified as an EM particle
47  };
48 
49  enum Flags {
50  NORMAL=0,
67  };
68 
69 
70  enum PFVertexType {
77  };
78 
79 
81  PFCandidate();
82 
84  PFCandidate( const PFCandidatePtr& sourcePtr );
85 
86  /* PFCandidate( Charge q, */
87  /* const LorentzVector & p4, */
88  /* ParticleType particleId, */
89  /* reco::PFBlockRef blockRef ); */
91  const LorentzVector & p4,
93 
95  virtual ~PFCandidate() {}
96 
98  virtual PFCandidate * clone() const;
99 
100 
101  /* /// set source ref */
102  /* void setSourceRef(const PFCandidateRef& ref) { sourceRef_ = ref; } */
103 
104  /* size_type numberOfSourceCandidateRefs() const {return 1;} */
105 
106  /* CandidateBaseRef sourceCandidateRef( size_type i ) const { */
107  /* return CandidateBaseRef(sourceRef_); */
108  /* } */
109 
110  //using reco::Candidate::setSourceCandidatePtr;
111  void setSourceCandidatePtr(const PFCandidatePtr& ptr) { sourcePtr_ = ptr; }
112 
113  size_t numberOfSourceCandidatePtrs() const {
114  return 1;
115  }
116 
118  return sourcePtr_;
119  }
120 
125  ParticleType translatePdgIdToType(int pdgid) const;
126 
129 
130 
132  /* void addElement( const reco::PFBlockElement* element ); */
133 
135  void addElementInBlock( const reco::PFBlockRef& blockref,
136  unsigned elementIndex );
137 
139  void setTrackRef(const reco::TrackRef& ref);
140 
143  reco::TrackRef trackRef() const;
144 
146  void setGsfTrackRef(const reco::GsfTrackRef& ref);
147 
151 
153  void setMuonRef(const reco::MuonRef& ref);
154 
157  reco::MuonRef muonRef() const;
158 
161 
165 
167  void setConversionRef(const reco::ConversionRef& ref);
168 
171 
174 
177 
180 
183 
185  void setEcalEnergy( float eeRaw, float eeCorr ) {
186  rawEcalEnergy_ = eeRaw; ecalERatio_= std::abs(eeRaw)<1.e-6 ? 1.0 : eeCorr/eeRaw;}
187 
189  double ecalEnergy() const { return ecalERatio_*rawEcalEnergy_;}
190 
192  double rawEcalEnergy() const { return rawEcalEnergy_;}
193 
195  void setHcalEnergy( float ehRaw, float ehCorr ) {
196  rawHcalEnergy_ = ehRaw; hcalERatio_= std::abs(ehRaw)<1.e-6 ? 1.0 : ehCorr/ehRaw;}
197 
199  double hcalEnergy() const { return hcalERatio_*rawHcalEnergy_;}
200 
202  double rawHcalEnergy() const { return rawHcalEnergy_;}
203 
205  void setGsfElectronRef (const reco::GsfElectronRef & ref);
206 
207  void setSuperClusterRef (const reco::SuperClusterRef& scRef);
208 
211 
213  void setPhotonRef(const reco::PhotonRef& phRef);
214 
216  reco::PhotonRef photonRef() const;
217 
220 
223 
224 
226  void setPs1Energy( float e1 ) {ps1Energy_ = e1;}
227 
229  double pS1Energy() const { return ps1Energy_;}
230 
232  void setPs2Energy( float e2 ) {ps2Energy_ = e2;}
233 
235  double pS2Energy() const { return ps2Energy_;}
236 
238  void rescaleMomentum( double rescaleFactor );
239 
241  void setFlag(Flags theFlag, bool value);
242 
244  bool flag(Flags theFlag) const;
245 
247  void setDeltaP(double dp ) {deltaP_ = dp;}
248 
250  double deltaP() const { return deltaP_;}
251 
252  // int pdgId() const { return translateTypeToPdgId( particleId_ ); }
253 
259 
260 
261  void set_mva_e_pi( float mva ){ mva_e_pi_=mva;}
262 
264  float mva_e_pi() const { return mva_e_pi_;}
265 
266 
268  void set_mva_e_mu( float mva ) { mva_e_mu_=mva;}
269 
271  float mva_e_mu() const { return mva_e_mu_;}
272 
274  void set_mva_pi_mu( float mva ) { mva_pi_mu_=mva;}
275 
277  float mva_pi_mu() const { return mva_pi_mu_;}
278 
279 
281  void set_mva_nothing_gamma( float mva ) { mva_nothing_gamma_=mva;}
282 
284  float mva_nothing_gamma() const { return mva_nothing_gamma_;}
285 
287  void set_mva_nothing_nh( float mva ) { mva_nothing_nh_=mva;}
288 
290  float mva_nothing_nh() const { return mva_nothing_nh_;}
291 
292 
294  void set_mva_gamma_nh( float mva ) { mva_gamma_nh_=mva;}
295 
297  float mva_gamma_nh() const { return mva_gamma_nh_;}
298 
302  }
303 
306 
310  }
311 
315 
316 
318  /* const std::vector<unsigned>& elementIndices() const { */
319  /* return elementIndices_; */
320  /* } */
322  /* const edm::OwnVector< reco::PFBlockElement >& elements() const */
323  /* {return elements_;} */
324 
326  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
327  typedef std::vector< ElementInBlock > ElementsInBlocks;
328 
330  typedef std::vector<unsigned> Elements;
331 
333 
334  if (elementsInBlocks_.size()!=blocksStorage_.size())
335  {
337  for(unsigned int icopy=0;icopy!=blocksStorage_.size();++icopy)
338  elementsInBlocks_[icopy]=std::make_pair(blocksStorage_[icopy],elementsStorage_[icopy]);
339  }
340  return elementsInBlocks_;
341  }
342 
343 
344 
345  static const float bigMva_;
346 
347  friend std::ostream& operator<<( std::ostream& out,
348  const PFCandidate& c );
349 
350  //Tips on setting the vertex efficiently
351  //There are two choices: a) use the vertex_ data member, or b) point to the vertex
352  //of one of the refs stored by this class. The PFVertexType enum gives the current list
353  //of possible references. For these references, use the setVeretxSource method and NOT
354  //the setVertex method. If none of the available refs have the vertex that you want for this
355  //PFCandidate, use the setVertex method. If you find that you are using frequently two store a
356  // vertex that is the same as one of the refs in this class, you should just extend the enum
357  // and modify the vertex() method accordingly.
359 
360  virtual void setVertex( math::XYZPoint p) {
362  }
363 
364  virtual const Point & vertex() const;
365  virtual double vx() const {return vertex().x();}
366  virtual double vy() const {return vertex().y();}
367  virtual double vz() const {return vertex().z();}
368 
369  private:
371  virtual bool overlap( const Candidate & ) const;
372 
373  void setFlag(unsigned shift, unsigned flag, bool value);
374 
375  bool flag(unsigned shift, unsigned flag) const;
376 
377 
381 
383  /* PFCandidateRef sourceRef_; */
385 
386 
388  float ecalERatio_;
389 
391  float hcalERatio_;
392 
395 
398 
400  float ps1Energy_;
401 
403  float ps2Energy_;
404 
406  unsigned flags_;
407 
409  float deltaP_;
410 
412 
414  float mva_e_pi_;
415 
417  float mva_e_mu_;
418 
420  float mva_pi_mu_;
421 
424 
427 
430 
433 
434 
435  //more efficiently stored refs
436  void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid,
437  const edm::RefCore& iCore, size_t iKey,
438  const edm::EDProductGetter*);
439  bool getRefInfo(unsigned int iMask, unsigned int iBit,
440  edm::ProductID& oProdID, size_t& oIndex, size_t& aIndex ) const;
441 
442 
443  const edm::EDProductGetter* getter_; //transient
444  unsigned short storedRefsBitPattern_;
445  std::vector<unsigned long long> refsInfo_;
446  std::vector<const void *> refsCollectionCache_;
447 
448  };
449 
451  struct PFParticleIdTag { };
452 
455  /* GET_DEFAULT_CANDIDATE_COMPONENT( PFCandidate, PFBlockRef, block ); */
456 
460 
461  std::ostream& operator<<( std::ostream& out, const PFCandidate& c );
462 
463 
464 }
465 
466 #endif
type
Definition: HCALResponse.h:22
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:189
float deltaP_
uncertainty on 3-momentum
Definition: PFCandidate.h:409
void setPs2Energy(float e2)
set corrected PS2 energy
Definition: PFCandidate.h:232
virtual ~PFCandidate()
destructor
Definition: PFCandidate.h:95
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:367
void setDeltaP(double dp)
set uncertainty on momentum
Definition: PFCandidate.h:247
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:226
ParticleType
particle types
Definition: PFCandidate.h:38
const edm::EDProductGetter * getter_
Definition: PFCandidate.h:443
void setPFPhotonExtraRef(const reco::PFCandidatePhotonExtraRef &ref)
set the PF Photon Extra Ref
Definition: PFCandidate.cc:530
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:192
void setGsfElectronRef(const reco::GsfElectronRef &ref)
set GsfElectronRef
Definition: PFCandidate.cc:466
void setFlag(Flags theFlag, bool value)
set a given flag
Definition: PFCandidate.cc:191
bool getRefInfo(unsigned int iMask, unsigned int iBit, edm::ProductID &oProdID, size_t &oIndex, size_t &aIndex) const
Definition: PFCandidate.cc:299
void set_mva_e_mu(float mva)
set mva for electron-muon discrimination
Definition: PFCandidate.h:268
virtual bool overlap(const Candidate &) const
Polymorphic overlap.
Definition: PFCandidate.cc:167
void set_mva_nothing_gamma(float mva)
set mva for gamma detection
Definition: PFCandidate.h:281
size_t size_type
Definition: Candidate.h:32
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:300
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:284
float hcalERatio_
corrected HCAL energy ratio (corrected/raw)
Definition: PFCandidate.h:391
int pdgId_
PDG identifier.
float rawHcalEnergy_
raw HCAL energy
Definition: PFCandidate.h:397
virtual PFCandidate * clone() const
return a clone
Definition: PFCandidate.cc:114
unsigned flags_
all flags, packed (ecal regional, hcal regional, tracking)
Definition: PFCandidate.h:406
float mva_e_mu_
mva for electron-muon discrimination
Definition: PFCandidate.h:417
static const float bigMva_
Definition: PFCandidate.h:345
math::XYZTLorentzVector LorentzVector
size_t numberOfSourceCandidatePtrs() const
Definition: PFCandidate.h:113
float mva_nothing_nh_
mva for neutral hadron detection
Definition: PFCandidate.h:426
ElementsInBlocks elementsInBlocks_
Definition: PFCandidate.h:378
#define abs(x)
Definition: mlp_lapack.h:159
edm::RefVector< reco::PFBlockCollection > Blocks
Definition: PFCandidate.h:329
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:111
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:490
float mva_gamma_nh_
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:429
float ecalERatio_
corrected ECAL energy ratio (corrected/raw)
Definition: PFCandidate.h:388
Point vertex_
vertex position
float mva_pi_mu_
mva for pi-muon discrimination
Definition: PFCandidate.h:420
particle ID component tag
Definition: PFCandidate.h:451
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:308
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:327
float mva_e_mu() const
mva for electron-muon discrimination
Definition: PFCandidate.h:271
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:365
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.h:332
void set_mva_e_pi(float mva)
Definition: PFCandidate.h:261
float rawEcalEnergy_
raw ECAL energy
Definition: PFCandidate.h:394
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:331
float mva_e_pi_
mva for electron-pion discrimination
Definition: PFCandidate.h:414
reco::PFDisplacedVertexRef displacedVertexRef(Flags type) const
Definition: PFCandidate.cc:416
void set_mva_pi_mu(float mva)
set mva for pi-muon discrimination
Definition: PFCandidate.h:274
CandidatePtr sourceCandidatePtr(size_type i) const
Definition: PFCandidate.h:117
void set_mva_nothing_nh(float mva)
set mva for neutral hadron detection
Definition: PFCandidate.h:287
double pS1Energy() const
return corrected PS1 energy
Definition: PFCandidate.h:229
std::vector< unsigned long long > refsInfo_
Definition: PFCandidate.h:445
float mva_pi_mu() const
mva for pi-muon discrimination
Definition: PFCandidate.h:277
void setDisplacedVertexRef(const reco::PFDisplacedVertexRef &ref, Flags flag)
set displaced vertex reference
Definition: PFCandidate.cc:372
float mva_nothing_nh() const
mva for neutral hadron detection
Definition: PFCandidate.h:290
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
std::vector< unsigned > Elements
Definition: PFCandidate.h:330
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:358
float ps1Energy_
corrected PS1 energy
Definition: PFCandidate.h:400
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
Definition: PFCandidate.cc:119
void setPFElectronExtraRef(const reco::PFCandidateElectronExtraRef &ref)
set the PF Electron Extra Ref
Definition: PFCandidate.cc:476
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:162
reco::PhotonRef photonRef() const
return a reference to the corresponding Photon if any
Definition: PFCandidate.cc:486
bool flag(Flags theFlag) const
return a given flag
Definition: PFCandidate.cc:201
math::XYZPoint Point
unsigned short storedRefsBitPattern_
Definition: PFCandidate.h:444
int translateTypeToPdgId(ParticleType type) const
Definition: PFCandidate.cc:144
GET_CANDIDATE_COMPONENT(PFCandidate, PFCandidate::ParticleType, particleId, PFParticleIdTag)
reco::GsfElectronRef gsfElectronRef() const
return a reference to the corresponding GsfElectron if any
Definition: PFCandidate.cc:471
virtual const Point & vertex() const
vertex position
Definition: PFCandidate.cc:538
void rescaleMomentum(double rescaleFactor)
particle momentum *= rescaleFactor
Definition: PFCandidate.cc:184
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:347
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:185
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:264
tuple out
Definition: dbtoconf.py:99
reco::PFCandidateElectronExtraRef electronExtraRef() const
return a reference to the electron extra
Definition: PFCandidate.cc:481
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidate.cc:351
PFCandidate()
default constructor
Definition: PFCandidate.cc:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
virtual void setVertex(math::XYZPoint p)
Definition: PFCandidate.h:360
void setPhotonRef(const reco::PhotonRef &phRef)
set ref to the corresponding reco::Photon if any
Definition: PFCandidate.cc:498
void setConversionRef(const reco::ConversionRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:427
void set_mva_gamma_nh(float mva)
set mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:294
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:366
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:130
PFVertexType vertexType_
Definition: PFCandidate.h:411
PFCandidatePtr sourcePtr_
reference to the source PFCandidate, if any
Definition: PFCandidate.h:384
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
reco::VertexCompositeCandidateRef v0Ref() const
return a reference to the original conversion
Definition: PFCandidate.cc:461
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:334
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
return indices of elements used in the block
Definition: PFCandidate.h:326
math::XYZPointF positionAtECALEntrance_
position at ECAL entrance, from the PFRecTrack
Definition: PFCandidate.h:432
float mva_nothing_gamma_
mva for gamma detection
Definition: PFCandidate.h:423
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:368
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:199
static unsigned int const shift
double pS2Energy() const
return corrected PS2 energy
Definition: PFCandidate.h:235
float ps2Energy_
corrected PS2 energy
Definition: PFCandidate.h:403
size_type size() const
Size of the RefVector.
Definition: RefVector.h:84
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:514
void setV0Ref(const reco::VertexCompositeCandidateRef &ref)
set ref to original reco conversion
Definition: PFCandidate.cc:456
float mva_gamma_nh() const
mva for neutral hadron - gamma discrimination
Definition: PFCandidate.h:297
virtual ParticleType particleId() const
Definition: PFCandidate.h:314
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:314
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Elements elementsStorage_
Definition: PFCandidate.h:380
reco::ConversionRef conversionRef() const
return a reference to the original conversion
Definition: PFCandidate.cc:451
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy
Definition: PFCandidate.h:195
int Charge
electric charge type
Definition: LeafCandidate.h:23
std::vector< const void * > refsCollectionCache_
Definition: PFCandidate.h:446
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:250
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:202
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:29
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:494
void storeRefInfo(unsigned int iMask, unsigned int iBit, bool iIsValid, const edm::RefCore &iCore, size_t iKey, const edm::EDProductGetter *)
Definition: PFCandidate.cc:263