CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TrackingTools/GsfTools/interface/GaussianSumUtilities1D.h

Go to the documentation of this file.
00001 #ifndef GaussianSumUtilities1D_h_
00002 #define GaussianSumUtilities1D_h_
00003 
00004 // #include "TROOT.h"
00005 
00006 #include "TrackingTools/GsfTools/interface/SingleGaussianState1D.h"
00007 #include "TrackingTools/GsfTools/interface/MultiGaussianState1D.h"
00008 
00009 #include <vector>
00010 
00016 class GaussianSumUtilities1D {
00017 private:
00018   enum ModeStatus { Valid, NotValid, NotComputed };
00019 
00020 public:
00021   GaussianSumUtilities1D (const MultiGaussianState1D& state) :
00022     theState(state),
00023 //     theStates(state.components()),
00024     theModeStatus(NotComputed) {} 
00025   ~GaussianSumUtilities1D () {}
00026 
00028   inline unsigned int size () const {return components().size();}
00030   inline const std::vector<SingleGaussianState1D>& components () const {
00031     return theState.components();
00032   }
00034   inline double weight (unsigned int i) const {return components()[i].weight();}
00036   inline double mean (unsigned int i) const {return components()[i].mean();}
00038   inline double standardDeviation (unsigned int i) const {
00039 //     return sqrt(components()[i].variance());
00040     return components()[i].standardDeviation();
00041   }
00043   inline double variance (unsigned int i) const {return components()[i].variance();}
00045   double pdf(unsigned int i, double x)  const;
00047   double quantile (const double) const;
00049   bool modeIsValid () const;
00052   const SingleGaussianState1D& mode () const;
00054   double pdf (double) const;
00056   double cdf (const double&) const;
00058   double d1Pdf (const double&) const;
00060   double d2Pdf (const double&) const;
00062   double d3Pdf (const double&) const;
00064   double lnPdf (const double&) const;
00066   double d1LnPdf (const double&) const;
00068   double d2LnPdf (const double&) const;
00069 
00071   double weight () const {
00072     return theState.weight();
00073   }
00075   double mean () const {
00076     return theState.mean();
00077   }
00079   double variance () const {
00080     return theState.variance();
00081   }
00082 
00083 private:
00087   bool findMode (double& mode, double& pdfAtMode, 
00088                  const double& xStart, const double& scale) const;
00090   static double gauss (double, double, double);
00092   static double gaussInt (double, double, double);
00094   double combinedMean() const;
00096   void computeMode () const;
00099   double localVariance (double x) const;
00100 
00101   // the state of the mode finder
00102   struct FinderState {
00103     FinderState(){}
00104     FinderState(size_t n): pdfs(n){}
00105     double x;
00106     double y;
00107     double yd; // d1LnPdf
00108     double yd2; // d2LnPdf
00109     std::vector<double> pdfs;
00110   };
00111 
00112   // update tre state at x
00113   void update(FinderState & state, double x) const;
00114 
00116   std::vector<double> pdfComponents (const double&) const;
00118   void pdfComponents (double, std::vector<double> & ) const;
00120   static double pdf (double, const std::vector<double>&);
00122   double d1Pdf (double, const std::vector<double>&) const;
00124   double d2Pdf (double, const std::vector<double>&) const;
00126   double d3Pdf (double, const std::vector<double>&) const;
00128   static double lnPdf (double, const std::vector<double>&);
00130   double d1LnPdf (double, const std::vector<double>&) const;
00132   double d2LnPdf (double, const std::vector<double>&) const;
00133 
00134 private:
00135   const MultiGaussianState1D& theState;
00136 //   std::vector<SingleGaussianState1D> theStates;
00137 
00138   mutable ModeStatus theModeStatus;
00139   mutable SingleGaussianState1D theMode;
00140 //   mutable double theMode;
00141 };
00142 #endif