CMS 3D CMS Logo

TrackFromPVSelector.cc
Go to the documentation of this file.
1 // Includes
9 
11 
16 
17 #include <algorithm>
18 #include <numeric>
19 #include <memory>
20 #include <vector>
21 
23 // class definition
26 public:
27  explicit TrackFromPVSelector(edm::ParameterSet const& iConfig);
28 
29  void produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
30 
31 private:
32  double max_dxy_;
33  double max_dz_;
36 };
37 
39 // construction/destruction
41 
42 //______________________________________________________________________________
44  : max_dxy_{iConfig.getParameter<double>("max_dxy")},
45  max_dz_{iConfig.getParameter<double>("max_dz")},
46  v_recoVertexToken_{consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("srcVertex"))},
47  v_recoTrackToken_{consumes<std::vector<reco::Track>>(iConfig.getParameter<edm::InputTag>("srcTrack"))} {
48  produces<std::vector<reco::Track>>();
49 }
50 
52 // implementation of member functions
54 
55 //______________________________________________________________________________
58  iEvent.getByToken(v_recoVertexToken_, vertices);
59 
61  iEvent.getByToken(v_recoTrackToken_, tracks);
62 
63  auto goodTracks = std::make_unique<std::vector<reco::Track>>();
64  if (!vertices->empty() && !tracks->empty()) {
65  auto const& vtxPos = vertices->front().position();
66  std::copy_if(
67  std::cbegin(*tracks), std::cend(*tracks), std::back_inserter(*goodTracks), [this, &vtxPos](auto const& track) {
68  return std::abs(track.dxy(vtxPos)) < max_dxy_ && std::abs(track.dz(vtxPos)) < max_dz_;
69  });
70  }
72 }
73 
edm::StreamID
Definition: StreamID.h:30
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
edm::EDGetTokenT
Definition: EDGetToken.h:33
TrackFromPVSelector::produce
void produce(edm::StreamID, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
Definition: TrackFromPVSelector.cc:56
TrackFromPVSelector
Definition: TrackFromPVSelector.cc:25
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackFromPVSelector::v_recoTrackToken_
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: TrackFromPVSelector.cc:35
edm::global::EDProducer
Definition: EDProducer.h:32
Vertex.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
TrackFromPVSelector::TrackFromPVSelector
TrackFromPVSelector(edm::ParameterSet const &iConfig)
Definition: TrackFromPVSelector.cc:43
InputTag.h
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackFromPVSelector::v_recoVertexToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
Definition: TrackFromPVSelector.cc:34
eostools.move
def move(src, dest)
Definition: eostools.py:511
StringCutObjectSelector.h
TrackFromPVSelector::max_dz_
double max_dz_
Definition: TrackFromPVSelector.cc:33
TrackFromPVSelector::max_dxy_
double max_dxy_
Definition: TrackFromPVSelector.cc:32
goodTracks_cfi.goodTracks
goodTracks
Definition: goodTracks_cfi.py:3
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7