]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDisplay.cxx
Making AliDCSValue sortable (Vladimir)
[u/mrichter/AliRoot.git] / STEER / AliDisplay.cxx
index 2caea0bf73986eec0ff6c6786549311b44e09ff3..8fdb111dc311402cae84499f16ebed023e47b145 100644 (file)
@@ -1,3 +1,19 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
 
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
 //                                                                      //
 //////////////////////////////////////////////////////////////////////////
 
-#include <TROOT.h>
-#include <TTree.h>
+#include <RVersion.h>
+#include <TArc.h>
 #include <TButton.h>
 #include <TCanvas.h>
-#include <TView.h>
-#include <TText.h>
-#include <TPolyMarker3D.h>
+#include <TDiamond.h>
+#include <TGaxis.h>
+#include <TMath.h>
 #include <TPaveLabel.h>
 #include <TPaveText.h>
-#include <TList.h>
-#include <TDiamond.h>
-#include <TNode.h>
-#include <TArc.h>
-#include <TTUBE.h>
 #include <TSlider.h>
 #include <TSliderBox.h>
-#include <TGaxis.h>
-#include <TGXW.h>
-#include <TMath.h>
-#include <X3DBuffer.h>
+//#include <TTree.h>
+#if ROOT_VERSION_CODE>= 331523
+#include <TView3D.h>
+#else
+#include <TView.h>
+#endif
+#include <TVirtualX.h>
 
-#include "AliRun.h"
+#include "AliLog.h"
 #include "AliDetector.h"
 #include "AliDisplay.h"
+#include "AliHeader.h"
 #include "AliPoints.h"
-#include "GParticle.h"
+#include "AliRun.h"
+#include "AliStack.h"
+#include "TGeometry.h"
+#include "TParticle.h"
+#include "AliMC.h"
+
+const Float_t AliDisplay::fgkPtCutMax  = 2;
+const Float_t AliDisplay::fgkEtaCutMax = 1.5;
+const Int_t   AliDisplay::fgkMaxZooms = 20;
 
-const Float_t ptcutmax  = 2;
-const Float_t etacutmax = 1.5;
 
 ClassImp(AliDisplay)
 
 
-//_____________________________________________________________________________
-AliDisplay::AliDisplay()
+//_______________________________________________________________________
+AliDisplay::AliDisplay():
+  fZoomMode(0),
+  fDrawAllViews(0),
+  fDrawParticles(0),
+  fDrawHits(0),
+  fPTcut(0),
+  fTheta(0),
+  fPhi(0),
+  fPsi(0),
+  fRrange(0),
+  fZrange(0),
+  fZooms(0),
+  fHitsCuts(0),
+  fCanvas(0),
+  fTrigPad(0),
+  fCutPad(0),
+  fEtaPad(0),
+  fButtons(0),
+  fPad(0),
+  fCutSlider(0),
+  fEtaSlider(0),
+  fRangeSlider(0),
+  fPickButton(0),
+  fZoomButton(0),
+  fArcButton(0),
+  fFruits(0),
+  fTracksToDisplay(0),
+  fNTracksToDisplay(0)
 {
-   fCanvas = 0;
+  //
+  // Default constructor
+  //
 }
 
 //_____________________________________________________________________________
