X-Git-Url: http://git.treefish.org/~alex/phys/u1casc.git/blobdiff_plain/8bf84241c8516b086e026b43f3bcb8b8c5ed78ae..a0c10794ee1276a61a221a398f96df89658149dd:/u1casc-ordinary/obs_phi2.hpp?ds=inline diff --git a/u1casc-ordinary/obs_phi2.hpp b/u1casc-ordinary/obs_phi2.hpp index 9afc390..0cad20e 100644 --- a/u1casc-ordinary/obs_phi2.hpp +++ b/u1casc-ordinary/obs_phi2.hpp @@ -27,7 +27,9 @@ private: obsmem* OM; void phi2Compute(); - static double phi2Sus(vector< vector > *vals, void *para); + + static void prePhi2Sus(vector< vector > *allVals, vector *preCalculated, void *para); + static double phi2Sus(vector *preCalculated, vector *excludedMeas, int nmeas, void *para); sim *Sim; obstat oPhi2[2]; @@ -61,7 +63,7 @@ void obs_phi2::_finish() { for (int iflav=0; iflav<2; iflav++) { compid_phi2[iflav] = oPhi2[iflav].computeEasy(); - compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::phi2Sus, &(Sim->lsize4)); + compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::prePhi2Sus, obs_phi2::phi2Sus, &(Sim->lsize4)); *out << "\t" << oPhi2[iflav].getMean(compid_phi2[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2[iflav]); *out << "\t" << oPhi2[iflav].getMean(compid_phi2sus[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2sus[iflav]); @@ -84,17 +86,20 @@ void obs_phi2::phi2Compute() } } -double obs_phi2::phi2Sus(vector< vector > *vals, void *para) { - double mean=0, mean2=0; - for(vector< vector >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt) - { - mean += (*valIt)[0]; - mean2 += pow((*valIt)[0],2); - } - mean /= vals->size(); - mean2 /= vals->size(); - - return ( mean2 - pow(mean,2) ) * *(int*)para; +void obs_phi2::prePhi2Sus(vector< vector > *allVals, vector *preCalculated, void *para) { + preCalculated->push_back(0); + preCalculated->push_back(0); + + for(vector< vector >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) { + (*preCalculated)[0] += (*valIt)[0]; + (*preCalculated)[1] += pow((*valIt)[0],2); + } +} + +double obs_phi2::phi2Sus(vector *preCalculated, vector *excludedMeas, int nmeas, void *para) { + return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) ) / (nmeas-1) + - pow( ( (*preCalculated)[0] - (*excludedMeas)[0] ) / (nmeas-1), 2 )) + * *(int*)para; } #endif