4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
14 class obs_phi2 : public o815::obs {
20 obs_phi2(o815 *_O815);
24 void _meas(bool loadedobs, const int& nthmeas);
30 static double phi2Sus(vector< vector<double> > *vals, void *para);
33 obstat<double,double> oPhi2[2];
36 obs_phi2::obs_phi2(o815 *_O815) : o815::obs("phi2",
37 _O815->paraQ->getParaNames() +
38 "phi2one:phi2one_err:phi2onesus:phi2onesus_err"
39 ":phi2two:phi2two_err:phi2twosus:phi2twosus_err",
40 _O815, sizeof(obsmem) ) {
42 Sim = (sim*)O815->Sim;
45 void obs_phi2::_start() {
46 //*out << "OBS_test: start" << endl;
49 void obs_phi2::_meas(bool loadedobs, const int& nthmeas) {
53 for (int iflav=0; iflav<2; iflav++)
54 oPhi2[iflav].addMeas(OM->phi2[iflav]);
57 void obs_phi2::_finish() {
58 *out << O815->paraQ->getParaVals();
60 int compid_phi2[2], compid_phi2sus[2];
62 for (int iflav=0; iflav<2; iflav++) {
63 compid_phi2[iflav] = oPhi2[iflav].computeEasy();
64 compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::phi2Sus, &(Sim->lsize4));
66 *out << "\t" << oPhi2[iflav].getMean(compid_phi2[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2[iflav]);
67 *out << "\t" << oPhi2[iflav].getMean(compid_phi2sus[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2sus[iflav]);
75 void obs_phi2::phi2Compute()
77 for (int iflav=0; iflav<2; iflav++) {
80 for (int ix = 0; ix < Sim->lsize4; ix++)
81 OM->phi2[iflav] += norm(Sim->phi[ iflav*Sim->lsize4 + ix ]);
83 OM->phi2[iflav] /= Sim->lsize4;
87 double obs_phi2::phi2Sus(vector< vector<double> > *vals, void *para) {
88 double mean=0, mean2=0;
89 for(vector< vector<double> >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt)
92 mean2 += pow((*valIt)[0],2);
95 mean2 /= vals->size();
97 return ( mean2 - pow(mean,2) ) * *(int*)para;