CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
PrimaryVertexProducerAlgorithm Class Reference

#include <RecoVertex/PrimaryVertexProducerAlgorithm/src/PrimaryVertexProducerAlgorithm.cc>

Inheritance diagram for PrimaryVertexProducerAlgorithm:
VertexReconstructor

Classes

struct  algo
 

Public Member Functions

PrimaryVertexProducerAlgorithmclone () const override
 
edm::ParameterSet config () const
 
 PrimaryVertexProducerAlgorithm (const edm::ParameterSet &)
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &tracks) const override
 
virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &beamSpot, const std::string &label="") const
 
 ~PrimaryVertexProducerAlgorithm () override
 
- Public Member Functions inherited from VertexReconstructor
 VertexReconstructor ()
 
virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &t, const reco::BeamSpot &) const
 
virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &spot) const
 
virtual ~VertexReconstructor ()
 

Public Attributes

edm::InputTag beamSpotLabel
 
edm::InputTag trackLabel
 

Private Member Functions

virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &) const=0
 
virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &spot) const
 
virtual std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &t, const reco::BeamSpot &) const
 

Private Attributes

std::vector< algoalgorithms
 
bool fVerbose
 
edm::ParameterSet theConfig
 
TrackClusterizerInZtheTrackClusterizer
 
TrackFilterForPVFindingBasetheTrackFilter
 

Detailed Description

Description: allow redoing the primary vertex reconstruction from a list of tracks, considered obsolete

Implementation: <Notes on="" implementation>="">

Definition at line 53 of file PrimaryVertexProducerAlgorithm.h.

Constructor & Destructor Documentation

◆ PrimaryVertexProducerAlgorithm()

PrimaryVertexProducerAlgorithm::PrimaryVertexProducerAlgorithm ( const edm::ParameterSet conf)
explicit

Definition at line 19 of file PrimaryVertexProducerAlgorithm.cc.

References qcdUeDQM_cfi::algorithm, algorithms, beamSpotLabel, fVerbose, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theTrackClusterizer, theTrackFilter, trackLabel, and HLT_2023v12_cff::vertexCollections.

Referenced by clone().

