1 void tofanal (Int_t evNumber=0)
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.
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
13 <img src="picts/tofanal.gif">
16 /////////////////////////////////////////////////////////////////////////
19 // Dynamically link some shared libs
20 if (gClassTable->GetID("AliRun") < 0) {
21 gROOT->LoadMacro("loadlibs.C");
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");
32 // Get AliRun object from file or create it if not on file
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");
39 // Import the Kine and Hits Trees for the event evNumber in the file
40 gAlice->GetEvent(evNumber);
48 // Get pointers to Alice detectors and Hits containers
49 AliDetector *TOF = gAlice->GetDetector("TOF");
50 TClonesArray *Particles = gAlice->Particles();
52 Int_t ntracks = gAlice->TreeH()->GetEntries();
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++) {
60 // ======>Histogram TOF
61 for(AliTOFhit* tofHit=(AliTOFhit*)TOF->FirstHit(track); tofHit; tofHit=(AliTOFhit*)TOF->NextHit()) {
64 ipart = tofHit->fTrack;
65 particle = (TParticle*)Particles->UncheckedAt(ipart);
66 if (particle->GetFirstMother() < 0) hTOFprim->Fill(tof);
71 //Create a canvas, set the view range, show histograms
72 TCanvas *c1 = new TCanvas("c1","Alice TOF hits",400,10,600,700);
75 gPad->SetFillColor(33);
76 hTOF->SetFillColor(42);
78 // hSectors->Fit("pol1");
80 gPad->SetFillColor(33);
81 hTOFprim->SetFillColor(42);
83 // hTOFprim->Draw("same");
84 c1->Print("tofanal.ps");