]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/scripts/DrawCorrCentralSecMap2.C
Some script changes and additions
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / DrawCorrCentralSecMap2.C
1 /**
2  * @file 
3  * 
4  * Scripts to draw energy loss fits from correction object file 
5  *
6  * @ingroup pwg2_forward_analysis_scripts
7  */
8 /** 
9  * Clear canvas 
10  * 
11  * @param c Canvas to clear 
12  *
13  * @ingroup pwg2_forward_analysis_scripts
14  */
15 void
16 ClearCanvas(TCanvas* c)
17 {
18   c->SetLeftMargin(.1);
19   c->SetRightMargin(.05);
20   c->SetBottomMargin(.1);
21   c->SetTopMargin(.05);
22   c->Clear();
23 }
24
25 /** 
26  * Draw energy loss fits to a multi-page PDF. 
27  *
28  * @par Input: 
29  * The input file is expected to contain a AliFMDCorrELossFit object
30  * named @i elossfits in the top level directory.
31  * 
32  * @para Output: 
33  * A multi-page PDF.  Note, that the PDF generated by ROOT in this way
34  * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
35  * and one should pass it through a filter to correct these problems.
36  * 
37  * @param fname   File name 
38  * @param option  Drawing options 
39  *
40  * @ingroup pwg2_forward_analysis_scripts
41  */
42 void
43 DrawCorrCentralSecMap2(const char* fname, const char* option="colz")
44 {
45   //__________________________________________________________________
46   // Load libraries and object 
47   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
48
49   TFile* file = TFile::Open(fname, "READ");
50   if (!file) { 
51     Error("DrawCorrSecMap", "Failed to open %s", fname);
52     return;
53   }
54   TString pname(fname);
55   pname.ReplaceAll(".root", ".png");
56   pname = gSystem->BaseName(pname);
57
58   AliCentralMultiplicityTask::Manager* mgr = 
59     new AliCentralMultiplicityTask::Manager;
60   const char* objName = mgr->GetObjectName(0);
61   AliCentralCorrSecondaryMap* corr = 
62     static_cast<AliCentralCorrSecondaryMap*>(file->Get(objName));
63   if (!corr) { 
64     Error("DrawCorrCentralSecMap", "Object '%s' not found in %s", 
65           objName, fname);
66     return;
67   }
68
69   //__________________________________________________________________
70   // Create a canvas
71   Int_t w = 1200;
72   TCanvas* c = new TCanvas("c", "c", w, w / TMath::Sqrt(2));
73   c->SetFillColor(0);
74   c->SetBorderSize(0);
75   c->SetBorderMode(0);
76   // c->Print(Form("%s[", pname.Data()));
77   
78   gStyle->SetOptStat(0);
79   gStyle->SetTitleColor(0);
80   gStyle->SetTitleStyle(0);
81   gStyle->SetTitleBorderSize(0);
82   gStyle->SetTitleX(.1);
83   gStyle->SetTitleY(1);
84   gStyle->SetTitleW(.8);
85   gStyle->SetTitleH(.09);
86   gStyle->SetFrameFillColor(kWhite);
87   gStyle->SetFrameBorderSize(1);
88   gStyle->SetFrameBorderMode(1);
89   gStyle->SetPalette(1);
90
91   ClearCanvas(c);
92   //__________________________________________________________________
93   // Draw all corrections
94   const TAxis& vtxAxis = corr->GetVertexAxis();
95   Int_t        nVtx    = vtxAxis.GetNbins();
96   c->Divide((nVtx+2)/3, 3, 0, 0);
97   Int_t ipad = 0;
98   for (UShort_t v=1; v <= nVtx; v++) { 
99     ipad++;
100     if (ipad == 1) {
101       c->cd(ipad);
102       TLatex* l = new TLatex(.5, .5, 
103                              "#frac{#sum N_{ch,SPD0}}{#sum N_{ch,primary}}");
104       l->SetNDC();
105       l->SetTextAlign(22);
106       l->SetTextSize(.1);
107       l->Draw();
108       ipad++;
109     }
110     if (ipad == 12) ipad++;
111     
112     TVirtualPad* p = c->cd(ipad);
113     p->SetFillColor(kWhite);
114     p->SetGridx();
115     p->SetGridy();
116
117     TH2*   h1 = corr->GetCorrection(v);
118     TH1D*  pr = h1->ProjectionX(Form("vtxbin%02d", v), -1, -1, "e");
119     pr->SetDirectory(0);
120     pr->SetTitle(Form("%+5.1f<v_{z}<%+5.1f", 
121                       vtxAxis.GetBinLowEdge(v),
122                       vtxAxis.GetBinUpEdge(v)));
123     pr->Scale(1. / h1->GetNbinsY());
124     pr->SetMarkerColor(kRed+1);
125     pr->SetFillColor(kRed+1);
126     pr->SetFillStyle(3001);
127     pr->SetMaximum(1.65);
128     pr->GetXaxis()->SetRangeUser(-3.1,3.1);
129     pr->Draw("hist"); 
130     pr->Draw("same");
131    
132   }
133   
134   //__________________________________________________________________
135   // Close output file 
136   c->SaveAs(pname.Data());
137   
138 }
139 //
140 // EOF
141 //