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