]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/corrs/DrawCorrSecMap2.C
Added 2012 geom
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / corrs / DrawCorrSecMap2.C
1 /**
2  * @file 
3  * 
4  * Scripts to draw energy loss fits from correction object file 
5  *
6  * @ingroup pwg2_forward_scripts_corr
7  */
8 /** 
9  * Clear canvas 
10  * 
11  * @param c Canvas to clear 
12  *
13  * @ingroup pwg2_forward_scripts_corr
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 @c elossfits in the top level directory.
31  * 
32  * @par 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_scripts_corr
41  */
42 void
43 DrawCorrSecMap2(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   const char* objName = 
59     AliForwardCorrectionManager::Instance()
60     .GetObjectName(AliForwardCorrectionManager::kSecondaryMap);
61   AliFMDCorrSecondaryMap* corr = 
62     static_cast<AliFMDCorrSecondaryMap*>(file->Get(objName));
63   if (!corr) { 
64     Error("DrawCorrSecMap", "Object '%s' not found in %s", objName, fname);
65     return;
66   }
67
68   //__________________________________________________________________
69   // Create a canvas
70   TCanvas* c = new TCanvas("c", "c", 800, 800 / TMath::Sqrt(2));
71   c->SetFillColor(0);
72   c->SetBorderSize(0);
73   c->SetBorderMode(0);
74   // c->Print(Form("%s[", pname.Data()));
75   
76   gStyle->SetOptStat(0);
77   gStyle->SetTitleColor(0);
78   gStyle->SetTitleStyle(0);
79   gStyle->SetTitleBorderSize(0);
80   gStyle->SetTitleX(.1);
81   gStyle->SetTitleY(1);
82   gStyle->SetTitleW(.8);
83   gStyle->SetTitleH(.09);
84   gStyle->SetFrameFillColor(kWhite);
85   gStyle->SetFrameBorderSize(1);
86   gStyle->SetFrameBorderMode(1);
87   gStyle->SetPalette(1);
88
89   ClearCanvas(c);
90   //__________________________________________________________________
91   // Draw all corrections
92   const TAxis& vtxAxis = corr->GetVertexAxis();
93   Int_t        nVtx    = vtxAxis.GetNbins();
94   c->Divide((nVtx+2)/3, 3, 0, 0);
95   Int_t ipad = 0;
96   for (UShort_t v=1; v <= nVtx; v++) { 
97     ipad++;
98     if (ipad == 1 || ipad == 12) ipad++;
99     
100     TVirtualPad* p = c->cd(ipad);
101     p->SetFillColor(kWhite);
102     THStack* stack = new THStack(Form("vtxBin%02d", v), 
103                                  Form("%-4.1f<v_{z}<%4.1f", 
104                                       vtxAxis.GetBinLowEdge(v), 
105                                       vtxAxis.GetBinUpEdge(v))); 
106
107     for (UShort_t d = 1; d <= 3; d++) {
108       UShort_t     nQ = (d == 1 ? 1 : 2);
109       for (UShort_t q = 0; q < nQ; q++) { 
110         Char_t r = (q == 0 ? 'I' : 'O');
111         
112         TH2*   h1 = corr->GetCorrection(d, r, v);
113         if (!h1) { 
114           Warning("DrawCorrSecMap", "No correction for r=%c, v=%d", r, v);
115           continue;
116         }
117
118         // Info("DrawCorrSecMap2", "Getting FMD%d%c vtxbin %d", d, r, v);
119         TH1D*  pr = h1->ProjectionX(Form("FMD%d%c", d, r), -1, -1, "e");
120         pr->SetDirectory(0);
121         pr->SetTitle(Form("FMD%d%c", d, r));
122         pr->Scale(1. / (q == 0 ? 20 : 40));
123         pr->SetMarkerColor(AliForwardUtil::RingColor(d, r));
124         
125         stack->Add(pr);
126       }
127     }
128     stack->SetMaximum(3.2);
129     stack->Draw("nostack");
130   }
131   
132   //__________________________________________________________________
133   // Close output file 
134   c->SaveAs(pname.Data());
135   
136 }
137 //
138 // EOF
139 //