silvermy@ornl.gov : reverting to version 1.2
[u/mrichter/AliRoot.git] / FMD / scripts / DrawESD.C
CommitLineData
2b893216 1//____________________________________________________________________
2//
3// $Id$
4//
5// Script that contains a class to draw eloss from hits, versus ADC
6// counts from digits, using the AliFMDInputHits class in the util library.
7//
8// It draws the energy loss versus the p/(mq^2). It can be overlayed
9// with the Bethe-Bloc curve to show how the simulation behaves
10// relative to the expected.
11//
12// Use the script `Compile.C' to compile this class using ACLic.
13//
14#include <TH1D.h>
15#include <AliFMDHit.h>
16#include <AliFMDDigit.h>
17#include <AliFMDInput.h>
18#include <AliFMDUShortMap.h>
19#include <AliFMDFloatMap.h>
20#include <AliFMDRecPoint.h>
21#include <AliESDFMD.h>
22#include <AliLog.h>
23#include <iostream>
24#include <TStyle.h>
25#include <TArrayF.h>
26#include <TCanvas.h>
27#include <TMath.h>
28#include <TF1.h>
29#include <TSpectrum.h>
30#include <TLegend.h>
31#include <TLine.h>
32
33/** @class DrawESD
34 @brief Draw digit ADC versus Rec point mult
35 @code
36 Root> .L Compile.C
37 Root> Compile("DrawESD.C")
38 Root> DrawESD c
39 Root> c.Run();
40 @endcode
41 @ingroup FMD_script
42 */
43class DrawESD : public AliFMDInput
44{
45private:
46 TH1D* fMult; // Histogram
47 const Double_t fCorr;
48public:
49 //__________________________________________________________________
2b893216 50 DrawESD(Int_t n=420, Double_t mmin=-0.5, Double_t mmax=20.5)
51 : fCorr(1) // 0.68377 / 1.1)
52 {
53 AddLoad(kESD);
54 fMult = new TH1D("mult", " Multiplicity (strip)", n, mmin, mmax);
69893a66 55 fMult->Sumw2();
2b893216 56 fMult->SetXTitle("Strip Multiplicity");
57 }
58 //__________________________________________________________________
59 /** Begining of event
60 @param ev Event number
61 @return @c false on error */
62 Bool_t Begin(Int_t ev)
63 {
64 return AliFMDInput::Begin(ev);
65 }
66 //__________________________________________________________________
67 Bool_t ProcessESD(UShort_t /* det */,
68 Char_t /* ring */,
69 UShort_t /* sec */,
70 UShort_t /* strip */,
71 Float_t /* eta */,
72 Float_t mult)
73 {
74 // Cache the energy loss
75 fMult->Fill(mult/fCorr);
76 return kTRUE;
77 }
78 //__________________________________________________________________
79 Bool_t Finish()
80 {
81 gStyle->SetPalette(1);
82 gStyle->SetOptTitle(0);
83 gStyle->SetOptFit(1111111);
84 gStyle->SetCanvasColor(0);
85 gStyle->SetCanvasBorderSize(0);
86 gStyle->SetPadColor(0);
87 gStyle->SetPadBorderSize(0);
88
89 TCanvas* c = new TCanvas("c", "C");
90 c->cd();
91 c->SetLogy();
92 // fMult->GetXaxis()->SetRangeUser(0.2,4);
93 // fMult->Sumw2();
94 // fMult->Scale(1. / fMult->GetMaximum());
69893a66 95 fMult->Scale(1. / fMult->GetEntries());
2b893216 96 fMult->SetStats(kFALSE);
97 fMult->SetFillColor(2);
98 fMult->SetFillStyle(3001);
99 fMult->Draw();
100 Double_t x1 = .75; // .8; // .65 / fCorr;
101 Double_t x2 = 1.3; // 1.7; // fCorr;
102 Double_t x3 = 2.5; // 2.7; // fCorr;
103 Double_t x4 = 3.7; // fCorr;
104 TF1* l1 = new TF1("landau1", "landau", x1, x2);
105 TF1* l2 = new TF1("landau2", "landau", x2, x3);
106 // TF1* l3 = new TF1("landau3", "landau", x3, x4);
107 TF1* f = new TF1("user", "landau(0)+landau(3)", x1, x3);
108
109 fMult->SetStats(kTRUE);
110 fMult->GetXaxis()->SetRangeUser(0, 4);
111 fMult->Fit(l1, "E0L", "", x1, x2);
112 fMult->Fit(l2, "E0L", "", x2, x3);
113 // fMult->Fit(l3, "E0L", "", x3, x4);
114 f->SetParNames("A_{1}", "Mpv_{1}", "#sigma_{1}",
115 "A_{2}", "Mpv_{2}", "#sigma_{2}",
116 "A_{3}", "Mpv_{3}", "#sigma_{3}");
117 f->SetParameters(l1->GetParameter(0),
118 l1->GetParameter(1),
119 l1->GetParameter(2),
120 l2->GetParameter(0),
121 l2->GetParameter(1),
122 l2->GetParameter(2),
123 l1->GetParameter(0),
124 l1->GetParameter(1) * 3,
125 l1->GetParameter(2) * 3);
126 fMult->Fit(f, "E0L", "", x1, x3);
127 fMult->Fit(f, "MEL", "E1", x1, x3);
128
129 TH1* h = static_cast<TH1*>(fMult->DrawClone("same hist"));
130
131 // l1->SetLineStyle(2);
132 l1->SetLineColor(3);
133 l1->SetLineWidth(2);
134 l1->SetRange(0, 4);
135 l1->Draw("same");
136 // l2->SetLineStyle(3);
137 l2->SetLineColor(4);
138 l2->SetLineWidth(2);
139 l2->SetRange(0, 4);
140 l2->Draw("same");
141 // l3->SetLineStyle(3);
142 // l3->SetLineWidth(2);
143 // l3->SetRange(0, 5);
144 // l3->Draw("same");
145 f->SetLineWidth(2);
146 f->SetRange(0, 4);
147 f->Draw("same");
148
149 TLegend* l = new TLegend(0.2, 0.6, .6, .89);
150 l->AddEntry(l1, "1 particle Landau", "l");
151 l->AddEntry(l2, "2 particle Landau", "l");
152 l->AddEntry(f, "1+2 particle Landau", "l");
153 l->SetFillColor(0);
154 l->Draw("same");
155
156
157 c = new TCanvas("c2", "Landaus");
158 c->SetLogy();
159 fMult->DrawClone("axis");
160 f->Draw("same");
161 TF1* ll1 = new TF1("ll1", "landau", 0, 4);
162 ll1->SetParameters(f->GetParameter(0),
163 f->GetParameter(1),
164 f->GetParameter(2));
165 ll1->SetLineColor(3);
166 ll1->Draw("same");
167 TF1* ll2 = new TF1("ll2", "landau", 0, 4);
168 ll2->SetParameters(f->GetParameter(3),
169 f->GetParameter(4),
170 f->GetParameter(5));
171 ll2->SetLineColor(4);
172 ll2->Draw("same");
173
174 Double_t y1 = fMult->GetMinimum() * 1.1;
175 Double_t y2 = fMult->GetMaximum() * .9;
176 Double_t xc1 = f->GetParameter(1)-3*f->GetParameter(2);
177 Double_t xc2 = f->GetParameter(4)-2*f->GetParameter(5);
178 TLine* c1 = new TLine(xc1, y1, xc1, y2);
179 c1->Draw("same");
180 TLine* c2 = new TLine(xc2, y1, xc2, y2);
181 c2->Draw("same");
182
183 l = new TLegend(0.2, 0.6, .6, .89);
184 l->AddEntry(ll1, "1 particle Landau", "l");
185 l->AddEntry(ll2, "2 particle Landau", "l");
186 l->AddEntry(f, "1+2 particle Landau", "l");
187 l->SetFillColor(0);
188 l->Draw("same");
189
190#if 0
191 c = new TCanvas("s", "Spectrum");
192 TSpectrum* s = new TSpectrum(16);
193 h->GetXaxis()->SetRangeUser(0.3, 20);
194 s->Search(h, .15, "", 0.01);
195 c->Update();
196 TH1* b = s->Background(h);
197 b->SetFillColor(4);
198 b->SetFillStyle(3001);
199 b->Draw("same");
200#endif
201
202 return kTRUE;
203 }
204
205 ClassDef(DrawESD,0);
206
207};
208
209//____________________________________________________________________
210//
211// EOF
212//