CMS 3D CMS Logo

CSCThrTurnOnFcn.cc
Go to the documentation of this file.
3 #include <cmath>
4 #include <iostream>
5 #include <vector>
6 #include "TMath.h"
7 
8 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
9 double CSCThrTurnOnFcn::operator()(std::span<const double> par) const {
10 #else
11 double CSCThrTurnOnFcn::operator()(const std::vector<double>& par) const {
12 #endif
13  double x, y, er, fn;
14  double N = norm;
15  double chi2 = 0.;
16 
17  int size = xdata.size();
18  for (int i = 0; i < size; ++i) {
19  x = xdata[i];
20  y = ydata[i];
21  er = ery[i];
22 
23  fn = (x - par[0]) / (par[1] * 1.4142);
24  fn = N * (1. - TMath::Erf(fn)) / 2.;
25 
26  double diff = y - fn;
27  chi2 += diff * diff / (er * er);
28 
29  // std::cout<<"CSC AFEB threshold fit "<<i+1<<" "<<x<<" "<<y<<" "
30  // <<er<<" "<<fn<<" "<<chi2<<" "
31  // <<par[0]<<" "<<par[1]<<"\n";
32 
33  LogDebug("CSC") << " AFEB threshold fit " << i + 1 << " " << x << " " << y << " " << er << " " << fn << " " << chi2
34  << " " << par[0] << " " << par[1] << "\n";
35  }
36  // std::cout<<"Chi2 "<<chi2<<std::endl;
37  return chi2;
38 }
size
Write out results.
std::vector< float > ydata
std::vector< float > ery
#define N
Definition: blowfish.cc:9
std::vector< float > xdata
data
double operator()(std::span< const double >) const override
Provide the chi-squared function for the given data.
#define LogDebug(id)