]> git.treefish.org Git - phys/u1casc.git/blob - u1casc-ordinary/obs_plaq.hpp
Using microseconds for random seed.
[phys/u1casc.git] / u1casc-ordinary / obs_plaq.hpp
1 #ifndef OBS_PLAQ_HPP
2 #define OBS_PLAQ_HPP
3
4 #include "latlib/o815/o815.h"
5
6 #include "latlib/writeout.h"
7
8 #include "latlib/obstat.hpp"
9
10 #include <iostream>
11
12 using namespace std;
13
14 class obs_plaq : public o815::obs {
15
16 public:
17   struct obsmem {
18     double plaq;
19   };
20   obs_plaq(o815 *_O815);
21   
22 private:
23   void _start();
24   void _meas(bool loadedobs, const int& nthmeas);
25   void _finish();
26  
27   obsmem* OM;
28
29   void plaqCompute();
30   static double plaqSus(vector< vector<double> > *vals, void *para);
31
32   sim *Sim;
33   obstat<double,double> oPlaq;
34 };
35
36 obs_plaq::obs_plaq(o815 *_O815) : o815::obs("plaq", 
37                                             _O815->paraQ->getParaNames() + "plaq:plaq_err:plaqsus:plaqsus_err", 
38                                             _O815, sizeof(obsmem) ) {
39   OM = (obsmem*)obsMem;
40   Sim = (sim*)O815->Sim;
41 }
42
43 void obs_plaq::_start() {
44   //*out << "OBS_test: start" << endl;
45 };
46
47 void obs_plaq::_meas(bool loadedobs, const int& nthmeas) {
48   if (!loadedobs)
49     plaqCompute();
50
51   oPlaq.addMeas(OM->plaq);
52 };
53
54 void obs_plaq::_finish() {
55   *out << O815->paraQ->getParaVals();
56
57   int compid_plaq, compid_plaqsus;
58
59   compid_plaq = oPlaq.computeEasy();
60   compid_plaqsus = oPlaq.computeJack(obs_plaq::plaqSus, &(Sim->lsize4));
61
62   *out << "\t" << oPlaq.getMean(compid_plaq) << "\t" << oPlaq.getErr(compid_plaq);
63   *out << "\t" << oPlaq.getMean(compid_plaqsus) << "\t" << oPlaq.getErr(compid_plaqsus);
64
65   *out << endl;
66
67   oPlaq.reset();
68 };
69
70 void obs_plaq::plaqCompute()
71 {
72   OM->plaq = 0;
73   
74   for( int ix=0; ix<Sim->lsize4; ix++ )
75     for( int inu=0; inu<3; inu++ )
76       for( int isigma=inu+1; isigma<4; isigma++ ) {
77         OM->plaq += real( Sim->U[ ix*4 + inu ] * Sim->U[ (*Sim->nb)[ix*8+inu]*4 + isigma ]  
78                           * conj(Sim->U[ (*Sim->nb)[ix*8+isigma]*4 + inu ]) * conj(Sim->U[ ix*4 + isigma ]) );
79       }
80   
81   OM->plaq /= Sim->lsize4*6;
82 }
83
84 double obs_plaq::plaqSus(vector< vector<double> > *vals, void *para) {
85   double mean=0, mean2=0;
86   for(vector< vector<double> >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt)  
87     {
88       mean += (*valIt)[0];
89       mean2 += pow((*valIt)[0],2);
90     }
91   mean /= vals->size();
92   mean2 /= vals->size();
93   
94   return ( mean2 - pow(mean,2) ) * *(int*)para * 6;
95 }
96
97 #endif