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.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. void Scan_Info::Save (string outfile_str)
  18. {
  19. ofstream outfile;
  20. outfile.open(outfile_str);
  21. if (outfile.fail()) ABACUSerror("Could not open outfile... ");
  22. outfile.precision(16);
  23. int TT_hr = int(TT/3600);
  24. int TT_min = int((TT - 3600.0*TT_hr)/60);
  25. outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull
  26. << setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
  27. << "\t" << TT_hr << " h " << TT_min << " m "
  28. << std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
  29. outfile << setw(25) << "sumrule_obtained" << setw(25) << "Nfull" << setw(16) << "Ninadm"
  30. << setw(16) << "Ndata" << setw(16) << "Ndata_conv" << setw(16) << "Ndata_conv0" << setw(16) << "TT." << endl;
  31. outfile.close();
  32. return;
  33. }
  34. //void Scan_Info::Load (const char* infile_Cstr)
  35. void Scan_Info::Load (string infile_str)
  36. {
  37. ifstream infile;
  38. infile.open(infile_str);
  39. if(infile.fail()) {
  40. cout << endl << infile_str << endl;
  41. ABACUSerror("Could not open input file in Scan_Info::Load.");
  42. }
  43. int TT_hr, TT_min;
  44. DP TT_sec;
  45. char a;
  46. infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0
  47. >> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
  48. TT = 3600.0 * TT_hr + 60.0* TT_min + TT_sec;
  49. infile.close();
  50. return;
  51. }
  52. std::ostream& operator<< (std::ostream& s, const Scan_Info& info)
  53. {
  54. s.ios::unsetf(ios::scientific);
  55. return s << " sr " << setprecision(14) << info.sumrule_obtained
  56. << "\tNfull " << std::fixed << setprecision(0) << info.Nfull
  57. << "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
  58. << "\t_conv " << info.Ndata_conv << " _conv0 " << info.Ndata_conv0
  59. << "\tTT " << int(info.TT/3600) << " h " << int((info.TT - 3600.0 * int(info.TT/3600))/60)
  60. << " m " << std::fixed << setprecision(3)
  61. << info.TT - 3600.0 * int(info.TT/3600) - 60.0 * int((info.TT - 3600.0 * int(info.TT/3600))/60) << " s";
  62. }
  63. } // namespace ABACUS