1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.1 2000/04/19 13:16:47 morsch
19 Minor changes on class names.
24 ///////////////////////////////////////////////////////////////////////////////
26 // This class contains the points for the ALICE event display //
30 <img src="gif/AliRICHPointsClass.gif">
35 ///////////////////////////////////////////////////////////////////////////////
36 #include "AliRICHDisplay.h"
37 #include "AliRICHPoints.h"
43 const Int_t MAX_Nipx=400, MAX_Nipy=800;
45 ClassImp(AliRICHPoints)
47 //_____________________________________________________________________________
48 AliRICHPoints::AliRICHPoints()
51 // Default constructor
56 fMarker[0] = fMarker[1] = fMarker[2]=0;
59 //_____________________________________________________________________________
60 AliRICHPoints::AliRICHPoints(Int_t npoints)
64 // Standard constructor
69 fMarker[0] = fMarker[1] = fMarker[2]=0;
72 //_____________________________________________________________________________
73 AliRICHPoints::~AliRICHPoints()
83 //_____________________________________________________________________________
84 void AliRICHPoints::DumpHit()
87 // Dump hit corresponding to this point
89 AliRICHHit *hit = GetHit();
93 //_____________________________________________________________________________
94 void AliRICHPoints::DumpDigit()
97 // Dump digit corresponding to this point
99 AliRICHDigit *digit = GetDigit();
100 if (digit) digit->Dump();
103 //_____________________________________________________________________________
104 void AliRICHPoints::InspectHit()
107 // Inspect hit corresponding to this point
109 AliRICHHit *hit = GetHit();
110 if (hit) hit->Inspect();
113 //_____________________________________________________________________________
114 void AliRICHPoints::InspectDigit()
117 // Inspect digit corresponding to this point
119 AliRICHDigit *digit = GetDigit();
120 if (digit) digit->Inspect();
123 //_____________________________________________________________________________
124 Int_t AliRICHPoints::GetTrackIndex()
127 // Dump digit corresponding to this point
129 printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
133 //_____________________________________________________________________________
134 TParticle *AliRICHPoints::GetParticle() const
137 // Returns pointer to particle index in AliRun::fParticles
139 TClonesArray *particles = gAlice->Particles();
140 Int_t nparticles = particles->GetEntriesFast();
141 if (fIndex < 0 || fIndex >= nparticles) return 0;
142 return (TParticle*)particles->UncheckedAt(fIndex);
145 //_____________________________________________________________________________
146 AliRICHHit *AliRICHPoints::GetHit() const
149 // Returns pointer to hit index in AliRun::fParticles
151 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
152 gAlice->TreeH()->GetEvent(fTrackIndex);
153 TClonesArray *RICHhits = RICH->Hits();
154 Int_t nhits = RICHhits->GetEntriesFast();
155 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
156 return (AliRICHHit*)RICHhits->UncheckedAt(fHitIndex);
159 //_____________________________________________________________________________
160 AliRICHDigit *AliRICHPoints::GetDigit() const
163 // Returns pointer to digit index in AliRun::fParticles
166 AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
167 Int_t chamber=display->GetChamber();
168 Int_t cathode=display->GetCathode();
170 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
171 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
172 gAlice->TreeD()->GetEvent(cathode);
173 Int_t ndigits = RICHdigits->GetEntriesFast();
174 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
175 return (AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
177 //----------------------------------------------------------------------------
178 void AliRICHPoints::ShowRing(Int_t highlight) {
180 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
181 AliRICHChamber* iChamber;
182 AliRICHSegmentation* segmentation;
185 AliRICHPoints *points = 0;
186 TMarker3DBox *marker = 0;
188 AliRICHHit *mHit = GetHit();
190 printf("Hit %d on chamber: %d\n",fHitIndex, mHit->fChamber);
192 TClonesArray *digits = RICH->DigitsAddress(mHit->fChamber - 1);
193 iChamber = &(RICH->Chamber(mHit->fChamber - 1));
194 segmentation=iChamber->GetSegmentationModel();
196 Float_t dpx = segmentation->Dpx();
197 Float_t dpy = segmentation->Dpy();
199 int ndigits=digits->GetEntriesFast();
201 printf("Show Ring called with %d digits\n",ndigits);
203 for (int digit=0;digit<ndigits;digit++) {
204 AliRICHDigit *mdig = (AliRICHDigit*)digits->UncheckedAt(digit);
205 points = new AliRICHPoints(1);
207 //printf("Particle %d belongs to ring %d \n", fTrackIndex, mdig->fTracks[1]);
209 if (!points) continue;
210 if (fTrackIndex == mdig->fTracks[0]) {
212 printf("Digit %d from particle %d belongs to ring %d \n", digit, fTrackIndex, mdig->fTracks[0]);
214 Int_t charge=mdig->fSignal;
215 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
216 Int_t color=701+index;
217 if (color>722) color=722;
218 points->SetMarkerColor(color);
219 points->SetMarkerStyle(21);
220 points->SetMarkerSize(.5);
222 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
223 Float_t VecLoc[3]={xpad,6.276,ypad};
225 points->SetParticle(-1);
226 points->SetHitIndex(-1);
227 points->SetTrackIndex(-1);
228 points->SetDigitIndex(digit);
229 iChamber->LocaltoGlobal(VecLoc,VecGlob);
230 points->SetPoint(0,VecGlob[0],VecGlob[1],VecGlob[2]);
232 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY, xpad, ypad);
233 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
234 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
235 marker=new TMarker3DBox(VecGlob[0],VecGlob[1],VecGlob[2],
236 dpy/2,0,dpx/2,theta,phi);
237 marker->SetLineColor(highlight);
238 marker->SetFillStyle(1001);
239 marker->SetFillColor(color);
240 marker->SetRefObject((TObject*)points);
241 points->Set3DMarker(0, marker);
243 points->Draw("same");
244 for (Int_t im=0;im<3;im++) {
245 TMarker3DBox *marker=points->GetMarker(im);
249 TClonesArray *particles=gAlice->Particles();
250 TParticle *p = (TParticle*)particles->UncheckedAt(fIndex);
251 printf("\nTrack index %d\n",fTrackIndex);
252 printf("Particle ID %d\n",p->GetPdgCode());
253 printf("Parent %d\n",p->GetFirstMother());
254 printf("First child %d\n",p->GetFirstDaughter());
255 printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
259 //_____________________________________________________________________________
261 const AliRICHDigit *dig;
263 Bin() {dig=0; idx=-1;}
266 struct PreCluster : public AliRICHRawCluster {
267 const AliRICHDigit* summit;
271 PreCluster() : AliRICHRawCluster() {cut=npeaks=0;}
273 //_____________________________________________________________________________
275 static void FindCluster(AliRICHChamber *iChamber, AliRICHSegmentation *segmentation, int i, int j, Bin bins[MAX_Nipx][MAX_Nipy], PreCluster &c)
283 printf("I'm in FindCluster \n");
286 Int_t q=b.dig->fSignal;
288 printf("FindCluster - i j q %d %d %d\n",i,j,q);
294 if (b.idx >= 0 && b.idx != c.idx) {
299 if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
301 Int_t npx = segmentation->Npx();
302 Int_t npy = segmentation->Npy();
304 segmentation->GetPadCxy(i-npx, j-npy, x,y);
305 printf("FindCluster - x y %f %f \n",x,y);
312 b.dig = 0; b.idx = c.idx;
314 if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
315 if (bins[i][j-1].dig) FindCluster(iChamber,segmentation,i,j-1,bins,c);
316 if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
317 if (bins[i][j+1].dig) FindCluster(iChamber,segmentation,i,j+1,bins,c);
321 //_____________________________________________________________________________
323 void AliRICHPoints::GetCenterOfGravity()
326 // simple RICH cluster finder from digits -- finds neighbours and
327 // calculates center of gravity for the cluster
329 const Int_t MAX_nipx=400, MAX_nipy=800;
330 printf("\n Hallo world");
331 AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
332 Int_t chamber=display->GetChamber();
333 Int_t cathode=display->GetCathode();
335 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
336 AliRICHChamber *iChamber;
337 AliRICHSegmentation *segmentation;
338 iChamber =&(RICH->Chamber(chamber-1));
339 segmentation=iChamber->GetSegmentationModel(cathode);
340 Int_t npx = segmentation->Npx();
341 Int_t npy = segmentation->Npy();
342 Float_t zpos=iChamber->ZPosition();
344 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
345 gAlice->TreeD()->GetEvent(cathode);
346 Int_t ndigits = RICHdigits->GetEntriesFast();
347 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
350 dig=(AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
351 Int_t ipx=dig->fPadX;
352 Int_t ipy=dig->fPadY;
353 Bin bins[MAX_nipx][MAX_nipy];
354 bins[ipx+npx][ipy+npy].dig=dig;
358 for (ndig=0; ndig<ndigits; ndig++) {
359 dig = (AliRICHDigit*)RICHdigits->UncheckedAt(ndig);
360 int i=dig->fPadX, j=dig->fPadY;
361 bins[i+npx][j+npy].dig=dig;
364 PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
365 FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
367 printf("GetCenterOfGravity -- more than one peak");
371 printf("GetCenterOfGravity - c.fX c.fY c.fQ %f %f %d \n",c.fX,c.fY,c.fQ);
373 c.fTracks[0]=c.summit->fTracks[0];
374 c.fTracks[1]=c.summit->fTracks[1];
375 c.fTracks[2]=c.summit->fTracks[2];
377 AliRICHPoints *points = 0;
378 points = new AliRICHPoints(1);
379 points->SetMarkerColor(kYellow);
380 points->SetMarkerStyle(5);
381 points->SetMarkerSize(1.);
382 points->SetPoint(0,c.fX,c.fY,zpos);
385 printf("GetCenterOfGravity -- ncls %d \n",ncls);
389 //_____________________________________________________________________________
390 const Text_t *AliRICHPoints::GetName() const
393 // Return name of the Geant3 particle corresponding to this point
395 TParticle *particle = GetParticle();
396 if (!particle) return "Particle";
397 return particle->GetName();
400 //_____________________________________________________________________________
401 Text_t *AliRICHPoints::GetObjectInfo(Int_t, Int_t)
404 // Redefines TObject::GetObjectInfo.
405 // Displays the info (particle,etc
406 // corresponding to cursor position px,py
408 static char info[64];
409 sprintf(info,"%s %d",GetName(),fIndex);