CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfEleDxyCut.cc
Go to the documentation of this file.
6 
8 public:
10 
11  result_type operator()(const reco::GsfElectronPtr&) const override final;
12 
13  void setConsumes(edm::ConsumesCollector&) override final;
14  void getEventContent(const edm::EventBase&) override final;
15 
16  double value(const reco::CandidatePtr& cand) const override final;
17 
18  CandidateType candidateType() const override final {
19  return ELECTRON;
20  }
21 
22 private:
25 };
26 
29  "GsfEleDxyCut");
30 
33  _dxyCutValueEB(c.getParameter<double>("dxyCutValueEB")),
34  _dxyCutValueEE(c.getParameter<double>("dxyCutValueEE")),
35  _barrelCutOff(c.getParameter<double>("barrelCutOff")) {
36  edm::InputTag vertextag = c.getParameter<edm::InputTag>("vertexSrc");
37  edm::InputTag vertextagMiniAOD = c.getParameter<edm::InputTag>("vertexSrcMiniAOD");
38  contentTags_.emplace("vertices",vertextag);
39  contentTags_.emplace("verticesMiniAOD",vertextagMiniAOD);
40 }
41 
43  auto vtcs = cc.mayConsume<reco::VertexCollection>(contentTags_["vertices"]);
44  auto vtcsMiniAOD = cc.mayConsume<reco::VertexCollection>(contentTags_["verticesMiniAOD"]);
45  contentTokens_.emplace("vertices",vtcs);
46  contentTokens_.emplace("verticesMiniAOD",vtcsMiniAOD);
47 }
48 
50  // First try AOD, then go to miniAOD. Use the same Handle since collection class is the same.
51  ev.getByLabel(contentTags_["vertices"],_vtxs);
52  if (!_vtxs.isValid())
53  ev.getByLabel(contentTags_["verticesMiniAOD"],_vtxs);
54 }
55 
56 CutApplicatorBase::result_type
58 operator()(const reco::GsfElectronPtr& cand) const{
59  const float dxyCutValue =
60  ( std::abs(cand->superCluster()->position().eta()) < _barrelCutOff ?
62 
63  const reco::VertexCollection& vtxs = *_vtxs;
64  const double dxy = ( vtxs.size() ?
65  cand->gsfTrack()->dxy(vtxs[0].position()) :
66  cand->gsfTrack()->dxy() );
67  return std::abs(dxy) < dxyCutValue;
68 }
69 
70 double GsfEleDxyCut::value(const reco::CandidatePtr& cand) const {
71  reco::GsfElectronPtr ele(cand);
72  const reco::VertexCollection& vtxs = *_vtxs;
73  const double dxy = ( vtxs.size() ?
74  ele->gsfTrack()->dxy(vtxs[0].position()) :
75  ele->gsfTrack()->dxy() );
76  return std::abs(dxy);
77 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool ev
void getEventContent(const edm::EventBase &) overridefinal
Definition: GsfEleDxyCut.cc:49
const double _dxyCutValueEB
Definition: GsfEleDxyCut.cc:23
std::unordered_map< std::string, edm::InputTag > contentTags_
CandidateType candidateType() const overridefinal
Definition: GsfEleDxyCut.cc:18
result_type operator()(const reco::GsfElectronPtr &) const overridefinal
Definition: GsfEleDxyCut.cc:58
edm::Handle< reco::VertexCollection > _vtxs
Definition: GsfEleDxyCut.cc:24
const double _dxyCutValueEE
Definition: GsfEleDxyCut.cc:23
void setConsumes(edm::ConsumesCollector &) overridefinal
Definition: GsfEleDxyCut.cc:42
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:75
GsfEleDxyCut(const edm::ParameterSet &c)
Definition: GsfEleDxyCut.cc:31
const double _barrelCutOff
Definition: GsfEleDxyCut.cc:23
string const
Definition: compareJSON.py:14
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
static int position[264][3]
Definition: ReadPGInfo.cc:509
#define DEFINE_EDM_PLUGIN(factory, type, name)
double value(const reco::CandidatePtr &cand) const overridefinal
Definition: GsfEleDxyCut.cc:70