]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONdisplay.cxx
Make-depend automatically generated if not there.
[u/mrichter/AliRoot.git] / MUON / AliMUONdisplay.cxx
CommitLineData
fe4da5cc 1
2//////////////////////////////////////////////////////////////////////////
3// //
4// AliDisplay //
5// //
6// Utility class to display ALICE outline, tracks, hits,.. //
7// //
8//////////////////////////////////////////////////////////////////////////
9
10#include <TROOT.h>
11#include <TTree.h>
12#include <TButton.h>
13#include <TColor.h>
14#include <TCanvas.h>
15#include <TView.h>
16#include <TText.h>
17#include <TPolyMarker3D.h>
18#include <TPolyMarker.h>
19#include <TPaveLabel.h>
20#include <TPaveText.h>
21#include <TList.h>
22#include <TDiamond.h>
23#include <TNode.h>
24#include <TArc.h>
25#include <TTUBE.h>
26#include <TSlider.h>
27#include <TSliderBox.h>
28#include <TGaxis.h>
29#include <TGXW.h>
30#include <TMath.h>
31#include <X3DBuffer.h>
32
33#include "AliRun.h"
34#include "AliDetector.h"
35#include "AliMUON.h"
36#include "AliMUONConst.h"
37#include "AliMUONdisplay.h"
38#include "AliMUONpoints.h"
39#include "GParticle.h"
40
41
42ClassImp(AliMUONdisplay)
43
44
45//_____________________________________________________________________________
46AliMUONdisplay::AliMUONdisplay()
47{
48 fPoints = 0;
49 fPhits = 0;
50 fCanvas = 0;
51}
52
53//_____________________________________________________________________________
54AliMUONdisplay::AliMUONdisplay(Int_t size)
55{
56// Create an event display object.
57// A canvas named "edisplay" is created with a vertical size in pixels
58//
59// A QUICK Overview of the Event Display functions
60// ===============================================
61//
62// The event display can ve invoked by executing the macro "display.C"
63// A canvas like in the picture below will appear.
64//
65// On the left side of the canvas, the following buttons appear:
66// *Next* to move to the next event
67// *Previous* to move to the previous event
68
69// *Pick* Select this option to be able to point on a track with the
70// mouse. Once on the track, use the right button to select
71// an action. For example, select SetMarkerAttributes to
72// change the marker type/color/size for the track.
73// *Zoom* Select this option (default) if you want to zoom.
74// To zoom, simply select the selected area with the left button.
75// *UnZoom* To revert to the previous picture size.
76//
77// slider R On the left side, the vertical slider can be used to
78// set the default picture size.
79//
80// When you are in Zoom mode, you can click on the black part of the canvas
81// to select special options with the right mouse button.
82
83//
84// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
85// When you are on a track, select the menu item "InspectParticle"
86// to display the current particle attributes.
87//
88// You can activate the Root browser by selecting the Inspect menu
89// in the canvas tool bar menu. Then select "Start Browser"
90// This will open a new canvas with the browser. At this point, you may want
91// to display some histograms (from the Trees). Go to the "File" menu
92// of the browser and click on "New canvas".
93// In the browser, click on item "ROOT files" in the left pane.
94// Click on galice.root.
95// Click on TH
96// Click on TPC for example
97// Click on any variable (eg TPC.fX) to histogram the variable.
98//
99// If you are lost, you can click on HELP in any Root canvas or browser.
100//Begin_Html
101/*
102<img src="gif/aliMUONdisplay.gif">
103*/
104//End_Html
105
106
107 fPad = 0;
108
109 gAlice->SetDisplay(this);
110
111 // Initialize display default parameters
112 SetRange();
113
114 // Set front view by default
115 fTheta = 0;
116 fPhi = -90;
117 fPsi = 0;
118 fChamber = 1;
119 fCathode = 1;
120 // fRzone = 1.e10;
121 fDrawClusters = kTRUE;
122 fZoomMode = 1;
123 fZooms = 0;
124 fClustersCuts = 0;
125 fPoints = 0;
126 fPhits = 0;
127 // Create colors
128 CreateColors();
129 // Create display canvas
130 Int_t ysize = size;
131 if (ysize < 100) ysize = 750;
132 Int_t xsize = Int_t(size*830./ysize);
133 fCanvas = new TCanvas("Canvas", "MUON Clusters Display",14,47,xsize,ysize);
134 fCanvas->SetEditable(kIsNotEditable);
135 fCanvas->ToggleEventStatus();
136
137 // Create main display pad
138 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
139 fPad->Draw();
140 fPad->Modified();
141 fPad->SetFillColor(1);
142 fPad->SetBorderSize(2);
143
144 fCanvas->cd();
145
146 // Create colors pad
147 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
148 fColPad->Draw();
149 fColPad->Modified();
150 fColPad->SetFillColor(19);
151 fColPad->SetBorderSize(2);
152 fColPad->cd();
153 DisplayColorScale();
154
155 fCanvas->cd();
156
157 // Create user interface control pad
158 DisplayButtons();
159 fCanvas->cd();
160
161 // Create Range and mode pad
162 Float_t dxtr = 0.15;
163 Float_t dytr = 0.45;
164 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
165 fTrigPad->Draw();
166 fTrigPad->cd();
167 fTrigPad->SetFillColor(22);
168 fTrigPad->SetBorderSize(2);
169 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
170 fRangeSlider->SetObject(this);
171 char pickmode[] = "gAlice->Display()->SetPickMode()";
172 Float_t db = 0.09;
173 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
174 fPickButton->SetFillColor(38);
175 fPickButton->Draw();
176 char zoommode[] = "gAlice->Display()->SetZoomMode()";
177 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
178 fZoomButton->SetFillColor(38);
179 fZoomButton->Draw();
180 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
181 fArcButton->SetFillColor(kGreen);
182 fArcButton->Draw();
183 char butUnzoom[] = "gAlice->Display()->UnZoom()";
184 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
185 button->SetFillColor(38);
186 button->Draw();
187 AppendPad(); // append display object as last object to force selection
188
189 fCanvas->cd();
190 fCanvas->Update();
191}
192
193
194//_____________________________________________________________________________
195AliMUONdisplay::~AliMUONdisplay()
196{
197 // Delete space point structure
198 if (fPoints) fPoints->Delete();
199 delete fPoints;
200 fPoints = 0;
201 //
202 if (fPhits) fPhits->Delete();
203 delete fPhits;
204 fPhits = 0;
205}
206
207//_____________________________________________________________________________
208void AliMUONdisplay::Clear(Option_t *)
209{
210// Delete graphics temporary objects
211}
212
213//_____________________________________________________________________________
214void AliMUONdisplay::DisplayButtons()
215{
216// Create the user interface buttons
217
218
219 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
220 fButtons->Draw();
221 fButtons->SetFillColor(38);
222 fButtons->SetBorderSize(2);
223 fButtons->cd();
224
225 // Int_t butcolor = 33;
226 Float_t dbutton = 0.08;
227 Float_t y = 0.96;
228 Float_t dy = 0.014;
229 Float_t x0 = 0.05;
230 Float_t x1 = 0.95;
231
232 TButton *button;
233 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
234 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
235 button->SetFillColor(38);
236 button->Draw();
237
238 y -= dbutton +dy;
239 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
240 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
241 button->SetFillColor(38);
242 button->Draw();
243 /*
244 y -= dbutton +dy;
245 char but3[] = "gAlice->Display()->SetChamberAndCathode(1,1)";
246 button = new TButton("Cham&Cath",but3,x0,y-dbutton,x1,y);
247 button->SetFillColor(butcolor);
248 button->Draw();
249 */
250 // display logo
251 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
252 diamond->SetFillColor(50);
253 diamond->SetTextAlign(22);
254 diamond->SetTextColor(5);
255 diamond->SetTextSize(0.11);
256 diamond->Draw();
257 diamond->AddText(".. ");
258 diamond->AddText("ROOT");
259 diamond->AddText("MUON");
260 diamond->AddText("... ");
261 diamond->AddText(" ");
262}
263
264//_____________________________________________________________________________
265void AliMUONdisplay::CreateColors()
266{
267// Create the colors palette used to display clusters
268
269 Int_t k,i;
270 Int_t color;
271 Float_t r,g,b;
272
273 for (k=1;k<=5;k++) {
274 switch(k) {
275 case 1:
276 for (i=1;i<=5;i++) {
277 r=1.;
278 g=i*0.2;
279 b=0.;
280 color=i;
281 color=50+23-color;
282 // printf("CreateColors - i, k, color %d %d %d \n",i,k,color);
283 new TColor(color,r,g,b);
284 }
285 // printf("I'm out of case %d \n",k);
286 break;
287 case 2:
288 for (i=1;i<=4;i++) {
289 r=1.1-i*0.2;
290 g=1.;
291 b=0.;
292 color=i+5;
293 color=50+23-color;
294 // printf("CreateColors - i, k, color %d %d %d \n",i,k,color);
295 new TColor(color,r,g,b);
296 }
297 // printf("I'm out of case %d \n",k);
298 break;
299 case 3:
300 for (i=1;i<=4;i++) {
301 r=0.;
302 g=1.;
303 b=i*0.2+0.2;
304 color=i+9;
305 color=50+23-color;
306 // printf("CreateColors - i, k, color %d %d %d \n",i,k,color);
307 new TColor(color,r,g,b);
308 }
309 // printf("I'm out of case %d \n",k);
310 break;
311 case 4:
312 for (i=1;i<=4;i++) {
313 r=0.;
314 g=1.1-i*0.2;
315 b=1.;
316 color=i+13;
317 color=50+23-color;
318 // printf("CreateColors - i, k, color %d %d %d \n",i,k,color);
319 new TColor(color,r,g,b);
320 }
321 // printf("I'm out of case %d \n",k);
322 break;
323 case 5:
324 for (i=1;i<=5;i++) {
325 r=i*0.2;
326 g=0.;
327 b=1.;
328 color=i+17;
329 color=50+23-color;
330 // printf("CreateColors - i, k, color %d %d %d \n",i,k,color);
331 new TColor(color,r,g,b);
332 }
333 // printf("I'm out of case %d \n",k);
334 break;
335 }
336
337 }
338
339}
340
341//_____________________________________________________________________________
342void AliMUONdisplay::DisplayColorScale()
343{
344
345 Int_t i;
346 Int_t color;
347 Float_t xlow, ylow, xup, yup, hs;
348 Float_t x1, y1, x2, y2;
349 x1 = y1 = 0;
350 x2 = y2 = 20;
351
352 gPad->SetFillColor(0);
353 gPad->Clear();
354 gPad->Range(x1,y1,x2,y2);
355
356 TText *text = new TText(0,0,"");
357 text->SetTextFont(61);
358 text->SetTextSize(0.03);
359 text->SetTextAlign(22);
360
361 TBox *box;
362 char label[8];
363//*-* draw colortable boxes
364 hs = (y2-y1)/Float_t(22);
365 xlow=x1+1;
366 xup=x2-9;
367 for (i=0;i<22;i++) {
368 ylow = y1 + hs*(Float_t(i));
369 yup = y1 + hs*(Float_t(i+1));
370 color = 51+i;
371 // Int_t scale=(i+1)*(Int_t)adc_satm/22;
372 // sprintf(label,"%d",scale);
373 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
374 Int_t scale=(Int_t)TMath::Exp(logscale);
375 sprintf(label,"%d",scale);
376 box = new TBox(xlow, ylow, xup, yup);
377 box->SetFillColor(color);
378 box->Draw();
379 text->DrawText(xup+4, 0.5*(ylow+yup),label);
380 }
381}
382
383//______________________________________________________________________________
384Int_t AliMUONdisplay::DistancetoPrimitive(Int_t px, Int_t)
385{
386// Compute distance from point px,py to objects in event
387
388 gPad->SetCursor(kCross);
389
390 if (gPad == fTrigPad) return 9999;
391
392 const Int_t big = 9999;
393 Int_t dist = big;
394 Float_t xmin = gPad->GetX1();
395 Float_t xmax = gPad->GetX2();
396 Float_t dx = 0.02*(xmax - xmin);
397 Float_t x = gPad->AbsPixeltoX(px);
398 if (x < xmin+dx || x > xmax-dx) return dist;
399
400 if (fZoomMode) return 0;
401 else return 7;
402}
403
404//_____________________________________________________________________________
405void AliMUONdisplay::Draw(Option_t *)
406{
407// Display current event
408
409 fPad->cd();
410
411 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
412
413 // Display the event number and title
414 fPad->cd();
415 DrawTitle();
416}
417
418
419//_____________________________________________________________________________
420void AliMUONdisplay::DrawClusters()
421{
422// Draw clusterss for MUON chambers
423
424 Int_t ndigits, digit;
425 TObjArray *points;
426 AliMUONpoints *pm;
427
428 // rmax=fRzone;
429
430 fClustersCuts = 0;
431 points = Points();
432 if (!points) return;
433 ndigits = points->GetEntriesFast();
434 printf("DrawClusters - ndigits %d \n",ndigits);
435 for (digit=0;digit<ndigits;digit++){
436 pm = (AliMUONpoints*)points->UncheckedAt(digit);
437 if (!pm) continue;
438 // Float_t *pxyz;
439 // pxyz=pm->GetP();
440 // printf("DrawClusters - pxyz[0],pxyz[1] %f %f \n",pxyz[0],pxyz[1]);
441 pm->Draw();
442 // Int_t n=pm->GetN();
443 // printf("DrawClusters - n %d \n",n);
444 fClustersCuts +=pm->GetN();
445 }
446}
447
448//_____________________________________________________________________________
449void AliMUONdisplay::DrawHits()
450{
451// Draw hits for MUON chambers
452
453 LoadHits(fChamber);
454
455 Int_t ntracks, track;
456 TObjArray *points;
457 AliMUONpoints *pm;
458
459 fHitsCuts = 0;
460 points = Phits();
461 if (!points) return;
462 ntracks = points->GetEntriesFast();
463 printf("DrawHits - ntracks %d \n",ntracks);
464 for (track=0;track<ntracks;track++) {
465 pm = (AliMUONpoints*)points->UncheckedAt(track);
466 if (!pm) continue;
467 pm->Draw();
468 fHitsCuts += pm->GetN();
469 }
470}
471
472
473//_____________________________________________________________________________
474void AliMUONdisplay::DrawTitle(Option_t *option)
475{
476// Draw the event title
477
478 Float_t xmin = gPad->GetX1();
479 Float_t xmax = gPad->GetX2();
480 Float_t ymin = gPad->GetY1();
481 Float_t ymax = gPad->GetY2();
482 Float_t dx = xmax-xmin;
483 Float_t dy = ymax-ymin;
484
485 if (strlen(option) == 0) {
486 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
487 title->SetBit(kCanDelete);
488 title->SetFillColor(42);
489 title->Draw();
490 char ptitle[100];
491 sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
492 title->AddText(ptitle);
493 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
494 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",nparticles, fHitsCuts,fClustersCuts);
495 title->AddText(ptitle);
496 } else {
497 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
498 label->SetBit(kCanDelete);
499 label->SetFillColor(42);
500 label->Draw();
501 }
502}
503
504//_____________________________________________________________________________
505void AliMUONdisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
506{
507// Draw a view of MUON clusters
508
509 gPad->SetCursor(kWatch);
510 gPad->SetFillColor(1);
511 gPad->Clear();
512
513 Int_t iret;
514 TView *view = new TView(1);
515 Float_t range = fRrange*fRangeSlider->GetMaximum();
516 view->SetRange(-range,-range,-range,range, range, range);
517 fZoomX0[0] = -1;
518 fZoomY0[0] = -1;
519 fZoomX1[0] = 1;
520 fZoomY1[0] = 1;
521 fZooms = 0;
522
523 // Display MUON Chamber Geometry
524 // gAlice->GetGeometry()->Draw("same");
525
526 //add clusters to the pad
527 DrawClusters();
528 DrawHits();
529
530 // add itself to the list (must be last)
531 AppendPad();
532
533 view->SetView(phi, theta, psi, iret);
534}
535
536
537//______________________________________________________________________________
538void AliMUONdisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
539{
540// Execute action corresponding to the mouse event
541
542 static Float_t x0, y0, x1, y1;
543
544 static Int_t pxold, pyold;
545 static Int_t px0, py0;
546 static Int_t linedrawn;
547 Float_t temp;
548
549 if (px == 0 && py == 0) { //when called by sliders
550 if (event == kButton1Up) {
551 Draw();
552 }
553 return;
554 }
555 if (!fZoomMode && gPad->GetView()) {
556 gPad->GetView()->ExecuteRotateView(event, px, py);
557 return;
558 }
559
560 // something to zoom ?
561 gPad->SetCursor(kCross);
562
563 switch (event) {
564
565 case kButton1Down:
566 gGXW->SetLineColor(-1);
567 gPad->TAttLine::Modify(); //Change line attributes only if necessary
568 x0 = gPad->AbsPixeltoX(px);
569 y0 = gPad->AbsPixeltoY(py);
570 px0 = px; py0 = py;
571 pxold = px; pyold = py;
572 linedrawn = 0;
573 return;
574
575 case kButton1Motion:
576 if (linedrawn) gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
577 pxold = px;
578 pyold = py;
579 linedrawn = 1;
580 gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
581 return;
582
583 case kButton1Up:
584 gPad->GetCanvas()->FeedbackMode(kFALSE);
585 if (px == px0) return;
586 if (py == py0) return;
587 x1 = gPad->AbsPixeltoX(px);
588 y1 = gPad->AbsPixeltoY(py);
589
590 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
591 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
592 gPad->Range(x0,y0,x1,y1);
593 if (fZooms < kMAXZOOM-1) {
594 fZooms++;
595 fZoomX0[fZooms] = x0;
596 fZoomY0[fZooms] = y0;
597 fZoomX1[fZooms] = x1;
598 fZoomY1[fZooms] = y1;
599 }
600 gPad->Modified(kTRUE);
601 return;
602 }
603
604}
605
606//___________________________________________
607void AliMUONdisplay::LoadDigits(Int_t chamber, Int_t cathode)
608{
609// Read digits info and store x,y,z info in arrays fPoints
610// Loop on all detectors
611
612 fChamber=chamber;
613 fCathode=cathode;
614
615 ResetPoints();
616
0f439796 617 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 618 AliMUONchamber* iChamber;
619 AliMUONsegmentation* segmentation;
620
621 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
622 if (MUONdigits == 0) return;
623
624 gAlice->ResetDigits();
625 gAlice->TreeD()->GetEvent(cathode);
626 Int_t ndigits = MUONdigits->GetEntriesFast();
627 if (ndigits == 0) return;
628 if (fPoints == 0) fPoints = new TObjArray(ndigits);
629 printf("Found %d digits for cathode %d in chamber %d \n",ndigits,cathode,chamber);
630
631 iChamber = &(MUON->Chamber(chamber-1));
632 printf("LoadPoints - iChamber %p \n",iChamber);
633 segmentation=iChamber->GetSegmentationModel(cathode);
634 printf("LoadPoints - segmentation %p \n",segmentation);
635 Float_t dpx = segmentation->Dpx();
636 Float_t dpy = segmentation->Dpy();
637 printf("LoadPoints - dpx, dpy %f %f \n",dpx,dpy);
638 Float_t zpos=iChamber->ZPosition();
639 printf("LoadPoint - zpos %f \n",zpos);
640 AliMUONdigit *mdig;
641 AliMUONpoints *points = 0;
642 //
643 //loop over all digits and store their position
644 // points = new AliMUONpoints(ndigits);
645 Int_t npoints=1;
646 for (Int_t digit=0;digit<ndigits;digit++) {
647 mdig = (AliMUONdigit*)MUONdigits->UncheckedAt(digit);
648 points = new AliMUONpoints(npoints);
649 fPoints->AddAt(points,digit);
650 Int_t charge=mdig->fSignal;
651 // set the color according to the color scale
652 // Int_t scale=(Int_t)adc_satm/22;
653 // Int_t index=(Int_t)charge/scale;
654 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
655 Int_t color=51+index;
656 if (color>72) color=72;
657 points->SetMarkerColor(color);
658 points->SetMarkerStyle(21);
659 points->SetMarkerSize(0.5);
660 // get the center of the pad - add on x and y half of pad size
661 Float_t xpad, ypad;
662 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
663 points->SetParticle(-1);
664 points->SetHitIndex(-1);
665 points->SetTrackIndex(-1);
666 points->SetDigitIndex(digit);
667 points->SetPoint(0,xpad,ypad,zpos);
668 // Float_t *pxyz;
669 // pxyz=points->GetP();
670 // printf("pxyz[0],pxyz[1],color %f %f %d \n",pxyz[0],pxyz[1],color);
671 // Int_t np=points->GetN();
672 // printf("np %d \n",np);
673 }
674}
675
676
677//___________________________________________
678void AliMUONdisplay::LoadHits(Int_t chamber)
679{
680// Read hits info and store x,y,z info in arrays fPhits
681// Loop on all detectors
682
683 fChamber=chamber;
684
685 ResetPhits();
686
0f439796 687 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 688 AliMUONchamber* iChamber;
689
690 iChamber = &(MUON->Chamber(chamber-1));
691 Float_t zpos=iChamber->ZPosition();
692 printf("LoadHits - zpos %f \n",zpos);
693
694 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
695 printf("ntracks %d\n",ntracks);
696 Int_t ntrks = gAlice->GetNtrack();
697 printf("ntrks %d\n",ntrks);
698
699 if (fPhits == 0) fPhits = new TObjArray(ntracks);
700 // if (fPhits == 0) fPhits = new TObjArray(ntrks);
701
702 TVector *xp = new TVector(10);
703 TVector *yp = new TVector(10);
704 TVector *ptrk = new TVector(10);
705 TVector *phit = new TVector(10);
706 for (Int_t track=0; track<ntracks;track++) {
707 gAlice->ResetHits();
708 gAlice->TreeH()->GetEvent(track);
709 TClonesArray *MUONhits = MUON->Hits();
710 // printf("MUONhits %p\n",MUONhits);
711 if (MUONhits == 0) return;
712 Int_t nhits = MUONhits->GetEntriesFast();
713 if (nhits == 0) continue;
714 // printf("nhits %d \n",nhits);
715 AliMUONhit *mHit;
716 AliMUONpoints *points = 0;
717 // Int_t trko=-99, trk;
718 // points = new AliPoints(nhits);
719 Int_t npoints=0;
720 for (Int_t hit=0;hit<nhits;hit++) {
721 mHit = (AliMUONhit*)MUONhits->UncheckedAt(hit);
722 Int_t nch = mHit->fChamber; // chamber number
723 if (nch != chamber) continue;
724 (*xp)(npoints)=mHit->fX;
725 (*yp)(npoints)=mHit->fY;
726 (*ptrk)(npoints)=Float_t(mHit->GetTrack());
727 (*phit)(npoints)=Float_t(hit);
728 // printf("track, trk %d %d\n",track,mHit->GetTrack());
729 npoints++;
730 }
731 if (npoints == 0) continue;
732 // printf("npoints %d \n",npoints);
733 points = new AliMUONpoints(npoints);
734 for (Int_t p=0;p<npoints;p++) {
735 points->SetMarkerColor(kRed);
736 points->SetMarkerStyle(5);
737 points->SetMarkerSize(1.);
738 points->SetParticle(Int_t((*ptrk)(p)));
739 // Int_t index=points->GetIndex();
740 // printf("index %d \n",index);
741 points->SetHitIndex(Int_t((*phit)(p)));
742 points->SetTrackIndex(track);
743 points->SetDigitIndex(-1);
744 points->SetPoint(p,(*xp)(p),(*yp)(p),zpos);
745 }
746 xp->Zero();
747 yp->Zero();
748 ptrk->Zero();
749 phit->Zero();
750 fPhits->AddAt(points,track);
751 // Int_t np=points->GetN();
752 // printf("np %d \n",np);
753 }
754
755}
756
757//_____________________________________________________________________________
758void AliMUONdisplay::Paint(Option_t *)
759{
760// Paint miscellaneous items
761
762}
763
764//_____________________________________________________________________________
765void AliMUONdisplay::SetPickMode()
766{
767 fZoomMode = 0;
768
769 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
770 fTrigPad->Modified();
771}
772
773//_____________________________________________________________________________
774void AliMUONdisplay::SetZoomMode()
775{
776 fZoomMode = 1;
777
778 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
779 fTrigPad->Modified();
780}
781
782//_____________________________________________________________________________
783void AliMUONdisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
784{
785// Set chamber and cathode number
786 fChamber = chamber;
787 fCathode = cathode;
788
789 // Pad();
790 // printf("SetChamberAndCathode - fPad %p \n",fPad);
791 printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
792 if (!fPad) return;
793 fPad->Clear();
794 LoadDigits(chamber,cathode);
795 Draw();
796}
797
798//_____________________________________________________________________________
799void AliMUONdisplay::SetRange(Float_t rrange, Float_t zrange)
800{
801// Set view range along R and Z
802 fRrange = rrange;
803 fZrange = zrange;
804
805 if (!fPad) return;
806 fPad->Clear();
807 Draw();
808}
809
810//_____________________________________________________________________________
811void AliMUONdisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
812{
813// change viewing angles for current event
814
815 fPad->cd();
816 fPhi = phi;
817 fTheta = theta;
818 fPsi = psi;
819 Int_t iret = 0;
820
821 TView *view = gPad->GetView();
822 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
823 else Draw();
824
825 gPad->Modified();
826}
827
828//_____________________________________________________________________________
829void AliMUONdisplay::ShowNextEvent(Int_t delta)
830{
831// Display (current event_number+delta)
832// delta = 1 shown next event
833// delta = -1 show previous event
834
835 if (delta) {
836 gAlice->Clear();
837 Int_t current_event = gAlice->GetHeader()->GetEvent();
838 Int_t new_event = current_event + delta;
839 gAlice->GetEvent(new_event);
840 if (!gAlice->TreeD()) return;
841 }
842 LoadDigits(fChamber,fCathode);
843 fPad->cd();
844 Draw();
845}
846
847//______________________________________________________________________________
848void AliMUONdisplay::UnZoom()
849{
850 if (fZooms <= 0) return;
851 fZooms--;
852 TPad *pad = (TPad*)gPad->GetPadSave();
853 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
854 pad->Modified();
855}
856
857//_____________________________________________________________________________
858void AliMUONdisplay::ResetPoints()
859{
860 //
861 // Reset array of points
862 //
863 if (fPoints) {
864 fPoints->Delete();
865 delete fPoints;
866 fPoints = 0;
867 }
868}
869//_____________________________________________________________________________
870void AliMUONdisplay::ResetPhits()
871{
872 //
873 // Reset array of points
874 //
875 if (fPhits) {
876 fPhits->Delete();
877 delete fPhits;
878 fPhits = 0;
879 }
880}