CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
26  : verticesToken_(iC.consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"))),
27  d0Cut_(cfg.getParameter<double>("d0Cut")),
28  dzCut_(cfg.getParameter<double>("dzCut")),
29  dtCut_(cfg.getParameter<double>("dtCut")),
30  d0SigCut_(cfg.getParameter<double>("d0SigCut")),
31  dzSigCut_(cfg.getParameter<double>("dzSigCut")),
32  dtSigCut_(cfg.getParameter<double>("dtSigCut")) {}
33 
34  void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s) {
35  selected_.clear();
36 
38  e.getByToken(verticesToken_, vertices);
39  if (vertices->empty())
40  return;
41  const reco::Vertex &vtx = (*vertices)[0];
42  double vt = vtx.t();
43  double vte = vtx.tError();
44 
45  unsigned key = 0;
46  for (collection::const_iterator pfc = hc->begin(); pfc != hc->end(); ++pfc, ++key) {
47  bool passing = true;
48  const reco::Track *tk = nullptr;
49  if (pfc->gsfTrackRef().isNonnull())
50  tk = pfc->gsfTrackRef().get();
51  else if (pfc->trackRef().isNonnull())
52  tk = pfc->trackRef().get();
53 
54  if (tk != nullptr) {
55  double d0 = fabs(tk->dxy(vtx.position()));
56  double dz = fabs(tk->dz(vtx.position()));
57  double d0e = hypot(tk->dxyError(), hypot(vtx.xError(), vtx.yError()));
58  double dze = hypot(tk->dzError(), vtx.zError());
59  if (d0Cut_ > 0 && d0 > d0Cut_)
60  passing = false;
61  if (dzCut_ > 0 && dz > dzCut_)
62  passing = false;
63  if (d0SigCut_ > 0 && d0e > 0 && d0 / d0e > d0SigCut_)
64  passing = false;
65  if (dzSigCut_ > 0 && dze > 0 && dz / dze > dzSigCut_)
66  passing = false;
67  }
68  double pfct = pfc->time();
69  double pfcte = pfc->timeError();
70  double dt = fabs(pfct - vt);
71  double dte = std::sqrt(pfcte * pfcte + vte * vte);
72  if (dtCut_ > 0 && pfcte > 0 && vte > 0 && dt > dtCut_)
73  passing = false;
74  if (dtSigCut_ > 0 && pfcte > 0 && vte > 0 && dt / dte > dtSigCut_)
75  passing = false;
76 
77  if (passing) {
78  selected_.push_back(reco::PFCandidate(*pfc));
79  reco::PFCandidatePtr ptrToMother(hc, key);
80 
81  if (pfc->numberOfSourceCandidatePtrs() > 0) {
82  selected_.back().setSourceCandidatePtr(edm::Ptr<reco::PFCandidate>(pfc->sourceCandidatePtr(0)));
83  } else {
84  selected_.back().setSourceCandidatePtr(ptrToMother);
85  }
86  }
87  }
88  }
89 
90  private:
92  double d0Cut_;
93  double dzCut_;
94  double dtCut_;
95  double d0SigCut_;
96  double dzSigCut_;
97  double dtSigCut_;
98  };
99 } // namespace pf2pat
100 
101 #endif
float dt
Definition: AMPTWrapper.h:136
tuple cfg
Definition: looper.py:296
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:539
double zError() const
error on z
Definition: Vertex.h:141
double dxyError() const
error on dxy
Definition: TrackBase.h:769
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
const Point & position() const
position
Definition: Vertex.h:127
IPCutPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
T sqrt(T t)
Definition: SSEVec.h:19
tuple key
prepare the HTCondor submission files and eventually submit them
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:622
double dzError() const
error on dz
Definition: TrackBase.h:778
static constexpr float d0
double xError() const
error on x
Definition: Vertex.h:137
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
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:608
double yError() const
error on y
Definition: Vertex.h:139
double tError() const
error on t
Definition: Vertex.h:143
double t() const
t coordinate
Definition: Vertex.h:135