00001 #ifndef Impala_Core_Histogram_ComputeWeibull_h
00002 #define Impala_Core_Histogram_ComputeWeibull_h
00003
00004 #include "Core/Geometry/RectangleSet.h"
00005 #include "Core/Histogram/MakeHistogram1dSet.h"
00006 #include "Core/Histogram/FitWeibullMarginal.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Histogram
00013 {
00014
00015
00018 template <class VecElemT, class HistElemT>
00019 void
00020 ComputeWeibull(Vector::VectorTem<VecElemT>& v, Vector::VectorTem<HistElemT> hist,
00021 HistElemT histLow, HistElemT histHigh,
00022 bool storeMu, bool storeA)
00023 {
00024 FitWeibullMarginal<VecElemT> fit(hist.GetData(), hist.Size(), histLow,
00025 histHigh);
00026 v[0] = fit.Beta();
00027 v[1] = fit.Gamma();
00028 int idx = 2;
00029 if (storeMu)
00030 v[idx++] = fit.Mu();
00031 if (storeA)
00032 v[idx] = fit.A2();
00033 }
00034
00037 template <class VecElemT, class HistElemT>
00038 void
00039 ComputeWeibull(Vector::VectorTem<VecElemT>& v, Histogram1dTem<HistElemT> hist,
00040 bool storeMu, bool storeA)
00041 {
00042 FitWeibullMarginal<VecElemT> fit(hist.GetData(), hist.GetBinCount(),
00043 hist.GetLow(), hist.GetHigh());
00044 v[0] = fit.Beta();
00045 v[1] = fit.Gamma();
00046 int idx = 2;
00047 if (storeMu)
00048 v[idx++] = fit.Mu();
00049 if (storeA)
00050 v[idx] = fit.A2();
00051 }
00052
00056 template <class VecElemT, class HistArrayT>
00057 void
00058 ComputeWeibull(Vector::VectorTem<VecElemT>& v, Histogram1dSet<HistArrayT>* hSet,
00059 bool storeMu, bool storeA)
00060 {
00061 typedef typename Histogram1dSet<HistArrayT>::HistT HistType;
00062
00063 int nrPar = 2 + ((storeMu) ? 1 : 0) + ((storeA) ? 1 : 0);
00064 for (int i=0 ; i<hSet->Size() ; i++)
00065 {
00066 HistType hist = hSet->Hist(i);
00067 FitWeibullMarginal<VecElemT> fit(hist.GetData(), hist.GetBinCount(),
00068 hist.GetLow(), hist.GetHigh());
00069 int idx = i*nrPar;
00070 v[idx++] = fit.Beta();
00071 v[idx++] = fit.Gamma();
00072 if (storeMu)
00073 v[idx++] = fit.Mu();
00074 if (storeA)
00075 v[idx++] = fit.A2();
00076 }
00077 }
00078
00082 template <class VecArrayT, class ImArrayT, class HistArrayT>
00083 void
00084 ComputeWeibullSet(Vector::VectorSet<VecArrayT>* vSet, Array::ArraySet<ImArrayT>& imSet,
00085 const Geometry::RectangleSet& rects, Histogram1dSet<HistArrayT>* hSet,
00086 bool storeMu, bool storeA)
00087 {
00088 typedef typename Vector::VectorSet<VecArrayT>::ElemT VecElemT;
00089 typedef typename Vector::VectorSet<VecArrayT>::VectorT VectorT;
00090
00091 for (int i=0 ; i<rects.size() ; i++)
00092 {
00093 MakeHistogram1dSet<HistArrayT,ImArrayT>(hSet, imSet, rects[i]);
00094 VectorT v = vSet->GetVector(i, true);
00095 ComputeWeibull<VecElemT,HistArrayT>(v, hSet, storeMu, storeA);
00096 }
00097 vSet->SetSize(rects.size());
00098 }
00099
00100 }
00101 }
00102 }
00103
00104 #endif