3fe3a833 |
1 | void tofanal (Int_t evNumber=0) |
2 | { |
3 | ///////////////////////////////////////////////////////////////////////// |
4 | // This macro is a small example of a ROOT macro |
5 | // illustrating how to read the output of GALICE |
6 | // and fill some histograms. |
7 | // |
8 | // Root > .L anal.C //this loads the macro in memory |
9 | // Root > anal(); //by default process first event |
10 | // Root > anal(2); //process third event |
11 | //Begin_Html |
12 | /* |
13 | <img src="picts/tofanal.gif"> |
14 | */ |
15 | //End_Html |
16 | ///////////////////////////////////////////////////////////////////////// |
17 | |
18 | |
19 | // Dynamically link some shared libs |
20 | if (gClassTable->GetID("AliRun") < 0) { |
21 | gROOT->LoadMacro("loadlibs.C"); |
22 | loadlibs(); |
23 | } else { |
24 | delete gAlice; |
25 | gAlice = 0; |
26 | } |
27 | |
28 | // Connect the Root Galice file containing Geometry, Kine and Hits |
29 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root"); |
30 | if (!file) file = new TFile("galice.root"); |
31 | |
32 | // Get AliRun object from file or create it if not on file |
33 | if (!gAlice) { |
34 | gAlice = (AliRun*)file->Get("gAlice"); |
35 | if (gAlice) printf("AliRun object found on file\n"); |
36 | if (!gAlice) gAlice = new AliRun("gAlice","TOF test program"); |
37 | } |
38 | |
39 | // Import the Kine and Hits Trees for the event evNumber in the file |
40 | gAlice->GetEvent(evNumber); |
41 | Float_t x,y,z,mass,e; |
42 | Int_t nbytes = 0; |
43 | Int_t j,hit,ipart; |
44 | Int_t nhits; |
45 | Float_t tof; |
46 | TParticle *particle; |
47 | |
48 | // Get pointers to Alice detectors and Hits containers |
49 | AliDetector *TOF = gAlice->GetDetector("TOF"); |
50 | TClonesArray *Particles = gAlice->Particles(); |
51 | |
52 | Int_t ntracks = gAlice->TreeH()->GetEntries(); |
53 | |
54 | // Create histograms |
55 | TH1F *hTOF = new TH1F("TOF","Time-of-flight distribution",100,0,10e-8); |
56 | TH1F *hTOFprim = new TH1F("TOFprim","Time-of-flight distribution of primaries",100,0,10e-8); |
57 | // Start loop on tracks in the hits containers |
58 | for (Int_t track=0; track<ntracks;track++) { |
59 | if(TOF) { |
60 | // ======>Histogram TOF |
61 | for(AliTOFhit* tofHit=(AliTOFhit*)TOF->FirstHit(track); tofHit; tofHit=(AliTOFhit*)TOF->NextHit()) { |
62 | tof = tofHit->fTof; |
63 | hTOF->Fill(tof); |
64 | ipart = tofHit->fTrack; |
65 | particle = (TParticle*)Particles->UncheckedAt(ipart); |
66 | if (particle->GetFirstMother() < 0) hTOFprim->Fill(tof); |
67 | } |
68 | } |
69 | } |
70 | |
71 | //Create a canvas, set the view range, show histograms |
72 | TCanvas *c1 = new TCanvas("c1","Alice TOF hits",400,10,600,700); |
73 | c1->Divide(1,2); |
74 | c1->cd(1); |
75 | gPad->SetFillColor(33); |
76 | gPad->SetLogy(); |
77 | hTOF->SetFillColor(42); |
78 | hTOF->Draw(); |
79 | // hSectors->Fit("pol1"); |
80 | c1->cd(2); |
81 | gPad->SetFillColor(33); |
82 | gPad->SetLogy(); |
83 | hTOFprim->SetFillColor(42); |
84 | hTOFprim->Draw(); |
85 | // hTOFprim->Draw("same"); |
86 | c1->Print("tofanal.ps"); |
87 | } |