| 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 |
#include <iostream> |
| 28 |
#include "p_out_indexing.hh" |
| 29 |
#include "ControlParam.hh" |
| 30 |
#include "PeakPosData.hh" |
| 31 |
#include "lattice_symmetry/LatticeFigureOfMeritToCheckSymmetry.hh" |
| 32 |
#include "lattice_symmetry/LatticeFigureOfMeritToDisplay.hh" |
| 33 |
#include "utility_func/covar_matrix.hh" |
| 34 |
#include "utility_func/zmath.hh" |
| 35 |
#include "utility_lattice_reduction/matrix_4by4.hh" |
| 36 |
#include "utility_data_structure/Bud.hh" |
| 37 |
#include "utility_data_structure/Node3.hh" |
| 38 |
#include "utility_data_structure/qdata.hh" |
| 39 |
#include "utility_data_structure/SymMatWCovar.hh" |
| 40 |
#include "lattice_symmetry/OutputInfo.hh" |
| 41 |
|
| 42 |
|
| 43 |
void printQdata(const vector<QData>& qdata, |
| 44 |
ostream* os) |
| 45 |
{ |
| 46 |
os->setf(ios::right); |
| 47 |
os->setf(ios::uppercase); |
| 48 |
os->setf(ios::showpoint); |
| 49 |
os->setf(ios::scientific); |
| 50 |
|
| 51 |
*os << "IGOR" << endl; |
| 52 |
*os << "WAVES/O index, Q, sqrt_root_of_variance_of_Q" << endl; |
| 53 |
*os << "BEGIN" << endl; |
| 54 |
|
| 55 |
const Int4 isize = qdata.size(); |
| 56 |
|
| 57 |
for (Int4 k=0; k<isize; k++) |
| 58 |
{ |
| 59 |
os->width(5); |
| 60 |
*os << k+1; |
| 61 |
|
| 62 |
os->width(15); |
| 63 |
*os << qdata[k].q; |
| 64 |
|
| 65 |
os->width(15); |
| 66 |
*os << sqrt(qdata[k].q_var); |
| 67 |
|
| 68 |
*os << endl; |
| 69 |
} |
| 70 |
*os << "END" << endl; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
void print_bud_data(const vector<Bud>& bud_basket, |
| 76 |
const Vec_BOOL& root_flag, |
| 77 |
const vector< vector<Int4> >& leftbr_tray, |
| 78 |
const vector< vector<Int4> >& rightbr_tray, |
| 79 |
const vector< vector<Int4> >& root_leftbr, |
| 80 |
const vector< vector<Int4> >& root_rightbr, |
| 81 |
const string& fname) |
| 82 |
{ |
| 83 |
ofstream ofs(fname.c_str()); |
| 84 |
ostream *os; |
| 85 |
os = &ofs; |
| 86 |
|
| 87 |
*os << "IGOR" << endl; |
| 88 |
*os << "WAVES/O "; |
| 89 |
|
| 90 |
*os << "Number, K1, K2, K3, K4, (Q1+Q2)*2-Q3-Q4, Err[(Q1+Q2)*2-Q3-Q4]"; |
| 91 |
*os << "root?, super_base?, left_branch, right_branch, left_root, right_root, tree_index" << endl; |
| 92 |
|
| 93 |
*os << "BEGIN" << endl; |
| 94 |
os->setf(ios::right); |
| 95 |
os->setf(ios::uppercase); |
| 96 |
os->setf(ios::showpoint); |
| 97 |
|
| 98 |
Int4 k=0; |
| 99 |
for(vector<Bud>::const_iterator it=bud_basket.begin(); it!=bud_basket.end(); it++, k++) |
| 100 |
{ |
| 101 |
os->unsetf(ios::scientific); |
| 102 |
os->width(5); |
| 103 |
*os << k+1; |
| 104 |
|
| 105 |
os->width(5); |
| 106 |
if( it->iK1() < 0 ) *os << -1; |
| 107 |
else *os << it->iK1() + 1; |
| 108 |
|
| 109 |
os->width(5); |
| 110 |
if( it->iK2() < 0 ) *os << -1; |
| 111 |
else *os << it->iK2() + 1; |
| 112 |
|
| 113 |
os->width(5); |
| 114 |
if( it->iK3() < 0 ) *os << -1; |
| 115 |
else *os << it->iK3() + 1; |
| 116 |
|
| 117 |
os->width(5); |
| 118 |
if( it->iK4() < 0 ) *os << -1; |
| 119 |
else *os << it->iK4() + 1; |
| 120 |
|
| 121 |
const VCData diff = (it->Q1()+it->Q2())*2-(it->Q3()+it->Q4()); |
| 122 |
|
| 123 |
os->setf(ios::scientific); |
| 124 |
os->width(15); |
| 125 |
*os << diff.Value(); |
| 126 |
|
| 127 |
os->width(15); |
| 128 |
*os << sqrt( diff.Variance() ); |
| 129 |
|
| 130 |
os->precision(6); |
| 131 |
os->width(5); |
| 132 |
if( root_flag[k] ) *os << 1; |
| 133 |
else *os << 0; |
| 134 |
|
| 135 |
os->width(5); |
| 136 |
if( it->IsSuperBasisObtuse() ) *os << 1; |
| 137 |
else *os << 0; |
| 138 |
|
| 139 |
os->width(10); |
| 140 |
if( leftbr_tray[k].empty() ) *os << "Emp"; |
| 141 |
else |
| 142 |
{ |
| 143 |
*os << leftbr_tray[k][0] + 1; |
| 144 |
for(UInt4 l=1; l<leftbr_tray[k].size(); l++) *os << ":" << leftbr_tray[k][l] + 1; |
| 145 |
} |
| 146 |
|
| 147 |
os->width(10); |
| 148 |
if( rightbr_tray[k].empty() ) *os << "Emp"; |
| 149 |
else |
| 150 |
{ |
| 151 |
*os << rightbr_tray[k][0] + 1; |
| 152 |
for(UInt4 l=1; l<rightbr_tray[k].size(); l++) *os << ":" << rightbr_tray[k][l] + 1; |
| 153 |
} |
| 154 |
|
| 155 |
os->width(10); |
| 156 |
if( root_leftbr[k].empty() ) *os << "Emp"; |
| 157 |
else |
| 158 |
{ |
| 159 |
*os << root_leftbr[k][0] + 1; |
| 160 |
for(UInt4 l=1; l<root_leftbr[k].size(); l++) *os << ":" << root_leftbr[k][l] + 1; |
| 161 |
} |
| 162 |
|
| 163 |
os->width(10); |
| 164 |
if( root_rightbr[k].empty() ) *os << "Emp"; |
| 165 |
else |
| 166 |
{ |
| 167 |
*os << root_rightbr[k][0] + 1; |
| 168 |
for(UInt4 l=1; l<root_rightbr[k].size(); l++) *os << ":" << root_rightbr[k][l] + 1; |
| 169 |
} |
| 170 |
|
| 171 |
*os << endl; |
| 172 |
} |
| 173 |
*os << "END" << endl; |
| 174 |
|
| 175 |
ofs.close(); |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
void print_bud_data(const vector<Bud>& bud_basket, const string& fname) |
| 182 |
{ |
| 183 |
ofstream ofs(fname.c_str()); |
| 184 |
ostream *os; |
| 185 |
os = &ofs; |
| 186 |
|
| 187 |
*os << "IGOR" << endl; |
| 188 |
*os << "WAVES/O "; |
| 189 |
|
| 190 |
*os << "Number, K1, K2, K3, K4, (Q1+Q2)*2-Q3-Q4, Err[(Q1+Q2)*2-Q3-Q4]"; |
| 191 |
*os << "root?, super_base?, left_branch, right_branch, left_root, right_root, tree_index" << endl; |
| 192 |
|
| 193 |
*os << "BEGIN" << endl; |
| 194 |
os->setf(ios::right); |
| 195 |
os->setf(ios::uppercase); |
| 196 |
os->setf(ios::showpoint); |
| 197 |
|
| 198 |
Int4 k=0; |
| 199 |
for(vector<Bud>::const_iterator it=bud_basket.begin(); it!=bud_basket.end(); it++, k++) |
| 200 |
{ |
| 201 |
os->unsetf(ios::scientific); |
| 202 |
os->width(5); |
| 203 |
*os << k+1; |
| 204 |
|
| 205 |
os->width(5); |
| 206 |
if( it->iK1() < 0 ) *os << -1; |
| 207 |
else *os << it->iK1() + 1; |
| 208 |
|
| 209 |
os->width(5); |
| 210 |
if( it->iK2() < 0 ) *os << -1; |
| 211 |
else *os << it->iK2() + 1; |
| 212 |
|
| 213 |
os->width(5); |
| 214 |
if( it->iK3() < 0 ) *os << -1; |
| 215 |
else *os << it->iK3() + 1; |
| 216 |
|
| 217 |
os->width(5); |
| 218 |
if( it->iK4() < 0 ) *os << -1; |
| 219 |
else *os << it->iK4() + 1; |
| 220 |
|
| 221 |
const VCData diff = (it->Q1()+it->Q2())*2-(it->Q3()+it->Q4()); |
| 222 |
|
| 223 |
os->setf(ios::scientific); |
| 224 |
os->width(15); |
| 225 |
*os << diff.Value(); |
| 226 |
|
| 227 |
os->width(15); |
| 228 |
*os << sqrt( diff.Variance() ); |
| 229 |
|
| 230 |
os->width(5); |
| 231 |
if( it->IsSuperBasisObtuse() ) *os << 1; |
| 232 |
else *os << 0; |
| 233 |
|
| 234 |
*os << endl; |
| 235 |
} |
| 236 |
*os << "END" << endl; |
| 237 |
|
| 238 |
ofs.close(); |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
void print_node_data(const vector<Node3>& node_basket, |
| 245 |
const string& fname) |
| 246 |
{ |
| 247 |
ofstream ofs(fname.c_str()); |
| 248 |
ostream *os; |
| 249 |
os = &ofs; |
| 250 |
|
| 251 |
ofs << "** Node, K1, K2, K3, K1-K2, K1-K3, K2-K3, Q1, Q2, Q3, Q12, Q13, Q23, UnitcellVolume" << endl; |
| 252 |
|
| 253 |
os->setf(ios::scientific); |
| 254 |
os->precision(4); |
| 255 |
|
| 256 |
Int4 iK1, iK2, iK3; |
| 257 |
Int4 iK12, iK13, iK23; |
| 258 |
Double detS; |
| 259 |
for(UInt4 l=0; l<node_basket.size(); l++) |
| 260 |
{ |
| 261 |
os->width(5); |
| 262 |
*os << l + 1; |
| 263 |
|
| 264 |
const Node3& nodex = node_basket[l]; |
| 265 |
iK1 = nodex.iK(0); |
| 266 |
iK2 = nodex.iK(1); |
| 267 |
iK3 = nodex.iK(2); |
| 268 |
|
| 269 |
iK12 = nodex.iSumK(0,1); |
| 270 |
iK13 = nodex.iSumK(0,2); |
| 271 |
iK23 = nodex.iSumK(1,2); |
| 272 |
|
| 273 |
os->width(8); |
| 274 |
if( iK1 >= 0 ) *os << iK1 + 1; |
| 275 |
else *os << -1; |
| 276 |
|
| 277 |
os->width(5); |
| 278 |
if( iK2 >= 0 ) *os << iK2 + 1; |
| 279 |
else *os << -1; |
| 280 |
|
| 281 |
os->width(5); |
| 282 |
if( iK3 >= 0 ) *os << iK3 + 1; |
| 283 |
else *os << -1; |
| 284 |
|
| 285 |
os->width(8); |
| 286 |
if( iK12 >= 0 ) *os << iK12 + 1; |
| 287 |
else *os << -1; |
| 288 |
|
| 289 |
os->width(5); |
| 290 |
if( iK13 >= 0 ) *os << iK13 + 1; |
| 291 |
else *os << -1; |
| 292 |
|
| 293 |
os->width(5); |
| 294 |
if( iK23 >= 0 ) *os << iK23 + 1; |
| 295 |
else *os << -1; |
| 296 |
|
| 297 |
|
| 298 |
os->width(15); |
| 299 |
*os << nodex.K(0).Value(); |
| 300 |
|
| 301 |
os->width(15); |
| 302 |
*os << nodex.K(1).Value(); |
| 303 |
|
| 304 |
os->width(15); |
| 305 |
*os << nodex.K(2).Value(); |
| 306 |
|
| 307 |
os->width(15); |
| 308 |
*os << nodex.SumK(0,1).Value(); |
| 309 |
|
| 310 |
os->width(15); |
| 311 |
*os << nodex.SumK(0,2).Value(); |
| 312 |
|
| 313 |
os->width(15); |
| 314 |
*os << nodex.SumK(1,2).Value(); |
| 315 |
|
| 316 |
detS = nodex.putDeterminantS(); |
| 317 |
|
| 318 |
os->width(20); |
| 319 |
*os << 1.0/sqrt(detS); |
| 320 |
|
| 321 |
*os << endl; |
| 322 |
} |
| 323 |
*os << endl; |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
void printHKLdata(const vector<LatticeFigureOfMeritToCheckSymmetry> lattice_result[], |
| 330 |
const OutputInfo outinfo[], |
| 331 |
const eSortCriterion& sort_criterion, |
| 332 |
const ControlParam& cdata, |
| 333 |
const PeakPosData& pdata, |
| 334 |
const string& fname) |
| 335 |
{ |
| 336 |
static const ArrayIndex NUM_LS = put_cs_num(); |
| 337 |
|
| 338 |
ofstream ofs(fname.c_str()); |
| 339 |
ostream *os; |
| 340 |
os = &ofs; |
| 341 |
|
| 342 |
os->setf(ios::scientific); |
| 343 |
os->precision(4); |
| 344 |
|
| 345 |
pair< vector<Int4>::const_iterator, vector<Int4>::const_iterator> it_pair; |
| 346 |
SymMatWCovar dbl_S(3); |
| 347 |
VecDat3<Double> length_axis, angle_axis; |
| 348 |
SymMat<VCData> S_red2(3); |
| 349 |
set< SymMat<VCData> > S_tray; |
| 350 |
|
| 351 |
Int4 label_start=0; |
| 352 |
os->width(label_start); |
| 353 |
*os << "" << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; |
| 354 |
|
| 355 |
os->width(label_start); |
| 356 |
*os << "" << "<ZCodeParameters>\n"; |
| 357 |
label_start++; |
| 358 |
|
| 359 |
os->width(label_start); |
| 360 |
*os << "" << "<ConographOutput>\n"; |
| 361 |
label_start++; |
| 362 |
|
| 363 |
os->width(label_start); |
| 364 |
*os << "" << "<!-- Information on the best " + putLabel(sort_criterion) + " solution for each Bravais type.\n"; |
| 365 |
os->width(label_start+6); |
| 366 |
*os << "" << "TNB : total number of solutions of the Bravais types,\n"; |
| 367 |
os->width(label_start+6); |
| 368 |
*os << "" << putLabel(SCM) << " : de Wolff figure of merit,\n"; |
| 369 |
os->width(label_start+6); |
| 370 |
*os << "" << putLabel(SCWuM) << " : Wu figure of merit,\n"; |
| 371 |
// os->width(label_start+6); |
| 372 |
// *os << "" << putLabel(SCNormM) << " : normalized de Wolff figure of merit,\n"; |
| 373 |
os->width(label_start+6); |
| 374 |
*os << "" << putLabel(SCRevM) << " : reversed de Wolff figure of merit,\n"; |
| 375 |
os->width(label_start+6); |
| 376 |
*os << "" << putLabel(SCSymM) << " : symmetric de Wolff figure of merit,\n"; |
| 377 |
os->width(label_start+6); |
| 378 |
*os << "" << putLabel(SCNN) << " : number of lattices in the neighborhood,\n"; |
| 379 |
os->width(label_start+6); |
| 380 |
*os << "" << "VOL : unit-cell volume.\n"; |
| 381 |
os->width(label_start); |
| 382 |
*os << "" << "Bravais Lattice : TNB"; |
| 383 |
for(ArrayIndex i=0; i<putNumberOfSortCriterion(); i++) |
| 384 |
{ |
| 385 |
*os << ", " << putLabel(eSortCriterion(i)); |
| 386 |
} |
| 387 |
*os << ", VOL\n"; |
| 388 |
|
| 389 |
for(ArrayIndex k=NUM_LS-1; k>=0; k--) |
| 390 |
{ |
| 391 |
os->width(17); |
| 392 |
*os << put_cs_name(eCrystalSystem(k), cdata.putBaseCenteredAxis()) << " : "; |
| 393 |
os->width(7); |
| 394 |
*os << outinfo[k].putCandidateNumToOutput(); |
| 395 |
|
| 396 |
const ArrayIndex& index = outinfo[k].putIndex( outinfo[k].putLatticeLabelSelectedFromListToOutput(sort_criterion) ); |
| 397 |
if( index >= 0 ) |
| 398 |
{ |
| 399 |
const LatticeFigureOfMerit& lat_fom = lattice_result[k][index].putLatticeFigureOfMerit(); |
| 400 |
const SetOfFigureOfMerit& set_fom = lat_fom.putFiguresOfMerit(); |
| 401 |
|
| 402 |
os->width(15); |
| 403 |
*os << set_fom.putFigureOfMeritWolff(); |
| 404 |
|
| 405 |
os->width(15); |
| 406 |
*os << set_fom.putFigureOfMeritWu(); |
| 407 |
|
| 408 |
// os->width(15); |
| 409 |
// *os << set_fom.putNormalizedFigureOfMeritWolff(); |
| 410 |
|
| 411 |
os->width(15); |
| 412 |
*os << set_fom.putReversedFigureOfMerit(); |
| 413 |
|
| 414 |
os->width(15); |
| 415 |
*os << set_fom.putSymmetricFigureOfMerit(); |
| 416 |
|
| 417 |
os->width(5); |
| 418 |
*os << lattice_result[k][index].putNumberOfLatticesInNeighborhood(); |
| 419 |
|
| 420 |
os->width(15); |
| 421 |
*os << lat_fom.putLatticeVolume(); |
| 422 |
|
| 423 |
// os->width(15); |
| 424 |
// *os << set_fom.putFigureOfMeritWolff_Original(); |
| 425 |
// |
| 426 |
// os->width(15); |
| 427 |
// *os << set_fom.putFigureOfMeritWu_Original(); |
| 428 |
} |
| 429 |
*os << endl; |
| 430 |
} |
| 431 |
os->width(label_start); |
| 432 |
*os << "" << "-->\n\n"; |
| 433 |
os->width(label_start); |
| 434 |
*os << "" << "<!-- Labels of the solution with the best figure of merit.\n"; |
| 435 |
for(ArrayIndex k=NUM_LS-1; k>=0; k--) |
| 436 |
{ |
| 437 |
os->width(18); |
| 438 |
*os << put_cs_name(eCrystalSystem(k), cdata.putBaseCenteredAxis()) << ", Best Score : Lattice constants, label.\n"; |
| 439 |
// if( lattice_result[k].empty() ) |
| 440 |
// { |
| 441 |
// *os << "\n"; |
| 442 |
// continue; |
| 443 |
// } |
| 444 |
for(ArrayIndex i=0; i<putNumberOfSortCriterion(); i++) |
| 445 |
{ |
| 446 |
os->width(15); |
| 447 |
*os << putLabel(eSortCriterion(i)) << " = "; |
| 448 |
|
| 449 |
const ArrayIndex index = outinfo[k].putIndex( outinfo[k].putLatticeLabelSelectedAmongAll(eSortCriterion(i)) ); |
| 450 |
os->width(12); |
| 451 |
if( index >= 0 ) |
| 452 |
{ |
| 453 |
const LatticeFigureOfMerit& lat_fom = lattice_result[k][index].putLatticeFigureOfMerit(); |
| 454 |
const SetOfFigureOfMerit& set_fom = lat_fom.putFiguresOfMerit(); |
| 455 |
|
| 456 |
if( eSortCriterion(i) == SCM ) |
| 457 |
{ |
| 458 |
*os << set_fom.putFigureOfMeritWolff(); |
| 459 |
} |
| 460 |
else if( eSortCriterion(i) == SCWuM ) |
| 461 |
{ |
| 462 |
*os << set_fom.putFigureOfMeritWu(); |
| 463 |
} |
| 464 |
// if( eSortCriterion(i) == SCNormM ) |
| 465 |
// { |
| 466 |
// *os << set_fom.putNormalizedFigureOfMeritWolff(); |
| 467 |
// } |
| 468 |
else if( eSortCriterion(i) == SCRevM ) |
| 469 |
{ |
| 470 |
*os << set_fom.putReversedFigureOfMerit(); |
| 471 |
} |
| 472 |
else if( eSortCriterion(i) == SCSymM ) |
| 473 |
{ |
| 474 |
*os << set_fom.putSymmetricFigureOfMerit(); |
| 475 |
} |
| 476 |
else if( eSortCriterion(i) == SCNN ) |
| 477 |
{ |
| 478 |
*os << lattice_result[k][index].putNumberOfLatticesInNeighborhood(); |
| 479 |
} |
| 480 |
// else if( eSortCriterion(i) == SCM_org ) |
| 481 |
// { |
| 482 |
// *os << set_fom.putFigureOfMeritWolff_Original(); |
| 483 |
// } |
| 484 |
// else if( eSortCriterion(i) == SCWuM_org ) |
| 485 |
// { |
| 486 |
// *os << set_fom.putFigureOfMeritWu_Original(); |
| 487 |
// } |
| 488 |
|
| 489 |
*os << " : "; |
| 490 |
lat_fom.putReducedLatticeConstantsDegree(cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), length_axis, angle_axis); |
| 491 |
os->width(14); |
| 492 |
*os << length_axis[0]; |
| 493 |
os->width(14); |
| 494 |
*os << length_axis[1]; |
| 495 |
os->width(14); |
| 496 |
*os << length_axis[2]; |
| 497 |
os->width(14); |
| 498 |
*os << angle_axis[0]; |
| 499 |
os->width(14); |
| 500 |
*os << angle_axis[1]; |
| 501 |
os->width(14); |
| 502 |
*os << angle_axis[2]; |
| 503 |
os->width(10); |
| 504 |
*os << lattice_result[k][index].putStringLabel(); |
| 505 |
*os << endl; |
| 506 |
} |
| 507 |
else |
| 508 |
{ |
| 509 |
*os << "- -" << " : - -\n"; |
| 510 |
} |
| 511 |
} |
| 512 |
*os << endl; |
| 513 |
} |
| 514 |
os->width(label_start); |
| 515 |
*os << "" << "-->\n\n"; |
| 516 |
|
| 517 |
pair<eCrystalSystem, lattice_label> selected_lattice_info = put_selected_lattice_from_all(lattice_result, outinfo, sort_criterion); |
| 518 |
const ArrayIndex selected_lattice_index = outinfo[selected_lattice_info.first].putIndex(selected_lattice_info.second); |
| 519 |
|
| 520 |
if( selected_lattice_index >= 0 ) |
| 521 |
{ |
| 522 |
const LatticeFigureOfMeritToCheckSymmetry& selected_lattice = lattice_result[selected_lattice_info.first][selected_lattice_index]; |
| 523 |
|
| 524 |
os->width(label_start); |
| 525 |
*os << "" << "<!-- Information on the selected candidates.-->\n"; |
| 526 |
|
| 527 |
os->width(label_start); |
| 528 |
*os << "" << "<SelectedLatticeCandidate number=\"" << selected_lattice.putStringLabel() << "\">\n"; |
| 529 |
label_start++; |
| 530 |
|
| 531 |
selected_lattice.printLatticeInformation(lattice_result, outinfo, cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), label_start, os); |
| 532 |
|
| 533 |
label_start--; |
| 534 |
os->width(label_start); |
| 535 |
*os << "" << "</SelectedLatticeCandidate>\n\n"; |
| 536 |
} |
| 537 |
|
| 538 |
for(ArrayIndex k=NUM_LS-1; k>=0; k--) |
| 539 |
{ |
| 540 |
*os << "\n"; |
| 541 |
os->width(label_start); |
| 542 |
*os << "" << "<!-- Candidates for " << put_cs_name(eCrystalSystem(k), cdata.putBaseCenteredAxis()) << " -->\n\n"; |
| 543 |
|
| 544 |
const Int4 num_topo = lattice_result[k].size(); |
| 545 |
|
| 546 |
for(Int4 n=0; n<num_topo; n++) |
| 547 |
{ |
| 548 |
const LatticeFigureOfMeritToCheckSymmetry& ans = lattice_result[k][n]; |
| 549 |
if( !outinfo[k].IsOutput(ans.putLatticeLabel()) ) continue; |
| 550 |
|
| 551 |
os->width(label_start); |
| 552 |
*os << "" << "<LatticeCandidate number=\"" << ans.putStringLabel() << "\">\n"; |
| 553 |
label_start++; |
| 554 |
ans.printLatticeInformation(lattice_result, outinfo, cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), label_start, os); |
| 555 |
|
| 556 |
label_start--; |
| 557 |
os->width(label_start); |
| 558 |
*os << "" << "</LatticeCandidate>\n\n"; |
| 559 |
} |
| 560 |
*os << endl; |
| 561 |
} |
| 562 |
|
| 563 |
label_start--; |
| 564 |
os->width(label_start); |
| 565 |
*os << "" << "</ConographOutput>\n"; |
| 566 |
|
| 567 |
label_start--; |
| 568 |
os->width(label_start); |
| 569 |
*os << "" << "</ZCodeParameters>\n"; |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
void printHKLdata(const vector<LatticeFigureOfMeritToDisplay> lattice_result, |
| 575 |
const ControlParam& cdata, |
| 576 |
const PeakPosData& pdata, |
| 577 |
const string& fname) |
| 578 |
{ |
| 579 |
ofstream ofs(fname.c_str()); |
| 580 |
ostream *os; |
| 581 |
os = &ofs; |
| 582 |
|
| 583 |
os->setf(ios::scientific); |
| 584 |
os->precision(4); |
| 585 |
|
| 586 |
pair< vector<Int4>::const_iterator, vector<Int4>::const_iterator> it_pair; |
| 587 |
SymMatWCovar dbl_S(3); |
| 588 |
VecDat3<Double> length_axis, angle_axis; |
| 589 |
SymMat<VCData> S_red2(3); |
| 590 |
set< SymMat<VCData> > S_tray; |
| 591 |
|
| 592 |
Int4 label_start=0; |
| 593 |
os->width(label_start); |
| 594 |
*os << "" << "<ZCodeParameters>\n"; |
| 595 |
label_start++; |
| 596 |
|
| 597 |
os->width(label_start); |
| 598 |
*os << "" << "<ConographOutput>\n"; |
| 599 |
label_start++; |
| 600 |
|
| 601 |
const Int4 num_topo = lattice_result.size(); |
| 602 |
|
| 603 |
for(Int4 n=0; n<num_topo; n++) |
| 604 |
{ |
| 605 |
const LatticeFigureOfMeritZeroShift& ans = lattice_result[n].putLatticeFigureOfMerit(); |
| 606 |
|
| 607 |
os->width(label_start); |
| 608 |
*os << "" << "<LatticeCandidate>\n"; |
| 609 |
label_start++; |
| 610 |
ans.printLatticeInformation(cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), label_start, os); |
| 611 |
lattice_result[n].printIndexingResult(cdata, pdata, label_start, os); |
| 612 |
|
| 613 |
label_start--; |
| 614 |
os->width(label_start); |
| 615 |
*os << "" << "</LatticeCandidate>\n\n"; |
| 616 |
} |
| 617 |
*os << endl; |
| 618 |
|
| 619 |
label_start--; |
| 620 |
os->width(label_start); |
| 621 |
*os << "" << "</ConographOutput>\n"; |
| 622 |
|
| 623 |
label_start--; |
| 624 |
os->width(label_start); |
| 625 |
*os << "" << "</ZCodeParameters>\n"; |
| 626 |
} |
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
void printPeakPosition( |
| 631 |
const ControlParam& cdata, |
| 632 |
const PeakPosData& pdata, |
| 633 |
const eABCaxis& axis1, const eRHaxis& axis2, |
| 634 |
const LatticeFigureOfMeritToDisplay& latfit, |
| 635 |
const string& fname) |
| 636 |
{ |
| 637 |
ofstream ofs(fname.c_str()); |
| 638 |
ostream * const os = &ofs; |
| 639 |
|
| 640 |
*os << "IGOR\n"; |
| 641 |
*os << "WAVES/O "; |
| 642 |
|
| 643 |
pdata.printData(os); |
| 644 |
|
| 645 |
// const Int4 isize = latfit.size(); |
| 646 |
|
| 647 |
for (Int4 j=0, j1=1; j<1; j++, j1++) |
| 648 |
{ |
| 649 |
*os << "WAVES/O dphase_" << j1 << ", xphase_" << j1 << ", yphase_" << j1 << ", "; |
| 650 |
*os << "h_" << j1 << ", "; |
| 651 |
*os << "k_" << j1 << ", "; |
| 652 |
*os << "l_" << j1; |
| 653 |
*os << endl; |
| 654 |
|
| 655 |
*os << "BEGIN\n"; |
| 656 |
|
| 657 |
const vector<HKL_Q>& cal_hkl_tray = latfit.putCalMillerIndices(); |
| 658 |
Vec_DP cal_pos_tray; |
| 659 |
latfit.putCalculatedPeakPosInRange(cdata, cal_pos_tray); |
| 660 |
|
| 661 |
const Int4 peak_num = cal_hkl_tray.size(); |
| 662 |
|
| 663 |
for (Int4 i=0; i<peak_num; i++) |
| 664 |
{ |
| 665 |
os->width(15); |
| 666 |
*os << 1.0 / sqrt( cal_hkl_tray[i].Q() ); |
| 667 |
|
| 668 |
os->width(15); |
| 669 |
if( cal_pos_tray[i] < 0.0 ) |
| 670 |
{ |
| 671 |
*os << "NAN"; |
| 672 |
} |
| 673 |
else |
| 674 |
{ |
| 675 |
*os << cal_pos_tray[i]; |
| 676 |
} |
| 677 |
os->width(15); |
| 678 |
*os << 0.0; |
| 679 |
|
| 680 |
const VecDat3<Int4>& hkl = cal_hkl_tray[i].HKL(); |
| 681 |
|
| 682 |
os->width(5); |
| 683 |
*os << hkl[0]; |
| 684 |
os->width(5); |
| 685 |
*os << hkl[1]; |
| 686 |
os->width(5); |
| 687 |
*os << hkl[2]; |
| 688 |
|
| 689 |
*os << endl; |
| 690 |
} |
| 691 |
*os << "END\n\n"; |
| 692 |
} |
| 693 |
|
| 694 |
VecDat3<Double> length_axis, angle_axis; |
| 695 |
const string str_num_ref = num2str( cdata.putNumberOfReflectionsForFigureOfMerit() ); |
| 696 |
|
| 697 |
|
| 698 |
*os << "X Display " << pdata.putYIntColumnTitle() << " vs " << pdata.putXColumnTitle() << endl; |
| 699 |
*os << "X ModifyGraph mirror(left)=2\n"; |
| 700 |
*os << "X ModifyGraph mirror(bottom)=2\n"; |
| 701 |
*os << "X ModifyGraph rgb(" << pdata.putYIntColumnTitle() << ")=(0,15872,65280)\n"; |
| 702 |
|
| 703 |
*os << "X AppendToGraph height vs peakpos\n"; |
| 704 |
*os << "X ModifyGraph mode(height)=3,marker(height)=17\n"; |
| 705 |
*os << "X ModifyGraph rgb(height)=(0,65280,65280)\n"; |
| 706 |
|
| 707 |
for (Int4 j=0, j1=1; j<1; j++, j1++) |
| 708 |
{ |
| 709 |
*os << "X AppendToGraph yphase_" << j1 << " vs xphase_" << j1 << endl; |
| 710 |
*os << "X ModifyGraph offset(yphase_" << j1 << ")={0,0},mode(yphase_" << j1 << ")=3,marker(yphase_" << j1; |
| 711 |
*os << ")=10,msize(yphase_" << j1 << ")=3,mrkThick(yphase_" << j1 << ")=0.6,rgb(yphase_" << j1 << ")=(3,52428,1)" << endl; |
| 712 |
} |
| 713 |
|
| 714 |
*os << "X Legend/C/N=text0/J/A=MC \""; |
| 715 |
*os << "\\s(yphase_" << 1 << ") " |
| 716 |
+ put_cs_name(latfit.putLatticeFigureOfMerit().enumCrystalSystem(), cdata.putBaseCenteredAxis()) + " " |
| 717 |
+ latfit.putLatticeFigureOfMerit().printOptimizedLatticeConstants(cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), 3); |
| 718 |
*os << "\"\nX Legend/C/N=text0/J/A=RT/X=0.00/Y=0.00"; |
| 719 |
|
| 720 |
ofs.close(); |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
void printPeakPosition( |
| 726 |
const ControlParam& cdata, |
| 727 |
const PeakPosData& pdata, |
| 728 |
const eABCaxis& axis1, const eRHaxis& axis2, |
| 729 |
const vector<LatticeFigureOfMeritToDisplay>& latfit_tray, |
| 730 |
const Double& offset_first, |
| 731 |
const string& fname) |
| 732 |
{ |
| 733 |
ofstream ofs(fname.c_str()); |
| 734 |
ostream * const os = &ofs; |
| 735 |
|
| 736 |
*os << "IGOR\n"; |
| 737 |
*os << "WAVES/O "; |
| 738 |
|
| 739 |
pdata.printData(os); |
| 740 |
|
| 741 |
if( latfit_tray.empty() ) return; |
| 742 |
|
| 743 |
const Int4 isize = latfit_tray.size(); |
| 744 |
for (Int4 j=0, j1=1; j<isize; j++, j1++) |
| 745 |
{ |
| 746 |
const LatticeFigureOfMeritToDisplay& latfit = latfit_tray[j]; |
| 747 |
|
| 748 |
*os << "WAVES/O dphase_" << j1 << ", xphase_" << j1 << ", yphase_" << j1 << ", "; |
| 749 |
*os << "h_" << j1 << ", "; |
| 750 |
*os << "k_" << j1 << ", "; |
| 751 |
*os << "l_" << j1; |
| 752 |
*os << endl; |
| 753 |
|
| 754 |
*os << "BEGIN\n"; |
| 755 |
|
| 756 |
const vector<HKL_Q>& cal_hkl_tray = latfit.putCalMillerIndices(); |
| 757 |
Vec_DP cal_pos_tray; |
| 758 |
latfit.putCalculatedPeakPosInRange(cdata, cal_pos_tray); |
| 759 |
|
| 760 |
const Int4 peak_num = cal_hkl_tray.size(); |
| 761 |
|
| 762 |
for (Int4 i=0; i<peak_num; i++) |
| 763 |
{ |
| 764 |
os->width(15); |
| 765 |
*os << 1.0 / sqrt( cal_hkl_tray[i].Q() ); |
| 766 |
|
| 767 |
os->width(15); |
| 768 |
if( cal_pos_tray[i] < 0.0 ) |
| 769 |
{ |
| 770 |
*os << "NAN"; |
| 771 |
} |
| 772 |
else |
| 773 |
{ |
| 774 |
*os << cal_pos_tray[i]; |
| 775 |
} |
| 776 |
os->width(15); |
| 777 |
*os << 0.0; |
| 778 |
|
| 779 |
const VecDat3<Int4>& hkl = cal_hkl_tray[i].HKL(); |
| 780 |
|
| 781 |
os->width(5); |
| 782 |
*os << hkl[0]; |
| 783 |
os->width(5); |
| 784 |
*os << hkl[1]; |
| 785 |
os->width(5); |
| 786 |
*os << hkl[2]; |
| 787 |
|
| 788 |
*os << endl; |
| 789 |
} |
| 790 |
*os << "END\n\n"; |
| 791 |
} |
| 792 |
|
| 793 |
VecDat3<Double> length_axis, angle_axis; |
| 794 |
const string str_num_ref = num2str( cdata.putNumberOfReflectionsForFigureOfMerit() ); |
| 795 |
|
| 796 |
|
| 797 |
*os << "X Display " << pdata.putYIntColumnTitle() << " vs " << pdata.putXColumnTitle() << endl; |
| 798 |
*os << "X ModifyGraph mirror(left)=2\n"; |
| 799 |
*os << "X ModifyGraph mirror(bottom)=2\n"; |
| 800 |
*os << "X ModifyGraph rgb(" << pdata.putYIntColumnTitle() << ")=(0,15872,65280)\n"; |
| 801 |
|
| 802 |
*os << "X AppendToGraph height vs peakpos\n"; |
| 803 |
*os << "X ModifyGraph mode(height)=3,marker(height)=17\n"; |
| 804 |
*os << "X ModifyGraph rgb(height)=(0,65280,65280)\n"; |
| 805 |
|
| 806 |
const Double width = pdata.putAveragePeakHeightOfFirst20() * 0.3; |
| 807 |
Double offset = offset_first; |
| 808 |
for (Int4 j=0, j1=1; j<isize; j++, j1++) |
| 809 |
{ |
| 810 |
*os << "X AppendToGraph yphase_" << j1 << " vs xphase_" << j1 << endl; |
| 811 |
*os << "X ModifyGraph offset(yphase_" << j1 << ")={0," << offset << "},mode(yphase_" << j1 << ")=3,marker(yphase_" << j1; |
| 812 |
*os << ")=10,msize(yphase_" << j1 << ")=3,mrkThick(yphase_" << j1 << ")=0.6,rgb(yphase_" << j1 << ")=(3,52428,1)" << endl; |
| 813 |
offset -= width; |
| 814 |
} |
| 815 |
|
| 816 |
*os << "X Legend/C/N=text0/J/A=MC \""; |
| 817 |
*os << "\\s(yphase_" << 1 << ") " |
| 818 |
+ put_cs_name(latfit_tray[0].putLatticeFigureOfMerit().enumCrystalSystem(), cdata.putBaseCenteredAxis()) + " " |
| 819 |
+ latfit_tray[0].putLatticeFigureOfMerit().printOptimizedLatticeConstants(cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), 3); |
| 820 |
for (Int4 j=1, j1=2; j<isize; j++, j1++) |
| 821 |
{ |
| 822 |
*os << "\\r\\s(yphase_" << j1 << ") " |
| 823 |
+ put_cs_name(latfit_tray[j].putLatticeFigureOfMerit().enumCrystalSystem(), cdata.putBaseCenteredAxis()) + " " |
| 824 |
+ latfit_tray[j].putLatticeFigureOfMerit().printOptimizedLatticeConstants(cdata.putBaseCenteredAxis(), cdata.putRhombohedralAxis(), 3); |
| 825 |
} |
| 826 |
*os << "\"\nX Legend/C/N=text0/J/A=RT/X=0.00/Y=0.00"; |
| 827 |
|
| 828 |
ofs.close(); |
| 829 |
} |