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 **************************************************************************/
15 #include <TVirtualFitter.h>
16 #include <TStopwatch.h>
18 #include "AliBtoJPSItoEleCDFfitHandler.h"
19 #include "AliBtoJPSItoEleCDFfitFCN.h"
21 //-------------------------------------------------------------------------
22 // Class AliBtoJPSItoEleCDFfitHandler
23 // Class to perform unbinned log-likelihood fit
25 // Origin: C. Di Giglio
26 // Contact: carmelo.digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it
27 //-------------------------------------------------------------------------
29 void CDFFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag);
31 ClassImp(AliBtoJPSItoEleCDFfitHandler)
33 //______________________________________________________________________________
34 void CDFFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
36 // This function is called by minuit
37 // The corresponding member method is called
38 // using SetObjectFit/GetObjectFit methods of TMinuit
39 AliBtoJPSItoEleCDFfitHandler* dummy = (AliBtoJPSItoEleCDFfitHandler *)TVirtualFitter::GetFitter()->GetObjectFit();
40 dummy->CdfFCN(npar, gin, f, par, iflag);
44 //_________________________________________________________________________________________________
45 AliBtoJPSItoEleCDFfitHandler::AliBtoJPSItoEleCDFfitHandler():
53 // default constructor
56 //_________________________________________________________________________________________________
57 AliBtoJPSItoEleCDFfitHandler::AliBtoJPSItoEleCDFfitHandler(Double_t* decaytime,
58 Double_t* invariantmass, Int_t ncand) :
68 AliInfo("\n+++\n+++ Minimization object AliBtoJPSItoEleCDFfitHandler created\n+++\n");
69 AliInfo("\n+++\n+++ Creating AliBtoJPSItoEleCDFfitFCN object\n+++\n");
70 fLikely = new AliBtoJPSItoEleCDFfitFCN();
71 fLikely->SetCrystalBallParam(kFALSE); //Landau selected; otherwise Crystal Ball is selected
73 AliInfo(Form("\n+++\n+++ Number of candidates ---> %d\n+++\n ", ncand));
75 //___________________________________________________________________________
76 AliBtoJPSItoEleCDFfitHandler& AliBtoJPSItoEleCDFfitHandler::operator=(const AliBtoJPSItoEleCDFfitHandler& c)
79 // Assignment operator
91 //___________________________________________________________________________
92 AliBtoJPSItoEleCDFfitHandler::AliBtoJPSItoEleCDFfitHandler(const AliBtoJPSItoEleCDFfitHandler& c) :
104 //________________________________________________________________________
105 AliBtoJPSItoEleCDFfitHandler::~AliBtoJPSItoEleCDFfitHandler()
112 //_________________________________________________________________________________________________
113 Int_t AliBtoJPSItoEleCDFfitHandler::DoMinimization()
116 // performs the minimization
118 static TVirtualFitter *fitter = TVirtualFitter::Fitter(this,13);
119 fitter->SetFCN(CDFFunction);
120 Double_t startingParamValues[13] =
148 fitter->SetParameter(0,"fRadius",startingParamValues[0], 0.01, 0., 1.);
149 fitter->SetParameter(1,"fTheta",startingParamValues[1], 0.001, 0., TMath::Pi()/2);
150 fitter->SetParameter(2,"fPhi",startingParamValues[2], 0.001, 0., TMath::Pi()/2);
151 fitter->SetParameter(3,"fOneOvLamPlus",startingParamValues[3], 0.0001, 0., 5.e-01);
152 fitter->SetParameter(4,"fOneOvLamMinus",startingParamValues[4], 0.0001, 0., 5.e-01);
153 fitter->SetParameter(5,"fOneOvLamSym",startingParamValues[5], 0.00001, 0., 5.e-01);
154 fitter->SetParameter(6,"fMSlope",startingParamValues[6], 0.001, -1.e-00, 1.e+00);
155 fitter->SetParameter(7,"fB",startingParamValues[7], 0.1, 0., 1.);
156 fitter->SetParameter(8,"fFsig",startingParamValues[8], 0.1, 0., 1.);
157 fitter->SetParameter(9,"fMmean",startingParamValues[9], 0.1, 0., 1.e+02);
158 fitter->SetParameter(10,"fNexp",startingParamValues[10], 0.1, 0., 1.e+02);
159 fitter->SetParameter(11,"fSigma",startingParamValues[11], 0.001, 0., 1.e+02);
160 fitter->SetParameter(12,"fAlpha",startingParamValues[12], 0.01, 0., 1.e+02);
161 fitter->FixParameter(9);
163 Double_t arglist[2]={10000,0.5};
164 Int_t iret=fitter->ExecuteCommand("MIGRAD", arglist ,2);
165 fitter->PrintResults(4,0);
167 AliInfo("Minimization procedure finished\n");
171 //_______________________________________________________________________________________
172 void AliBtoJPSItoEleCDFfitHandler::CdfFCN(Int_t & /* npar */,
173 Double_t * /* gin */,Double_t &f,Double_t *par,Int_t /* iflag */)
176 // Definition of the FCN to be used by minuit
178 fLikely->SetAllParameters(par);
179 fLikely->ConvertFromSpherical();
180 fLikely->ComputeIntegral();
181 //printf("\n+++\n+++\n+++\n");
182 //fLikely->PrintStatus();
187 f = fLikely->EvaluateLikelihood(fX,fM,fNcand);
190 AliDebug(2,Form("Real time spent to calculate function == %f \n", t.RealTime()));
191 AliDebug(2,Form("CPU time spent to calculate function == %f \n", t.CpuTime()));
192 AliDebug(2,Form("Actual value of the AliBtoJPSItoEleCDFfitFCN function == %f \n", f));