CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | 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 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 58 of file PrimaryVertexProducerAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file PrimaryVertexProducerAlgorithm.cc.

References electronCleaner_cfi::algorithm, algorithms, beamSpotLabel, edm::ParameterSet::exists(), PrimaryVertexProducerAlgorithm::algo::fitter, fVerbose, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), PrimaryVertexProducerAlgorithm::algo::label, PrimaryVertexProducerAlgorithm::algo::minNdof, AlCaHLTBitMon_QueryRunRegistry::string, theTrackClusterizer, theTrackFilter, trackLabel, PrimaryVertexProducerAlgorithm::algo::useBeamConstraint, HIPixelAdaptiveVertex_cfi::vertexCollections, and PrimaryVertexProducerAlgorithm::algo::vertexSelector.

Referenced by clone().

21  :theConfig(conf)
22 {
23 
24  fVerbose = conf.getUntrackedParameter<bool>("verbose", false);
25  trackLabel = conf.getParameter<edm::InputTag>("TrackLabel");
26  beamSpotLabel = conf.getParameter<edm::InputTag>("beamSpotLabel");
27 
28 
29  // select and configure the track selection
30  std::string trackSelectionAlgorithm=conf.getParameter<edm::ParameterSet>("TkFilterParameters").getParameter<std::string>("algorithm");
31  if(trackSelectionAlgorithm=="filter"){
32  theTrackFilter= new TrackFilterForPVFinding( conf.getParameter<edm::ParameterSet>("TkFilterParameters") );
33  }else if (trackSelectionAlgorithm=="filterWithThreshold"){
35  }else{
36  throw VertexException("PrimaryVertexProducerAlgorithm: unknown track selection algorithm: " + trackSelectionAlgorithm);
37  }
38 
39 
40  // select and configure the track clusterizer
41  std::string clusteringAlgorithm=conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
42  if (clusteringAlgorithm=="gap"){
43  theTrackClusterizer = new GapClusterizerInZ(conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkGapClusParameters"));
44  }else if(clusteringAlgorithm=="DA"){
45  theTrackClusterizer = new DAClusterizerInZ(conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
46  }
47  // provide the vectorized version of the clusterizer, if supported by the build
48  else if(clusteringAlgorithm == "DA_vect") {
49  theTrackClusterizer = new DAClusterizerInZ_vect(conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
50  }
51 
52 
53  else{
54  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
55  }
56 
57 
58  // select and configure the vertex fitters
59  if (conf.exists("vertexCollections")){
60  std::vector<edm::ParameterSet> vertexCollections =conf.getParameter< std::vector<edm::ParameterSet> >("vertexCollections");
61 
62  for( std::vector< edm::ParameterSet >::const_iterator algoconf = vertexCollections.begin(); algoconf != vertexCollections.end(); algoconf++){
63 
65  std::string fitterAlgorithm = algoconf->getParameter<std::string>("algorithm");
66  if (fitterAlgorithm=="KalmanVertexFitter") {
67  algorithm.fitter= new KalmanVertexFitter();
68  } else if( fitterAlgorithm=="AdaptiveVertexFitter") {
69  algorithm.fitter= new AdaptiveVertexFitter();
70  } else {
71  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
72  }
73  algorithm.label = algoconf->getParameter<std::string>("label");
74  algorithm.minNdof = algoconf->getParameter<double>("minNdof");
75  algorithm.useBeamConstraint=algoconf->getParameter<bool>("useBeamConstraint");
76  algorithm.vertexSelector=new VertexCompatibleWithBeam(VertexDistanceXY(), algoconf->getParameter<double>("maxDistanceToBeam"));
77  algorithms.push_back(algorithm);
78 
79  }
80  }else{
81  edm::LogWarning("MisConfiguration")<<"this module's configuration has changed, please update to have a vertexCollections=cms.VPSet parameter.";
82 
84  std::string fitterAlgorithm = conf.getParameter<std::string>("algorithm");
85  if (fitterAlgorithm=="KalmanVertexFitter") {
86  algorithm.fitter= new KalmanVertexFitter();
87  } else if( fitterAlgorithm=="AdaptiveVertexFitter") {
88  algorithm.fitter= new AdaptiveVertexFitter();
89  } else {
90  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
91  }
92  algorithm.label = "";
93  algorithm.minNdof = conf.getParameter<double>("minNdof");
94  algorithm.useBeamConstraint=conf.getParameter<bool>("useBeamConstraint");
95 
96  algorithm.vertexSelector=new VertexCompatibleWithBeam(VertexDistanceXY(), conf.getParameter<edm::ParameterSet>("PVSelParameters").getParameter<double>("maxDistanceToBeam"));
97 
98  algorithms.push_back(algorithm);
99  }
100 
101 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
vertexCollections
1 cm max separation between clusters
Common base class.
bool exists(std::string const &parameterName) const
checks if a parameter exists
TrackFilterForPVFindingBase * theTrackFilter
PrimaryVertexProducerAlgorithm::~PrimaryVertexProducerAlgorithm ( )
override

Definition at line 104 of file PrimaryVertexProducerAlgorithm.cc.

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

105 {
106  if (theTrackFilter) delete theTrackFilter;
108  for( std::vector <algo>::const_iterator algorithm=algorithms.begin(); algorithm!=algorithms.end(); algorithm++){
109  if (algorithm->fitter) delete algorithm->fitter;
110  if (algorithm->vertexSelector) delete algorithm->vertexSelector;
111  }
112 }
TrackFilterForPVFindingBase * theTrackFilter

Member Function Documentation

PrimaryVertexProducerAlgorithm* PrimaryVertexProducerAlgorithm::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexReconstructor.

Definition at line 75 of file PrimaryVertexProducerAlgorithm.h.

References PrimaryVertexProducerAlgorithm().

75  {
76  return new PrimaryVertexProducerAlgorithm(*this);
77  }
PrimaryVertexProducerAlgorithm(const edm::ParameterSet &)
edm::ParameterSet PrimaryVertexProducerAlgorithm::config ( void  ) const
inline

Definition at line 81 of file PrimaryVertexProducerAlgorithm.h.

References theConfig.

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

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 124 of file PrimaryVertexProducerAlgorithm.cc.

125 {
126 
127  throw VertexException("PrimaryVertexProducerAlgorithm: cannot make a Primary Vertex without a beam spot" );
128 
129  return std::vector<TransientVertex>();
130 }
Common base class.
std::vector< TransientVertex > PrimaryVertexProducerAlgorithm::vertices ( const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot beamSpot,
const std::string &  label = "" 
) const
virtual

Definition at line 134 of file PrimaryVertexProducerAlgorithm.cc.

References electronCleaner_cfi::algorithm, algorithms, TrackClusterizerInZ::clusterize(), fastPrimaryVertexProducer_cfi::clusters, gather_cfg::cout, GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czz(), TransientVertex::degreesOfFreedom(), VertexState::error(), fVerbose, TransientVertex::isValid(), GlobalErrorBase< T, ErrorWeightType >::matrix(), TransientVertex::position(), TrackFilterForPVFindingBase::select(), theTrackClusterizer, theTrackFilter, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

138 {
139 
140 
141 
142 
143 
144  bool validBS = true;
145  VertexState beamVertexState(beamSpot);
146  if ( (beamVertexState.error().cxx() <= 0.) ||
147  (beamVertexState.error().cyy() <= 0.) ||
148  (beamVertexState.error().czz() <= 0.) ) {
149  validBS = false;
150  edm::LogError("UnusableBeamSpot") << "Beamspot with invalid errors "<<beamVertexState.error().matrix();
151  }
152 
153 
154 // // get RECO tracks from the event
155 // // `tks` can be used as a ptr to a reco::TrackCollection
156 // edm::Handle<reco::TrackCollection> tks;
157 // iEvent.getByLabel(trackLabel, tks);
158 
159 
160  // select tracks
161  std::vector<reco::TransientTrack> seltks = theTrackFilter->select( t_tks );
162 
163 
164  // clusterize tracks in Z
165  std::vector< std::vector<reco::TransientTrack> > clusters = theTrackClusterizer->clusterize(seltks);
166  if (fVerbose){std::cout << " clustering returned "<< clusters.size() << " clusters from " << seltks.size() << " selected tracks" <<std::endl;}
167 
168 
169  // vertex fits
170  for( std::vector <algo>::const_iterator algorithm=algorithms.begin(); algorithm!=algorithms.end(); algorithm++){
171  if ( ! (algorithm->label == label) )continue;
172 
173  //std::auto_ptr<reco::VertexCollection> result(new reco::VertexCollection);
174  // reco::VertexCollection vColl;
175 
176 
177  std::vector<TransientVertex> pvs;
178  for (std::vector< std::vector<reco::TransientTrack> >::const_iterator iclus
179  = clusters.begin(); iclus != clusters.end(); iclus++) {
180 
181 
183  if( algorithm->useBeamConstraint && validBS &&((*iclus).size()>1) ){
184 
185  v = algorithm->fitter->vertex(*iclus, beamSpot);
186 
187  }else if( !(algorithm->useBeamConstraint) && ((*iclus).size()>1) ) {
188 
189  v = algorithm->fitter->vertex(*iclus);
190 
191  }// else: no fit ==> v.isValid()=False
192 
193 
194  if (fVerbose){
195  if (v.isValid()) std::cout << "x,y,z=" << v.position().x() <<" " << v.position().y() << " " << v.position().z() << std::endl;
196  else std::cout <<"Invalid fitted vertex\n";
197  }
198 
199  if (v.isValid()
200  && (v.degreesOfFreedom()>=algorithm->minNdof)
201  && (!validBS || (*(algorithm->vertexSelector))(v,beamVertexState))
202  ) pvs.push_back(v);
203  }// end of cluster loop
204 
205  if(fVerbose){
206  std::cout << "PrimaryVertexProducerAlgorithm::vertices candidates =" << pvs.size() << std::endl;
207  }
208 
209 
210 
211 
212 
213  // sort vertices by pt**2 vertex (aka signal vertex tagging)
214  if(pvs.size()>1){
215  sort(pvs.begin(), pvs.end(), VertexHigherPtSquared());
216  }
217 
218  return pvs;
219  }
220 
221  std::vector<TransientVertex> dummy;
222  return dummy;//avoid compiler warning, should never be here
223 }
T y() const
Definition: PV3DBase.h:63
float degreesOfFreedom() const
GlobalPoint position() const
T z() const
Definition: PV3DBase.h:64
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
TrackFilterForPVFindingBase * theTrackFilter
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
T x() const
Definition: PV3DBase.h:62
bool isValid() const

Member Data Documentation

std::vector< algo > PrimaryVertexProducerAlgorithm::algorithms
private
edm::InputTag PrimaryVertexProducerAlgorithm::beamSpotLabel

Definition at line 83 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().

bool PrimaryVertexProducerAlgorithm::fVerbose
private

Definition at line 102 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm(), and vertices().

edm::ParameterSet PrimaryVertexProducerAlgorithm::theConfig
private

Definition at line 101 of file PrimaryVertexProducerAlgorithm.h.

Referenced by config().

TrackClusterizerInZ* PrimaryVertexProducerAlgorithm::theTrackClusterizer
private
TrackFilterForPVFindingBase* PrimaryVertexProducerAlgorithm::theTrackFilter
private
edm::InputTag PrimaryVertexProducerAlgorithm::trackLabel

Definition at line 82 of file PrimaryVertexProducerAlgorithm.h.

Referenced by PrimaryVertexProducerAlgorithm().