38 maxVtx_(iConfig.getParameter<
uint>(
"maxVtx")),
39 fractionSumPt2_(iConfig.getParameter<double>(
"fractionSumPt2")),
40 minSumPt2_(iConfig.getParameter<double>(
"minSumPt2")) {
42 throw cms::Exception(
"PixelVertexConfiguration") <<
"value of \"fractionSumPt2\" is larger than 1.";
45 auto const track_pt_min = pvComparerPSet.getParameter<
double>(
"track_pt_min");
46 auto const track_pt_max = pvComparerPSet.getParameter<
double>(
"track_pt_max");
47 auto const track_chi2_max = pvComparerPSet.getParameter<
double>(
"track_chi2_max");
48 auto const track_prob_min = pvComparerPSet.getParameter<
double>(
"track_prob_min");
52 <<
"PVcomparer.track_pt_min (" <<
track_pt_min <<
") >= PVcomparer.track_pt_max (" << track_pt_max
53 <<
") : PVClusterComparer will use pT=" << track_pt_max <<
" for all selected tracks.";
57 produces<reco::VertexCollection>();
61 auto vtxs_trim = std::make_unique<reco::VertexCollection>();
66 edm::LogWarning(
"PixelVertexInput") <<
"Input collection of vertices is empty. Output collection will be empty.";
68 std::vector<double> foms(vtxs.size());
69 for (
size_t idx = 0; idx < vtxs.size(); ++idx)
72 std::vector<size_t> sortIdxs(vtxs.size());
73 std::iota(sortIdxs.begin(), sortIdxs.end(), 0);
74 std::sort(sortIdxs.begin(), sortIdxs.end(), [&](
size_t const i1,
size_t const i2) {
return foms[i1] > foms[i2]; });
79 for (
auto const idx : sortIdxs) {
80 if (vtxs_trim->size() >=
maxVtx_)
82 if (foms[idx] >= minFOM_fromFrac and foms[idx] >
minSumPt2_)
83 vtxs_trim->emplace_back(vtxs[idx]);
86 if (vtxs_trim->empty())
87 edm::LogInfo(
"PixelVertexOutput") <<
"Output collection is empty.";
96 desc.
add<
uint>(
"maxVtx", 100)->setComment(
"max output collection size (number of accepted vertices)");
97 desc.
add<
double>(
"fractionSumPt2", 0.3)->
setComment(
"threshold on sumPt2 fraction of the leading vertex");
100 PVcomparerPSet.
add<
double>(
"track_pt_min", 1.0)->
setComment(
"min track p_T");
101 PVcomparerPSet.
add<
double>(
"track_pt_max", 10.0)->
setComment(
"max track p_T");
102 PVcomparerPSet.
add<
double>(
"track_chi2_max", 99999.)->
setComment(
"max track chi2");
103 PVcomparerPSet.
add<
double>(
"track_prob_min", -1.)->
setComment(
"min track prob");
105 ->setComment(
"from RecoPixelVertexing/PixelVertexFinding/python/PVClusterComparer_cfi.py");
106 descriptions.
add(
"hltPixelVertexCollectionTrimmer", desc);
double const fractionSumPt2_
void setComment(std::string const &value)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
std::vector< Vertex > VertexCollection
bool get(ProductID const &oid, Handle< PROD > &result) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
ParameterSet const & getParameterSet(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
PixelVertexCollectionTrimmer(const edm::ParameterSet &)
edm::EDGetTokenT< reco::VertexCollection > const vtxToken_
std::unique_ptr< PVClusterComparer > pvComparer_