KaliVeda
Toolkit for HIC analysis
KVGaus2D.cpp
1 //Created by KVClassFactory on Tue Feb 7 16:49:15 2012
2 //Author: bonnet
3 
4 #include "KVGaus2D.h"
5 #include "TH2.h"
6 #include "Riostream.h"
7 #include "TMath.h"
8 #include "TMarker.h"
9 
11 
12 //________________________________________________________________
13 
14 
18 {
19  // Default constructor
20  SetName("Gaus2D");
21  is2D = kTRUE;
22 
23 }
24 
25 
26 
27 
34 
36 {
37  // Copy constructor
38  // This ctor is used to make a copy of an existing object (for example
39  // when a method returns an object), and it is always a good idea to
40  // implement it.
41  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
42 
43 }
44 
45 
46 
48 
49 Bool_t KVGaus2D::NewFunction_2D()
50 {
51 
52  Int_t nf = lfunc->GetEntries();
53 
54  f2Dfit = new TF2(Form("func_%d", ++nf),
55  this,
56  &KVGaus2D::f2D,
57  Xmin,
58  Xmax,
59  Ymin,
60  Ymax,
61  6
62  );
63 
64  lfunc->Add(f2Dfit);
65 
66  hclone->GetXaxis()->SetRangeUser(Xmin, Xmax);
67  hclone->GetYaxis()->SetRangeUser(Ymin, Ymax);
68 
69  f2Dfit->SetParameters(
70  hclone->GetMean(1),
71  hclone->GetRMS(1),
72  hclone->GetMean(2),
73  hclone->GetRMS(2),
74  ((TH2*)hclone)->GetCorrelationFactor(),
75  hclone->Integral()
76  );
77 
78  return kTRUE;
79 }
80 
81 
82 
84 
85 TF1* KVGaus2D::ReloadFunction_2D(const Char_t* nom, Int_t npar)
86 {
87 
88  TF2* f2 = new TF2(nom,
89  this,
90  &KVGaus2D::f2D,
91  0, 1, 0, 1,
92  npar
93  );
94 
95  return f2;
96 }
97 
98 
99 
104 
105 Double_t KVGaus2D::f2D(Double_t* xx, Double_t* para)
106 {
107 
108 //Function gaussienne 2D
109 //
110 // E1 vs E2
111 
112  userdefined = kTRUE;
113 
114  Double_t e2 = xx[0];
115  Double_t e1 = xx[1];
116 
117  Double_t E2 = para[0];
118  Double_t sigE2 = para[1];
119  Double_t E1 = para[2];
120  Double_t sigE1 = para[3];
121  Double_t rho = para[4];
122  Double_t norm = para[5];
123 
124  Double_t dE1 = E1 - e1;
125  Double_t dE2 = E2 - e2;
126 
127  Double_t A = -0.5 / ((1. - TMath::Power(rho, 2.)) * TMath::Power(sigE1 * sigE2, 2.)) * (TMath::Power(dE1 * sigE2, 2.) + TMath::Power(dE2 * sigE1, 2.) - 2.*rho * dE1 * dE2 * sigE1 * sigE2);
128  Double_t det = (1. - TMath::Power(rho, 2.)) * TMath::Power(sigE1 * sigE2, 2.);
129  Double_t P = norm * 1. / det * exp(A);
130 
131  return P;
132 
133 }
134 
135 
136 
138 
140 {
141  TMarker* m1 = new TMarker(f2Dfit->GetParameter(0), f2Dfit->GetParameter(2), 8);
142  m1->SetMarkerSize(0.7);
143 
144  m1->Draw();
145 }
146 
147 
int Int_t
bool Bool_t
char Char_t
double Double_t
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
Manage SemiAutomatic Fits.
Definition: KVAutoFit.h:26
Handle semi-automatic fit to 2D Gaussian distributions.
Definition: KVGaus2D.h:17
void ExtraDrawing() override
Definition: KVGaus2D.cpp:139
KVGaus2D(Bool_t batch=kFALSE)
Default constructor.
Definition: KVGaus2D.cpp:17
virtual void SetMarkerSize(Size_t msize=1)
virtual Double_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t *option="") const
void Draw(Option_t *option="") override
RVec< PromoteType< T > > exp(const RVec< T > &v)
gr SetName("gr")
Double_t Power(Double_t x, Double_t y)
ClassImp(TPyArg)