CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
PrimaryVertexSorter< ParticlesCollection > Class Template Reference

#include <PrimaryVertexSorter.h>

Inheritance diagram for PrimaryVertexSorter< ParticlesCollection >:
edm::stream::EDProducer<>

Public Types

typedef edm::Association< reco::VertexCollectionCandToVertex
 
typedef edm::ValueMap< int > CandToVertexQuality
 
typedef ParticlesCollection PFCollection
 
typedef edm::ValueMap< float > VertexScore
 
- 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
 

Public Member Functions

template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
 PrimaryVertexSorter (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
std::vector< reco::VertexsortedList (const reco::VertexCollection &primaryVertex) const
 
 ~PrimaryVertexSorter () override
 
- 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 doConsumesForTiming (const edm::ParameterSet &iConfig)
 
template<>
void doConsumesForTiming (const edm::ParameterSet &iConfig)
 
template<>
void doConsumesForTiming (const edm::ParameterSet &iConfig)
 
template<>
void doConsumesForTiming (const edm::ParameterSet &iConfig)
 
bool needsProductsForTiming ()
 
template<>
bool needsProductsForTiming ()
 
template<>
bool needsProductsForTiming ()
 
template<>
bool needsProductsForTiming ()
 
std::pair< int, PrimaryVertexAssignment::QualityrunAlgo (const reco::VertexCollection &vertices, const typename ParticlesCollection::value_type &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)
 
template<>
std::pair< int, PrimaryVertexAssignment::QualityrunAlgo (const reco::VertexCollection &vertices, const reco::RecoChargedRefCandidate &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)
 
template<>
std::pair< int, PrimaryVertexAssignment::QualityrunAlgo (const reco::VertexCollection &vertices, const reco::PFCandidate &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)
 
template<>
std::pair< int, PrimaryVertexAssignment::QualityrunAlgo (const reco::VertexCollection &vertices, const pat::PackedCandidate &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)
 

Static Private Member Functions

static void fillDescriptionsCommon (edm::ParameterSetDescription &descriptions)
 

Private Attributes

PrimaryVertexAssignment assignmentAlgo_
 
bool produceOriginalMapping_
 
bool producePFNoPileUp_
 
bool producePFPileUp_
 
bool produceSortedVertices_
 
int qualityCut_
 
PrimaryVertexSorting sortingAlgo_
 
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordtokenBuilder_
 
edm::EDGetTokenT< PFCollectiontokenCandidates_
 Candidates to be analyzed. More...
 
edm::EDGetTokenT< edm::View< reco::Candidate > > tokenJets_
 
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeResoTag_
 
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeTag_
 
edm::EDGetTokenT< reco::VertexCollectiontokenVertices_
 vertices More...
 
bool useMET_
 
bool useTiming_
 

Detailed Description

template<class ParticlesCollection>
class PrimaryVertexSorter< ParticlesCollection >

Author
Andrea Rizzi

class to sort VertexCollection in decreasing order of the sum of the squared track pT's

Definition at line 35 of file PrimaryVertexSorter.h.

Member Typedef Documentation

◆ CandToVertex

template<class ParticlesCollection >
typedef edm::Association<reco::VertexCollection> PrimaryVertexSorter< ParticlesCollection >::CandToVertex

Definition at line 37 of file PrimaryVertexSorter.h.

◆ CandToVertexQuality

template<class ParticlesCollection >
typedef edm::ValueMap<int> PrimaryVertexSorter< ParticlesCollection >::CandToVertexQuality

Definition at line 38 of file PrimaryVertexSorter.h.

◆ PFCollection

template<class ParticlesCollection >
typedef ParticlesCollection PrimaryVertexSorter< ParticlesCollection >::PFCollection

Definition at line 41 of file PrimaryVertexSorter.h.

◆ VertexScore

template<class ParticlesCollection >
typedef edm::ValueMap<float> PrimaryVertexSorter< ParticlesCollection >::VertexScore

Definition at line 39 of file PrimaryVertexSorter.h.

Constructor & Destructor Documentation

◆ PrimaryVertexSorter()

template<class ParticlesCollection >
PrimaryVertexSorter< ParticlesCollection >::PrimaryVertexSorter ( const edm::ParameterSet iConfig)
explicit

Definition at line 94 of file PrimaryVertexSorter.h.

References PrimaryVertexSorter< ParticlesCollection >::doConsumesForTiming(), PrimaryVertexSorter< ParticlesCollection >::produceOriginalMapping_, PrimaryVertexSorter< ParticlesCollection >::producePFNoPileUp_, PrimaryVertexSorter< ParticlesCollection >::producePFPileUp_, PrimaryVertexSorter< ParticlesCollection >::produceSortedVertices_, and PrimaryVertexSorter< ParticlesCollection >::useTiming_.

95  : assignmentAlgo_(iConfig.getParameterSet("assignment")),
96  sortingAlgo_(iConfig.getParameterSet("sorting")),
97  tokenCandidates_(consumes<ParticlesCollection>(iConfig.getParameter<edm::InputTag>("particles"))),
98  tokenVertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
100  tokenBuilder_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
101  produceOriginalMapping_(iConfig.getParameter<bool>("produceAssociationToOriginalVertices")),
102  produceSortedVertices_(iConfig.getParameter<bool>("produceSortedVertices")),
103  producePFPileUp_(iConfig.getParameter<bool>("producePileUpCollection")),
104  producePFNoPileUp_(iConfig.getParameter<bool>("produceNoPileUpCollection")),
105  qualityCut_(iConfig.getParameter<int>("qualityForPrimary")),
106  useMET_(iConfig.getParameter<bool>("usePVMET")),
107  useTiming_(iConfig.getParameterSet("assignment").getParameter<bool>("useTiming")) {
108  using namespace std;
109  using namespace edm;
110  using namespace reco;
111 
113  produces<CandToVertex>("original");
114  produces<CandToVertexQuality>("original");
115  produces<VertexScore>("original");
116  }
118  produces<reco::VertexCollection>();
119  produces<CandToVertex>();
120  produces<CandToVertexQuality>();
121  produces<VertexScore>();
122  }
123 
124  if (producePFPileUp_) {
126  produces<PFCollection>("originalPileUp");
128  produces<PFCollection>("PileUp");
129  }
130 
131  if (producePFNoPileUp_) {
133  produces<PFCollection>("originalNoPileUp");
135  produces<PFCollection>("NoPileUp");
136  }
137 
138  if (useTiming_)
139  doConsumesForTiming(iConfig);
140 }
void doConsumesForTiming(const edm::ParameterSet &iConfig)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
PrimaryVertexSorting sortingAlgo_
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< PFCollection > tokenCandidates_
Candidates to be analyzed.
PrimaryVertexAssignment assignmentAlgo_
fixed size matrix
HLT enums.
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > tokenBuilder_
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
edm::EDGetTokenT< edm::View< reco::Candidate > > tokenJets_

