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