CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:46:05 2009 for CMSSW by  doxygen 1.5.4