#endif
#include "obs_phi2.hpp"
+#include "obs_phi2_hist.hpp"
o815 *O815;
sim *Sim;
if ( strcmp(*lonit, "phi2") == 0 ) {
*O815->out->log << "MASTER: registered observable: phi2" << endl << flush;
O815->observables.push_back(new obs_phi2(O815));
- }
+ }
+ else if ( strcmp(*lonit, "phi2_hist") == 0 ) {
+ *O815->out->log << "MASTER: registered observable: phi2_hist" << endl << flush;
+ O815->observables.push_back(new obs_phi2_hist(O815));
+ }
}
}
private:
void _start();
- void _meas(bool loadedobs);
+ void _meas(bool loadedobs, const int& nthmeas);
void _finish();
obsmem* OM;
//*out << "OBS_test: start" << endl;
};
-void obs_phi2::_meas(bool loadedobs) {
+void obs_phi2::_meas(bool loadedobs, const int& nthmeas) {
if (!loadedobs)
phi2Compute();
--- /dev/null
+#ifndef OBS_PHI2_HIST_HPP
+#define OBS_PHI2_HIST_HPP
+
+#include "latlib/o815/o815.h"
+
+#include "latlib/writeout.h"
+
+#include "latlib/obstat.hpp"
+
+#include <iostream>
+
+using namespace std;
+
+class obs_phi2_hist : public o815::obs {
+
+public:
+ struct obsmem {
+ double phi2;
+ };
+ obs_phi2_hist(o815 *_O815);
+
+private:
+ void _start() {}
+ void _meas(bool loadedobs, const int& nthmeas);
+ void _finish() {}
+ obsmem* OM;
+ void phi2Compute();
+ sim *Sim;
+};
+
+obs_phi2_hist::obs_phi2_hist(o815 *_O815) : o815::obs("phi2",
+ _O815->paraQ->getParaNames() + "nthstep:phi2:phi2_err",
+ _O815, sizeof(obsmem), "_hist") {
+ OM = (obsmem*)obsMem;
+ Sim = (sim*)O815->Sim;
+}
+
+void obs_phi2_hist::_meas(bool loadedobs, const int& nthmeas) {
+ if (!loadedobs)
+ phi2Compute();
+
+ *out << O815->paraQ->getParaVals();
+ *out << "\t" << ( Sim->nequi + (nthmeas+1)*Sim->nskip );
+ *out << "\t" << OM->phi2 << endl;
+};
+
+void obs_phi2_hist::phi2Compute()
+{
+ OM->phi2 = 0;
+
+ for (int ix = 0; ix < Sim->LSIZE2; ix++)
+ OM->phi2 += norm( Sim->conf[ix].phi );
+
+ OM->phi2 /= Sim->LSIZE2;
+}
+
+#endif