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