CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual
PrimaryVertexProducerAlgorithm
clone () const
 
edm::ParameterSet config () const
 
 PrimaryVertexProducerAlgorithm (const edm::ParameterSet &)
 
virtual std::vector
< TransientVertex
vertices (const std::vector< reco::TransientTrack > &tracks) const
 
virtual std::vector
< TransientVertex
vertices (const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &beamSpot, const std::string &label="") const
 
 ~PrimaryVertexProducerAlgorithm ()
 
- Public Member Functions inherited from VertexReconstructor
 VertexReconstructor ()
 
virtual std::vector
< TransientVertex
vertices (const std::vector< reco::TransientTrack > &t, const reco::BeamSpot &) const
 
virtual std::vector
< TransientVertex
vertices (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 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, 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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
49  else if(clusteringAlgorithm == "DA_vect") {
50  theTrackClusterizer = new DAClusterizerInZ_vect(conf.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
51  }
52 #endif
53 
54 
55  else{
56  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
57  }
58 
59 
60  // select and configure the vertex fitters
61  if (conf.exists("vertexCollections")){
62  std::vector<edm::ParameterSet> vertexCollections =conf.getParameter< std::vector<edm::ParameterSet> >("vertexCollections");
63 
64  for( std::vector< edm::ParameterSet >::const_iterator algoconf = vertexCollections.begin(); algoconf != vertexCollections.end(); algoconf++){
65 
66  algo algorithm;
67  std::string fitterAlgorithm = algoconf->getParameter<std::string>("algorithm");
68  if (fitterAlgorithm=="KalmanVertexFitter") {
69  algorithm.fitter= new KalmanVertexFitter();
70  } else if( fitterAlgorithm=="AdaptiveVertexFitter") {
71  algorithm.fitter= new AdaptiveVertexFitter();
72  } else {
73  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
74  }
75  algorithm.label = algoconf->getParameter<std::string>("label");
76  algorithm.minNdof = algoconf->getParameter<double>("minNdof");
77  algorithm.useBeamConstraint=algoconf->getParameter<bool>("useBeamConstraint");
78  algorithm.vertexSelector=new VertexCompatibleWithBeam(VertexDistanceXY(), algoconf->getParameter<double>("maxDistanceToBeam"));
79  algorithms.push_back(algorithm);
80 
81  }
82  }else{
83  edm::LogWarning("MisConfiguration")<<"this module's configuration has changed, please update to have a vertexCollections=cms.VPSet parameter.";
84 
85  algo algorithm;
86  std::string fitterAlgorithm = conf.getParameter<std::string>("algorithm");
87  if (fitterAlgorithm=="KalmanVertexFitter") {
88  algorithm.fitter= new KalmanVertexFitter();
89  } else if( fitterAlgorithm=="AdaptiveVertexFitter") {
90  algorithm.fitter= new AdaptiveVertexFitter();
91  } else {
92  throw VertexException("PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
93  }
94  algorithm.label = "";
95  algorithm.minNdof = conf.getParameter<double>("minNdof");
96  algorithm.useBeamConstraint=conf.getParameter<bool>("useBeamConstraint");
97 
98  algorithm.vertexSelector=new VertexCompatibleWithBeam(VertexDistanceXY(), conf.getParameter<edm::ParameterSet>("PVSelParameters").getParameter<double>("maxDistanceToBeam"));
99 
100  algorithms.push_back(algorithm);
101  }
102 
103 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
Common base class.
bool exists(std::string const &parameterName) const
checks if a parameter exists
TrackFilterForPVFindingBase * theTrackFilter
PrimaryVertexProducerAlgorithm::~PrimaryVertexProducerAlgorithm ( )

Definition at line 106 of file PrimaryVertexProducerAlgorithm.cc.

References algorithm(), algorithms, theTrackClusterizer, and theTrackFilter.

107 {
108  if (theTrackFilter) delete theTrackFilter;
110  for( std::vector <algo>::const_iterator algorithm=algorithms.begin(); algorithm!=algorithms.end(); algorithm++){
111  if (algorithm->fitter) delete algorithm->fitter;
112  if (algorithm->vertexSelector) delete algorithm->vertexSelector;
113  }
114 }
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
TrackFilterForPVFindingBase * theTrackFilter

Member Function Documentation

virtual PrimaryVertexProducerAlgorithm* PrimaryVertexProducerAlgorithm::clone ( void  ) const
inlinevirtual

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.

81 { return theConfig; }
std::vector< TransientVertex > PrimaryVertexProducerAlgorithm::vertices ( const std::vector< reco::TransientTrack > &  ) const
virtual

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 126 of file PrimaryVertexProducerAlgorithm.cc.

127 {
128 
129  throw VertexException("PrimaryVertexProducerAlgorithm: cannot make a Primary Vertex without a beam spot" );
130 
131  return std::vector<TransientVertex>();
132 }
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 136 of file PrimaryVertexProducerAlgorithm.cc.

References algorithm(), algorithms, TrackClusterizerInZ::clusterize(), 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(), python.multivaluedict::sort(), theTrackClusterizer, theTrackFilter, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

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