00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef OBSERVATIONFLAGS_HEADER
00022 #define OBSERVATIONFLAGS_HEADER
00023
00024 #include <string>
00025
00026 namespace scala
00027 {
00028
00029 float PackFlagValues(const float& BGratio,
00030 const float& PKratio, const float& Gradient);
00031
00032 class ObservationFlag
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 {
00050 public:
00051 ObservationFlag() : bitflags(0), bgpk(0.0) {}
00052 ObservationFlag(const int& ObsFlag, const float& bgpkratio)
00053 : bitflags(ObsFlag), bgpk(bgpkratio){}
00054 ObservationFlag(const ObservationFlag& flag);
00055
00056
00057 void AddFlag(const ObservationFlag& other);
00058
00059
00060 bool OK() const {return (bitflags == 0);}
00061
00062
00063 unsigned int Flags() const {return bitflags;}
00064 float BgPk() const {return bgpk;}
00065
00066
00067 void BgPkValues(float& BGratio, float& PKratio, float& Gradient) const;
00068
00069
00070
00071 bool TestBGratio() const {return (bitflags & 1) != 0;}
00072 bool TestPKratio() const {return (bitflags & 2) != 0;}
00073 bool TestTooNeg() const {return (bitflags & 4) != 0;}
00074 bool TestGradient() const {return (bitflags & 8) != 0;}
00075 bool TestOverload() const {return (bitflags & 16) != 0;}
00076 bool TestEdge() const {return (bitflags & 32) != 0;}
00077
00079 std::string format() const;
00080
00081 static const int FLAG_BGRATIO;
00082 static const int FLAG_PKRATIO;
00083 static const int FLAG_TOONEGATIVE;
00084 static const int FLAG_GRADIENT;
00085 static const int FLAG_OVERLOAD;
00086 static const int FLAG_EDGE;
00087
00088 private:
00089 unsigned int bitflags;
00090 float bgpk;
00091 };
00092
00093 class ObservationFlagControl
00094
00095
00096
00097 {
00098 public:
00099 ObservationFlagControl();
00100
00101
00102
00103
00104
00105
00106 ObservationFlagControl(const float& BGrlim, const float& PKrlim,
00107 const float& Gradlim,
00108 const bool& AcceptOverload, const bool& AcceptEdge);
00109
00110 void SetBGRlimit(const float& BGrlim);
00111 void SetPKRlimit(const float& PKrlim);
00112 void SetGradlimit(const float& Gradlim);
00113 void SetAcceptOverload();
00114 void SetAcceptEdge();
00115
00116
00117 bool IsAccepted(const ObservationFlag& flag);
00118
00119
00120 void Init();
00121
00122 void Clear();
00123
00124 std::string PrintCounts() const;
00125
00126 int NumAccOverload() const {return Naccoverload;}
00127
00128 private:
00129 float bgrlim;
00130 float pkrlim;
00131 float grdlim;
00132 bool acceptoverload;
00133 bool acceptedge;
00134
00135 int NBGratio;
00136 int NPKratio;
00137 int NTooNeg;
00138 int NGradient;
00139 int Noverload;
00140 int Nedge;
00141
00142 int NaccBGratio;
00143 int NaccPKratio;
00144 int NaccTooNeg;
00145 int NaccGradient;
00146 int Naccoverload;
00147 int Naccedge;
00148
00149 float MaxBGratio;
00150 float MaxPKratio;
00151 float MaxGradient;
00152
00153 float MaxAccBGratio;
00154 float MaxAccPKratio;
00155 float MaxAccGradient;
00156 };
00157
00158 class ObservationStatus
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 {
00169 public:
00170 enum ObsStatusFlag {OBSSTAT_FLAG=1, OBSSTAT_RESOLUTION=2, OBSSTAT_OUTLIER=4, OBSSTAT_OUTLIERANOM=8,
00171 OBSSTAT_EMAX=16, OBSSTAT_STRONG=32, OBSSTAT_WEAK=64};
00172
00173 ObservationStatus() :bitflags(0){}
00174 ObservationStatus(const unsigned int& flags) :bitflags(flags){}
00175
00176 void Clear() {bitflags = 0;}
00177
00178
00179 bool IsAccepted() const {return (bitflags == 0);}
00180
00181 void ResetStatus() {bitflags &= 3;}
00182
00183 unsigned int Bitflags() const {return bitflags;}
00184
00185
00186 void SetObsFlag() {bitflags |= OBSSTAT_FLAG;}
00187 void UnsetObsFlag() {bitflags &= (wordmask-OBSSTAT_FLAG);}
00188
00189 bool TestObsFlag() const {return (bitflags & OBSSTAT_FLAG) != 0;}
00190
00191
00192 void SetResolution() {bitflags |= OBSSTAT_RESOLUTION;}
00193 void UnSetResolution() {bitflags &= (wordmask-OBSSTAT_RESOLUTION);}
00194 bool TestResolution() const {return (bitflags & OBSSTAT_RESOLUTION) != 0;}
00195
00196
00197 void SetOutlier() {bitflags |= OBSSTAT_OUTLIER;}
00198 void UnsetOutlier() {bitflags &= (wordmask-OBSSTAT_OUTLIER);}
00199 bool TestOutlier() const {return (bitflags & OBSSTAT_OUTLIER) != 0;}
00200
00201
00202 void SetOutlierAnom() {bitflags |= OBSSTAT_OUTLIERANOM;}
00203 void UnsetOutlierAnom() {bitflags &= (wordmask-OBSSTAT_OUTLIERANOM);}
00204 bool TestOutlierAnom() const {return (bitflags & OBSSTAT_OUTLIERANOM) != 0;}
00205
00206
00207 void SetEmax() {bitflags |= OBSSTAT_EMAX;}
00208 void UnsetEmax() {bitflags &= (wordmask-OBSSTAT_EMAX);}
00209 bool TestEmax() const {return (bitflags & OBSSTAT_EMAX) != 0;}
00210
00211
00212 void SetTooStrong() {bitflags |= OBSSTAT_STRONG;}
00213 void UnsetTooStrong() {bitflags &= (wordmask-OBSSTAT_STRONG);}
00214 bool TestTooStrong() const {return (bitflags & OBSSTAT_STRONG) != 0;}
00215
00216
00217 void SetTooWeak() {bitflags |= OBSSTAT_WEAK;}
00218 void UnsetTooWeak() {bitflags &= (wordmask-OBSSTAT_WEAK);}
00219 bool TestTooWeak() const {return (bitflags & OBSSTAT_WEAK) != 0;}
00220
00221 private:
00222 unsigned int bitflags;
00223 static const unsigned int wordmask = 0xFFFF;
00224 };
00225
00226 class ObservationStatusSet
00227
00228 {
00229 };
00230 }
00231
00232 #endif