937fe4a4 |
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"); |
937fe4a4 |
50 | |
51 | Int_t ntracks = gAlice->TreeH()->GetEntries(); |
52 | |
53 | // Create histograms |
54 | TH1F *hTOF = new TH1F("TOF","Time-of-flight distribution",100,0,10e-8); |
55 | TH1F *hTOFprim = new TH1F("TOFprim","Time-of-flight distribution of primaries",100,0,10e-8); |
56 | // Start loop on tracks in the hits containers |
57 | for (Int_t track=0; track<ntracks;track++) { |
58 | if(TOF) { |
59 | // ======>Histogram TOF |
60 | for(AliTOFhit* tofHit=(AliTOFhit*)TOF->FirstHit(track); tofHit; tofHit=(AliTOFhit*)TOF->NextHit()) { |
359432da |
61 | tof = tofHit->GetTof(); |
937fe4a4 |
62 | hTOF->Fill(tof); |
359432da |
63 | ipart = tofHit->GetTrack(); |
64 | particle = (TParticle*)gAlice->Particle(ipart); |
937fe4a4 |
65 | if (particle->GetFirstMother() < 0) hTOFprim->Fill(tof); |
66 | } |
67 | } |
68 | } |
69 | |
70 | //Create a canvas, set the view range, show histograms |
71 | TCanvas *c1 = new TCanvas("c1","Alice TOF hits",400,10,600,700); |
72 | c1->Divide(1,2); |
73 | c1->cd(1); |
74 | gPad->SetFillColor(33); |
75 | hTOF->SetFillColor(42); |
76 | hTOF->Draw(); |
77 | // hSectors->Fit("pol1"); |
78 | c1->cd(2); |
79 | gPad->SetFillColor(33); |
80 | hTOFprim->SetFillColor(42); |
81 | hTOFprim->Draw(); |
82 | // hTOFprim->Draw("same"); |
83 | c1->Print("tofanal.ps"); |
b94fa26c |
84 | delete c1; |
85 | c1 = 0; |
937fe4a4 |
86 | } |