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