CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PFPileUpAlgo Class Reference

#include <PFPileUpAlgo.h>

Public Types

typedef std::vector< edm::FwdPtr< reco::PFCandidate > > PFCollection
 

Public Member Functions

int chargedHadronVertex (const reco::VertexCollection &vertices, const reco::PFCandidate &pfcand) const
 
const PFCollectiongetPFCandidatesFromPU () const
 
const PFCollectiongetPFCandidatesFromVtx () const
 
 PFPileUpAlgo ()
 
 PFPileUpAlgo (bool checkClosestZVertex, bool verbose=false)
 
void process (const PFCollection &pfCandidates, const reco::VertexCollection &vertices)
 
void setCheckClosestZVertex (bool val)
 
void setVerbose (bool verbose)
 
 ~PFPileUpAlgo ()
 

Private Attributes

bool checkClosestZVertex_
 use the closest z vertex if a track is not in a vertex More...
 
PFCollection pfCandidatesFromPU_
 
PFCollection pfCandidatesFromVtx_
 
bool verbose_
 verbose ? More...
 

Detailed Description

Definition at line 12 of file PFPileUpAlgo.h.

Member Typedef Documentation

◆ PFCollection

Definition at line 14 of file PFPileUpAlgo.h.

Constructor & Destructor Documentation

◆ PFPileUpAlgo() [1/2]

PFPileUpAlgo::PFPileUpAlgo ( )
inline

Definition at line 16 of file PFPileUpAlgo.h.

16 : checkClosestZVertex_(true), verbose_(false) { ; }

◆ PFPileUpAlgo() [2/2]

PFPileUpAlgo::PFPileUpAlgo ( bool  checkClosestZVertex,
bool  verbose = false 
)
inline

Definition at line 18 of file PFPileUpAlgo.h.

◆ ~PFPileUpAlgo()

PFPileUpAlgo::~PFPileUpAlgo ( )
inline

Definition at line 23 of file PFPileUpAlgo.h.

23 { ; }

Member Function Documentation

◆ chargedHadronVertex()

int PFPileUpAlgo::chargedHadronVertex ( const reco::VertexCollection vertices,
const reco::PFCandidate pfcand 
) const

Definition at line 38 of file PFPileUpAlgo.cc.

38  {
39  auto const& track = pfcand.trackRef();
40  size_t iVertex = 0;
41  unsigned int index = 0;
42  unsigned int nFoundVertex = 0;
43  float bestweight = 0;
44  for (auto const& vtx : vertices) {
45  float w = vtx.trackWeight(track);
46  //select the vertex for which the track has the highest weight
47  if (w > bestweight) {
48  bestweight = w;
49  iVertex = index;
50  nFoundVertex++;
51  }
52  ++index;
53  }
54 
55  if (nFoundVertex > 0) {
56  if (nFoundVertex != 1)
57  edm::LogWarning("TrackOnTwoVertex") << "a track is shared by at least two verteces. Used to be an assert";
58  return iVertex;
59  }
60  // no vertex found with this track.
61 
62  // optional: as a secondary solution, associate the closest vertex in z
64  double dzmin = 10000;
65  double ztrack = pfcand.vertex().z();
66  bool foundVertex = false;
67  index = 0;
68  for (auto iv = vertices.begin(); iv != vertices.end(); ++iv, ++index) {
69  double dz = fabs(ztrack - iv->z());
70  if (dz < dzmin) {
71  dzmin = dz;
72  iVertex = index;
73  foundVertex = true;
74  }
75  }
76 
77  if (foundVertex)
78  return iVertex;
79  }
80 
81  return -1;
82 }

References checkClosestZVertex_, PVValHelper::dz, gpuVertexFinder::iv, pfDeepBoostedJetPreprocessParams_cfi::pfcand, HLT_FULL_cff::track, pwdgSkimBPark_cfi::vertices, extraflags_cff::vtx, and w.

Referenced by process().

◆ getPFCandidatesFromPU()

const PFCollection& PFPileUpAlgo::getPFCandidatesFromPU ( ) const
inline

Definition at line 32 of file PFPileUpAlgo.h.

32 { return pfCandidatesFromPU_; }

References pfCandidatesFromPU_.

◆ getPFCandidatesFromVtx()

const PFCollection& PFPileUpAlgo::getPFCandidatesFromVtx ( ) const
inline

