B2 analysis code
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / DrawSpectra.C
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 differential yields
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 #include <Riostream.h>
20 #include <TROOT.h>
21 #include <TStyle.h>
22 #include <TFile.h>
23 #include <TString.h>
24 #include <TCanvas.h>
25 #include <TGraphErrors.h>
26 #include <TF1.h>
27
28 #include "B2.h"
29
30 void DrawSpectra(const TString& inputFile="spectra.root", const TString& tag="lhc10d", const TString& particle="Deuteron")
31 {
32 //
33 // Draw differential yields
34 //
35         gStyle->SetOptLogy(1);
36         
37         TFile* finput = new TFile(inputFile.Data());
38         if (finput->IsZombie()) exit(1);
39         
40         TCanvas* c0 = new TCanvas(Form("%s.Spectra", particle.Data()), Form("Spectra for %ss", particle.Data()));
41         c0->Divide(2,2);
42         
43         // differential yields
44         
45         c0->cd(1);
46         
47         TGraphErrors* grDYieldPt = (TGraphErrors*)FindObj(finput, tag, particle + "_DiffYield_Pt");
48         TGraphErrors* grSysErrDYieldPt = (TGraphErrors*)FindObj(finput, tag, particle + "_SysErr_DiffYield_Pt");
49         
50         grSysErrDYieldPt->SetLineColor(kRed);
51         grSysErrDYieldPt->SetFillStyle(0);
52         grSysErrDYieldPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
53         grSysErrDYieldPt->GetYaxis()->SetTitle("#frac{1}{N_{inel}} #frac{d^{2}N}{dp_{T}dy} (GeV^{-1}c^{2})");
54         grSysErrDYieldPt->Draw("A5");
55         
56         grDYieldPt->SetMarkerStyle(kFullCircle);
57         grDYieldPt->SetMarkerColor(kRed);
58         grDYieldPt->SetLineColor(kRed);
59         grDYieldPt->Draw("P");
60         
61         // fitting function
62         TF1* fit0 = (TF1*)FindObj(finput, tag, particle + "_Fit_DiffYield_Pt");
63         fit0->SetLineWidth(1);
64         fit0->SetLineColor(kRed);
65         fit0->Draw("same");
66         
67         // invariant differential yields
68         
69         c0->cd(2);
70         
71         TGraphErrors* grInvDYieldPt = (TGraphErrors*)FindObj(finput, tag, particle + "_InvDiffYield_Pt");
72         TGraphErrors* grSysErrInvDYieldPt = (TGraphErrors*)FindObj(finput, tag, particle + "_SysErr_InvDiffYield_Pt");
73         
74         grSysErrInvDYieldPt->SetLineColor(kRed);
75         grSysErrInvDYieldPt->SetFillStyle(0);
76         grSysErrInvDYieldPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
77         grSysErrInvDYieldPt->GetYaxis()->SetTitle("#frac{1}{2#piN_{inel}} #frac{d^{2}N}{p_{T}dp_{T}dy} (GeV^{-2}c^{3})");
78         grSysErrInvDYieldPt->Draw("A5");
79         
80         grInvDYieldPt->SetMarkerStyle(kFullCircle);
81         grInvDYieldPt->SetMarkerColor(kRed);
82         grInvDYieldPt->SetLineColor(kRed);
83         grInvDYieldPt->Draw("P");
84         
85         // fitting function
86         TF1* fit1 = (TF1*)FindObj(finput, tag, particle + "_Fit_InvDiffYield_Pt");
87         fit1->SetLineWidth(1);
88         fit1->SetLineColor(kRed);
89         fit1->Draw("same");
90         
91         // invariant differential cross section
92         
93         c0->cd(3);
94         
95         TGraphErrors* grInvDXsectPt = (TGraphErrors*)FindObj(finput, tag, particle + "_InvDiffXSection_Pt");
96         TGraphErrors* grSysErrInvDXsectPt = (TGraphErrors*)FindObj(finput, tag, particle + "_SysErr_InvDiffXSection_Pt");
97         
98         grSysErrInvDXsectPt->SetLineColor(kRed);
99         grSysErrInvDXsectPt->SetFillStyle(0);
100         grSysErrInvDXsectPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
101         grSysErrInvDXsectPt->GetYaxis()->SetTitle("E #frac{d^{3}#sigma}{dp^{3}} (mb GeV^{-2}c^{3})");
102         grSysErrInvDXsectPt->Draw("A5");
103         
104         grInvDXsectPt->SetMarkerStyle(kFullCircle);
105         grInvDXsectPt->SetMarkerColor(kRed);
106         grInvDXsectPt->SetLineColor(kRed);
107         grInvDXsectPt->Draw("P");
108         
109         // fitting function
110         TF1* fit2 = (TF1*)FindObj(finput, tag, particle + "_Fit_InvDiffXSection_Pt");
111         fit2->SetLineWidth(1);
112         fit2->SetLineColor(kRed);
113         fit2->Draw("same");
114 }