4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
14 class obs_plaq : public o815::obs {
21 obs_plaq(o815 *_O815);
25 void _meas(bool loadedobs, const int& nthmeas);
30 static void prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
31 static double plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
34 obstat<double,double> oPlaq;
36 double A(const double& beta);
37 double B(const double& beta);
40 obs_plaq::obs_plaq(o815 *_O815) : o815::obs("plaq",
41 _O815->paraQ->getParaNames() + "plaq:plaq_err:plaqsus:plaqsus_err",
42 _O815, sizeof(obsmem) ) {
44 Sim = (sim*)O815->Sim;
47 void obs_plaq::_start() {
48 //*out << "OBS_test: start" << endl;
51 void obs_plaq::_meas(bool loadedobs, const int& nthmeas) {
53 OM->A = A((*paraQ)["beta"]);
54 OM->B = B((*paraQ)["beta"]);
57 double tmpMeas[2] = {OM->A, OM->B};
58 oPlaq.addMeas(tmpMeas, 2);
61 void obs_plaq::_finish() {
62 *out << O815->paraQ->getParaVals();
64 int compid_plaq, compid_plaqsus;
66 compid_plaq = oPlaq.computeEasy();
67 compid_plaqsus = oPlaq.computeJack(obs_plaq::prePlaqSus, obs_plaq::plaqSus, &(Sim->lsize4));
69 *out << "\t" << oPlaq.getMean(compid_plaq) << "\t" << oPlaq.getErr(compid_plaq);
70 *out << "\t" << oPlaq.getMean(compid_plaqsus) << "\t" << oPlaq.getErr(compid_plaqsus);
77 void obs_plaq::prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
78 preCalculated->push_back(0);
79 preCalculated->push_back(0);
81 for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
82 (*preCalculated)[0] += (*valIt)[1] + pow((*valIt)[0], 2)*(*(int*)para*6);
83 (*preCalculated)[1] += (*valIt)[0];
87 double obs_plaq::plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
88 return ( (*preCalculated)[0] - pow((*excludedMeas)[0], 2) * *(int*)para * 6 - (*excludedMeas)[1] ) / (nmeas-1)
89 - pow( ( (*preCalculated)[1] - (*excludedMeas)[0] ) / (nmeas-1), 2 )
93 double obs_plaq::A(const double& beta)
97 for( int x=0; x<Sim->lsize4; x++ )
98 for( int sigma=0; sigma<3; sigma++ )
99 for( int tau=sigma+1; tau<4; tau++ ) {
100 A += Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 1 ) / Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] );
101 A += Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] / beta;
104 return A/(6*Sim->lsize4);
107 double obs_plaq::B(const double& beta)
111 for( int x=0; x<Sim->lsize4; x++ )
112 for( int sigma=0; sigma<3; sigma++ )
113 for( int tau=sigma+1; tau<4; tau++ ) {
114 B += Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 2 ) / Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] );
115 B += ( (Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 1) * Sim->I(Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 1) ) /
116 ( beta * Sim->I(Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ]) );
117 B -= pow(Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 1 ) / Sim->I( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] ), 2);
118 B -= ( Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] * Sim->I(Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ] + 1) ) /
119 ( beta * Sim->I(Sim->p[ x*6 + Sim->iPlaq(sigma,tau) ]) );
120 B -= Sim->p[ x*6 + Sim->iPlaq(sigma,tau)] / pow(beta,2);
123 return B/(6*Sim->lsize4);