]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/scripts/DrawHits.C
Fixed some coding style violations.
[u/mrichter/AliRoot.git] / FMD / scripts / DrawHits.C
CommitLineData
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>
a1f80595 19
20class DrawHits : public AliFMDInputHits
21{
22private:
23 TH2D* fElossVsPMQ; // Histogram
088f8e79 24 Int_t fPdg;
a1f80595 25public:
088f8e79 26 TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max)
27 {
28 TArrayF bins(n+1);
29 Float_t dp = n / TMath::Log10(max / min);
30 Float_t pmin = TMath::Log10(min);
31 bins[0] = min;
32 for (Int_t i = 1; i < n+1; i++) {
33 Float_t p = pmin + i / dp;
34 bins[i] = TMath::Power(10, p);
9aa0bdc4 35 }
088f8e79 36 return bins;
37 }
38 DrawHits(Int_t m=1000, Double_t emin=1, Double_t emax=1000,
39 Int_t n=900, Double_t tmin=1e-2, Double_t tmax=1e3,
40 Int_t pdg=211)
41 : fPdg(pdg)
42 {
43 TArrayF tkine(MakeLogScale(n, tmin, tmax));
44 TArrayF eloss(MakeLogScale(m, emin, emax));
45 fElossVsPMQ = new TH2D("bad", "#Delta E/#Delta x vs. p/(mq^{2})",
9aa0bdc4 46 tkine.fN-1, tkine.fArray, eloss.fN-1, eloss.fArray);
088f8e79 47 fElossVsPMQ->SetXTitle(Form("p%s", (fPdg == 0 ? "/(mq^{2})" : " [GeV]")));
48 fElossVsPMQ->SetYTitle("#Delta E/#Delta x [MeV/cm]");
a1f80595 49 }
50 Bool_t ProcessHit(AliFMDHit* hit, TParticle*)
51 {
52 if (!hit) {
53 std::cout << "No hit" << std::endl;
54 return kFALSE;
55 }
088f8e79 56
57 if (hit->IsStop()) return kTRUE;
58 Float_t x = hit->P();
59 Float_t y = hit->Edep()/hit->Length();
60 if (fPdg != 0) {
61 if (TMath::Abs(hit->Pdg()) != fPdg) return kTRUE;
62 }
63 else {
64 Float_t q = hit->Q() / 3.;
65 if (hit->M() == 0 || q == 0) return kTRUE;
66 x /= hit->M();
67 y /= q * q;
68 }
69 fElossVsPMQ->Fill(x, y);
a1f80595 70 return kTRUE;
71 }
72 Bool_t Finish()
73 {
74 gStyle->SetPalette(1);
9aa0bdc4 75 gStyle->SetOptTitle(0);
088f8e79 76 gStyle->SetCanvasColor(0);
77 gStyle->SetCanvasBorderSize(0);
78 gStyle->SetPadColor(0);
79 gStyle->SetPadBorderSize(0);
a1f80595 80 fElossVsPMQ->SetStats(kFALSE);
81 fElossVsPMQ->Draw("COLZ");
82 return kTRUE;
83 }
84};
85
86//____________________________________________________________________
87//
88// EOF
89//