1 #ifndef OBS_CORRCHICHI_HPP
2 #define OBS_CORRCHICHI_HPP
4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
17 class obs_corrchichi : public o815::obs {
20 obs_corrchichi(o815 *_O815);
24 void _meas(bool loadedobs, const int& nthmeas);
28 static complex<double> effMass(vector < complex<double> > *preCalculated, vector< complex<double> > *excludedMeas, int nmeas, void *para);
29 static void preEffMass(vector< vector < complex<double> > > *allVals, vector < complex<double> > *preCalculated, void *para);
32 obstat< complex<double>, complex<double> > oC;
39 obs_corrchichi::obs_corrchichi(o815 *_O815) : o815::obs("corrchichi",
40 _O815->paraQ->getParaNames() +
42 ":chichi_real:chichi_imag:chichi_abs:chichi_mass:chichi_mass_err",
43 _O815, sizeof(complex<double>)*(_O815->comargs.lsize[1]/2+1) ) {
45 OM = (complex<double>*)(obsMem);
47 Sim = (sim*)O815->Sim;
48 spatialV = O815->comargs.lsize[0] * O815->comargs.lsize[0] * O815->comargs.lsize[0];
51 void obs_corrchichi::_start() {
52 //*out << "OBS_test: start" << endl;
55 void obs_corrchichi::_meas(bool loadedobs, const int& nthmeas) {
59 oC.addMeas( OM, O815->comargs.lsize[1]/2+1 );
62 void obs_corrchichi::_finish() {
63 int compid_corr[O815->comargs.lsize[1]/2];
64 int compid_effmass[O815->comargs.lsize[1]/2-1];
66 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++)
67 compid_corr[itsep] = oC.computeEasy(itsep);
69 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) {
70 pair<int,int> effmasspass( itsep, O815->comargs.lsize[1]/2 );
71 compid_effmass[itsep] = oC.computeJack(obs_corrchichi::preEffMass, obs_corrchichi::effMass, &effmasspass);
74 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) {
75 *out << O815->paraQ->getParaVals();
76 *out << "\t" << itsep;
78 *out << "\t" << real( oC.getMean(compid_corr[itsep]) )
79 << "\t" << imag( oC.getMean(compid_corr[itsep]) )
80 << "\t" << abs ( oC.getMean(compid_corr[itsep]) );
82 if ( itsep < O815->comargs.lsize[1]/2-1 )
83 *out << "\t" << real( oC.getMean(compid_effmass[itsep]) )
84 << "\t" << real( oC.getErr (compid_effmass[itsep]) );
86 *out << "\t" << NAN << "\t" << NAN;
95 void obs_corrchichi::corrCompute()
97 complex<double> phislice[O815->comargs.lsize[1]];
99 OM[O815->comargs.lsize[1]/2] = 0;
101 for (int it = 0; it < O815->comargs.lsize[1]; it++) {
104 for (int ix = 0; ix < spatialV; ix++)
105 phislice[it] += conj(Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ]) * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ];
107 phislice[it] /= spatialV;
109 OM[O815->comargs.lsize[1]/2] += phislice[it];
112 for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) {
115 for (int it = 0; it < O815->comargs.lsize[1]; it++)
116 OM[itsep] += phislice[ (it+itsep)%O815->comargs.lsize[1] ] * conj( phislice[it] );
118 OM[itsep] /= O815->comargs.lsize[1];
121 OM[O815->comargs.lsize[1]/2] /= O815->comargs.lsize[1];
124 void obs_corrchichi::preEffMass(vector< vector < complex<double> > > *allVals, vector < complex<double> > *preCalculated, void *para) {
125 pair<int,int> *myparas = (pair<int,int>*)para;
127 preCalculated->push_back(0);
128 preCalculated->push_back(0);
129 preCalculated->push_back(0);
131 for(vector< vector< complex<double> > >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
132 (*preCalculated)[0] += (*valIt)[myparas->first];
133 (*preCalculated)[1] += (*valIt)[myparas->first+1];
134 (*preCalculated)[2] += (*valIt)[myparas->second];
138 complex<double> obs_corrchichi::effMass(vector < complex<double> > *preCalculated, vector< complex<double> > *excludedMeas, int nmeas, void *para) {
139 pair<int,int> *myparas = (pair<int,int>*)para;
141 double disconnected = norm( ( (*preCalculated)[2] - (*excludedMeas)[myparas->second] ) / (complex<double>)(nmeas-1) );
143 return std::log( abs(
144 ( ( (*preCalculated)[0] - (*excludedMeas)[myparas->first] ) / (complex<double>)(nmeas-1) - disconnected ) /
145 ( ( (*preCalculated)[1] - (*excludedMeas)[myparas->first+1] ) / (complex<double>)(nmeas-1) - disconnected )