// the function computes distances from many points to the parabola described by the input values a,b,c (using some global variables and a numetrical minimisation algorithm minDist). double PRF_CHI_ev (const double *x){ //cout <<"############## FUNCTION CALL ##########"<GetParameter(0)<<" "<GetParameter(1)<<" "<GetParameter(2)<<" "<GetParameter(3)<Interpolate(x_pos[padx[j][k]],y_pos[pady[j][k]])<SetParabola(x[0],x[1],x[2]); para->SetParameter(2,x[0]); para->SetParameter(1,x[1]); para->SetParameter(0,x[2]); PadPair[j][k] = ChargeFraction_real(x_pos[padx[j][k]],y_pos[pady[j][k]],charge[j][k],thisSeg); Localqf[j][k] = PadPair[j][k].qfrac; x_pad = x_pos[padx[j][k]]; y_pad = y_pos[pady[j][k]]; x_closest = minDist(a,b,c,x_pad,y_pad); y_closest = x_closest*x_closest*a + x_closest*b + c; distance = sqrt( (x_closest-x_pad)*(x_closest-x_pad) + (y_closest-y_pad)*(y_closest-y_pad) ); //cout<<" PADPAIR: "< 0 ){ distance = distance; }else if(y_pad - y_closest < 0 ){ distance = -distance; }else{ if(x_pad - x_closest > 0 ){ distance = distance; }else if(x_pad - x_closest < 0 ){ distance = -distance; } } if (charge[j][k]!=0){ //chi += ( PadPair[j][k].qfrac - func->Eval( PadPair[j][k].distance ) )*( PadPair[j][k].qfrac - func->Eval( PadPair[j][k].distance ) ) // / ( ( graph_FWs->Eval(PadPair[j][k].distance) )*( graph_FWs->Eval(PadPair[j][k].distance) ) ); sigup = BMinvert( PadPair[j][k].qfrac + graph_FWs->Eval(distance)/2., distance ); sigdn = BMinvert( PadPair[j][k].qfrac - graph_FWs->Eval(distance)/2., distance ); exp_distance = BMinvert( PadPair[j][k].qfrac, distance ); sig = graph_FWs->Eval(exp_distance)/func->Derivative(exp_distance); if( sig > 0.03 ) sig = 0.03; // sig = fabs(sigup-sigdn); // sigma must no exceed 3 cm //cout<Eval(distance)/2.<<"\t"<SetPoint(cnt,b,chi); std::ofstream of; of.open ("func.txt", std::ofstream::out | std::ofstream::app); of<