00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SCA_UNMERGE_HEADER
00009 #define SCA_UNMERGE_HEADER
00010
00011 #include <fstream>
00012
00013
00014 #include "rotation.hh"
00015 #include <clipper/clipper.h>
00016 using clipper::Vec3;
00017 using clipper::Mat33;
00018
00019 #include <string>
00020 #include "hkl_controls.hh"
00021 #include "controls.hh"
00022 #include "hkl_unmerge.hh"
00023 #include "hkl_datatypes.hh"
00024 #include "hash.hh"
00025
00026
00027 namespace SCAIO
00028 {
00029 enum ScaFileType {SCA_NONE, SCA_MERGED, SCA_UNMERGED, SCA_SHELX,
00030 SCA_SAINT};
00031
00032 class KeyValues;
00033
00034 class SCAunmergeFile
00036 {
00037 public:
00038 SCAunmergeFile(){}
00039
00041
00042 SCAunmergeFile(const std::string& scaname,
00043 std::string& output);
00044
00045 ~SCAunmergeFile() {if (scain.is_open()) scain.close();}
00046
00048 ScaFileType FileType() const {return sca_type;}
00049
00051 scala::FileRead FillHklList(std::string& output,
00052 scala::hkl_unmerge_list& hkl_list);
00054 scala::FileRead FillHklList(std::string& output,
00055 const scala::Scell& input_cell,
00056 scala::hkl_unmerge_list& hkl_list);
00057
00059
00060
00061
00062
00063
00064 scala::FileRead AddHklList(const scala::file_select& file_sel,
00065 const scala::all_controls& controls,
00066 const scala::PxdName& InputPxdName,
00067 const scala::Scell& input_cell,
00068 const double& input_wavelength,
00069 std::string& output,
00070 scala::hkl_unmerge_list& hkl_list);
00087
00088
00089 private:
00090
00091 int ReadObservations(std::ifstream& scain,
00092 const scala::file_select& file_sel,
00093 const scala::all_controls& controls,
00094 std::string& output,
00095 scala::hkl_unmerge_list& hkl_list);
00096 int MakeDataset(const scala::PxdName& InputPxdName);
00097 int MakeBatches(const scala::hkl_symmetry& Symm,
00098 const int& Idataset);
00099
00100 int ReadSaint(std::ifstream& scain,
00101 const scala::file_select& file_sel,
00102 const scala::all_controls& controls,
00103 std::string& output,
00104 scala::hkl_unmerge_list& hkl_list);
00105 void ZeroRecVector(std::vector<clipper::Coord_orth>& vc);
00106 scala::data_flags SetSaintDataFlags();
00107 bool CheckCells(const scala::Scell& input_cell, const scala::Scell& file_cell,
00108 const std::string& label, std::string& output);
00109
00110
00111
00112 std::vector<scala::Xdataset> datasets;
00113 std::vector<scala::Batch> batches;
00114
00115
00116 ScaFileType sca_type;
00117
00118 std::string scaname;
00119 std::ifstream scain;
00120 clipper::String line;
00121 bool lineFull;
00122 std::string spaceGroupName;
00123 scala::Scell cell;
00124 double wavelength;
00125
00126 scala::Scell inputcell;
00127 double inputwavelength;
00128
00129
00130 int Nbatches;
00131 hash_table lookup;
00132 };
00133
00134
00135 class SaintRun {
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 public:
00181 SaintRun(){}
00182
00183 SaintRun(const int& Ibatch, const int& Iaxis, const double& Chi, const double& Other,
00184 const int& Icryst, const double& Swing);
00185
00186 void init(const int& Ibatch, const int& Iaxis, const double& Chi, const double& Other,
00187 const int& Icryst, const double& Swing);
00188
00189 bool SameRun(const int& Ibatch, const int& Iaxis,
00190 const double& chi, const double& other,
00191 const int& icryst, const double& swing);
00192
00193 void StoreReflection(const IVect3& hkl, const int& batch,
00194 const DVect3& s0r, const DVect3& s2r,
00195 const double& rot, const int& istl);
00196
00197
00198 scala::Scell CalcCell();
00199
00200 void SetBatchOffset(const int& batchOffset) {batchoffset = batchOffset;}
00201 int BatchOffset() const {return batchoffset;}
00202 int MaxBatch() const;
00203 int Nbatches() const { return nbatches;}
00204
00205 std::string ScanAxis() const;
00206 double Chi() const {return chi;}
00207 double Other() const {return other;}
00208 double Swing() const {return swing;}
00209
00210 double RotAxistoBeamAngle() const;
00211
00212
00213
00214 DMat33 Umatrix(DVect3& Utrn);
00215
00216 double Wavelength();
00217 double SdWavelength() const {return sdwavelength;}
00218 scala::Scell Cell() const {return cell;}
00219
00220 void SetWavelength(const double& wvl)
00221 {wavelength = wvl; sdwavelength=0.0;lambdaDone=true;}
00222 void SetCell(const scala::Scell& Cell) {cell = Cell;cellDone=true;}
00223
00224 static DMat33 Rmatrix(const double& omegar, const double& chir, const double& phir);
00225 static DVect3 s0v() {return s0;}
00226
00227 std::vector<CMtz::MTZBAT> MakeBatch(const float& wavelength);
00228
00229 private:
00230 double BasicAngleD(const double& aa);
00231 bool SameAngle(const double& a1, const double& a2);
00232
00233 struct CompareMtzBat {
00234
00235
00236 bool operator()(const CMtz::MTZBAT& a, const CMtz::MTZBAT& b);
00237 };
00238
00239
00240 int ibatch;
00241 int iaxis;
00242 double chi;
00243 double other;
00244 int icryst;
00245 double swing;
00246 std::vector<scala::Range> rotRange;
00247
00248 double omegar, chir, phir;
00249
00250 std::vector<DVect3> s0rv;
00251 std::vector<DVect3> s2rv;
00252 std::vector<IVect3> hklv;
00253 std::vector<int> istlv;
00254 std::vector<DMat33> Rv;
00255
00256
00257
00258 bool cellDone;
00259 bool UmatrixDone;
00260 bool lambdaDone;
00261 DMat33 U;
00262 DVect3 Ut;
00263 scala::Scell cell;
00264 double wavelength;
00265 double sdwavelength;
00266
00267
00268
00269 int nbatches;
00270 hash_table lookup;
00271 int table_size;
00272 int batchoffset;
00273
00274
00275
00276
00277
00278
00279
00280 static DVect3 e1;
00281 static DVect3 e2;
00282 static DVect3 e3;
00283 static DVect3 s0;
00284
00285 static int nxpix, nypix;
00286 };
00287 }
00288 #endif