]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDisplay.cxx
Fix problems in interpretation of GROUPPATH
[u/mrichter/AliRoot.git] / STEER / AliDisplay.cxx
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 Revision 1.5  1999/09/29 09:24:29  fca
19 Introduction of the Copyright and cvs Log
20
21 */
22
23
24 //////////////////////////////////////////////////////////////////////////
25 //                                                                      //
26 // AliDisplay                                                           //
27 //                                                                      //
28 // Utility class to display ALICE outline, tracks, hits,..              //
29 //                                                                      //
30 //////////////////////////////////////////////////////////////////////////
31
32 #include <TROOT.h>
33 #include <TTree.h>
34 #include <TButton.h>
35 #include <TCanvas.h>
36 #include <TView.h>
37 #include <TText.h>
38 #include <TPolyMarker3D.h>
39 #include <TPaveLabel.h>
40 #include <TPaveText.h>
41 #include <TList.h>
42 #include <TDiamond.h>
43 #include <TNode.h>
44 #include <TArc.h>
45 #include <TTUBE.h>
46 #include <TSlider.h>
47 #include <TSliderBox.h>
48 #include <TGaxis.h>
49 #include <TVirtualX.h>
50 #include <TMath.h>
51 #include <X3DBuffer.h>
52
53 #include "AliRun.h"
54 #include "AliDetector.h"
55 #include "AliDisplay.h"
56 #include "AliPoints.h"
57 #include "TParticle.h"
58
59 const Float_t ptcutmax  = 2;
60 const Float_t etacutmax = 1.5;
61
62 ClassImp(AliDisplay)
63
64
65 //_____________________________________________________________________________
66 AliDisplay::AliDisplay()
67 {
68    fCanvas = 0;
69 }
70
71 //_____________________________________________________________________________
72 AliDisplay::AliDisplay(Int_t size)
73 {
74 // Create an event display object.
75 // A canvas named "edisplay" is created with a vertical size in pixels
76 //
77 //    A QUICK Overview of the Event Display functions
78 //    ===============================================
79 //
80 //  The event display can ve invoked by executing the macro "display.C"
81 // A canvas like in the picture below will appear.
82 //
83 //  On the left side of the canvas, the following buttons appear:
84 //   *Next*       to move to the next event
85 //   *Previous*   to move to the previous event
86 //   *Top View*   to display a top view of the current event
87 //   *Side View*  to display a side view of the current event
88 //   *Front View* to display a front view of the current event
89 //   *All Views*  to display front/side/top/30-30 views of the current event
90 //   *OpenGL*     to use OpenGl to view the current event.
91 //                Note that OpenGL cannot be used across the network.
92 //                Before using OpenGL, load the GL libraries
93 //                by executing the macro GL.C (in $ROOTSYS/macros/GL.C.
94 //                Once in GL, click the HELP button of the GL canvas.
95 //   *X3D*        to use X3D to view the current event (Unix only).
96 //                Once in X3D, type M to see the list of all possible options.
97 //                for example type J to zoom, K to unzoom
98 //                use the mouse to rotate.
99 //   *Pick*       Select this option to be able to point on a track with the
100 //                mouse. Once on the track, use the right button to select
101 //                an action. For example, select SetMarkerAttributes to
102 //                change the marker type/color/size for the track.
103 //   *Zoom*       Select this option (default) if you want to zoom.
104 //                To zoom, simply select the selected area with the left button.
105 //   *UnZoom*     To revert to the previous picture size.
106 //
107 //   slider R     On the left side, the vertical slider can be used to
108 //                set the default picture size.
109 //   slider pcut  At the top of the canvas, a slider can be used to change
110 //                the momentum cut (or range) to display tracks.
111 //   slider eta   On the right side of the canvas, a vertical slider can be used
112 //                to specify a rapidity range for the tracks.
113 //
114 //    When you are in Zoom mode, you can click on the black part of the canvas
115 //  to select special options with the right mouse button.
116 //  This will display a pop-up menu with items like:
117 //     *Disable detector* 
118 //     *Enable detector*, etc.
119 //  For example select "Disable detector". You get a dialog box.
120 //  Diable detector TRD for example.
121 //
122 //  When you are in pick mode, you can "Inspect" the object pointed by the mouse.
123 //  When you are on a track, select the menu item "InspectParticle"
124 //  to display the current particle attributes.
125 //
126 //  You can activate the Root browser by selecting the Inspect menu
127 //  in the canvas tool bar menu. Then select "Start Browser"
128 //  This will open a new canvas with the browser. At this point, you may want
129 //  to display some histograms (from the Trees). Go to the "File" menu
130 //  of the browser and click on "New canvas".
131 //  In the browser, click on item "ROOT files" in the left pane.
132 //  Click on galice.root.
133 //  Click on TH
134 //  Click on TPC for example
135 //  Click on any variable (eg TPC.fX) to histogram the variable.
136 //
137 //   If you are lost, you can click on HELP in any Root canvas or browser.
138 //Begin_Html
139 /*
140 <img src="picts/alidisplay.gif">
141 */
142 //End_Html
143    
144    fPad = 0;
145    gAlice->SetDisplay(this);
146    
147    // Initialize display default parameters
148    SetRange();
149    SetPTcut();
150
151    // Set front view by default
152    fTheta = 0;
153    fPhi   = -90;
154    fPsi   = 0;
155    fDrawAllViews  = kFALSE;
156    fDrawHits      = kTRUE;
157    fDrawParticles = kTRUE;
158    fZoomMode      = 1;
159    fZooms         = 0;
160    fHitsCuts      = 0;
161    
162    // Create display canvas
163    Int_t ysize = size;
164    if (ysize < 100) ysize = 750;
165    Int_t xsize = Int_t(size*830./ysize);
166    fCanvas = new TCanvas("Canvas", "ALICE Event Display",14,47,xsize,ysize);
167    fCanvas->SetEditable(kFALSE);
168    fCanvas->ToggleEventStatus();
169    
170    // Create main display pad
171    fPad = new TPad("viewpad", "Alice display",0.15,0,0.97,0.96);
172    fPad->Draw();
173    fPad->Modified();
174    fPad->SetFillColor(1);
175    fPad->SetBorderSize(2);
176
177    // Create user interface control pad
178    DisplayButtons();
179    fCanvas->cd();
180
181    // Create Range and mode pad
182    Float_t dxtr     = 0.15;
183    Float_t dytr     = 0.45;
184    fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
185    fTrigPad->Draw();
186    fTrigPad->cd();
187    fTrigPad->SetFillColor(22);
188    fTrigPad->SetBorderSize(2);
189    fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
190    fRangeSlider->SetObject(this);
191    char pickmode[] = "gAlice->Display()->SetPickMode()";
192    Float_t db = 0.09;
193    fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
194    fPickButton->SetFillColor(38);
195    fPickButton->Draw();
196    char zoommode[] = "gAlice->Display()->SetZoomMode()";
197    fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
198    fZoomButton->SetFillColor(38);
199    fZoomButton->Draw();
200    fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
201    fArcButton->SetFillColor(kGreen);
202    fArcButton->Draw();
203    char butUnzoom[] = "gAlice->Display()->UnZoom()";
204    TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
205    button->SetFillColor(38);
206    button->Draw();
207    AppendPad(); // append display object as last object to force selection
208
209    // Create momentum cut slider pad
210    fCanvas->cd();
211    fCutPad = new TPad("cutSlider", "pcut slider pad",dxtr,.96,1,1);
212    fCutPad->Draw();
213    fCutPad->cd();
214    fCutPad->SetFillColor(22);
215    fCutPad->SetBorderSize(2);
216    fCutSlider   = new TSlider("pcut","Momentum cut",0,0,1,1);
217    fCutSlider->SetRange(fPTcut/ptcutmax,1);
218    fCutSlider->SetObject(this);
219    fCutSlider->SetFillColor(45);
220    TSliderBox *sbox = (TSliderBox*)fCutSlider->GetListOfPrimitives()->First();
221    sbox->SetFillColor(46);
222    fCutSlider->cd();
223    TGaxis *cutaxis = new TGaxis(0.02,0.8,0.98,0.8,0,ptcutmax,510,"");
224    cutaxis->SetLabelSize(0.5);
225    cutaxis->SetTitleSize(0.6);
226    cutaxis->SetTitleOffset(0.5);
227    cutaxis->SetTitle("pcut .  ");
228    fCutSlider->GetListOfPrimitives()->AddFirst(cutaxis);
229
230       // Create rapidity cut slider pad
231    fCanvas->cd();
232    fEtaPad = new TPad("EtaSlider", "Eta slider pad",0.97,0,1,0.96);
233    fEtaPad->Draw();
234    fEtaPad->cd();
235    fEtaPad->SetFillColor(22);
236    fEtaPad->SetBorderSize(2);
237    fEtaSlider   = new TSlider("etacut","Rapidity cut",0,0,1,1);
238    fEtaSlider->SetObject(this);
239    fEtaSlider->SetFillColor(45);
240    TSliderBox *sbox2 = (TSliderBox*)fEtaSlider->GetListOfPrimitives()->First();
241    sbox2->SetFillColor(46);
242    fEtaSlider->cd();
243    TGaxis *etaaxis = new TGaxis(0.9,0.02,0.9,0.98,-etacutmax,etacutmax,510,"");
244    etaaxis->SetLabelSize(0.5);
245    etaaxis->SetTitleSize(0.6);
246    etaaxis->SetTitleOffset(0.2);
247    cutaxis->SetTitle("Etacut .  ");
248    fEtaSlider->GetListOfPrimitives()->AddFirst(etaaxis);
249    fCanvas->cd();
250    
251
252    fCanvas->cd();
253    fCanvas->Update();
254 }
255
256
257 //_____________________________________________________________________________
258 AliDisplay::~AliDisplay()
259 {
260 }
261
262 //_____________________________________________________________________________
263 void AliDisplay::Clear(Option_t *)
264 {
265 //    Delete graphics temporary objects
266 }
267
268 //----------------------------------------------------------------------------
269 void AliDisplay::ShowTrack(Int_t idx) {
270    AliDetector *TPC=(AliDetector*)gAlice->GetModule("TPC");
271    TObjArray *points=TPC->Points();
272    int ntracks=points->GetEntriesFast();
273    for (int track=0;track<ntracks;track++) {
274       AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
275       if (!pm) continue;
276       if (idx == pm->GetIndex()) {
277          pm->SetMarkerColor(2);
278          pm->SetMarkerStyle(22);
279          pm->Draw("same");
280 //       fPad->Update();
281 //       fPad->Modified();
282          TClonesArray *particles=gAlice->Particles();
283          TParticle *p = (TParticle*)particles->UncheckedAt(idx);
284          printf("\nTrack index %d\n",idx);
285          printf("Particle ID %d\n",p->GetPdgCode());
286          printf("Parent %d\n",p->GetFirstMother());
287          printf("First child %d\n",p->GetFirstDaughter());
288          printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
289          return;
290       }
291    }
292 }
293
294 //----------------------------------------------------------------------------
295 void AliDisplay::HideTrack(Int_t idx) {
296    AliDetector *TPC=(AliDetector*)gAlice->GetModule("TPC");
297    TObjArray *points=TPC->Points();
298    int ntracks=points->GetEntriesFast();
299    for (int track=0;track<ntracks;track++) {
300       AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
301       if (!pm) continue;
302       if (idx == pm->GetIndex()) {
303          pm->SetMarkerColor(5);
304          pm->SetMarkerStyle(1);
305          pm->Draw("same");
306 //       fPad->Update();
307 //       fPad->Modified();
308          return;
309       }
310    }
311 }
312
313 //_____________________________________________________________________________
314 void AliDisplay::DisableDetector(const char *name)
315 {
316 //    Disable detector name from graphics views
317    
318    AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
319    if (!module) return;
320    module->Disable();
321    Draw();
322 }
323
324 //_____________________________________________________________________________
325 void AliDisplay::DisplayButtons()
326 {
327 //    Create the user interface buttons
328
329    fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
330    fButtons->Draw();
331    fButtons->SetFillColor(38);
332    fButtons->SetBorderSize(2);
333    fButtons->cd();
334
335    Int_t butcolor = 33;
336    Float_t dbutton = 0.08;
337    Float_t y  = 0.96;
338    Float_t dy = 0.014;
339    Float_t x0 = 0.05;
340    Float_t x1 = 0.95;
341
342    TButton *button;
343    char but1[] = "gAlice->Display()->ShowNextEvent(1)";
344    button = new TButton("Next",but1,x0,y-dbutton,x1,y);
345    button->SetFillColor(38);
346    button->Draw();
347
348    y -= dbutton +dy;
349    char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
350    button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
351    button->SetFillColor(38);
352    button->Draw();
353
354    y -= dbutton +dy;
355    char but3[] = "gAlice->Display()->SetView(90,-90,90)";
356    button = new TButton("Top View",but3,x0,y-dbutton,x1,y);
357    button->SetFillColor(butcolor);
358    button->Draw();
359
360    y -= dbutton +dy;
361    char but4[] = "gAlice->Display()->SetView(90,0,-90)";
362    button = new TButton("Side View",but4,x0,y-dbutton,x1,y);
363    button->SetFillColor(butcolor);
364    button->Draw();
365
366    y -= dbutton +dy;
367    char but5[] = "gAlice->Display()->SetView(0,-90,0)";
368    button = new TButton("Front View",but5,x0,y-dbutton,x1,y);
369    button->SetFillColor(butcolor);
370    button->Draw();
371
372    y -= dbutton +dy;
373    char but6[] = "gAlice->Display()->DrawAllViews()";
374    button = new TButton("All Views",but6,x0,y-dbutton,x1,y);
375    button->SetFillColor(butcolor);
376    button->Draw();
377
378    y -= dbutton +dy;
379    char but7[] = "gAlice->Display()->DrawViewGL()";
380    button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
381    button->SetFillColor(38);
382    button->Draw();
383
384    y -= dbutton +dy;
385    char but8[] = "gAlice->Display()->DrawViewX3D()";
386    button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
387    button->SetFillColor(38);
388    button->Draw();
389
390    // display logo
391    TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
392    diamond->SetFillColor(50);
393    diamond->SetTextAlign(22);
394    diamond->SetTextColor(5);
395    diamond->SetTextSize(0.11);
396    diamond->Draw();
397    diamond->AddText(".. ");
398    diamond->AddText("ROOT");
399    diamond->AddText("ALICE");
400    diamond->AddText("... ");
401    diamond->AddText(" ");
402 }
403
404 //______________________________________________________________________________
405 Int_t AliDisplay::DistancetoPrimitive(Int_t px, Int_t)
406 {
407 // Compute distance from point px,py to objects in event
408
409    gPad->SetCursor(kCross);
410    
411    if (gPad == fTrigPad) return 9999;
412    if (gPad == fCutPad)  return 9999;
413    if (gPad == fEtaPad)  return 9999;
414
415    const Int_t big = 9999;
416    Int_t dist   = big;
417    Float_t xmin = gPad->GetX1();
418    Float_t xmax = gPad->GetX2();
419    Float_t dx   = 0.02*(xmax - xmin);
420    Float_t x    = gPad->AbsPixeltoX(px);
421    if (x < xmin+dx || x > xmax-dx) return dist;
422
423    if (fZoomMode) return 0;
424    else           return 7;
425 }
426
427 //_____________________________________________________________________________
428 void AliDisplay::Draw(Option_t *)
429 {
430 //    Display current event
431
432    if (fDrawAllViews) {
433       DrawAllViews();
434       return;
435    }
436
437    fPad->cd();
438
439    DrawView(fTheta, fPhi, fPsi);
440
441    // Display the event number and title
442    fPad->cd();
443    DrawTitle();
444 }
445
446 //_____________________________________________________________________________
447 void AliDisplay::DrawAllViews()
448 {
449 //    Draw front,top,side and 30 deg views
450
451    fDrawAllViews = kTRUE;
452    fPad->cd();
453    fPad->SetFillColor(15);
454    fPad->Clear();
455    fPad->Divide(2,2);
456
457    // draw 30 deg view
458    fPad->cd(1);
459    DrawView(30, 30, 0);
460    DrawTitle();
461
462    // draw front view
463    fPad->cd(2);
464    DrawView(0, -90,0);
465    DrawTitle("Front");
466
467    // draw top view
468    fPad->cd(3);
469    DrawView(90, -90, 90);
470    DrawTitle("Top");
471
472    // draw side view
473    fPad->cd(4);
474    DrawView(90, 0, -90);
475    DrawTitle("Side");
476
477    fPad->cd(2);
478 }
479
480 //_____________________________________________________________________________
481 void AliDisplay::DrawHits()
482 {
483 //    Draw hits for all ALICE detectors
484
485    Float_t cutmin, cutmax, etamin, etamax, pmom, smin, smax, eta, theta, r;
486    Float_t *pxyz;
487    Int_t ntracks,track;
488    TParticle *particle;
489    TObjArray *points;
490    AliPoints *pm;
491       
492    //Get cut slider
493    smax   = fCutSlider->GetMaximum();
494    smin   = fCutSlider->GetMinimum();
495    cutmin = ptcutmax*smin;
496    if (smax < 0.98) cutmax = ptcutmax*smax;
497    else             cutmax = 100000;
498    
499    //Get eta slider
500    smax   = fEtaSlider->GetMaximum();
501    smin   = fEtaSlider->GetMinimum();
502    etamin = etacutmax*(2*smin-1);
503    etamax = etacutmax*(2*smax-1);
504    if (smin < 0.02) etamin = -1000;
505    if (smax > 0.98) etamax =  1000;
506       
507    TIter next(gAlice->Modules());
508    AliModule *module;
509    fHitsCuts = 0;
510    while((module = (AliModule*)next())) {
511       if (!module->IsActive()) continue;
512       points = module->Points();
513       if (!points) continue;
514       ntracks = points->GetEntriesFast();
515       for (track=0;track<ntracks;track++) {
516          pm = (AliPoints*)points->UncheckedAt(track);
517          if (!pm) continue;
518          particle = pm->GetParticle();
519          if (!particle) continue;
520          pmom = particle->P();
521          if (pmom < cutmin) continue;
522          if (pmom > cutmax) continue;
523          // as a first approximation, take eta of first point
524          pxyz  = pm->GetP();
525          r     = TMath::Sqrt(pxyz[0]*pxyz[0] + pxyz[1]*pxyz[1]);
526          theta = TMath::ATan2(r,TMath::Abs(pxyz[2]));
527          if(theta) eta = -TMath::Log(TMath::Tan(0.5*theta)); else eta = 1e10;
528          if (pxyz[2] < 0) eta = -eta;
529          if (eta < etamin || eta > etamax) continue;
530          pm->Draw();
531          fHitsCuts += pm->GetN();
532       }
533    }
534 }
535
536 //_____________________________________________________________________________
537 void AliDisplay::DrawTitle(Option_t *option)
538 {
539 //    Draw the event title
540
541    Float_t xmin = gPad->GetX1();
542    Float_t xmax = gPad->GetX2();
543    Float_t ymin = gPad->GetY1();
544    Float_t ymax = gPad->GetY2();
545    Float_t dx   = xmax-xmin;
546    Float_t dy   = ymax-ymin;
547
548    if (strlen(option) == 0) {
549       TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
550       title->SetBit(kCanDelete);
551       title->SetFillColor(42);
552       title->Draw();
553       char ptitle[100];
554       sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
555       title->AddText(ptitle);
556       Int_t nparticles = gAlice->Particles()->GetEntriesFast();
557       sprintf(ptitle,"Nparticles = %d  Nhits = %d",nparticles, fHitsCuts);
558       title->AddText(ptitle);
559    } else {
560       TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
561       label->SetBit(kCanDelete);
562       label->SetFillColor(42);
563       label->Draw();
564    }
565 }
566
567 //_____________________________________________________________________________
568 void AliDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
569 {
570 //    Draw a view of ALICE
571
572    gPad->SetCursor(kWatch);
573    gPad->SetFillColor(1);
574    gPad->Clear();
575
576    Int_t iret;
577    TView *view = new TView(1);
578    Float_t range = fRrange*fRangeSlider->GetMaximum();
579    view->SetRange(-range,-range,-range,range, range, range);
580    fZoomX0[0] = -1;
581    fZoomY0[0] = -1;
582    fZoomX1[0] =  1;
583    fZoomY1[0] =  1;
584    fZooms = 0;
585    
586    // Display Alice Geometry
587    gAlice->GetGeometry()->Draw("same");
588    
589    //Loop on all detectors to add their products to the pad
590    DrawHits();
591
592     // add itself to the list (must be last)
593    AppendPad();
594    
595    view->SetView(phi, theta, psi, iret);
596 }
597
598 //_____________________________________________________________________________
599 void AliDisplay::DrawViewGL()
600 {
601 //    Draw current view using OPENGL
602
603    TPad *pad = (TPad*)gPad->GetPadSave();
604    pad->cd();
605    TView *view = pad->GetView();
606    if (!view) return;
607    pad->x3d("OPENGL");
608 }
609
610 //_____________________________________________________________________________
611 void AliDisplay::DrawViewX3D()
612 {
613 //    Draw current view using X3D
614
615    TPad *pad = (TPad*)gPad->GetPadSave();
616    pad->cd();
617    TView *view = pad->GetView();
618    if (!view) return;
619    pad->x3d();
620 }
621
622 //_____________________________________________________________________________
623 void AliDisplay::EnableDetector(const char *name)
624 {
625 //    Enable detector name in graphics views
626    
627    AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
628    if (!module) return;
629    module->Enable();
630    Draw();
631 }
632
633 //______________________________________________________________________________
634 void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
635 {
636 //  Execute action corresponding to the mouse event
637
638    static Float_t x0, y0, x1, y1;
639
640    static Int_t pxold, pyold;
641    static Int_t px0, py0;
642    static Int_t linedrawn;
643    Float_t temp;
644
645    if (px == 0 && py == 0) { //when called by sliders
646       if (event == kButton1Up) {
647          Draw();
648       }
649       return;
650    }
651    if (!fZoomMode && gPad->GetView()) {
652       gPad->GetView()->ExecuteRotateView(event, px, py);
653       return;
654    }
655
656    // something to zoom ?
657 //   fPad->SetCursor(kCross);
658    gPad->SetCursor(kCross);
659    
660    switch (event) {
661
662    case kButton1Down:
663       gVirtualX->SetLineColor(-1);
664       gPad->TAttLine::Modify();  //Change line attributes only if necessary
665       x0 = gPad->AbsPixeltoX(px);
666       y0 = gPad->AbsPixeltoY(py);
667       px0   = px; py0   = py;
668       pxold = px; pyold = py;
669       linedrawn = 0;
670       return;
671
672    case kButton1Motion:
673       if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
674       pxold = px;
675       pyold = py;
676       linedrawn = 1;
677       gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
678       return;
679
680    case kButton1Up:
681       gPad->GetCanvas()->FeedbackMode(kFALSE);
682       if (px == px0) return;
683       if (py == py0) return;
684       x1 = gPad->AbsPixeltoX(px);
685       y1 = gPad->AbsPixeltoY(py);
686
687       if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
688       if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
689       gPad->Range(x0,y0,x1,y1);
690       if (fZooms < kMAXZOOMS-1) {
691          fZooms++;
692          fZoomX0[fZooms] = x0;
693          fZoomY0[fZooms] = y0;
694          fZoomX1[fZooms] = x1;
695          fZoomY1[fZooms] = y1;
696       }
697       gPad->Modified(kTRUE);
698       return;
699    }
700
701 }
702  
703 //___________________________________________
704 void AliDisplay::LoadPoints()
705 {
706 // Read hits info and store x,y,z info in arrays fPoints
707 // Loop on all detectors
708  
709    gAlice->ResetPoints();
710    TIter next(gAlice->Modules());
711    AliModule *module;
712    Int_t ntracks = gAlice->GetNtrack();
713    for (Int_t track=0; track<ntracks;track++) {
714       gAlice->ResetHits();
715       gAlice->TreeH()->GetEvent(track);
716       while((module = (AliModule*)next())) {
717          module->LoadPoints(track);
718       }
719       next.Reset();
720    }
721 }
722
723 //_____________________________________________________________________________
724 void AliDisplay::Paint(Option_t *)
725 {
726 //    Paint miscellaneous items
727
728 }
729
730 //_____________________________________________________________________________
731 void AliDisplay::SetPickMode()
732 {
733    fZoomMode = 0;
734
735    fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
736    fTrigPad->Modified();
737 }
738
739 //_____________________________________________________________________________
740 void AliDisplay::SetZoomMode()
741 {
742    fZoomMode = 1;
743
744    fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
745    fTrigPad->Modified();
746 }
747
748 //_____________________________________________________________________________
749 void AliDisplay::SetPTcut(Float_t ptcut)
750 {
751    fPTcut = ptcut;
752
753    if (!fPad) return;
754    fPad->Clear();
755    Draw();
756 }
757
758 //_____________________________________________________________________________
759 void AliDisplay::SetRange(Float_t rrange, Float_t zrange)
760 {
761 // Set view range along R and Z
762    fRrange = rrange;
763    fZrange = zrange;
764
765    if (!fPad) return;
766    fPad->Clear();
767    Draw();
768 }
769    
770 //_____________________________________________________________________________
771 void AliDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
772 {
773 //  change viewing angles for current event
774
775    fPad->cd();
776    fDrawAllViews = kFALSE;
777    fPhi   = phi;
778    fTheta = theta;
779    fPsi   = psi;
780    Int_t iret = 0;
781
782    TView *view = gPad->GetView();
783    if (view) view->SetView(fPhi, fTheta, fPsi, iret);
784    else      Draw();
785
786    gPad->Modified();
787 }
788
789 //_____________________________________________________________________________
790 void AliDisplay::ShowNextEvent(Int_t delta)
791 {
792 //  Display (current event_number+delta)
793 //    delta =  1  shown next event
794 //    delta = -1 show previous event
795
796   if (delta) {
797      gAlice->Clear();
798      Int_t current_event = gAlice->GetHeader()->GetEvent();
799      Int_t new_event     = current_event + delta;
800      gAlice->GetEvent(new_event);
801      if (!gAlice->TreeH()) return; 
802    }
803   LoadPoints();
804   fPad->cd(); 
805   Draw();
806 }
807
808 //______________________________________________________________________________
809 void AliDisplay::UnZoom()
810 {
811    if (fZooms <= 0) return;
812    fZooms--;
813    TPad *pad = (TPad*)gPad->GetPadSave();
814    pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
815    pad->Modified();
816 }