00001
00002
00003 #ifndef ZONE_HEADER
00004 #define ZONE_HEADER
00005
00006 #include <clipper/clipper.h>
00007 #include "hkl_datatypes.hh"
00008 #include "range.hh"
00009 #include "globalcontrols.hh"
00010 #include "hkl_symmetry.hh"
00011 #include "score_datatypes.hh"
00012
00013 namespace scala
00014 {
00015
00016 double IscoreVal(const IsigI& Isig);
00017
00018
00019
00020 class IndexIsigI
00021 {
00022 public:
00023 IndexIsigI(){}
00024 IndexIsigI(const int& j, const IsigI& Is) : index(j), Isig(Is) {}
00025
00026 int index;
00027 IsigI Isig;
00028 };
00029
00030 class OneDFourier
00031
00032 {
00033 public:
00034 OneDFourier(){}
00035 OneDFourier(const std::vector<int>& Ngrid);
00036 OneDFourier(const std::vector<double>& Xgrid);
00037
00038
00039 void AddRef(const int& j, const double& Val);
00040
00041 int Nobs() const;
00042 std::vector<double> FourierVal() const;
00043
00044
00045 private:
00046 std::vector<int> ngrid;
00047 std::vector<double> xgrid;
00048 std::vector<double> Sumx;
00049 int nobs;
00050 };
00051
00052 class Zone
00053 {
00054 public:
00055 Zone() {}
00056
00057
00058
00059
00060
00061
00062
00063 Zone(const std::string& Axis, const int& Nfold,
00064 const hkl_symmetry& LGsym);
00065
00066
00067
00068
00069 Zone(const std::string& GlidePlane, const std::string& Glide,
00070 const hkl_symmetry& LGsym);
00071
00072
00073 bool InZone(const Hkl& hkl) const;
00074
00075 bool Axis() const {return axis;}
00076
00077 int Order() const {return order;}
00078
00079
00080
00081
00082
00083 std::string formatNewFrame(const ReindexOp& RefToNew, const int Sub=1) const;
00084 std::string formatRefFrame(const int Sub=1) const;
00085
00086 std::string formatLGFrame(const int Sub=1) const;
00087
00088
00089 std::string FormatConditionNewFrame(const ReindexOp& RefToNew,
00090 const int Sub=1) const;
00091 std::string FormatConditionRefFrame(const int Sub=1) const;
00092 std::string FormatConditionLGFrame(const int Sub=1) const;
00093
00094
00095 std::string Direction() const;
00096
00097
00098
00099 bool SameZone(const Zone& other) const;
00100
00101
00102 void AddRef(const Hkl& hkl, const IsigI& Isig, const float& sSqr);
00103
00104
00105
00106 void StoreMeanSD(const std::vector<double>& Mean, const std::vector<double>& SD);
00107
00108
00109 void StoreReindex(const ReindexOp& reindexin);
00110 ReindexOp Reindex() const {return reindexmat;}
00111
00112
00113 void StoreProb(const double& ProbYes);
00114
00115
00116 hkl_symmetry LGsymm() const {return lgsymm;}
00117
00118
00119
00120 std::vector<double> FourierVal() const;
00121
00122
00123 std::vector<double> p() const;
00124
00125
00126 double Prob() const;
00127
00128 std::vector<int> Ngrid() const {return ngrid;}
00129
00130 int NgridPoints() const {return npoint;}
00131
00132 int Nobs() const;
00133
00134 Range InvResoRange() const {return InvResRange;}
00135
00136 std::pair<int,int> IndexRange() const
00137 {return std::pair<int,int>(minIndx, maxIndx);}
00138
00139 std::vector<int> Indices() const;
00140
00141 bool Valid() const {return (valid);}
00142
00143 bool ValidPoint(const int& ig) const {return validpoint.at(ig);}
00144
00145 double GetSD(const int& i) const {return controlsd[i];}
00146
00147 bool PrunedData() const {
00148
00149 for (int i=0;i<npoint;++i) {
00150 if (prunedData[i]) {return true;}
00151 }
00152 return false;
00153 }
00154
00155 bool PrunedData(const int& i) const {return prunedData[i];}
00156
00157
00158
00159
00160
00161
00162 std::vector<Hkl> GlideTestHkl(const ReindexOp& RefToNew) const;
00163
00164
00165
00166 std::vector<Hkl> AxisTestHkl(const ReindexOp& RefToNew,
00167 std::vector<std::vector<int> >& screwabsence) const;
00168
00169 std::vector<IndexIsigI> IndexedData() const {return IndxIsigI;}
00170
00171
00172 std::vector<IsigI> AverageIsigI() const { return averageIsigI;}
00173
00174 std::vector<IsigI> AdjustedIsigI() const {return adjustedIsigI;}
00175
00176
00177
00178 static void SetNeighbourFraction(const float& nf) {neighbourFraction = nf;}
00179 static float GetNeighbourFraction() {return neighbourFraction;}
00180
00181 void dump() const;
00182
00183
00184 friend bool operator < (const Zone& a,const Zone& b)
00185
00186 {
00187 if (a.axis) {
00188 if (!b.axis) return true;
00189 } else {
00190 if (b.axis) return false;
00191 }
00192
00193 return a.order > b.order;
00194 }
00195
00196
00197 bool Compare(const Zone& other) const;
00198
00199 private:
00200 void init(const bool& disable);
00201 void TestValidIndices() const;
00202 void CalcResults() const;
00203 Hkl CondReference() const;
00204 std::vector<double> GetFourierValues() const;
00205 std::vector<IsigI> AverageI(const std::vector<IndexIsigI>& IdxIs) const;
00206
00207 clipper::Vec3<double> DirectionRefFrame() const;
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 ReindexOp permute;
00219
00220 ReindexOp permuteIndex;
00221
00222
00223
00224
00225
00226
00227 clipper::Vec3<int> cond;
00228
00229
00230
00231
00232 clipper::Vec3<double> qcond;
00233
00234
00235
00236 std::string direction;
00237 std::string glide;
00238 int order;
00239 bool axis;
00240 bool diagonal;
00241 Range InvResRange;
00242 std::vector<IndexIsigI> IndxIsigI;
00243 int minIndx;
00244 int maxIndx;
00245
00246 mutable std::vector<IsigI> averageIsigI;
00247 mutable std::vector<IsigI> adjustedIsigI;
00248
00249 mutable std::vector<bool> validpoint;
00250
00251
00252
00253
00254
00255 std::vector<int> ngrid;
00256
00257 mutable OneDFourier fsum;
00258 std::vector<double> controlsd;
00259 std::vector<double> controlmean;
00260 int npoint;
00261 bool ZeroControlSD;
00262 std::vector<bool> UnitControlMean;
00263 static double MinControlSD;
00264
00265
00266 static float neighbourFraction;
00267
00268
00269
00270 ReindexOp reindexmat;
00271 bool NonIdentityReindex;
00272 hkl_symmetry lgsymm;
00273
00274
00275 bool singleprob;
00276
00277
00278
00279 mutable bool valid;
00280 mutable bool results;
00281 mutable std::vector<double> Pfor;
00282 mutable double prob_yes;
00283 mutable std::vector<bool> prunedData;
00284
00285
00286
00287 };
00288
00289 class SysAbsScore
00290
00291
00292
00293
00294
00295
00296 {
00297 public:
00298 SysAbsScore() : TotalProb(1.0), n(0), possible(true) {}
00299 SysAbsScore(const PossibleSpaceGroup& PSG)
00300 : TotalProb(1.0), n(0), possible(true), PossibleSG(PSG) {}
00301
00302
00303 void ProbYes(const double& p) {if (p >= 0.0) {TotalProb *= p; n++;}}
00304
00305 void ProbNo(const double& p) {if (p >= 0.0) {TotalProb *= 1.0-p; n++;}}
00306
00307 void Impossible() {possible=false;}
00308
00309 void Possible() {possible=true;}
00310
00311 void SetCondition(const std::string& cnd) {condition = cnd;}
00312
00313 void SetConditionLG(const std::string& cnd) {conditionLG = cnd;}
00314
00315 void SetSGposs(const PossibleSpaceGroup& PSG) {PossibleSG = PSG;}
00316
00317 void Normalise(const double& fac) {TotalProb *= fac;}
00318
00319 void AddZone(const int& izone) {zonesingroup.push_back(izone);}
00320
00321 std::vector<int> ZoneList() const {return zonesingroup;}
00322
00323 bool IsZoneInGroup(const int& iz) const;
00324
00325
00326
00327 double TotalProbability() const {return TotalProb;}
00328
00329 bool IsPossible() const {return possible;}
00330
00331 std::string Condition() const {return condition;}
00332
00333 std::string ConditionLG() const {return conditionLG;}
00334
00335 PossibleSpaceGroup SGposs() const {return PossibleSG;}
00336
00337 private:
00338 bool possible;
00339 double TotalProb;
00340 int n;
00341 std::string condition;
00342 std::string conditionLG;
00343 PossibleSpaceGroup PossibleSG;
00344 std::vector<int> zonesingroup;
00345 };
00346
00347 }
00348
00349 #endif