4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
14 class obs_phi2 : public o815::obs {
20 obs_phi2(o815 *_O815);
24 void _meas(bool loadedobs, const int& nthmeas);
31 static void prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
32 static double phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
35 obstat<double,double> oPhi2[2];
38 obs_phi2::obs_phi2(o815 *_O815) : o815::obs("phi2",
39 _O815->paraQ->getParaNames() +
40 "phi2one:phi2one_err:phi2onesus:phi2onesus_err"
41 ":phi2two:phi2two_err:phi2twosus:phi2twosus_err",
42 _O815, sizeof(obsmem) ) {
44 Sim = (sim*)O815->Sim;
47 void obs_phi2::_start() {
48 //*out << "OBS_test: start" << endl;
51 void obs_phi2::_meas(bool loadedobs, const int& nthmeas) {
55 for (int iflav=0; iflav<2; iflav++)
56 oPhi2[iflav].addMeas(OM->phi2[iflav]);
59 void obs_phi2::_finish() {
60 *out << O815->paraQ->getParaVals();
62 int compid_phi2[2], compid_phi2sus[2];
64 for (int iflav=0; iflav<2; iflav++) {
65 compid_phi2[iflav] = oPhi2[iflav].computeEasy();
66 compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::prePhi2Sus, obs_phi2::phi2Sus, &(Sim->lsize4));
68 *out << "\t" << oPhi2[iflav].getMean(compid_phi2[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2[iflav]);
69 *out << "\t" << oPhi2[iflav].getMean(compid_phi2sus[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2sus[iflav]);
77 void obs_phi2::phi2Compute()
79 for (int iflav=0; iflav<2; iflav++) {
82 for (int ix = 0; ix < Sim->lsize4; ix++)
83 OM->phi2[iflav] += norm(Sim->phi[ iflav*Sim->lsize4 + ix ]);
85 OM->phi2[iflav] /= Sim->lsize4;
89 void obs_phi2::prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
90 preCalculated->push_back(0);
91 preCalculated->push_back(0);
93 for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
94 (*preCalculated)[0] += (*valIt)[0];
95 (*preCalculated)[1] += pow((*valIt)[0],2);
99 double obs_phi2::phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
100 return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) )
101 - pow( (*preCalculated)[0] - (*excludedMeas)[0], 2 ))