Validation
RecoTau
plugins
TrackFromPVSelector.cc
Go to the documentation of this file.
1
// Includes
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/Framework/interface/MakerMacros.h
"
6
#include "
FWCore/Framework/interface/global/EDProducer.h
"
7
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
8
#include "
FWCore/Utilities/interface/InputTag.h
"
9
10
#include "
CommonTools/Utils/interface/StringCutObjectSelector.h
"
11
12
#include "
DataFormats/TrackReco/interface/Track.h
"
13
#include "
DataFormats/TrackReco/interface/TrackFwd.h
"
14
#include "
DataFormats/VertexReco/interface/Vertex.h
"
15
#include "
DataFormats/VertexReco/interface/VertexFwd.h
"
16
17
#include <algorithm>
18
#include <numeric>
19
#include <memory>
20
#include <vector>
21
23
// class definition
25
class
TrackFromPVSelector
:
public
edm::global::EDProducer
<> {
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_
;
34
edm::EDGetTokenT<std::vector<reco::Vertex>
>
v_recoVertexToken_
;
35
edm::EDGetTokenT<std::vector<reco::Track>
>
v_recoTrackToken_
;
36
};
37
39
// construction/destruction
41
42
//______________________________________________________________________________
43
TrackFromPVSelector::TrackFromPVSelector
(
edm::ParameterSet
const
& iConfig)
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
//______________________________________________________________________________
56
void
TrackFromPVSelector::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
edm::EventSetup
const
&)
const
{
57
edm::Handle<std::vector<reco::Vertex>
>
vertices
;
58
iEvent
.getByToken(
v_recoVertexToken_
,
vertices
);
59
60
edm::Handle<std::vector<reco::Track>
>
tracks
;
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
}
71
iEvent
.put(
std::move
(
goodTracks
));
72
}
73
74
DEFINE_FWK_MODULE
(
TrackFromPVSelector
);
edm::StreamID
Definition:
StreamID.h:30
HLT_FULL_cff.track
track
Definition:
HLT_FULL_cff.py:11724
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
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition:
AlignmentTracksFromVertexSelector_cfi.py:5
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
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition:
CAHitNtupletGeneratorKernelsImpl.h:176
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
TrackFromPVSelector::TrackFromPVSelector
TrackFromPVSelector(edm::ParameterSet const &iConfig)
Definition:
TrackFromPVSelector.cc:43
InputTag.h
VertexFwd.h
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
Vertex.h
TrackFromPVSelector::max_dxy_
double max_dxy_
Definition:
TrackFromPVSelector.cc:32
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
goodTracks_cfi.goodTracks
goodTracks
Definition:
goodTracks_cfi.py:3
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
Generated for CMSSW Reference Manual by
1.8.16