RecoTauTag
RecoTau
plugins
RecoTauPileUpVertexSelector.cc
Go to the documentation of this file.
1
/*
2
* Select reco:Vertices consistent with pileup.
3
*
4
* Author: Evan K. Friis
5
*
6
*/
7
8
#include "
FWCore/Framework/interface/stream/EDFilter.h
"
9
#include "
FWCore/Framework/interface/EventSetup.h
"
10
#include "
FWCore/Framework/interface/Event.h
"
11
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
12
#include "
FWCore/Framework/interface/ConsumesCollector.h
"
13
14
#include <
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
>
15
#include <
FWCore/ParameterSet/interface/ParameterSetDescription.h
>
16
17
#include "
DataFormats/VertexReco/interface/VertexFwd.h
"
18
#include "
DataFormats/VertexReco/interface/Vertex.h
"
19
20
#include <algorithm>
21
22
class
RecoTauPileUpVertexSelector
:
public
edm::stream::EDFilter
<> {
23
public
:
24
explicit
RecoTauPileUpVertexSelector
(
const
edm::ParameterSet
&
pset
);
25
~RecoTauPileUpVertexSelector
()
override
{}
26
bool
filter
(
edm::Event
& evt,
const
edm::EventSetup
& es)
override
;
27
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions);
28
29
private
:
30
edm::InputTag
src_
;
31
double
minPt_
;
32
bool
filter_
;
33
edm::EDGetTokenT<reco::VertexCollection>
token
;
34
};
35
36
RecoTauPileUpVertexSelector::RecoTauPileUpVertexSelector
(
const
edm::ParameterSet
&
pset
)
37
: minPt_(
pset
.getParameter<double>(
"minTrackSumPt"
)) {
38
src_
=
pset
.getParameter<
edm::InputTag
>(
"src"
);
39
token
= consumes<reco::VertexCollection>(
src_
);
40
filter_
=
pset
.getParameter<
bool
>(
"filter"
);
41
produces<reco::VertexCollection>();
42
}
43
44
bool
RecoTauPileUpVertexSelector::filter
(
edm::Event
& evt,
const
edm::EventSetup
& es) {
45
edm::Handle<reco::VertexCollection>
vertices_;
46
evt.
getByToken
(
token
, vertices_);
47
auto
output
= std::make_unique<reco::VertexCollection>();
48
// If there is only one vertex, there are no PU vertices!
49
if
(vertices_->size() > 1) {
50
// Copy over all the vertices that have associatd tracks with pt greater
51
// than the threshold. The predicate function is the VertexTrackPtSumFilter
52
// better name: copy_if_not
53
std::remove_copy_if(vertices_->begin() + 1, vertices_->end(), std::back_inserter(*
output
), [
this
](
auto
const
&
vtx
) {
54
double
trackPtSum = 0.;
55
for
(
reco::Vertex::trackRef_iterator
track
=
vtx
.tracks_begin();
track
!=
vtx
.tracks_end(); ++
track
) {
56
trackPtSum += (*track)->pt();
57
}
58
return
trackPtSum > this->
minPt_
;
59
});
60
}
61
size_t
nPUVtx =
output
->size();
62
evt.
put
(
std::move
(
output
));
63
// If 'filter' is enabled, return whether true if there are PU vertices
64
if
(!
filter_
)
65
return
true
;
66
else
67
return
nPUVtx;
68
}
69
70
void
RecoTauPileUpVertexSelector::fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions) {
71
// recoTauPileUpVertexSelector
72
edm::ParameterSetDescription
desc
;
73
74
desc
.add<
double
>(
"minTrackSumPt"
);
75
desc
.add<
edm::InputTag
>(
"src"
);
76
desc
.add<
bool
>(
"filter"
);
77
78
descriptions.
add
(
"recoTauPileUpVertexSelector"
,
desc
);
79
}
80
81
#include "
FWCore/Framework/interface/MakerMacros.h
"
82
DEFINE_FWK_MODULE
(
RecoTauPileUpVertexSelector
);
ConfigurationDescriptions.h
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition:
Vertex.h:38
RecoTauPileUpVertexSelector::src_
edm::InputTag src_
Definition:
RecoTauPileUpVertexSelector.cc:30
HLT_FULL_cff.track
track
Definition:
HLT_FULL_cff.py:11724
RecoTauPileUpVertexSelector::RecoTauPileUpVertexSelector
RecoTauPileUpVertexSelector(const edm::ParameterSet &pset)
Definition:
RecoTauPileUpVertexSelector.cc:36
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< reco::VertexCollection >
RecoTauPileUpVertexSelector
Definition:
RecoTauPileUpVertexSelector.cc:22
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
RecoTauPileUpVertexSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition:
RecoTauPileUpVertexSelector.cc:70
edm::Handle< reco::VertexCollection >
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:57
RecoTauPileUpVertexSelector::filter_
bool filter_
Definition:
RecoTauPileUpVertexSelector.cc:32
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:539
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
edm::ParameterSet
Definition:
ParameterSet.h:47
RecoTauPileUpVertexSelector::minPt_
double minPt_
Definition:
RecoTauPileUpVertexSelector.cc:31
Event.h
RecoTauPileUpVertexSelector::filter
bool filter(edm::Event &evt, const edm::EventSetup &es) override
Definition:
RecoTauPileUpVertexSelector.cc:44
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:133
edm::EventSetup
Definition:
EventSetup.h:58
RecoTauPileUpVertexSelector::token
edm::EDGetTokenT< reco::VertexCollection > token
Definition:
RecoTauPileUpVertexSelector.cc:33
VertexFwd.h
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition:
eostools.py:511
extraflags_cff.vtx
vtx
Definition:
extraflags_cff.py:19
Vertex.h
EventSetup.h
EDFilter.h
RecoTauPileUpVertexSelector::~RecoTauPileUpVertexSelector
~RecoTauPileUpVertexSelector() override
Definition:
RecoTauPileUpVertexSelector.cc:25
ConsumesCollector.h
ParameterSet.h
edm::stream::EDFilter
Definition:
EDFilter.h:36
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
Generated for CMSSW Reference Manual by
1.8.16