]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/macros/FitCDFLocal.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / macros / FitCDFLocal.C
1 void FitCDFLocal() {
2
3   ///////////////////////////////////////////////////////////////////
4   //
5   // Example macro to read local N-Tuples of JPSI 
6   // and bkg candidates and perform log-likelihood 
7   // minimization using the minimization handler class
8   //
9   // Origin: C. Di Giglio
10   //
11   ///////////////////////////////////////////////////////////////////
12
13   Bool_t useParFiles=kFALSE;
14   gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/LoadLibraries.C");
15   LoadLibraries(useParFiles);
16
17   TH1F* hCsiMCPithya = new TH1F();
18   TH1F* hCsiMCevtgen = new TH1F();
19
20   TString datadir=".";
21   TString useFile = datadir.Data();
22   useFile.Append("/CmpBdecayKine.root"); // file with MC templates for J/psi (<-B) X distribution (in different pT bins)
23   TFile *fCmpBdecayKine = new TFile(useFile);
24   hCsiMCPithya = (TH1F*)fCmpBdecayKine->Get("PsproperPithya46GeV"); // Pithya case: 4 - 6 GeV
25   hCsiMCPithya->Scale(1./hCsiMCPithya->Integral());
26   hCsiMCevtgen = (TH1F*)fCmpBdecayKine->Get("PsproperEvtGen46GeV"); // EvtGen case: 4 - 6 GeV
27   hCsiMCevtgen->Scale(1./hCsiMCevtgen->Integral());
28
29   Double_t* x=0x0; Double_t* m=0x0; Int_t n=0;
30   AliAnalysisBtoJPSItoEle* aBtoJPSItoEle =new AliAnalysisBtoJPSItoEle();
31   Double_t paramInputValues [16] = /*  
32                                      paramInputValues[0]   ----> fRadius;
33                                      paramInputValues[1]   ----> fTheta;
34                                      paramInputValues[2]   ----> fPhi;
35                                      paramInputValues[3]   ----> fOneOvLamPlus;
36                                      paramInputValues[4]   ----> fOneOvLamMinus;
37                                      paramInputValues[5]   ----> fOneOvLamSym;
38                                      paramInputValues[6]   ----> fMSlope;
39                                      paramInputValues[7]   ----> fB;
40                                      paramInputValues[8]   ----> fFsig;
41                                      paramInputValues[9]   ----> fMmean;
42                                      paramInputValues[10]  ----> fNexp;
43                                      paramInputValues[11]  ----> fSigma;
44                                      paramInputValues[12]  ----> fAlpha;
45                                      paramInputValues[13]  ----> fNorm;
46                                      paramInputValues[14]  ----> fSigmaResol;
47                                      paramInputValues[15]  ----> fNResol;
48                                    */
49                                    { 0.5,TMath::Pi()/4.,
50                                      TMath::Pi()/4.,
51                                      0.00210,
52                                      0.00480,
53                                      0.,
54                                      0.,
55                                      0.227272,
56                                      0.3981,
57                                      3.09568,
58                                      0.9671,
59                                      0.0239,
60                                      0.6599,
61                                      0.04587,
62                                      55.4, 
63                                      0.033 }; // Starting values for parameters 
64
65   TFile *f= new TFile("CdfFit_OneYear.root"); // file with N-tuples for one year collected statistics (in different pT bins)
66   //TNtuple *nt=(TNtuple*)f->Get("fNtupleJPSI12GeV");
67   //TNtuple *nt=(TNtuple*)f->Get("fNtupleJPSI23GeV");
68   //TNtuple *nt=(TNtuple*)f->Get("fNtupleJPSI34GeV");
69   TNtuple *nt=(TNtuple*)f->Get("fNtupleJPSI46GeV"); // N-Tuples in 4 - 6 Gev
70   nt->ls();
71
72   aBtoJPSItoEle->ReadCandidates(nt,x,m,n); // read N-Tuples
73   printf("+++\n+++  
74           Number of total candidates (prim J/psi + secondary J/psi + bkg) ---> %d candidates 
75           \n+++\n",n);
76
77   aBtoJPSItoEle->SetFitHandler(x,m,n); // Set the fit handler with given values of x, m, # of candidates 
78
79   aBtoJPSItoEle->CloneMCtemplate(hCsiMCPithya);    // clone MC template and copy internally
80                                                    // in this way any model can be setted from outside
81   //aBtoJPSItoEle->CloneMCtemplate(hCsiMCEvtGen);  // clone MC template and copy internally
82                                                    // in this way any model can be setted from outside
83
84   aBtoJPSItoEle->SetCsiMC(); // Pass the MC template to the CDF fit function
85
86   AliBtoJPSItoEleCDFfitHandler* fithandler = aBtoJPSItoEle->GetCDFFitHandler(); // Get the fit handler
87
88   //
89   // Set some fit options through the handler class
90   //
91   fithandler->SetErrorDef(0.5); // tells Minuit that the error interval is the one in which
92                                 // the function differs from the minimum for less than setted value
93
94   fithandler->SetPrintStatus(kTRUE);
95
96   fithandler->SetParamStartValues(paramInputValues);
97   fithandler->SetResolutionConstants(); 
98   fithandler->SetCrystalBallFunction(kTRUE);
99   fithandler->SetMassWndLow(0.6);
100   fithandler->SetMassWndHigh(0.4);
101   //fithandler->FixParam(5,kTRUE); // Fix some parameters to their input values
102   //fithandler->FixParam(14,kTRUE);
103   //fithandler->FixParam(15,kTRUE);
104   fithandler->SetMassWndLow(0.341696); // ----> M_low = 2.75 GeV
105   fithandler->SetMassWndHigh(0.308304); // ----> M_high = 3.4 GeV
106
107   aBtoJPSItoEle->DoMinimization();
108
109   f->Close();
110 }