1 /**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
22 #include "AliDielectronBtoJPSItoEleCDFfitFCN.h"
24 //_________________________________________________________________________
25 // Class AliDielectronBtoJPSItoEleCDFfitFCN
26 // Definition of main function used in
27 // unbinned log-likelihood fit for
28 // the channel B -> JPsi + X -> e+e- + X
30 // Origin: C.Di Giglio
31 // Contact: Carmelo.Digiglio@ba.infn.it , Giuseppe.Bruno@ba.infn.it
32 //_________________________________________________________________________
34 ClassImp(AliDielectronBtoJPSItoEleCDFfitFCN)
36 //_________________________________________________________________________________________________
37 AliDielectronBtoJPSItoEleCDFfitFCN::AliDielectronBtoJPSItoEleCDFfitFCN() :
46 fCrystalBallParam(kFALSE)
51 SetCrystalBallFunction(kFALSE);
54 for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = 0.;
55 fParameters[9] = 1.;fParameters[11] = 1.;fParameters[12] = 1.;
56 for(Int_t index=0; index<4; index++) fResolutionConstants[index] = 0.;
57 AliInfo("Instance of AliDielectronBtoJPSItoEleCDFfitFCN-class created");
59 //_________________________________________________________________________________________________
60 AliDielectronBtoJPSItoEleCDFfitFCN::AliDielectronBtoJPSItoEleCDFfitFCN(const AliDielectronBtoJPSItoEleCDFfitFCN& source) :
62 fFPlus(source.fFPlus),
63 fFMinus(source.fFMinus),
65 fintmMassSig(source.fintmMassSig),
66 fintmMassBkg(source.fintmMassBkg),
67 fhCsiMC(source.fhCsiMC),
68 fMassWndHigh(source.fMassWndHigh),
69 fMassWndLow(source.fMassWndLow),
70 fCrystalBallParam(source.fCrystalBallParam)
75 for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = source.fParameters[iPar];
76 for(Int_t index=0; index<4; index++) fResolutionConstants[index] = source.fResolutionConstants[index];
78 //_________________________________________________________________________________________________
79 AliDielectronBtoJPSItoEleCDFfitFCN& AliDielectronBtoJPSItoEleCDFfitFCN::operator=(const AliDielectronBtoJPSItoEleCDFfitFCN& source)
82 // Assignment operator
84 if(&source == this) return *this;
85 fFPlus = source.fFPlus;
86 fFMinus = source.fFMinus;
88 fintmMassSig = source.fintmMassSig;
89 fintmMassBkg = source.fintmMassBkg;
90 fhCsiMC = source.fhCsiMC;
91 fCrystalBallParam = source.fCrystalBallParam;
93 for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = source.fParameters[iPar];
94 for(Int_t index=0; index<4; index++) fResolutionConstants[index] = source.fResolutionConstants[index];
98 //_________________________________________________________________________________________________
99 AliDielectronBtoJPSItoEleCDFfitFCN::~AliDielectronBtoJPSItoEleCDFfitFCN()
102 // Default destructor
106 for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = 0.;
107 for(Int_t index=0; index<4; index++) fResolutionConstants[index] = 0.;
109 //_________________________________________________________________________________________________
110 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateLikelihood(const Double_t* pseudoproperdecaytime,
111 const Double_t* invariantmass, const Int_t ncand) const
114 // This function evaluates the Likelihood fnction
115 // It returns the -Log(of the likelihood function)
120 for(Int_t i=0; i < ncand; i++) {
121 f = EvaluateCDFfuncNorm(pseudoproperdecaytime[i],invariantmass[i]);
122 if(f <= 0.) continue;
123 ret += -1*TMath::Log(f);
127 //_________________________________________________________________________________________________
128 void AliDielectronBtoJPSItoEleCDFfitFCN::SetAllParameters(const Double_t* parameters)
131 // Sets array of FCN parameters
133 for(Int_t index = 0; index < 20; index++) fParameters[index] = parameters[index];
135 //_________________________________________________________________________________________________
136 void AliDielectronBtoJPSItoEleCDFfitFCN::ComputeMassIntegral()
139 // this function compute the integral of the likelihood function
140 // (theoretical function) in order to normalize it to unity
142 Double_t npm = 20000.;
145 stepm = (fMassWndHigh-fMassWndLow)/npm;
146 // compute integrals for invariant mass terms
149 Double_t intmMassSig = 0.0;
150 Double_t summMassSig = 0.0;
151 for(iMassSig = 1.0; iMassSig<= npm/2.; iMassSig++) {
152 mx = fMassWndLow + (iMassSig - .5)*stepm;
153 summMassSig += EvaluateCDFInvMassSigDistr(mx);
154 mx = fMassWndHigh - (iMassSig - .5)*stepm;
155 summMassSig += EvaluateCDFInvMassSigDistr(mx);
157 intmMassSig = summMassSig*stepm;
158 SetIntegralMassSig(intmMassSig);
161 Double_t intmMassBkg = 0.0;
162 Double_t summMassBkg = 0.0;
163 for(iMassBkg = 1.0; iMassBkg <= npm/2.; iMassBkg++) {
164 mx = fMassWndLow + (iMassBkg - .5)*stepm;
165 summMassBkg += EvaluateCDFInvMassBkgDistr(mx);
166 mx = fMassWndHigh - (iMassBkg - .5)*stepm;
167 summMassBkg += EvaluateCDFInvMassBkgDistr(mx);
169 intmMassBkg = summMassBkg*stepm;
170 SetIntegralMassBkg(intmMassBkg);
172 //_________________________________________________________________________________________________
173 void AliDielectronBtoJPSItoEleCDFfitFCN::PrintStatus()
176 // Print the parameters of the fits
180 printf("actual value of fWeightRes------------------------------------->> | %f \n", GetResWeight());
181 printf("actual value of fPos ------------------------------------------>> | %f \n", GetFPlus());
182 printf("actual value of fNeg ------------------------------------------>> | %f \n", GetFMinus());
183 printf("actual value of fSym ------------------------------------------>> | %f \n", GetFSym());
184 printf("actual value of fOneOvLamPlus --------------------------------->> | %f \n", GetLamPlus());
185 printf("actual value of fOneOvLamMinus -------------------------------->> | %f \n", GetLamMinus());
186 printf("actual value of fOneOvLamSym ---------------------------------->> | %f \n", GetLamSym());
187 printf("actual value of fFractionJpsiFromBeauty ----------------------->> | %f \n", GetFractionJpsiFromBeauty());
188 printf("actual value of fFsig ----------------------------------------->> | %f \n", GetFsig());
190 if(fCrystalBallParam){
191 printf("actual value of fCrystalBallMmean ----------------------------->> | %f \n", GetCrystalBallMmean());
192 printf("actual value of fCrystalBallNexp ------------------------------>> | %f \n", GetCrystalBallNexp());
193 printf("actual value of fCrystalBallSigma ----------------------------->> | %f \n", GetCrystalBallSigma());
194 printf("actual value of fCrystalBallAlpha ----------------------------->> | %f \n", GetCrystalBallAlpha());
195 printf("actual value of fCrystalBallNorm ----------------------------->> | %f \n", GetCrystalBallNorm());
197 printf("actual value of fMpv ------------------------------------------>> | %f \n", GetCrystalBallMmean());
198 printf("actual value of fConstRovL ------------------------------------>> | %f \n", GetCrystalBallNexp());
199 printf("actual value of fSigmaL --------------------------------------->> | %f \n", GetCrystalBallSigma());
200 printf("actual value of fSigmaR --------------------------------------->> | %f \n", GetCrystalBallAlpha());
204 printf("actual value of normBkg ----------------------------------------->> | %f \n", GetBkgInvMassNorm());
205 printf("actual value of meanBkg ----------------------------------------->> | %f \n", GetBkgInvMassMean());
206 printf("actual value of slopeBkg ---------------------------------------->> | %f \n", GetBkgInvMassSlope());
207 printf("actual value of constBkg ---------------------------------------->> | %f \n", GetBkgInvMassConst());
209 printf("actual value of norm1Gauss -------------------------------------->> | %f \n",GetNormGaus1ResFunc());
210 printf("actual value of norm2Gauss -------------------------------------->> | %f \n",GetNormGaus2ResFunc());
213 // integrals constants
214 printf("Actual value of normalization integral for MassSig ---------------->> | %f \n", GetIntegralMassSig());
215 printf("Actual value of normalization integral for MassBkg ---------------->> | %f \n", GetIntegralMassBkg());
219 //_________________________________________________________________________________________________
220 void AliDielectronBtoJPSItoEleCDFfitFCN::SetResolutionConstants(Double_t* resolutionConst)
223 // Resolution function is parametrized as the sum of two gaussian
225 fResolutionConstants[0] = resolutionConst[0]; // mean 1
226 fResolutionConstants[1] = resolutionConst[1]; // sigma 1
227 fResolutionConstants[2] = resolutionConst[2]; // mean 2
228 fResolutionConstants[3] = resolutionConst[3]; // sigma 2
231 //_________________________________________________________________________________________________
232 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfunc(Double_t x, Double_t m) const
234 return fParameters[8]*EvaluateCDFfuncSignalPart(x,m) + (1. - fParameters[8])*EvaluateCDFfuncBkgPart(x,m);
237 //_________________________________________________________________________________________________
238 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncNorm(Double_t x, Double_t m) const
240 return EvaluateCDFfunc(x,m);
243 //_________________________________________________________________________________________________
244 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncSignalPart(Double_t x, Double_t m) const
246 return EvaluateCDFDecayTimeSigDistr(x)*(EvaluateCDFInvMassSigDistr(m)/fintmMassSig);
249 //_________________________________________________________________________________________________
250 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeSigDistr(Double_t x) const
253 // Implementation of the Background part of the Likelyhood function
256 Double_t retvalue = 0.;
257 Double_t funBnorm = FunB(x);
258 Double_t funPnorm = ResolutionFunc(x);
259 retvalue = fParameters[7]*funBnorm + (1. - fParameters[7])*funPnorm;
263 //_________________________________________________________________________________________________
264 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFInvMassSigDistr(Double_t m) const
267 // Parametrization of signal part invariant mass distribution
268 // It can be either Crystal Ball function or sum of two Landau
271 Double_t fitval = 0.;
273 if(fCrystalBallParam){
274 Double_t t = (m-fParameters[9])/fParameters[11]; ;
275 if (fParameters[12] < 0) t = -t;
277 Double_t absAlpha = TMath::Abs((Double_t)fParameters[12]);
279 if (t >= -absAlpha) {
280 return fParameters[13]*TMath::Exp(-0.5*t*t);
283 Double_t a = TMath::Power(fParameters[10]/absAlpha,fParameters[10])* TMath::Exp(-0.5*absAlpha*absAlpha);
284 Double_t b= fParameters[10]/absAlpha - absAlpha;
285 fitval = (fParameters[13]*a/TMath::Power(b - t, fParameters[10]));
290 Double_t tmpv=-1*fParameters[9];
291 fitval=TMath::Sqrt(TMath::Landau(t,tmpv,fParameters[11]));
292 fitval += fParameters[10]*(TMath::Landau(m,fParameters[9],fParameters[12]));
296 //_________________________________________________________________________________________________
297 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunB(Double_t x) const
300 // Parameterisation of the fit function for the x part of the Background
302 Double_t np = 1000.0;
304 Double_t sigma3 = 1000.; // valore usato nella macro
310 xlow = x - sc * sigma3 ;
311 xupp = x + sc * sigma3 ;
312 step = (xupp-xlow) / np;
313 Double_t csiMCxprime = 0.;
314 Double_t resolutionxdiff = 0.;
317 for(i=1.0; i<=np; i++){
318 xprime = xlow + (i-.5) * step;
319 csiMCxprime = CsiMC(xprime);
321 resolutionxdiff = ResolutionFunc(xdiff); // normalized value
322 sum += csiMCxprime * resolutionxdiff;
327 //_________________________________________________________________________________________________
328 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunP(Double_t x) const
331 // Parameterisation of the Prompt part for the x distribution
333 return ResolutionFunc(x);
337 //_________________________________________________________________________________________________
338 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::CsiMC(Double_t x) const
341 // Distribution (template) of the x distribution for the x variable
342 // for the J/psi coming from Beauty hadrons
344 Double_t returnvalue = 0.;
346 if((fhCsiMC->FindBin(x) > 0) && (fhCsiMC->FindBin(x) < fhCsiMC->GetNbinsX()+1))
347 returnvalue = fhCsiMC->Interpolate(x);
352 //_________________________________________________________________________________________________
353 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncBkgPart(Double_t x,Double_t m) const
356 // Return the part of the likelihood function for the background hypothesis
358 return EvaluateCDFDecayTimeBkgDistr(x)*(EvaluateCDFInvMassBkgDistr(m)/fintmMassBkg);
361 //_________________________________________________________________________________________________
362 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeBkgDistr(Double_t x) const
365 // it returns the value of the probability to have a given x for the background
368 Double_t ret = fParameters[0]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*ResolutionFunc(x) + fParameters[1]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgPos(x) + fParameters[2]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgNeg(x) + fParameters[3]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgSym(x);
372 //_________________________________________________________________________________________________
373 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFInvMassBkgDistr(Double_t m) const
376 // it returns the value of the probability to have a given mass for the background
379 value = fParameters[14]*TMath::Exp(-1*(m-fParameters[15])/fParameters[16]) + fParameters[17];
382 //_________________________________________________________________________________________________
383 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgPos(Double_t x) const
386 // exponential with positive slopes for the background part (x)
389 Double_t np = 1000.0;
391 Double_t sigma3 = 1000.; // valore usato nella macro
397 xlow = x - sc * sigma3 ;
398 xupp = x + sc * sigma3 ;
399 step = (xupp-xlow) / np;
401 for(i=1.0; i<=np/2; i++) {
402 xprime = xlow + (i-.5) * step;
403 if (xprime > 0) {sum += fParameters[4] * TMath::Exp(-1*xprime*fParameters[4])*(ResolutionFunc(xprime-x));}
404 xprime = xupp - (i-.5) * step;
405 if (xprime > 0) {sum += fParameters[4] * TMath::Exp(-1*xprime*fParameters[4])*(ResolutionFunc(xprime-x));}
410 //_________________________________________________________________________________________________
411 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgNeg(Double_t x) const
414 // exponential with negative slopes for the background part (x)
416 Double_t np = 1000.0;
418 Double_t sigma3 = 1000.;
424 xlow = x - sc * sigma3 ;
425 xupp = x + sc * sigma3 ;
426 step = (xupp-xlow) / np;
428 for(i=1.0; i<=np/2; i++) {
430 xprime = xlow + (i-.5) * step;
431 if (xprime < 0) {sum += fParameters[5] * TMath::Exp(xprime*fParameters[5]) * (ResolutionFunc(xprime-x));}
433 xprime = xupp - (i-.5) * step;
434 if (xprime < 0) {sum += fParameters[5] * TMath::Exp(xprime*fParameters[5]) * (ResolutionFunc(xprime-x));}
439 //_________________________________________________________________________________________________
440 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgSym(Double_t x) const
443 // exponential with both positive and negative slopes for the background part (x)
445 Double_t np = 1000.0;
447 Double_t sigma3 = 1000.;
454 xlow = x - sc * sigma3 ;
455 xupp = x + sc * sigma3 ;
456 step = (xupp-xlow) / np;
458 for(i=1.0; i<=np/2; i++) {
460 xprime = xlow + (i-.5) * step;
461 if (xprime > 0) {sum1 += 0.5 * fParameters[6]*TMath::Exp(-1*xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
462 if (xprime < 0) {sum2 += 0.5 * fParameters[6]*TMath::Exp(xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
464 xprime = xupp - (i-.5) * step;
465 if (xprime > 0) {sum1 += 0.5 * fParameters[6]*TMath::Exp(-1*xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
466 if (xprime < 0) {sum2 += 0.5 * fParameters[6]*TMath::Exp(xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
469 return step*(sum1 + sum2) ;
471 //_________________________________________________________________________________________________
472 Double_t AliDielectronBtoJPSItoEleCDFfitFCN::ResolutionFunc(Double_t x) const
475 // parametrization with 2 gaus
478 Double_t mean1 = fResolutionConstants[0];
479 Double_t mean2 = fResolutionConstants[2];
480 Double_t norm1 = fParameters[18];
481 Double_t sigma1 = fResolutionConstants[1];
482 Double_t sigma2 = fResolutionConstants[3];
483 Double_t norm2 = fParameters[19];
485 ret = (norm1/(norm1+norm2))*((1/(sigma1*TMath::Sqrt(2*TMath::Pi())))*TMath::Exp(-0.5*((x-mean1)/sigma1)*((x-mean1)/sigma1)))+(norm2/(norm1+norm2))*((1/(sigma2*TMath::Sqrt(2*TMath::Pi())))*TMath::Exp(-0.5*((x-mean2)/sigma2)*((x-mean2)/sigma2)));
490 //_________________________________________________________________________________________________
491 TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetCsiMC(Double_t xmin, Double_t xmax)
493 // return the pointer to the templateMC function
494 TF1* templateMC = new TF1("MCtemplate",this,&AliDielectronBtoJPSItoEleCDFfitFCN::CsiMCfunc,xmin,xmax,0);
495 templateMC->SetNpx(5000);
496 return (TF1*)templateMC->Clone();
499 //__________________________________________________________________________________________________
500 TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetResolutionFunc(Double_t xmin, Double_t xmax){
501 // return the pointer to the resolution function
502 TF1* resFunc = new TF1("resolutionFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::ResolutionFuncf,xmin,xmax,0);
503 resFunc->SetNpx(5000);
504 return (TF1*)resFunc->Clone();
507 //___________________________________________________________________________________________________
508 TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetEvaluateCDFDecayTimeBkgDistr(Double_t xmin, Double_t xmax){
509 // return the pointer to the background x distribution function
510 TF1 *backFunc = new TF1("backFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeBkgDistrFunc,xmin,xmax,0);
511 backFunc->SetNpx(5000);
512 return (TF1*)backFunc->Clone();
515 //__________________________________________________________________________________________________
516 TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetEvaluateCDFDecayTimeSigDistr(Double_t xmin, Double_t xmax){
517 // return the pointer to the signal x distribution function
518 TF1 *signFunc = new TF1("signalFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeSigDistrFunc,xmin,xmax,0);
519 signFunc->SetNpx(5000);
520 return (TF1*)signFunc->Clone();