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++){
85 if (fMarker[i]) delete fMarker[i];
90 //_____________________________________________________________________________
91 //void AliMUONpoints::ExecuteEvent(Int_t event, Int_t px, Int_t py)
94 //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*
95 //*-* =========================================
97 //*-* This member function must be implemented to realize the action
98 //*-* corresponding to the mouse click on the object in the window
100 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
101 // gPad->SetCursor(kCross);
104 //_____________________________________________________________________________
105 void AliMUONpoints::DumpHit()
108 // Dump hit corresponding to this point
110 AliMUONhit *hit = GetHit();
111 if (hit) hit->Dump();
114 //_____________________________________________________________________________
115 void AliMUONpoints::DumpDigit()
118 // Dump digit corresponding to this point
120 AliMUONdigit *digit = GetDigit();
121 if (digit) digit->Dump();
124 //_____________________________________________________________________________
125 void AliMUONpoints::InspectHit()
128 // Inspect hit corresponding to this point
131 if (fHitIndex < 0 ) return;
132 TVirtualPad *padsav = gPad;
133 AliMUONhit *hit = GetHit();
134 if (hit) hit->Inspect();
135 TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
137 Float_t xmin = gPad->GetX1();
138 Float_t xmax = gPad->GetX2();
139 Float_t ymin = gPad->GetY1();
140 Float_t ymax = gPad->GetY2();
141 Float_t dy = ymax-ymin;
143 TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.15*dy);
144 pad->SetBit(kCanDelete);
145 pad->SetFillColor(42);
148 sprintf(ptitle," %s , fTrack: %d fTrackIndex: %d ",GetName(),fIndex,fTrackIndex);
149 pad->AddText(ptitle);
151 padinspect->Update();
152 if (padsav) padsav->cd();
156 //_____________________________________________________________________________
157 void AliMUONpoints::InspectDigit()
160 // Inspect digit corresponding to this point
162 if (fDigitIndex < 0) return;
163 TVirtualPad *padsav = gPad;
164 AliMUONdigit *digit = GetDigit();
165 if (digit) digit->Inspect();
166 TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
168 Float_t xmin = gPad->GetX1();
169 Float_t xmax = gPad->GetX2();
170 Float_t ymin = gPad->GetY1();
171 Float_t ymax = gPad->GetY2();
172 Float_t dy = ymax-ymin;
174 TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.25*dy);
175 pad->SetBit(kCanDelete);
176 pad->SetFillColor(42);
178 char ptitle[11][100];
179 // sprintf(ptitle[11],"Tracks making this digit");
180 // pad->AddText(ptitle[11]);
181 for (int i=0;i<10;i++) {
182 if (digit->fTracks[i] == 0) continue;
183 sprintf(ptitle[i],"fTrackIndex: %d Charge: %d",digit->fTracks[i],digit->fTcharges[i]);
184 pad->AddText(ptitle[i]);
187 padinspect->Update();
188 if (padsav) padsav->cd();
192 //_____________________________________________________________________________
193 Int_t AliMUONpoints::GetTrackIndex()
196 // Dump digit corresponding to this point
201 if (fDigitIndex != 0) {
202 Int_t ncol=this->fMatrix->GetNcols();
203 for (int i=0;i<ncol;i++) {
204 printf(" track charge %f %f \n",(*(this->fMatrix))(0,i),(*(this->fMatrix))(1,i));
211 //_____________________________________________________________________________
212 AliMUONhit *AliMUONpoints::GetHit() const
215 // Returns pointer to hit index in AliRun::fParticles
217 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
218 gAlice->TreeH()->GetEvent(fTrackIndex);
219 TClonesArray *MUONhits = MUON->Hits();
220 Int_t nhits = MUONhits->GetEntriesFast();
221 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
222 return (AliMUONhit*)MUONhits->UncheckedAt(fHitIndex);
225 //_____________________________________________________________________________
226 AliMUONdigit *AliMUONpoints::GetDigit() const
229 // Returns pointer to digit index in AliRun::fParticles
232 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
233 Int_t chamber=display->GetChamber();
234 Int_t cathode=display->GetCathode();
236 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
237 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
238 Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
239 gAlice->TreeD()->GetEvent(nent-2+cathode-1);
240 //gAlice->TreeD()->GetEvent(cathode);
241 Int_t ndigits = MUONdigits->GetEntriesFast();
242 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
243 return (AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
245 //_____________________________________________________________________________
247 const AliMUONdigit *dig;
249 Bin() {dig=0; idx=-1;}
252 struct PreCluster : public AliMUONreccluster {
253 const AliMUONdigit* summit;
261 PreCluster() : AliMUONreccluster() {cut=npeaks=npoly=0;
262 for (int k=0;k<100;k++) {
263 xpoly[k]=ypoly[k]=zpoly[k]=0;
268 //_____________________________________________________________________________
270 static void FindCluster(AliMUONchamber *iChamber, AliMUONsegmentation *segmentation, int i, int j, Bin bins[][MAX_Nipy], PreCluster &c)
280 Int_t q=b.dig->fSignal;
286 // if (b.idx >= 0 && b.idx != c.idx) {
287 if (b.idx >= 0 && b.idx > c.idx) {
292 if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
294 Float_t zpos=iChamber->ZPosition();
296 Int_t npx = segmentation->Npx();
297 Int_t npy = segmentation->Npy();
300 // get pad coordinates and prepare the up and down steps
301 Int_t jup =(j-npy > 0) ? j+1 : j-1;
302 Int_t jdown=(j-npy > 0) ? j-1 : j+1;
305 segmentation->GetPadCxy(i-npx, j-npy,x, y);
306 Int_t isec0=segmentation->Sector(i-npx,j-npy);
308 Float_t dpy = segmentation->Dpy(isec0);
309 Float_t dpx = segmentation->Dpx(isec0)/16;
311 Float_t absx=TMath::Abs(x);
313 (y >0) ? segmentation->GetPadIxy(absx+dpx,y+dpy,ixx,iyy) : segmentation->GetPadIxy(absx+dpx,y-dpy,ixx,iyy);
315 // Int_t jtest=TMath::Abs(iyy)-npy-1;
317 Int_t iup=(x >0) ? ixx+npx : -ixx+npx;
319 (y >0) ? segmentation->GetPadIxy(absx+dpx,y-dpy,ixx,iyy) : segmentation->GetPadIxy(absx+dpx,y+dpy,ixx,iyy);
321 Int_t idown=(x >0) ? ixx+npx : -ixx+npx;
322 if (bins[idown][jdown].dig == 0) {
323 (y >0) ? segmentation->GetPadIxy(absx-dpx,y-dpy,ixx,iyy) : segmentation->GetPadIxy(absx-dpx,y+dpy,ixx,iyy);
324 idown=(x >0) ? ixx+npx : -ixx+npx;
328 // calculate center of gravity
330 if (c.npoly > 100 ) {
331 printf("FindCluster - npoly >100, npoly %d \n",c.npoly);
334 c.xpoly[c.npoly-1]=x;
335 c.ypoly[c.npoly-1]=y;
336 c.zpoly[c.npoly-1]=zpos;
342 b.dig = 0; b.idx = c.idx;
345 if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
346 if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
348 if (bins[iup][jup].dig) FindCluster(iChamber,segmentation,iup,jup,bins,c);
349 if (bins[idown][jdown].dig) FindCluster(iChamber,segmentation,idown,jdown,bins,c);
353 //_____________________________________________________________________________
355 void AliMUONpoints::GetCenterOfGravity()
358 // simple MUON cluster finder from digits -- finds neighbours and
359 // calculates center of gravity for the cluster
362 // const Int_t MAX_Nipx=1026, MAX_Nipy=1026;
364 Bin bins[MAX_Nipx][MAX_Nipy];
366 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
367 Int_t chamber=display->GetChamber();
368 Int_t cathode=display->GetCathode();
370 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
371 AliMUONchamber *iChamber;
372 AliMUONsegmentation *segmentation;
373 iChamber =&(MUON->Chamber(chamber-1));
374 segmentation=iChamber->GetSegmentationModel(cathode);
375 Int_t npx = segmentation->Npx();
376 Int_t npy = segmentation->Npy();
377 Float_t zpos=iChamber->ZPosition();
379 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
380 Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
381 gAlice->TreeD()->GetEvent(nent-2+cathode-1);
382 //gAlice->TreeD()->GetEvent(cathode);
383 Int_t ndigits = MUONdigits->GetEntriesFast();
384 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
387 dig=(AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
388 Int_t ipx=dig->fPadX;
389 Int_t ipy=dig->fPadY;
390 bins[ipx+npx][ipy+npy].dig=dig;
394 for (ndig=0;ndig<ndigits;ndig++) {
395 dig = (AliMUONdigit*)MUONdigits->UncheckedAt(ndig);
396 int i=dig->fPadX, j=dig->fPadY;
397 bins[i+npx][j+npy].dig=dig;
399 PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
400 FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
403 printf("GetCenterOfGravity -- more than one peak");
408 c.fTracks[0]=c.summit->fTracks[0];
409 c.fTracks[1]=c.summit->fTracks[1];
410 c.fTracks[2]=c.summit->fTracks[2];
412 AliMUONpoints *points = 0;
413 points = new AliMUONpoints(1);
414 points->SetMarkerColor(kYellow);
415 points->SetMarkerStyle(5);
416 points->SetMarkerSize(1.);
417 points->SetPoint(0,c.fX,c.fY,zpos);
418 points->SetParticle(-1);
421 TPolyLine3D *pline=0;
423 pline=new TPolyLine3D(c.npoly);
425 TVector *xp=new TVector(c.npoly);
426 TVector *yp=new TVector(c.npoly);
427 TVector *zp=new TVector(c.npoly);
428 for (int i=0;i<np;i++) {
432 pline->SetPoint(i,(*xp)(i),(*yp)(i),(*zp)(i));
433 //printf("np, i, xp, yp, zp %d %d %f %f %f \n",np,i,(*xp)(i),(*yp)(i),(*zp)(i));
436 pline=new TPolyLine3D(c.npoly,c.xpoly,c.ypoly,c.zpoly);
437 pline->SetLineColor(kWhite);
444 for (int k=0;k<c.npoly;k++) {
445 c.xpoly[k]=c.ypoly[k]=c.zpoly[k]=0;