90 rivejä
2.9 KiB
C++
90 rivejä
2.9 KiB
C++
/**********************************************************
|
|
|
|
This software is part of J.-S. Caux's ABACUS library.
|
|
|
|
Copyright (c) J.-S. Caux.
|
|
|
|
-----------------------------------------------------------
|
|
|
|
File: Scan_Info.cc
|
|
|
|
Purpose: defines all functions for Scan_Info class.
|
|
|
|
***********************************************************/
|
|
|
|
#include "ABACUS.h"
|
|
|
|
using namespace std;
|
|
using namespace ABACUS;
|
|
|
|
namespace ABACUS {
|
|
|
|
Scan_Info::Scan_Info() :
|
|
sumrule_obtained(0.0), Nfull(0.0), Ninadm(0LL), Ndata(0LL), Ndata_conv(0LL), Ndata_conv0(0LL), TT(0.0) {}
|
|
|
|
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) :
|
|
sumrule_obtained(sr), Nfull(Nf), Ninadm(Ni), Ndata(Nd), Ndata_conv(Ndc), Ndata_conv0(Ndc0), TT(t) {}
|
|
|
|
//void Scan_Info::Save (const char* outfile_Cstr)
|
|
void Scan_Info::Save (string outfile_str)
|
|
{
|
|
ofstream outfile;
|
|
|
|
outfile.open(outfile_str);
|
|
if (outfile.fail()) ABACUSerror("Could not open outfile... ");
|
|
|
|
outfile.precision(16);
|
|
|
|
int TT_hr = int(TT/3600);
|
|
int TT_min = int((TT - 3600.0*TT_hr)/60);
|
|
|
|
outfile << setw(25) << setprecision(16) << sumrule_obtained << setw(25) << Nfull
|
|
<< setw(16) << Ninadm << setw(16) << Ndata << setw(16) << Ndata_conv << setw(16) << Ndata_conv0
|
|
<< "\t" << TT_hr << " h " << TT_min << " m "
|
|
<< std::fixed << setprecision(3) << TT - 3600*TT_hr - 60*TT_min << " s" << endl;
|
|
outfile << setw(25) << "sumrule_obtained" << setw(25) << "Nfull" << setw(16) << "Ninadm"
|
|
<< setw(16) << "Ndata" << setw(16) << "Ndata_conv" << setw(16) << "Ndata_conv0" << setw(16) << "TT." << endl;
|
|
outfile.close();
|
|
|
|
return;
|
|
}
|
|
|
|
//void Scan_Info::Load (const char* infile_Cstr)
|
|
void Scan_Info::Load (string infile_str)
|
|
{
|
|
ifstream infile;
|
|
infile.open(infile_str);
|
|
if(infile.fail()) {
|
|
cout << endl << infile_str << endl;
|
|
ABACUSerror("Could not open input file in Scan_Info::Load.");
|
|
}
|
|
|
|
int TT_hr, TT_min;
|
|
DP TT_sec;
|
|
char a;
|
|
|
|
infile >> sumrule_obtained >> Nfull >> Ninadm >> Ndata >> Ndata_conv >> Ndata_conv0
|
|
>> TT_hr >> a >> TT_min >> a >> TT_sec >> a;
|
|
|
|
TT = 3600.0 * TT_hr + 60.0* TT_min + TT_sec;
|
|
|
|
infile.close();
|
|
|
|
return;
|
|
}
|
|
|
|
std::ostream& operator<< (std::ostream& s, const Scan_Info& info)
|
|
{
|
|
s.ios::unsetf(ios::scientific);
|
|
return s << " sr " << setprecision(14) << info.sumrule_obtained
|
|
<< "\tNfull " << std::fixed << setprecision(0) << info.Nfull
|
|
<< "\t Ninadm " << info.Ninadm << " Ndata " << info.Ndata
|
|
<< "\t_conv " << info.Ndata_conv << " _conv0 " << info.Ndata_conv0
|
|
<< "\tTT " << int(info.TT/3600) << " h " << int((info.TT - 3600.0 * int(info.TT/3600))/60)
|
|
<< " m " << std::fixed << setprecision(3)
|
|
<< info.TT - 3600.0 * int(info.TT/3600) - 60.0 * int((info.TT - 3600.0 * int(info.TT/3600))/60) << " s";
|
|
}
|
|
|
|
|
|
} // namespace ABACUS
|