Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Conograph/trunk/src/ControlParam.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download) (as text)
Fri Feb 22 04:51:31 2013 UTC (11 years, 1 month ago) by rtomiyasu
File MIME type: text/x-c++src
File size: 26503 byte(s)


1 /*
2 * The MIT License
3
4 Conograph (powder auto-indexing program)
5
6 Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 *
26 */
27 #ifdef _OPENMP
28 #include <omp.h>
29 #endif
30 #include <string>
31 #include "ControlParam.hh"
32 #include "utility_data_structure/qdata.hh"
33 #include "utility_func/zstring.hh"
34 #include "utility_func/zmath.hh"
35 #include "zlog/zlog.hh"
36
37 const map<eABCaxis, string> ControlParam::ABCaxisLabel = putABCaxisLabel();
38 const map<eRHaxis, string> ControlParam::RHaxisLabel = putRHaxisLabel();
39
40 static Vec_DP putConvParamRange()
41 {
42 Vec_DP ans(2, 0.0);
43 ans[0] = -I_ReadData::MAX_DP();
44 return ans;
45 }
46
47 const pair<RWParamProperty, RWParamData<bool> > ControlParam::IsAngleDispersion_Data(
48 RWParamProperty(BOOLFLAG, "IsAngleDispersion"),
49 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) );
50 const pair<RWParamProperty, RWParamData<bool> > ControlParam::OutputSymmetry_Data[NUM_LS]
51 = {
52 pair<RWParamProperty, RWParamData<bool> >(
53 RWParamProperty(BOOLFLAG, "OutputTriclinic"),
54 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
55 pair<RWParamProperty, RWParamData<bool> >(
56 RWParamProperty(BOOLFLAG, "OutputMonoclinicP"),
57 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
58 pair<RWParamProperty, RWParamData<bool> >(
59 RWParamProperty(BOOLFLAG, "OutputMonoclinicB"),
60 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
61 pair<RWParamProperty, RWParamData<bool> >(
62 RWParamProperty(BOOLFLAG, "OutputOrthorhombicP"),
63 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
64 pair<RWParamProperty, RWParamData<bool> >(
65 RWParamProperty(BOOLFLAG, "OutputOrthorhombicB"),
66 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
67 pair<RWParamProperty, RWParamData<bool> >(
68 RWParamProperty(BOOLFLAG, "OutputOrthorhombicI"),
69 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
70 pair<RWParamProperty, RWParamData<bool> >(
71 RWParamProperty(BOOLFLAG, "OutputOrthorhombicF"),
72 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
73 pair<RWParamProperty, RWParamData<bool> >(
74 RWParamProperty(BOOLFLAG, "OutputTetragonalP"),
75 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
76 pair<RWParamProperty, RWParamData<bool> >(
77 RWParamProperty(BOOLFLAG, "OutputTetragonalI"),
78 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
79 pair<RWParamProperty, RWParamData<bool> >(
80 RWParamProperty(BOOLFLAG, "OutputRhombohedral"),
81 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
82 pair<RWParamProperty, RWParamData<bool> >(
83 RWParamProperty(BOOLFLAG, "OutputHexagonal"),
84 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
85 pair<RWParamProperty, RWParamData<bool> >(
86 RWParamProperty(BOOLFLAG, "OutputCubicP"),
87 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
88 pair<RWParamProperty, RWParamData<bool> >(
89 RWParamProperty(BOOLFLAG, "OutputCubicI"),
90 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) ),
91 pair<RWParamProperty, RWParamData<bool> >(
92 RWParamProperty(BOOLFLAG, "OutputCubicF"),
93 RWParamData<bool>(true, REPLACE_NONE<bool>, NULL, false, NULL, false, -1, -1) )
94 };
95
96 inline Vec_DP put_initial_conv_param()
97 {
98 Vec_DP ans(3,0.0);
99 ans[1] = 1.0;
100 return ans;
101 }
102
103 const pair<RWParamProperty, RWParamData<Vec_DP> > ControlParam::ConvParam_Data(
104 RWParamProperty(DARRAY, "ConversionParameters"),
105 RWParamData<Vec_DP>(put_initial_conv_param(), REPLACE_VECTOR_NONE<Double>, GTVec<Double>, putConvParamRange(), NULL, Vec_DP(), 2, 6) );
106 const pair<RWParamProperty, RWParamData<Vec_DP> > ControlParam::PeakShiftParam_Data(
107 RWParamProperty(DARRAY, "PeakShiftParameters"),
108 RWParamData<Vec_DP>(Vec_DP(1,0.0), REPLACE_VECTOR_NONE<Double>, NULL, Vec_DP(), NULL, Vec_DP(), 1, 1) );
109 const pair<RWParamProperty, RWParamData<Double> > ControlParam::WlengthX_Data(
110 RWParamProperty(DVALUE, "WaveLength"),
111 RWParamData<Double>(1.54056, REPLACE_NONE<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) );
112
113
114 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxPeakNum_Data(
115 RWParamProperty(STRVALUE, "MaxNumberOfPeaks"),
116 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
117 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::NumRefFigureOfMerit_Data(
118 RWParamProperty(INT4VALUE, "MaxNumberOfPeaksForFOM"),
119 RWParamData<Int4>(20, REPLACE_NONE<Int4>, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ); // 20 <= param < INF.
120 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxEdgeNum_Data(
121 RWParamProperty(STRVALUE, "MaxNumberOfTwoDimTopographs"),
122 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 < param < INF.
123 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxNodeNum_Data(
124 RWParamProperty(STRVALUE, "MaxNumberOfLatticeCandidates"),
125 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 < param < INF.
126 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxNumPeakInRange_Data(
127 RWParamProperty(STRVALUE, "MaxNumberOfMillerIndicesInRange"),
128 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
129 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MinNumPeakInRange_Data(
130 RWParamProperty(STRVALUE, "MinNumberOfMillerIndicesInRange"),
131 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0.0 <= param <= 1.0.
132 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinFOM_Data(
133 RWParamProperty(DVALUE, "MinFOM"),
134 RWParamData<Double>(3.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
135 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MaxUnitCellVolume_Data(
136 RWParamProperty(STRVALUE, "MaxPrimitiveUnitCellVolume"),
137 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 <= param < INF.
138 const pair<RWParamProperty, RWParamData<string> > ControlParam::str_MinUnitCellVolume_Data(
139 RWParamProperty(STRVALUE, "MinPrimitiveUnitCellVolume"),
140 RWParamData<string>("AUTO", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) ); // 0 <= param < INF.
141 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinUnitCellEdgeABC_Data(
142 RWParamProperty(DVALUE, "MinUnitCellEdgeABC"),
143 RWParamData<Double>(0.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
144 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MaxUnitCellEdgeABC_Data(
145 RWParamProperty(DVALUE, "MaxUnitCellEdgeABC"),
146 RWParamData<Double>(1000.0, REPLACE_MAX<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
147 const pair<RWParamProperty, RWParamData<Double> > ControlParam::CVForLinearSum_Data(
148 RWParamProperty(DVALUE, "CriticalValueForLinearSum"),
149 RWParamData<Double>(1.0, REPLACE_NONE<Double>, GT<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 < param < INF.
150 const pair<RWParamProperty, RWParamData<Double> > ControlParam::Resol_Data(
151 RWParamProperty(DVALUE, "Resolution"),
152 RWParamData<Double>(0.03, REPLACE_NONE<Double>, GE<Double>, 0.0, LE<Double>, 0.25, -1, -1) ); // 0 <= param < INF.
153
154 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::SearchLevel_Data(
155 RWParamProperty(INT4VALUE, "SearchLevel"),
156 RWParamData<Int4>((Int4)ConographQuickSearch, REPLACE_NONE<Int4>, GE<Int4>, (Int4)ConographQuickSearch, LE<Int4>, (Int4)ConographRegularSearch, -1, -1) );
157
158 #ifdef _OPENMP
159 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::NumCores_Data(
160 RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
161 RWParamData<Int4>(omp_get_max_threads()-1, REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) );
162 #else
163 const pair<RWParamProperty, RWParamData<Int4> > ControlParam::NumCores_Data(
164 RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
165 RWParamData<Int4>(1, REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) );
166 #endif
167
168 const pair<RWParamProperty, RWParamData<string> > ControlParam::MonoBaseAxis_Data(
169 RWParamProperty(STRVALUE, "AxisForBaseCenteredSymmetry"),
170 RWParamData<string>("B", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
171 const pair<RWParamProperty, RWParamData<string> > ControlParam::RhomAxis_Data(
172 RWParamProperty(STRVALUE, "AxisForRhombohedralSymmetry"),
173 RWParamData<string>("Hexagonal", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
174 const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdNormM_Data(
175 RWParamProperty(DVALUE, "ThresholdOnNormM"),
176 RWParamData<Double>(1.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
177 const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdRevM_Data(
178 RWParamProperty(DVALUE, "ThresholdOnRevM"),
179 RWParamData<Double>(0.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
180 const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinLatticePointDistance_Data(
181 RWParamProperty(DVALUE, "MinDistanceBetweenLatticePoints"),
182 RWParamData<Double>(2.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
183
184
185 ControlParam::ControlParam()
186 : IsADorTOF(IsAngleDispersion_Data.second.initial_value),
187 ConvParam(ConvParam_Data.second.initial_value),
188 PeakShiftParam(PeakShiftParam_Data.second.initial_value),
189 WlengthX(WlengthX_Data.second.initial_value),
190 SearchLevel(SearchLevel_Data.second.initial_value),
191 MaxPeakNum(0),
192 MaxEdgeNum(0),
193 MaxNodeNum(0),
194 MinUnitCellVolume(0.0),
195 MaxUnitCellVolume(0.0),
196 CVForLinearSum(CVForLinearSum_Data.second.initial_value),
197 NumRefFigureOfMerit(NumRefFigureOfMerit_Data.second.initial_value),
198 MaxNumPeakInRange(0),
199 MinNumPeakInRange(0),
200 MinUnitCellEdgeABC(MinUnitCellEdgeABC_Data.second.initial_value),
201 MaxUnitCellEdgeABC(MaxUnitCellEdgeABC_Data.second.initial_value),
202 MinFOM(MinFOM_Data.second.initial_value),
203 Resol(Resol_Data.second.initial_value),
204 NumCores(NumCores_Data.second.initial_value),
205 MonoBaseAxis(MonoBaseAxis_Data.second.initial_value),
206 RhomAxis(RhomAxis_Data.second.initial_value),
207 ThresholdNormM(ThresholdNormM_Data.second.initial_value),
208 ThresholdRevM(ThresholdRevM_Data.second.initial_value),
209 MinLatticePointDistance(MinLatticePointDistance_Data.second.initial_value),
210 str_MaxPeakNum(str_MaxPeakNum_Data.second.initial_value),
211 str_MaxEdgeNum(str_MaxEdgeNum_Data.second.initial_value),
212 str_MaxNodeNum(str_MaxNodeNum_Data.second.initial_value),
213 str_MinUnitCellVolume(str_MinUnitCellVolume_Data.second.initial_value),
214 str_MaxUnitCellVolume(str_MaxUnitCellVolume_Data.second.initial_value),
215 str_MaxNumPeakInRange(str_MaxNumPeakInRange_Data.second.initial_value),
216 str_MinNumPeakInRange(str_MinNumPeakInRange_Data.second.initial_value)
217 {
218 for(Int4 i=0; i<NUM_LS; i++)
219 {
220 OutputSymmetry[i] = OutputSymmetry_Data[i].second.initial_value;
221 }
222 }
223
224
225 ControlParam::~ControlParam()
226 {
227 }
228
229
230 const string& ControlParam::putTagLabel() const
231 {
232 static const string label = "ConographParameters";
233 return label;
234 }
235
236
237 ZErrorMessageReadingFile ControlParam::readFile(const string& filename, const string& file_label)
238 {
239 ZErrorMessageReadingFile zerr = I_ReadData::readFile(filename, file_label);
240 if( IsAngleDispersion() ) ConvParam.clear();
241 else PeakShiftParam.clear();
242
243 if( zerr.putErrorType() != ZErrorNoError ) return zerr;
244 if( str_MaxPeakNum!="AUTO" )
245 {
246 if( str_MaxPeakNum=="MAX" )
247 {
248 MaxPeakNum = numeric_limits<Int4>::max();
249 }
250 else
251 {
252 istringstream iss( str_MaxPeakNum );
253 iss >> MaxPeakNum;
254 if( iss.fail() ) return ZErrorMessageReadingFile( filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxPeakNum_Data.first.putLabel() + ">:"+str_MaxPeakNum, __FILE__, __LINE__, __FUNCTION__) );
255 if( MaxPeakNum < 3 )
256 {
257 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
258 }
259 else if( MaxPeakNum > 2000 )
260 {
261 return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too large: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
262 }
263 }
264 }
265
266 if( str_MaxEdgeNum != "AUTO" )
267 {
268 if( str_MaxEdgeNum=="MAX" )
269 {
270 MaxEdgeNum = numeric_limits<Int4>::max();
271 }
272 else
273 {
274 istringstream iss( str_MaxEdgeNum );
275 iss >> MaxEdgeNum;
276 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxEdgeNum_Data.first.putLabel() + ">: "+str_MaxEdgeNum, __FILE__, __LINE__, __FUNCTION__) );
277 if( MaxEdgeNum < 1 )
278 {
279 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxEdgeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxEdgeNum), __FILE__, __LINE__, __FUNCTION__) );
280 }
281 }
282 }
283
284 if( str_MaxNodeNum != "AUTO" )
285 {
286 if( str_MaxNodeNum=="MAX" )
287 {
288 MaxNodeNum = numeric_limits<Int4>::max();
289 }
290 else
291 {
292 istringstream iss( str_MaxNodeNum );
293 iss >> MaxNodeNum;
294 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string in <" + str_MaxNodeNum_Data.first.putLabel() + "> is not replaced: "+str_MaxNodeNum, __FILE__, __LINE__, __FUNCTION__) );
295 if( MaxNodeNum < 1 )
296 {
297 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxNodeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxNodeNum), __FILE__, __LINE__, __FUNCTION__) );
298 }
299 }
300 }
301
302 if( str_MinUnitCellVolume != "AUTO" )
303 {
304 istringstream iss( str_MinUnitCellVolume );
305 iss >> MinUnitCellVolume;
306 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMinUnitCellVolumeLabel() + ">: "+str_MinUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
307 if( MinUnitCellVolume < 1.0 )
308 {
309 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMinUnitCellVolumeLabel() + "> is less than 1: "+num2str<Double>(MinUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
310 }
311 }
312
313 if( str_MaxUnitCellVolume != "AUTO" )
314 {
315 istringstream iss( str_MaxUnitCellVolume );
316 iss >> MaxUnitCellVolume;
317 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMaxUnitCellVolumeLabel() + ">: "+str_MaxUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
318 if( MaxUnitCellVolume <= MinUnitCellVolume )
319 {
320 return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMaxUnitCellVolumeLabel() + "> is not larger than <"+ putMinUnitCellVolumeLabel() + "> : "+num2str<Double>(MaxUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
321 }
322 }
323
324 if( str_MaxNumPeakInRange != "AUTO" )
325 {
326 if( str_MaxNumPeakInRange =="MAX" )
327 {
328 MaxNumPeakInRange = numeric_limits<Int4>::max();
329 }
330 else
331 {
332 istringstream iss( str_MaxNumPeakInRange );
333 iss >> MaxNumPeakInRange;
334 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxNumPeakInRange_Data.first.putLabel() + ">: "+str_MaxNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
335 if( MaxNumPeakInRange < 1 )
336 {
337 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MaxNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
338 }
339 }
340 }
341
342 if( str_MinNumPeakInRange != "AUTO" )
343 {
344 istringstream iss( str_MinNumPeakInRange );
345 iss >> MinNumPeakInRange;
346 if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MinNumPeakInRange_Data.first.putLabel() + ">: "+str_MinNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
347 if( MinNumPeakInRange < 1 )
348 {
349 return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MinNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MinNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
350 }
351
352 if( str_MaxNumPeakInRange != "AUTO" && MaxNumPeakInRange < MinNumPeakInRange )
353 {
354 return ZErrorMessageReadingFile(filename, ZErrorMessage( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">",
355 __FILE__, __LINE__, __FUNCTION__) );
356 }
357 }
358
359 return ZErrorMessageReadingFile();
360 }
361
362
363
364 void ControlParam::setData(const RWParamProperty& parent_prop,
365 vector<RWParam_void>& tray)
366 {
367 if( parent_prop.putLabel() == this->putTagLabel() )
368 {
369 tray.push_back( RWParam_void(IsAngleDispersion_Data, &IsADorTOF) );
370 for(Int4 i=0; i<NUM_LS; i++)
371 {
372 tray.push_back( RWParam_void(OutputSymmetry_Data[i], &OutputSymmetry[i]) );
373 }
374 tray.push_back( RWParam_void(ConvParam_Data, &ConvParam) );
375 tray.push_back( RWParam_void(PeakShiftParam_Data, &PeakShiftParam) );
376 tray.push_back( RWParam_void(WlengthX_Data, &WlengthX) );
377 tray.push_back( RWParam_void(Resol_Data, &Resol) );
378 tray.push_back( RWParam_void(CVForLinearSum_Data, &CVForLinearSum) );
379 tray.push_back( RWParam_void(str_MaxPeakNum_Data, &str_MaxPeakNum) );
380 tray.push_back( RWParam_void(str_MaxEdgeNum_Data, &str_MaxEdgeNum) );
381 tray.push_back( RWParam_void(str_MaxNodeNum_Data, &str_MaxNodeNum) );
382 tray.push_back( RWParam_void(str_MinUnitCellVolume_Data, &str_MinUnitCellVolume) );
383 tray.push_back( RWParam_void(str_MaxUnitCellVolume_Data, &str_MaxUnitCellVolume) );
384
385 tray.push_back( RWParam_void(MinUnitCellEdgeABC_Data, &MinUnitCellEdgeABC) );
386 tray.push_back( RWParam_void(MaxUnitCellEdgeABC_Data, &MaxUnitCellEdgeABC) );
387 tray.push_back( RWParam_void(MinFOM_Data, &MinFOM) );
388 tray.push_back( RWParam_void(str_MaxNumPeakInRange_Data, &str_MaxNumPeakInRange) );
389 tray.push_back( RWParam_void(str_MinNumPeakInRange_Data, &str_MinNumPeakInRange) );
390 tray.push_back( RWParam_void(NumRefFigureOfMerit_Data, &NumRefFigureOfMerit) );
391
392 tray.push_back( RWParam_void(SearchLevel_Data, &SearchLevel) );
393 tray.push_back( RWParam_void(NumCores_Data, &NumCores) );
394 tray.push_back( RWParam_void(MonoBaseAxis_Data, &MonoBaseAxis) );
395 tray.push_back( RWParam_void(RhomAxis_Data, &RhomAxis) );
396 tray.push_back( RWParam_void(ThresholdNormM_Data, &ThresholdNormM) );
397 tray.push_back( RWParam_void(ThresholdRevM_Data, &ThresholdRevM) );
398 tray.push_back( RWParam_void(MinLatticePointDistance_Data, &MinLatticePointDistance) );
399 }
400 }
401
402
403 ZErrorMessage ControlParam::checkData(const RWParam_void& param) const
404 {
405 const string Label = param.putLabel();
406 if( IsEqualTag(param.putProperty(), ConvParam_Data.first ) )
407 {
408 if( IsADorTOF )
409 {
410 return ZErrorMessage();
411 }
412 }
413 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
414 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
415 {
416 if( !IsADorTOF )
417 {
418 return ZErrorMessage();
419 }
420 }
421 else if( IsEqualTag(param.putProperty(), MonoBaseAxis_Data.first) )
422 {
423 if( find_key(ABCaxisLabel, MonoBaseAxis) == eABCaxis(-1) )
424 {
425 return nerror_out_range(param.putLabel(), MonoBaseAxis, __FILE__, __LINE__, __FUNCTION__ );
426 }
427 else return ZErrorMessage();
428 }
429 else if( IsEqualTag(param.putProperty(), RhomAxis_Data.first) )
430 {
431 if( find_key(RHaxisLabel, RhomAxis) == eRHaxis(-1) )
432 {
433 return nerror_out_range(param.putLabel(), RhomAxis, __FILE__, __LINE__, __FUNCTION__ );
434 }
435 else return ZErrorMessage();
436 }
437 return I_ReadData::checkData(param);
438 }
439
440
441
442 ZErrorMessage ControlParam::checkIfDataAreSet(const RWParam_void& param, const Int4& num) const
443 {
444 const string Label = param.putLabel();
445 if( IsEqualTag(param.putProperty(), ConvParam_Data.first) )
446 {
447 if( IsADorTOF )
448 {
449 return ZErrorMessage();
450 }
451 }
452 else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
453 || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
454 {
455 if( !IsADorTOF )
456 {
457 return ZErrorMessage();
458 }
459 }
460 else if( IsEqualTag(param.putProperty(), MaxUnitCellEdgeABC_Data.first) )
461 {
462 if( MaxUnitCellEdgeABC < MinUnitCellEdgeABC )
463 {
464 return ZErrorMessage( "<" + MaxUnitCellEdgeABC_Data.first.putLabel() + "> is less than <" + MinUnitCellEdgeABC_Data.first.putLabel() + ">",
465 __FILE__, __LINE__, __FUNCTION__);
466 }
467 }
468
469 return I_ReadData::checkIfDataAreSet(param, num);
470 }
471
472
473 inline Int4 put_automatic_peak_num(const eConographAnalysisMode& search_level, const vector<QData>& qdata,
474 const Int4& num_ref_figure_of_merit, const Double& min_length_edge)
475 {
476 assert( num_ref_figure_of_merit <= (Int4)qdata.size() );
477 if( qdata.empty() ) return 0;
478 return max(num_ref_figure_of_merit, min(48, (Int4)distance( qdata.begin(),
479 upper_bound( qdata.begin(), qdata.end(), QData( 10.0 /(min_length_edge*min_length_edge), 0.0 ) ) ) ) );
480 }
481
482
483 inline Int4 put_automatic_edge_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
484 {
485 if( search_level == ConographQuickSearch ) return MaxPeakNum * (MaxPeakNum+1) / 3;
486 return MaxPeakNum * (MaxPeakNum+1) / 2;
487 }
488
489
490 inline Int4 put_automatic_node_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
491 {
492 if( search_level == ConographQuickSearch ) return min(MaxPeakNum * (MaxPeakNum+1) * MaxPeakNum * (MaxPeakNum+1) / 9, 64000);
493 return min(MaxPeakNum * (MaxPeakNum+1) * (MaxPeakNum+2) * 2 / 3, 32000);
494 }
495
496
497 inline pair<Double, Double> put_automatic_unit_cell_volume(const vector<QData>& qData, const Int4& MaxPeakNum)
498 {
499 Double ans = 1.0/put_maximum_counitcell_volume(qData, 20);
500 return pair<Double, Double>(max(5.0, ans), ans*30.0);
501 }
502
503
504 ZErrorMessage ControlParam::setAutomaticallyComputedParam(const vector<QData>& qData)
505 {
506 // Set the automatically calculated number of peaks to utilize for indexing.
507 if( this->putNumberOfReflectionsForFigureOfMerit() > (Int4)qData.size() )
508 {
509 this->setNumberOfReflectionsForFigureOfMerit(qData.size());
510 ZLOG_INFO( "\"" + ControlParam::putNumberOfReflectionsForFigureOfMeritLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
511 }
512
513 if( this->putStrMaxPeakNum()=="AUTO" )
514 {
515 MaxPeakNum = put_automatic_peak_num( this->putSearchLevel(), qData, NumRefFigureOfMerit, MinLatticePointDistance);
516 ZLOG_INFO( "<" + str_MaxPeakNum_Data.first.putLabel() + "> is set to " + num2str<Int4>(MaxPeakNum) + "\n" );
517 }
518 else
519 {
520 if( this->putMaxPeakNum() > (Int4)qData.size() )
521 {
522 this->setMaxPeakNum(qData.size());
523 ZLOG_INFO( "\"" + str_MaxPeakNum_Data.first.putLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
524 }
525 }
526
527 if( str_MaxEdgeNum == "AUTO" )
528 {
529 MaxEdgeNum = put_automatic_edge_num( this->putSearchLevel(), this->putMaxPeakNum() );
530 ZLOG_INFO( "<" + str_MaxEdgeNum_Data.first.putLabel() + "> is set to " + num2str(MaxEdgeNum) + ".\n" );
531 }
532
533 if( str_MaxNodeNum == "AUTO" )
534 {
535 MaxNodeNum = put_automatic_node_num( this->putSearchLevel(), this->putMaxPeakNum() );
536 ZLOG_INFO( "<" + str_MaxNodeNum_Data.first.putLabel() + "> is set to " + num2str(MaxNodeNum) + ".\n" );
537 }
538
539 if( str_MinUnitCellVolume == "AUTO" || str_MaxUnitCellVolume == "AUTO" )
540 {
541 pair<Double, Double> unit_cell_vol_range = put_automatic_unit_cell_volume(qData, this->putMaxPeakNum());
542 if( str_MinUnitCellVolume == "AUTO" )
543 {
544 MinUnitCellVolume = unit_cell_vol_range.first;
545 ZLOG_INFO( "<" + putMinUnitCellVolumeLabel() + "> is set to " + num2str(MinUnitCellVolume) + ".\n" );
546 }
547 if( str_MaxUnitCellVolume == "AUTO" )
548 {
549 MaxUnitCellVolume = unit_cell_vol_range.second;
550 ZLOG_INFO( "<" + putMaxUnitCellVolumeLabel() + "> is set to " + num2str(MaxUnitCellVolume) + ".\n" );
551 }
552 }
553
554 if( str_MaxNumPeakInRange == "AUTO" )
555 {
556 MaxNumPeakInRange = ifloor( pow(this->putNumberOfReflectionsForFigureOfMerit(), 1.6) );
557 ZLOG_INFO( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MaxNumPeakInRange) + ".\n" );
558 }
559
560 if( str_MinNumPeakInRange == "AUTO" )
561 {
562 MinNumPeakInRange = this->putNumberOfReflectionsForFigureOfMerit() * 3 / 5;
563 ZLOG_INFO( "<" + str_MinNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MinNumPeakInRange) + ".\n" );
564 }
565
566 if( MaxNumPeakInRange < MinNumPeakInRange )
567 {
568 return ZErrorMessage("<" + str_MinNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MinNumPeakInRange) +'\n'
569 + str_MaxNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MaxNumPeakInRange) +'\n'
570 + "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">", __FILE__, __LINE__, __FUNCTION__);
571 }
572
573 return ZErrorMessage();
574 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26