]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHDisplay.cxx
bbe9d887d716a20a517504369230395fd7fb628f
[u/mrichter/AliRoot.git] / RICH / AliRICHDisplay.cxx
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$
18   Revision 1.18  2002/10/29 14:24:19  morsch
19   Minor corrections on the display (adc counts readable, ...).
20   (J. Barbosa)
21
22   Revision 1.17  2001/10/23 13:03:35  hristov
23   The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
24
25   Revision 1.16  2001/10/21 18:31:24  hristov
26   Several pointers were set to zero in the default constructors to avoid memory management problems
27
28   Revision 1.15  2001/10/09 07:34:09  hristov
29   Modifications needed by Root.03.01.06 (J.Chudoba)
30
31   Revision 1.14  2001/05/16 14:57:20  alibrary
32   New files for folders and Stack
33
34   Revision 1.13  2001/05/10 12:35:16  jbarbosa
35   Removed hit display, added rec. ring properties.
36
37   Revision 1.12  2001/03/14 18:15:03  jbarbosa
38   Changes to adapt to new IO.
39   Removed verbose output.
40
41   Revision 1.11  2001/02/27 15:21:34  jbarbosa
42   Transition to SDigits.
43
44   Revision 1.10  2001/02/13 20:18:48  jbarbosa
45   Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
46
47   Revision 1.9  2000/11/01 15:33:11  jbarbosa
48   Updated to handle both reconstruction algorithms.
49
50   Revision 1.8  2000/10/03 21:44:09  morsch
51   Use AliSegmentation and AliHit abstract base classes.
52
53   Revision 1.7  2000/10/02 21:28:12  fca
54   Removal of useless dependecies via forward declarations
55
56   Revision 1.6  2000/10/02 15:46:38  jbarbosa
57   Fixed forward declarations.
58
59   Revision 1.5  2000/06/30 16:49:34  dibari
60   Different call for ring drawing.
61
62   Revision 1.4  2000/06/12 15:21:08  jbarbosa
63   Cleaned up version.
64
65   Revision 1.3  2000/06/09 14:52:08  jbarbosa
66   New tentative ellipse drawing routine
67
68   Revision 1.1  2000/04/19 13:07:45  morsch
69   Digits, clusters and reconstruction results added.
70
71 */
72
73
74 //////////////////////////////////////////////////////////////////////////
75 //                                                                      //
76 // AliDisplay                                                           //
77 //                                                                      //
78 // Utility class to display ALICE outline, tracks, hits,..              //
79 //                                                                      //
80 //////////////////////////////////////////////////////////////////////////
81
82 #include <TROOT.h>
83 #include <TTree.h>
84 #include <TButton.h>
85 #include <TColor.h>
86 #include <TCanvas.h>
87 #include <TView.h>
88 #include <TText.h>
89 #include <TPolyMarker3D.h>
90 #include <TAtt3D.h>
91 #include <TAttLine.h>
92 #include <TPolyMarker.h>
93 #include <TPaveLabel.h>
94 #include <TPaveText.h>
95 #include <TList.h>
96 #include <TDiamond.h>
97 #include <TNode.h>
98 #include <TArc.h>
99 #include <TTUBE.h>
100 #include <TSlider.h>
101 #include <TGeometry.h>
102 #include <TSliderBox.h>
103 #include <TGaxis.h>
104 #include <TVirtualX.h>
105 #include <TMath.h>
106 #include <TRandom.h>
107 #include <X3DBuffer.h>
108 #include <TParticle.h>
109
110 #include "AliRun.h"
111 #include "AliPDG.h"
112 #include "AliDetector.h"
113 #include "AliRICH.h"
114 #include "AliRICHConst.h"
115 #include "AliRICHDisplay.h"
116 #include "AliRICHPoints.h"
117 #include "AliHeader.h"
118
119 #include "AliRICHHit.h"
120 #include "AliRICHCerenkov.h"
121 #include "AliRICHSDigit.h"
122 #include "AliRICHDigit.h"
123 #include "AliRICHRawCluster.h"
124 #include "AliRICHRecHit1D.h"
125 #include "AliRICHRecHit3D.h"
126 #include "AliRICHEllipse.h"
127
128 ClassImp(AliRICHDisplay)
129     
130
131 //____________________________________________________________________________
132 AliRICHDisplay::AliRICHDisplay()
133
134
135 // default constructor
136     fColPad = 0;
137     fPoints = 0;
138     fPhits = 0;
139     fPCerenkovs = 0;
140     fCanvas = 0;
141     fRpoints = 0;
142     fRecpoints = 0; 
143 }
144
145 //_____________________________________________________________________________
146 AliRICHDisplay::AliRICHDisplay(Int_t size)
147 {
148 // Create an event display object.
149 // A canvas named "edisplay" is created with a vertical size in pixels
150 //
151 //    A QUICK Overview of the Event Display functions
152 //    ===============================================
153 //
154 //  The event display can ve invoked by executing the macro "display.C"
155 // A canvas like in the picture below will appear.
156 //
157 //  On the left side of the canvas, the following buttons appear:
158 //   *Next*       to move to the next event
159 //   *Previous*   to move to the previous event
160
161 //   *Pick*       Select this option to be able to point on a track with the
162 //                mouse. Once on the track, use the right button to select
163 //                an action. For example, select SetMarkerAttributes to
164 //                change the marker type/color/size for the track.
165 //   *Zoom*       Select this option (default) if you want to zoom.
166 //                To zoom, simply select the selected area with the left button.
167 //   *UnZoom*     To revert to the previous picture size.
168 //
169 //   slider R     On the left side, the vertical slider can be used to
170 //                set the default picture size.
171 //
172 //    When you are in Zoom mode, you can click on the black part of the canvas
173 //  to select special options with the right mouse button.
174
175 //
176 //  When you are in pick mode, you can "Inspect" the object pointed by the mouse.
177 //  When you are on a track, select the menu item "InspectParticle"
178 //  to display the current particle attributes.
179 //
180 //  You can activate the Root browser by selecting the Inspect menu
181 //  in the canvas tool bar menu. Then select "Start Browser"
182 //  This will open a new canvas with the browser. At this point, you may want
183 //  to display some histograms (from the Trees). Go to the "File" menu
184 //  of the browser and click on "New canvas".
185 //  In the browser, click on item "ROOT files" in the left pane.
186 //  Click on galice.root.
187 //  Click on TH
188 //  Click on TPC for example
189 //  Click on any variable (eg TPC.fX) to histogram the variable.
190 //
191 //   If you are lost, you can click on HELP in any Root canvas or browser.
192 //Begin_Html
193 /*
194   <img src="gif/AliRICHDisplay.gif">
195 */
196 //End_Html
197     
198     
199     fPad = 0;
200     
201     gAlice->SetDisplay(this);
202     
203     // Initialize display default parameters
204     SetRange();
205     
206     // Set front view by default
207     fTheta = 90;              //inclined HMPID
208     fPhi   = 30;              //inclined HMPID
209     //fTheta = 90;               //normal HMPID
210     //fPhi   = 90;                //normal HMPID
211     fPsi   = 0;
212     fChamber = 1;
213     fCathode = 1;
214     //   fRzone   = 1.e10;
215     fDrawClusters  = kTRUE;
216     fDrawCoG       = kTRUE;
217     fDrawRecHits   = kTRUE;
218     fZoomMode      = 1;
219     fZooms         = 0;
220     fClustersCuts  = 0;
221     fPoints        = 0;
222     fPCerenkovs    = 0;
223     fPhits         = 0;
224     fRpoints       = 0;   
225     fRecpoints       = 0;
226     // Create colors
227     CreateColors();
228     // Create display canvas
229     Int_t ysize = size;
230     if (ysize < 100) ysize = 750;
231     Int_t xsize = Int_t(size*830./ysize);
232     fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
233     fCanvas->ToggleEventStatus();
234     
235     // Create main display pad
236     fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
237     fPad->Draw();
238     fPad->Modified();
239     fPad->SetFillColor(1);
240     fPad->SetBorderSize(2);
241     
242     fCanvas->cd();
243     
244     // Create colors pad
245     fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
246     fColPad->Draw();
247     fColPad->Modified();
248     fColPad->SetFillColor(19);
249     fColPad->SetBorderSize(2);
250     fColPad->cd();
251     DisplayColorScale();
252     
253     fCanvas->cd();
254     
255     // Create user interface control pad
256     DisplayButtons();
257     fCanvas->cd();
258     
259     // Create Range and mode pad
260     Float_t dxtr     = 0.15;
261     Float_t dytr     = 0.45;
262     fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
263     fTrigPad->Draw();
264     fTrigPad->cd();
265     fTrigPad->SetFillColor(22);
266     fTrigPad->SetBorderSize(2);
267     fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
268     fRangeSlider->SetObject(this);
269     char pickmode[] = "gAlice->Display()->SetPickMode()";
270     Float_t db = 0.09;
271     fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
272     fPickButton->SetFillColor(38);
273     fPickButton->Draw();
274     char zoommode[] = "gAlice->Display()->SetZoomMode()";
275     fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
276     fZoomButton->SetFillColor(38);
277     fZoomButton->Draw();
278     fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
279     fArcButton->SetFillColor(kGreen);
280     fArcButton->Draw();
281     char butUnzoom[] = "gAlice->Display()->UnZoom()";
282     TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
283     button->SetFillColor(38);
284     button->Draw();
285     AppendPad(); // append display object as last object to force selection
286     
287     fTrigPad->SetEditable(kFALSE);
288     fButtons->SetEditable(kFALSE);
289     fCanvas->cd();
290     fCanvas->Update();
291 }
292
293
294 //_____________________________________________________________________________
295 AliRICHDisplay::~AliRICHDisplay()
296 {
297     // Delete space point structure
298     if (fPoints) fPoints->Delete();
299     delete fPoints;
300     fPoints     = 0;
301     //
302     if (fPhits) fPhits->Delete();
303     delete fPhits;
304     fPhits     = 0;
305     //
306     if (fRpoints) fRpoints->Delete();
307     delete fRpoints;
308     fRpoints     = 0;
309     //
310     if (fRecpoints) fRecpoints->Delete();
311     delete fRecpoints;
312     fRecpoints     = 0;
313     //
314     if (fPCerenkovs) fPCerenkovs->Delete();
315     delete fPCerenkovs;
316     fPCerenkovs     = 0;
317 }
318
319 //_____________________________________________________________________________
320 void AliRICHDisplay::Clear(Option_t *)
321 {
322 //    Delete graphics temporary objects
323 }
324
325 //_____________________________________________________________________________
326 void AliRICHDisplay::DisplayButtons()
327 {
328 //    Create the user interface buttons
329     
330     
331     fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
332     fButtons->Draw();
333     fButtons->SetFillColor(38);
334     fButtons->SetBorderSize(2);
335     fButtons->cd();
336     
337     //   Int_t butcolor = 33;
338     Float_t dbutton = 0.08;
339     Float_t y  = 0.96;
340     Float_t dy = 0.014;
341     Float_t x0 = 0.05;
342     Float_t x1 = 0.95;
343     
344     TButton *button;
345     char but1[] = "gAlice->Display()->ShowNextEvent(1)";
346     button = new TButton("Next",but1,x0,y-dbutton,x1,y);
347     button->SetFillColor(38);
348     button->Draw();
349     
350     y -= dbutton +dy;
351     char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
352     button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
353     button->SetFillColor(38);
354     button->Draw();
355
356     y -= dbutton +dy;
357     char but7[] = "gAlice->Display()->DrawViewGL()";
358     button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
359     button->SetFillColor(38);
360     button->Draw();
361     
362     y -= dbutton +dy;
363     char but8[] = "gAlice->Display()->DrawViewX3D()";
364     button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
365     button->SetFillColor(38);
366     button->Draw();
367     
368     // display logo
369     TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
370     diamond->SetFillColor(50);
371     diamond->SetTextAlign(22);
372     diamond->SetTextColor(5);
373     diamond->SetTextSize(0.11);
374     diamond->Draw();
375     diamond->AddText(".. ");
376     diamond->AddText("ROOT");
377     diamond->AddText("RICH");
378     diamond->AddText("... ");
379     diamond->AddText(" ");
380 }
381
382 //_____________________________________________________________________________
383 void AliRICHDisplay::CreateColors()
384 {
385 //    Create the colors palette used to display clusters
386     
387     Int_t k,i;
388     Int_t color;
389     Float_t r,g,b;
390     
391     for (k=1;k<=5;k++) {
392         switch(k) {
393         case 1:
394             for (i=1;i<=5;i++) {
395                 r=1.;
396                 g=i*0.2;  
397                 b=0.;
398                 color=i;
399                 color=700+23-color;
400                 new TColor(color,r,g,b);
401             } 
402             break;
403         case 2:
404             for (i=1;i<=4;i++) {
405                 r=1.1-i*0.2;
406                 g=1.;  
407                 b=0.;
408                 color=i+5;
409                 color=700+23-color;
410                 new TColor(color,r,g,b);
411             } 
412             break;
413     case 3:
414         for (i=1;i<=4;i++) {
415             r=0.;
416             g=1.;  
417             b=i*0.2+0.2;
418             color=i+9;
419             color=700+23-color;
420             new TColor(color,r,g,b);
421         } 
422         break;
423         case 4:
424             for (i=1;i<=4;i++) {
425                 r=0.;
426                 g=1.1-i*0.2;  
427                 b=1.;
428                 color=i+13;
429                 color=700+23-color;
430                 new TColor(color,r,g,b);
431             } 
432             break;
433         case 5:
434             for (i=1;i<=5;i++) {
435                 r=i*0.2;
436                 g=0.;  
437                 b=1.;
438                 color=i+17;
439                 color=700+23-color;
440                 new TColor(color,r,g,b);
441             } 
442             break;
443         }
444     }
445 }
446
447 //_____________________________________________________________________________
448 void AliRICHDisplay::DisplayColorScale()
449 {
450
451 // Draw the color scale in the RICH display canvas
452     
453     Int_t i;
454     Int_t color;
455     Float_t xlow, ylow, xup, yup, hs;
456     Float_t x1, y1, x2, y2;
457     x1 = y1 = 0;
458     x2 = y2 = 20;
459     
460     gPad->SetFillColor(0);
461     gPad->Clear();
462     gPad->Range(x1,y1,x2,y2);
463     TText *text = new TText(0,0,"");
464     text->SetTextFont(61);
465     text->SetTextSize(0.2);
466     text->SetTextAlign(22);
467     
468     TBox *box;
469     char label[8];
470 //*-* draw colortable boxes
471     hs = (y2-y1)/Float_t(22);
472     xlow=x1+1;
473     xup=x2-9;
474     for (i=0;i<22;i++) {
475         ylow = y1 + hs*(Float_t(i));
476         yup  = y1 + hs*(Float_t(i+1));
477         color = 701+i;
478         Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
479         Int_t scale=(Int_t)TMath::Exp(logscale);
480         sprintf(label,"%d",scale);
481         box = new TBox(xlow, ylow, xup, yup);
482         box->SetFillColor(color);
483         box->Draw();
484         text->DrawText(xup+4, 0.5*(ylow+yup),label);
485     }
486 }
487
488 //______________________________________________________________________________
489 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
490 {
491 // Compute distance from point px,py to objects in event
492     
493     gPad->SetCursor(kCross);
494     
495     if (gPad == fTrigPad) return 9999;
496     
497     const Int_t kBig = 9999;
498     Int_t dist   = kBig;
499     Float_t xmin = gPad->GetX1();
500     Float_t xmax = gPad->GetX2();
501     Float_t dx   = 0.02*(xmax - xmin);
502     Float_t x    = gPad->AbsPixeltoX(px);
503     if (x < xmin+dx || x > xmax-dx) return dist;
504     if (fZoomMode) return 0;
505     else           return 7;
506 }
507
508 //_____________________________________________________________________________
509 void AliRICHDisplay::Draw(Option_t *)
510 {
511 //    Display current event
512
513     fPad->cd();
514     
515     DrawView(fTheta, fPhi, fPsi);      // see how to draw PGON+inner frames
516     
517     // Display the event number and title
518     fPad->cd();
519     DrawTitle();
520 }
521
522 //_____________________________________________________________________________
523 void AliRICHDisplay::DrawCoG()
524 {
525 //    Draw hits for RICH chambers
526
527     if (!fDrawCoG) return;
528     ResetRpoints();
529     for (Int_t chamber=0;chamber<kNCH;chamber++) {
530         LoadCoG(chamber,1);
531     }
532     
533     Int_t ncog, icog;
534     TObjArray *points;
535     AliRICHPoints *pm;
536     points = fRpoints;
537     if (!points) return;
538     ncog = points->GetEntriesFast();
539     for (icog=0; icog < ncog; icog++) {
540         pm = (AliRICHPoints*)points->UncheckedAt(icog);
541         if (!pm) continue;
542         pm->Draw();
543     }
544 }
545
546 void AliRICHDisplay::DrawRecHits()
547 {
548 //    Draw rec hits for RICH chambers
549
550     if (!fDrawRecHits) return;
551     //ResetRecpoints();
552     for (Int_t chamber=0;chamber<kNCH;chamber++) {
553         LoadRecHits(chamber,1);
554     }
555     
556     Int_t nrec, irec;
557     TObjArray *points;
558     AliRICHPoints *pm;
559     points = fRecpoints;
560     if (!points) return;
561     nrec = points->GetEntriesFast();
562     //printf("Nrec %d\n",nrec);
563     for (irec=0; irec < nrec; irec++) {
564         pm = (AliRICHPoints*)points->UncheckedAt(irec);
565         if (!pm) continue;
566         pm->Draw();
567     }
568 }
569
570 //_____________________________________________________________________________
571
572 void AliRICHDisplay::DrawCerenkovs()
573 {
574 //    Draw cerenkovs hits for RICH chambers
575     
576     LoadCerenkovs(fChamber);
577     //printf("\nDrawCerenkovs\n");
578     
579     Int_t ntracks, track;
580     TObjArray *cpoints;
581     AliRICHPoints *pm;
582     
583     fHitsCuts = 0;
584     cpoints = fPCerenkovs;
585     //printf ("Cpoints: %p",cpoints);
586     if (!cpoints) return;
587     ntracks = cpoints->GetEntriesFast();
588     //printf("DrawCerenkovs - ntracks %d \n",ntracks);
589     for (track=0;track<ntracks;track++) {
590         pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
591         if (!pm) continue;
592         pm->Draw();
593         fHitsCuts += pm->GetN();
594     }
595 }
596
597 //_____________________________________________________________________________
598
599 void AliRICHDisplay::DrawClusters()
600 {
601 //    Draw clusterss for RICH chambers
602     
603     Int_t ndigits, digit;
604     TObjArray *points;
605     AliRICHPoints *pm;
606     
607     fClustersCuts = 0;
608     points = fPoints;
609     if (!points) return;
610     ndigits = points->GetEntriesFast();
611     for (digit=0;digit<ndigits;digit++){
612         pm = (AliRICHPoints*)points->UncheckedAt(digit);
613         if (!pm) continue;
614         pm->Draw();
615         Float_t *pxyz;
616         pxyz=pm->GetP();
617         for (Int_t im=0;im<3;im++) {
618             TMarker3DBox *marker=pm->GetMarker(im);
619             if (marker)
620                 marker->Draw();
621         }
622         fClustersCuts +=pm->GetN();
623     }
624 }
625
626 //_____________________________________________________________________________
627 void AliRICHDisplay::DrawHits()
628 {
629 //    Draw hits for RICH chambers
630     
631     LoadHits(fChamber);
632     
633     Int_t ntracks, track;
634     TObjArray *points;
635     AliRICHPoints *pm;
636     
637     fHitsCuts = 0;
638     points = Phits();
639     if (!fPhits) return;
640 //    ntracks = points->GetEntriesFast();
641     ntracks = fPhits->GetEntriesFast();
642     
643     //printf("DrawHits - ntracks %d \n",ntracks);
644     for (track=0;track<ntracks;track++) {
645         pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
646         if (!pm) continue;
647         pm->Draw();
648         fHitsCuts += pm->GetN();
649     }
650 }
651
652
653 //_____________________________________________________________________________
654 void AliRICHDisplay::DrawTitle(Option_t *option)
655 {
656 //    Draw the event title
657     
658     Float_t xmin = gPad->GetX1();
659     Float_t xmax = gPad->GetX2();
660     Float_t ymin = gPad->GetY1();
661     Float_t ymax = gPad->GetY2();
662     Float_t dx   = xmax-xmin;
663     Float_t dy   = ymax-ymin;
664     
665     if (strlen(option) == 0) {
666         TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
667         title->SetBit(kCanDelete);
668         title->SetFillColor(42);
669         title->Draw();
670         char ptitle[100];
671         sprintf(ptitle,"Alice event: %d, Run:%d",
672                 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
673         title->AddText(ptitle);
674         Int_t nparticles = gAlice->Particles()->GetEntriesFast();
675         sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
676                 nparticles, fHitsCuts,fClustersCuts);
677         title->AddText(ptitle);
678     } else {
679         TPaveLabel *label = 
680             new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
681         label->SetBit(kCanDelete);
682         label->SetFillColor(42);
683         label->Draw();
684     }
685 }
686
687 //_____________________________________________________________________________
688 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
689 {
690 //    Draw a view of RICH clusters
691     
692    gPad->SetCursor(kWatch);
693    gPad->SetFillColor(1);
694    gPad->Clear();
695    
696    Int_t iret;
697    TView *view = new TView(1);
698    Float_t range = fRrange*fRangeSlider->GetMaximum();
699    view->SetRange(-range,-range,-range,range, range, range);
700    fZoomX0[0] = -1;
701    fZoomY0[0] = -1;
702    fZoomX1[0] =  1;
703    fZoomY1[0] =  1;
704    fZooms = 0;
705    
706    //Display RICH Chamber Geometry
707    gAlice->GetGeometry()->Draw("same");
708    
709    //add clusters to the pad
710    DrawClusters();
711    //DrawHits();
712    //DrawCerenkovs();
713    if (gAlice->TreeR())
714      {
715        //printf("Calling DrawCoG\n");
716        DrawCoG();
717        //printf("Calling DrawRecHits\n");
718        DrawRecHits();
719      }
720    /*for (Int_t i=0;i<7;i++)
721      LoadRecHits(i,1);*/
722    
723    // add itself to the list (must be last)
724    AppendPad();
725    
726    view->SetView(phi, theta, psi, iret);
727 }
728
729 //______________________________________________________________________________
730 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
731 {
732 //  Execute action corresponding to the mouse event
733     
734     static Float_t x0, y0, x1, y1;
735     
736    static Int_t pxold, pyold;
737    static Int_t px0, py0;
738    static Int_t linedrawn;
739    Float_t temp;
740    
741    if (px == 0 && py == 0) { //when called by sliders
742        if (event == kButton1Up) {
743          printf("Drawing event %d\n",event);
744          Draw();
745        }
746        return;
747    }
748    if (!fZoomMode && gPad->GetView()) {
749        gPad->GetView()->ExecuteRotateView(event, px, py);
750        return;
751    }
752
753    // something to zoom ?
754    gPad->SetCursor(kCross);
755    
756    switch (event) {
757        
758    case kButton1Down:
759        gVirtualX->SetLineColor(-1);
760        gPad->TAttLine::Modify();  //Change line attributes only if necessary
761        x0 = gPad->AbsPixeltoX(px);
762        y0 = gPad->AbsPixeltoY(py);
763        px0   = px; py0   = py;
764        pxold = px; pyold = py;
765        linedrawn = 0;
766        return;
767        
768    case kButton1Motion:
769        if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
770        pxold = px;
771        pyold = py;
772        linedrawn = 1;
773        gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
774        return;
775        
776    case kButton1Up:
777        gPad->GetCanvas()->FeedbackMode(kFALSE);
778        if (px == px0) return;
779        if (py == py0) return;
780        x1 = gPad->AbsPixeltoX(px);
781        y1 = gPad->AbsPixeltoY(py);
782        
783        if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
784        if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
785        gPad->Range(x0,y0,x1,y1);
786        if (fZooms < kMAXZOOM-1) {
787            fZooms++;
788            fZoomX0[fZooms] = x0;
789            fZoomY0[fZooms] = y0;
790            fZoomX1[fZooms] = x1;
791            fZoomY1[fZooms] = y1;
792        }
793        gPad->Modified(kTRUE);
794        return;
795    }
796    
797 }
798 //___________________________________________
799 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
800 {
801 // Read raw clusters info and store x,y,z info in arrays fRpoints
802 // Loop on all detectors
803
804    if (chamber > 6) return;
805
806    //printf("Entering LoadCoG\n");
807
808
809    AliRICH *pRICH  = (AliRICH*)gAlice->GetModule("RICH");
810    AliRICHChamber*  iChamber;
811
812    TClonesArray *pRICHrawclust  = pRICH->RawClustAddress(chamber);
813    //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
814    if (pRICHrawclust == 0) return;
815
816    pRICH->ResetRawClusters();
817
818
819    Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
820    gAlice->TreeR()->GetEvent(nent-1+cathode-1);
821    Int_t nrawcl = pRICHrawclust->GetEntriesFast();
822    //printf ("nrawcl:%d\n",nrawcl);
823    if (nrawcl == 0) return;
824    if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
825    
826    iChamber = &(pRICH->Chamber(chamber));
827    AliRICHRawCluster  *mRaw;
828    AliRICHPoints *points = 0;
829    //
830    //loop over all raw clusters and store their position
831    points = new AliRICHPoints(nrawcl);
832    for (Int_t iraw=0;iraw<nrawcl;iraw++) {
833        mRaw   = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
834        fRpoints->AddAt(points,iraw);
835        points->SetMarkerColor(3);
836        points->SetMarkerStyle(3);
837        points->SetMarkerSize(1.);
838        points->SetParticle(-1);
839        points->SetHitIndex(-1);
840        points->SetTrackIndex(-1);
841        points->SetDigitIndex(-1);
842        Float_t  vectorLoc[3]={mRaw->fX,5,mRaw->fY};
843        Float_t  vectorGlob[3];
844        iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
845        points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
846    }
847 }
848 //___________________________________________
849 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
850 {
851 // Read rec. hits info 
852 // Loop on all detectors
853
854    if (chamber > 6) return;
855
856    ///printf("Entering LoadRecHits\n");
857
858
859    AliRICH *pRICH  = (AliRICH*)gAlice->GetModule("RICH");
860    AliRICHChamber*  iChamber;
861
862    TClonesArray *pRICHrechits1D  = pRICH->RecHitsAddress1D(chamber);
863    //printf ("Chamber:%d\n", chamber);
864    if (pRICHrechits1D != 0)
865      {
866
867        //RICH->ResetRecHits();
868
869
870        Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
871        gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
872        Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
873        //printf ("nrechits1D:%d\n",nrechits1D);
874        if (nrechits1D != 0)
875          {
876            if (fRecpoints == 0) fRecpoints = new TObjArray(50);
877            
878            iChamber = &(pRICH->Chamber(chamber));
879            AliRICHRecHit1D  *mRec1D;
880            AliRICHPoints *points1D = 0;
881            //AliRICHEllipse *ellipse = 0;
882            //
883            //loop over all rechits and store their position  
884            
885            points1D = new AliRICHPoints(nrechits1D);
886            for (Int_t irec=0;irec<nrechits1D;irec++) {
887              mRec1D   = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
888              fRecpoints->AddAt(points1D,irec);
889              points1D->SetMarkerColor(38);
890              points1D->SetMarkerStyle(8);
891              points1D->SetMarkerSize(.5);
892              points1D->SetParticle(-1);
893              points1D->SetHitIndex(-1);
894              points1D->SetTrackIndex(-1);
895              points1D->SetDigitIndex(-1);
896              Float_t  vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
897              Float_t  vectorGlob[3];
898              iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
899              points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
900              //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
901              //Float_t phi   = iChamber->GetRotMatrix()->GetPhi();         
902              //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
903              //printf("Generating ellipse %d\n",irec);
904              AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
905              printf("Ring at x:%f, y:%f - Omega:%f rad, theta:%3.1f deg, phi:%3.1f deg\n",mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta*180/TMath::Pi(),mRec1D->fPhi*180/TMath::Pi());
906              printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
907              ellipse->CerenkovRingDrawing(chamber,irec);
908              //ellipse->SetFillStyle(1001);
909              ellipse->SetMarkerColor(38);
910              ellipse->Draw();
911              //marker->SetRefObject((TObject*)points1D);
912              //points1D->Set3DMarker(0, marker); 
913            }
914          }
915      }
916
917    TClonesArray *pRICHrechits3D  = pRICH->RecHitsAddress3D(chamber);
918    //printf ("Chamber:%d\n", chamber);
919    if (pRICHrechits3D != 0)
920      {
921        
922        //RICH->ResetRecHits();
923        
924        
925        Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
926        gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
927        Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
928        //printf ("nrechits3D:%d\n",nrechits3D);
929        if (nrechits3D != 0)
930          {
931            if (fRecpoints == 0) fRecpoints = new TObjArray(50);
932            
933            iChamber = &(pRICH->Chamber(chamber));
934            AliRICHRecHit3D  *mRec3D;
935            AliRICHPoints *points3D = 0;
936            //AliRICHEllipse *ellipse = 0;
937            //
938            //loop over all rechits and store their position  
939            
940            points3D = new AliRICHPoints(nrechits3D);
941            for (Int_t irec=0;irec<nrechits3D;irec++) {
942              mRec3D   = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
943              fRecpoints->AddAt(points3D,irec);
944              points3D->SetMarkerColor(42);
945              points3D->SetMarkerStyle(8);
946              points3D->SetMarkerSize(1.);
947              points3D->SetParticle(-1);
948              points3D->SetHitIndex(-1);
949              points3D->SetTrackIndex(-1);
950              points3D->SetDigitIndex(-1);
951              Float_t  vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
952              Float_t  vectorGlob[3];
953              iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
954              points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
955              //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
956              //Float_t phi   = iChamber->GetRotMatrix()->GetPhi();         
957              //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
958              //printf("Generating ellipse %d\n",irec);
959              AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
960              printf("Ring at x:%f, y:%f - Omega:%f rad, theta:%3.1f deg, phi:%3.1f deg\n",mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta*180/TMath::Pi(),mRec3D->fPhi*180/TMath::Pi());
961              //ellipse->CerenkovRingDrawing(chamber,irec);
962              //ellipse->SetFillStyle(1001);
963              ellipse->CreatePoints(chamber);
964              ellipse->SetMarkerStyle(7);
965              ellipse->SetMarkerColor(42);
966              ellipse->SetMarkerSize(1);
967              ellipse->Draw();
968              //marker->SetRefObject((TObject*)points3D);
969              //points3D->Set3DMarker(0, marker); 
970            }
971          }
972      }
973 }
974 //___________________________________________
975 void AliRICHDisplay::LoadDigits()
976 {
977 // Read digits info and store x,y,z info in arrays fPoints
978 // Loop on all detectors
979     
980    ResetPoints();
981    AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
982    AliRICHChamber*       iChamber;
983    AliSegmentation*      segmentation;
984    Int_t nAllDigits=0;
985    Int_t ich;
986
987    //printf("Entering LoadDigits\n");
988
989    if (gAlice->TreeD())
990      {
991    
992        for (ich=0; ich<kNCH; ich++) {
993          TClonesArray *pRICHdigits  = pRICH->DigitsAddress(ich);
994          //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
995          if (pRICHdigits == 0) continue;
996          gAlice->ResetDigits();
997          gAlice->TreeD()->GetEvent(0);
998          Int_t ndigits = pRICHdigits->GetEntriesFast();
999          //printf("ndigits:%d\n",ndigits);
1000          nAllDigits+=ndigits;
1001        }
1002        
1003        if (fPoints == 0) fPoints = new TObjArray(nAllDigits);   
1004        Int_t counter=0;
1005        for (ich=0; ich<kNCH; ich++) {
1006          TClonesArray *pRICHdigits  = pRICH->DigitsAddress(ich);
1007          if (pRICHdigits == 0) continue;
1008          gAlice->ResetDigits();
1009          gAlice->TreeD()->GetEvent(0);
1010          Int_t ndigits = pRICHdigits->GetEntriesFast();
1011          if (ndigits == 0) continue;
1012          iChamber = &(pRICH->Chamber(ich));
1013          segmentation=iChamber->GetSegmentationModel();
1014          Float_t dpx  = segmentation->Dpx();
1015          Float_t dpy  = segmentation->Dpy();
1016          
1017          //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1018          
1019          AliRICHDigit  *mdig;
1020          AliRICHPoints *points = 0;
1021          TMarker3DBox  *marker = 0;
1022          //
1023          //loop over all digits and store their position
1024          Int_t npoints=1;
1025          
1026          for (Int_t digit=0;digit<ndigits;digit++) {
1027            mdig    = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1028            points = new AliRICHPoints(npoints);
1029            fPoints->AddAt(points,counter);
1030            counter++;
1031            Int_t charge=mdig->Signal();
1032            Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1033            Int_t color=701+index;
1034            if (color>722) color=722;
1035            points->SetMarkerColor(color);
1036            points->SetMarkerStyle(21);
1037            points->SetMarkerSize(0.5);
1038            Float_t xpad, ypad, zpad;
1039            segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
1040            Float_t vectorLoc[3]={xpad,5,ypad};
1041            Float_t  vectorGlob[3];
1042            iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1043            points->SetParticle(-1);
1044            points->SetHitIndex(-1);
1045            points->SetTrackIndex(-1);
1046            points->SetDigitIndex(digit);
1047            points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1048            //printf("Y position (digit): %f\n", vectorGlob[1]);
1049            
1050            segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1051            Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1052            Float_t phi   = iChamber->GetRotMatrix()->GetPhi();     
1053            marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1054                                    dpy/2,0,dpx/2,theta,phi);
1055            marker->SetLineColor(2);
1056            marker->SetFillStyle(1001);
1057            marker->SetFillColor(color);
1058            marker->SetRefObject((TObject*)points);
1059            points->Set3DMarker(0, marker);
1060          } // loop over digits
1061        } // loop over chambers 
1062      } //if TreeD
1063 }
1064
1065
1066 //___________________________________________
1067 void AliRICHDisplay::LoadHits(Int_t chamber)
1068 {
1069 // Read hits info and store x,y,z info in arrays fPhits
1070 // Loop on all detectors
1071     
1072     
1073     fChamber=chamber; 
1074     ResetPhits();
1075     
1076     AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
1077     AliRICHChamber*  iChamber;
1078     
1079     iChamber = &(pRICH->Chamber(chamber-1));
1080     Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1081     Int_t track;
1082     
1083     if (fPhits == 0) fPhits = new TObjArray(ntracks);
1084     //TVector *xp = new TVector(1000);
1085     //TVector *yp = new TVector(1000);
1086     //TVector *zp = new TVector(1000);
1087     //TVector *ptrk = new TVector(1000);
1088     //TVector *phit = new TVector(1000);
1089     Int_t nAllHits=0;
1090     for (track=0; track<ntracks;track++) {
1091         gAlice->ResetHits();
1092         gAlice->TreeH()->GetEvent(track);
1093         TClonesArray *pRICHhits  = pRICH->Hits();
1094         if (pRICHhits == 0) return;
1095         Int_t nhits = pRICHhits->GetEntriesFast();
1096         nAllHits+=nhits;
1097     }
1098
1099     fPhits = new TObjArray(nAllHits);
1100
1101     Int_t npoints=0;
1102     for (track=0; track<ntracks;track++) {
1103         gAlice->ResetHits();
1104         gAlice->TreeH()->GetEvent(track);
1105         TClonesArray *pRICHhits  = pRICH->Hits();
1106         if (pRICHhits == 0) return;
1107         Int_t nhits = pRICHhits->GetEntriesFast();
1108         if (nhits == 0) continue;
1109         AliRICHHit *mHit;
1110         AliRICHPoints *points = 0;
1111         for (Int_t hit=0;hit<nhits;hit++) {
1112             points = new AliRICHPoints(1);
1113             fPhits->AddAt(points,npoints);
1114             mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1115             TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1116             if (current->GetPdgCode() == 50000050) {
1117                 points->SetMarkerColor(kBlue);
1118             } else if (current->GetPdgCode() == 50000051) {
1119                 points->SetMarkerColor(kYellow);
1120             } else {
1121                 points->SetMarkerColor(kRed);
1122             }
1123             points->SetMarkerStyle(5);
1124             points->SetMarkerSize(1.);
1125             points->SetParticle(mHit->Track());
1126             points->SetHitIndex(hit);
1127             points->SetTrackIndex(track);
1128             points->SetDigitIndex(-1);
1129             points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1130             //printf("Y position: %f\n", mHit->Y());
1131             npoints++;
1132         }
1133     }
1134 }
1135
1136 //_____________________________________________________________________________
1137
1138 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1139 {
1140 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1141 // Loop on all detectors
1142     
1143     fChamber=chamber; 
1144     ResetPCerenkovs();
1145     
1146     AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
1147     AliRICHChamber*  iChamber;
1148     
1149     iChamber = &(pRICH->Chamber(chamber-1));
1150     
1151     pRICH->SetTreeAddress();
1152     Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1153     
1154     if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1155     TVector *xp = new TVector(1000);
1156     TVector *yp = new TVector(1000);
1157     TVector *zp = new TVector(1000);
1158     TVector *ptrk = new TVector(1000);
1159     TVector *phit = new TVector(1000);
1160     for (Int_t track=0; track<ntracks;track++) {
1161         gAlice->ResetHits();
1162         gAlice->TreeH()->GetEvent(track);
1163         TClonesArray *pRICHCerenkovs  = pRICH->Cerenkovs();
1164         if (pRICHCerenkovs == 0) return;
1165         Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1166         if (nhits == 0) continue;
1167         AliRICHCerenkov *mCerenkov;
1168         AliRICHPoints *cpoints = 0;
1169         Int_t npoints=0;
1170         
1171         
1172 //Display Cerenkov hits in blue
1173         
1174         for (Int_t hit=0;hit<nhits;hit++) {
1175             mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1176             (*xp)(npoints)=mCerenkov->X();
1177             (*yp)(npoints)=mCerenkov->Y();
1178             (*zp)(npoints)=mCerenkov->Z();
1179             (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1180             (*phit)(npoints)=Float_t(hit);
1181             npoints++;
1182         }
1183         if (npoints == 0) continue;
1184         cpoints = new AliRICHPoints(npoints);
1185         for (Int_t p=0;p<npoints;p++) {
1186             cpoints->SetMarkerColor(kBlue);
1187             cpoints->SetMarkerStyle(5);
1188             cpoints->SetMarkerSize(1.);
1189             cpoints->SetParticle(Int_t((*ptrk)(p)));
1190             cpoints->SetHitIndex(Int_t((*phit)(p)));
1191             cpoints->SetTrackIndex(track);
1192             cpoints->SetDigitIndex(-1);
1193             cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1194         }
1195         xp->Zero();
1196         yp->Zero();
1197         ptrk->Zero();
1198         phit->Zero();
1199         fPCerenkovs->AddAt(cpoints,track);
1200     }
1201 }
1202
1203 //_____________________________________________________________________________
1204 void AliRICHDisplay::Paint(Option_t *)
1205 {
1206 //    Paint miscellaneous items
1207
1208 }
1209
1210 //_____________________________________________________________________________
1211 void AliRICHDisplay::SetPickMode()
1212 {
1213
1214 // Toggle pick mode
1215
1216     fZoomMode = 0;
1217     
1218     fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1219     fTrigPad->Modified();
1220 }
1221
1222 //_____________________________________________________________________________
1223 void AliRICHDisplay::SetZoomMode()
1224 {
1225
1226 // Toggle Zoom mode
1227
1228     fZoomMode = 1;
1229     
1230     fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1231     fTrigPad->Modified();
1232 }
1233
1234 //_____________________________________________________________________________
1235 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1236 {
1237 // Set chamber and cathode number
1238     fChamber = chamber;
1239     fCathode = cathode;
1240     
1241     //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1242     if (!fPad) return;
1243     fPad->Clear();
1244     LoadDigits();
1245     Draw();
1246 }
1247
1248 //_____________________________________________________________________________
1249 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1250 {
1251 // Set view range along R and Z
1252     fRrange = rrange;
1253     fZrange = zrange;
1254     
1255    if (!fPad) return;
1256    fPad->Clear();
1257    Draw();
1258 }
1259
1260 //_____________________________________________________________________________
1261 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1262 {
1263 //  change viewing angles for current event
1264     
1265     fPad->cd();
1266     fPhi   = phi;
1267     fTheta = theta;
1268     fPsi   = psi;
1269     Int_t iret = 0;
1270     
1271     TView *view = gPad->GetView();
1272     if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1273     else      Draw();
1274     
1275     gPad->Modified();
1276 }
1277
1278 //_____________________________________________________________________________
1279 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1280 {
1281 //  Display (current event_number+delta)
1282 //    delta =  1  shown next event
1283 //    delta = -1 show previous event
1284     
1285     if (delta) {
1286         gAlice->Clear();
1287         Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1288         Int_t newEvent     = currentEvent + delta;
1289         gAlice->GetEvent(newEvent);
1290         if (!gAlice->TreeD()) return; 
1291     }
1292     LoadDigits();
1293     DrawClusters();
1294     fPad->cd(); 
1295     Draw();
1296
1297   
1298 }
1299
1300 //______________________________________________________________________________
1301 void AliRICHDisplay::UnZoom()
1302 {
1303
1304 // Return to previous zoom factor
1305
1306     if (fZooms <= 0) return;
1307     fZooms--;
1308     TPad *pad = (TPad*)gPad->GetPadSave();
1309     pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1310     pad->Modified();
1311 }
1312
1313 //_____________________________________________________________________________
1314 void AliRICHDisplay::ResetPoints()
1315 {
1316     //
1317     // Reset array of points
1318     //
1319     if (fPoints) {
1320         fPoints->Delete();
1321         delete fPoints;
1322         fPoints = 0;
1323   }
1324 }
1325 //_____________________________________________________________________________
1326 void AliRICHDisplay::ResetRpoints()
1327 {
1328   //
1329   // Reset array of points
1330   //
1331   if (fRpoints) {
1332     fRpoints->Delete();
1333     delete fRpoints;
1334     fRpoints = 0;
1335   }
1336 }
1337 //_____________________________________________________________________________
1338 void AliRICHDisplay::ResetRecpoints()
1339 {
1340   //
1341   // Reset array of points
1342   //
1343   if (fRecpoints) {
1344     fRecpoints->Delete();
1345     delete fRecpoints;
1346     fRecpoints = 0;
1347   }
1348 }
1349 //_____________________________________________________________________________
1350 void AliRICHDisplay::ResetPhits()
1351 {
1352     //
1353     // Reset array of points
1354     //
1355     if (fPhits) {
1356         fPhits->Delete();
1357         delete fPhits;
1358         fPhits = 0;
1359     }
1360 }
1361 //_____________________________________________________________________________
1362 void AliRICHDisplay::ResetPCerenkovs()
1363 {
1364     //
1365     // Reset array of points
1366     //
1367     if (fPCerenkovs) {
1368         fPCerenkovs->Delete();
1369         delete fPCerenkovs;
1370         fPCerenkovs = 0;
1371     }
1372 }
1373
1374 //_____________________________________________________________________________
1375
1376 void AliRICHDisplay::DrawViewGL()
1377 {
1378 //    Draw current view using OPENGL
1379
1380    TPad *pad = (TPad*)gPad->GetPadSave();
1381    pad->cd();
1382    TView *view = pad->GetView();
1383    if (!view) return;
1384    pad->x3d("OPENGL");
1385 }
1386
1387 //_____________________________________________________________________________
1388 void AliRICHDisplay::DrawViewX3D()
1389 {
1390 //    Draw current view using X3D
1391
1392    TPad *pad = (TPad*)gPad->GetPadSave();
1393    pad->cd();
1394    TView *view = pad->GetView();
1395    if (!view) return;
1396    pad->x3d();
1397 }