]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/analITS.C
Corrections to line for alpha
[u/mrichter/AliRoot.git] / ITS / analITS.C
1 void analITS (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="gif/anal.gif">
14 */
15 //End_Html
16 /////////////////////////////////////////////////////////////////////////
17
18
19 // Dynamically link some shared libs
20    if (gClassTable->GetID("AliRun") < 0) {
21       gSystem->Load("libGeant3Dummy.so");   // a dummy version of Geant3
22       gSystem->Load("PHOS/libPHOSdummy.so");        // the standard Alice classes 
23       gSystem->Load("libgalice.so");        // the standard Alice classes 
24    }
25       
26 // Connect the Root Galice file containing Geometry, Kine and Hits
27    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
28    if (!file) file = new TFile("galice.root");
29
30 // Get AliRun object from file or create it if not on file
31    if (!gAlice) {
32       gAlice = (AliRun*)file->Get("gAlice");
33       if (gAlice) printf("AliRun object found on file\n");
34       if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
35    }
36       
37 // Import the Kine and Hits Trees for the event evNumber in the file
38    Int_t nparticles = gAlice->GetEvent(evNumber);
39    if (nparticles <= 0) return;
40    Float_t x,y,z,mass,e,r;
41    Int_t nbytes = 0;
42    Int_t j,hit,ipart;
43    Int_t nhits;
44    Int_t sector,plane;
45    GParticle *particle;
46    AliTPChit  *tpcHit;
47    AliITShit  *itsHit;
48
49 // Get pointers to Alice detectors and Hits containers
50    AliDetector *TPC  = gAlice->GetDetector("TPC");
51    AliDetector *ITS  = gAlice->GetDetector("ITS");
52    TClonesArray *Particles = gAlice->Particles();
53    if (TPC) TClonesArray *TPChits   = TPC->Hits();
54    if (ITS) TClonesArray *ITShits   = ITS->Hits();
55
56    TTree *TH = gAlice->TreeH();
57    Int_t ntracks    = TH->GetEntries();
58
59    // Create histograms
60    TH1F *hITSZ    = new TH1F("hITSZ","Z of hits in ITS",100,-50.,50.);
61    TH1F *hITSR    = new TH1F("hITSR","R of hits in ITS",100,0.,50.);
62    TH1F *hITSDnum = new TH1F("hITSDnum","JLAY of hits in ITS",20, 0., 20.);
63    TH1F *hITSTr   = new TH1F("hITSTr","Track number for hits in ITS",100,0.,50000.);
64
65 // Start loop on tracks in the hits containers
66    for (Int_t track=0; track<ntracks;track++) {
67      gAlice->ResetHits();
68      nbytes += TH->GetEvent(track);
69      Int_t i=0;
70      if (ITS) {
71        nhits = ITShits->GetEntriesFast();
72        for (hit=0;hit<nhits;hit++) {
73          itsHit   = (AliITShit*)ITShits->UncheckedAt(hit);
74          ipart    = itsHit->fTrack;
75          particle = (GParticle*)Particles->UncheckedAt(ipart);
76          z = itsHit->fZ;
77          hITSZ->Fill(z);
78          r = sqrt(itsHit->fX*itsHit->fX + itsHit->fY*itsHit->fY);
79          hITSR->Fill(r);
80          hITSDnum->Fill(itsHit->fDnum);
81          hITSTr->Fill(itsHit->fTrack);
82          i++;
83        }
84      }        
85    }
86
87 //Create a canvas, set the view range, show histograms
88    TCanvas *c1 = new TCanvas("c1","Alice TPC and ITS hits",400,10,600,700);
89    c1->Divide(2,2);
90    c1->cd(1);
91    gPad->SetFillColor(33);
92    hITSZ->SetFillColor(33);
93    hITSZ->Draw();
94    c1->cd(2);
95    gPad->SetFillColor(33);
96    hITSR->SetFillColor(46);
97    hITSR->Draw();
98    c1->cd(3);
99    gPad->SetFillColor(33);
100    hITSDnum->SetFillColor(46);
101    hITSDnum->Draw();
102    c1->cd(4);
103    gPad->SetFillColor(33);
104    hITSTr->SetFillColor(46);
105    hITSTr->Draw();
106    c1->Print("analITS.ps");
107 }