Definition at line 34 of file PFPileUpAlgo.h.

34 { return pfCandidatesFromVtx_; }

References pfCandidatesFromVtx_.

◆ process()

void PFPileUpAlgo::process ( const PFCollection pfCandidates,
const reco::VertexCollection vertices 
)

Definition at line 6 of file PFPileUpAlgo.cc.

6  {
7  pfCandidatesFromVtx_.clear();
8  pfCandidatesFromPU_.clear();
9 
10  for (unsigned i = 0; i < pfCandidates.size(); i++) {
11  const reco::PFCandidate& cand = *(pfCandidates[i]);
12 
13  int ivertex;
14 
15  switch (cand.particleId()) {
17  ivertex = chargedHadronVertex(vertices, cand);
18  break;
19  default:
20  continue;
21  }
22 
23  // no associated vertex, or primary vertex
24  // not pile-up
25  if (ivertex == -1 || ivertex == 0) {
26  if (verbose_)
27  std::cout << "VTX " << i << " " << *(pfCandidates[i]) << std::endl;
29  } else {
30  if (verbose_)
31  std::cout << "PU " << i << " " << *(pfCandidates[i]) << std::endl;
32  // associated to a vertex
34  }
35  }
36 }

References chargedHadronVertex(), gather_cfg::cout, reco::PFCandidate::h, mps_fire::i, zmumugammaAnalyzer_cfi::pfCandidates, pfCandidatesFromPU_, pfCandidatesFromVtx_, verbose_, and pwdgSkimBPark_cfi::vertices.

◆ setCheckClosestZVertex()

void PFPileUpAlgo::setCheckClosestZVertex ( bool  val)
inline

Definition at line 30 of file PFPileUpAlgo.h.

References checkClosestZVertex_, and heppy_batch::val.

◆ setVerbose()

void PFPileUpAlgo::setVerbose ( bool  verbose)
inline

Definition at line 28 of file PFPileUpAlgo.h.

28 { verbose_ = verbose; }

References verbose, and verbose_.

Member Data Documentation

◆ checkClosestZVertex_

bool PFPileUpAlgo::checkClosestZVertex_
private

use the closest z vertex if a track is not in a vertex

Definition at line 40 of file PFPileUpAlgo.h.

Referenced by chargedHadronVertex(), and setCheckClosestZVertex().

◆ pfCandidatesFromPU_

PFCollection PFPileUpAlgo::pfCandidatesFromPU_
private

Definition at line 46 of file PFPileUpAlgo.h.

Referenced by getPFCandidatesFromPU(), and process().

◆ pfCandidatesFromVtx_

PFCollection PFPileUpAlgo::pfCandidatesFromVtx_
private

Definition at line 45 of file PFPileUpAlgo.h.

Referenced by getPFCandidatesFromVtx(), and process().

◆ verbose_

bool PFPileUpAlgo::verbose_
private

verbose ?

Definition at line 43 of file PFPileUpAlgo.h.

Referenced by process(), and setVerbose().

zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::PFCandidate::h
Definition: PFCandidate.h:46
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
w
const double w
Definition: UKUtility.cc:23
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
cand
Definition: decayParser.h:32
heppy_batch.val
val
Definition: heppy_batch.py:351
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
PVValHelper::dz
Definition: PVValidationHelpers.h:51
PFPileUpAlgo::pfCandidatesFromPU_
PFCollection pfCandidatesFromPU_
Definition: PFPileUpAlgo.h:46
pfIsolationCalculator_cfi.checkClosestZVertex
checkClosestZVertex
Definition: pfIsolationCalculator_cfi.py:20
PFPileUpAlgo::pfCandidatesFromVtx_
PFCollection pfCandidatesFromVtx_
Definition: PFPileUpAlgo.h:45
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
PFPileUpAlgo::chargedHadronVertex
int chargedHadronVertex(const reco::VertexCollection &vertices, const reco::PFCandidate &pfcand) const
Definition: PFPileUpAlgo.cc:38
PFPileUpAlgo::verbose_
bool verbose_
verbose ?
Definition: PFPileUpAlgo.h:43
PFPileUpAlgo::checkClosestZVertex_
bool checkClosestZVertex_
use the closest z vertex if a track is not in a vertex
Definition: PFPileUpAlgo.h:40
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7