-AliDisplay::AliDisplay(Int_t size)
+AliDisplay::AliDisplay(Int_t size):
+  fZoomMode(1),
+  fDrawAllViews(kFALSE),
+  fDrawParticles(kTRUE),
+  fDrawHits(kTRUE),
+  fPTcut(0),
+  fTheta(0),
+  fPhi(-90),
+  fPsi(0),
+  fRrange(0),
+  fZrange(0),
+  fZooms(1),
+  fHitsCuts(0),
+  fCanvas(0),
+  fTrigPad(0),
+  fCutPad(0),
+  fEtaPad(0),
+  fButtons(0),
+  fPad(0),
+  fCutSlider(0),
+  fEtaSlider(0),
+  fRangeSlider(0),
+  fPickButton(0),
+  fZoomButton(0),
+  fArcButton(0),
+  fFruits(0),
+  fTracksToDisplay(0),
+  fNTracksToDisplay(0)
 {
 // Create an event display object.
 // A canvas named "edisplay" is created with a vertical size in pixels
@@ -115,126 +192,155 @@ AliDisplay::AliDisplay(Int_t size)
 //   If you are lost, you can click on HELP in any Root canvas or browser.
 //Begin_Html
 /*
-<img src="gif/alidisplay.gif">
+<img src="picts/alidisplay.gif">
 */
 //End_Html
    
-   fPad = 0;
-   gAlice->SetDisplay(this);
-   
-   // Initialize display default parameters
-   SetRange();
-   SetPTcut();
-
-   // Set front view by default
-   fTheta = 0;
-   fPhi   = -90;
-   fPsi   = 0;
-   fDrawAllViews  = kFALSE;
-   fDrawHits      = kTRUE;
-   fDrawParticles = kTRUE;
-   fZoomMode      = 1;
-   fZooms         = 0;
-   fHitsCuts      = 0;
-   
-   // Create display canvas
-   Int_t ysize = size;
-   if (ysize < 100) ysize = 750;
-   Int_t xsize = Int_t(size*830./ysize);
-   fCanvas = new TCanvas("Canvas", "ALICE Event Display",14,47,xsize,ysize);
-   fCanvas->SetEditable(kIsNotEditable);
-   fCanvas->ToggleEventStatus();
-   
-   // Create main display pad
-   fPad = new TPad("viewpad", "Alice display",0.15,0,0.97,0.96);
-   fPad->Draw();
-   fPad->Modified();
-   fPad->SetFillColor(1);
-   fPad->SetBorderSize(2);
-
-   // Create user interface control pad
-   DisplayButtons();
-   fCanvas->cd();
-
-   // Create Range and mode pad
-   Float_t dxtr     = 0.15;
-   Float_t dytr     = 0.45;
-   fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
-   fTrigPad->Draw();
-   fTrigPad->cd();
-   fTrigPad->SetFillColor(22);
-   fTrigPad->SetBorderSize(2);
-   fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
-   fRangeSlider->SetObject(this);
-   char pickmode[] = "gAlice->Display()->SetPickMode()";
-   Float_t db = 0.09;
-   fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
-   fPickButton->SetFillColor(38);
-   fPickButton->Draw();
-   char zoommode[] = "gAlice->Display()->SetZoomMode()";
-   fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
-   fZoomButton->SetFillColor(38);
-   fZoomButton->Draw();
-   fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
-   fArcButton->SetFillColor(kGreen);
-   fArcButton->Draw();
-   char butUnzoom[] = "gAlice->Display()->UnZoom()";
-   TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
-   button->SetFillColor(38);
-   button->Draw();
-   AppendPad(); // append display object as last object to force selection
-
-   // Create momentum cut slider pad
-   fCanvas->cd();
-   fCutPad = new TPad("cutSlider", "pcut slider pad",dxtr,.96,1,1);
-   fCutPad->Draw();
-   fCutPad->cd();
-   fCutPad->SetFillColor(22);
-   fCutPad->SetBorderSize(2);
-   fCutSlider   = new TSlider("pcut","Momentum cut",0,0,1,1);
-   fCutSlider->SetRange(fPTcut/ptcutmax,1);
-   fCutSlider->SetObject(this);
-   fCutSlider->SetFillColor(45);
-   TSliderBox *sbox = (TSliderBox*)fCutSlider->GetListOfPrimitives()->First();
-   sbox->SetFillColor(46);
-   fCutSlider->cd();
-   TGaxis *cutaxis = new TGaxis(0.02,0.8,0.98,0.8,0,ptcutmax,510,"");
-   cutaxis->SetLabelSize(0.5);
-   cutaxis->SetTitleSize(0.6);
-   cutaxis->SetTitleOffset(0.5);
-   cutaxis->SetTitle("pcut .  ");
-   fCutSlider->GetListOfPrimitives()->AddFirst(cutaxis);
-
-      // Create rapidity cut slider pad
-   fCanvas->cd();
-   fEtaPad = new TPad("EtaSlider", "Eta slider pad",0.97,0,1,0.96);
-   fEtaPad->Draw();
-   fEtaPad->cd();
-   fEtaPad->SetFillColor(22);
-   fEtaPad->SetBorderSize(2);
-   fEtaSlider   = new TSlider("etacut","Rapidity cut",0,0,1,1);
-   fEtaSlider->SetObject(this);
-   fEtaSlider->SetFillColor(45);
-   TSliderBox *sbox2 = (TSliderBox*)fEtaSlider->GetListOfPrimitives()->First();
-   sbox2->SetFillColor(46);
-   fEtaSlider->cd();
-   TGaxis *etaaxis = new TGaxis(0.9,0.02,0.9,0.98,-etacutmax,etacutmax,510,"");
-   etaaxis->SetLabelSize(0.5);
-   etaaxis->SetTitleSize(0.6);
-   etaaxis->SetTitleOffset(0.2);
-   cutaxis->SetTitle("Etacut .  ");
-   fEtaSlider->GetListOfPrimitives()->AddFirst(etaaxis);
-   fCanvas->cd();
+  gAlice->SetDisplay(this);
    
-
-   fCanvas->cd();
-   fCanvas->Update();
+  // Initialize display default parameters
+  SetRange();
+  SetPTcut();
+  
+  // Create display canvas
+  Int_t ysize = size;
+  if (ysize < 100) ysize = 750;
+  Int_t xsize = Int_t(size*830./ysize);
+  fCanvas = new TCanvas("Canvas", "ALICE Event Display",14,47,xsize,ysize);
+  fCanvas->ToggleEventStatus();
+
+  // Create main display pad
+  fPad = new TPad("viewpad", "Alice display",0.15,0,0.97,0.96);
+  fPad->Draw();
+  fPad->Modified();
+  fPad->SetFillColor(1);
+  fPad->SetBorderSize(2);
+
+  // Create user interface control pad
+  DisplayButtons();
+  fCanvas->cd();
+
+  // Create Range and mode pad
+  Float_t dxtr     = 0.15;
+  Float_t dytr     = 0.45;
+  fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
+  fTrigPad->Draw();
+  fTrigPad->cd();
+  fTrigPad->SetFillColor(22);
+  fTrigPad->SetBorderSize(2);
+  fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
+  fRangeSlider->SetObject(this);
+  char pickmode[] = "gAlice->Display()->SetPickMode()";
+  Float_t db = 0.09;
+  fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
+  fPickButton->SetFillColor(38);
+  fPickButton->Draw();
+  char zoommode[] = "gAlice->Display()->SetZoomMode()";
+  fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
+  fZoomButton->SetFillColor(38);
+  fZoomButton->Draw();
+  fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
+  fArcButton->SetFillColor(kGreen);
+  fArcButton->Draw();
+  char butUnzoom[] = "gAlice->Display()->UnZoom()";
+  TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
+  button->SetFillColor(38);
+  button->Draw();
+  AppendPad(); // append display object as last object to force selection
+  // Create momentum cut slider pad
+  fCanvas->cd();
+  fCutPad = new TPad("cutSlider", "pcut slider pad",dxtr,.96,1,1);
+  fCutPad->Draw();
+  fCutPad->cd();
+  fCutPad->SetFillColor(22);
+  fCutPad->SetBorderSize(2);
+  fCutSlider = new TSlider("pcut","Momentum cut",0,0,1,1);
+  fCutSlider->SetRange(fPTcut/fgkPtCutMax,1);
+  fCutSlider->SetObject(this);
+  fCutSlider->SetFillColor(45);
+  TSliderBox *sbox = dynamic_cast<TSliderBox*>(fCutSlider->GetListOfPrimitives()->First());
+  sbox->SetFillColor(46);
+  fCutSlider->cd();
+  TGaxis *cutaxis = new TGaxis(0.02,0.8,0.98,0.8,0,fgkPtCutMax,510,"");
+  cutaxis->SetLabelSize(0.5);
+  cutaxis->SetTitleSize(0.6);
+  cutaxis->SetTitleOffset(0.5);
+  cutaxis->SetTitle("pcut .  ");
+  fCutSlider->GetListOfPrimitives()->AddFirst(cutaxis);
+  // Create rapidity cut slider pad
+  fCanvas->cd();
+  fEtaPad = new TPad("EtaSlider", "Eta slider pad",0.97,0,1,0.96);
+  fEtaPad->Draw();
+  fEtaPad->cd();
+  fEtaPad->SetFillColor(22);
+  fEtaPad->SetBorderSize(2);
+  fEtaSlider = new TSlider("etacut","Rapidity cut",0,0,1,1);
+  fEtaSlider->SetObject(this);
+  fEtaSlider->SetFillColor(45);
+  TSliderBox *sbox2 = dynamic_cast<TSliderBox*>(fEtaSlider->GetListOfPrimitives()->First());
+  sbox2->SetFillColor(46);
+  fEtaSlider->cd();
+  TGaxis *etaaxis = new TGaxis(0.9,0.02,0.9,0.98,-fgkEtaCutMax,fgkEtaCutMax,510,"");
+  etaaxis->SetLabelSize(0.5);
+  etaaxis->SetTitleSize(0.6);
+  etaaxis->SetTitleOffset(0.2);
+  cutaxis->SetTitle("Etacut .  ");
+  fEtaSlider->GetListOfPrimitives()->AddFirst(etaaxis);
+  fCanvas->cd();
+
+  fTrigPad->SetEditable(kFALSE);
+  fButtons->SetEditable(kFALSE);
+  fTracksToDisplay =0;
+  fNTracksToDisplay =0;   
+
+  fCanvas->cd();
+  fCanvas->Update();
 }
 
 
