Avoid warning.
[u/mrichter/AliRoot.git] / RICH / RICHoccupancy.C
CommitLineData
8e766c6d 1void RICHoccupancy (Int_t evNumber1=0,Int_t evNumber2=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 do some analysis.
7//
8/////////////////////////////////////////////////////////////////////////
9
10
11 // Dynamically link some shared libs
29fa09ab 12
13 if (gClassTable->GetID("AliRun") < 0) {
14 gROOT->LoadMacro("loadlibs.C");
15 loadlibs();
16 }
17 else {
18 //delete gAlice;
19 gAlice = 0;
20 }
21
22 gAlice=0;
23
24 // Connect the Root Galice file containing Geometry, Kine and Hits
25
26 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
27 if (!file) file = new TFile("galice.root","UPDATE");
28
29 // Get AliRun object from file or create it if not on file
30
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 else {
37 delete gAlice;
38 gAlice = (AliRun*)file->Get("gAlice");
39 if (gAlice) printf("AliRun object found on file\n");
40 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
41 }
42
8e766c6d 43
44// Start loop over events
45
46 Float_t occ[7];
47 Float_t sum=0;
48 Float_t mean=0;
49
50 for (int nev=0; nev<= evNumber2; nev++) {
51 Int_t nparticles = gAlice->GetEvent(nev);
52
53
54 printf ("Number of Events : %d\n",nev);
55 printf ("Number of particles: %d\n\n",nparticles);
56 //if (nev < evNumber1) continue;
57 //if (nparticles <= 0) return;
58
59 // Get pointers to RICH detector and Hits containers
60
61 AliRICH *RICH =(AliRICH*) gAlice->GetModule("RICH");
62 Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
64a632a2 63 gAlice->TreeD()->GetEvent(0);
8e766c6d 64
65 for (Int_t ich=0;ich<7;ich++)
66 {
67 TClonesArray *Digits = RICH->DigitsAddress(ich); // Raw clusters branch
68 //printf ("Digits:%p",Digits);
69 Int_t ndigits = Digits->GetEntriesFast();
64a632a2 70 occ[ich] = Float_t(ndigits)/(160*144);
71 sum += Float_t(ndigits)/(160*144);
8e766c6d 72 printf ("Occupancy in chamber %d: %f, generated by %d digits\n",ich,occ[ich],ndigits);
73 }
74 mean = sum/7;
75 printf("\nMean occupancy: %f\n",mean);
76 }
77}
78