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