+//_______________________________________________________________________
+AliDisplay::AliDisplay(const AliDisplay &disp):
+  TObject(disp),
+  fZoomMode(0),
+  fDrawAllViews(0),
+  fDrawParticles(0),
+  fDrawHits(0),
+  fPTcut(0),
+  fTheta(0),
+  fPhi(0),
+  fPsi(0),
+  fRrange(0),
+  fZrange(0),
+  fZooms(0),
+  fHitsCuts(0),
+  fCanvas(0),
+  fTrigPad(0),
+  fCutPad(0),
+  fEtaPad(0),
+  fButtons(0),
+  fPad(0),
+  fCutSlider(0),
+  fEtaSlider(0),
+  fRangeSlider(0),
+  fPickButton(0),
+  fZoomButton(0),
+  fArcButton(0),
+  fFruits(0),
+  fTracksToDisplay(0),
+  fNTracksToDisplay(0)
+{
+  //
+  // Copy constructor
+  //
+  disp.Copy(*this);
+}
+
 //_____________________________________________________________________________
 AliDisplay::~AliDisplay()
 {
+  //
+  // Destructor
+  //
 }
 
 //_____________________________________________________________________________
@@ -243,13 +349,26 @@ void AliDisplay::Clear(Option_t *)
 //    Delete graphics temporary objects
 }
 