◆ ~PrimaryVertexSorter()

template<class ParticlesCollection >
PrimaryVertexSorter< ParticlesCollection >::~PrimaryVertexSorter ( )
inlineoverride

Definition at line 45 of file PrimaryVertexSorter.h.

45 {}

Member Function Documentation

◆ doConsumesForTiming() [1/4]

template<class ParticlesCollection >
void PrimaryVertexSorter< ParticlesCollection >::doConsumesForTiming ( const edm::ParameterSet iConfig)
private

◆ doConsumesForTiming() [2/4]

template<>
void PrimaryVertexSorter< std::vector< reco::RecoChargedRefCandidate > >::doConsumesForTiming ( const edm::ParameterSet iConfig)
inlineprivate

Definition at line 392 of file PrimaryVertexSorter.h.

References edm::ParameterSet::getParameter(), PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeResoTag_, and PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeTag_.

393  {
394  tokenTrackTimeTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeTag"));
395  tokenTrackTimeResoTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeResoTag"));
396 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeTag_
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeResoTag_

◆ doConsumesForTiming() [3/4]

template<>
void PrimaryVertexSorter< std::vector< reco::PFCandidate > >::doConsumesForTiming ( const edm::ParameterSet iConfig)
inlineprivate

Definition at line 399 of file PrimaryVertexSorter.h.

399  {
400 }

◆ doConsumesForTiming() [4/4]

template<>
void PrimaryVertexSorter< std::vector< pat::PackedCandidate > >::doConsumesForTiming ( const edm::ParameterSet iConfig)
inlineprivate

Definition at line 403 of file PrimaryVertexSorter.h.

404  {}

◆ fillDescriptions() [1/4]

template<class ParticlesCollection >
static void PrimaryVertexSorter< ParticlesCollection >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

◆ fillDescriptions() [2/4]

template<>
void PrimaryVertexSorter< std::vector< reco::RecoChargedRefCandidate > >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inline

Definition at line 312 of file PrimaryVertexSorter.h.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, PrimaryVertexSorter< ParticlesCollection >::fillDescriptionsCommon(), and ProducerED_cfi::InputTag.

313  {
316  desc.add<edm::InputTag>("trackTimeTag", edm::InputTag(""));
317  desc.add<edm::InputTag>("trackTimeResoTag", edm::InputTag(""));
318  desc.add<edm::InputTag>("particles", edm::InputTag("trackRefsForJets"));
319  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
320  desc.add<edm::InputTag>("jets", edm::InputTag("ak4CaloJetsForTrk"));
321  desc.add<bool>("produceAssociationToOriginalVertices", false);
322  desc.add<bool>("produceSortedVertices", true);
323  desc.add<bool>("producePileUpCollection", false);
324  desc.add<bool>("produceNoPileUpCollection", false);
325  descriptions.add("sortedPrimaryVertices", desc);
326 }
static void fillDescriptionsCommon(edm::ParameterSetDescription &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillDescriptions() [3/4]

template<>
void PrimaryVertexSorter< std::vector< reco::PFCandidate > >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inline

Definition at line 329 of file PrimaryVertexSorter.h.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, PrimaryVertexSorter< ParticlesCollection >::fillDescriptionsCommon(), and ProducerED_cfi::InputTag.

330  {
333  desc.add<edm::InputTag>("particles", edm::InputTag("particleFlow"));
334  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
335  desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJets"));
336  desc.add<bool>("produceAssociationToOriginalVertices", true);
337  desc.add<bool>("produceSortedVertices", true);
338  desc.add<bool>("producePileUpCollection", true);
339  desc.add<bool>("produceNoPileUpCollection", true);
340  descriptions.add("sortedPFPrimaryVertices", desc);
341 }
static void fillDescriptionsCommon(edm::ParameterSetDescription &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillDescriptions() [4/4]

template<>
void PrimaryVertexSorter< std::vector< pat::PackedCandidate > >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inline

Definition at line 344 of file PrimaryVertexSorter.h.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, PrimaryVertexSorter< ParticlesCollection >::fillDescriptionsCommon(), and ProducerED_cfi::InputTag.

345  {
348  desc.add<edm::InputTag>("particles", edm::InputTag("packedPFCandidates"));
349  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"));
350  desc.add<edm::InputTag>("jets", edm::InputTag("slimmedJets"));
351  desc.add<bool>("produceAssociationToOriginalVertices", true);
352  desc.add<bool>("produceSortedVertices", true);
353  desc.add<bool>("producePileUpCollection", true);
354  desc.add<bool>("produceNoPileUpCollection", true);
355  descriptions.add("sortedPackedPrimaryVertices", desc);
356 }
static void fillDescriptionsCommon(edm::ParameterSetDescription &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillDescriptionsCommon()

template<class ParticlesCollection >
void PrimaryVertexSorter< ParticlesCollection >::fillDescriptionsCommon ( edm::ParameterSetDescription descriptions)
inlinestaticprivate

Definition at line 359 of file PrimaryVertexSorter.h.

References edm::ParameterSetDescription::add(), and submitPVResolutionJobs::desc.

Referenced by PrimaryVertexSorter< ParticlesCollection >::fillDescriptions().

359  {
360  {
362  desc.add<edm::ParameterSetDescription>("sorting", psd0);
363  }
364  {
366  psd0.add<double>("maxDzSigForPrimaryAssignment", 5.0);
367  psd0.add<double>("maxDzForPrimaryAssignment", 0.1);
368  psd0.add<double>("maxDzErrorForPrimaryAssignment", 0.05);
369  psd0.add<double>("maxDtSigForPrimaryAssignment", 3.0);
370  psd0.add<double>("maxJetDeltaR", 0.5);
371  psd0.add<double>("minJetPt", 25);
372  psd0.add<double>("maxDistanceToJetAxis", 0.07);
373  psd0.add<double>("maxDzForJetAxisAssigment", 0.1);
374  psd0.add<double>("maxDxyForJetAxisAssigment", 0.1);
375  psd0.add<double>("maxDxySigForNotReconstructedPrimary", 2);
376  psd0.add<double>("maxDxyForNotReconstructedPrimary", 0.01);
377  psd0.add<bool>("useTiming", false);
378  psd0.add<bool>("useVertexFit", true);
379  psd0.add<bool>("preferHighRanked", false);
380  psd0.add<unsigned int>("NumOfPUVtxsForCharged", 0);
381  psd0.add<double>("DzCutForChargedFromPUVtxs", 0.2);
382  psd0.add<double>("PtMaxCharged", -1);
383  psd0.add<double>("EtaMinUseDz", -1);
384  psd0.add<bool>("OnlyUseFirstDz", false);
385  desc.add<edm::ParameterSetDescription>("assignment", psd0);
386  }
387  desc.add<int>("qualityForPrimary", 3);
388  desc.add<bool>("usePVMET", true);
389 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ needsProductsForTiming() [1/4]

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::needsProductsForTiming ( )
private

◆ needsProductsForTiming() [2/4]

template<>
bool PrimaryVertexSorter< std::vector< reco::RecoChargedRefCandidate > >::needsProductsForTiming ( )
inlineprivate

Definition at line 407 of file PrimaryVertexSorter.h.

407  {
408  return true;
409 }

◆ needsProductsForTiming() [3/4]

template<>
bool PrimaryVertexSorter< std::vector< reco::PFCandidate > >::needsProductsForTiming ( )
inlineprivate

Definition at line 412 of file PrimaryVertexSorter.h.

412  {
413  return false;
414 }

◆ needsProductsForTiming() [4/4]

template<>
bool PrimaryVertexSorter< std::vector< pat::PackedCandidate > >::needsProductsForTiming ( )
inlineprivate

Definition at line 417 of file PrimaryVertexSorter.h.

417  {
418  return false;
419 }

◆ produce()

template<class ParticlesCollection >
void PrimaryVertexSorter< ParticlesCollection >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 143 of file PrimaryVertexSorter.h.

References edm::helper::Filler< Map >::fill(), edm::EventSetup::getData(), mps_fire::i, heavyIonCSV_trainingSettings::idx, iEvent, edm::helper::Filler< Map >::insert(), PDWG_EXODelayedJetMET_cff::jets, eostools::move(), PrimaryVertexSorter< ParticlesCollection >::needsProductsForTiming(), ecalTrigSettings_cff::particles, packedPFCandidateRefMixer_cfi::pf, PrimaryVertexSorter< ParticlesCollection >::produceOriginalMapping_, PrimaryVertexSorter< ParticlesCollection >::producePFNoPileUp_, PrimaryVertexSorter< ParticlesCollection >::producePFPileUp_, PrimaryVertexSorter< ParticlesCollection >::produceSortedVertices_, edm::Handle< T >::product(), MetAnalyzer::pv(), l1tGTMenu_lepSeeds_cff::qual, PrimaryVertexSorter< ParticlesCollection >::qualityCut_, PrimaryVertexSorter< ParticlesCollection >::runAlgo(), alignCSCRings::s, PrimaryVertexSorting::score(), PrimaryVertexSorter< ParticlesCollection >::sortingAlgo_, PrimaryVertexSorter< ParticlesCollection >::tokenBuilder_, PrimaryVertexSorter< ParticlesCollection >::tokenCandidates_, PrimaryVertexSorter< ParticlesCollection >::tokenJets_, PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeResoTag_, PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeTag_, PrimaryVertexSorter< ParticlesCollection >::tokenVertices_, offlinePrimaryVertices_cfi::trackTimeResoTag, offlinePrimaryVertices_cfi::trackTimeTag, PrimaryVertexSorter< ParticlesCollection >::useMET_, PrimaryVertexSorter< ParticlesCollection >::useTiming_, and AlignmentTracksFromVertexSelector_cfi::vertices.

143  {
144  using namespace std;
145  using namespace edm;
146  using namespace reco;
147 
149  iEvent.getByToken(tokenJets_, jets);
150 
151  TransientTrackBuilder const& builder = iSetup.getData(tokenBuilder_);
152 
154  iEvent.getByToken(tokenVertices_, vertices);
155 
156  Handle<ParticlesCollection> particlesHandle;
157  iEvent.getByToken(tokenCandidates_, particlesHandle);
158 
159  Handle<edm::ValueMap<float>> trackTimeTagHandle;
160  Handle<edm::ValueMap<float>> trackTimeResoTagHandle;
161 
162  const edm::ValueMap<float>* trackTimeTag = nullptr;
163  const edm::ValueMap<float>* trackTimeResoTag = nullptr;
165  iEvent.getByToken(tokenTrackTimeTag_, trackTimeTagHandle);
166  iEvent.getByToken(tokenTrackTimeResoTag_, trackTimeResoTagHandle);
167 
168  trackTimeTag = trackTimeTagHandle.product();
169  trackTimeResoTag = trackTimeResoTagHandle.product();
170  }
171 
172  ParticlesCollection particles = *particlesHandle.product();
173  std::vector<int> pfToPVVector;
174  std::vector<PrimaryVertexAssignment::Quality> pfToPVQualityVector;
175  //reverse mapping
176  std::vector<std::vector<int>> pvToPFVector(vertices->size());
177  std::vector<std::vector<const reco::Candidate*>> pvToCandVector(vertices->size());
178  std::vector<std::vector<PrimaryVertexAssignment::Quality>> pvToPFQualityVector(vertices->size());
179  std::vector<float> vertexScoreOriginal(vertices->size());
180  std::vector<float> vertexScore(vertices->size());
181 
182  for (auto const& pf : particles) {
183  std::pair<int, PrimaryVertexAssignment::Quality> vtxWithQuality =
185  pfToPVVector.push_back(vtxWithQuality.first);
186  pfToPVQualityVector.push_back(vtxWithQuality.second);
187  }
188 
189  //Invert the mapping
190  for (size_t i = 0; i < pfToPVVector.size(); i++) {
191  auto pv = pfToPVVector[i];
192  auto qual = pfToPVQualityVector[i];
193  if (pv >= 0 and qual >= qualityCut_) {
194  pvToPFVector[pv].push_back(i);
195  // std::cout << i << std::endl;
196  // const typename ParticlesCollection::value_type & cp = particles[i];
197  // std::cout << "CP " << &cp << std::endl;
198  pvToCandVector[pv].push_back(&particles[i]);
199  pvToPFQualityVector[pv].push_back(qual);
200  }
201  }
202 
203  //Use multimap for sorting of indices
204  std::multimap<float, int> scores;
205  for (unsigned int i = 0; i < vertices->size(); i++) {
206  float s = sortingAlgo_.score((*vertices)[i], pvToCandVector[i], useMET_);
207  vertexScoreOriginal[i] = s;
208  scores.insert(std::pair<float, int>(-s, i));
209  }
210 
211  //create indices
212  std::vector<int> oldToNew(vertices->size()), newToOld(vertices->size());
213  size_t newIdx = 0;
214  for (auto const& idx : scores) {
215  // std::cout << newIdx << " score: " << idx.first << " oldidx: " << idx.second << " "<< producePFPileUp_ << std::endl;
216  vertexScore[newIdx] = -idx.first;
217  oldToNew[idx.second] = newIdx;
218  newToOld[newIdx] = idx.second;
219  newIdx++;
220  }
221 
223  unique_ptr<CandToVertex> pfCandToOriginalVertexOutput(new CandToVertex(vertices));
224  unique_ptr<CandToVertexQuality> pfCandToOriginalVertexQualityOutput(new CandToVertexQuality());
225  CandToVertex::Filler cand2VertexFiller(*pfCandToOriginalVertexOutput);
226  CandToVertexQuality::Filler cand2VertexQualityFiller(*pfCandToOriginalVertexQualityOutput);
227 
228  cand2VertexFiller.insert(particlesHandle, pfToPVVector.begin(), pfToPVVector.end());
229  cand2VertexQualityFiller.insert(particlesHandle, pfToPVQualityVector.begin(), pfToPVQualityVector.end());
230 
231  cand2VertexFiller.fill();
232  cand2VertexQualityFiller.fill();
233  iEvent.put(std::move(pfCandToOriginalVertexOutput), "original");
234  iEvent.put(std::move(pfCandToOriginalVertexQualityOutput), "original");
235 
236  unique_ptr<VertexScore> vertexScoreOriginalOutput(new VertexScore);
237  VertexScore::Filler vertexScoreOriginalFiller(*vertexScoreOriginalOutput);
238  vertexScoreOriginalFiller.insert(vertices, vertexScoreOriginal.begin(), vertexScoreOriginal.end());
239  vertexScoreOriginalFiller.fill();
240  iEvent.put(std::move(vertexScoreOriginalOutput), "original");
241  }
242 
244  std::vector<int> pfToSortedPVVector;
245  // std::vector<int> pfToSortedPVQualityVector;
246  for (size_t i = 0; i < pfToPVVector.size(); i++) {
247  pfToSortedPVVector.push_back(oldToNew[pfToPVVector[i]]);
248  // pfToSortedPVQualityVector.push_back(pfToPVQualityVector[i]); //same as old!
249  }
250 
251  unique_ptr<reco::VertexCollection> sortedVerticesOutput(new reco::VertexCollection);
252  for (size_t i = 0; i < vertices->size(); i++) {
253  sortedVerticesOutput->push_back((*vertices)[newToOld[i]]);
254  }
255  edm::OrphanHandle<reco::VertexCollection> oh = iEvent.put(std::move(sortedVerticesOutput));
256  unique_ptr<CandToVertex> pfCandToVertexOutput(new CandToVertex(oh));
257  unique_ptr<CandToVertexQuality> pfCandToVertexQualityOutput(new CandToVertexQuality());
258  CandToVertex::Filler cand2VertexFiller(*pfCandToVertexOutput);
259  CandToVertexQuality::Filler cand2VertexQualityFiller(*pfCandToVertexQualityOutput);
260 
261  cand2VertexFiller.insert(particlesHandle, pfToSortedPVVector.begin(), pfToSortedPVVector.end());
262  cand2VertexQualityFiller.insert(particlesHandle, pfToPVQualityVector.begin(), pfToPVQualityVector.end());
263 
264  cand2VertexFiller.fill();
265  cand2VertexQualityFiller.fill();
266  iEvent.put(std::move(pfCandToVertexOutput));
267  iEvent.put(std::move(pfCandToVertexQualityOutput));
268 
269  unique_ptr<VertexScore> vertexScoreOutput(new VertexScore);
270  VertexScore::Filler vertexScoreFiller(*vertexScoreOutput);
271  vertexScoreFiller.insert(oh, vertexScore.begin(), vertexScore.end());
272  vertexScoreFiller.fill();
273  iEvent.put(std::move(vertexScoreOutput));
274  }
275 
276  unique_ptr<PFCollection> pfCollectionNOPUOriginalOutput(new PFCollection);
277  unique_ptr<PFCollection> pfCollectionNOPUOutput(new PFCollection);
278  unique_ptr<PFCollection> pfCollectionPUOriginalOutput(new PFCollection);
279  unique_ptr<PFCollection> pfCollectionPUOutput(new PFCollection);
280 
281  for (size_t i = 0; i < particles.size(); i++) {
282  auto pv = pfToPVVector[i];
283  auto qual = pfToPVQualityVector[i];
284 
286  if (pv == newToOld[0] and qual >= qualityCut_)
287  pfCollectionNOPUOutput->push_back(particles[i]);
288 
290  if (pv != newToOld[0] and qual >= qualityCut_)
291  pfCollectionPUOutput->push_back(particles[i]);
292 
294  if (pv == 0 and qual >= qualityCut_)
295  pfCollectionNOPUOriginalOutput->push_back(particles[i]);
296 
298  if (pv != 0 and qual >= qualityCut_)
299  pfCollectionPUOriginalOutput->push_back(particles[i]);
300  }
302  iEvent.put(std::move(pfCollectionNOPUOutput), "NoPileUp");
304  iEvent.put(std::move(pfCollectionPUOutput), "PileUp");
306  iEvent.put(std::move(pfCollectionNOPUOriginalOutput), "originalNoPileUp");
308  iEvent.put(std::move(pfCollectionPUOriginalOutput), "originalPileUp");
309 }
edm::Association< reco::VertexCollection > CandToVertex
PrimaryVertexSorting sortingAlgo_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
float score(const reco::Vertex &pv, const std::vector< const reco::Candidate *> &candidates, bool useMet) const
T const * product() const
Definition: Handle.h:70
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< PFCollection > tokenCandidates_
Candidates to be analyzed.
int iEvent
Definition: GenABIO.cc:224
ParticlesCollection PFCollection
def pv(vc)
Definition: MetAnalyzer.py:7
bool needsProductsForTiming()
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeTag_
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:162
edm::ValueMap< float > VertexScore
edm::ValueMap< int > CandToVertexQuality
fixed size matrix
HLT enums.
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > tokenBuilder_
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeResoTag_
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::View< reco::Candidate > > tokenJets_
std::pair< int, PrimaryVertexAssignment::Quality > runAlgo(const reco::VertexCollection &vertices, const typename ParticlesCollection::value_type &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)

◆ runAlgo() [1/4]

template<class ParticlesCollection >
std::pair<int, PrimaryVertexAssignment::Quality> PrimaryVertexSorter< ParticlesCollection >::runAlgo ( const reco::VertexCollection vertices,
const typename ParticlesCollection::value_type &  pf,
const edm::ValueMap< float > *  trackTimeTag,
const edm::ValueMap< float > *  trackTimeResoTag,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
)
private

◆ runAlgo() [2/4]

template<>
std::pair< int, PrimaryVertexAssignment::Quality > PrimaryVertexSorter< std::vector< reco::RecoChargedRefCandidate > >::runAlgo ( const reco::VertexCollection vertices,
const reco::RecoChargedRefCandidate pf,
const edm::ValueMap< float > *  trackTimeTag,
const edm::ValueMap< float > *  trackTimeResoTag,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
)
inlineprivate

◆ runAlgo() [3/4]

template<>
std::pair< int, PrimaryVertexAssignment::Quality > PrimaryVertexSorter< std::vector< reco::PFCandidate > >::runAlgo ( const reco::VertexCollection vertices,
const reco::PFCandidate pf,
const edm::ValueMap< float > *  trackTimeTag,
const edm::ValueMap< float > *  trackTimeResoTag,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
)
inlineprivate

Definition at line 433 of file PrimaryVertexSorter.h.

References PrimaryVertexSorter< ParticlesCollection >::assignmentAlgo_, PrimaryVertexAssignment::chargedHadronVertex(), PDWG_EXODelayedJetMET_cff::jets, packedPFCandidateRefMixer_cfi::pf, and AlignmentTracksFromVertexSelector_cfi::vertices.

439  {
441 }
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, float trackTime, float trackTimeResolution, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
PrimaryVertexAssignment assignmentAlgo_

◆ runAlgo() [4/4]

template<>
std::pair< int, PrimaryVertexAssignment::Quality > PrimaryVertexSorter< std::vector< pat::PackedCandidate > >::runAlgo ( const reco::VertexCollection vertices,
const pat::PackedCandidate pf,
const edm::ValueMap< float > *  trackTimeTag,
const edm::ValueMap< float > *  trackTimeResoTag,
const edm::View< reco::Candidate > &  jets,
const TransientTrackBuilder builder 
)
inlineprivate

Definition at line 444 of file PrimaryVertexSorter.h.

References PrimaryVertexSorter< ParticlesCollection >::assignmentAlgo_, PrimaryVertexAssignment::chargedHadronVertex(), PDWG_EXODelayedJetMET_cff::jets, packedPFCandidateRefMixer_cfi::pf, and AlignmentTracksFromVertexSelector_cfi::vertices.

450  {
452 }
std::pair< int, PrimaryVertexAssignment::Quality > chargedHadronVertex(const reco::VertexCollection &vertices, const reco::TrackRef &trackRef, const reco::Track *track, float trackTime, float trackTimeResolution, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder) const
PrimaryVertexAssignment assignmentAlgo_

◆ sortedList()

template<class ParticlesCollection >
VertexCollection PrimaryVertexSorter< ParticlesCollection >::sortedList ( const reco::VertexCollection primaryVertex) const

Definition at line 7 of file PrimaryVertexSorter.cc.

References FSQDQM_cfi::pvs, and jetUpdater_cfi::sort.

7  {
8  VertexCollection pvs = unsortedPVColl;
9  sort(pvs.begin(), pvs.end(), VertexHigherPtSquared());
10  return pvs;
11 }
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9

Member Data Documentation

◆ assignmentAlgo_

template<class ParticlesCollection >
PrimaryVertexAssignment PrimaryVertexSorter< ParticlesCollection >::assignmentAlgo_
private

◆ produceOriginalMapping_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::produceOriginalMapping_
private

◆ producePFNoPileUp_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::producePFNoPileUp_
private

◆ producePFPileUp_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::producePFPileUp_
private

◆ produceSortedVertices_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::produceSortedVertices_
private

◆ qualityCut_

template<class ParticlesCollection >
int PrimaryVertexSorter< ParticlesCollection >::qualityCut_
private

◆ sortingAlgo_

template<class ParticlesCollection >
PrimaryVertexSorting PrimaryVertexSorter< ParticlesCollection >::sortingAlgo_
private

◆ tokenBuilder_

template<class ParticlesCollection >
edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> PrimaryVertexSorter< ParticlesCollection >::tokenBuilder_
private

◆ tokenCandidates_

template<class ParticlesCollection >
edm::EDGetTokenT<PFCollection> PrimaryVertexSorter< ParticlesCollection >::tokenCandidates_
private

Candidates to be analyzed.

Definition at line 56 of file PrimaryVertexSorter.h.

Referenced by PrimaryVertexSorter< ParticlesCollection >::produce().

◆ tokenJets_

template<class ParticlesCollection >
edm::EDGetTokenT<edm::View<reco::Candidate> > PrimaryVertexSorter< ParticlesCollection >::tokenJets_
private

◆ tokenTrackTimeResoTag_

template<class ParticlesCollection >
edm::EDGetTokenT<edm::ValueMap<float> > PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeResoTag_
private

◆ tokenTrackTimeTag_

template<class ParticlesCollection >
edm::EDGetTokenT<edm::ValueMap<float> > PrimaryVertexSorter< ParticlesCollection >::tokenTrackTimeTag_
private

◆ tokenVertices_

template<class ParticlesCollection >
edm::EDGetTokenT<reco::VertexCollection> PrimaryVertexSorter< ParticlesCollection >::tokenVertices_
private

vertices

Definition at line 59 of file PrimaryVertexSorter.h.

Referenced by PrimaryVertexSorter< ParticlesCollection >::produce().

◆ useMET_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::useMET_
private

◆ useTiming_

template<class ParticlesCollection >
bool PrimaryVertexSorter< ParticlesCollection >::useTiming_
private