1 #ifndef OBS_CORRPHIPHIMASS_HPP
2 #define OBS_CORRPHIPHIMASS_HPP
4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
22 class obs_corrphiphimass : public o815::obs {
25 obs_corrphiphimass(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;
41 complex<double> *OM[4];
44 obs_corrphiphimass::obs_corrphiphimass(o815 *_O815) : o815::obs("corr",
45 _O815->paraQ->getParaNames() +
47 ":u1_effmass:u1_effmass_err",
48 _O815, 4*sizeof(complex<double>)*(_O815->comargs.lsize[1]/2+1) ) {
50 for (int ivar = 0; ivar<4; ivar++)
51 OM[ivar] = (complex<double>*)( obsMem + ivar*sizeof(complex<double>)*( _O815->comargs.lsize[1]/2 + 1 ) );
53 Sim = (sim*)O815->Sim;
54 spatialV = O815->comargs.lsize[0] * O815->comargs.lsize[0] * O815->comargs.lsize[0];
57 void obs_corrphiphimass::_start() {
58 //*out << "OBS_test: start" << endl;
61 void obs_corrphiphimass::_meas(bool loadedobs, const int& nthmeas) {
65 oC.addMeas( OM[U1], O815->comargs.lsize[1]/2+1 );
68 void obs_corrphiphimass::_finish() {
69 int compid_corr[O815->comargs.lsize[1]/2][4];
70 int compid_effmass[O815->comargs.lsize[1]/2-1][4];
72 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++)
73 compid_corr[itsep][U1] = oC.computeEasy(itsep);
75 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) {
76 pair<int,int> effmasspass( itsep, O815->comargs.lsize[1]/2 );
77 compid_effmass[itsep][U1] = oC.computeJack(obs_corrphiphimass::preEffMass, obs_corrphiphimass::effMass, &effmasspass);
80 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) {
81 *out << O815->paraQ->getParaVals();
82 *out << "\t" << itsep;
84 *out << "\t" << real( oC.getMean(compid_effmass[itsep][U1]) )
85 << "\t" << real( oC.getErr (compid_effmass[itsep][U1]) );
93 void obs_corrphiphimass::corrCompute()
95 complex<double> phislice[4][O815->comargs.lsize[1]];
97 OM[U1][O815->comargs.lsize[1]/2] = 0;
98 OM[U2][O815->comargs.lsize[1]/2] = 0;
99 OM[F1][O815->comargs.lsize[1]/2] = 0;
100 OM[F2][O815->comargs.lsize[1]/2] = 0;
102 for (int it = 0; it < O815->comargs.lsize[1]; it++) {
103 phislice[U1][it] = 0;
104 phislice[U2][it] = 0;
105 phislice[F1][it] = 0;
106 phislice[F2][it] = 0;
108 for (int ix = 0; ix < spatialV; ix++) {
109 phislice[U1][it] += conj(Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ]) * Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ];
110 phislice[U2][it] += conj(Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ]) * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ];
111 phislice[F1][it] += Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ];
112 phislice[F2][it] += Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ];
114 phislice[U1][it] /= spatialV;
115 phislice[U2][it] /= spatialV;
116 phislice[F1][it] /= spatialV;
117 phislice[F2][it] /= spatialV;
119 OM[U1][O815->comargs.lsize[1]/2] += phislice[U1][it];
120 OM[U2][O815->comargs.lsize[1]/2] += phislice[U2][it];
121 OM[F1][O815->comargs.lsize[1]/2] += phislice[F1][it];
122 OM[F2][O815->comargs.lsize[1]/2] += phislice[F2][it];
125 for (int icorr = 0; icorr < 4; icorr++) {
126 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) {
127 OM[icorr][itsep] = 0;
129 for (int it = 0; it < O815->comargs.lsize[1]; it++)
130 OM[icorr][itsep] += phislice[icorr][ (it+itsep)%O815->comargs.lsize[1] ] * conj( phislice[icorr][it] );
132 OM[icorr][itsep] /= O815->comargs.lsize[1];
135 OM[icorr][O815->comargs.lsize[1]/2] /= O815->comargs.lsize[1];
139 void obs_corrphiphimass::preEffMass(vector< vector < complex<double> > > *allVals, vector < complex<double> > *preCalculated, void *para) {
140 pair<int,int> *myparas = (pair<int,int>*)para;
142 preCalculated->push_back(0);
143 preCalculated->push_back(0);
144 preCalculated->push_back(0);
146 for(vector< vector< complex<double> > >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
147 (*preCalculated)[0] += (*valIt)[myparas->first];
148 (*preCalculated)[1] += (*valIt)[myparas->first+1];
149 (*preCalculated)[2] += (*valIt)[myparas->second];
153 complex<double> obs_corrphiphimass::effMass(vector < complex<double> > *preCalculated, vector< complex<double> > *excludedMeas, int nmeas, void *para) {
154 pair<int,int> *myparas = (pair<int,int>*)para;
156 double disconnected = norm( ( (*preCalculated)[2] - (*excludedMeas)[myparas->second] ) / (complex<double>)(nmeas-1) );
158 return std::log( abs(
159 ( ( (*preCalculated)[0] - (*excludedMeas)[myparas->first] ) / (complex<double>)(nmeas-1) - disconnected ) /
160 ( ( (*preCalculated)[1] - (*excludedMeas)[myparas->first+1] ) / (complex<double>)(nmeas-1) - disconnected )