4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
14 class obs_plaq : public o815::obs {
20 obs_plaq(o815 *_O815);
24 void _meas(bool loadedobs, const int& nthmeas);
31 static void prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
32 static double plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
35 obstat<double,double> oPlaq;
38 obs_plaq::obs_plaq(o815 *_O815) : o815::obs("plaq",
39 _O815->paraQ->getParaNames() + "plaq:plaq_err:plaqsus:plaqsus_err",
40 _O815, sizeof(obsmem) ) {
42 Sim = (sim*)O815->Sim;
45 void obs_plaq::_start() {
46 //*out << "OBS_test: start" << endl;
49 void obs_plaq::_meas(bool loadedobs, const int& nthmeas) {
53 oPlaq.addMeas(OM->plaq);
56 void obs_plaq::_finish() {
57 *out << O815->paraQ->getParaVals();
59 int compid_plaq, compid_plaqsus;
61 compid_plaq = oPlaq.computeEasy();
62 compid_plaqsus = oPlaq.computeJack(obs_plaq::prePlaqSus, obs_plaq::plaqSus, &(Sim->lsize4));
64 *out << "\t" << oPlaq.getMean(compid_plaq) << "\t" << oPlaq.getErr(compid_plaq);
65 *out << "\t" << oPlaq.getMean(compid_plaqsus) << "\t" << oPlaq.getErr(compid_plaqsus);
72 void obs_plaq::plaqCompute()
76 for( int ix=0; ix<Sim->lsize4; ix++ )
77 for( int inu=0; inu<3; inu++ )
78 for( int isigma=inu+1; isigma<4; isigma++ ) {
79 OM->plaq += real( Sim->U[ ix*4 + inu ] * Sim->U[ (*Sim->nb)[ix*8+inu]*4 + isigma ]
80 * conj(Sim->U[ (*Sim->nb)[ix*8+isigma]*4 + inu ]) * conj(Sim->U[ ix*4 + isigma ]) );
83 OM->plaq /= Sim->lsize4*6;
86 void obs_plaq::prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
87 preCalculated->push_back(0);
88 preCalculated->push_back(0);
90 for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
91 (*preCalculated)[0] += (*valIt)[0];
92 (*preCalculated)[1] += pow((*valIt)[0],2);
96 double obs_plaq::plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
97 return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) ) / (nmeas-1)
98 - pow( ( (*preCalculated)[0] - (*excludedMeas)[0] ) / (nmeas-1), 2 ))