Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
AnalyticalIntegrals.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Authors: L. Moneta, A. Flandi 2015
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2015 ROOT Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10//
11// AnalyticalIntegrals.cxx
12//
13//
14// Created by Aurélie Flandi on 09.09.14.
15//
16//
17
18#include "AnalyticalIntegrals.h"
19
20#include "TROOT.h"
21#include "TF1.h"
22#include "TFormula.h"
23#include "TMath.h"
24#include "Math/DistFuncMathCore.h" //for cdf
25
26#include <cstdio>
27
29{
30
31 Double_t xmin = a;
32 Double_t xmax = b;
33 Int_t num = f->GetNumber();
34 Double_t *p = f->GetParameters();
35 Double_t result = 0.;
36
37 TFormula * formula = f->GetFormula();
38 if (!formula) {
39 Error("TF1::AnalyticalIntegral","Invalid formula number - return a NaN");
40 return TMath::QuietNaN();
41 }
42
43 if (num == 200)//expo: exp(p0+p1*x)
44 {
45 result = ( exp(p[0]+p[1]*xmax) - exp(p[0]+p[1]*xmin))/p[1];
46 }
47 else if (num == 100)//gaus: [0]*exp(-0.5*((x-[1])/[2])^2))
48 {
49 double amp = p[0];
50 double mean = p[1];
51 double sigma = p[2];
52 if (formula->TestBit(TFormula::kNormalized))
54 else
55 result = amp * sqrt(2 * TMath::Pi()) * sigma *
57 }
58 else if (num == 400)//landau: root::math::landau(x,mpv=0,sigma=1,bool norm=false)
59 {
60
61 double amp = p[0];
62 double mean = p[1];
63 double sigma = p[2];
64 //printf("computing integral for landau in [%f,%f] for m=%f s = %f \n",xmin,xmax,mean,sigma);
65 if (formula->TestBit(TFormula::kNormalized) )
67 else
69 }
70 else if (num == 500) //crystal ball
71 {
72 double amp = p[0];
73 double mean = p[1];
74 double sigma = p[2];
75 double alpha = p[3];
76 double n = p[4];
77
78 //printf("computing integral for CB in [%f,%f] for m=%f s = %f alpha = %f n = %f\n",xmin,xmax,mean,sigma,alpha,n);
79 if (alpha > 0)
81 else {
83 }
84 }
85
86 else if (num >= 300 && num < 400)//polN
87 {
88 Int_t n = num - 300;
89 for (int i=0;i<n+1;i++)
90 {
91 result += p[i]/(i+1)*(std::pow(xmax,i+1)-std::pow(xmin,i+1));
92 }
93 }
94 else
96
97 return result;
98}
Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b)
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
float xmin
float xmax
1-Dim function class
Definition TF1.h:233
The Formula class.
Definition TFormula.h:89
@ kNormalized
Set to true if the TFormula (ex gausn) is normalized.
Definition TFormula.h:180
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
double crystalball_integral(double x, double alpha, double n, double sigma, double x0=0)
Integral of the not-normalized Crystal Ball function.
double landau_cdf(double x, double xi=1, double x0=0)
Cumulative distribution function of the Landau distribution (lower tail).
const Double_t sigma
const Int_t n
Definition legend1.C:16
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Definition TMath.h:902
constexpr Double_t Pi()
Definition TMath.h:37