B2 analysis code
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / DrawCorr.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 pt corrections for debugging
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 #include <Riostream.h>
20 #include <TROOT.h>
21 #include <TFile.h>
22 #include <TH1D.h>
23 #include <TH2D.h>
24 #include <TString.h>
25 #include <TCanvas.h>
26 #include <TF1.h>
27
28 #include "B2.h"
29
30 void DrawPair(TH1* hX, TH1* hY, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, const char* title="", const char* option="E", Int_t xMarker=kFullCircle, Int_t yMarker=kFullCircle, Int_t xColor=kBlue, Int_t yColor=kRed);
31
32 void DrawCorr(const TString& species="Deuteron", const TString& inputFile="corrections.root", const TString& tag="")
33 {
34 //
35 // Draw pt corrections for debugging
36 //
37         Double_t xmin = 0;
38         Double_t xmax = 3.5;
39         
40         const Int_t kNpart = 2;
41         
42         TFile* finput = new TFile(inputFile.Data());
43         if (finput->IsZombie()) exit(1);
44         
45         const TString kPrefix[] = {"", "Anti"};
46         
47         // Response matrix
48         
49         TCanvas* c0 = new TCanvas(Form("%s.Unfolding", species.Data()), Form("Response matrix for (Anti)%ss", species.Data()));
50         
51         c0->Divide(2,1);
52         
53         for(Int_t i=0; i<kNpart; ++i)
54         {
55                 c0->cd(i+1);
56                 
57                 TH2D* hResponseMtx = (TH2D*)FindObj(finput, tag, Form("%s%s_Response_Matrix",kPrefix[i].Data(), species.Data()));
58                 hResponseMtx->SetAxisRange(xmin, xmax, "X");
59                 hResponseMtx->SetAxisRange(xmin, xmax, "Y");
60                 hResponseMtx->GetYaxis()->SetTitleOffset(1.3);
61                 hResponseMtx->DrawCopy("cont0colZ");
62         }
63         
64         // Fake tracks
65         
66         TH1D* hFracFakeTracks[kNpart];
67         for(Int_t i=0; i<kNpart; ++i)
68         {
69                 hFracFakeTracks[i] = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Frac_Fake_Pt");
70         }
71         
72         TCanvas* c1 = new TCanvas(Form("%s.FakeTracks",species.Data()), Form("Fake Tracks for (Anti)%ss",species.Data()));
73         c1->cd();
74         
75         DrawPair(hFracFakeTracks[0], hFracFakeTracks[1], xmin, xmax, -0.01, 0.2);
76         
77         // Reconstruction efficiency
78         
79         TCanvas* c2 = new TCanvas(Form("%s.Efficiency",species.Data()), Form("Reconstruction Efficiency for (Anti)%ss",species.Data()));
80         c2->Divide(2,2);
81         
82         TH1D* hEffVtxPt[kNpart];
83         TH1D* hEffAccTrkPt[kNpart];
84         TH1D* hEffTrigPt[kNpart];
85         
86         for(Int_t i=0; i<kNpart; ++i)
87         {
88                 hEffTrigPt[i] = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Eff_Trig_Pt");
89                 hEffVtxPt[i] = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Eff_Vtx_Pt");
90                 hEffAccTrkPt[i] = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Eff_AccTrk_Pt");
91         }
92         
93         c2->cd(1);
94         DrawPair(hEffTrigPt[0], hEffTrigPt[1], xmin, xmax, 0, 1.1);
95         
96         c2->cd(2);
97         DrawPair(hEffVtxPt[0], hEffVtxPt[1], xmin, xmax, 0, 1.1);
98         
99         c2->cd(3);
100         DrawPair(hEffAccTrkPt[0], hEffAccTrkPt[1], xmin, xmax, 0, 1.1);
101         
102         // Secondaries
103         
104         TCanvas* c3 = new TCanvas(Form("%s.Secondaries",species.Data()), Form("Fraction of secondaries for (Anti)%ss",species.Data()));
105         
106         c3->Divide(2,2);
107         
108         for(Int_t i=0; i<kNpart; ++i)
109         {
110                 TH1D* hFracFdwnPt = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Frac_Fdwn_Pt");
111                 TH1D* hFracMatPt  = (TH1D*)FindObj(finput, tag, kPrefix[i] + species + "_Frac_Mat_Pt");
112                 
113                 TF1* fncFracFdwnPt = (TF1*)FindObj(finput, tag, kPrefix[i] + species + "_Frac_Fdwn_Fit_Pt");
114                 TF1* fncFracMatPt  = (TF1*)FindObj(finput, tag, kPrefix[i] + species + "_Frac_Mat_Fit_Pt");
115                 
116                 c3->cd(2*i+1);
117                 hFracFdwnPt->SetAxisRange(xmin, xmax, "X");
118                 hFracFdwnPt->SetAxisRange(0., 0.6, "Y");
119                 hFracFdwnPt->GetYaxis()->SetTitleOffset(1.4);
120                 
121                 hFracFdwnPt->SetMarkerColor(kBlue);
122                 hFracFdwnPt->SetLineColor(kBlue);
123                 hFracFdwnPt->SetMarkerStyle(kFullCircle);
124                 hFracFdwnPt->DrawCopy("E");
125                 
126                 fncFracFdwnPt->SetLineColor(kRed);
127                 fncFracFdwnPt->SetLineWidth(1);
128                 fncFracFdwnPt->Draw("same");
129                 
130                 c3->cd(2*i+2);
131                 hFracMatPt->SetAxisRange(xmin, xmax, "X");
132                 hFracMatPt->SetAxisRange(0.,0.6, "Y");
133                 hFracMatPt->GetYaxis()->SetTitleOffset(1.4);
134                 
135                 hFracMatPt->SetMarkerColor(kBlue);
136                 hFracMatPt->SetLineColor(kBlue);
137                 hFracMatPt->SetMarkerStyle(kFullCircle);
138                 hFracMatPt->DrawCopy("E");
139                 
140                 fncFracMatPt->SetLineColor(kRed);
141                 fncFracMatPt->SetLineWidth(1);
142                 fncFracMatPt->Draw("same");
143         }
144 }
145
146 void DrawPair(TH1* hX, TH1* hY, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, const char* title, const char* option, Int_t xMarker, Int_t yMarker, Int_t xColor, Int_t yColor)
147 {
148 //
149 // Draw a pair of histograms in the current pad
150 //
151         hX->SetTitle(title);
152         hX->SetAxisRange(xmin, xmax, "X");
153         hX->SetAxisRange(ymin, ymax, "Y");
154         hX->SetMarkerColor(xColor);
155         hX->SetLineColor(xColor);
156         hX->SetMarkerStyle(xMarker);
157         
158         hY->SetMarkerColor(yColor);
159         hY->SetLineColor(yColor);
160         hY->SetMarkerStyle(yMarker);
161         
162         hX->DrawCopy(option);
163         hY->DrawCopy(Form("same%s",option));
164 }