]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ITSdigit.C
Corrections to line for alpha
[u/mrichter/AliRoot.git] / ITS / ITSdigit.C
1 void ITSdigit (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 //   for the ITS digits
7 //   
8 //     Root > .L ITSdigit.C   //this loads the macro in memory
9 //     Root > ITSdigit();     //by default process first event   
10 //     Root > ITSdigit(2);    //process third event
11 //End_Html
12 /////////////////////////////////////////////////////////////////////////
13
14
15 // Dynamically link some shared libs
16    if (gClassTable->GetID("AliRun") < 0) {
17       gSystem->Load("libGeant3Dummy.so");   // a dummy version of Geant3
18       gSystem->Load("PHOS/libPHOSdummy.so");        // the standard Alice classes 
19       gSystem->Load("libgalice.so");        // the standard Alice classes 
20    }
21       
22 // Connect the Root Galice file containing Geometry, Kine and Hits
23    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
24    if (!file) file = new TFile("galice.root");
25
26 // Get AliRun object from file or create it if not on file
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 // Import the Kine and Hits Trees for the event evNumber in the file
34    Int_t nparticles = gAlice->GetEvent(evNumber);
35    if (nparticles <= 0) return;
36    Float_t x,y,z,mass,e;
37    Int_t nbytes = 0;
38    Int_t j,hit,ipart;
39    Int_t nhits;
40    Int_t sector,plane;
41    GParticle *particle;
42    AliITSdigit  *ITSdigit;
43
44 // Get pointers to Alice detectors and Hits containers
45    AliDetector *ITS  = gAlice->GetDetector("ITS");
46    TClonesArray *Particles = gAlice->Particles();
47    if (ITS) TClonesArray *ITSdigits  = ITS->Digits();
48
49    TTree *TD = gAlice->TreeD();
50    Int_t nent    = TD->GetEntries();
51
52    printf("Found %d entries in the tree (must be one per event!)\n",nent);
53    
54    for (Int_t dig=0; dig<nent; dig++) {
55      gAlice->ResetDigits();
56      nbytes += TD->GetEvent(dig);
57      if (ITS) {
58        Int_t ndigits = ITSdigits->GetEntriesFast();
59        printf("Found %d digits\n",ndigits);
60        for (Int_t digit=0;digit<ndigits;digit++) {
61          ITSdigit   = (AliITSdigit*)ITSdigits->UncheckedAt(digit);
62          printf("%d %d %d %d \n",ITSdigit->fEvent,ITSdigit->fLayer,ITSdigit->fDet,ITSdigit->fNoverl);
63        }
64      }        
65    }
66 }