Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef TrackingTools_GsfTools_MultiGaussianState_icc
0002 #define TrackingTools_GsfTools_MultiGaussianState_icc
0003 #include "TrackingTools/GsfTools/interface/MultiGaussianState.h"
0004 
0005 // template <unsigned int N>
0006 // MultiGaussianState<N>::MultiGaussianState
0007 // (const std::vector< std::shared_ptr<SingleState> >& stateV) :
0008 //   theCombinedStateUp2Date(false) {
0009 //   theComponents.reserve(stateV.size());
0010 //   for ( typename std::vector< std::shared_ptr<SingleState> >::const_iterator ic=stateV.begin();
0011 //  ic!=stateV.end(); ++ic )  theComponents.push_back( std::shared_ptr<const SingleState>(*ic) );
0012 // }
0013 
0014 template <unsigned int N>
0015 double MultiGaussianState<N>::weight() const {
0016   if (theCombinedStateUp2Date)
0017     return theCombinedState->weight();
0018 
0019   double result(0.);
0020   for (typename SingleStateContainer::const_iterator ic = theComponents.begin(); ic != theComponents.end(); ic++)
0021     result += (**ic).weight();
0022   return result;
0023 }
0024 
0025 template <unsigned int N>
0026 const typename MultiGaussianState<N>::Vector& MultiGaussianState<N>::mean() const {
0027   checkCombinedState();
0028   return theCombinedState->mean();
0029 }
0030 
0031 template <unsigned int N>
0032 const typename MultiGaussianState<N>::Matrix& MultiGaussianState<N>::covariance() const {
0033   checkCombinedState();
0034   return theCombinedState->covariance();
0035 }
0036 
0037 template <unsigned int N>
0038 const typename MultiGaussianState<N>::Matrix& MultiGaussianState<N>::weightMatrix() const {
0039   checkCombinedState();
0040   return theCombinedState->weightMatrix();
0041 }
0042 
0043 template <unsigned int N>
0044 void MultiGaussianState<N>::checkCombinedState() const {
0045   if (theCombinedStateUp2Date)
0046     return;
0047   MultiGaussianStateCombiner<N> theCombiner;
0048   theCombinedState = theCombiner.combine(theComponents);
0049   theCombinedStateUp2Date = true;
0050   //   ++constructsCombinedState_;
0051 }
0052 
0053 template <unsigned int N>
0054 void MultiGaussianState<N>::setWeight(double newWeight) {
0055   double wgt = weight();
0056   if (wgt > DBL_MIN)
0057     rescaleWeight(newWeight / wgt);
0058 }
0059 
0060 template <unsigned int N>
0061 void MultiGaussianState<N>::rescaleWeight(double scale) {
0062   for (typename std::vector<SingleState>::const_iterator ic = theComponents.begin(); ic != theComponents.end(); ic++)
0063     (**ic).rescaleWeight(scale);
0064   if (theCombinedStateUp2Date)
0065     theCombinedState->rescaleWeight(scale);
0066 }
0067 #endif