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 55 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_2022v15_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  } else if (clusteringAlgorithm == "DA") {
44  conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
45  }
46  // provide the vectorized version of the clusterizer, if supported by the build
47  else if (clusteringAlgorithm == "DA_vect") {
49  conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
50  }
51 
52  else {
53  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
54  }
55 
56  // select and configure the vertex fitters
57  std::vector<edm::ParameterSet> vertexCollections =
58  conf.getParameter<std::vector<edm::ParameterSet> >("vertexCollections");
59 
60  for (std::vector<edm::ParameterSet>::const_iterator algoconf = vertexCollections.begin();
61  algoconf != vertexCollections.end();
62  algoconf++) {
64  std::string fitterAlgorithm = algoconf->getParameter<std::string>("algorithm");
65  if (fitterAlgorithm == "KalmanVertexFitter") {
66  algorithm.fitter = new KalmanVertexFitter();
67  } else if (fitterAlgorithm == "AdaptiveVertexFitter") {
68  algorithm.fitter = new AdaptiveVertexFitter();
69  } else {
70  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
71  }
72  algorithm.label = algoconf->getParameter<std::string>("label");
73  algorithm.minNdof = algoconf->getParameter<double>("minNdof");
74  algorithm.useBeamConstraint = algoconf->getParameter<bool>("useBeamConstraint");
75  algorithm.vertexSelector =
76  new VertexCompatibleWithBeam(VertexDistanceXY(), algoconf->getParameter<double>("maxDistanceToBeam"));
77  algorithms.push_back(algorithm);
78  }
79 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Common base class.
T getUntrackedParameter(std::string const &, T const &) const
TrackFilterForPVFindingBase * theTrackFilter

◆ ~PrimaryVertexProducerAlgorithm()

PrimaryVertexProducerAlgorithm::~PrimaryVertexProducerAlgorithm ( )
override

Definition at line 81 of file PrimaryVertexProducerAlgorithm.cc.

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

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

Member Function Documentation

◆ clone()

PrimaryVertexProducerAlgorithm* PrimaryVertexProducerAlgorithm::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexReconstructor.

Definition at line 68 of file PrimaryVertexProducerAlgorithm.h.

References PrimaryVertexProducerAlgorithm().

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

◆ config()

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

Definition at line 71 of file PrimaryVertexProducerAlgorithm.h.

References theConfig.

71 { return theConfig; }

◆ vertices() [1/5]

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

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 99 of file PrimaryVertexProducerAlgorithm.cc.

100  {
101  throw VertexException("PrimaryVertexProducerAlgorithm: cannot make a Primary Vertex without a beam spot");
102 
103  return std::vector<TransientVertex>();
104 }
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 106 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(), jetsAK4_CHS_cff::sort, theTrackClusterizer, theTrackFilter, findQualityFiles::v, and trackerHitRTTI::vector.

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

◆ 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 73 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().

◆ fVerbose

bool PrimaryVertexProducerAlgorithm::fVerbose
private

Definition at line 93 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm(), and vertices().

◆ theConfig

edm::ParameterSet PrimaryVertexProducerAlgorithm::theConfig
private

Definition at line 92 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 72 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().