]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/SPECTRA/Nuclei/B2/macros/DrawPt.C
cumulative changes for root scripts and code cleanup
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / DrawPt.C
CommitLineData
2403d402 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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
16// Draw corrected pt
17// author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
aa54def0 19#if !defined(__CINT__) || defined(__MAKECINT__)
2403d402 20#include <TROOT.h>
aa54def0 21#include <TStyle.h>
2403d402 22#include <TFile.h>
23#include <TH1D.h>
24#include <TString.h>
25#include <TCanvas.h>
26#include <TGraphErrors.h>
27#include <TLegend.h>
2403d402 28#include <RooWorkspace.h>
29#include <RooMsgService.h>
30#include <RooPlot.h>
31#include <RooRealVar.h>
2403d402 32#include <RooAbsData.h>
aa54def0 33#include <RooAbsPdf.h>
34#endif
2403d402 35
36#include "B2.h"
37
aa54def0 38void DrawPt(const TString& inputFile="debug.root", const TString& tag="test", const TString& particle="AntiDeuteron", Double_t ptmax=3., Bool_t m2pid=0, Double_t ptpid=1.2)
2403d402 39{
40//
41// Draw corrected pt for debugging
42//
43 Double_t xmin = 0;
44 Double_t xmax = 3.5;
45
aa54def0 46 gStyle->SetPadTickX(1);
47 gStyle->SetPadTickY(1);
48 gStyle->SetPadGridX(1);
49 gStyle->SetPadGridY(1);
50 gStyle->SetOptStat(0);
51 gStyle->SetOptTitle(1);
52
2403d402 53 TFile* finput = new TFile(inputFile.Data());
54 if (finput->IsZombie()) exit(1);
55
aa54def0 56 TH1D* hPidPt = FindObj<TH1D>(finput, tag, Form("%s_PID_Pt",particle.Data()));
57
58 Int_t hiptbin = hPidPt->GetXaxis()->FindFixBin(ptmax);
59 Int_t lowm2bin = hPidPt->GetXaxis()->FindFixBin(ptpid);
60 Int_t him2bin = hPidPt->GetXaxis()->FindFixBin(ptmax);
61
2403d402 62 // m2 data fitted models
63
fe25d981 64 if(m2pid && (hiptbin>lowm2bin))
2403d402 65 {
2403d402 66 using namespace RooFit;
67
68 // disable verbose in RooFit
69 RooMsgService::instance().setSilentMode(1);
70 RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
71
72 TCanvas* c0 = new TCanvas(Form("%s.M2",particle.Data()), Form("M2 for %ss",particle.Data()));
aa54def0 73 c0->Divide(4,5);
2403d402 74
75 TGraphErrors* grFitSigmaPt = new TGraphErrors();
76 grFitSigmaPt->SetName(Form("%s_Fit_Sigma_Pt", particle.Data()));
77
78 TGraphErrors* grFitM2Pt = new TGraphErrors();
79 grFitM2Pt->SetName(Form("%s_Fit_M2_Pt", particle.Data()));
80
aa54def0 81 for(Int_t i=lowm2bin, j=0; i<him2bin && i-lowm2bin < 20 && i < hiptbin; ++i)
2403d402 82 {
83 c0->cd(i-lowm2bin+1);
2403d402 84
aa54def0 85 RooWorkspace* w= FindObj<RooWorkspace>(finput, tag, Form("%s_M2_%02d",particle.Data(),i));
2403d402 86
aa54def0 87 RooPlot* m2frame = w->var("x")->frame();
2403d402 88
89 w->data("data")->plotOn(m2frame);
90
aa54def0 91 w->pdf("model")->plotOn(m2frame, Components(*(w->pdf("Sd"))),LineWidth(1), LineColor(8));
2403d402 92 w->pdf("model")->plotOn(m2frame, Components(*(w->pdf("Bkg"))),LineWidth(1), LineColor(46),LineStyle(kDashed));
aa54def0 93 w->pdf("model")->plotOn(m2frame, LineWidth(1));
2403d402 94
aa54def0 95 m2frame->SetTitle(Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c}", hPidPt->GetBinLowEdge(i), hPidPt->GetBinLowEdge(i)+hPidPt->GetBinWidth(i)));
2403d402 96 m2frame->SetMinimum(0.2);
aa54def0 97
2403d402 98 m2frame->Draw();
99
aa54def0 100 Double_t pt = hPidPt->GetBinCenter(i);
101
102 grFitSigmaPt->SetPoint(j, pt, w->var("sigma")->getVal());
103 grFitSigmaPt->SetPointError(j, 0, w->var("sigma")->getError());
2403d402 104
aa54def0 105 grFitM2Pt->SetPoint(j, pt, w->var("mu")->getVal());
106 grFitM2Pt->SetPointError(j++, 0, w->var("mu")->getError());
2403d402 107 }
108
aa54def0 109 c0->Update();
110
2403d402 111 // model parameters
112
113 TCanvas* c1 = new TCanvas(Form("%s.M2.FitParameters",particle.Data()), Form("M2 model parameters for %ss",particle.Data()));
114
115 c1->Divide(2,1);
116
117 c1->cd(1);
2403d402 118
119 grFitSigmaPt->SetMarkerStyle(kFullCircle);
120 grFitSigmaPt->SetMarkerColor(kBlue);
121 grFitSigmaPt->SetLineColor(kBlue);
122 grFitSigmaPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
aa54def0 123 grFitSigmaPt->GetYaxis()->SetTitle("#sigma");
2403d402 124 grFitSigmaPt->Draw("ALP");
125
126 c1->cd(2);
2403d402 127
128 grFitM2Pt->SetMarkerStyle(kFullCircle);
129 grFitM2Pt->SetMarkerColor(kBlue);
130 grFitM2Pt->SetLineColor(kBlue);
131 grFitM2Pt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
aa54def0 132 grFitM2Pt->GetYaxis()->SetTitle("#mu");
2403d402 133 grFitM2Pt->Draw("ALP");
134
135 //delete grFitSigmaPt;
136 //delete grFitM2Pt;
aa54def0 137
138 c1->Update();
2403d402 139 }
140
141 // remaining corrections
142
aa54def0 143 TCanvas* c2 = new TCanvas(Form("%s.Pt",particle.Data()), Form("Pt for %s",particle.Data()));
144 c2->SetLogy();
145
146 const Int_t kNum = 4;
147 const TString kCorr[kNum] = { "PID", "PidCorr", "SecCorr", "EffCorr"};
148 const TString kLabel[kNum] = { "Raw", "PID", "Secondaries","Efficiency" };
149 const Int_t kColor[] = { kRed, kAzure, kOrange+1, kGreen-3, kGreen-2};
150 const Int_t kMarker[] = { kFullCircle, kFullSquare, kFullTriangleUp, kFullTriangleDown, kFullCircle, kOpenTriangleUp};
2403d402 151
152 TLegend* legend = new TLegend(0.5689655,0.6355932,0.8362069,0.8326271,0,"brNDC");
153 legend->SetTextSize(0.03);
154 legend->SetFillColor(0);
155 legend->SetBorderSize(0);
156
157 TH1D* hPt[kNum];
158
159 for(Int_t i=0; i<kNum; ++i)
160 {
aa54def0 161 hPt[i] = FindObj<TH1D>(finput, tag, particle + "_" + kCorr[i] + "_Pt");
2403d402 162 hPt[i]->SetLineColor(kColor[i]);
163 hPt[i]->SetMarkerColor(kColor[i]);
164 hPt[i]->SetMarkerStyle(kMarker[i]);
165 legend->AddEntry(hPt[i], kLabel[i], "lp");
166 }
167
0f539a2b 168 hPt[kNum-1]->SetTitle(particle.Data());
169 hPt[kNum-1]->SetAxisRange(xmin,xmax,"X");
170 hPt[kNum-1]->Draw("E");
2403d402 171
aa54def0 172 for(Int_t i=0; i<kNum-1; ++i) hPt[i]->Draw("sameE");
2403d402 173 legend->Draw();
aa54def0 174
175 c2->Update();
2403d402 176}