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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // This class contains the points for the ALICE event display //
26 <img src="gif/AliMUONpointsClass.gif">
31 ///////////////////////////////////////////////////////////////////////////////
33 #include "AliMUONpoints.h"
34 #include "AliMUONdisplay.h"
37 #include "TVirtualPad.h"
38 #include "TPolyLine3D.h"
39 #include "TPaveText.h"
43 //const Int_t MAX_Nipx=1026, MAX_Nipy=1026;
44 const Int_t MAX_Nipx=400, MAX_Nipy=800;
46 ClassImp(AliMUONpoints)
48 //_____________________________________________________________________________
49 AliMUONpoints::AliMUONpoints()
52 // Default constructor
57 fMarker[0] = fMarker[1] = fMarker[2]=0;
61 //_____________________________________________________________________________
62 AliMUONpoints::AliMUONpoints(Int_t npoints)
66 // Standard constructor
71 fMarker[0] = fMarker[1] = fMarker[2]=0;
75 //_____________________________________________________________________________
76 AliMUONpoints::~AliMUONpoints()
84 for (Int_t i=0;i<3;i++){
86 fMarker[i]) delete fMarker[i];
91 //_____________________________________________________________________________
92 //void AliMUONpoints::ExecuteEvent(Int_t event, Int_t px, Int_t py)
95 //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*
96 //*-* =========================================
98 //*-* This member function must be implemented to realize the action
99 //*-* corresponding to the mouse click on the object in the window
101 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
102 // gPad->SetCursor(kCross);
105 //_____________________________________________________________________________
106 void AliMUONpoints::DumpHit()
109 // Dump hit corresponding to this point
111 AliMUONhit *hit = GetHit();
112 if (hit) hit->Dump();
113 printf("fTrackIndex %d \n",fTrackIndex);
116 //_____________________________________________________________________________
117 void AliMUONpoints::DumpDigit()
120 // Dump digit corresponding to this point
122 AliMUONdigit *digit = GetDigit();
123 if (digit) digit->Dump();
124 for (int i=0;i<10;i++) {
125 printf(" track charge %d %d \n",digit->fTracks[i],digit->fTcharges[i]);
130 //_____________________________________________________________________________
131 void AliMUONpoints::InspectHit()
134 // Inspect hit corresponding to this point
137 if (fHitIndex < 0 ) return;
138 TVirtualPad *padsav = gPad;
139 AliMUONhit *hit = GetHit();
140 if (hit) hit->Inspect();
141 TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
143 Float_t xmin = gPad->GetX1();
144 Float_t xmax = gPad->GetX2();
145 Float_t ymin = gPad->GetY1();
146 Float_t ymax = gPad->GetY2();
147 Float_t dy = ymax-ymin;
149 TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.15*dy);
150 pad->SetBit(kCanDelete);
151 pad->SetFillColor(42);
154 sprintf(ptitle," %s , fTrack: %d fTrackIndex: %d ",GetName(),fIndex,fTrackIndex);
155 pad->AddText(ptitle);
157 padinspect->Update();
158 if (padsav) padsav->cd();
162 //_____________________________________________________________________________
163 void AliMUONpoints::InspectDigit()
166 // Inspect digit corresponding to this point
168 if (fDigitIndex < 0) return;
169 TVirtualPad *padsav = gPad;
170 AliMUONdigit *digit = GetDigit();
171 if (digit) digit->Inspect();
172 TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
174 Float_t xmin = gPad->GetX1();
175 Float_t xmax = gPad->GetX2();
176 Float_t ymin = gPad->GetY1();
177 Float_t ymax = gPad->GetY2();
178 Float_t dy = ymax-ymin;
180 TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.25*dy);
181 pad->SetBit(kCanDelete);
182 pad->SetFillColor(42);
184 char ptitle[11][100];
185 // sprintf(ptitle[11],"Tracks making this digit");
186 // pad->AddText(ptitle[11]);
187 for (int i=0;i<10;i++) {
188 if (digit->fTracks[i] == 0) continue;
189 sprintf(ptitle[i],"fTrackIndex: %d Charge: %d",digit->fTracks[i],digit->fTcharges[i]);
190 pad->AddText(ptitle[i]);
193 padinspect->Update();
194 if (padsav) padsav->cd();
198 //_____________________________________________________________________________
199 Int_t AliMUONpoints::GetTrackIndex()
202 // Dump digit corresponding to this point
204 printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
207 if (fDigitIndex != 0) {
208 Int_t ncol=this->fMatrix->GetNcols();
209 for (int i=0;i<ncol;i++) {
210 printf(" track charge %f %f \n",(*(this->fMatrix))(0,i),(*(this->fMatrix))(1,i));
217 //_____________________________________________________________________________
218 AliMUONhit *AliMUONpoints::GetHit() const
221 // Returns pointer to hit index in AliRun::fParticles
223 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
224 gAlice->TreeH()->GetEvent(fTrackIndex);
225 TClonesArray *MUONhits = MUON->Hits();
226 Int_t nhits = MUONhits->GetEntriesFast();
227 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
228 return (AliMUONhit*)MUONhits->UncheckedAt(fHitIndex);
231 //_____________________________________________________________________________
232 AliMUONdigit *AliMUONpoints::GetDigit() const
235 // Returns pointer to digit index in AliRun::fParticles
238 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
239 Int_t chamber=display->GetChamber();
240 Int_t cathode=display->GetCathode();
242 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
243 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
244 gAlice->TreeD()->GetEvent(cathode);
245 Int_t ndigits = MUONdigits->GetEntriesFast();
246 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
247 return (AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
249 //_____________________________________________________________________________
251 const AliMUONdigit *dig;
253 Bin() {dig=0; idx=-1;}
256 struct PreCluster : public AliMUONreccluster {
257 const AliMUONdigit* summit;
265 PreCluster() : AliMUONreccluster() {cut=npeaks=npoly=0;
266 for (int k=0;k<100;k++) {
267 xpoly[k]=ypoly[k]=zpoly[k]=0;
272 //_____________________________________________________________________________
274 static void FindCluster(AliMUONchamber *iChamber, AliMUONsegmentation *segmentation, int i, int j, Bin bins[][MAX_Nipy], PreCluster &c)
282 printf("I'm in FindCluster \n");
285 Int_t q=b.dig->fSignal;
287 printf("FindCluster - i j q %d %d %d\n",i,j,q);
293 // if (b.idx >= 0 && b.idx != c.idx) {
294 if (b.idx >= 0 && b.idx > c.idx) {
297 printf("FindCluster - one more peak \n");
300 if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
302 Float_t zpos=iChamber->ZPosition(); // check with Andreas
304 Int_t npx = segmentation->Npx();
305 Int_t npy = segmentation->Npy();
307 // get pad coordinates and prepare the up and down steps
308 Int_t jup =(j-npy > 0) ? j+1 : (j-npy-1)+npy;
309 Int_t jdown=(j-npy > 0) ? j-1 : (j-npy+1)+npy;
313 segmentation->GetPadCxy(i-npx, j-npy,x, y);
314 Int_t isec0=segmentation->Sector(i-npx,j-npy);
315 printf("FindCluster - i-npx j-npy isec0 %d %d %d \n",i-npx,j-npy,isec0);
316 // printf("FindCluster - x y %f %f \n",x,y);
318 Float_t dpy = segmentation->Dpy();
319 Float_t dpx = segmentation->Dpx()/16;
321 Float_t absx=TMath::Abs(x);
323 (y >0) ? segmentation->GetPadIxy(absx+dpx,y+dpy,ixx,iyy) : segmentation->GetPadIxy(absx+dpx,y-dpy,ixx,iyy);
324 printf(" iup: ixx iyy %d %d \n",ixx,iyy);
325 Int_t jtest=TMath::Abs(iyy)-npy-1;
327 printf(" j != jtest - something's wrong %d %d \n",j,jtest);
329 Int_t iup=(x >0) ? ixx+npx : -ixx+npx;
331 (y >0) ? segmentation->GetPadIxy(absx+dpx,y-dpy,ixx,iyy) : segmentation->GetPadIxy(absx+dpx,y+dpy,ixx,iyy);
332 printf(" idown: ixx iyy %d %d \n",ixx,iyy);
333 Int_t idown=(x >0) ? ixx+npx : -ixx+npx;
334 if (bins[idown][jdown].dig == 0) {
335 (y >0) ? segmentation->GetPadIxy(absx-dpx,y-dpy,ixx,iyy) : segmentation->GetPadIxy(absx-dpx,y+dpy,ixx,iyy);
336 printf(" idown: ixx iyy %d %d \n",ixx,iyy);
337 idown=(x >0) ? ixx+npx : -ixx+npx;
340 printf("i, iup, idown, j, jup, jdown %d %d %d %d %d %d \n",i,iup,idown,j,jup,jdown);
342 // calculate center of gravity
344 if (c.npoly > 100 ) {
345 printf("FindCluster - npoly >100, npoly %d \n",c.npoly);
348 c.xpoly[c.npoly-1]=x;
349 c.ypoly[c.npoly-1]=y;
350 c.zpoly[c.npoly-1]=zpos;
356 b.dig = 0; b.idx = c.idx;
359 if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
360 if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
362 if (bins[iup][jup].dig) FindCluster(iChamber,segmentation,iup,jup,bins,c);
363 if (bins[idown][jdown].dig) FindCluster(iChamber,segmentation,idown,jdown,bins,c);
367 //_____________________________________________________________________________
369 void AliMUONpoints::GetCenterOfGravity()
372 // simple MUON cluster finder from digits -- finds neighbours and
373 // calculates center of gravity for the cluster
376 // const Int_t MAX_Nipx=1026, MAX_Nipy=1026;
378 Bin bins[MAX_Nipx][MAX_Nipy];
380 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
381 Int_t chamber=display->GetChamber();
382 Int_t cathode=display->GetCathode();
384 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
385 AliMUONchamber *iChamber;
386 AliMUONsegmentation *segmentation;
387 iChamber =&(MUON->Chamber(chamber-1));
388 segmentation=iChamber->GetSegmentationModel(cathode);
389 Int_t npx = segmentation->Npx();
390 Int_t npy = segmentation->Npy();
391 Float_t zpos=iChamber->ZPosition();
393 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
394 gAlice->TreeD()->GetEvent(cathode);
395 Int_t ndigits = MUONdigits->GetEntriesFast();
396 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
399 dig=(AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
400 Int_t ipx=dig->fPadX;
401 Int_t ipy=dig->fPadY;
402 bins[ipx+npx][ipy+npy].dig=dig;
406 for (ndig=0;ndig<ndigits;ndig++) {
407 dig = (AliMUONdigit*)MUONdigits->UncheckedAt(ndig);
408 int i=dig->fPadX, j=dig->fPadY;
409 bins[i+npx][j+npy].dig=dig;
411 PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
412 FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
413 printf("GetCenterOfGravity -- npoly %d \n",c.npoly);
416 printf("GetCenterOfGravity -- more than one peak");
420 printf("GetCenterOfGravity - c.fX c.fY c.fQ c.npeaks%f %f %d %d \n",c.fX,c.fY,c.fQ,c.npeaks);
422 c.fTracks[0]=(Int_t)(*(c.summit->fTrks))(0);
423 c.fTracks[1]=(Int_t)(*(c.summit->fTrks))(1);
424 c.fTracks[2]=(Int_t)(*(c.summit->fTrks))(2);
426 c.fTracks[0]=c.summit->fTracks[0];
427 c.fTracks[1]=c.summit->fTracks[1];
428 c.fTracks[2]=c.summit->fTracks[2];
430 AliMUONpoints *points = 0;
431 points = new AliMUONpoints(1);
432 points->SetMarkerColor(kYellow);
433 points->SetMarkerStyle(5);
434 points->SetMarkerSize(1.);
435 points->SetPoint(0,c.fX,c.fY,zpos);
436 points->SetParticle(-1);
439 TPolyLine3D *pline=0;
441 pline=new TPolyLine3D(c.npoly);
443 Float_t *x=new Float_t(c.npoly);
444 Float_t *y=new Float_t(c.npoly);
445 Float_t *z=new Float_t(c.npoly);
446 for (int i=0;i<np;i++) {
450 pline->SetPoint(i,x[i],y[i],z[i]);
453 pline=new TPolyLine3D(c.npoly,c.xpoly,c.ypoly,c.zpoly);
454 pline->SetLineColor(kWhite);
458 printf("GetCenterOfGravity -- ncls %d \n",ncls);