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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-02-25/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 210 of file Utilities.h.

Constructor & Destructor Documentation

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

Definition at line 482 of file Utilities.cxx.

ana::FitToFourier::~FitToFourier ( )

Definition at line 488 of file Utilities.cxx.

489  {
490  }

Member Function Documentation

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

Definition at line 503 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().

504  {
505  std::vector<double> s(fNOsc, 0.);
506  std::vector<double> c(fNOsc, 0.);
507  int nBins = 0;
508  for(int i = 1; i <= fHist->GetNbinsX(); ++i){
509  const double x = M_PI * fHist->GetXaxis()->GetBinCenter(i);
510  const double y = fHist->GetBinContent(i);
511 
512  if(y == 0) continue;
513  ++nBins;
514 
515  for(int n = 0; n <= fNOsc; ++n){
516  s[n] += y * sin(n*x);
517  c[n] += y * cos(n*x);
518  }
519  }
520 
521  for(int n = 0; n <= fNOsc; ++n){
522  s[n] *= 2./nBins;
523  c[n] *= 2./nBins;
524  }
525 
526  TF1* f = new TF1(UniqueName().c_str(), this, fxlo, fxhi, 2*fNOsc+1);
527 
528  f->SetParameter(0, c[0]/2);
529  for(int n = 1; n <= fNOsc; ++n){
530  f->SetParameter(n*2-1, s[n]);
531  f->SetParameter(n*2, c[n]);
532  }
533 
534  // Because ROOT is having problems drawing f if I don't
535  double min = fHist->GetMinimum();
536  double max = fHist->GetMaximum();
537  f->GetYaxis()->SetRangeUser(0.8*min, 1.2*max);
538  return f;
539  }
const double fxhi
Definition: Utilities.h:221
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:220
const TH1 * fHist
Definition: Utilities.h:219
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:222
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 493 of file Utilities.cxx.

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

494  {
495  double x0 = x[0];
496  double val = par[0];
497  for (int i = 1; i <= fNOsc; i++)
498  val += par[2*i-1]*sin(i*M_PI*x0) + par[2*i]*cos(i*M_PI*x0);
499  return val;
500  }
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:222

Member Data Documentation

const TH1* ana::FitToFourier::fHist
private

Definition at line 219 of file Utilities.h.

Referenced by Fit().

const int ana::FitToFourier::fNOsc
private

Definition at line 222 of file Utilities.h.

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

const double ana::FitToFourier::fxhi
private

Definition at line 221 of file Utilities.h.

Referenced by Fit().

const double ana::FitToFourier::fxlo
private

Definition at line 220 of file Utilities.h.

Referenced by Fit().


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