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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

const double fractionSumPt2_
 
const uint maxVtx_
 
const double minSumPt2_
 
std::unique_ptr< PVClusterComparerpvComparer_
 
const edm::EDGetTokenT< reco::VertexCollectionvtxToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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 }

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

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 93 of file PixelVertexCollectionTrimmer.cc.

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 RecoPixelVertexing/PixelVertexFinding/python/PVClusterComparer_cfi.py");
106  descriptions.add("hltPixelVertexCollectionTrimmer", desc);
107 }

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

◆ produce()

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

Definition at line 60 of file PixelVertexCollectionTrimmer.cc.

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 }

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

Member Data Documentation

◆ fractionSumPt2_

const double PixelVertexCollectionTrimmer::fractionSumPt2_
private

Definition at line 30 of file PixelVertexCollectionTrimmer.cc.

Referenced by PixelVertexCollectionTrimmer(), and produce().

◆ maxVtx_

const uint PixelVertexCollectionTrimmer::maxVtx_
private

Definition at line 29 of file PixelVertexCollectionTrimmer.cc.

Referenced by produce().

◆ minSumPt2_

const double 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_

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

Definition at line 28 of file PixelVertexCollectionTrimmer.cc.

Referenced by produce().

testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
HLT_FULL_cff.track_pt_min
track_pt_min
Definition: HLT_FULL_cff.py:256
HLT_FULL_cff.track_prob_min
track_prob_min
Definition: HLT_FULL_cff.py:255
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
min
T min(T a, T b)
Definition: MathUtil.h:58
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PixelVertexCollectionTrimmer::pvComparer_
std::unique_ptr< PVClusterComparer > pvComparer_
Definition: PixelVertexCollectionTrimmer.cc:33
parallelization.uint
uint
Definition: parallelization.py:124
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLT_FULL_cff.track_chi2_max
track_chi2_max
Definition: HLT_FULL_cff.py:253
PixelVertexCollectionTrimmer::fractionSumPt2_
const double fractionSumPt2_
Definition: PixelVertexCollectionTrimmer.cc:30
HLT_FULL_cff.track_pt_max
track_pt_max
Definition: HLT_FULL_cff.py:254
PixelVertexCollectionTrimmer::vtxToken_
const edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: PixelVertexCollectionTrimmer.cc:28
PixelVertexCollectionTrimmer::minSumPt2_
const double minSumPt2_
Definition: PixelVertexCollectionTrimmer.cc:31
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
iEvent
int iEvent
Definition: GenABIO.cc:224
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
edm::Log
Definition: MessageLogger.h:70
PixelVertexCollectionTrimmer::maxVtx_
const uint maxVtx_
Definition: PixelVertexCollectionTrimmer.cc:29
edm::InputTag
Definition: InputTag.h:15
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128