00001 #ifndef CONVERGENCEMASTER_H
00002 #define CONVERGENCEMASTER_H
00003
00017
00018 #include <vector>
00019 #include <list>
00020
00021 #include "Rtypes.h"
00022
00023 class DataFT;
00024
00025
00026 class ConvergenceMaster {
00027
00028 public:
00029 typedef Int_t Count_t;
00030
00031 typedef UShort_t Mask_t;
00032 typedef std::vector<Mask_t> ViewMask_t;
00033
00034 private:
00035 typedef ViewMask_t::iterator ViewMaskItr;
00036 typedef ViewMask_t::reverse_iterator ViewMaskRItr;
00037 typedef ViewMask_t::const_iterator ViewMaskCItr;
00038 typedef ViewMask_t::const_reverse_iterator ViewMaskCRItr;
00039 typedef std::vector<ViewMask_t> ViewMaskVec_t;
00040 typedef std::list<ViewMask_t> ViewMaskList_t;
00041 typedef ViewMaskList_t::iterator ViewMaskListItr;
00042 typedef ViewMaskList_t::const_iterator ViewMaskListCItr;
00043
00049 class MaskStep {
00050
00051 public:
00052 MaskStep( const ViewMask_t& umask, const ViewMask_t& vmask,
00053 Int_t nhitsinviewmin
00054 );
00055 ~MaskStep();
00056
00057 Bool_t IncrementPlaneCount();
00058 Bool_t DecrementPlaneCount();
00059
00060 Count_t GetPlaneCountCur() const { return fPlaneCountCur; };
00061 void SetPlaneCountCur(Count_t n) { fPlaneCountCur = n; };
00062 void SetPlaneCountLast(Count_t n) { fPlaneCountLast = n; };
00063
00064 Count_t GetPlaneCountMax() const { return fPlaneCountMax; };
00065 Count_t GetPlaneCountMin() const { return fPlaneCountMin; };
00066 Count_t GetPlaneCountLast() const { return fPlaneCountLast; };
00067 Bool_t GetConvergedCur() const { return fConvergedCur; };
00068
00069 Count_t GetNPlanesToFit() const { return GetPlaneCountCur(); };
00070
00071 void SetConverged() { fConvergedCur = kTRUE; };
00072 void SetDiverged() { fConvergedCur = kFALSE; };
00073
00074 Count_t FindPlaneCountMin( const ViewMask_t& mask,
00075 Count_t nhitsmin );
00076 Count_t FindPlaneCountMax( const ViewMask_t& mask );
00077
00078 const ViewMask_t& GetMaskU() const { return fMaskU; } ;
00079 const ViewMask_t& GetMaskV() const { return fMaskV; };
00080
00081 void Print() const;
00082 void PrintMasks() const;
00083
00084 private:
00085 ViewMask_t fMaskU;
00086 ViewMask_t fMaskV;
00087
00088 ViewMask_t fMaskUVSum;
00089
00090 Count_t fPlaneCountMin;
00091 Count_t fPlaneCountMax;
00092
00093 Count_t fPlaneCountCur;
00094 Bool_t fConvergedCur;
00095
00096 Count_t fPlaneCountLast;
00097 };
00098
00099 typedef std::vector<MaskStep> MaskList_t;
00100 typedef MaskList_t::iterator MaskListItr;
00101 typedef MaskList_t::const_iterator MaskListCItr;
00102
00103 public:
00104 ConvergenceMaster(Int_t nhitsinviewmin = 4);
00105 ~ConvergenceMaster();
00106
00110 void BuildMasks(const DataFT& data);
00111
00112 void SetNHitsInViewMin(Int_t n)
00113 { fNHitsInViewMin = n; } ;
00114
00115 Bool_t NextStep();
00116
00117 Bool_t MaskIsValid() const { return fMaskIsValid; };
00118 void SetMaskIsValid(Bool_t valid) { fMaskIsValid = valid; };
00119
00120 void SetConverged() { fMaskCur->SetConverged(); };
00121 void SetDiverged() { fMaskCur->SetDiverged(); };
00122
00123 Count_t GetNPlanesCur() const;
00124 Count_t GetNPlanesMin() const;
00125 Count_t GetNPlanesMax() const;
00126
00127 const ViewMask_t& GetMaskUCur() const;
00128 const ViewMask_t& GetMaskVCur() const;
00129
00130 private:
00131 void PrintMasks() const;
00132
00133 void SetInitialMask();
00134
00135 void BuildMaskSteps( const ViewMaskList_t& maskU,
00136 const ViewMaskList_t& maskV );
00137
00138 void BuildViewMasks(const ViewMask_t& maskIn,
00139 ViewMaskList_t& maskList);
00140
00141 Bool_t UnsetEverySecond(ViewMask_t& mask);
00142
00143 void PadMaskLists(ViewMaskList_t& maskU, ViewMaskList_t& maskV);
00144 void PadWithLastElement(ViewMaskList_t& maskList, UInt_t n);
00145
00146 Bool_t IncrementPlaneCount();
00147 Bool_t DecrementPlaneCount();
00148 Bool_t NextMask(Count_t planeCount);
00149
00150 Int_t fNHitsInViewMin;
00151
00152 MaskList_t fMaskList;
00153 MaskListItr fMaskCur;
00154
00155 Bool_t fMaskIsValid;
00156 };
00157
00158 #endif