1 #ifndef OBS_PHIP2_HIST_HPP
2 #define OBS_PHIP2_HIST_HPP
4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
15 class obs_phip2_hist : public o815::obs {
21 obs_phip2_hist(o815 *_O815, const int& avgmany=2);
25 void _meas(bool loadedobs, const int& nthmeas);
30 static string intToStr(const int& number);
34 string obs_phip2_hist::intToStr(const int& number)
41 obs_phip2_hist::obs_phip2_hist(o815 *_O815, const int& _avgmany) : o815::obs("phip2",
42 _O815->paraQ->getParaNames() + "nthstep:imode:kt:kx:phip2absdiffequi", _O815,
44 "_hist_avg" + intToStr(_avgmany) ) {
46 Sim = (sim*)O815->Sim;
50 void obs_phip2_hist::_meas(bool loadedobs, const int& nthmeas) {
51 for (int kpimode=0; kpimode<4; kpimode++) {
52 const double ppt = 2.*M_PI/O815->comargs.lsize[0] * ( 0 + int( kpimode/4. * O815->comargs.lsize[0] ) ) ;
53 const double ppx = 2.*M_PI/O815->comargs.lsize[1] * ( 0 + int( kpimode/4. * O815->comargs.lsize[1] ) );
56 complex<double> phitildepp = 0;
58 for (int ixpt = 0; ixpt < O815->comargs.lsize[0]; ixpt++)
59 for (int ixpx = 0; ixpx < O815->comargs.lsize[1]; ixpx++)
60 phitildepp += Sim->conf[ ixpt*O815->comargs.lsize[1] + ixpx ].phi
61 * exp ( - _i_*(double)ppx*(double)ixpx - _i_*(double)ppt*(double)ixpt );
63 OM->phip2[ kpimode ] = norm( phitildepp) / Sim->LSIZE2;
66 if ( nthmeas%avgmany == 0 )
67 avgphip2[kpimode] = 0;
69 avgphip2[kpimode] += OM->phip2[ kpimode ];
71 if ( (nthmeas+1)%avgmany == 0 ) {
72 *out << O815->paraQ->getParaVals();
73 *out << "\t" << ( Sim->nequi + (nthmeas+1)*Sim->nskip );
74 *out << "\t" << kpimode;
75 *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[0] );
76 *out << "\t" << 0 + int( kpimode/4. * O815->comargs.lsize[1] );
77 *out << "\t" << abs( avgphip2[kpimode] / (double)avgmany - 1./(ppt*ppt + ppx*ppx + Sim->m*Sim->m) ) << endl;