19  : theConfig(conf) {
20  fVerbose = conf.getUntrackedParameter<bool>("verbose", false);
21  trackLabel = conf.getParameter<edm::InputTag>("TrackLabel");
22  beamSpotLabel = conf.getParameter<edm::InputTag>("beamSpotLabel");
23 
24  // select and configure the track selection
25  std::string trackSelectionAlgorithm =
26  conf.getParameter<edm::ParameterSet>("TkFilterParameters").getParameter<std::string>("algorithm");
27  if (trackSelectionAlgorithm == "filter") {
28  theTrackFilter = new TrackFilterForPVFinding(conf.getParameter<edm::ParameterSet>("TkFilterParameters"));
29  } else if (trackSelectionAlgorithm == "filterWithThreshold") {
31  } else {
32  throw VertexException("PrimaryVertexProducerAlgorithm: unknown track selection algorithm: " +
33  trackSelectionAlgorithm);
34  }
35 
36  // select and configure the track clusterizer
37  std::string clusteringAlgorithm =
38  conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
39  if (clusteringAlgorithm == "gap") {
41  conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkGapClusParameters"));
42  }
43  // provide the vectorized version of the clusterizer, if supported by the build
44  else if (clusteringAlgorithm == "DA_vect") {
46  conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
47  }
48 
49  else {
50  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
51  }
52 
53  // select and configure the vertex fitters
54  std::vector<edm::ParameterSet> vertexCollections =
55  conf.getParameter<std::vector<edm::ParameterSet> >("vertexCollections");
56 
57  for (std::vector<edm::ParameterSet>::const_iterator algoconf = vertexCollections.begin();
58  algoconf != vertexCollections.end();
59  algoconf++) {
61  std::string fitterAlgorithm = algoconf->getParameter<std::string>("algorithm");
62  if (fitterAlgorithm == "KalmanVertexFitter") {
63  algorithm.fitter = new KalmanVertexFitter();
64  } else if (fitterAlgorithm == "AdaptiveVertexFitter") {
65  algorithm.fitter = new AdaptiveVertexFitter();
66  } else {
67  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
68  }
69  algorithm.label = algoconf->getParameter<std::string>("label");
70  algorithm.minNdof = algoconf->getParameter<double>("minNdof");
71  algorithm.useBeamConstraint = algoconf->getParameter<bool>("useBeamConstraint");
72  algorithm.vertexSelector =
73  new VertexCompatibleWithBeam(VertexDistanceXY(), algoconf->getParameter<double>("maxDistanceToBeam"));
74  algorithms.push_back(algorithm);
75  }
76 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Common base class.
T getUntrackedParameter(std::string const &, T const &) const
TrackFilterForPVFindingBase * theTrackFilter

◆ ~PrimaryVertexProducerAlgorithm()

PrimaryVertexProducerAlgorithm::~PrimaryVertexProducerAlgorithm ( )
override

Definition at line 78 of file PrimaryVertexProducerAlgorithm.cc.

References qcdUeDQM_cfi::algorithm, algorithms, theTrackClusterizer, and theTrackFilter.

78  {
79  if (theTrackFilter)
80  delete theTrackFilter;
82  delete theTrackClusterizer;
83  for (std::vector<algo>::const_iterator algorithm = algorithms.begin(); algorithm != algorithms.end(); algorithm++) {
84  if (algorithm->fitter)
85  delete algorithm->fitter;
86  if (algorithm->vertexSelector)
87  delete algorithm->vertexSelector;
88  }
89 }
TrackFilterForPVFindingBase * theTrackFilter

Member Function Documentation

◆ clone()

PrimaryVertexProducerAlgorithm* PrimaryVertexProducerAlgorithm::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexReconstructor.

Definition at line 66 of file PrimaryVertexProducerAlgorithm.h.

References PrimaryVertexProducerAlgorithm().

66 { return new PrimaryVertexProducerAlgorithm(*this); }
PrimaryVertexProducerAlgorithm(const edm::ParameterSet &)

◆ config()

edm::ParameterSet PrimaryVertexProducerAlgorithm::config ( void  ) const
inline

Definition at line 69 of file PrimaryVertexProducerAlgorithm.h.

References theConfig.

69 { return theConfig; }

◆ vertices() [1/5]

std::vector< TransientVertex > PrimaryVertexProducerAlgorithm::vertices ( const std::vector< reco::TransientTrack > &  ) const
overridevirtual

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 96 of file PrimaryVertexProducerAlgorithm.cc.

97  {
98  throw VertexException("PrimaryVertexProducerAlgorithm: cannot make a Primary Vertex without a beam spot");
99 
100  return std::vector<TransientVertex>();
101 }
Common base class.

◆ vertices() [2/5]

std::vector< TransientVertex > PrimaryVertexProducerAlgorithm::vertices ( const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot beamSpot,
const std::string &  label = "" 
) const
virtual

Definition at line 103 of file PrimaryVertexProducerAlgorithm.cc.

References qcdUeDQM_cfi::algorithm, algorithms, pwdgSkimBPark_cfi::beamSpot, TrackClusterizerInZ::clusterize(), bsc_activity_cfg::clusters, gather_cfg::cout, GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czz(), VertexState::error(), fVerbose, label, GlobalErrorBase< T, ErrorWeightType >::matrix(), FSQDQM_cfi::pvs, TrackFilterForPVFindingBase::select(), jetUpdater_cfi::sort, theTrackClusterizer, theTrackFilter, findQualityFiles::v, and trackerHitRTTI::vector.

105  {
106  bool validBS = true;
107  VertexState beamVertexState(beamSpot);
108  if ((beamVertexState.error().cxx() <= 0.) || (beamVertexState.error().cyy() <= 0.) ||
109  (beamVertexState.error().czz() <= 0.)) {
110  validBS = false;
111  edm::LogError("UnusableBeamSpot") << "Beamspot with invalid errors " << beamVertexState.error().matrix();
112  }
113 
114  // // get RECO tracks from the event
115  // // `tks` can be used as a ptr to a reco::TrackCollection
116  // edm::Handle<reco::TrackCollection> tks;
117  // iEvent.getByLabel(trackLabel, tks);
118 
119  // select tracks
120  std::vector<reco::TransientTrack> seltks = theTrackFilter->select(t_tks);
121 
122  // clusterize tracks in Z
123  std::vector<std::vector<reco::TransientTrack> > clusters = theTrackClusterizer->clusterize(seltks);
124  if (fVerbose) {
125  std::cout << " clustering returned " << clusters.size() << " clusters from " << seltks.size()
126  << " selected tracks" << std::endl;
127  }
128 
129  // vertex fits
130  for (std::vector<algo>::const_iterator algorithm = algorithms.begin(); algorithm != algorithms.end(); algorithm++) {
131  if (!(algorithm->label == label))
132  continue;
133 
134  //std::auto_ptr<reco::VertexCollection> result(new reco::VertexCollection);
135  // reco::VertexCollection vColl;
136 
137  std::vector<TransientVertex> pvs;
138  for (std::vector<std::vector<reco::TransientTrack> >::const_iterator iclus = clusters.begin();
139  iclus != clusters.end();
140  iclus++) {
142  if (algorithm->useBeamConstraint && validBS && ((*iclus).size() > 1)) {
143  v = algorithm->fitter->vertex(*iclus, beamSpot);
144 
145  } else if (!(algorithm->useBeamConstraint) && ((*iclus).size() > 1)) {
146  v = algorithm->fitter->vertex(*iclus);
147 
148  } // else: no fit ==> v.isValid()=False
149 
150  if (fVerbose) {
151  if (v.isValid())
152  std::cout << "x,y,z=" << v.position().x() << " " << v.position().y() << " " << v.position().z() << std::endl;
153  else
154  std::cout << "Invalid fitted vertex\n";
155  }
156 
157  if (v.isValid() && (v.degreesOfFreedom() >= algorithm->minNdof) &&
158  (!validBS || (*(algorithm->vertexSelector))(v, beamVertexState)))
159  pvs.push_back(v);
160  } // end of cluster loop
161 
162  if (fVerbose) {
163  std::cout << "PrimaryVertexProducerAlgorithm::vertices candidates =" << pvs.size() << std::endl;
164  }
165 
166  // sort vertices by pt**2 vertex (aka signal vertex tagging)
167  if (pvs.size() > 1) {
168  sort(pvs.begin(), pvs.end(), VertexHigherPtSquared());
169  }
170 
171  return pvs;
172  }
173 
174  std::vector<TransientVertex> dummy;
175  return dummy; //avoid compiler warning, should never be here
176 }
Log< level::Error, false > LogError
char const * label
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
TrackFilterForPVFindingBase * theTrackFilter

◆ vertices() [3/5]

virtual std::vector<TransientVertex> VertexReconstructor::vertices
inlineprivate

Reconstruct vertices, but exploit the fact that you know that some tracks cannot come from a secondary vertex. primaries Tracks that cannot come from a secondary vertex (but can, in principle, be non-primaries, also). tracks These are the tracks that are of unknown origin. These tracks are subjected to pattern recognition. spot A beamspot constraint is mandatory in this method.

Definition at line 39 of file VertexReconstructor.h.

41  {
42  return vertices(tracks, spot);
43  }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const override

◆ vertices() [4/5]

virtual std::vector<TransientVertex> VertexReconstructor::vertices
inlineprivate

Reconstruct vertices, exploiting the beamspot constraint for the primary vertex

Definition at line 25 of file VertexReconstructor.h.

26  {
27  return vertices(t);
28  }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const override

◆ vertices() [5/5]

virtual std::vector<TransientVertex> VertexReconstructor::vertices
private

Reconstruct vertices

Member Data Documentation

◆ algorithms

std::vector<algo> PrimaryVertexProducerAlgorithm::algorithms
private

◆ beamSpotLabel

edm::InputTag PrimaryVertexProducerAlgorithm::beamSpotLabel

Definition at line 71 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().

◆ fVerbose

bool PrimaryVertexProducerAlgorithm::fVerbose
private

Definition at line 91 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm(), and vertices().

◆ theConfig

edm::ParameterSet PrimaryVertexProducerAlgorithm::theConfig
private

Definition at line 90 of file PrimaryVertexProducerAlgorithm.h.

Referenced by config().

◆ theTrackClusterizer

TrackClusterizerInZ* PrimaryVertexProducerAlgorithm::theTrackClusterizer
private

◆ theTrackFilter

TrackFilterForPVFindingBase* PrimaryVertexProducerAlgorithm::theTrackFilter
private

◆ trackLabel

edm::InputTag PrimaryVertexProducerAlgorithm::trackLabel

Definition at line 70 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().