]>
Commit | Line | Data |
---|---|---|
e8189707 | 1 | #include "iostream.h" |
2 | ||
3 | void ITSreadTest (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 | AliITSRawClusterSDD *ITSclust; | |
52 | AliITSRecPoint *ITSrecp; | |
53 | ||
54 | // Get pointers to Alice detectors and Digits containers | |
55 | AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); | |
56 | if(!ITS) return; | |
57 | TClonesArray *Particles = gAlice->Particles(); | |
58 | ||
59 | // fill modules with sorted by module hits | |
60 | Int_t nmodules; | |
61 | ITS->InitModules(-1,nmodules); | |
62 | ITS->FillModules(nev,-1,nmodules," "," "); | |
63 | //get pointer to modules array | |
64 | TObjArray *ITSmodules = ITS->GetModules(); | |
65 | AliITShit *itsHit; | |
66 | ||
67 | TTree *TR=gAlice->TreeR(); | |
68 | Int_t nentr=TR->GetEntries(); | |
69 | printf("Found %d entries in the TreeR (must be one per module per event!)\n",nentr); | |
70 | TClonesArray *ITSrecpoints = ITS->RecPoints(); | |
71 | ||
72 | // get the Tree for clusters | |
73 | ITS->GetTreeC(nev); | |
74 | TTree *TC=ITS->TreeC(); | |
75 | Int_t nent=TC->GetEntries(); | |
76 | printf("Found %d entries in the tree (must be one per module per event!)\n",nent); | |
77 | ||
78 | for (Int_t idettype=0;idettype<3;idettype++) { | |
79 | ||
80 | TClonesArray *ITSclusters = ITS->ClustersAddress(idettype); | |
81 | //printf ("ITSclusters %p \n",ITSclusters); | |
82 | ||
83 | if (idettype != 1) continue; | |
84 | for (Int_t mod=0; mod<nent; mod++) { | |
85 | AliITSmodule *itsModule = (AliITSmodule*)ITSmodules->At(mod); | |
86 | Int_t nhits = itsModule->GetNhits(); | |
87 | printf("module nhits %d %d\n",mod,nhits); | |
88 | for (Int_t ihit=0;ihit<nhits;ihit++) { | |
89 | itsHit=(AliITShit*)itsModule->GetHit(ihit); | |
90 | printf("ihit x y z %d %f %f %f\n",ihit,itsHit->GetXG(),itsHit->GetYG(),itsHit->GetZG()); | |
91 | } | |
92 | ||
93 | ||
94 | ITS->ResetClusters(); | |
95 | TC->GetEvent(mod); | |
96 | Int_t nclust = ITSclusters->GetEntries(); | |
97 | if (nclust) printf("Found %d clust for module %d in det type %d \n",nclust,mod,idettype); | |
98 | if (!nclust) continue; | |
99 | ||
100 | ITS->ResetRecPoints(); | |
de7cc3b7 | 101 | TR->GetEvent(mod); |
e8189707 | 102 | Int_t nrecp = ITSrecpoints->GetEntries(); |
103 | if (nrecp) printf("Found %d recp for module %d \n",nrecp,mod); | |
104 | ||
105 | for (Int_t clust=0;clust<nclust;clust++) { | |
106 | ITSrecp = (AliITSRecPoint*)ITSrecpoints->UncheckedAt(clust); | |
107 | printf("recp %d %f %f %f\n",clust,ITSrecp->GetX(),ITSrecp->GetZ(),ITSrecp->GetQ()); | |
108 | ITSclust = (AliITSRawClusterSDD*)ITSclusters->UncheckedAt(clust); | |
109 | printf("clust %d %f %f %f\n",clust,ITSclust->X(),ITSclust->Z(),ITSclust->Q()); | |
110 | } | |
111 | } | |
112 | } | |
113 | ||
114 | ITS->ClearModules(); | |
115 | ||
116 | } // event loop | |
117 | ||
118 | cout<<"END test for clusters and hits "<<endl; | |
119 | ||
120 | file->Close(); | |
121 | } | |
122 | ||
123 | ||
124 |