MINT2
RooJohnsonSU.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * *
4  * Copyright (c) 2000-2005, Regents of the University of California *
5  * and Stanford University. All rights reserved. *
6  * *
7  * Redistribution and use in source and binary forms, *
8  * with or without modification, are permitted according to the terms *
9  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
10  *****************************************************************************/
11 
12 // -- CLASS DESCRIPTION [PDF] --
13 //
14 // file: RooJohnsonSU.h
15 // author: Maurizio Martinelli (Nikhef)
16 // email: maurizio.martinelli@cern.ch
17 //
18 // description: this distribution can have highly asymmetric tails and is
19 // therefore helpful in fitting the mass difference between D* and D0 mass.
20 //
21 // reference: Johnson, N. L. (1954). Systems of frequency curves derived from the first law of Laplace., Trabajos de Estadistica, 5, 283-291.
22 //
23 
24 #include "Riostream.h"
25 
26 #include "Mint/RooJohnsonSU.h"
27 #include "RooAbsReal.h"
28 #include "RooAbsCategory.h"
29 #include "RooMath.h"
30 
31 #include "TMath.h"
32 
33 #include <iostream>
34 
35 using namespace std;
36 
37 //ClassImp(RooJohnsonSU)
38 
39 RooJohnsonSU::RooJohnsonSU(const char *name, const char *title,
40  RooAbsReal& _x,
41  RooAbsReal& _mean,
42  RooAbsReal& _width,
43  RooAbsReal& _nu,
44  RooAbsReal& _tau) :
45 RooAbsPdf(name,title),
46 x("x","x",this,_x),
47 mean("mean","mean",this,_mean),
48 width("width","width",this,_width),
49 nu("nu","nu",this,_nu),
50 tau("tau","tau",this,_tau)
51 {
52 }
53 
54 
55 RooJohnsonSU::RooJohnsonSU(const RooJohnsonSU& other, const char* name) :
56 RooAbsPdf(other,name),
57 x("x",this,other.x),
58 mean("mean",this,other.mean),
59 width("width",this,other.width),
60 nu("nu",this,other.nu),
61 tau("tau",this,other.tau)
62 {
63 }
64 
65 
66 
67 Double_t RooJohnsonSU::evaluate() const
68 {
69  // ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
70  // calculate a few variables
71  double w = exp( tau * tau);
72  double omega = - nu * tau;
73  double c = 0.5 * (w-1) * (w * TMath::CosH(2 * omega) + 1);
74  c = pow(c, -0.5);
75  double z = (x - (mean + c * width * sqrt(w) * TMath::SinH(omega) )) / c / width;
76  double r = -nu + TMath::ASinH(z) / tau;
77  // the actual value
78  double val = 1. / (c * width * 2 * TMath::Pi());
79  val *= 1. / (tau * sqrt(z*z+1));
80  val *= exp(-0.5 * r * r);
81  // return
82  return val ;
83 }
84 
85 // Integrals
86 Int_t
87 RooJohnsonSU::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
88 {
89  if (matchArgs(allVars,analVars,x)) return 1 ;
90  return 0 ;
91 }
92 
93 Double_t
94 RooJohnsonSU::analyticalIntegral(Int_t code, const char* rangeName) const
95 {
96  assert(code==1) ;
97 
98  // calculate a few variables
99  double w = exp( tau * tau);
100  double omega = - nu * tau;
101  double c = 0.5 * (w-1) * (w * TMath::CosH(2 * omega) + 1);
102  c = pow(c, -0.5);
103  double zmax = (- x.max(rangeName) + (mean + c * width * sqrt(w) * TMath::SinH(omega) )) / c / width;
104  double zmin = (- x.min(rangeName) + (mean + c * width * sqrt(w) * TMath::SinH(omega) )) / c / width;
105  static const Double_t pi = atan2(0.0,-1.0);
106  static const Double_t PiBy2 = pi/2.0;
107  static const Double_t rootPiBy2 = sqrt(PiBy2);
108 
109  // the integral calculation
110  Double_t ret = 0;
111  if(code==1){
112  // ret = rootPiBy2 * sigx * (RooMath::erf((x.max(rangeName)-mean)/xscale)-RooMath::erf((x.min(rangeName)-mean)/xscale));
113  ret = -0.25/rootPiBy2* ( RooMath::erf( (nu*tau + TMath::ASinH( zmax ) )/(sqrt(2)*tau) )-
114  RooMath::erf( (nu*tau + TMath::ASinH( zmin ) )/(sqrt(2)*tau) ) );
115 
116  /*-rootPiBy2 * ( RooMath::erf( PiBy2 * nu - ( PiBy2 * TMath::ASinH( zmax ) / tau ) ) -
117  RooMath::erf( PiBy2 * nu - ( PiBy2 * TMath::ASinH( zmin ) / tau ) ) );
118  ret *= c * width;
119  ret *= 0.5 / c / width / pi;*/
120  // if (gDebug>2) {
121  // cout << "Int_gauss_dx(mean=" << mean << ",sigma=" << sigma << ", xmin=" << x.min(rangeName) << ", xmax=" << x.max(rangeName) << ")=" << ret << endl ;
122  // }
123  } else{
124  cout << "Error in RooJohnsonSU::analyticalIntegral" << endl;
125  }
126  return ret ;
127 
128 }
129 
130 
131 
RooRealProxy mean
Definition: RooJohnsonSU.h:47
static const double pi
Double_t evaluate() const
RooRealProxy width
Definition: RooJohnsonSU.h:48
RooRealProxy x
Definition: RooJohnsonSU.h:46
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
RooRealProxy tau
Definition: RooJohnsonSU.h:50
RooRealProxy nu
Definition: RooJohnsonSU.h:49