CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PixelVertexCollectionTrimmer Class Reference
Inheritance diagram for PixelVertexCollectionTrimmer:
edm::stream::EDProducer<>

Public Member Functions

 PixelVertexCollectionTrimmer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double const fractionSumPt2_
 
uint const maxVtx_
 
double const minSumPt2_
 
std::unique_ptr< PVClusterComparerpvComparer_
 
edm::EDGetTokenT< reco::VertexCollection > const vtxToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 19 of file PixelVertexCollectionTrimmer.cc.

Constructor & Destructor Documentation

◆ PixelVertexCollectionTrimmer()

PixelVertexCollectionTrimmer::PixelVertexCollectionTrimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 36 of file PixelVertexCollectionTrimmer.cc.

References Exception, fractionSumPt2_, edm::ParameterSet::getParameterSet(), pvComparer_, HLT_2024v14_cff::track_chi2_max, HLT_2024v14_cff::track_prob_min, HLT_2024v14_cff::track_pt_max, and HLT_2024v14_cff::track_pt_min.

37  : vtxToken_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("src"))),
38  maxVtx_(iConfig.getParameter<uint>("maxVtx")),
39  fractionSumPt2_(iConfig.getParameter<double>("fractionSumPt2")),
40  minSumPt2_(iConfig.getParameter<double>("minSumPt2")) {
41  if (fractionSumPt2_ > 1)
42  throw cms::Exception("PixelVertexConfiguration") << "value of \"fractionSumPt2\" is larger than 1.";
43 
44  auto const& pvComparerPSet = iConfig.getParameterSet("PVcomparer");
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");
49 
51  throw cms::Exception("PixelVertexConfiguration")
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.";
54 
55  pvComparer_ = std::make_unique<PVClusterComparer>(track_pt_min, track_pt_max, track_chi2_max, track_prob_min);
56 
57  produces<reco::VertexCollection>();
58 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > const vtxToken_
std::unique_ptr< PVClusterComparer > pvComparer_

Member Function Documentation

◆ fillDescriptions()

void PixelVertexCollectionTrimmer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 93 of file PixelVertexCollectionTrimmer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, edm::ParameterDescriptionNode::setComment(), and parallelization::uint.

93  {
95  desc.add<edm::InputTag>("src", edm::InputTag(""))->setComment("input (pixel) vertex collection");
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");
98  desc.add<double>("minSumPt2", 0.)->setComment("min sumPt2");
99  edm::ParameterSetDescription PVcomparerPSet;
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");
104  desc.add<edm::ParameterSetDescription>("PVcomparer", PVcomparerPSet)
105  ->setComment("from RecoVertex/PixelVertexFinding/python/PVClusterComparer_cfi.py");
106  descriptions.add("hltPixelVertexCollectionTrimmer", desc);
107 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void PixelVertexCollectionTrimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 60 of file PixelVertexCollectionTrimmer.cc.

References fractionSumPt2_, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, heavyIonCSV_trainingSettings::idx, iEvent, maxVtx_, SiStripPI::min, minSumPt2_, eostools::move(), pvComparer_, jetUpdater_cfi::sort, and vtxToken_.

60  {
61  auto vtxs_trim = std::make_unique<reco::VertexCollection>();
62 
63  auto const& vtxs = iEvent.get(vtxToken_);
64 
65  if (vtxs.empty())
66  edm::LogWarning("PixelVertexInput") << "Input collection of vertices is empty. Output collection will be empty.";
67  else {
68  std::vector<double> foms(vtxs.size());
69  for (size_t idx = 0; idx < vtxs.size(); ++idx)
70  foms[idx] = pvComparer_->pTSquaredSum(vtxs[idx]);
71 
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]; });
75 
76  auto const minFOM_fromFrac = foms[sortIdxs.front()] * fractionSumPt2_;
77 
78  vtxs_trim->reserve(std::min((size_t)maxVtx_, vtxs.size()));
79  for (auto const idx : sortIdxs) {
80  if (vtxs_trim->size() >= maxVtx_)
81  break;
82  if (foms[idx] >= minFOM_fromFrac and foms[idx] > minSumPt2_)
83  vtxs_trim->emplace_back(vtxs[idx]);
84  }
85 
86  if (vtxs_trim->empty())
87  edm::LogInfo("PixelVertexOutput") << "Output collection is empty.";
88  }
89 
90  iEvent.put(std::move(vtxs_trim));
91 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::VertexCollection > const vtxToken_
std::unique_ptr< PVClusterComparer > pvComparer_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ fractionSumPt2_

double const PixelVertexCollectionTrimmer::fractionSumPt2_
private

Definition at line 30 of file PixelVertexCollectionTrimmer.cc.

Referenced by PixelVertexCollectionTrimmer(), and produce().

◆ maxVtx_

uint const PixelVertexCollectionTrimmer::maxVtx_
private

Definition at line 29 of file PixelVertexCollectionTrimmer.cc.

Referenced by produce().

◆ minSumPt2_

double const PixelVertexCollectionTrimmer::minSumPt2_
private

Definition at line 31 of file PixelVertexCollectionTrimmer.cc.

Referenced by produce().

◆ pvComparer_

std::unique_ptr<PVClusterComparer> PixelVertexCollectionTrimmer::pvComparer_
private

Definition at line 33 of file PixelVertexCollectionTrimmer.cc.

Referenced by PixelVertexCollectionTrimmer(), and produce().

◆ vtxToken_

edm::EDGetTokenT<reco::VertexCollection> const PixelVertexCollectionTrimmer::vtxToken_
private

Definition at line 28 of file PixelVertexCollectionTrimmer.cc.

Referenced by produce().