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