CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoVertex/GaussianSumVertexFit/src/GsfVertexMerger.cc

Go to the documentation of this file.
00001 #include "RecoVertex/GaussianSumVertexFit/interface/GsfVertexMerger.h"
00002 #include "TrackingTools/GsfTools/interface/KullbackLeiblerDistance.h"
00003 // #include "TrackingTools/GsfTools/interface/MahalanobisDistance.h"
00004 #include "TrackingTools/GsfTools/interface/CloseComponentsMerger.h"
00005 // #include "CommonReco/GSFTools/interface/KeepingNonZeroWeightsMerger.h"
00006 // #include "TrackingTools/GsfTools/interface/LargestWeightsStateMerger.h"
00007 // #include "TrackingTools/GsfTools/interface/RCMultiGaussianState.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00010 
00011 #include "RecoVertex/GaussianSumVertexFit/interface/VertexGaussianStateConversions.h"
00012 
00013 GsfVertexMerger::GsfVertexMerger(const edm::ParameterSet& pSet)
00014 {
00015 
00016   maxComponents = pSet.getParameter<int>("maxNbrComponents");
00017   std::string mergerName = pSet.getParameter<std::string>("merger");
00018   std::string distanceName = pSet.getParameter<std::string>("distance");
00019 
00020   if ( mergerName=="CloseComponentsMerger" ) {
00021     DistanceBetweenComponents<3>* distance;
00022 
00023     if ( distanceName=="KullbackLeiblerDistance" )
00024       distance = new KullbackLeiblerDistance<3>();
00025 //     else if ( distanceName=="MahalanobisDistance" )
00026 //       distance = new MahalanobisDistance();
00027     else 
00028       throw VertexException("GsfVertexMerger: Distance type "+distanceName+" unknown. Check distance parameter in GsfMergerParameters PSet");
00029     
00030     merger = new CloseComponentsMerger<3>(maxComponents, distance);
00031     delete distance;
00032   } 
00033 //   else if ( mergerName=="LargestWeightsStateMerger" )
00034 //     merger = new LargestWeightsStateMerger(maxComponents);
00035   else 
00036     throw VertexException("GsfVertexMerger: Merger type "+mergerName+" unknown. Check merger parameter in GsfMergerParameters PSet");
00037 
00038 //   else if ( mergerName=="KeepingNonZeroWeightsMerger" )
00039 //     merger = new KeepingNonZeroWeightsMerger();
00040 
00041 //   std::string mergerName = "test";
00042 //   edm::ESHandle<MultiGaussianStateMerger> mergerProducer;
00043 //   iRecord.get(mergerName,mergerProducer);
00044 //   merger = (MultiGaussianStateMerger *) mergerProducer.product();
00045 
00046 }
00047 
00048 CachingVertex<5> GsfVertexMerger::merge(const CachingVertex<5> & oldVertex) const
00049 {
00050   if (oldVertex.vertexState().components().size() <= maxComponents) 
00051         return oldVertex;
00052 
00053   VertexState newVertexState = merge(oldVertex.vertexState());
00054 
00055   if  (oldVertex.hasPrior()) {
00056     return CachingVertex<5>(oldVertex.priorPosition(), oldVertex.priorError(),
00057                 newVertexState.weightTimesPosition(), newVertexState.weight(),
00058                 oldVertex.tracks(), oldVertex.totalChiSquared());
00059   } else {
00060     return CachingVertex<5>(newVertexState, oldVertex.tracks(), 
00061                 oldVertex.totalChiSquared());
00062   }
00063 }
00064 
00065 
00066 VertexState GsfVertexMerger::merge(const VertexState & oldVertex) const
00067 {
00068   using namespace GaussianStateConversions;
00069 
00070   if (oldVertex.components().size() <= maxComponents) 
00071         return oldVertex;
00072 
00073   MultiGaussianState<3> multiGaussianState(multiGaussianStateFromVertex(oldVertex));
00074   MultiGaussianState<3> finalState(merger->merge(multiGaussianState));
00075   return vertexFromMultiGaussianState(finalState);
00076 }