CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GsfVertexMerger.cc
Go to the documentation of this file.
3 // #include "TrackingTools/GsfTools/interface/MahalanobisDistance.h"
5 // #include "CommonReco/GSFTools/interface/KeepingNonZeroWeightsMerger.h"
6 // #include "TrackingTools/GsfTools/interface/LargestWeightsStateMerger.h"
7 // #include "TrackingTools/GsfTools/interface/RCMultiGaussianState.h"
10 
12 
14  maxComponents = pSet.getParameter<int>("maxNbrComponents");
15  std::string mergerName = pSet.getParameter<std::string>("merger");
16  std::string distanceName = pSet.getParameter<std::string>("distance");
17 
18  if (mergerName == "CloseComponentsMerger") {
20 
21  if (distanceName == "KullbackLeiblerDistance")
22  distance = new KullbackLeiblerDistance<3>();
23  // else if ( distanceName=="MahalanobisDistance" )
24  // distance = new MahalanobisDistance();
25  else
26  throw VertexException("GsfVertexMerger: Distance type " + distanceName +
27  " unknown. Check distance parameter in GsfMergerParameters PSet");
28 
30  delete distance;
31  }
32  // else if ( mergerName=="LargestWeightsStateMerger" )
33  // merger = new LargestWeightsStateMerger(maxComponents);
34  else
35  throw VertexException("GsfVertexMerger: Merger type " + mergerName +
36  " unknown. Check merger parameter in GsfMergerParameters PSet");
37 
38  // else if ( mergerName=="KeepingNonZeroWeightsMerger" )
39  // merger = new KeepingNonZeroWeightsMerger();
40 
41  // std::string mergerName = "test";
42  // edm::ESHandle<MultiGaussianStateMerger> mergerProducer;
43  // iRecord.get(mergerName,mergerProducer);
44  // merger = (MultiGaussianStateMerger *) mergerProducer.product();
45 }
46 
48  if (oldVertex.vertexState().components().size() <= maxComponents)
49  return oldVertex;
50 
51  VertexState newVertexState = merge(oldVertex.vertexState());
52 
53  if (oldVertex.hasPrior()) {
54  return CachingVertex<5>(oldVertex.priorPosition(),
55  oldVertex.priorError(),
56  newVertexState.weightTimesPosition(),
57  newVertexState.weight(),
58  oldVertex.tracks(),
59  oldVertex.totalChiSquared());
60  } else {
61  return CachingVertex<5>(newVertexState, oldVertex.tracks(), oldVertex.totalChiSquared());
62  }
63 }
64 
66  using namespace GaussianStateConversions;
67 
68  if (oldVertex.components().size() <= maxComponents)
69  return oldVertex;
70 
71  MultiGaussianState<3> multiGaussianState(multiGaussianStateFromVertex(oldVertex));
72  MultiGaussianState<3> finalState(merger->merge(multiGaussianState));
73  return vertexFromMultiGaussianState(finalState);
74 }
MultiGaussianState< 3 > multiGaussianStateFromVertex(const VertexState aState)
std::vector< RefCountedVertexTrack > tracks() const
virtual MultiState merge(const MultiState &mgs) const =0
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
Common base class.
VertexState const & vertexState() const
GlobalError priorError() const
VertexState vertexFromMultiGaussianState(const MultiGaussianState< 3 > &multiState)
Mixture of multi-variate gaussian states.
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:77
float totalChiSquared() const
std::vector< VertexState > components() const
Definition: VertexState.h:90
bool hasPrior() const
DeepCopyPointerByClone< MultiGaussianStateMerger< 3 > > merger
GlobalWeight weight() const
Definition: VertexState.h:69
unsigned int maxComponents
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GsfVertexMerger(const edm::ParameterSet &pSet)
GlobalPoint priorPosition() const