You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Scan_Info.cc 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: Scan_Info.cc
  6. Purpose: defines all functions for Scan_Info class.
  7. ***********************************************************/
  8. #include "ABACUS.h"
  9. using namespace std;
  10. using namespace ABACUS;
  11. namespace ABACUS {
  12. Scan_Info::Scan_Info() :
  13. sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), TT(0.0) {}
  14. Scan_Info::Scan_Info (DP sr, DP Nf, long long int Ni, long long int Nd, long long int Ndc, long long int Ndc0, double t) :
  15. sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), TT(t) {}
  16. void Scan_Info::Save (const char* outfile_Cstr)
  17. {
  18. ofstream outfile;
  19. outfile.open(outfile_Cstr);
  20. if (outfile.fail()) ABACUSerror("Could not open outfile... ");
  21. outfile.precision(16);
  22. int TT_hr = int(TT/3600);
  23. int TT_min = int((TT - 3600.0*TT_hr)/60);
  24. outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull
  25. << setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
  26. << "\t" << TT_hr << " h " << TT_min << " m "
  27. << std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
  28. outfile << setw(25) << "sumrule_obtained" << setw(25) << "Nfull" << setw(16) << "Ninadm"
  29. << setw(16) << "Ndata" << setw(16) << "Ndata_conv" << setw(16) << "Ndata_conv0" << setw(16) << "TT." << endl;
  30. outfile.close();
  31. return;
  32. }
  33. void Scan_Info::Load (const char* infile_Cstr)
  34. {
  35. ifstream infile;
  36. infile.open(infile_Cstr);
  37. if(infile.fail()) {
  38. cout << endl << infile_Cstr << endl;
  39. ABACUSerror("Could not open input file in Scan_Info::Load.");
  40. }
  41. int TT_hr, TT_min;
  42. DP TT_sec;
  43. char a;
  44. infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0
  45. >> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
  46. TT = 3600.0 * TT_hr + 60.0* TT_min + TT_sec;
  47. infile.close();
  48. return;
  49. }
  50. std::ostream& operator<< (std::ostream& s, const Scan_Info& info)
  51. {
  52. s.ios::unsetf(ios::scientific);
  53. return s << " sr " << setprecision(14) << info.sumrule_obtained
  54. << "\tNfull " << std::fixed << setprecision(0) << info.Nfull
  55. << "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
  56. << "\t_conv " << info.Ndata_conv << " _conv0 " << info.Ndata_conv0
  57. << "\tTT " << int(info.TT/3600) << " h " << int((info.TT - 3600.0 * int(info.TT/3600))/60)
  58. << " m " << std::fixed << setprecision(3)
  59. << info.TT - 3600.0 * int(info.TT/3600) - 60.0 * int((info.TT - 3600.0 * int(info.TT/3600))/60) << " s";
  60. }
  61. } // namespace ABACUS