]>
Commit | Line | Data |
---|---|---|
bf000c32 | 1 | //____________________________________________________________________ |
a1f80595 | 2 | // |
3 | // $Id$ | |
4 | // | |
5 | // Script that contains a class to draw hits, using the | |
6 | // 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 <TH2D.h> | |
15 | #include <AliFMDHit.h> | |
16 | #include <AliFMDInput.h> | |
17 | #include <iostream> | |
18 | #include <TStyle.h> | |
9aa0bdc4 | 19 | #include <TArrayF.h> |
8f6ee336 | 20 | #include <TParticle.h> |
a1f80595 | 21 | |
22 | class DrawHits : public AliFMDInputHits | |
23 | { | |
24 | private: | |
25 | TH2D* fElossVsPMQ; // Histogram | |
088f8e79 | 26 | Int_t fPdg; |
a1f80595 | 27 | public: |
bf000c32 | 28 | //__________________________________________________________________ |
088f8e79 | 29 | TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max) |
30 | { | |
31 | TArrayF bins(n+1); | |
8f6ee336 | 32 | bins[0] = min; |
33 | if (n <= 20) { | |
34 | for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n; | |
35 | return bins; | |
36 | } | |
088f8e79 | 37 | Float_t dp = n / TMath::Log10(max / min); |
38 | Float_t pmin = TMath::Log10(min); | |
088f8e79 | 39 | for (Int_t i = 1; i < n+1; i++) { |
40 | Float_t p = pmin + i / dp; | |
41 | bins[i] = TMath::Power(10, p); | |
9aa0bdc4 | 42 | } |
088f8e79 | 43 | return bins; |
44 | } | |
bf000c32 | 45 | //__________________________________________________________________ |
088f8e79 | 46 | DrawHits(Int_t m=1000, Double_t emin=1, Double_t emax=1000, |
47 | Int_t n=900, Double_t tmin=1e-2, Double_t tmax=1e3, | |
48 | Int_t pdg=211) | |
49 | : fPdg(pdg) | |
50 | { | |
8f6ee336 | 51 | AddLoad(kKinematics); |
088f8e79 | 52 | TArrayF tkine(MakeLogScale(n, tmin, tmax)); |
53 | TArrayF eloss(MakeLogScale(m, emin, emax)); | |
8f6ee336 | 54 | TString name(Form("elossVsP%s", (fPdg == 0 ? "MQ" : ""))); |
55 | TString title(Form("#Delta E/#Delta x vs. p%s", | |
56 | (fPdg == 0 ? "/(mq^{2})" : ""))); | |
57 | fElossVsPMQ = new TH2D(name.Data(), title.Data(), | |
58 | tkine.fN-1, tkine.fArray, | |
59 | eloss.fN-1, eloss.fArray); | |
088f8e79 | 60 | fElossVsPMQ->SetXTitle(Form("p%s", (fPdg == 0 ? "/(mq^{2})" : " [GeV]"))); |
61 | fElossVsPMQ->SetYTitle("#Delta E/#Delta x [MeV/cm]"); | |
a1f80595 | 62 | } |
bf000c32 | 63 | //__________________________________________________________________ |
8f6ee336 | 64 | Bool_t ProcessHit(AliFMDHit* hit, TParticle* p) |
a1f80595 | 65 | { |
66 | if (!hit) { | |
67 | std::cout << "No hit" << std::endl; | |
68 | return kFALSE; | |
69 | } | |
088f8e79 | 70 | |
8f6ee336 | 71 | if (!p) { |
72 | std::cout << "No track" << std::endl; | |
73 | return kFALSE; | |
74 | } | |
75 | if (!p->IsPrimary()) return kTRUE; | |
088f8e79 | 76 | if (hit->IsStop()) return kTRUE; |
77 | Float_t x = hit->P(); | |
78 | Float_t y = hit->Edep()/hit->Length(); | |
79 | if (fPdg != 0) { | |
80 | if (TMath::Abs(hit->Pdg()) != fPdg) return kTRUE; | |
81 | } | |
82 | else { | |
83 | Float_t q = hit->Q() / 3.; | |
84 | if (hit->M() == 0 || q == 0) return kTRUE; | |
85 | x /= hit->M(); | |
86 | y /= q * q; | |
87 | } | |
88 | fElossVsPMQ->Fill(x, y); | |
a1f80595 | 89 | return kTRUE; |
90 | } | |
bf000c32 | 91 | //__________________________________________________________________ |
a1f80595 | 92 | Bool_t Finish() |
93 | { | |
94 | gStyle->SetPalette(1); | |
9aa0bdc4 | 95 | gStyle->SetOptTitle(0); |
088f8e79 | 96 | gStyle->SetCanvasColor(0); |
97 | gStyle->SetCanvasBorderSize(0); | |
98 | gStyle->SetPadColor(0); | |
99 | gStyle->SetPadBorderSize(0); | |
a1f80595 | 100 | fElossVsPMQ->SetStats(kFALSE); |
8f6ee336 | 101 | fElossVsPMQ->Draw("COLZ box"); |
a1f80595 | 102 | return kTRUE; |
103 | } | |
8f6ee336 | 104 | ClassDef(DrawHits,0); |
a1f80595 | 105 | }; |
106 | ||
107 | //____________________________________________________________________ | |
108 | // | |
109 | // EOF | |
110 | // |