1 //____________________________________________________________________
3 // $Id: DrawHits.C 30718 2009-01-22 16:07:40Z cholm $
5 // Script that contains a class to draw hits, using the
6 // AliFMDInputHits class in the util library.
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.
12 // Use the script `Compile.C' to compile this class using ACLic.
15 #include <AliFMDHit.h>
16 #include <AliFMDInput.h>
20 #include <TParticle.h>
22 #include <TGraphErrors.h>
23 #include <TDatabasePDG.h>
24 #include <TParticlePDG.h>
30 #include <AliTrackReference.h>
31 #include <AliFMDStripIndex.h>
32 #include <AliFMDGeometry.h>
33 #include <AliGenEventHeader.h>
34 #include <AliHeader.h>
38 @brief Draw hit energy loss
41 Root> Compile("DrawHits.C")
47 class DrawTrackRefs : public AliFMDInput
59 //__________________________________________________________________
60 Hists(const char* prefix, const char* where)
61 : fPrefix(prefix), fWhere(where),
62 fAll(0), fPrimary(0), fSecondary(0), fStack(0)
64 fAll = MakeHist(Form("%sAll", prefix),
65 Form("All tracks in %s", where));
66 fPrimary = MakeHist(Form("%sPrimary", prefix),
67 Form("All primaries in %s", where));
68 fSecondary = MakeHist(Form("%sSecondary", prefix),
69 Form("All secondaries in %s", where));
71 //__________________________________________________________________
72 TH2* MakeHist(const char* name, const char* title)
74 TH2D* ret = new TH2D(name, title, 200, -4, 6, 40, 0, 2*TMath::Pi());
75 ret->SetDrawOption("colz");
78 //__________________________________________________________________
79 void Draw(TVirtualPad* pad, Bool_t stack=false, Option_t* option="colz")
83 pad->Divide(1,2, 0, 0);
85 fStack = new THStack(Form("%sDisplay", fPrefix.Data()),
86 Form("2nd over 1st particles in %s",
90 fStack->Add((prim = fPrimary->ProjectionX()));
91 fStack->Add((sec = fSecondary->ProjectionX()));
92 prim->SetFillColor(kGray);
93 sec->SetFillColor(kRed);
94 sec->SetFillStyle(3001);
98 TH1* ratio = new TH1D(*sec);
99 ratio->SetName(Form("%sRatio", fPrefix.Data()));
100 ratio->SetTitle(Form("2nd over 1st particles in %s", fWhere.Data()));
102 ratio->SetFillColor(kRed);
103 ratio->SetFillStyle(3001);
108 pad->Divide(1,3,0,0);
109 TVirtualPad* p1 = pad->cd(1);
114 fPrimary->Draw(option);
117 fSecondary->Draw(option);
130 //__________________________________________________________________
132 : AliFMDInput("galice.root"),
133 fTotal("total", "ALICE"),
134 fFMD1I("fmd1I", "FMD1i"),
135 fFMD2I("fmd2I", "FMD2i"),
136 fFMD2O("fmd2O", "FMD2o"),
137 fFMD3I("fmd3I", "FMD3i"),
138 fFMD3O("fmd3O", "FMD3o")
140 AddLoad(kKinematics);
145 //__________________________________________________________________
146 Bool_t ProcessTrackRef(AliTrackReference* trackRef, TParticle* p)
148 if (trackRef->DetectorId() != AliTrackReference::kFMD) return kTRUE;
150 if (!p->GetPDG() || p->GetPDG()->Charge() == 0) return kTRUE;
152 // Double_t eta = p->Eta();
153 // Double_t phi = p->Phi();
159 AliFMDStripIndex::Unpack(trackRef->UserId(),d,r,s,t);
162 AliFMDGeometry::Instance()->Detector2XYZ(d,r,s,t,x,y,z);
164 AliGenEventHeader* genHeader = fHeader->GenEventHeader();
166 genHeader->PrimaryVertex(v);
169 Double_t eta, phi, theta, rr;
170 AliFMDGeometry::XYZ2REtaPhiTheta(x, y, z, rr, eta, phi, theta);
171 if (phi < 0) phi += 2*TMath::Pi();
172 if (phi > 2 * TMath::Pi()) phi -= 2*TMath::Pi();
176 case 1: hists = &fFMD1I; break;
177 case 2: hists = (r == 'I' || r == 'i') ? &fFMD2I : &fFMD2O; break;
178 case 3: hists = (r == 'I' || r == 'i') ? &fFMD3I : &fFMD3O; break;
180 if (!hists) return kTRUE;
182 hists->fAll->Fill(eta, phi);
184 if (fStack->IsPhysicalPrimary(trackRef->GetTrack()))
185 hists->fPrimary->Fill(eta,phi);
187 hists->fSecondary->Fill(eta, phi);
191 //__________________________________________________________________
192 Bool_t ProcessParticle(Int_t id, TParticle* p)
194 if (!p) return kTRUE;
196 if (!p->GetPDG() || p->GetPDG()->Charge() == 0) return kTRUE;
197 // std::cout << p->GetPDG()->GetName() << std::endl;
199 Double_t eta = p->Eta();
200 Double_t phi = p->Phi();
202 fTotal.fAll->Fill(eta, phi);
204 if (fStack->IsPhysicalPrimary(id)) fTotal.fPrimary->Fill(eta,phi);
205 else fTotal.fSecondary->Fill(eta, phi);
210 //__________________________________________________________________
213 gStyle->SetPalette(1);
214 // gStyle->SetOptTitle(0);
215 gStyle->SetTitleBorderSize(1);
216 gStyle->SetTitleFillColor(0);
217 gStyle->SetCanvasColor(0);
218 gStyle->SetCanvasColor(0);
219 gStyle->SetCanvasBorderSize(0);
220 gStyle->SetPadColor(0);
221 gStyle->SetPadBorderSize(0);
223 TCanvas* c2d = new TCanvas("c2d", "2D plots", 1200, 700);
225 fTotal.Draw(c2d->cd(1)); c2d->cd();
226 fFMD1I.Draw(c2d->cd(6)); c2d->cd();
227 fFMD2I.Draw(c2d->cd(5)); c2d->cd();
228 fFMD2O.Draw(c2d->cd(4)); c2d->cd();
229 fFMD3I.Draw(c2d->cd(2)); c2d->cd();
230 fFMD3O.Draw(c2d->cd(3)); c2d->cd();
235 c2d->SaveAs("kine_etaphi.png");
237 TCanvas* c1d = new TCanvas("c1d", "1D plots", 1200, 700);
239 fTotal.Draw(c1d->cd(1), kTRUE); c1d->cd();
240 fFMD1I.Draw(c1d->cd(6), kTRUE); c1d->cd();
241 fFMD2I.Draw(c1d->cd(5), kTRUE); c1d->cd();
242 fFMD2O.Draw(c1d->cd(4), kTRUE); c1d->cd();
243 fFMD3I.Draw(c1d->cd(2), kTRUE); c1d->cd();
244 fFMD3O.Draw(c1d->cd(3), kTRUE); c1d->cd();
249 c1d->SaveAs("kine_eta.png");
255 ClassDef(DrawTrackRefs,0);
258 //____________________________________________________________________