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