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 
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
pf2pat::IPCutPFCandidateSelectorDefinition
Selects PFCandidates basing on their compatibility with vertex.
Definition: IPCutPFCandidateSelectorDefinition.h:24
pf2pat::IPCutPFCandidateSelectorDefinition::d0SigCut_
double d0SigCut_
Definition: IPCutPFCandidateSelectorDefinition.h:95
PFCandidate.h
pf2pat
Definition: ElectronIDPFCandidateSelectorDefinition.h:22
edm::EDGetTokenT< reco::VertexCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
pf2pat::IPCutPFCandidateSelectorDefinition::select
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
Definition: IPCutPFCandidateSelectorDefinition.h:34
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
reco::TrackBase::dxyError
double dxyError() const
error on dxy
Definition: TrackBase.h:722
pf2pat::IPCutPFCandidateSelectorDefinition::d0Cut_
double d0Cut_
Definition: IPCutPFCandidateSelectorDefinition.h:92
dt
float dt
Definition: AMPTWrapper.h:136
alignCSCRings.s
s
Definition: alignCSCRings.py:92
pf2pat::IPCutPFCandidateSelectorDefinition::IPCutPFCandidateSelectorDefinition
IPCutPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
Definition: IPCutPFCandidateSelectorDefinition.h:25
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
pf2pat::PFCandidateSelectorDefinition::selected_
container selected_
Definition: PFCandidateSelectorDefinition.h:33
reco::TrackBase::dz
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:602
PFCandidateSelectorDefinition.h
pf2pat::IPCutPFCandidateSelectorDefinition::dzSigCut_
double dzSigCut_
Definition: IPCutPFCandidateSelectorDefinition.h:96
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
Vertex.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
pf2pat::IPCutPFCandidateSelectorDefinition::verticesToken_
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
Definition: IPCutPFCandidateSelectorDefinition.h:91
TagProbeFitTreeAnalyzer_cfi.passing
passing
Definition: TagProbeFitTreeAnalyzer_cfi.py:25
reco::TrackBase::dzError
double dzError() const
error on dz
Definition: TrackBase.h:731
GsfTrack.h
edm::EventSetup
Definition: EventSetup.h:57
edm::Ptr< PFCandidate >
looper.cfg
cfg
Definition: looper.py:297
VertexFwd.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
pf2pat::IPCutPFCandidateSelectorDefinition::dtSigCut_
double dtSigCut_
Definition: IPCutPFCandidateSelectorDefinition.h:97
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
ConsumesCollector.h
pf2pat::PFCandidateSelectorDefinition
Definition: PFCandidateSelectorDefinition.h:10
ParameterSet.h
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
reco::TrackBase::dxy
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:593
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
pf2pat::IPCutPFCandidateSelectorDefinition::dzCut_
double dzCut_
Definition: IPCutPFCandidateSelectorDefinition.h:93
reco::Vertex
Definition: Vertex.h:35
PFCandidateFwd.h
pf2pat::IPCutPFCandidateSelectorDefinition::dtCut_
double dtCut_
Definition: IPCutPFCandidateSelectorDefinition.h:94
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37