Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:35

0001 #ifndef CloseComponentsMerger_H
0002 #define CloseComponentsMerger_H
0003 
0004 #include "TrackingTools/GsfTools/interface/MultiGaussianStateMerger.h"
0005 #include "TrackingTools/GsfTools/interface/DistanceBetweenComponents.h"
0006 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointerByClone.h"
0007 
0008 #include <map>
0009 #include <algorithm>
0010 
0011 /** Merging of a Gaussian mixture by clustering components
0012  *  which are close to one another. The actual calculation
0013  *  of the distance between components is done by a specific
0014  *  (polymorphic) class, given at construction time.
0015  */
0016 
0017 template <unsigned int N>
0018 class CloseComponentsMerger final : public MultiGaussianStateMerger<N> {
0019 private:
0020   using SingleState = SingleGaussianState<N>;
0021   using MultiState = MultiGaussianState<N>;
0022   using SingleStatePtr = std::shared_ptr<SingleState>;
0023 
0024 public:
0025   CloseComponentsMerger(int n, const DistanceBetweenComponents<N>* distance);
0026 
0027   CloseComponentsMerger* clone() const override { return new CloseComponentsMerger(*this); }
0028 
0029   /** Method which does the actual merging. Returns a trimmed MultiGaussianState.
0030    */
0031 
0032   MultiState merge(const MultiState& mgs) const override;
0033 
0034   MultiState mergeOld(const MultiState& mgs) const;
0035 
0036 public:
0037   typedef std::multimap<double, SingleStatePtr> SingleStateMap;
0038   typedef std::pair<SingleStatePtr, typename SingleStateMap::iterator> MinDistResult;
0039 
0040 private:
0041   //   std::pair< SingleState, SingleStateMap::iterator >
0042   MinDistResult compWithMinDistToLargestWeight(SingleStateMap&) const;
0043 
0044   int theMaxNumberOfComponents;
0045   DeepCopyPointerByClone<DistanceBetweenComponents<N> > theDistance;
0046 };
0047 
0048 #include "TrackingTools/GsfTools/interface/CloseComponentsMerger.icc"
0049 
0050 #endif  // CloseComponentsMerger_H