]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHPoints.cxx
Macro for RICH diagnostics (JB, AM)
[u/mrichter/AliRoot.git] / RICH / AliRICHPoints.cxx
CommitLineData
0279872e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17 $Log$
18*/
19
20
21///////////////////////////////////////////////////////////////////////////////
22// //
23// This class contains the points for the ALICE event display //
24// //
25//Begin_Html
26/*
27<img src="gif/AliRICHPointsClass.gif">
28*/
29//End_Html
30// //
31// //
32///////////////////////////////////////////////////////////////////////////////
33#include "AliRICHDisplay.h"
34#include "AliRICHPoints.h"
35#include "AliRun.h"
36#include "TPad.h"
37#include "TView.h"
38#include "TMath.h"
39
40const Int_t MAX_Nipx=400, MAX_Nipy=800;
41
42ClassImp(AliRICHPoints)
43
44//_____________________________________________________________________________
45AliRICHPoints::AliRICHPoints()
46{
47 //
48 // Default constructor
49 //
50 fHitIndex = 0;
51 fTrackIndex = 0;
52 fDigitIndex = 0;
53 fMarker[0] = fMarker[1] = fMarker[2]=0;
54}
55
56//_____________________________________________________________________________
57AliRICHPoints::AliRICHPoints(Int_t npoints)
58 :AliPoints(npoints)
59{
60 //
61 // Standard constructor
62 //
63 fHitIndex = 0;
64 fTrackIndex = 0;
65 fDigitIndex = 0;
66 fMarker[0] = fMarker[1] = fMarker[2]=0;
67}
68
69//_____________________________________________________________________________
70AliRICHPoints::~AliRICHPoints()
71{
72 //
73 // Default destructor
74 //
75 fHitIndex = 0;
76 fTrackIndex = 0;
77 fDigitIndex = 0;
78}
79
80//_____________________________________________________________________________
81void AliRICHPoints::DumpHit()
82{
83 //
84 // Dump hit corresponding to this point
85 //
86 AliRICHHit *hit = GetHit();
87 if (hit) hit->Dump();
88}
89
90//_____________________________________________________________________________
91void AliRICHPoints::DumpDigit()
92{
93 //
94 // Dump digit corresponding to this point
95 //
96 AliRICHDigit *digit = GetDigit();
97 if (digit) digit->Dump();
98}
99
100//_____________________________________________________________________________
101void AliRICHPoints::InspectHit()
102{
103 //
104 // Inspect hit corresponding to this point
105 //
106 AliRICHHit *hit = GetHit();
107 if (hit) hit->Inspect();
108}
109
110//_____________________________________________________________________________
111void AliRICHPoints::InspectDigit()
112{
113 //
114 // Inspect digit corresponding to this point
115 //
116 AliRICHDigit *digit = GetDigit();
117 if (digit) digit->Inspect();
118}
119
120//_____________________________________________________________________________
121Int_t AliRICHPoints::GetTrackIndex()
122{
123 //
124 // Dump digit corresponding to this point
125 //
126 printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
127 this->Inspect();
128 return fTrackIndex;
129}
130
131//_____________________________________________________________________________
132AliRICHHit *AliRICHPoints::GetHit() const
133{
134 //
135 // Returns pointer to hit index in AliRun::fParticles
136 //
137 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
138 gAlice->TreeH()->GetEvent(fTrackIndex);
139 TClonesArray *RICHhits = RICH->Hits();
140 Int_t nhits = RICHhits->GetEntriesFast();
141 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
142 return (AliRICHHit*)RICHhits->UncheckedAt(fHitIndex);
143}
144
145//_____________________________________________________________________________
146AliRICHDigit *AliRICHPoints::GetDigit() const
147{
148 //
149 // Returns pointer to digit index in AliRun::fParticles
150 //
151
152 AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
153 Int_t chamber=display->GetChamber();
154 Int_t cathode=display->GetCathode();
155
156 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
157 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
158 gAlice->TreeD()->GetEvent(cathode);
159 Int_t ndigits = RICHdigits->GetEntriesFast();
160 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
161 return (AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
162}
163//_____________________________________________________________________________
164struct Bin {
165 const AliRICHDigit *dig;
166 int idx;
167 Bin() {dig=0; idx=-1;}
168};
169
170struct PreCluster : public AliRICHRawCluster {
171 const AliRICHDigit* summit;
172 int idx;
173 int cut;
174 int npeaks;
175 PreCluster() : AliRICHRawCluster() {cut=npeaks=0;}
176};
177//_____________________________________________________________________________
178
179static void FindCluster(AliRICHChamber *iChamber, AliRICHSegmentation *segmentation, int i, int j, Bin bins[MAX_Nipx][MAX_Nipy], PreCluster &c)
180
181{
182
183 //
184 // Find clusters
185 //
186
187 printf("I'm in FindCluster \n");
188
189 Bin& b=bins[i][j];
190 Int_t q=b.dig->fSignal;
191
192 printf("FindCluster - i j q %d %d %d\n",i,j,q);
193
194 if (q<0) {
195 q=-q;
196 c.cut=1;
197 }
198 if (b.idx >= 0 && b.idx != c.idx) {
199 c.idx=b.idx;
200 c.npeaks++;
201 }
202
203 if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
204
205 Int_t npx = segmentation->Npx();
206 Int_t npy = segmentation->Npy();
207 Float_t x,y;
208 segmentation->GetPadCxy(i-npx, j-npy, x,y);
209 printf("FindCluster - x y %f %f \n",x,y);
210
211
212 c.fX += q*x;
213 c.fY += q*y;
214 c.fQ += q;
215
216 b.dig = 0; b.idx = c.idx;
217
218 if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
219 if (bins[i][j-1].dig) FindCluster(iChamber,segmentation,i,j-1,bins,c);
220 if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
221 if (bins[i][j+1].dig) FindCluster(iChamber,segmentation,i,j+1,bins,c);
222
223}
224
225//_____________________________________________________________________________
226
227void AliRICHPoints::GetCenterOfGravity()
228{
229 //
230 // simple RICH cluster finder from digits -- finds neighbours and
231 // calculates center of gravity for the cluster
232 //
233 const Int_t MAX_nipx=400, MAX_nipy=800;
234 printf("\n Hallo world");
235 AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
236 Int_t chamber=display->GetChamber();
237 Int_t cathode=display->GetCathode();
238
239 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
240 AliRICHChamber *iChamber;
241 AliRICHSegmentation *segmentation;
242 iChamber =&(RICH->Chamber(chamber-1));
243 segmentation=iChamber->GetSegmentationModel(cathode);
244 Int_t npx = segmentation->Npx();
245 Int_t npy = segmentation->Npy();
246 Float_t zpos=iChamber->ZPosition();
247
248 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
249 gAlice->TreeD()->GetEvent(cathode);
250 Int_t ndigits = RICHdigits->GetEntriesFast();
251 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
252
253 AliRICHDigit *dig;
254 dig=(AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
255 Int_t ipx=dig->fPadX;
256 Int_t ipy=dig->fPadY;
257 Bin bins[MAX_nipx][MAX_nipy];
258 bins[ipx+npx][ipy+npy].dig=dig;
259
260 int ndig;
261 int ncls=0;
262 for (ndig=0; ndig<ndigits; ndig++) {
263 dig = (AliRICHDigit*)RICHdigits->UncheckedAt(ndig);
264 int i=dig->fPadX, j=dig->fPadY;
265 bins[i+npx][j+npy].dig=dig;
266 }
267
268 PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
269 FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
270 if (c.npeaks>1) {
271 printf("GetCenterOfGravity -- more than one peak");
272 }
273 c.fX /= c.fQ;
274 c.fY /= c.fQ;
275 printf("GetCenterOfGravity - c.fX c.fY c.fQ %f %f %d \n",c.fX,c.fY,c.fQ);
276
277 c.fTracks[0]=c.summit->fTracks[0];
278 c.fTracks[1]=c.summit->fTracks[1];
279 c.fTracks[2]=c.summit->fTracks[2];
280 ncls++;
281 AliRICHPoints *points = 0;
282 points = new AliRICHPoints(1);
283 points->SetMarkerColor(kYellow);
284 points->SetMarkerStyle(5);
285 points->SetMarkerSize(1.);
286 points->SetPoint(0,c.fX,c.fY,zpos);
287 points->Draw();
288
289 printf("GetCenterOfGravity -- ncls %d \n",ncls);
290
291}
292
293//_____________________________________________________________________________
294const Text_t *AliRICHPoints::GetName() const
295{
296 //
297 // Return name of the Geant3 particle corresponding to this point
298 //
299 TParticle *particle = GetParticle();
300 if (!particle) return "Particle";
301 return particle->GetName();
302}
303
304//_____________________________________________________________________________
305Text_t *AliRICHPoints::GetObjectInfo(Int_t, Int_t)
306{
307 //
308 // Redefines TObject::GetObjectInfo.
309 // Displays the info (particle,etc
310 // corresponding to cursor position px,py
311 //
312 static char info[64];
313 sprintf(info,"%s %d",GetName(),fIndex);
314 return info;
315}
316
317
318