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");
51 Int_t ntracks = gAlice->TreeH()->GetEntries();
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++) {
59 // ======>Histogram TOF
60 for(AliTOFhit* tofHit=(AliTOFhit*)TOF->FirstHit(track); tofHit; tofHit=(AliTOFhit*)TOF->NextHit()) {
61 tof = tofHit->GetTof();
63 ipart = tofHit->GetTrack();
64 particle = (TParticle*)gAlice->Particle(ipart);
65 if (particle->GetFirstMother() < 0) hTOFprim->Fill(tof);
70 //Create a canvas, set the view range, show histograms
71 TCanvas *c1 = new TCanvas("c1","Alice TOF hits",400,10,600,700);
74 gPad->SetFillColor(33);
75 hTOF->SetFillColor(42);
77 // hSectors->Fit("pol1");
79 gPad->SetFillColor(33);
80 hTOFprim->SetFillColor(42);
82 // hTOFprim->Draw("same");
83 c1->Print("tofanal.ps");