CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 {
15 
16  maxComponents = pSet.getParameter<int>("maxNbrComponents");
17  std::string mergerName = pSet.getParameter<std::string>("merger");
18  std::string distanceName = pSet.getParameter<std::string>("distance");
19 
20  if ( mergerName=="CloseComponentsMerger" ) {
22 
23  if ( distanceName=="KullbackLeiblerDistance" )
24  distance = new KullbackLeiblerDistance<3>();
25 // else if ( distanceName=="MahalanobisDistance" )
26 // distance = new MahalanobisDistance();
27  else
28  throw VertexException("GsfVertexMerger: Distance type "+distanceName+" unknown. Check distance parameter in GsfMergerParameters PSet");
29 
31  delete distance;
32  }
33 // else if ( mergerName=="LargestWeightsStateMerger" )
34 // merger = new LargestWeightsStateMerger(maxComponents);
35  else
36  throw VertexException("GsfVertexMerger: Merger type "+mergerName+" 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 }
47 
49 {
50  if (oldVertex.vertexState().components().size() <= maxComponents)
51  return oldVertex;
52 
53  VertexState newVertexState = merge(oldVertex.vertexState());
54 
55  if (oldVertex.hasPrior()) {
56  return CachingVertex<5>(oldVertex.priorPosition(), oldVertex.priorError(),
57  newVertexState.weightTimesPosition(), newVertexState.weight(),
58  oldVertex.tracks(), oldVertex.totalChiSquared());
59  } else {
60  return CachingVertex<5>(newVertexState, oldVertex.tracks(),
61  oldVertex.totalChiSquared());
62  }
63 }
64 
65 
66 VertexState GsfVertexMerger::merge(const VertexState & oldVertex) const
67 {
68  using namespace GaussianStateConversions;
69 
70  if (oldVertex.components().size() <= maxComponents)
71  return oldVertex;
72 
73  MultiGaussianState<3> multiGaussianState(multiGaussianStateFromVertex(oldVertex));
74  MultiGaussianState<3> finalState(merger->merge(multiGaussianState));
75  return vertexFromMultiGaussianState(finalState);
76 }
MultiGaussianState< 3 > multiGaussianStateFromVertex(const VertexState aState)
T getParameter(std::string const &) const
DeepCopyPointerByClone< MultiGaussianStateMerger< 3 > > merger
virtual MultiState merge(const MultiState &mgs) const =0
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
Common base class.
VertexState const & vertexState() const
Definition: CachingVertex.h:85
GlobalError priorError() const
Definition: CachingVertex.h:94
VertexState vertexFromMultiGaussianState(const MultiGaussianState< 3 > &multiState)
Mixture of multi-variate gaussian states.
std::vector< RefCountedVertexTrack > const & tracks() const
Definition: CachingVertex.h:91
float totalChiSquared() const
bool hasPrior() const
Definition: CachingVertex.h:95
unsigned int maxComponents
GsfVertexMerger(const edm::ParameterSet &pSet)
GlobalPoint priorPosition() const
Definition: CachingVertex.h:93