CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/TrackingTools/GsfTools/src/MultiGaussianState1D.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTools/interface/MultiGaussianState1D.h"
00002 #include "TrackingTools/GsfTools/interface/MultiGaussianStateCombiner1D.h"
00003 // #include "TrackingTools/GsfTools/interface/MultiGaussianState.h"
00004 
00005 double MultiGaussianState1D::weight() const
00006 {
00007   if (theCombinedStateUp2Date) return theCombinedState.weight();
00008   
00009   double result(0.);
00010   for ( SingleState1dContainer::const_iterator ic=theComponents.begin();
00011         ic!=theComponents.end(); ic++ )  result += (*ic).weight();
00012   return result;
00013 }
00014 
00015 double MultiGaussianState1D::mean() const
00016 {
00017   checkCombinedState();
00018   return theCombinedState.mean();
00019 }
00020 
00021 double MultiGaussianState1D::variance() const
00022 {
00023   checkCombinedState();
00024   return theCombinedState.variance();
00025 }
00026 
00027 void MultiGaussianState1D::checkCombinedState() const
00028 {
00029   if (theCombinedStateUp2Date) return;
00030 
00031   MultiGaussianStateCombiner1D combiner;
00032   theCombinedState = combiner.combine(theComponents);
00033 
00034 //   typedef SingleGaussianState<1> SingleState;
00035 //   typedef boost::shared_ptr< SingleGaussianState<1> > SingleStatePtr;
00036 //   typedef std::vector< SingleStatePtr > SingleStateContainer;
00037 
00038 //   SingleStateContainer components;
00039 //   for ( SingleState1dContainer::const_iterator ic=theComponents.begin();
00040 //      ic!=theComponents.end(); ic++ ) {
00041 //     SingleStatePtr ssp(new SingleState(SingleState::Vector((*ic).mean()),
00042 //                                     SingleState::Matrix((*ic).variance()),
00043 //                                     (*ic).weight()));
00044 //     components.push_back(ssp);
00045 //   }
00046 //   MultiGaussianState<1> multiState(components);
00047 
00048 //   theCombinedState = SingleGaussianState1D(multiState.mean()(0),
00049 //                                         multiState.covariance()(0,0),
00050 //                                         multiState.weight());
00051 
00052   theCombinedStateUp2Date = true;
00053 
00054 }