1 void anal (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/anal.gif">
16 /////////////////////////////////////////////////////////////////////////
19 // Dynamically link some shared libs
20 if (gClassTable->GetID("AliRun") < 0) {
21 gROOT->LoadMacro("loadlibs.C");
25 // Connect the Root Galice file containing Geometry, Kine and Hits
26 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
27 if (!file) file = new TFile("galice.root");
29 // Get AliRun object from file or create it if not on file
31 gAlice = (AliRun*)file->Get("gAlice");
32 if (gAlice) printf("AliRun object found on file\n");
33 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
36 // Import the Kine and Hits Trees for the event evNumber in the file
37 Int_t nparticles = gAlice->GetEvent(evNumber);
38 if (nparticles <= 0) return;
48 // Get pointers to Alice detectors and Hits containers
49 AliDetector *TPC = gAlice->GetDetector("TPC");
50 AliDetector *TRD = gAlice->GetDetector("TRD");
51 TClonesArray *Particles = gAlice->Particles();
52 if (TPC) TClonesArray *TPChits = TPC->Hits();
53 if (TRD) TClonesArray *TRDhits = TRD->Hits();
55 TTree *TH = gAlice->TreeH();
56 Int_t ntracks = TH->GetEntries();
59 TH1F *hSectors = new TH1F("hSectors","Number of tracks hits per sector",75,1,76);
60 TH1F *hTRD = new TH1F("hTRD","Number of planes crossed per track in TRD",6,1,7);
61 TH1F *hTRDprim = new TH1F("hTRDprim","Number of planes crossed per primary track in TRD",6,1,7);
63 // Start loop on tracks in the hits containers
64 for (Int_t track=0; track<ntracks;track++) {
66 nbytes += TH->GetEvent(track);
67 // ======>Histogram TPC
68 // histogram number of tracks per sector
70 nhits = TPChits->GetEntriesFast();
71 for (hit=0;hit<nhits;hit++) {
72 tpcHit = (AliTPChit*)TPChits->UncheckedAt(hit);
73 sector = tpcHit->fPadRow;
74 hSectors->Fill(sector);
77 // =======>Histogram TRD
78 // histogram number of planes crossed per track
79 // same for primary tracks only
81 nhits = TRDhits->GetEntriesFast();
82 for (hit=0;hit<nhits;hit++) {
83 trdHit = (AliTRDhit*)TRDhits->UncheckedAt(hit);
84 ipart = trdHit->fTrack;
85 particle = (TParticle*)Particles->UncheckedAt(ipart);
86 plane = trdHit->fX;//Plane;
88 if (particle->GetFirstMother() < 0) hTRDprim->Fill(plane);
93 //Create a canvas, set the view range, show histograms
94 TCanvas *c1 = new TCanvas("c1","Alice TPC and ITS hits",400,10,600,700);
97 gPad->SetFillColor(33);
98 hSectors->SetFillColor(42);
99 hSectors->Fit("pol1");
101 gPad->SetFillColor(33);
102 hTRD->SetFillColor(42);
104 hTRDprim->SetFillColor(46);
105 hTRDprim->Draw("same");
106 c1->Print("anal.ps");