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"
11 
13 
15 {
16 
17  maxComponents = pSet.getParameter<int>("maxNbrComponents");
18  std::string mergerName = pSet.getParameter<std::string>("merger");
19  std::string distanceName = pSet.getParameter<std::string>("distance");
20 
21  if ( mergerName=="CloseComponentsMerger" ) {
23 
24  if ( distanceName=="KullbackLeiblerDistance" )
25  distance = new KullbackLeiblerDistance<3>();
26 // else if ( distanceName=="MahalanobisDistance" )
27 // distance = new MahalanobisDistance();
28  else
29  throw VertexException("GsfVertexMerger: Distance type "+distanceName+" unknown. Check distance parameter in GsfMergerParameters PSet");
30 
32  delete distance;
33  }
34 // else if ( mergerName=="LargestWeightsStateMerger" )
35 // merger = new LargestWeightsStateMerger(maxComponents);
36  else
37  throw VertexException("GsfVertexMerger: Merger type "+mergerName+" unknown. Check merger parameter in GsfMergerParameters PSet");
38 
39 // else if ( mergerName=="KeepingNonZeroWeightsMerger" )
40 // merger = new KeepingNonZeroWeightsMerger();
41 
42 // std::string mergerName = "test";
43 // edm::ESHandle<MultiGaussianStateMerger> mergerProducer;
44 // iRecord.get(mergerName,mergerProducer);
45 // merger = (MultiGaussianStateMerger *) mergerProducer.product();
46 
47 }
48 
50 {
51  if (oldVertex.vertexState().components().size() <= maxComponents)
52  return oldVertex;
53 
54  VertexState newVertexState = merge(oldVertex.vertexState());
55 
56  if (oldVertex.hasPrior()) {
57  return CachingVertex<5>(oldVertex.priorPosition(), oldVertex.priorError(),
58  newVertexState.weightTimesPosition(), newVertexState.weight(),
59  oldVertex.tracks(), oldVertex.totalChiSquared());
60  } else {
61  return CachingVertex<5>(newVertexState, oldVertex.tracks(),
62  oldVertex.totalChiSquared());
63  }
64 }
65 
66 
68 {
69  using namespace GaussianStateConversions;
70 
71  if (oldVertex.components().size() <= maxComponents)
72  return oldVertex;
73 
74  MultiGaussianState<3> multiGaussianState(multiGaussianStateFromVertex(oldVertex));
75  MultiGaussianState<3> finalState(merger->merge(multiGaussianState));
76  return vertexFromMultiGaussianState(finalState);
77 }
MultiGaussianState< 3 > multiGaussianStateFromVertex(const VertexState aState)
T getParameter(std::string const &) const
std::vector< RefCountedVertexTrack > tracks() const
Definition: CachingVertex.h:92
VertexState vertexState() const
Definition: CachingVertex.h:86
DeepCopyPointerByClone< MultiGaussianStateMerger< 3 > > merger
virtual MultiState merge(const MultiState &mgs) const =0
CachingVertex< 5 > merge(const CachingVertex< 5 > &vertex) const
Common base class.
GlobalError priorError() const
Definition: CachingVertex.h:94
VertexState vertexFromMultiGaussianState(const MultiGaussianState< 3 > &multiState)
Mixture of multi-variate gaussian states.
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:44
float totalChiSquared() const
std::vector< VertexState > components() const
Definition: VertexState.h:61
bool hasPrior() const
Definition: CachingVertex.h:95
GlobalWeight weight() const
Definition: VertexState.h:39
unsigned int maxComponents
GsfVertexMerger(const edm::ParameterSet &pSet)
GlobalPoint priorPosition() const
Definition: CachingVertex.h:93