CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IPCutPFCandidateSelectorDefinition.h
Go to the documentation of this file.
1 #ifndef CommonTools_ParticleFlow_IPCutPFCandidateSelectorDefinition
2 #define CommonTools_ParticleFlow_IPCutPFCandidateSelectorDefinition
3 
18 
19 namespace pf2pat {
20 
22 
24  vertices_( cfg.getParameter<edm::InputTag> ( "vertices" ) ),
25  d0Cut_( cfg.getParameter<double>("d0Cut") ),
26  dzCut_( cfg.getParameter<double>("dzCut") ),
27  d0SigCut_( cfg.getParameter<double>("d0SigCut") ),
28  dzSigCut_( cfg.getParameter<double>("dzSigCut") ) {}
29 
30  void select( const HandleToCollection & hc,
31  const edm::Event & e,
32  const edm::EventSetup& s) {
33  selected_.clear();
34 
36  e.getByLabel(vertices_, vertices);
37  if (vertices->empty()) return;
38  const reco::Vertex &vtx = (*vertices)[0];
39 
40  unsigned key=0;
41  for( collection::const_iterator pfc = hc->begin();
42  pfc != hc->end(); ++pfc, ++key) {
43 
44  bool passing = true;
45  const reco::Track *tk = 0;
46  if (pfc->gsfTrackRef().isNonnull()) tk = pfc->gsfTrackRef().get();
47  else if (pfc->trackRef().isNonnull()) tk = pfc->trackRef().get();
48 
49  if (tk != 0) {
50  double d0 = fabs(tk->dxy(vtx.position()));
51  double dz = fabs(tk->dz(vtx.position()));
52  double d0e = hypot(tk->dxyError(), hypot(vtx.xError(), vtx.yError()));
53  double dze = hypot(tk->dzError(), vtx.zError());
54  if (d0Cut_ > 0 && d0 > d0Cut_) passing = false;
55  if (dzCut_ > 0 && dz > dzCut_) passing = false;
56  if (d0SigCut_ > 0 && d0e > 0 && d0/d0e > d0SigCut_) passing = false;
57  if (dzSigCut_ > 0 && dze > 0 && dz/dze > dzSigCut_) passing = false;
58  }
59 
60  if( passing ) {
61  selected_.push_back( reco::PFCandidate(*pfc) );
62  reco::PFCandidatePtr ptrToMother( hc, key );
63  selected_.back().setSourceCandidatePtr( ptrToMother );
64  }
65  }
66  }
67 
68  private:
70  double d0Cut_;
71  double dzCut_;
72  double d0SigCut_;
73  double dzSigCut_;
74  };
75 }
76 
77 #endif
Selects PFCandidates basing on their compatibility with vertex.
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
double zError() const
error on z
Definition: Vertex.h:105
double dxyError() const
error on dxy
Definition: TrackBase.h:209
const Point & position() const
position
Definition: Vertex.h:93
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:127
double dzError() const
error on dz
Definition: TrackBase.h:215
double xError() const
error on x
Definition: Vertex.h:101
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
list key
Definition: combine.py:13
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:121
double yError() const
error on y
Definition: Vertex.h:103