X-Git-Url: http://git.treefish.org/~alex/phys/u1casc.git/blobdiff_plain/6a7825ba94ab1d448ae48a3868e41f2683f9431d..fb62bce00a991081189fc750d6acdd51bbc7c468:/u1casc-ordinary/obs_corrphichimass.hpp diff --git a/u1casc-ordinary/obs_corrphichimass.hpp b/u1casc-ordinary/obs_corrphichimass.hpp new file mode 100644 index 0000000..45880c1 --- /dev/null +++ b/u1casc-ordinary/obs_corrphichimass.hpp @@ -0,0 +1,147 @@ +#ifndef OBS_CORRPHICHIMASS_HPP +#define OBS_CORRPHICHIMASS_HPP + +#include "latlib/o815/o815.h" + +#include "latlib/writeout.h" + +#include "latlib/obstat.hpp" + +#include +#include + +#include + +#define U1 0 +#define U2 1 +#define F1 2 +#define F2 3 + +using namespace std; + +class obs_corrphichimass : public o815::obs { + +public: + obs_corrphichimass(o815 *_O815); + +private: + void _start(); + void _meas(bool loadedobs, const int& nthmeas); + void _finish(); + + void corrCompute(); + static complex effMass(vector < complex > *preCalculated, vector< complex > *excludedMeas, int nmeas, void *para); + static void preEffMass(vector< vector < complex > > *allVals, vector < complex > *preCalculated, void *para); + + sim *Sim; + obstat< complex, complex > oC; + + int spatialV; + + complex *OM; +}; + +obs_corrphichimass::obs_corrphichimass(o815 *_O815) : o815::obs("corrphichimass", + _O815->paraQ->getParaNames() + + "tsep" + ":phichi_effmass:phichi_effmass_err", + _O815, sizeof(complex)*(_O815->comargs.lsize[1]/2+1) ) { + + OM = (complex*)(obsMem); + + Sim = (sim*)O815->Sim; + spatialV = O815->comargs.lsize[0] * O815->comargs.lsize[0] * O815->comargs.lsize[0]; +} + +void obs_corrphichimass::_start() { + //*out << "OBS_test: start" << endl; +}; + +void obs_corrphichimass::_meas(bool loadedobs, const int& nthmeas) { + if (!loadedobs) + corrCompute(); + + oC.addMeas( OM, O815->comargs.lsize[1]/2+1 ); +}; + +void obs_corrphichimass::_finish() { + int compid_corr[O815->comargs.lsize[1]/2][4]; + int compid_effmass[O815->comargs.lsize[1]/2-1][4]; + + for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) + compid_corr[itsep][U1] = oC.computeEasy(itsep); + + for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) { + pair effmasspass( itsep, O815->comargs.lsize[1]/2 ); + compid_effmass[itsep][U1] = oC.computeJack(obs_corrphichimass::preEffMass, obs_corrphichimass::effMass, &effmasspass); + } + + for (int itsep = 0; itsep < O815->comargs.lsize[1]/2-1; itsep++) { + *out << O815->paraQ->getParaVals(); + *out << "\t" << itsep; + + *out << "\t" << real( oC.getMean(compid_effmass[itsep][U1]) ) + << "\t" << real( oC.getErr (compid_effmass[itsep][U1]) ); + + *out << endl; + } + + oC.reset(); +}; + +void obs_corrphichimass::corrCompute() +{ + complex phislice[O815->comargs.lsize[1]]; + + OM[O815->comargs.lsize[1]/2] = 0; + + for (int it = 0; it < O815->comargs.lsize[1]; it++) { + phislice[it] = 0; + + for (int ix = 0; ix < spatialV; ix++) + phislice[it] += Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ] * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ]; + //phislice[it] += conj(Sim->phi[ 0*Sim->lsize4 + it*spatialV + ix ]) * Sim->phi[ 1*Sim->lsize4 + it*spatialV + ix ]; + + phislice[it] /= spatialV; + + OM[O815->comargs.lsize[1]/2] += phislice[it]; + } + + for (int itsep = 0; itsep < O815->comargs.lsize[1]/2; itsep++) { + OM[itsep] = 0; + + for (int it = 0; it < O815->comargs.lsize[1]; it++) + OM[itsep] += phislice[ (it+itsep)%O815->comargs.lsize[1] ] * conj( phislice[it] ); + + OM[itsep] /= O815->comargs.lsize[1]; + } + + OM[O815->comargs.lsize[1]/2] /= O815->comargs.lsize[1]; +} + +void obs_corrphichimass::preEffMass(vector< vector < complex > > *allVals, vector < complex > *preCalculated, void *para) { + pair *myparas = (pair*)para; + + preCalculated->push_back(0); + preCalculated->push_back(0); + preCalculated->push_back(0); + + for(vector< vector< complex > >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) { + (*preCalculated)[0] += (*valIt)[myparas->first]; + (*preCalculated)[1] += (*valIt)[myparas->first+1]; + (*preCalculated)[2] += (*valIt)[myparas->second]; + } +} + +complex obs_corrphichimass::effMass(vector < complex > *preCalculated, vector< complex > *excludedMeas, int nmeas, void *para) { + pair *myparas = (pair*)para; + + double disconnected = norm( ( (*preCalculated)[2] - (*excludedMeas)[myparas->second] ) / (complex)(nmeas-1) ); + + return std::log( abs( + ( ( (*preCalculated)[0] - (*excludedMeas)[myparas->first] ) / (complex)(nmeas-1) - disconnected ) / + ( ( (*preCalculated)[1] - (*excludedMeas)[myparas->first+1] ) / (complex)(nmeas-1) - disconnected ) + ) ); +} + +#endif