00001
00002
00003 #ifndef SCALA_CONTROLS
00004 #define SCALA_CONTROLS
00005
00006 #include "hkl_datatypes.hh"
00007 #include "observationflags.hh"
00008 #include "eprob.hh"
00009 #include "range.hh"
00010
00011 namespace scala
00012 {
00013
00014
00015 class run_controls
00016
00017 {
00018 public:
00019 run_controls();
00020 void SetStatus(const int& Status) {RunStatus = Status;}
00021 int Status() const {return RunStatus;}
00022
00023 bool Set() const {return (RunStatus >= 0);}
00024
00025
00026 bool Explicit() const {return ((RunStatus == -2) || (RunStatus == +1));}
00027
00028 void StoreRunBatchSelection(const BatchSelection& runselection)
00029 {batchrangesruns = runselection; RunStatus = -2;}
00030
00032 int RunNumber(const int& batchnumber);
00033
00035 std::vector<int> RunNumberList() const;
00036
00038 std::vector<IntRange> BatchRanges(const int& RunNumber)
00039 {return batchrangesruns.BatchRanges(RunNumber);}
00040
00042 void StoreResoByRun(const std::vector<std::pair<int,ResoRange> > Run_resolution_ranges);
00044 std::vector<std::pair<int,ResoRange> > GetResoByRun() const
00045 {return run_resolution_ranges;}
00047 void ClearResoByRun() {run_resolution_ranges.clear();}
00049 bool IsResoByRun() const {return resobyrun;}
00050
00051 private:
00052
00053
00054
00055
00056
00057 int RunStatus;
00058
00059
00060 BatchSelection batchrangesruns;
00061
00062 std::vector<std::pair<int,ResoRange> > run_resolution_ranges;
00063 bool resobyrun;
00064 };
00065
00066 class partial_controls
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 {
00079 public:
00080 partial_controls();
00081 partial_controls(const double& FrMin, const double& FrMax,
00082 const double& FrCorr, const bool& Check,
00083 const int& MaxGap);
00084
00085 std::string format() const;
00086
00087 Rtype& accept_fract_min() {return accept_fract_min_;}
00088 Rtype accept_fract_min() const {return accept_fract_min_;}
00089 Rtype& accept_fract_max() {return accept_fract_max_;}
00090 Rtype accept_fract_max() const {return accept_fract_max_;}
00091 Rtype& correct_fract_min() {return correct_fract_min_;}
00092 Rtype correct_fract_min() const {return correct_fract_min_;}
00093 bool& check() {return check_;}
00094 bool check() const {return check_;}
00095 int& maxgap() {return maxgap_;}
00096 int maxgap() const {return maxgap_;}
00097
00098 void Clear();
00099
00100
00101 void IncrementNrejGap() {nrejgap++;}
00102 int NrejGap() const {return nrejgap;}
00103
00104 void IncrementNrejFractionTooSmall() {nrejfractionsmall++;}
00105 int NrejFractionTooSmall() const {return nrejfractionsmall;}
00106
00107 void IncrementNrejFractionTooLarge() {nrejfractionlarge++;}
00108 int NrejFractionTooLarge() const {return nrejfractionlarge;}
00109
00110 private:
00111 Rtype accept_fract_min_, accept_fract_max_;
00112 Rtype correct_fract_min_;
00113 bool check_;
00114 int maxgap_;
00115 int nrejgap;
00116 int nrejfractionsmall;
00117 int nrejfractionlarge;
00118 };
00119
00120 class col_controls
00121
00122
00123 {
00124 public:
00125 col_controls() : SelectIcolFlag(-1), imid(-1.0) {}
00126
00127
00128
00129
00130
00131
00132 void SetIcolFlag(const int& IcolFlag, const double& Imid, const int Ipower=3);
00133
00134
00135
00136 void SetupColSelection(const int col_Ipr=1);
00137
00138 private:
00139 int SelectIcolFlag;
00140 int IpowerComb;
00141 double imid;
00142 };
00143
00144 class AnalysisControls
00145
00146
00147
00148 {
00149 public:
00150 AnalysisControls() : nresobins(10), nibins(10) {}
00151 AnalysisControls(const int& Nresobins, const int& Nibins)
00152 : nresobins(Nresobins), nibins(Nibins) {}
00153
00154 int NresoBins() const {return nresobins;}
00155 int NiBins() const {return nibins;}
00156
00157 private:
00158 int nresobins;
00159 int nibins;
00160 };
00161
00162 class RejectFlags {
00163 public:
00164
00165 enum Reject2Policy {REJECT, KEEP, REJECTLARGER, REJECTSMALLER};
00166
00167 RejectFlags(){}
00168 RejectFlags(const float& Sdrej, const float& Sdrej2,
00169 const Reject2Policy& Rej2policy)
00170 : sdrej(Sdrej), sdrej2(Sdrej2), rej2policy(Rej2policy) {}
00171
00172 std::string format() const;
00173
00174 std::string formatReject2Policy() const;
00175
00176 float sdrej;
00177 float sdrej2;
00178
00179 Reject2Policy rej2policy;
00180
00181 float operator += (const float& addition) {sdrej += addition; sdrej2 += addition;}
00182
00183 };
00184
00185 class OutlierControl
00186 {
00187 public:
00188 OutlierControl();
00189 OutlierControl(const int& Ndatasets);
00190
00191 bool& Combine() {return combine;}
00192 bool Combine() const {return combine;}
00193
00194 bool Anom() const;
00195
00196 void SetNdatasets(const int& Ndatasets);
00197
00198
00199
00200 RejectFlags& Reject(const AnomalousClass& selclass, const int& dts_index=0);
00201
00202 RejectFlags Reject(const AnomalousClass& selclass, const int& dts_index=0) const;
00203
00204 float SetEmax(const float& Emax);
00205 EProb EMaxTest() const {return emaxtest;}
00206
00207 private:
00208 bool combine;
00209 RejectFlags reject;
00210
00211 std::vector<RejectFlags> rejectanom;
00212 EProb emaxtest;
00213 };
00214
00216 class RefineControl
00217 {
00218 public:
00219 RefineControl();
00220
00221 bool& BFGS() {return bfgs;}
00222 bool BFGS() const {return bfgs;}
00223
00224 int& Ncyc1() {return ncyc1;}
00225 int Ncyc1() const {return ncyc1;}
00226
00227 int& Ncycles() {return ncycles;}
00228 int Ncycles() const {return ncycles;}
00229
00230 float& Converge() {return converge;}
00231 float Converge() const {return converge;}
00232
00233 float& IovSDmin() {return iovsdmin;}
00234 float IovSDmin() const {return iovsdmin;}
00235
00236 float& E2min() {return e2min;}
00237 float E2min() const {return e2min;}
00238
00239 private:
00240 bool bfgs;
00241 int ncyc1;
00242 int ncycles;
00243 float converge;
00244 float iovsdmin;
00245 float e2min;
00246 };
00247
00248 class DatasetControl
00249
00250 {
00251 public:
00252 DatasetControl() :basedataset(-1){}
00253
00254 int BaseDataset() const {return basedataset;}
00255 private:
00256 int basedataset;
00257 };
00258
00259 class all_controls
00260
00261
00262
00263
00264
00265
00266
00267 {
00268 public:
00269 all_controls(){};
00270
00271 run_controls runs;
00272 partial_controls partials;
00273 ObservationFlagControl observationflagcontrol;
00274 AnalysisControls analysis;
00275 OutlierControl outlierScale;
00276 OutlierControl outlierMerge;
00277 RefineControl refinecontrol;
00278 bool Anomalous;
00279 bool AnomalousSDcorr;
00280 DatasetControl datasetcontrol;
00281 };
00282 }
00283 #endif