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