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