Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (hide annotations) (download) (as text)
Fri Apr 26 08:50:24 2013 UTC (10 years, 10 months ago) by rtomiyasu
File MIME type: text/x-c++src
File size: 26477 byte(s)
Modifications for GUI development.

1 rtomiyasu 3 /*
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 rtomiyasu 9 RWParamProperty(BOOLFLAG, "OutputOrthorhombicC"),
66 rtomiyasu 3 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 rtomiyasu 9 RWParamProperty(DARRAY, "ZeroPointShiftParameter"),
108 rtomiyasu 3 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     const pair<RWParamProperty, RWParamData<string> > ControlParam::MonoBaseAxis_Data(
159 rtomiyasu 9 RWParamProperty(STRVALUE, "AxisForMonoclinicSymmetry"),
160 rtomiyasu 3 RWParamData<string>("B", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
161     const pair<RWParamProperty, RWParamData<string> > ControlParam::RhomAxis_Data(
162     RWParamProperty(STRVALUE, "AxisForRhombohedralSymmetry"),
163     RWParamData<string>("Hexagonal", REPLACE_NONE<string>, NULL, "", NULL, "", -1, -1) );
164     const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdNormM_Data(
165     RWParamProperty(DVALUE, "ThresholdOnNormM"),
166     RWParamData<Double>(1.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
167     const pair<RWParamProperty, RWParamData<Double> > ControlParam::ThresholdRevM_Data(
168     RWParamProperty(DVALUE, "ThresholdOnRevM"),
169     RWParamData<Double>(0.9, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
170     const pair<RWParamProperty, RWParamData<Double> > ControlParam::MinLatticePointDistance_Data(
171     RWParamProperty(DVALUE, "MinDistanceBetweenLatticePoints"),
172     RWParamData<Double>(2.0, REPLACE_NONE<Double>, GE<Double>, 0.0, NULL, MAX_DP(), -1, -1) ); // 0 <= param < INF.
173    
174    
175     ControlParam::ControlParam()
176 rtomiyasu 6 :
177     #ifdef _OPENMP
178     NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
179 rtomiyasu 16 RWParamData<Int4>(max(1, omp_get_num_procs()-1), REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
180 rtomiyasu 6 #else
181     NumCores_Data(RWParamProperty(INT4VALUE, "NumberOfThreadsToUse"),
182     RWParamData<Int4>(1, REPLACE_MAX_THREAD, GE<Int4>, 1, NULL, MAX_INT(), -1, -1) ),
183     #endif
184 rtomiyasu 16 ReadConfigurationParameters(true),
185     IsADorTOF(IsAngleDispersion_Data.second.initial_value),
186 rtomiyasu 3 ConvParam(ConvParam_Data.second.initial_value),
187     PeakShiftParam(PeakShiftParam_Data.second.initial_value),
188     WlengthX(WlengthX_Data.second.initial_value),
189     SearchLevel(SearchLevel_Data.second.initial_value),
190     MaxPeakNum(0),
191     MaxEdgeNum(0),
192     MaxNodeNum(0),
193     MinUnitCellVolume(0.0),
194     MaxUnitCellVolume(0.0),
195     CVForLinearSum(CVForLinearSum_Data.second.initial_value),
196     NumRefFigureOfMerit(NumRefFigureOfMerit_Data.second.initial_value),
197     MaxNumPeakInRange(0),
198     MinNumPeakInRange(0),
199     MinUnitCellEdgeABC(MinUnitCellEdgeABC_Data.second.initial_value),
200     MaxUnitCellEdgeABC(MaxUnitCellEdgeABC_Data.second.initial_value),
201     MinFOM(MinFOM_Data.second.initial_value),
202     Resol(Resol_Data.second.initial_value),
203     NumCores(NumCores_Data.second.initial_value),
204     MonoBaseAxis(MonoBaseAxis_Data.second.initial_value),
205     RhomAxis(RhomAxis_Data.second.initial_value),
206     ThresholdNormM(ThresholdNormM_Data.second.initial_value),
207     ThresholdRevM(ThresholdRevM_Data.second.initial_value),
208     MinLatticePointDistance(MinLatticePointDistance_Data.second.initial_value),
209     str_MaxPeakNum(str_MaxPeakNum_Data.second.initial_value),
210     str_MaxEdgeNum(str_MaxEdgeNum_Data.second.initial_value),
211     str_MaxNodeNum(str_MaxNodeNum_Data.second.initial_value),
212     str_MinUnitCellVolume(str_MinUnitCellVolume_Data.second.initial_value),
213     str_MaxUnitCellVolume(str_MaxUnitCellVolume_Data.second.initial_value),
214     str_MaxNumPeakInRange(str_MaxNumPeakInRange_Data.second.initial_value),
215     str_MinNumPeakInRange(str_MinNumPeakInRange_Data.second.initial_value)
216     {
217     for(Int4 i=0; i<NUM_LS; i++)
218     {
219     OutputSymmetry[i] = OutputSymmetry_Data[i].second.initial_value;
220     }
221     }
222    
223    
224     ControlParam::~ControlParam()
225     {
226     }
227    
228    
229     const string& ControlParam::putTagLabel() const
230     {
231     static const string label = "ConographParameters";
232     return label;
233     }
234    
235    
236     ZErrorMessageReadingFile ControlParam::readFile(const string& filename, const string& file_label)
237     {
238     ZErrorMessageReadingFile zerr = I_ReadData::readFile(filename, file_label);
239     if( IsAngleDispersion() ) ConvParam.clear();
240     else PeakShiftParam.clear();
241    
242     if( zerr.putErrorType() != ZErrorNoError ) return zerr;
243     if( str_MaxPeakNum!="AUTO" )
244     {
245     if( str_MaxPeakNum=="MAX" )
246     {
247     MaxPeakNum = numeric_limits<Int4>::max();
248     }
249     else
250     {
251     istringstream iss( str_MaxPeakNum );
252     iss >> MaxPeakNum;
253     if( iss.fail() ) return ZErrorMessageReadingFile( filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxPeakNum_Data.first.putLabel() + ">:"+str_MaxPeakNum, __FILE__, __LINE__, __FUNCTION__) );
254     if( MaxPeakNum < 3 )
255     {
256     return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
257     }
258     else if( MaxPeakNum > 2000 )
259     {
260     return ZErrorMessageReadingFile( filename, ZErrorMessage("<"+ str_MaxPeakNum_Data.first.putLabel() + "> is too large: "+num2str<Int4>(MaxPeakNum), __FILE__, __LINE__, __FUNCTION__) );
261     }
262     }
263     }
264    
265     if( str_MaxEdgeNum != "AUTO" )
266     {
267     if( str_MaxEdgeNum=="MAX" )
268     {
269     MaxEdgeNum = numeric_limits<Int4>::max();
270     }
271     else
272     {
273     istringstream iss( str_MaxEdgeNum );
274     iss >> MaxEdgeNum;
275     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxEdgeNum_Data.first.putLabel() + ">: "+str_MaxEdgeNum, __FILE__, __LINE__, __FUNCTION__) );
276     if( MaxEdgeNum < 1 )
277     {
278     return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxEdgeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxEdgeNum), __FILE__, __LINE__, __FUNCTION__) );
279     }
280     }
281     }
282    
283     if( str_MaxNodeNum != "AUTO" )
284     {
285     if( str_MaxNodeNum=="MAX" )
286     {
287     MaxNodeNum = numeric_limits<Int4>::max();
288     }
289     else
290     {
291     istringstream iss( str_MaxNodeNum );
292     iss >> MaxNodeNum;
293     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string in <" + str_MaxNodeNum_Data.first.putLabel() + "> is not replaced: "+str_MaxNodeNum, __FILE__, __LINE__, __FUNCTION__) );
294     if( MaxNodeNum < 1 )
295     {
296     return ZErrorMessageReadingFile(filename, nerror_arg("<"+ str_MaxNodeNum_Data.first.putLabel() + "> is too small: "+num2str<Int4>(MaxNodeNum), __FILE__, __LINE__, __FUNCTION__) );
297     }
298     }
299     }
300    
301     if( str_MinUnitCellVolume != "AUTO" )
302     {
303     istringstream iss( str_MinUnitCellVolume );
304     iss >> MinUnitCellVolume;
305     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMinUnitCellVolumeLabel() + ">: "+str_MinUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
306     if( MinUnitCellVolume < 1.0 )
307     {
308     return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMinUnitCellVolumeLabel() + "> is less than 1: "+num2str<Double>(MinUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
309     }
310     }
311    
312     if( str_MaxUnitCellVolume != "AUTO" )
313     {
314     istringstream iss( str_MaxUnitCellVolume );
315     iss >> MaxUnitCellVolume;
316     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + putMaxUnitCellVolumeLabel() + ">: "+str_MaxUnitCellVolume, __FILE__, __LINE__, __FUNCTION__) );
317     if( MaxUnitCellVolume <= MinUnitCellVolume )
318     {
319     return ZErrorMessageReadingFile(filename, nerror_arg("<"+ putMaxUnitCellVolumeLabel() + "> is not larger than <"+ putMinUnitCellVolumeLabel() + "> : "+num2str<Double>(MaxUnitCellVolume), __FILE__, __LINE__, __FUNCTION__) );
320     }
321     }
322    
323     if( str_MaxNumPeakInRange != "AUTO" )
324     {
325     if( str_MaxNumPeakInRange =="MAX" )
326     {
327     MaxNumPeakInRange = numeric_limits<Int4>::max();
328     }
329     else
330     {
331     istringstream iss( str_MaxNumPeakInRange );
332     iss >> MaxNumPeakInRange;
333     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MaxNumPeakInRange_Data.first.putLabel() + ">: "+str_MaxNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
334     if( MaxNumPeakInRange < 1 )
335     {
336     return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MaxNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
337     }
338     }
339     }
340    
341     if( str_MinNumPeakInRange != "AUTO" )
342     {
343     istringstream iss( str_MinNumPeakInRange );
344     iss >> MinNumPeakInRange;
345     if( iss.fail() ) return ZErrorMessageReadingFile(filename, ZErrorMessage(ZErrorFileFormatBroken, "The string cannot be replaced for <" + str_MinNumPeakInRange_Data.first.putLabel() + ">: "+str_MinNumPeakInRange, __FILE__, __LINE__, __FUNCTION__) );
346     if( MinNumPeakInRange < 1 )
347     {
348     return ZErrorMessageReadingFile(filename, ZErrorMessage("<"+ str_MinNumPeakInRange_Data.first.putLabel() + "> is less than 1: "+num2str<Double>(MinNumPeakInRange), __FILE__, __LINE__, __FUNCTION__) );
349     }
350    
351     if( str_MaxNumPeakInRange != "AUTO" && MaxNumPeakInRange < MinNumPeakInRange )
352     {
353     return ZErrorMessageReadingFile(filename, ZErrorMessage( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">",
354     __FILE__, __LINE__, __FUNCTION__) );
355     }
356     }
357    
358     return ZErrorMessageReadingFile();
359     }
360    
361    
362    
363     void ControlParam::setData(const RWParamProperty& parent_prop,
364     vector<RWParam_void>& tray)
365     {
366     if( parent_prop.putLabel() == this->putTagLabel() )
367     {
368     tray.push_back( RWParam_void(IsAngleDispersion_Data, &IsADorTOF) );
369     for(Int4 i=0; i<NUM_LS; i++)
370     {
371     tray.push_back( RWParam_void(OutputSymmetry_Data[i], &OutputSymmetry[i]) );
372     }
373     tray.push_back( RWParam_void(ConvParam_Data, &ConvParam) );
374     tray.push_back( RWParam_void(PeakShiftParam_Data, &PeakShiftParam) );
375     tray.push_back( RWParam_void(WlengthX_Data, &WlengthX) );
376     tray.push_back( RWParam_void(Resol_Data, &Resol) );
377     tray.push_back( RWParam_void(CVForLinearSum_Data, &CVForLinearSum) );
378     tray.push_back( RWParam_void(str_MaxPeakNum_Data, &str_MaxPeakNum) );
379     tray.push_back( RWParam_void(str_MaxEdgeNum_Data, &str_MaxEdgeNum) );
380     tray.push_back( RWParam_void(str_MaxNodeNum_Data, &str_MaxNodeNum) );
381     tray.push_back( RWParam_void(str_MinUnitCellVolume_Data, &str_MinUnitCellVolume) );
382     tray.push_back( RWParam_void(str_MaxUnitCellVolume_Data, &str_MaxUnitCellVolume) );
383    
384     tray.push_back( RWParam_void(MinUnitCellEdgeABC_Data, &MinUnitCellEdgeABC) );
385     tray.push_back( RWParam_void(MaxUnitCellEdgeABC_Data, &MaxUnitCellEdgeABC) );
386     tray.push_back( RWParam_void(MinFOM_Data, &MinFOM) );
387     tray.push_back( RWParam_void(str_MaxNumPeakInRange_Data, &str_MaxNumPeakInRange) );
388     tray.push_back( RWParam_void(str_MinNumPeakInRange_Data, &str_MinNumPeakInRange) );
389     tray.push_back( RWParam_void(NumRefFigureOfMerit_Data, &NumRefFigureOfMerit) );
390    
391     tray.push_back( RWParam_void(SearchLevel_Data, &SearchLevel) );
392 rtomiyasu 16
393     if( ReadConfigurationParameters )
394     {
395     tray.push_back( RWParam_void(NumCores_Data, &NumCores) );
396     tray.push_back( RWParam_void(MonoBaseAxis_Data, &MonoBaseAxis) );
397     tray.push_back( RWParam_void(RhomAxis_Data, &RhomAxis) );
398     tray.push_back( RWParam_void(ThresholdNormM_Data, &ThresholdNormM) );
399     tray.push_back( RWParam_void(ThresholdRevM_Data, &ThresholdRevM) );
400     tray.push_back( RWParam_void(MinLatticePointDistance_Data, &MinLatticePointDistance) );
401     }
402 rtomiyasu 3 }
403     }
404    
405    
406     ZErrorMessage ControlParam::checkData(const RWParam_void& param) const
407     {
408     const string Label = param.putLabel();
409     if( IsEqualTag(param.putProperty(), ConvParam_Data.first ) )
410     {
411     if( IsADorTOF )
412     {
413     return ZErrorMessage();
414     }
415     }
416     else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
417     || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
418     {
419     if( !IsADorTOF )
420     {
421     return ZErrorMessage();
422     }
423     }
424     else if( IsEqualTag(param.putProperty(), MonoBaseAxis_Data.first) )
425     {
426     if( find_key(ABCaxisLabel, MonoBaseAxis) == eABCaxis(-1) )
427     {
428     return nerror_out_range(param.putLabel(), MonoBaseAxis, __FILE__, __LINE__, __FUNCTION__ );
429     }
430     else return ZErrorMessage();
431     }
432     else if( IsEqualTag(param.putProperty(), RhomAxis_Data.first) )
433     {
434     if( find_key(RHaxisLabel, RhomAxis) == eRHaxis(-1) )
435     {
436     return nerror_out_range(param.putLabel(), RhomAxis, __FILE__, __LINE__, __FUNCTION__ );
437     }
438     else return ZErrorMessage();
439     }
440     return I_ReadData::checkData(param);
441     }
442    
443    
444    
445     ZErrorMessage ControlParam::checkIfDataAreSet(const RWParam_void& param, const Int4& num) const
446     {
447     const string Label = param.putLabel();
448     if( IsEqualTag(param.putProperty(), ConvParam_Data.first) )
449     {
450     if( IsADorTOF )
451     {
452     return ZErrorMessage();
453     }
454     }
455     else if( IsEqualTag(param.putProperty(), PeakShiftParam_Data.first)
456     || IsEqualTag(param.putProperty(), WlengthX_Data.first) )
457     {
458     if( !IsADorTOF )
459     {
460     return ZErrorMessage();
461     }
462     }
463     else if( IsEqualTag(param.putProperty(), MaxUnitCellEdgeABC_Data.first) )
464     {
465     if( MaxUnitCellEdgeABC < MinUnitCellEdgeABC )
466     {
467     return ZErrorMessage( "<" + MaxUnitCellEdgeABC_Data.first.putLabel() + "> is less than <" + MinUnitCellEdgeABC_Data.first.putLabel() + ">",
468     __FILE__, __LINE__, __FUNCTION__);
469     }
470     }
471    
472     return I_ReadData::checkIfDataAreSet(param, num);
473     }
474    
475    
476     inline Int4 put_automatic_peak_num(const eConographAnalysisMode& search_level, const vector<QData>& qdata,
477     const Int4& num_ref_figure_of_merit, const Double& min_length_edge)
478     {
479     assert( num_ref_figure_of_merit <= (Int4)qdata.size() );
480     if( qdata.empty() ) return 0;
481     return max(num_ref_figure_of_merit, min(48, (Int4)distance( qdata.begin(),
482     upper_bound( qdata.begin(), qdata.end(), QData( 10.0 /(min_length_edge*min_length_edge), 0.0 ) ) ) ) );
483     }
484    
485    
486     inline Int4 put_automatic_edge_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
487     {
488     if( search_level == ConographQuickSearch ) return MaxPeakNum * (MaxPeakNum+1) / 3;
489     return MaxPeakNum * (MaxPeakNum+1) / 2;
490     }
491    
492    
493     inline Int4 put_automatic_node_num(const eConographAnalysisMode& search_level, const Int4& MaxPeakNum)
494     {
495     if( search_level == ConographQuickSearch ) return min(MaxPeakNum * (MaxPeakNum+1) * MaxPeakNum * (MaxPeakNum+1) / 9, 64000);
496     return min(MaxPeakNum * (MaxPeakNum+1) * (MaxPeakNum+2) * 2 / 3, 32000);
497     }
498    
499    
500     inline pair<Double, Double> put_automatic_unit_cell_volume(const vector<QData>& qData, const Int4& MaxPeakNum)
501     {
502     Double ans = 1.0/put_maximum_counitcell_volume(qData, 20);
503     return pair<Double, Double>(max(5.0, ans), ans*30.0);
504     }
505    
506    
507     ZErrorMessage ControlParam::setAutomaticallyComputedParam(const vector<QData>& qData)
508     {
509     // Set the automatically calculated number of peaks to utilize for indexing.
510     if( this->putNumberOfReflectionsForFigureOfMerit() > (Int4)qData.size() )
511     {
512     this->setNumberOfReflectionsForFigureOfMerit(qData.size());
513     ZLOG_INFO( "\"" + ControlParam::putNumberOfReflectionsForFigureOfMeritLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
514     }
515    
516     if( this->putStrMaxPeakNum()=="AUTO" )
517     {
518     MaxPeakNum = put_automatic_peak_num( this->putSearchLevel(), qData, NumRefFigureOfMerit, MinLatticePointDistance);
519     ZLOG_INFO( "<" + str_MaxPeakNum_Data.first.putLabel() + "> is set to " + num2str<Int4>(MaxPeakNum) + "\n" );
520     }
521     else
522     {
523     if( this->putMaxPeakNum() > (Int4)qData.size() )
524     {
525     this->setMaxPeakNum(qData.size());
526     ZLOG_INFO( "\"" + str_MaxPeakNum_Data.first.putLabel() + "\" is more than the number of peaks. It is replaced by the number of peaks.\n" );
527     }
528     }
529    
530     if( str_MaxEdgeNum == "AUTO" )
531     {
532     MaxEdgeNum = put_automatic_edge_num( this->putSearchLevel(), this->putMaxPeakNum() );
533     ZLOG_INFO( "<" + str_MaxEdgeNum_Data.first.putLabel() + "> is set to " + num2str(MaxEdgeNum) + ".\n" );
534     }
535    
536     if( str_MaxNodeNum == "AUTO" )
537     {
538     MaxNodeNum = put_automatic_node_num( this->putSearchLevel(), this->putMaxPeakNum() );
539     ZLOG_INFO( "<" + str_MaxNodeNum_Data.first.putLabel() + "> is set to " + num2str(MaxNodeNum) + ".\n" );
540     }
541    
542     if( str_MinUnitCellVolume == "AUTO" || str_MaxUnitCellVolume == "AUTO" )
543     {
544     pair<Double, Double> unit_cell_vol_range = put_automatic_unit_cell_volume(qData, this->putMaxPeakNum());
545     if( str_MinUnitCellVolume == "AUTO" )
546     {
547     MinUnitCellVolume = unit_cell_vol_range.first;
548     ZLOG_INFO( "<" + putMinUnitCellVolumeLabel() + "> is set to " + num2str(MinUnitCellVolume) + ".\n" );
549     }
550     if( str_MaxUnitCellVolume == "AUTO" )
551     {
552     MaxUnitCellVolume = unit_cell_vol_range.second;
553     ZLOG_INFO( "<" + putMaxUnitCellVolumeLabel() + "> is set to " + num2str(MaxUnitCellVolume) + ".\n" );
554     }
555     }
556    
557     if( str_MaxNumPeakInRange == "AUTO" )
558     {
559 rtomiyasu 16 MaxNumPeakInRange = ifloor( pow(this->putNumberOfReflectionsForFigureOfMerit(), 1.62) );
560 rtomiyasu 3 ZLOG_INFO( "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MaxNumPeakInRange) + ".\n" );
561     }
562    
563     if( str_MinNumPeakInRange == "AUTO" )
564     {
565     MinNumPeakInRange = this->putNumberOfReflectionsForFigureOfMerit() * 3 / 5;
566     ZLOG_INFO( "<" + str_MinNumPeakInRange_Data.first.putLabel() + "> is set to " + num2str(MinNumPeakInRange) + ".\n" );
567     }
568    
569     if( MaxNumPeakInRange < MinNumPeakInRange )
570     {
571     return ZErrorMessage("<" + str_MinNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MinNumPeakInRange) +'\n'
572     + str_MaxNumPeakInRange_Data.first.putLabel() + "> : " + num2str<Int4>(MaxNumPeakInRange) +'\n'
573     + "<" + str_MaxNumPeakInRange_Data.first.putLabel() + "> is less than <" + str_MinNumPeakInRange_Data.first.putLabel() + ">", __FILE__, __LINE__, __FUNCTION__);
574     }
575    
576     return ZErrorMessage();
577     }

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