1 #ifndef OBS_CORRPHICHIMASS_HPP
2 #define OBS_CORRPHICHIMASS_HPP
4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
22 class obs_corrphichimass : public o815::obs {
25 obs_corrphichimass(o815 *_O815);
29 void _meas(bool loadedobs, const int& nthmeas);
33 static complex<double> effMass(vector < complex<double> > *preCalculated, vector< complex<double> > *excludedMeas, int nmeas, void *para);
34 static void preEffMass(vector< vector < complex<double> > > *allVals, vector < complex<double> > *preCalculated, void *para);
37 obstat< complex<double>, complex<double> > oC;
44 obs_corrphichimass::obs_corrphichimass(o815 *_O815) : o815::obs("corrphichimass",
45 _O815->paraQ->getParaNames() +
47 ":phichi_effmass:phichi_effmass_err",
48 _O815, sizeof(complex<double>)*(_O815->comargs.lsize[1]/2+1) ) {
50 OM = (complex<double>*)(obsMem);
52 Sim = (sim*)O815->Sim;
53 spatialV = O815->comargs.lsize[0] * O815->comargs.lsize[0] * O815->comargs.lsize[0];
56 void obs_corrphichimass::_start() {
57 //*out << "OBS_test: start" << endl;
60 void obs_corrphichimass::_meas(bool loadedobs, const int& nthmeas) {
64 oC.addMeas( OM, O815->comargs.lsize[1]/2+1 );
67 void obs_corrphichimass::_finish() {
68 int compid_corr[O815->comargs.lsize[1]/2][4];
69 int compid_effmass[O815->comargs.lsize[1]/2-1][4];
71 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++)
72 compid_corr[itsep][U1] = oC.computeEasy(itsep);
74 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) {
75 pair<int,int> effmasspass( itsep, O815->comargs.lsize[1]/2 );
76 compid_effmass[itsep][U1] = oC.computeJack(obs_corrphichimass::preEffMass, obs_corrphichimass::effMass, &effmasspass);
79 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) {
80 *out << O815->paraQ->getParaVals();
81 *out << "\t" << itsep;
83 *out << "\t" << real( oC.getMean(compid_effmass[itsep][U1]) )
84 << "\t" << real( oC.getErr (compid_effmass[itsep][U1]) );
92 void obs_corrphichimass::corrCompute()
94 complex<double> phislice[O815->comargs.lsize[1]];
96 OM[O815->comargs.lsize[1]/2] = 0;
98 for (int it = 0; it < O815->comargs.lsize[1]; it++) {
101 for (int ix = 0; ix < spatialV; ix++)
102 phislice[it] += Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ] * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ];
103 //phislice[it] += conj(Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ]) * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ];
105 phislice[it] /= spatialV;
107 OM[O815->comargs.lsize[1]/2] += phislice[it];
110 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) {
113 for (int it = 0; it < O815->comargs.lsize[1]; it++)
114 OM[itsep] += phislice[ (it+itsep)%O815->comargs.lsize[1] ] * conj( phislice[it] );
116 OM[itsep] /= O815->comargs.lsize[1];
119 OM[O815->comargs.lsize[1]/2] /= O815->comargs.lsize[1];
122 void obs_corrphichimass::preEffMass(vector< vector < complex<double> > > *allVals, vector < complex<double> > *preCalculated, void *para) {
123 pair<int,int> *myparas = (pair<int,int>*)para;
125 preCalculated->push_back(0);
126 preCalculated->push_back(0);
127 preCalculated->push_back(0);
129 for(vector< vector< complex<double> > >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
130 (*preCalculated)[0] += (*valIt)[myparas->first];
131 (*preCalculated)[1] += (*valIt)[myparas->first+1];
132 (*preCalculated)[2] += (*valIt)[myparas->second];
136 complex<double> obs_corrphichimass::effMass(vector < complex<double> > *preCalculated, vector< complex<double> > *excludedMeas, int nmeas, void *para) {
137 pair<int,int> *myparas = (pair<int,int>*)para;
139 double disconnected = norm( ( (*preCalculated)[2] - (*excludedMeas)[myparas->second] ) / (complex<double>)(nmeas-1) );
141 return std::log( abs(
142 ( ( (*preCalculated)[0] - (*excludedMeas)[myparas->first] ) / (complex<double>)(nmeas-1) - disconnected ) /
143 ( ( (*preCalculated)[1] - (*excludedMeas)[myparas->first+1] ) / (complex<double>)(nmeas-1) - disconnected )