Public Member Functions | Private Attributes | List of all members
ana::FitToFourier Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/CAFAna/Core/Utilities.h"

Public Member Functions

 FitToFourier (TH1 *h, double xlo, double xhi, int NOsc)
 
 ~FitToFourier ()
 
TF1 * Fit () const
 
double operator() (double *x, double *par) const
 

Private Attributes

const TH1 * fHist
 
const double fxlo
 
const double fxhi
 
const int fNOsc
 

Detailed Description

Definition at line 203 of file Utilities.h.

Constructor & Destructor Documentation

ana::FitToFourier::FitToFourier ( TH1 *  h,
double  xlo,
double  xhi,
int  NOsc 
)

Definition at line 406 of file Utilities.cxx.

ana::FitToFourier::~FitToFourier ( )

Definition at line 412 of file Utilities.cxx.

413  {
414  }

Member Function Documentation

TF1 * ana::FitToFourier::Fit ( ) const

Definition at line 427 of file Utilities.cxx.

References plot_validation_datamc::c, std::cos(), MakeMiniprodValidationCuts::f, fHist, fNOsc, fxhi, fxlo, MECModelEnuComparisons::i, M_PI, cet::sqlite::max(), min(), getGoodRuns4SAM::n, plotROC::nBins, std::sin(), ana::UniqueName(), submit_syst::x, and submit_syst::y.

Referenced by SmoothWithFourierFit().

428  {
429  std::vector<double> s(fNOsc, 0.);
430  std::vector<double> c(fNOsc, 0.);
431  int nBins = 0;
432  for(int i = 1; i <= fHist->GetNbinsX(); ++i){
433  const double x = M_PI * fHist->GetXaxis()->GetBinCenter(i);
434  const double y = fHist->GetBinContent(i);
435 
436  if(y == 0) continue;
437  ++nBins;
438 
439  for(int n = 0; n <= fNOsc; ++n){
440  s[n] += y * sin(n*x);
441  c[n] += y * cos(n*x);
442  }
443  }
444 
445  for(int n = 0; n <= fNOsc; ++n){
446  s[n] *= 2./nBins;
447  c[n] *= 2./nBins;
448  }
449 
450  TF1* f = new TF1(UniqueName().c_str(), this, fxlo, fxhi, 2*fNOsc+1);
451 
452  f->SetParameter(0, c[0]/2);
453  for(int n = 1; n <= fNOsc; ++n){
454  f->SetParameter(n*2-1, s[n]);
455  f->SetParameter(n*2, c[n]);
456  }
457 
458  // Because ROOT is having problems drawing f if I don't
459  double min = fHist->GetMinimum();
460  double max = fHist->GetMaximum();
461  f->GetYaxis()->SetRangeUser(0.8*min, 1.2*max);
462  return f;
463  }
const double fxhi
Definition: Utilities.h:214
int nBins
Definition: plotROC.py:16
#define M_PI
Definition: SbMath.h:34
const XML_Char * s
Definition: expat.h:262
const double fxlo
Definition: Utilities.h:213
const TH1 * fHist
Definition: Utilities.h:212
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
T sin(T number)
Definition: d0nt_math.hpp:132
T cos(T number)
Definition: d0nt_math.hpp:78
const int fNOsc
Definition: Utilities.h:215
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
double ana::FitToFourier::operator() ( double *  x,
double *  par 
) const

Definition at line 417 of file Utilities.cxx.

References std::cos(), fNOsc, MECModelEnuComparisons::i, M_PI, std::sin(), and febshutoff_auto::val.

418  {
419  double x0 = x[0];
420  double val = par[0];
421  for (int i = 1; i <= fNOsc; i++)
422  val += par[2*i-1]*sin(i*M_PI*x0) + par[2*i]*cos(i*M_PI*x0);
423  return val;
424  }
Int_t par
Definition: SimpleIterate.C:24
#define M_PI
Definition: SbMath.h:34
T sin(T number)
Definition: d0nt_math.hpp:132
T cos(T number)
Definition: d0nt_math.hpp:78
const int fNOsc
Definition: Utilities.h:215

Member Data Documentation

const TH1* ana::FitToFourier::fHist
private

Definition at line 212 of file Utilities.h.

Referenced by Fit().

const int ana::FitToFourier::fNOsc
private

Definition at line 215 of file Utilities.h.

Referenced by Fit(), and operator()().

const double ana::FitToFourier::fxhi
private

Definition at line 214 of file Utilities.h.

Referenced by Fit().

const double ana::FitToFourier::fxlo
private

Definition at line 213 of file Utilities.h.

Referenced by Fit().


The documentation for this class was generated from the following files: