CMS 3D CMS Logo

IPCutPFCandidateSelectorDefinition.h
Go to the documentation of this file.
1 #ifndef CommonTools_ParticleFlow_IPCutPFCandidateSelectorDefinition
2 #define CommonTools_ParticleFlow_IPCutPFCandidateSelectorDefinition
3 
21 
22 namespace pf2pat {
23 
25 
27  verticesToken_( iC.consumes<reco::VertexCollection>( cfg.getParameter<edm::InputTag> ( "vertices" ) ) ),
28  d0Cut_( cfg.getParameter<double>("d0Cut") ),
29  dzCut_( cfg.getParameter<double>("dzCut") ),
30  d0SigCut_( cfg.getParameter<double>("d0SigCut") ),
31  dzSigCut_( cfg.getParameter<double>("dzSigCut") ) {}
32 
33  void select( const HandleToCollection & hc,
34  const edm::Event & e,
35  const edm::EventSetup& s) {
36  selected_.clear();
37 
39  e.getByToken(verticesToken_, vertices);
40  if (vertices->empty()) return;
41  const reco::Vertex &vtx = (*vertices)[0];
42 
43  unsigned key=0;
44  for( collection::const_iterator pfc = hc->begin();
45  pfc != hc->end(); ++pfc, ++key) {
46 
47  bool passing = true;
48  const reco::Track *tk = nullptr;
49  if (pfc->gsfTrackRef().isNonnull()) tk = pfc->gsfTrackRef().get();
50  else if (pfc->trackRef().isNonnull()) tk = pfc->trackRef().get();
51 
52  if (tk != nullptr) {
53  double d0 = fabs(tk->dxy(vtx.position()));
54  double dz = fabs(tk->dz(vtx.position()));
55  double d0e = hypot(tk->dxyError(), hypot(vtx.xError(), vtx.yError()));
56  double dze = hypot(tk->dzError(), vtx.zError());
57  if (d0Cut_ > 0 && d0 > d0Cut_) passing = false;
58  if (dzCut_ > 0 && dz > dzCut_) passing = false;
59  if (d0SigCut_ > 0 && d0e > 0 && d0/d0e > d0SigCut_) passing = false;
60  if (dzSigCut_ > 0 && dze > 0 && dz/dze > dzSigCut_) passing = false;
61  }
62 
63  if( passing ) {
64  selected_.push_back( reco::PFCandidate(*pfc) );
65  reco::PFCandidatePtr ptrToMother( hc, key );
66 
67  if ( pfc->numberOfSourceCandidatePtrs() > 0 ) {
68  selected_.back().setSourceCandidatePtr( edm::Ptr<reco::PFCandidate>( pfc->sourceCandidatePtr(0)
69  ) );
70  }
71  else {
72  selected_.back().setSourceCandidatePtr( ptrToMother );
73  }
74  }
75  }
76  }
77 
78  private:
80  double d0Cut_;
81  double dzCut_;
82  double d0SigCut_;
83  double dzSigCut_;
84  };
85 }
86 
87 #endif
Selects PFCandidates basing on their compatibility with vertex.
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
double zError() const
error on z
Definition: Vertex.h:123
double dxyError() const
error on dxy
Definition: TrackBase.h:841
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const Point & position() const
position
Definition: Vertex.h:109
IPCutPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
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:642
double dzError() const
error on dz
Definition: TrackBase.h:859
double xError() const
error on x
Definition: Vertex.h:119
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
HLT enums.
susybsm::HSCParticleCollection hc
Definition: classes.h:25
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:624
double yError() const
error on y
Definition: Vertex.h:121