1 #include "Minuit2/VariableMetricMinimizer.h" 2 #include "Minuit2/FunctionMinimum.h" 16 theFitter =
new VariableMetricMinimizer();
25 const std::vector<float> & inputy,
27 std::vector<int> & dacoccup,
28 std::vector<float> & mypar,
29 std::vector<float> & ermypar,
38 std::vector<double> parinit(2,0);
39 std::vector<double> erparinit(2,0);
51 std::vector<float> ynorm;
52 std::vector<float> ery;
68 for(
size_t i=0;
i<inputx.size();
i++) {
69 if(inputy[
i]>0.0) sum++;
81 int nbeg=inputx.size();
86 for(
size_t i=inputx.size();
i>0;
i--) {
87 if(ynorm[
i-1]<1.0) nbeg--;
88 if(ynorm[
i-1]==1.0)
break;
91 for(
size_t i=nbeg;
i<inputx.size();
i++) {
93 x.push_back(inputx[
i]);
94 y.push_back(ynorm[i]);
96 float p=inputy[
i]/(
float)dacoccup[i];
97 float s=(
float)dacoccup[i] * p * (1.0-p);
105 if(ndf <=0)
return status;
111 for(
size_t i=0;
i<x.size();
i++) {
112 diff=y[
i]-half;
if(diff<0.0) diff=-
diff;
113 if(diff<dmin) {dmin=
diff; parinit[0]=x[
i];}
128 status = fmin.IsValid();
131 mypar[0]=(
float)fmin.Parameters().Vec()(0);
132 mypar[1]=(
float)fmin.Parameters().Vec()(1);
133 ermypar[0]=(
float)
sqrt( fmin.Error().Matrix()(0,0) );
134 ermypar[1]=(
float)
sqrt( fmin.Error().Matrix()(1,1) );
136 if(ermypar[0] !=0.0 && ermypar[1]!=0.0)
137 ercorr=(
float)fmin.Error().Matrix()(0,1)/(ermypar[0]*ermypar[1]);
140 ndf=y.size()-mypar.size();
void setNorm(float n)
Set the norm (if needed)
ModularFunctionMinimizer * theFitter
virtual bool ThresholdNoise(const std::vector< float > &inputx, const std::vector< float > &inputy, const int &npulses, std::vector< int > &dacoccup, std::vector< float > &mypar, std::vector< float > &ermypar, float &ercorr, float &chisq, int &ndf, int &niter, float &edm) const
void setData(const std::vector< float > &x, const std::vector< float > &y)
Cache the current data, x and y.
CSCThrTurnOnFcn * theOBJfun
void setErrors(const std::vector< float > &er)
Set the errors.