+//_____________________________________________________________________________
+void AliDisplay::Copy(TObject &) const
+{
+  //
+  // Copy *this onto disp -- not implemented
+  //
+  AliFatal("Not implemented");
+}
+
 //----------------------------------------------------------------------------
-void AliDisplay::ShowTrack(Int_t idx) {
-   AliDetector *TPC=(AliDetector*)gAlice->GetModule("TPC");
-   TObjArray *points=TPC->Points();
+void AliDisplay::ShowTrack(Int_t idx) 
+{
+  //
+  // Display track idx
+  //
+   AliDetector *mTPC=dynamic_cast<AliDetector*>(gAlice->GetModule("TPC"));
+   TObjArray *points=mTPC->Points();
    int ntracks=points->GetEntriesFast();
    for (int track=0;track<ntracks;track++) {
-      AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
+      AliPoints *pm = dynamic_cast<AliPoints*>(points->UncheckedAt(track));
       if (!pm) continue;
       if (idx == pm->GetIndex()) {
          pm->SetMarkerColor(2);
@@ -257,25 +376,30 @@ void AliDisplay::ShowTrack(Int_t idx) {
          pm->Draw("same");
 //       fPad->Update();
 //       fPad->Modified();
-         TClonesArray *particles=gAlice->Particles();
-         GParticle *p = (GParticle*)particles->UncheckedAt(idx);
-         printf("\nTrack index %d\n",idx);
-         printf("Particle ID %d\n",p->GetKF());
-         printf("Parent %d\n",p->GetParent());
-         printf("First child %d\n",p->GetFirstChild());
-         printf("Px,Py,Pz %f %f %f\n",p->GetPx(),p->GetPy(),p->GetPz());
+        //         TClonesArray *particles=gAlice->Particles();
+        //         TParticle *p = (TParticle*)particles->UncheckedAt(idx);
+        TParticle *p = gAlice->GetMCApp()->Particle(idx);
+         AliInfo(Form("Track index %d",idx));
+         AliInfo(Form("Particle ID %d",p->GetPdgCode()));
+         AliInfo(Form("Parent %d",p->GetFirstMother()));
+         AliInfo(Form("First child %d",p->GetFirstDaughter()));
+         AliInfo(Form("Px,Py,Pz %f %f %f",p->Px(),p->Py(),p->Pz()));
          return;
       }
    }
 }
 
 //----------------------------------------------------------------------------
-void AliDisplay::HideTrack(Int_t idx) {
-   AliDetector *TPC=(AliDetector*)gAlice->GetModule("TPC");
-   TObjArray *points=TPC->Points();
+void AliDisplay::HideTrack(Int_t idx) const
+{
+  //
+  // Hide track on display
+  //
+   AliDetector *mTPC=dynamic_cast<AliDetector*>(gAlice->GetModule("TPC"));
+   TObjArray *points=mTPC->Points();
    int ntracks=points->GetEntriesFast();
    for (int track=0;track<ntracks;track++) {
-      AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
+      AliPoints *pm = dynamic_cast<AliPoints*>(points->UncheckedAt(track));
       if (!pm) continue;
       if (idx == pm->GetIndex()) {
          pm->SetMarkerColor(5);
@@ -293,7 +417,7 @@ void AliDisplay::DisableDetector(const char *name)
 {
 //    Disable detector name from graphics views
    
-   AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
+   AliModule *module = dynamic_cast<AliModule*>(gAlice->Modules()->FindObject(name));
    if (!module) return;
    module->Disable();
    Draw();
@@ -390,8 +514,8 @@ Int_t AliDisplay::DistancetoPrimitive(Int_t px, Int_t)
    if (gPad == fCutPad)  return 9999;
    if (gPad == fEtaPad)  return 9999;
 
-   const Int_t big = 9999;
-   Int_t dist   = big;
+   const Int_t kbig = 9999;
+   Int_t dist   = kbig;
    Float_t xmin = gPad->GetX1();
    Float_t xmax = gPad->GetX2();
    Float_t dx   = 0.02*(xmax - xmin);
@@ -463,46 +587,46 @@ void AliDisplay::DrawHits()
    Float_t cutmin, cutmax, etamin, etamax, pmom, smin, smax, eta, theta, r;
    Float_t *pxyz;
    Int_t ntracks,track;
-   GParticle *particle;
+   TParticle *particle;
    TObjArray *points;
    AliPoints *pm;
       
    //Get cut slider
    smax   = fCutSlider->GetMaximum();
    smin   = fCutSlider->GetMinimum();
-   cutmin = ptcutmax*smin;
-   if (smax < 0.98) cutmax = ptcutmax*smax;
+   cutmin = fgkPtCutMax*smin;
+   if (smax < 0.98) cutmax = fgkPtCutMax*smax;
    else             cutmax = 100000;
    
    //Get eta slider
    smax   = fEtaSlider->GetMaximum();
    smin   = fEtaSlider->GetMinimum();
-   etamin = etacutmax*(2*smin-1);
-   etamax = etacutmax*(2*smax-1);
+   etamin = fgkEtaCutMax*(2*smin-1);
+   etamax = fgkEtaCutMax*(2*smax-1);
    if (smin < 0.02) etamin = -1000;
    if (smax > 0.98) etamax =  1000;
       
    TIter next(gAlice->Modules());
    AliModule *module;
    fHitsCuts = 0;
-   while((module = (AliModule*)next())) {
+   while((module = dynamic_cast<AliModule*>(next()))) {
       if (!module->IsActive()) continue;
       points = module->Points();
       if (!points) continue;
       ntracks = points->GetEntriesFast();
       for (track=0;track<ntracks;track++) {
-         pm = (AliPoints*)points->UncheckedAt(track);
+         pm = dynamic_cast<AliPoints*>(points->UncheckedAt(track));
          if (!pm) continue;
          particle = pm->GetParticle();
          if (!particle) continue;
-         pmom = particle->GetMomentum();
+         pmom = particle->P();
          if (pmom < cutmin) continue;
          if (pmom > cutmax) continue;
          // as a first approximation, take eta of first point
          pxyz  = pm->GetP();
          r     = TMath::Sqrt(pxyz[0]*pxyz[0] + pxyz[1]*pxyz[1]);
          theta = TMath::ATan2(r,TMath::Abs(pxyz[2]));
-         if(theta) eta = -TMath::Log(TMath::Tan(0.5*theta)); else eta = 1e10;
+         if(theta) eta = -TMath::Log(TMath::Abs(TMath::Tan(0.5*theta))); else eta = 1e10;
          if (pxyz[2] < 0) eta = -eta;
          if (eta < etamin || eta > etamax) continue;
          pm->Draw();
@@ -531,7 +655,7 @@ void AliDisplay::DrawTitle(Option_t *option)
       char ptitle[100];
       sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
       title->AddText(ptitle);
-      Int_t nparticles = gAlice->Particles()->GetEntriesFast();
+      Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
       sprintf(ptitle,"Nparticles = %d  Nhits = %d",nparticles, fHitsCuts);
       title->AddText(ptitle);
    } else {
@@ -552,7 +676,13 @@ void AliDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
    gPad->Clear();
 
    Int_t iret;
+#if ROOT_VERSION_CODE>= 331523
+   Double_t rmin[]={-1,-1,-1};
+   Double_t rmax[]={ 1, 1, 1};
+   TView *view = new TView3D(1,rmin,rmax);
+#else
    TView *view = new TView(1);
+#endif
    Float_t range = fRrange*fRangeSlider->GetMaximum();
    view->SetRange(-range,-range,-range,range, range, range);
    fZoomX0[0] = -1;
@@ -578,7 +708,7 @@ void AliDisplay::DrawViewGL()
 {
 //    Draw current view using OPENGL
 
-   TPad *pad = (TPad*)gPad->GetPadSave();
+   TPad *pad = dynamic_cast<TPad*>(gPad->GetPadSave());
    pad->cd();
    TView *view = pad->GetView();
    if (!view) return;
@@ -590,7 +720,7 @@ void AliDisplay::DrawViewX3D()
 {
 //    Draw current view using X3D
 
-   TPad *pad = (TPad*)gPad->GetPadSave();
+   TPad *pad = dynamic_cast<TPad*>(gPad->GetPadSave());
    pad->cd();
    TView *view = pad->GetView();
    if (!view) return;
@@ -602,7 +732,7 @@ void AliDisplay::EnableDetector(const char *name)
 {
 //    Enable detector name in graphics views
    
-   AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
+   AliModule *module = dynamic_cast<AliModule*>(gAlice->Modules()->FindObject(name));
    if (!module) return;
    module->Enable();
    Draw();
@@ -638,7 +768,7 @@ void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
    switch (event) {
 
    case kButton1Down:
-      gGXW->SetLineColor(-1);
+      gVirtualX->SetLineColor(-1);
       gPad->TAttLine::Modify();  //Change line attributes only if necessary
       x0 = gPad->AbsPixeltoX(px);
       y0 = gPad->AbsPixeltoY(py);
@@ -648,11 +778,11 @@ void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
       return;
 
    case kButton1Motion:
-      if (linedrawn) gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
+      if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
       pxold = px;
       pyold = py;
       linedrawn = 1;
-      gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
+      gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
       return;
 
    case kButton1Up:
@@ -665,7 +795,7 @@ void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
       if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
       if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
       gPad->Range(x0,y0,x1,y1);
-      if (fZooms < kMAXZOOMS-1) {
+      if (fZooms < fgkMaxZooms-1) {
          fZooms++;
          fZoomX0[fZooms] = x0;
          fZoomY0[fZooms] = y0;
@@ -678,6 +808,13 @@ void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
 
 }
  
+
+void AliDisplay::SetTracksToDisplay(Int_t *tracks, Int_t n){
+  //
+  // set tracks to display  - MI
+  fTracksToDisplay = tracks;
+  fNTracksToDisplay = n;
+}
 //___________________________________________
 void AliDisplay::LoadPoints()
 {
@@ -687,14 +824,50 @@ void AliDisplay::LoadPoints()
    gAlice->ResetPoints();
    TIter next(gAlice->Modules());
    AliModule *module;
-   Int_t ntracks = gAlice->GetNtrack();
-   for (Int_t track=0; track<ntracks;track++) {
+   Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+
+   while((module = (AliModule*)next())) 
+    {
+     AliDetector* detector = dynamic_cast<AliDetector*>(module);
+     if(detector) detector->SetTreeAddress();
+    }
+   next.Reset();
+
+   // load only wanted tracks
+   if (fNTracksToDisplay>0)
+    {
+      Int_t nprim =  gAlice->Stack()->GetNprimary();
+      for (Int_t track=0; track<fNTracksToDisplay;track++) 
+       {
+        gAlice->ResetHits();
+        Int_t nev = nprim-1-gAlice->GetMCApp()->GetPrimary(fTracksToDisplay[track]);
+        while((module = (AliModule*)next())) 
+         {
+          AliDetector* detector = dynamic_cast<AliDetector*>(module);
+          if(detector)
+           {
+            detector->TreeH()->GetEvent(nev);
+            module->LoadPoints(nprim-1-gAlice->GetMCApp()->GetPrimary(fTracksToDisplay[track]));
+           }
+         }
+        next.Reset();
+     }
+   }
+   else
+    {
+      
+      for (Int_t track=0; track<ntracks;track++) {
       gAlice->ResetHits();
-      gAlice->TreeH()->GetEvent(track);
       while((module = (AliModule*)next())) {
-         module->LoadPoints(track);
+         AliDetector* detector = dynamic_cast<AliDetector*>(module);
+         if(detector)
+           {
+             if (detector->TreeH()->GetEvent(track))
+              detector->LoadPoints(track);
+           }
       }
       next.Reset();
+     }
    }
 }
 
@@ -708,6 +881,9 @@ void AliDisplay::Paint(Option_t *)
 //_____________________________________________________________________________
 void AliDisplay::SetPickMode()
 {
+  //
+  // Set Pick Mode -- disable zoom
+  //
    fZoomMode = 0;
 
    fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
@@ -717,6 +893,9 @@ void AliDisplay::SetPickMode()
 //_____________________________________________________________________________
 void AliDisplay::SetZoomMode()
 {
+  //
+  // Set Zoom Mode -- disable pick
+  //
    fZoomMode = 1;
 
    fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
@@ -726,6 +905,9 @@ void AliDisplay::SetZoomMode()
 //_____________________________________________________________________________
 void AliDisplay::SetPTcut(Float_t ptcut)
 {
+  //
+  // Set Pt Cut
+  //
    fPTcut = ptcut;
 
    if (!fPad) return;
@@ -772,11 +954,13 @@ void AliDisplay::ShowNextEvent(Int_t delta)
 //    delta = -1 show previous event
 
   if (delta) {
-     gAlice->Clear();
-     Int_t current_event = gAlice->GetHeader()->GetEvent();
-     Int_t new_event     = current_event + delta;
-     gAlice->GetEvent(new_event);
-     if (!gAlice->TreeH()) return; 
+//     gAlice->Clear();
+     //Int_t currentEvent = gAlice->GetHeader()->GetEvent();//event number is not filled correctly
+     Int_t currentEvent = gAlice->GetRunLoader()->GetEventNumber();
+     Int_t newEvent     = currentEvent + delta;
+     gAlice->GetEvent(newEvent);
+     AliInfo(Form("delta = %d  currentEvent = %d  newEvent = %d",
+                  delta, currentEvent, newEvent));
    }
   LoadPoints();
   fPad->cd(); 
@@ -786,9 +970,22 @@ void AliDisplay::ShowNextEvent(Int_t delta)
 //______________________________________________________________________________
 void AliDisplay::UnZoom()
 {
-   if (fZooms <= 0) return;
-   fZooms--;
-   TPad *pad = (TPad*)gPad->GetPadSave();
-   pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
-   pad->Modified();
+  //
+  // Resets ZOOM 
+  //
+  if (fZooms <= 0) return;
+  fZooms--;
+  TPad *pad = dynamic_cast<TPad*>(gPad->GetPadSave());
+  pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
+  pad->Modified();
+}
+
+//_____________________________________________________________________________
+AliDisplay & AliDisplay::operator=(const AliDisplay &disp)
+{
+  //
+  // Assignment operator
+  //
+  disp.Copy(*this);
+  return (*this);
 }