4 #include "latlib/o815/o815.h"
6 #include "latlib/writeout.h"
8 #include "latlib/obstat.hpp"
14 class obs_phi2 : public o815::obs {
22 obs_phi2(o815 *_O815);
26 void _meas(bool loadedobs, const int& nthmeas);
33 static void prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
34 static double phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
37 obstat<double,double> oPhi2[2];
40 obs_phi2::obs_phi2(o815 *_O815) : o815::obs("phi2",
41 _O815->paraQ->getParaNames() +
42 "phi2one:phi2one_err:phi2onesus:phi2onesus_err"
43 ":phi2two:phi2two_err:phi2twosus:phi2twosus_err",
44 _O815, sizeof(obsmem) ) {
46 Sim = (sim*)O815->Sim;
49 void obs_phi2::_start() {
50 //*out << "OBS_test: start" << endl;
53 void obs_phi2::_meas(bool loadedobs, const int& nthmeas) {
57 for (int iflav=0; iflav<2; iflav++) {
58 double tmpMeas[3] = {OM->A[iflav], OM->B[iflav], OM->C[iflav]};
59 oPhi2[iflav].addMeas(tmpMeas, 3);
63 void obs_phi2::_finish() {
64 *out << O815->paraQ->getParaVals();
66 int compid_phi2[2], compid_phi2sus[2];
68 for (int iflav=0; iflav<2; iflav++) {
69 compid_phi2[iflav] = oPhi2[iflav].computeEasy();
70 compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::prePhi2Sus, obs_phi2::phi2Sus, &(Sim->lsize4));
72 *out << "\t" << oPhi2[iflav].getMean(compid_phi2[iflav]) / Sim->lsize4 << "\t" << oPhi2[iflav].getErr(compid_phi2[iflav]) / Sim->lsize4;
73 *out << "\t" << oPhi2[iflav].getMean(compid_phi2sus[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2sus[iflav]);
81 void obs_phi2::phi2Compute()
83 for(int i=0; i<2; i++) {
88 for (int x = 0; x < Sim->lsize4; x++) {
91 wp2w = Sim->WF( Sim->wArg(x,i) + 2, Sim->wArg(x,i), i );
94 OM->B[i] += Sim->WF( Sim->wArg(x,i) + 4, Sim->wArg(x,i), i );
95 OM->C[i] += pow(wp2w, 2);
100 void obs_phi2::prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para)
102 preCalculated->push_back(0);
103 preCalculated->push_back(0);
105 for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt)
107 (*preCalculated)[0] += pow( (*valIt)[0], 2 ) + (*valIt)[1] - (*valIt)[2];
108 (*preCalculated)[1] += (*valIt)[0];
112 double obs_phi2::phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
113 return (( (*preCalculated)[0] - pow((*excludedMeas)[0], 2) - (*excludedMeas)[1] + (*excludedMeas)[2] ) / (nmeas-1)
114 - pow( ( (*preCalculated)[1] - (*excludedMeas)[0] ) / (nmeas-1), 2 ))