]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ITSreadRecPointsTest.C
Fixed bug with GetCovMatrix returning a pointer to a deleted local array.
[u/mrichter/AliRoot.git] / ITS / ITSreadRecPointsTest.C
1 #include "iostream.h"
2
3 void ITSreadRecPointsTest (Int_t evNumber1=0,Int_t evNumber2=0) 
4 {
5 /////////////////////////////////////////////////////////////////////////
6 //   This macro is a small example of a ROOT macro
7 //   illustrating how to read the output of GALICE
8 //   and do some analysis.
9 //   
10 /////////////////////////////////////////////////////////////////////////
11
12 // Dynamically link some shared libs
13
14    if (gClassTable->GetID("AliRun") < 0) {
15       gROOT->LoadMacro("loadlibs.C");
16       loadlibs();
17    }
18
19 // Connect the Root Galice file containing Geometry, Kine and Hits
20
21    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
22    if (!file) file = new TFile("galice.root");
23    file->ls();
24
25 // Get AliRun object from file or create it if not on file
26
27    if (!gAlice) {
28       gAlice = (AliRun*)file->Get("gAlice");
29       if (gAlice) printf("AliRun object found on file\n");
30       if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
31    }
32  
33 //
34 //   Loop over events 
35 //
36    Int_t Nh=0;
37    Int_t Nh1=0;
38    for (int nev=0; nev<= evNumber2; nev++) {
39      Int_t nparticles = gAlice->GetEvent(nev);
40      cout << "nev         " << nev <<endl;
41      cout << "nparticles  " << nparticles <<endl;
42      if (nev < evNumber1) continue;
43      if (nparticles <= 0) return;
44
45      TTree *TH = gAlice->TreeH();
46      Int_t ntracks = TH->GetEntries();
47      cout<<"ntracks "<<ntracks<<endl;
48
49      Int_t nbytes = 0;
50
51      AliITSRecPoint  *recp;
52
53      // Get pointers to Alice detectors and Digits containers
54      AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
55      if (!ITS) return;
56      TClonesArray *Particles = gAlice->Particles();
57      TTree *TR = gAlice->TreeR();
58      Int_t nent=TR->GetEntries();
59      printf("Found %d entries in the tree (must be one per module per event!)\n",nent);
60
61      TClonesArray *ITSrec  = ITS->RecPoints();
62      for (Int_t mod=0; mod<nent; mod++) {
63        ITS->ResetRecPoints();
64        TR->GetEvent(mod+1);
65        Int_t nrecp = ITSrec->GetEntries();
66        if (nrecp) printf("Found %d rec points for module %d \n",nrecp,mod);
67        if (!nrecp) continue;
68
69        for (Int_t irec=0;irec<nrecp;irec++) {
70                 recp   = (AliITSRecPoint*)ITSrec->UncheckedAt(irec);
71                 printf("%d %f %f %d %d %d\n",irec,recp->GetX(),recp->GetZ(),recp->fTracks[0],recp->fTracks[1],recp->fTracks[2]);
72
73        }
74      }        
75    }   // event loop 
76    
77      cout<<"END  test for rec points "<<endl;
78
79      file->Close();   
80 }
81
82
83