]>
Commit | Line | Data |
---|---|---|
ddae0931 | 1 | void RICHpadtest (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 | Int_t NpadX = 252; // number of pads on X | |
12 | Int_t NpadY = 374; // number of pads on Y | |
13 | ||
14 | Int_t Pad[252][374]; | |
15 | for (Int_t i=0;i<NpadX;i++) { | |
16 | for (Int_t j=0;j<NpadY;j++) { | |
17 | Pad[i][j]=0; | |
18 | } | |
19 | } | |
20 | ||
21 | ||
22 | ||
23 | // Dynamically link some shared libs | |
24 | ||
25 | if (gClassTable->GetID("AliRun") < 0) { | |
26 | gROOT->LoadMacro("loadlibs.C"); | |
27 | loadlibs(); | |
28 | } | |
29 | ||
30 | // Connect the Root Galice file containing Geometry, Kine and Hits | |
31 | ||
32 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root"); | |
33 | if (!file) file = new TFile("galice.root"); | |
34 | ||
35 | // Get AliRun object from file or create it if not on file | |
36 | ||
37 | if (!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 | ||
43 | // Create some histograms | |
44 | ||
45 | Int_t xmin=-NpadX/2; | |
46 | Int_t xmax= NpadX/2; | |
47 | Int_t ymin=-NpadY/2; | |
48 | Int_t ymax= NpadY/2; | |
49 | ||
50 | TH2F *hc = new TH2F("hc","Chamber1 signal distribution",NpadX,xmin,xmax,NpadY,ymin,ymax); | |
51 | TH2F *h = new TH2F("h","Chamber1 hit distribution",100,-100,100,100,-100,100); | |
52 | TH1F *charge = new TH1F("charge","Charge distribution",100,0.,1000.); | |
53 | ||
54 | // Start loop over events | |
55 | ||
56 | Int_t Nh=0; | |
57 | Int_t Nh1=0; | |
58 | for (int nev=0; nev<= evNumber2; nev++) { | |
59 | Int_t nparticles = gAlice->GetEvent(nev); | |
60 | //cout<<"nev "<<nev<<endl; | |
61 | printf ("Number of Events : %d\n",nev); | |
62 | //cout<<"nparticles "<<nparticles<<endl; | |
63 | printf ("Number of particles: %d\n",nparticles); | |
64 | if (nev < evNumber1) continue; | |
65 | if (nparticles <= 0) return; | |
66 | ||
67 | // Get pointers to RICH detector and Hits containers | |
68 | ||
69 | AliRICH *RICH = gAlice->GetDetector("RICH"); | |
70 | TTree *TH = gAlice->TreeH(); | |
71 | Int_t ntracks = TH->GetEntries(); | |
72 | ||
73 | // Start loop on tracks in the hits containers | |
74 | ||
75 | // Int_t Nh=0; | |
76 | Int_t Nc=0; | |
77 | for (Int_t track=0; track<ntracks;track++) { | |
78 | // printf("ntracks %d\n",ntracks); | |
79 | gAlice->ResetHits(); | |
80 | Int_t nbytes += TH->GetEvent(track); | |
81 | if (RICH) { | |
82 | TClonesArray *Clusters = RICH->Clusters(); // Cluster branch | |
83 | TClonesArray *Hits = RICH->Hits(); // Hits branch | |
84 | //printf("%d %d \n",Clusters,Hits); | |
85 | } | |
86 | //see hits distribution | |
87 | Int_t nhits = Hits->GetEntriesFast(); | |
88 | if (nhits) Nh+=nhits; | |
89 | // printf("nhits %d\n",nhits); | |
90 | for (Int_t hit=0;hit<nhits;hit++) { | |
91 | mHit = (AliRICHhit*) Hits->UncheckedAt(hit); | |
92 | Int_t nch = mHit->fChamber; // chamber number | |
93 | Float_t x = mHit->fX; // x-pos of hit | |
94 | Float_t y = mHit->fY; // y-pos | |
95 | // Fill the histograms | |
96 | if( nch==1) { | |
97 | Float_t rhit=TMath::Sqrt(x*x+y*y); | |
98 | if( rhit<= 55 ) Nh1+=nhits; | |
99 | h->Fill(x,y,(float) 1); | |
100 | } | |
101 | } | |
102 | // see signal distribution | |
103 | Int_t nclust = Clusters->GetEntriesFast(); | |
104 | // printf("nclust %d\n",nclust); | |
105 | if (nclust) { | |
106 | Nc+=nclust; | |
107 | for (Int_t hit=0;hit<nclust;hit++) { | |
108 | padHit = (AliRICHcluster*) Clusters->UncheckedAt(hit); | |
109 | Int_t nchamber = padHit->fChamber; // chamber number | |
110 | Int_t nhit = padHit->fHitNumber; // hit number | |
111 | Int_t qtot = padHit->fQ; // charge | |
112 | Int_t ipx = padHit->fPadX; // pad number on X | |
113 | Int_t ipy = padHit->fPadY; // pad number on Y | |
114 | Int_t iqpad = padHit->fQpad; // charge per pad | |
115 | Int_t rpad = padHit->fRpad; // R-position of pad | |
116 | if (qtot > 0 && nchamber==1){ | |
117 | charge->Fill(qtot,(float) 1); | |
118 | } | |
119 | if(rpad <= 55 && nchamber==1) { | |
120 | // if(nchamber==1) { | |
121 | Pad[ipx+126][ipy+187]+=(iqpad); | |
122 | hc->Fill(ipx,ipy,(float) iqpad); | |
123 | } | |
124 | } | |
125 | } | |
126 | } | |
127 | // cout<<"Nh "<<Nh<<endl; | |
128 | //cout<<"Nc "<<Nc<<endl; | |
129 | printf ("Cluster Number: %d\n",Nc); | |
130 | } | |
131 | //Create a canvas, set the view range, show histograms | |
132 | TCanvas *c1 = new TCanvas("c1","Alice RICH pad hits",400,10,600,700); | |
133 | hc->SetXTitle("ix (npads)"); | |
134 | hc->Draw(); | |
135 | TCanvas *c2 = new TCanvas("c2","Alice RICH hits",400,10,600,700); | |
136 | h->SetFillColor(42); | |
137 | h->SetXTitle("x (cm)"); | |
138 | h->Draw(); | |
139 | TCanvas *c3 = new TCanvas("c3","Charge distribution",400,10,600,700); | |
140 | charge->SetFillColor(42); | |
141 | charge->SetXTitle("ADC units"); | |
142 | charge->Draw(); | |
143 | ||
144 | ||
145 | // calculate the number of pads which give a signal | |
146 | ||
147 | ||
148 | Int_t Np=0; | |
149 | for (Int_t i=0;i< NpadX;i++) { | |
150 | for (Int_t j=0;j< NpadY;j++) { | |
151 | if (Pad[i][j]>=6){ | |
152 | Np+=1; | |
153 | // cout<<"i, j "<<i<<" "<<j<<endl; | |
154 | } | |
155 | } | |
156 | } | |
157 | ||
158 | //cout<<"The total number of pads which give a signal "<<Np<<endl; | |
159 | //cout<<"Nh "<<Nh<<endl; | |
160 | //cout<<"Nh1 "<<Nh1<<endl; | |
161 | printf("The total number of pads which give a signal: %d %d\n",Nh,Nh1); | |
162 | ||
163 | } |