Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Conograph/trunk/src/lattice_symmetry/LatticeFigureOfMeritToDisplay.hh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (show annotations) (download) (as text)
Mon Jul 7 02:35:51 2014 UTC (9 years, 8 months ago) by rtomiyasu
File MIME type: text/x-c++hdr
File size: 9686 byte(s)
Source codes of version 0.9.99
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 #ifndef LatticeFigureOfMeritToDisplay_HH_
28 #define LatticeFigureOfMeritToDisplay_HH_
29
30 #include <map>
31 #include "LatticeFigureOfMeritZeroShift.hh"
32 #include "../utility_data_structure/range.hh"
33
34
35 // Class for outputting information about a lattice in IGOR file.
36 class LatticeFigureOfMeritToDisplay
37 {
38 private:
39 LatticeFigureOfMeritZeroShift m_latfom;
40
41 vector<QData> m_qdata;
42 vector< multimap<Double, vector<HKL_Q>::const_iterator> > m_associated_hkl_tray;
43 vector<HKL_Q> m_cal_hkl_tray;
44
45 // The size of the following arrays equals zero or m_figures_of_merit.m_num_ref_figure_of_merit.
46 vector< VecDat3<Int4> > m_hkl_to_fit;
47 vector<bool> m_fix_or_fit_flag; // 0:fix, 1:fit.
48
49 // for GUI
50 bool m_showsTicks;
51
52 public:
53 void putPeakPosToFit(const ControlParam& cdata, Vec_DP& cal_q_tray, Vec_DP& cal_pos_tray) const;
54 void putStandardMillerIndicesToFit(vector< VecDat3<Int4> >& hkl_to_fit,
55 vector<bool>& fix_or_fit_flag) const;
56
57 LatticeFigureOfMeritToDisplay();
58 ~LatticeFigureOfMeritToDisplay(){};
59
60 inline const eBravaisType& enumBravaisType() const { return m_latfom.enumBravaisType(); };
61 inline const LatticeFigureOfMeritZeroShift& putLatticeFigureOfMerit() const { return m_latfom; };
62 inline const vector<HKL_Q>& putCalMillerIndices() const { return m_cal_hkl_tray; };
63 inline const vector< multimap<Double, vector<HKL_Q>::const_iterator> >& putAssociatedMillerIndices() const { return m_associated_hkl_tray; };
64
65 // axis1: axis of the argument lattice constants for Monoclinic(C) or Orthorhombic(C).
66 // axis2: axis of the argument lattice constants for Rhombohedral.
67 inline ZErrorMessage setLatticeConstantsDegree(const eBravaisType& ecys,
68 const eABCaxis& axis1,
69 const eRHaxis& axis2,
70 const VecDat3<Double>& length_axis,
71 const VecDat3<Double>& angle_axis) { return m_latfom.setLatticeConstantsDegree(BravaisType(ecys, axis1, axis2), length_axis, angle_axis); };
72 inline ZErrorMessage setPeakShiftParamDegree(const ePeakShiftFunctionType& type,
73 const Double& wave_length,
74 const vector<ZParawError>& peak_shift_param_deg, // The errors are not used in this method.
75 const PeakPosData& pdata);
76 inline void reduceLatticeConstants();
77
78 inline void putOptimizedLatticeConstantsDegree(const eABCaxis& axis1,
79 const eRHaxis& axis2,
80 VecDat3<Double>& length_axis,
81 VecDat3<Double>& angle_axis) { m_latfom.putOptimizedLatticeConstantsDegree(axis1, axis2, length_axis, angle_axis); };
82
83 // axis1: axis of the argument lattice constants for Monoclinic(C) or Orthorhombic(C).
84 // axis2: axis of the argument lattice constants for Rhombohedral.
85 inline void putReducedLatticeConstantsDegree(const eABCaxis& axis1,
86 const eRHaxis& axis2,
87 VecDat3<Double>& length_axis,
88 VecDat3<Double>& angle_axis) { m_latfom.putReducedLatticeConstantsDegree(axis1, axis2, length_axis, angle_axis); };
89
90 inline const Double& putWaveLength() const { return m_latfom.putWaveLength(); };
91 inline const ePeakShiftFunctionType& putPeakShiftFunctionType() const { return m_latfom.putPeakShiftFunctionType(); };
92 inline vector<ZParawError> putPeakShiftParamDegree() const { return m_latfom.putPeakShiftParamDegree(); };
93
94 inline const vector<QData>& putQDataModifiedWithNewPeakShiftParam() const { return m_qdata; };
95
96 // Return false if Qdata is not set or
97 // the number of unindexed reflections is larger max_num_false_peak.
98 inline void setFigureOfMerit(const Int4& num_ref_figure_of_merit){ m_latfom.setFigureOfMerit(num_ref_figure_of_merit, m_qdata); };
99
100 // Resets m_associated_hkl_tray and q-values in m_cal_hkl_tray.
101 void resetQValuesInRange(const Int4& num_fit_data);
102 // Resets m_associated_hkl_tray and m_cal_hkl_tray.
103 void resetMillerIndicesInRange(const Int4& num_fit_data);
104 // Resets m_hkl_to_fit and m_fix_or_fit_flag.
105 void resetMillerIndicesToFit() { putStandardMillerIndicesToFit(m_hkl_to_fit, m_fix_or_fit_flag); };
106
107 inline ZErrorMessage setFittingIDs(const vector<bool>& arg);
108 inline const vector<bool>& putFittingIDs() const { return m_fix_or_fit_flag; };
109 inline ZErrorMessage setMillerIndicesToFit(const vector< VecDat3<Int4> >& arg);
110 inline const vector< VecDat3<Int4> >& putMillerIndicesToFit() const { return m_hkl_to_fit; };
111
112 // Return peak positions for this lattice candidate.
113 void putCalculatedPeakPosInRange(const ControlParam& cdata, Vec_DP& cal_pos_tray) const;
114
115 // Returned value
116 // > 1 : Optimization has succeeded at least twice. (The members m_hkl_to_fit and m_fix_or_fit_flag are changed.)
117 // > 0 : Optimization has succeeded. (Lattice constants are changed.)
118 // 0 : Optimization has failed.
119 Int4 fitLatticeParameter(const PeakPosData& pdata, const vector<etype_ID>& fitflag,
120 const Int4& Max_ITNUM,
121 const Double& limiter);
122
123 // Output indexing results.
124 void printIndexingResult(const ControlParam& cdata,
125 const PeakPosData& pdata,
126 const Int4& label_start0,
127 ostream* os) const;
128
129 // For GUI.
130 const vector<bool> &getref_m_fix_or_fit_flag() const {return m_fix_or_fit_flag;}
131 vector<bool> &getref_m_fix_or_fit_flag() {return m_fix_or_fit_flag;}
132 const vector<VecDat3<Int4> > &getref_m_hkl_to_fit() const {return m_hkl_to_fit;}
133 vector<VecDat3<Int4> > &getref_m_hkl_to_fit() {return m_hkl_to_fit;}
134 const LatticeFigureOfMeritZeroShift &getref_m_latfom() const {return m_latfom;}
135 LatticeFigureOfMeritZeroShift &getref_m_latfom() {return m_latfom;}
136 const vector<QData> &getref_m_qdata() const {return m_qdata;}
137 vector<QData> &getref_m_qdata() {return m_qdata;}
138 const vector< multimap<Double, vector<HKL_Q>::const_iterator> > &getref_m_associated_hkl_tray() const {return m_associated_hkl_tray;}
139 vector< multimap<Double, vector<HKL_Q>::const_iterator> > &getref_m_associated_hkl_tray() {return m_associated_hkl_tray;}
140 const vector<HKL_Q> &getref_m_cal_hkl_tray() const {return m_cal_hkl_tray;}
141 vector<HKL_Q> &getref_m_cal_hkl_tray() {return m_cal_hkl_tray;}
142 const bool &getref_m_showsTicks() const {return m_showsTicks;}
143 bool &getref_m_showsTicks() {return m_showsTicks;}
144 };
145
146
147 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setFittingIDs(const vector<bool>& arg)
148 {
149 if( arg.size() != m_associated_hkl_tray.size() )
150 {
151 return ZErrorMessage(ZErrorArgmentSize, __FILE__, __LINE__, __FUNCTION__);
152 }
153 m_fix_or_fit_flag = arg;
154 return ZErrorMessage();
155 }
156
157 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setMillerIndicesToFit(const vector< VecDat3<Int4> >& arg)
158 {
159 if( arg.size() != m_associated_hkl_tray.size() )
160 {
161 return ZErrorMessage(ZErrorArgmentSize, __FILE__, __LINE__, __FUNCTION__);
162 }
163 m_hkl_to_fit = arg;
164 return ZErrorMessage();
165 };
166
167
168 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setPeakShiftParamDegree(
169 const ePeakShiftFunctionType& type,
170 const Double& wave_length,
171 const vector<ZParawError>& peak_shift_param_deg,
172 const PeakPosData& pdata)
173 {
174 static const Double RadDeg = PI() / 180.0;
175
176 vector<ZParawError> peak_shift_param_rad = peak_shift_param_deg;
177 for(vector<ZParawError>::iterator it=peak_shift_param_rad.begin(); it<peak_shift_param_rad.end(); it++)
178 {
179 *it *= RadDeg;
180 }
181 return m_latfom.setPeakShiftParamRadian(VCData::putPeakQData(), type, wave_length, peak_shift_param_rad, pdata,
182 VCData::putPeakQData().size(), m_qdata);
183 };
184
185 inline void LatticeFigureOfMeritToDisplay::reduceLatticeConstants()
186 {
187 NRMat<Int4> trans_mat;
188 m_latfom.reduceLatticeConstants(trans_mat);
189
190 for(vector<HKL_Q>::iterator it=m_cal_hkl_tray.begin(); it<m_cal_hkl_tray.end(); it++)
191 {
192 it->setHKL( product_hkl(it->HKL(), trans_mat) );
193 }
194
195 for(vector< VecDat3<Int4> >::iterator it=m_hkl_to_fit.begin(); it<m_hkl_to_fit.end(); it++)
196 {
197 *it = product_hkl(*it, trans_mat);
198 }
199 };
200
201 #endif /*LatticeFigureOfMeritToDisplay_HH_*/

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