AliPhysics  aaf9c62 (aaf9c62)
AliHFVnVsMassFitter.cxx
Go to the documentation of this file.
1 #include "AliHFVnVsMassFitter.h"
2 
3 #include <TROOT.h>
4 #include <TMath.h>
5 #include <TF1.h>
6 #include <TGraphErrors.h>
7 #include <TColor.h>
8 #include <TLegend.h>
9 #include <TList.h>
10 #include <TCanvas.h>
11 #include <TStyle.h>
12 #include <TVirtualPad.h>
13 #include <TDatabasePDG.h>
14 #include <TPaveText.h>
15 #include "Fit/BinData.h"
16 #include "HFitInterface.h"
17 #include <vector>
18 
19 #include "AliVertexingHFUtils.h"
20 
22 ClassImp(AliHFVnVsMassFitter);
24 
25 //________________________________________________________________
27  :TObject()
28  ,fMassHisto(0x0)
29  ,fVnVsMassHisto(0x0)
30  ,fMassSgnFuncType(kGaus)
31  ,fMassBkgFuncType(kExpo)
32  ,fVnBkgFuncType(kLin)
33  ,fMassFuncFromPrefit(0x0)
34  ,fMassBkgFunc(0x0)
35  ,fMassSgnFunc(0x0)
36  ,fMassTotFunc(0x0)
37  ,fVnBkgFuncSb(0x0)
38  ,fVnBkgFunc(0x0)
39  ,fVnTotFunc(0x0)
40  ,fMassFitter(0x0)
41  ,fMassMin(1.69)
42  ,fMassMax(2.05)
43  ,fVn(0.)
44  ,fVnUncertainty(0.)
45  ,fSigma(0.)
46  ,fSigmaUncertainty(0.)
47  ,fMean(0.)
48  ,fMeanUncertainty(0.)
49  ,fRawYield(0.)
50  ,fRawYieldUncertainty(0.)
51  ,fChiSquare(0.)
52  ,fNDF(0)
53  ,fProb(0.)
54  ,fNSigmaForSB(3.)
55  ,fSigmaInit(0.012)
56  ,fMeanInit(1.870)
57  ,fSigma2GausInit(0.012)
58  ,fFrac2GausInit(0.2)
59  ,fMeanFixedFromMassFit(kFALSE)
60  ,fSigmaFixedFromMassFit(kFALSE)
61  ,fSigma2GausFixedFromMassFit(kFALSE)
62  ,fFrac2GausFixedFromMassFit(kFALSE)
63  ,fMassParticle(1.870)
64  ,fNParsMassSgn(3)
65  ,fNParsMassBkg(2)
66  ,fNParsVnBkg(2)
67  ,fNParsVnSgn(1)
68  ,fNParsVnSecPeak(0)
69  ,fNParsVnRfl(0)
70  ,fSigmaFixed(0)
71  ,fMeanFixed(0)
72  ,fSigma2GausFixed(0)
73  ,fFrac2GausFixed(0)
74  ,fPolDegreeBkg(3)
75  ,fPolDegreeVnBkg(3)
76  ,fReflections(kFALSE)
77  ,fNParsRfl(0)
78  ,fRflOverSig(0.)
79  ,fFixRflOverSig(kFALSE)
80  ,fHistoTemplRfl(0x0)
81  ,fHistoTemplRflInit(0x0)
82  ,fMassRflFunc(0x0)
83  ,fMassBkgRflFunc(0x0)
84  ,fRflOpt("1gaus")
85  ,fMinRefl(0.)
86  ,fMaxRefl(0.)
87  ,fSmoothRfl(kFALSE)
88  ,fRawYieldHelp(0.)
89  ,fVnRflOpt(0)
90  ,fSecondPeak(kFALSE)
91  ,fMassSecPeakFunc(0x0)
92  ,fNParsSec(0)
93  ,fSecMass(-999.)
94  ,fSecWidth(9999.)
95  ,fFixSecMass(kFALSE)
96  ,fFixSecWidth(kFALSE)
97  ,fDoSecondPeakVn(kFALSE)
98  ,fHarmonic(2) {
99 
100  //default constructor
101 }
102 
103 //________________________________________________________________
104 AliHFVnVsMassFitter::AliHFVnVsMassFitter(TH1F* hMass, TH1F* hvn, Double_t min, Double_t max, Int_t funcMassBkg, Int_t funcMassSgn, Int_t funcvnBkg)
105  :TObject()
106  ,fMassSgnFuncType(funcMassSgn)
107  ,fMassBkgFuncType(funcMassBkg)
108  ,fVnBkgFuncType(funcvnBkg)
109  ,fMassFuncFromPrefit(0x0)
110  ,fMassBkgFunc(0x0)
111  ,fMassSgnFunc(0x0)
112  ,fMassTotFunc(0x0)
113  ,fVnBkgFuncSb(0x0)
114  ,fVnBkgFunc(0x0)
115  ,fVnTotFunc(0x0)
116  ,fMassFitter(0x0)
117  ,fMassMin(min)
118  ,fMassMax(max)
119  ,fVn(0.)
120  ,fVnUncertainty(0.)
121  ,fSigma(0.)
122  ,fSigmaUncertainty(0.)
123  ,fMean(0.)
124  ,fMeanUncertainty(0.)
125  ,fRawYield(0.)
127  ,fChiSquare(0.)
128  ,fNDF(0)
129  ,fProb(0)
130  ,fNSigmaForSB(3.)
131  ,fSigmaInit(0.012)
132  ,fMeanInit(1.870)
133  ,fSigma2GausInit(0.012)
134  ,fFrac2GausInit(0.2)
135  ,fMeanFixedFromMassFit(kFALSE)
136  ,fSigmaFixedFromMassFit(kFALSE)
139  ,fMassParticle(1.870)
140  ,fNParsMassSgn(3)
141  ,fNParsMassBkg(2)
142  ,fNParsVnBkg(2)
143  ,fNParsVnSgn(1)
144  ,fNParsVnSecPeak(0)
145  ,fNParsVnRfl(0)
146  ,fSigmaFixed(0)
147  ,fMeanFixed(0)
148  ,fSigma2GausFixed(0)
149  ,fFrac2GausFixed(0)
150  ,fPolDegreeBkg(3)
151  ,fPolDegreeVnBkg(3)
152  ,fReflections(kFALSE)
153  ,fNParsRfl(0)
154  ,fRflOverSig(0.)
155  ,fFixRflOverSig(kFALSE)
156  ,fHistoTemplRfl(0x0)
157  ,fHistoTemplRflInit(0x0)
158  ,fMassRflFunc(0x0)
159  ,fMassBkgRflFunc(0x0)
160  ,fRflOpt("1gaus")
161  ,fMinRefl(0.)
162  ,fMaxRefl(0.)
163  ,fSmoothRfl(kFALSE)
164  ,fRawYieldHelp(0.)
165  ,fVnRflOpt(0)
166  ,fSecondPeak(kFALSE)
167  ,fMassSecPeakFunc(0x0)
168  ,fNParsSec(0)
169  ,fSecMass(-999.)
170  ,fSecWidth(9999.)
171  ,fFixSecMass(kFALSE)
172  ,fFixSecWidth(kFALSE)
173  ,fDoSecondPeakVn(kFALSE)
174  ,fHarmonic(2) {
175 
176  //standard constructor
177  fMassHisto = (TH1F*)hMass->Clone("fHistoInvMass");
178  fMassHisto->SetDirectory(0);
179  fVnVsMassHisto = (TH1F*)hvn->Clone(Form("fHistoV%dVsMass",fHarmonic));
180  fVnVsMassHisto->SetDirectory(0);
181 
183 }
184 
185 //________________________________________________________________
187 
188  //destructor
189  if(fMassHisto) delete fMassHisto;
190  if(fVnVsMassHisto) delete fVnVsMassHisto;
192  if(fMassBkgFunc) delete fMassBkgFunc;
193  if(fMassBkgRflFunc) delete fMassBkgRflFunc;
194  if(fMassSgnFunc) delete fMassSgnFunc;
195  if(fMassTotFunc) delete fMassTotFunc;
196  if(fVnBkgFuncSb) delete fVnBkgFuncSb;
197  if(fVnBkgFunc) delete fVnBkgFunc;
198  if(fVnTotFunc) delete fVnTotFunc;
199  if(fMassFitter) delete fMassFitter;
200  if(fHistoTemplRfl) delete fHistoTemplRfl;
202  if(fMassRflFunc) delete fMassRflFunc;
204 }
205 
206 //________________________________________________________________
208 
209  if(!fMassHisto || !fVnVsMassHisto) {AliError("Histograms not set! Exit."); return kFALSE;}
211 
213  Int_t NvnParsSgn = 1;
214  if(fSecondPeak && fDoSecondPeakVn) {NvnParsSgn+=1;}
215  const Int_t nparsvn = nparsmass+fNParsVnBkg+NvnParsSgn;
216 
217  Bool_t massprefit=MassPrefit();
218  if(!massprefit) {AliError("Impossible to perform the mass prefit"); return kFALSE;}
219  Bool_t vnprefit=VnSBPrefit();
220 
221  std::vector<Double_t> initpars;
222  for(Int_t iBkgPar=0; iBkgPar<fNParsMassBkg; iBkgPar++) {
223  initpars.push_back(fMassFuncFromPrefit->GetParameter(iBkgPar));
224  }
225  for(Int_t iSgnPar=0; iSgnPar<fNParsMassSgn; iSgnPar++) {
226  initpars.push_back(fMassFuncFromPrefit->GetParameter(iSgnPar+fNParsMassBkg));
227  }
228  for(Int_t iSecPeakPar=0; iSecPeakPar<fNParsSec; iSecPeakPar++) {
229  initpars.push_back(fMassFuncFromPrefit->GetParameter(iSecPeakPar+fNParsMassBkg+fNParsMassSgn));
230  }
231  for(Int_t iReflPar=0; iReflPar<fNParsRfl; iReflPar++) {
232  initpars.push_back(fMassFuncFromPrefit->GetParameter(iReflPar+fNParsMassBkg+fNParsMassSgn+fNParsSec));
233  }
234  for(Int_t iVnBkgPar=0; iVnBkgPar<fNParsVnBkg; iVnBkgPar++) {
235  if(vnprefit) {initpars.push_back(fVnBkgFuncSb->GetParameter(iVnBkgPar));}
236  else {initpars.push_back(0.05);}
237  }
238  initpars.push_back(0.10); //initial parameter for signal vn
239  if(fSecondPeak && fDoSecondPeakVn) {initpars.push_back(0.10);} //initial parameter for second peak vn
240 
241  fMassTotFunc = new TF1("fMassTotFunc",this,&AliHFVnVsMassFitter::MassFunc,fMassMin,fMassMax,nparsmass,"AliHFVnVsMassFitter","MassFunc");
242  fVnTotFunc = new TF1("fVnTotFunc",this,&AliHFVnVsMassFitter::vnFunc,fMassMin,fMassMax,nparsvn,"AliHFVnVsMassFitter","vnFunc");
243  SetParNames();
244 
245  ROOT::Math::WrappedMultiTF1 wfTotMass(*fMassTotFunc,1);
246  ROOT::Math::WrappedMultiTF1 wfTotVn(*fVnTotFunc,1);
247 
248  // set data options and ranges
249  ROOT::Fit::DataOptions opt;
250  ROOT::Fit::DataRange rangeMass; //same range for two functions
251 
252  rangeMass.SetRange(fMassMin,fMassMax);
253  ROOT::Fit::BinData dataMass(opt,rangeMass);
254  ROOT::Fit::FillData(dataMass, fMassHisto);
255  ROOT::Fit::BinData dataVn(opt,rangeMass);
256  ROOT::Fit::FillData(dataVn, fVnVsMassHisto);
257 
258  //define the 2 chi squares
259  ROOT::Fit::Chi2Function chi2Mass(dataMass, wfTotMass);
260  ROOT::Fit::Chi2Function chi2Vn(dataVn, wfTotVn);
261 
262  //define the global chi square
263  AliHFGlobalChi2 globalChi2(chi2Mass, chi2Vn);
264 
265  //define fitter
266  ROOT::Fit::Fitter fitter;
267  // create before the parameter settings in order to fix or set range on them
268  fitter.Config().SetParamsSettings(nparsvn,initpars.data()); //set initial parameters from prefits
269  if(fMeanFixed==2 || fMeanFixedFromMassFit) {fitter.Config().ParSettings(fNParsMassBkg+1).Fix();}
270  if(fSigmaFixed==2 || fSigmaFixedFromMassFit) {fitter.Config().ParSettings(fNParsMassBkg+2).Fix();}
271  if(fMassSgnFuncType==k2Gaus) {
272  if(fFrac2GausFixed==2 || fFrac2GausFixedFromMassFit) {fitter.Config().ParSettings(fNParsMassBkg+3).Fix();}
273  if(fSigma2GausFixed==2 || fSigma2GausFixedFromMassFit) {fitter.Config().ParSettings(fNParsMassBkg+4).Fix();}
274  }
275  if(fSecondPeak) {
276  if(fFixSecMass) {fitter.Config().ParSettings(fNParsMassBkg+fNParsMassSgn+1).Fix();}
277  if(fFixSecWidth) {fitter.Config().ParSettings(fNParsMassBkg+fNParsMassSgn+2).Fix();}
278  }
279  if(fReflections && fFixRflOverSig) {fitter.Config().ParSettings(fNParsMassBkg+fNParsMassSgn+fNParsSec).Fix();}
280 
281  fitter.Config().MinimizerOptions().SetPrintLevel(0);
282  fitter.Config().SetMinimizer("Minuit2","Migrad");
283  for(Int_t iPar=0; iPar<nparsvn; iPar++) {fitter.Config().ParSettings(iPar).SetName(fVnTotFunc->GetParName(iPar));}
284  // fit FCN function directly
285  // (specify optionally data size and flag to indicate that is a chi2 fit
286  fitter.FitFCN(nparsvn,globalChi2,0,dataMass.Size()+dataVn.Size(),kFALSE);
287  ROOT::Fit::FitResult result = fitter.Result();
288  result.Print(std::cout);
289 
290  //set parameters in every function
291  fVnBkgFunc = new TF1("fVnBkgFunc",this,&AliHFVnVsMassFitter::vnBkgFunc,fMassMin,fMassMax,fNParsVnBkg,"AliHFVnVsMassFitter","vnBkgFunc");
292  fMassBkgFunc = new TF1("fMassBkgFunc",this,&AliHFVnVsMassFitter::MassBkg,fMassMin,fMassMax,fNParsMassBkg,"AliHFVnVsMassFitter","MassBkg");
293  fMassSgnFunc = new TF1("fMassSgnFunc",this,&AliHFVnVsMassFitter::MassSignal,fMassMin,fMassMax,fNParsMassSgn,"AliHFVnVsMassFitter","MassSignal");
294  if(fReflections) {fMassRflFunc = new TF1("fMassRflFunc",this,&AliHFVnVsMassFitter::MassRfl,fMassMin,fMassMax,fNParsRfl,"AliHFVnVsMassFitter","MassRfl");}
295  if(fReflections) {fMassBkgRflFunc = new TF1("fMassBkgRflFunc",this,&AliHFVnVsMassFitter::MassBkgRfl,fMassMin,fMassMax,fNParsMassBkg+fNParsRfl,"AliHFVnVsMassFitter","MassBkgRfl");}
296  if(fSecondPeak) {fMassSecPeakFunc = new TF1("fMassSecPeakFunc",this,&AliHFVnVsMassFitter::MassSecondPeak,fMassMin,fMassMax,fNParsSec,"AliHFVnVsMassFitter","MassSecondPeak");}
297  for(Int_t iPar=0; iPar<nparsvn; iPar++) {
298  fVnTotFunc->SetParameter(iPar,result.Parameter(iPar));
299  fVnTotFunc->SetParError(iPar,result.ParError(iPar));
300  if(iPar<nparsmass) {
301  fMassTotFunc->SetParameter(iPar,result.Parameter(iPar));
302  fMassTotFunc->SetParError(iPar,result.ParError(iPar));
303  }
304  if(iPar>=nparsmass && iPar<nparsvn-NvnParsSgn) {
305  fVnBkgFunc->SetParameter(iPar-nparsmass,result.Parameter(iPar));
306  fVnBkgFunc->SetParError(iPar-nparsmass,result.ParError(iPar));
307  }
308  if(iPar>=fNParsMassBkg && iPar<fNParsMassBkg+fNParsMassSgn) {
309  fMassSgnFunc->SetParameter(iPar-fNParsMassBkg,result.Parameter(iPar));
310  }
311  if(iPar<fNParsMassBkg) {
312  fMassBkgFunc->SetParameter(iPar,result.Parameter(iPar));
313  fMassBkgFunc->SetParError(iPar,result.ParError(iPar));
314  if(fReflections) {
315  fMassRflFunc->SetParameter(iPar,result.Parameter(iPar));
316  fMassRflFunc->SetParError(iPar,result.ParError(iPar));
317  }
318  }
319  if(fReflections && (iPar>=fNParsMassBkg+fNParsMassSgn+fNParsSec && iPar<fNParsMassBkg+fNParsMassSgn+fNParsSec+fNParsRfl)) {
320  fMassRflFunc->SetParameter(iPar-(fNParsMassBkg+fNParsMassSgn+fNParsSec),result.Parameter(iPar));
321  fMassRflFunc->SetParError(iPar-(fNParsMassBkg+fNParsMassSgn+fNParsSec),result.ParError(iPar));
322  }
323  if(fSecondPeak && (iPar>=fNParsMassBkg+fNParsMassSgn && iPar<fNParsMassBkg+fNParsMassSgn+fNParsSec)) {
324  fMassSecPeakFunc->SetParameter(iPar-(fNParsMassBkg+fNParsMassSgn),result.Parameter(iPar));
325  fMassSecPeakFunc->SetParError(iPar-(fNParsMassBkg+fNParsMassSgn),result.ParError(iPar));
326  }
327  }
328  if(drawFit) {DrawFit();}
329 
330  fVn = fVnTotFunc->GetParameter(fVnTotFunc->GetNpar()-NvnParsSgn);
331  fVnUncertainty = fVnTotFunc->GetParError(fVnTotFunc->GetNpar()-NvnParsSgn);
332  if(fDoSecondPeakVn) {
333  fVnSecPeak = fVnTotFunc->GetParameter(fVnTotFunc->GetNpar()-1);
334  fVnSecPeakUncertainty = fVnTotFunc->GetParError(fVnTotFunc->GetNpar()-1);
335  }
336  fRawYield = fVnTotFunc->GetParameter(fNParsMassBkg)/fMassHisto->GetBinWidth(10);
337  fRawYieldUncertainty = fVnTotFunc->GetParError(fNParsMassBkg)/fMassHisto->GetBinWidth(10);
338  fMean = fVnTotFunc->GetParameter(fNParsMassBkg+1);
339  fMeanUncertainty = fVnTotFunc->GetParError(fNParsMassBkg+1);
340  fSigma = fVnTotFunc->GetParameter(fNParsMassBkg+2);
341  fSigmaUncertainty = fVnTotFunc->GetParError(fNParsMassBkg+2);
342  fChiSquare = result.MinFcnValue();
343  fNDF = result.Ndf();
344  fProb = result.Prob();
345 
346  return kTRUE;
347 }
348 
349 //______________________________________________________________________________
350 void AliHFVnVsMassFitter::DrawHere(TVirtualPad* c){
352 
353  gStyle->SetOptStat(0);
354  gStyle->SetCanvasColor(0);
355  gStyle->SetFrameFillColor(0);
356  c->Divide(1,2);
357 
358  c->cd(1);
359  fMassHisto->SetTitle("");
360  fMassHisto->SetMarkerStyle(20);
361  fMassHisto->SetMarkerSize(1);
362  fMassHisto->SetMarkerColor(kBlack);
363  fMassHisto->SetLineColor(kBlack);
364  fMassHisto->GetYaxis()->SetRangeUser(0.,fMassHisto->GetMaximum()*1.2);
365  fMassHisto->GetXaxis()->SetRangeUser(fMassMin,fMassMax);
366  fMassHisto->Draw("E");
367  if(fMassFuncFromPrefit) {
368  fMassFuncFromPrefit->SetLineColor(kGray+1);
369  fMassFuncFromPrefit->SetLineStyle(7);
371  fMassFuncFromPrefit->Draw("same");
372  }
373  if(fMassBkgFunc) {
374  fMassBkgFunc->SetLineColor(kRed);
375  fMassBkgFunc->SetRange(fMassMin,fMassMax);
376  fMassBkgFunc->Draw("same");
377  }
378  if(fMassRflFunc) {
379  fMassRflFunc->SetLineColor(kGreen+1);
380  fMassRflFunc->SetRange(fMassMin,fMassMax);
381  fMassRflFunc->Draw("same");
382  }
383  if(fMassBkgRflFunc) {
384  fMassBkgRflFunc->SetLineColor(kRed+1);
385  fMassBkgRflFunc->SetLineStyle(7);
386  fMassBkgRflFunc->SetRange(fMassMin,fMassMax);
387  fMassBkgRflFunc->Draw("same");
388  }
389  if(fMassSecPeakFunc) {
390  fMassSecPeakFunc->SetLineColor(kMagenta+1);
391  fMassSecPeakFunc->SetLineStyle(7);
393  fMassSecPeakFunc->Draw("same");
394  }
395  if(fMassTotFunc) {
396  fMassTotFunc->SetLineColor(kBlue);
397  fMassTotFunc->SetRange(fMassMin,fMassMax);
398  fMassTotFunc->Draw("same");
399  }
400  TPaveText* massinfo = new TPaveText(0.45,0.7,1.,0.87,"NDC");
401  massinfo->SetTextFont(42);
402  massinfo->SetTextSize(0.05);
403  massinfo->SetBorderSize(0);
404  massinfo->SetFillStyle(0);
405  massinfo->SetTextColor(kBlue);
406  massinfo->AddText(Form("mean = %.3f #pm %.3f",fVnTotFunc->GetParameter(fNParsMassBkg+1),fVnTotFunc->GetParError(fNParsMassBkg+1)));
407  massinfo->AddText(Form("sigma = %.3f #pm %.3f",fVnTotFunc->GetParameter(fNParsMassBkg+2),fVnTotFunc->GetParError(fNParsMassBkg+2)));
408  if(fMassSgnFuncType==k2Gaus) {
409  massinfo->AddText(Form("sigma2 = %.3f #pm %.3f",fVnTotFunc->GetParameter(fNParsMassBkg+3),fVnTotFunc->GetParError(fNParsMassBkg+3)));
410  }
411  massinfo->Draw("same");
412 
413  c->cd(2);
414  fVnVsMassHisto->SetTitle("");
415  fVnVsMassHisto->SetMarkerStyle(20);
416  fVnVsMassHisto->SetMarkerSize(1);
417  fVnVsMassHisto->SetMarkerColor(kBlack);
418  fVnVsMassHisto->SetLineColor(kBlack);
419  fVnVsMassHisto->GetYaxis()->SetRangeUser(fVnVsMassHisto->GetMinimum()-0.15,fVnVsMassHisto->GetMaximum()+0.20);
420  fVnVsMassHisto->GetXaxis()->SetRangeUser(fMassMin,fMassMax);
421  fVnBkgFuncSb->SetRange(fMassMin,fMassMax);
422  fVnVsMassHisto->Draw("E");
423  if(fVnBkgFuncSb) {
424  fVnBkgFuncSb->SetLineColor(kGray+1);
425  fVnBkgFuncSb->SetLineStyle(7);
426  fVnBkgFuncSb->Draw("same");
427  }
428  if(fVnBkgFunc) {
429  fVnBkgFunc->SetLineColor(kRed);
430  fVnBkgFunc->SetRange(fMassMin,fMassMax);
431  fVnBkgFunc->Draw("same");
432  }
433  if(fVnTotFunc) {
434  fVnTotFunc->SetLineColor(kBlue);
435  fVnTotFunc->SetRange(fMassMin,fMassMax);
436  fVnTotFunc->Draw("same");
437  }
438 
439  TPaveText* vninfo = new TPaveText(-0.45,0.7,1.,0.87,"NDC");
440  vninfo->SetTextFont(42);
441  vninfo->SetTextSize(0.05);
442  vninfo->SetBorderSize(0);
443  vninfo->SetFillStyle(0);
444  Int_t NvnParsSgn = 1;
445  if(fSecondPeak && fDoSecondPeakVn) {NvnParsSgn+=1;}
446  vninfo->AddText(Form("#it{v}_{%d}^{sgn} = %.3f #pm %.3f",fHarmonic,fVnTotFunc->GetParameter(fVnTotFunc->GetNpar()-NvnParsSgn),fVnTotFunc->GetParError(fVnTotFunc->GetNpar()-NvnParsSgn)));
447  if(fSecondPeak && fDoSecondPeakVn) {vninfo->AddText(Form("#it{v}_{%d}^{sec peak} = %.3f #pm %.3f",fHarmonic,fVnTotFunc->GetParameter(fVnTotFunc->GetNpar()-1),fVnTotFunc->GetParError(fVnTotFunc->GetNpar()-1)));}
448  vninfo->AddText(Form("#chi^{2}/#it{ndf} = %.2f/%d",fChiSquare,fNDF));
449  vninfo->Draw("same");
450 
451  c->Update();
452 }
453 
454 //________________________________________________________________
456 
457  //define proper maxs and mins from histos
458  Double_t tmpmin = TMath::Max(fMassHisto->GetBinLowEdge(1),fVnVsMassHisto->GetBinLowEdge(1));
459  fMassMin=TMath::Max(fMassMin,tmpmin);
460  Double_t tmpmax = TMath::Min(fMassHisto->GetBinLowEdge(fMassHisto->GetNbinsX())+fMassHisto->GetBinWidth(fMassHisto->GetNbinsX()),fVnVsMassHisto->GetBinLowEdge(fVnVsMassHisto->GetNbinsX())+fVnVsMassHisto->GetBinWidth(fVnVsMassHisto->GetNbinsX()));
461  fMassMax=TMath::Min(fMassMax,tmpmax);
462 
468  if(fMassSgnFuncType==k2Gaus) {
473  }
477  if(fReflections) {
481  }
482  Bool_t status = fMassFitter->MassFitter(kFALSE);
483 
484  if(status) {
486  fMassFuncFromPrefit->SetName("fMassFuncFromPrefit");
487  }
488 
489  return status;
490 }
491 
492 //________________________________________________________________
494 
495  Double_t mean = fMassFitter->GetMean();
497  const Int_t nMassBins = fVnVsMassHisto->GetNbinsX();
498  Double_t SBbins[nMassBins];
499  Int_t nSBbins=0;
500  for(Int_t iBin=0; iBin<nMassBins; iBin++) {
501  Double_t min = fVnVsMassHisto->GetBinLowEdge(iBin+1);
502  Double_t max = fVnVsMassHisto->GetBinLowEdge(iBin+1)+fVnVsMassHisto->GetBinWidth(iBin+1);
503  if(max<mean){
504  if(max<(mean-fNSigmaForSB*sigma)) {SBbins[iBin]=1; nSBbins++;}
505  else {SBbins[iBin]=0;}
506  }
507  if(min>=mean){
508  if(min>(mean+fNSigmaForSB*sigma)) {SBbins[iBin]=1; nSBbins++;}
509  else {SBbins[iBin]=0;}
510  }
511  }
512  TGraphErrors* gVnVsMassSB = new TGraphErrors(nSBbins);
513  for(Int_t iBin=0; iBin<nMassBins; iBin++) {
514  if(SBbins[iBin]==1) {
515  gVnVsMassSB->SetPoint(iBin,fVnVsMassHisto->GetBinCenter(iBin+1),fVnVsMassHisto->GetBinContent(iBin+1));
516  gVnVsMassSB->SetPointError(iBin,fVnVsMassHisto->GetBinWidth(iBin+1)/2,fVnVsMassHisto->GetBinError(iBin+1));
517  }
518  }
519  fVnBkgFuncSb = new TF1("fVnBkgFuncSb",this,&AliHFVnVsMassFitter::vnBkgFunc,fMassMin,fMassMax,fNParsVnBkg,"AliHFVnVsMassFitter","vnBkgFunc");
520  switch(fVnBkgFuncType) {
521  case 1:
522  fVnBkgFuncSb->SetParName(0,"ConstVnBkg");
523  fVnBkgFuncSb->SetParName(1,"SlopeVnBkg");
524  break;
525  case 2:
526  fVnBkgFuncSb->SetParName(0,"ConstVnBkg");
527  fVnBkgFuncSb->SetParName(1,"Coef1VnBkg");
528  fVnBkgFuncSb->SetParName(2,"Coef2VnBkg");
529  break;
530  default:
531  AliError("Error in setting signal par names: check fVnBkgFuncType");
532  break;
533  }
534  gVnVsMassSB->Fit(fVnBkgFuncSb,"","",fMassMin,fMassMax);
535  Bool_t status=kFALSE;
536  if(fVnBkgFuncSb->GetChisquare()<1000) status=kTRUE;
537 
538  delete gVnVsMassSB;
539  return status;
540 }
541 
542 //________________________________________________________________
544 
545  switch(fMassSgnFuncType) {
546  case 0: //single gaus
547  fNParsMassSgn=3;
548  break;
549  case 1: //double gaus
550  fNParsMassSgn=5;
551  break;
552  default:
553  AliError("Error in computing fMassSgnFuncType: check fMassSgnFuncType");
554  break;
555  }
556 
557  switch(fMassBkgFuncType) {
558  case 0: //expo
559  fNParsMassBkg=2;
560  break;
561  case 1: //lin
562  fNParsMassBkg=2;
563  break;
564  case 2: //pol2
565  fNParsMassBkg=3;
566  break;
567  case 3: //no bkg
568  fNParsMassBkg=1;
569  break;
570  case 4: //power law
571  fNParsMassBkg=2;
572  break;
573  case 5: //power expo
574  fNParsMassBkg=2;
575  break;
576  case 6: //high degree pol
578  break;
579  default:
580  AliError("Error in computing fNParsMassBkg: check fMassBkgFuncType");
581  break;
582  }
583 
584  switch(fVnBkgFuncType) {
585  case 0: //expo
586  fNParsVnBkg=2;
587  break;
588  case 1: //lin
589  fNParsVnBkg=2;
590  break;
591  case 2: //pol2
592  fNParsVnBkg=3;
593  break;
594  case 6: //high degree pol
596  break;
597  default:
598  AliError("Error in computing fNParsVnBkg: check fVnBkgFuncType");
599  break;
600  }
601 
602  fNParsVnSgn=1;
603 
604  if(fReflections) {
605  fNParsRfl=1;
606  if(fVnRflOpt==3) fNParsVnRfl=1;
607  else fNParsVnRfl=0;
608  }
609  else {
610  fNParsRfl=0;
611  fNParsVnRfl=0;
612  }
613 
614  if(fSecondPeak) {
615  fNParsSec=3;
616  fNParsVnSecPeak=1;
617  }
618  else {
619  fNParsSec=0;
620  fNParsVnSecPeak=0;
621  }
622 }
623 
624 //________________________________________________________________
626 
627  switch(fMassSgnFuncType) {
628  case 0: //single gaus
629  fVnTotFunc->SetParName(fNParsMassBkg,"SgnInt");
630  fVnTotFunc->SetParName(fNParsMassBkg+1,"Mean");
631  fVnTotFunc->SetParName(fNParsMassBkg+2,"Sigma");
632  break;
633  case 1: //double gaus
634  fVnTotFunc->SetParName(fNParsMassBkg,"SgnInt");
635  fVnTotFunc->SetParName(fNParsMassBkg+1,"Mean");
636  fVnTotFunc->SetParName(fNParsMassBkg+2,"Sigma1");
637  fVnTotFunc->SetParName(fNParsMassBkg+3,"Frac");
638  fVnTotFunc->SetParName(fNParsMassBkg+4,"Sigma2");
639  break;
640  default:
641  AliError("Error in setting signal par names: check fMassSgnFuncType");
642  break;
643  }
644 
645  switch(fMassBkgFuncType) {
646  case 0: //expo
647  fVnTotFunc->SetParName(0,"BkgInt");
648  fVnTotFunc->SetParName(1,"Slope");
649  break;
650  case 1: //lin
651  fVnTotFunc->SetParName(0,"BkgInt");
652  fVnTotFunc->SetParName(1,"Slope");
653  break;
654  case 2: //pol2
655  fVnTotFunc->SetParName(0,"BkgInt");
656  fVnTotFunc->SetParName(1,"Coef1");
657  fVnTotFunc->SetParName(2,"Coef1");
658  break;
659  case 3: //no bkg
660  fVnTotFunc->SetParName(0,"Const");
661  break;
662  case 4: //power law
663  fVnTotFunc->SetParName(0,"BkgInt");
664  fVnTotFunc->SetParName(1,"Coef1");
665  break;
666  case 5: //power expo
667  fVnTotFunc->SetParName(0,"Coef1");
668  fVnTotFunc->SetParName(1,"Coef2");
669  break;
670  case 6: //high degree pol
671  fVnTotFunc->SetParName(0,"BkgInt");
672  for(Int_t iPar=1; iPar<fNParsMassBkg; iPar++) {fVnTotFunc->SetParName(iPar,Form("Coef%d",iPar));}
673  break;
674  default:
675  AliError("Error in setting signal par names: check fMassBkgFuncType");
676  break;
677  }
678 
679  for(Int_t iPar=0; iPar<fNParsVnBkg; iPar++) {fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+fNParsSec+fNParsRfl+iPar,fVnBkgFuncSb->GetParName(iPar));}
680 
681  if(fReflections) {fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+fNParsSec,"ReflOverS");}
682 
683  if(fSecondPeak) {
684  fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn,"SecPeakInt");
685  fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+1,"SecPeakMean");
686  fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+2,"SecPeakSigma");
687  }
688  fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+fNParsSec+fNParsVnBkg,Form("v%dSgn",fHarmonic));
689  if(fSecondPeak && fDoSecondPeakVn) {fVnTotFunc->SetParName(fNParsMassBkg+fNParsMassSgn+fNParsSec+fNParsVnBkg+1,Form("v%dSecPeak",fHarmonic));}
690 }
691 
692 //_________________________________________________________________________
693 void AliHFVnVsMassFitter::Signal(Double_t nOfSigma,Double_t &signal,Double_t &errsignal) const {
696 
697  Double_t minMass=fMean-nOfSigma*fSigma;
698  Double_t maxMass=fMean+nOfSigma*fSigma;
699  Signal(minMass,maxMass,signal,errsignal);
700  return;
701 }
702 
703 //_________________________________________________________________________
704 void AliHFVnVsMassFitter::Signal(Double_t min, Double_t max, Double_t &signal,Double_t &errsignal) const {
707  if(!fMassSgnFunc) {signal=-1; errsignal=0; return;}
708 
709  signal=fMassSgnFunc->Integral(min, max)/(Double_t)fMassHisto->GetBinWidth(1);
710  errsignal=(fRawYieldUncertainty/fRawYield)*signal;/*assume relative error is the same as for total integral*/
711 
712  return;
713 }
714 
715 //___________________________________________________________________________
716 void AliHFVnVsMassFitter::Background(Double_t nOfSigma,Double_t &background,Double_t &errbackground) const {
719 
720  Double_t minMass=fMean-nOfSigma*fSigma;
721  Double_t maxMass=fMean+nOfSigma*fSigma;
722  Background(minMass,maxMass,background,errbackground);
723 
724  return;
725 }
726 
727 //___________________________________________________________________________
728 void AliHFVnVsMassFitter::Background(Double_t min, Double_t max, Double_t &background,Double_t &errbackground) const {
731 
732  if(!fMassBkgFunc) {background=-1; errbackground=0; return;}
733 
734  Double_t intB=fMassBkgFunc->GetParameter(0);
735  Double_t intBerr=fMassBkgFunc->GetParError(0);
736  //relative error evaluation: from histo
737 
738  Int_t leftBand=fMassHisto->FindBin(fMean-4*fSigma);
739  Int_t rightBand=fMassHisto->FindBin(fMean+4*fSigma);
740  intB=fMassHisto->Integral(1,leftBand)+fMassHisto->Integral(rightBand,fMassHisto->GetNbinsX());
741  Double_t sum2=0;
742  for(Int_t iBin=1; iBin<=leftBand; iBin++){
743  sum2+=fMassHisto->GetBinError(iBin)*fMassHisto->GetBinError(iBin);
744  }
745  for(Int_t iBin=rightBand; iBin<=fMassHisto->GetNbinsX(); iBin++){
746  sum2+=fMassHisto->GetBinError(iBin)*fMassHisto->GetBinError(iBin);
747  }
748 
749  intBerr=TMath::Sqrt(sum2);
750 
751  background=fMassBkgFunc->Integral(min,max)/(Double_t)fMassHisto->GetBinWidth(1);
752  errbackground=intBerr/intB*background;
753 
754  return;
755 }
756 
757 //__________________________________________________________________________
758 
759 void AliHFVnVsMassFitter::Significance(Double_t nOfSigma,Double_t &significance,Double_t &errsignificance) const {
762 
763  Double_t minMass=fMean-nOfSigma*fSigma;
764  Double_t maxMass=fMean+nOfSigma*fSigma;
765  Significance(minMass, maxMass, significance, errsignificance);
766 
767  return;
768 }
769 
770 //__________________________________________________________________________
771 
772 void AliHFVnVsMassFitter::Significance(Double_t min, Double_t max, Double_t &significance,Double_t &errsignificance) const {
775 
776  Double_t background,errbackground;
777  Background(min,max,background,errbackground);
778 
779  if (fRawYield+background <= 0.){
780  significance=-1;
781  errsignificance=0;
782  return;
783  }
784 
785  AliVertexingHFUtils::ComputeSignificance(fRawYield,fRawYieldUncertainty,background,errbackground,significance,errsignificance);
786 
787  return;
788 }
789 
790 //________________________________________________________________
792 
793  return TMath::Gaus(x,mean,sigma,kTRUE);
794 }
795 
796 //________________________________________________________________
798 
799  if(isnorm) {return TMath::Exp(x/coeff)/(coeff*(TMath::Exp(fMassMax/coeff)-TMath::Exp(fMassMin/coeff)));}
800  else TMath::Exp(x/coeff);
801 }
802 
803 //________________________________________________________________
805 
806  switch(order) {
807  case 0:
808  if(isnorm) {return 1./(fMassMax-fMassMin);}
809  else {return pars[0];}
810  break;
811  case 1:
812  if(isnorm) {return (pars[0]-pars[1]/2*(fMassMax*fMassMax-fMassMin*fMassMin))/(fMassMax-fMassMin)+pars[1]*x;}
813  else {return pars[0]+pars[1]*x;}
814  break;
815  case 2:
816  if(isnorm) {return (pars[0]-pars[1]/2*(fMassMax*fMassMax-fMassMin*fMassMin)-pars[2]/3*(fMassMax*fMassMax*fMassMax-fMassMin*fMassMin*fMassMin))/(fMassMax-fMassMin)+pars[1]*x;}
817  else {return pars[0]+pars[1]*x+pars[2]*x*x;}
818  }
819  return 0;
820 }
821 
822 //________________________________________________________________
824 
825  Double_t mpi = TDatabasePDG::Instance()->GetParticle(211)->Mass();
826  return pars[0]*(pars[1]+1.)/(TMath::Power(fMassMax-mpi,pars[1]+1.)-TMath::Power(fMassMin-mpi,pars[1]+1.))*TMath::Power(x-mpi,pars[1]);
827 }
828 
829 //________________________________________________________________
831 
832  Double_t mpi = TDatabasePDG::Instance()->GetParticle(211)->Mass();
833  return pars[0]*TMath::Sqrt(x - mpi)*TMath::Exp(-1.*pars[1]*(x-mpi));
834 }
835 
836 //________________________________________________________________
838 
839  Double_t total=pars[0];
840  for(Int_t iT=1; iT<=Ndeg; iT++){
841  if(isnorm) total+=pars[iT]*TMath::Power(x-fMassParticle,iT)/TMath::Factorial(iT);
842  else total+=pars[iT]*TMath::Power(x,iT);
843  }
844  return total;
845 }
846 
847 //________________________________________________________________
849 
850  switch(fMassSgnFuncType) {
851  case 0:
852  return pars[0]*GetGausPDF(m[0],pars[1],pars[2]);
853  break;
854  case 1:
855  return pars[0]*(pars[3]*GetGausPDF(m[0],pars[1],pars[2])+(1-pars[3])*GetGausPDF(m[0],pars[1],pars[4]));
856  break;
857  }
858  fRawYieldHelp=pars[0]/fMassHisto->GetBinWidth(1);
859 
860  return 0;
861 }
862 
863 //________________________________________________________________
865 
866  switch(fMassBkgFuncType) {
867  case 0: //exponential
868  return pars[0]*GetExpoPDF(m[0],pars[1],kTRUE);
869  break;
870  case 1: //linear
871  return GetPolPDF(m[0],pars,1,kTRUE);
872  break;
873  case 2: //parabolic
874  return GetPolPDF(m[0],pars,2,kTRUE);
875  break;
876  case 3: //constant
877  return GetPolPDF(m[0],pars,0,kTRUE);
878  break;
879  case 4: //power law
880  return GetPowerFuncPDF(m[0],pars);
881  break;
882  case 5: //power law expo
883  return GetPowerExpoPDF(m[0],pars);
884  break;
885  case 6: //higher order (>=3) polinomial
886  return GetHigherPolFuncPDF(m[0],pars,fPolDegreeBkg,kTRUE);
887  break;
888  }
889  return 0;
890 }
891 
892 //_________________________________________________________________________
896  if(!fHistoTemplRfl) return 0;
897 
898  Int_t bin =fHistoTemplRfl->FindBin(m[0]);
899  Double_t value=fHistoTemplRfl->GetBinContent(bin);
900  Int_t binmin=fHistoTemplRfl->FindBin(fMassMin*1.00001);
901  Int_t binmax=fHistoTemplRfl->FindBin(fMassMax*0.99999);
902  Double_t norm=fHistoTemplRfl->Integral(binmin,binmax)*fHistoTemplRfl->GetBinWidth(bin);
903  if(TMath::Abs(value)<1.e-14 && fSmoothRfl){// very rough, assume a constant trend, much better would be a pol1 or pol2 over a broader range
904  value+=fHistoTemplRfl->GetBinContent(bin-1)+fHistoTemplRfl->GetBinContent(bin+1);
905  value/=3.;
906  }
907  return pars[0]*value/norm*fRawYieldHelp*fMassHisto->GetBinWidth(1);
908 }
909 
910 //_________________________________________________________________________
912 
913  if(!fHistoTemplRfl) {return MassBkg(m,pars);}
914  else {
915  //bkg mass parameters
916  const Int_t nBkgPars = fNParsMassBkg;
917  Double_t bkgpars[nBkgPars];
918  for(Int_t iPar=0; iPar<fNParsMassBkg; iPar++) {bkgpars[iPar] = pars[iPar];}
919  //reflection parameters
920  Double_t rflpars[1]; //maximum number of parameters for rfl = 1 for the implemented functions
921  for(Int_t iPar=0; iPar<fNParsRfl; iPar++) {rflpars[iPar] = pars[iPar+fNParsMassBkg];}
922  return MassBkg(m,bkgpars)+MassRfl(m,rflpars);
923  }
924 }
925 
926 //_________________________________________________________________________
930 
931  return pars[0]*GetGausPDF(m[0],pars[1],pars[2]);
932 }
933 
934 //________________________________________________________________
936 
937  switch(fVnBkgFuncType) {
938  case 0: //expo
939  return pars[0]*GetExpoPDF(m[0],pars[1],kFALSE);
940  break;
941  case 1: //linear
942  return GetPolPDF(m[0],pars,1,kFALSE);
943  break;
944  case 2: //parabolic
945  return GetPolPDF(m[0],pars,2,kFALSE);
946  break;
947  case 6: //higher order (>=3) polinomial
948  return GetHigherPolFuncPDF(m[0],pars,fPolDegreeVnBkg,kFALSE);
949  break;
950  }
951  return 0;
952 }
953 
954 //________________________________________________________________
956 
957  //bkg mass parameters
958  const Int_t nBkgPars = fNParsMassBkg;
959  Double_t bkgpars[nBkgPars];
960  for(Int_t iPar=0; iPar<fNParsMassBkg; iPar++) {bkgpars[iPar] = pars[iPar];}
961  //signal mass parameters
962  Double_t sgnpars[5]; //maximum number of parameters for sgn = 5 for the implemented functions
963  for(Int_t iPar=0; iPar<fNParsMassSgn; iPar++) {sgnpars[iPar] = pars[iPar+fNParsMassBkg];}
964  //second peak parameters
965  Double_t secpeakpars[3]; //maximum number of parameters for second peak = 3 for the implemented functions
966  for(Int_t iPar=0; iPar<fNParsSec; iPar++) {secpeakpars[iPar] = pars[iPar+fNParsMassBkg+fNParsMassSgn];}
967  //reflection parameters
968  Double_t rflpars[1]; //maximum number of parameters for rfl = 1 for the implemented functions
969  for(Int_t iPar=0; iPar<fNParsRfl; iPar++) {rflpars[iPar] = pars[iPar+fNParsMassBkg+fNParsMassSgn+fNParsSec];}
970 
971  Double_t total = MassSignal(m,sgnpars)+MassBkg(m,bkgpars);
972  if(fSecondPeak) {total += MassSecondPeak(m,secpeakpars);}
973  if(fReflections) {total += MassRfl(m,rflpars);}
974 
975  return total;
976 }
977 
978 //________________________________________________________________
980 
981  //bkg mass parameters
982  const Int_t nBkgPars = fNParsMassBkg;
983  Double_t massbkgpars[nBkgPars];
984  for(Int_t iPar=0; iPar<fNParsMassBkg; iPar++) {massbkgpars[iPar] = pars[iPar];}
985  //signal mass parameters
986  Double_t masssgnpars[5]; //maximum number of parameters for mass sgn = 5 for the implemented functions
987  for(Int_t iPar=0; iPar<fNParsMassSgn; iPar++) {masssgnpars[iPar] = pars[iPar+fNParsMassBkg];}
988  //second peak parameters
989  Double_t secpeakpars[3]; //maximum number of parameters for second peak = 3 for the implemented functions
990  for(Int_t iPar=0; iPar<fNParsSec; iPar++) {secpeakpars[iPar] = pars[iPar+fNParsMassBkg+fNParsMassSgn];}
991  //reflection parameters
992  Double_t rflpars[1]; //maximum number of parameters for rfl = 1 for the implemented functions
993  for(Int_t iPar=0; iPar<fNParsRfl; iPar++) {rflpars[iPar] = pars[iPar+fNParsMassBkg+fNParsMassSgn+fNParsSec];}
994  //bkg vn parameters
995  const Int_t nVnBkgPars = fNParsVnBkg;
996  Double_t vnbkgpars[nVnBkgPars];
997  for(Int_t iPar=0; iPar<fNParsVnBkg; iPar++) {vnbkgpars[iPar] = pars[iPar+fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl];}
998  //signal vn parameter
999  Double_t vnSgn = pars[fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl+fNParsVnBkg];
1000  //second peak vn parameter
1001  Double_t vnSecPeak = 0;
1002  if(fSecondPeak && fDoSecondPeakVn) {vnSecPeak = pars[fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl+fNParsVnBkg+fNParsVnSgn];}
1003  //refl vn parameter
1004  Double_t vnRefl = 0;
1005  if(fReflections) {
1006  switch(fVnRflOpt) {
1007  case 0:
1008  vnRefl = pars[fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl+fNParsVnBkg];
1009  break;
1010  case 1:
1011  vnRefl = -pars[fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl+fNParsVnBkg];
1012  break;
1013  case 2:
1014  vnRefl = 0; //not used
1015  break;
1016  case 3:
1017  vnRefl = pars[fNParsMassSgn+fNParsMassBkg+fNParsSec+fNParsRfl+fNParsVnBkg+fNParsVnSgn+fNParsVnSecPeak];
1018  break;
1019  default:
1020  AliError("Error in setting reflection vn option: check fVnRflOpt");
1021  break;
1022  }
1023  }
1024 
1025  Double_t vnBkg = vnBkgFunc(m,vnbkgpars);
1026  Double_t Sgn = MassSignal(m,masssgnpars);
1027  Double_t Bkg = MassBkg(m,massbkgpars);
1028  Double_t SecPeak = 0;
1029  if(fSecondPeak) {
1030  if(fDoSecondPeakVn) SecPeak += MassSecondPeak(m,secpeakpars);
1031  else Bkg += MassSecondPeak(m,secpeakpars);
1032  }
1033  Double_t Refl=0;
1034  if(fReflections) {
1035  if(fVnRflOpt==kSameVnBkg) Bkg += MassRfl(m,rflpars);
1036  else Refl += MassRfl(m,rflpars);
1037  }
1038 
1039  return (vnSgn*Sgn+vnBkg*Bkg+vnSecPeak*SecPeak+vnRefl*Refl)/(Sgn+Bkg+SecPeak+Refl);
1040 }
1041 
1042 //______________________________________________________________________________
1046  TCanvas* c0=new TCanvas("c0","",600,800);
1047  DrawHere(c0);
1048 }
Int_t fVnRflOpt
internal variable for fit with reflections
Int_t fFrac2GausFixed
flag to fix second peak width in case of k2Gaus
Int_t fPolDegreeVnBkg
degree of polynomial expansion for back fit (option 6 for back)
Double_t MassSecondPeak(Double_t *m, Double_t *par)
Double_t GetExpoPDF(Double_t x, Double_t slope, Bool_t isnorm=kTRUE)
Int_t fNParsVnBkg
number of parameters in mass bkg fit function
Bool_t fFixSecWidth
flag to fix the position of the 2nd peak
double Double_t
Definition: External.C:58
void SetFixReflOverS(Double_t rovers)
Int_t fNParsVnSecPeak
number of parameters in vn sgn fit function (1)
Int_t fNParsRfl
flag use/not use reflections
Bool_t fReflections
degree of polynomial expansion for vn back fit (option 6 for back)
void IncludeSecondGausPeak(Double_t mass, Bool_t fixm, Double_t width, Bool_t fixw)
Double_t MassRfl(Double_t *m, Double_t *par)
Bool_t SimultaneusFit(Bool_t drawFit=kTRUE)
Double_t GetPowerFuncPDF(Double_t x, Double_t *pars)
Bool_t fMeanFixedFromMassFit
initialization for fraction of second gaussian in case of k2Gaus
Double_t fMean
uncertainty on mass peak width from simultaneus fit
TH1F * fHistoTemplRfl
switch for fix refl/signal
Double_t fMassParticle
flag to fix fraction of second gaussian in case of k2Gaus
Bool_t fFixSecMass
width of the 2nd peak
Int_t fNParsSec
fit function for second peak
Bool_t fSecondPeak
option for reflection vn type
Double_t fSigma2GausInit
initialization for peak position
Double_t GetHigherPolFuncPDF(Double_t x, Double_t *pars, Int_t Ndeg, Bool_t isnorm=kTRUE)
Bool_t fSigmaFixedFromMassFit
flag to fix peak position from mass prefit
void Signal(Double_t nOfSigma, Double_t &signal, Double_t &errsignal) const
Int_t MassFitter(Bool_t draw=kTRUE)
Double_t fSecMass
number of parameters in second peak fit function
TF1 * fMassTotFunc
mass signal fit function (final, after simultaneus fit)
Double_t vnBkgFunc(Double_t *m, Double_t *pars)
Double_t fRflOverSig
fit parameters in reflection fit function
Double_t fMassMax
upper mass limit
AliHFInvMassFitter class for the fit of invariant mass distribution of charm hadrons.
void SetFixSecondGaussianSigma(Double_t sigma)
TCanvas * c
Definition: TestFitELoss.C:172
Int_t fSigma2GausFixed
flag to fix peak position
Int_t fMeanFixed
flag to fix peak width
Double_t fVn
lower mass limit
Int_t fMassSgnFuncType
vn vs. mass histogram to fit
void DefineNumberOfParameters()
private methods
void SetFixFrac2Gaus(Double_t frac)
Double_t GetSigma() const
void SetPolDegreeForBackgroundFit(Int_t deg)
Double_t fChiSquare
uncertainty raw yield from simultaneus fit
Bool_t fSigma2GausFixedFromMassFit
flag to fix peak width from mass prefit
void SetFixGaussianSigma(Double_t sigma)
Double_t fRawYieldUncertainty
raw yield from simultaneus fit
Double_t GetPowerExpoPDF(Double_t x, Double_t *pars)
Int_t fNSigmaForSB
simultaneus fit probability
Double_t * sigma
TF1 * fMassBkgFunc
mass fit function (1st step, from prefit)
Double_t fMaxRefl
minimum for refelction histo
Double_t vnFunc(Double_t *m, Double_t *pars)
Double_t fVnUncertainty
vn of the signal from fit
Double_t fProb
simultaneus fit number of degree of freedom
Double_t MassSignal(Double_t *m, Double_t *pars)
void SetFixGaussianMean(Double_t mean)
Bool_t fFrac2GausFixedFromMassFit
flag to fix second peak width from mass prefit in case of k2Gaus
int Int_t
Definition: External.C:63
TF1 * fMassSecPeakFunc
switch off/on second peak (for D+->KKpi in Ds)
Double_t GetMean() const
TF1 * fVnBkgFunc
vn bkg fit function (1st step from SB prefit)
Int_t fPolDegreeBkg
flag to fix fraction of second gaussian in case of k2Gaus
Double_t fSecWidth
position of the 2nd peak
void SetInitialSecondGaussianSigma(Double_t sigma)
TF1 * fVnTotFunc
vn bkg fit function (final, after simultaneus fit)
Int_t fHarmonic
vn uncertainty of second peak from fit
Double_t fSigmaInit
number of sigma for sidebands region (vn bkg prefit)
Int_t fNParsMassBkg
number of parameters in mass signal fit function
Double_t MassBkgRfl(Double_t *m, Double_t *par)
Double_t fMeanUncertainty
mass peak position from simultaneus fit
Double_t GetPolPDF(Double_t x, Double_t *pars, Int_t order, Bool_t isnorm=kTRUE)
TH1F * SetTemplateReflections(const TH1 *h, TString opt, Double_t minRange, Double_t maxRange)
Double_t fSigma
uncertainty on vn of the signal from simultaneus fit
TF1 * fVnBkgFuncSb
mass fit function (final, after simultaneus fit)
Double_t fMeanInit
initialization for peak width
TList * fitter
Definition: DrawAnaELoss.C:26
TH1F * fMassHisto
data members
void DrawHere(TVirtualPad *c)
TH1F * fHistoTemplRflInit
histogram with reflection template
Double_t GetGausPDF(Double_t x, Double_t mean, Double_t sigma)
fit functions
Int_t fNDF
simultaneus fit chi square
static void ComputeSignificance(Double_t signal, Double_t errsignal, Double_t background, Double_t errbackground, Double_t &significance, Double_t &errsignificance)
Significance calculator.
Bool_t fDoSecondPeakVn
vn of second peak from fit
TF1 * fMassRflFunc
initial histogram with reflection template
Double_t MassFunc(Double_t *m, Double_t *pars)
void Background(Double_t nOfSigma, Double_t &background, Double_t &errbackground) const
AliHFInvMassFitter * fMassFitter
vn fit function (final, after simultaneus fit)
TF1 * fMassBkgRflFunc
fit function for reflections
void SetInitialReflOverS(Double_t rovers)
Int_t fNParsVnRfl
number of parameters in vn sec peak fit function (1 if included, 0 otherwise)
TF1 * fMassFuncFromPrefit
type of vn bkg fit function
TH1F * fVnVsMassHisto
mass histogram to fit
Int_t fNParsMassSgn
mass of selected particle
void SetInitialGaussianSigma(Double_t sigma)
void SetInitialGaussianMean(Double_t mean)
Double_t minMass
Int_t fNParsVnSgn
number of parameters in vn bkg fit function
Double_t fSigmaUncertainty
mass peak width from simultaneus fit
Double_t fFrac2GausInit
initialization for second peak width in case of k2Gaus
Double_t fRawYield
uncertainty on mass peak position from simultaneus fit
Int_t fSigmaFixed
number of parameters in vn refl fit function (1 if included, 0 otherwise)
Double_t fMinRefl
refelction option
Int_t fVnBkgFuncType
type of mass bkg fit function
void Significance(Double_t nOfSigma, Double_t &significance, Double_t &errsignificance) const
Int_t fMassBkgFuncType
type of mass signal fit function
TF1 * fMassSgnFunc
mass bkg fit function (final, after simultaneus fit)
void SetInitialFrac2Gaus(Double_t frac)
Double_t maxMass
bool Bool_t
Definition: External.C:53
Double_t fRawYieldHelp
switch for smoothing of reflection template
Bool_t fFixRflOverSig
reflection/signal
TString fRflOpt
mass bkg fit function plus reflections (final, after simultaneus fit)
Double_t fMassMin
mass fitter for mass prefit
Double_t MassBkg(Double_t *m, Double_t *pars)
Double_t fVnSecPeakUncertainty
flag to introduce second peak vn in the vn vs. mass fit
Bool_t fSmoothRfl
maximum for refelction histo
Double_t fVnSecPeak
flag to fix the width of the 2nd peak