1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.16 2001/10/21 18:31:24 hristov
19 Several pointers were set to zero in the default constructors to avoid memory management problems
21 Revision 1.15 2001/10/09 07:34:09 hristov
22 Modifications needed by Root.03.01.06 (J.Chudoba)
24 Revision 1.14 2001/05/16 14:57:20 alibrary
25 New files for folders and Stack
27 Revision 1.13 2001/05/10 12:35:16 jbarbosa
28 Removed hit display, added rec. ring properties.
30 Revision 1.12 2001/03/14 18:15:03 jbarbosa
31 Changes to adapt to new IO.
32 Removed verbose output.
34 Revision 1.11 2001/02/27 15:21:34 jbarbosa
35 Transition to SDigits.
37 Revision 1.10 2001/02/13 20:18:48 jbarbosa
38 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
40 Revision 1.9 2000/11/01 15:33:11 jbarbosa
41 Updated to handle both reconstruction algorithms.
43 Revision 1.8 2000/10/03 21:44:09 morsch
44 Use AliSegmentation and AliHit abstract base classes.
46 Revision 1.7 2000/10/02 21:28:12 fca
47 Removal of useless dependecies via forward declarations
49 Revision 1.6 2000/10/02 15:46:38 jbarbosa
50 Fixed forward declarations.
52 Revision 1.5 2000/06/30 16:49:34 dibari
53 Different call for ring drawing.
55 Revision 1.4 2000/06/12 15:21:08 jbarbosa
58 Revision 1.3 2000/06/09 14:52:08 jbarbosa
59 New tentative ellipse drawing routine
61 Revision 1.1 2000/04/19 13:07:45 morsch
62 Digits, clusters and reconstruction results added.
67 //////////////////////////////////////////////////////////////////////////
71 // Utility class to display ALICE outline, tracks, hits,.. //
73 //////////////////////////////////////////////////////////////////////////
82 #include <TPolyMarker3D.h>
85 #include <TPolyMarker.h>
86 #include <TPaveLabel.h>
87 #include <TPaveText.h>
94 #include <TGeometry.h>
95 #include <TSliderBox.h>
97 #include <TVirtualX.h>
100 #include <X3DBuffer.h>
101 #include <TParticle.h>
105 #include "AliDetector.h"
107 #include "AliRICHConst.h"
108 #include "AliRICHDisplay.h"
109 #include "AliRICHPoints.h"
110 #include "AliHeader.h"
112 #include "AliRICHHit.h"
113 #include "AliRICHCerenkov.h"
114 #include "AliRICHSDigit.h"
115 #include "AliRICHDigit.h"
116 #include "AliRICHRawCluster.h"
117 #include "AliRICHRecHit1D.h"
118 #include "AliRICHRecHit3D.h"
119 #include "AliRICHEllipse.h"
121 ClassImp(AliRICHDisplay)
124 //____________________________________________________________________________
125 AliRICHDisplay::AliRICHDisplay()
128 // default constructor
138 //_____________________________________________________________________________
139 AliRICHDisplay::AliRICHDisplay(Int_t size)
141 // Create an event display object.
142 // A canvas named "edisplay" is created with a vertical size in pixels
144 // A QUICK Overview of the Event Display functions
145 // ===============================================
147 // The event display can ve invoked by executing the macro "display.C"
148 // A canvas like in the picture below will appear.
150 // On the left side of the canvas, the following buttons appear:
151 // *Next* to move to the next event
152 // *Previous* to move to the previous event
154 // *Pick* Select this option to be able to point on a track with the
155 // mouse. Once on the track, use the right button to select
156 // an action. For example, select SetMarkerAttributes to
157 // change the marker type/color/size for the track.
158 // *Zoom* Select this option (default) if you want to zoom.
159 // To zoom, simply select the selected area with the left button.
160 // *UnZoom* To revert to the previous picture size.
162 // slider R On the left side, the vertical slider can be used to
163 // set the default picture size.
165 // When you are in Zoom mode, you can click on the black part of the canvas
166 // to select special options with the right mouse button.
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.
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.
181 // Click on TPC for example
182 // Click on any variable (eg TPC.fX) to histogram the variable.
184 // If you are lost, you can click on HELP in any Root canvas or browser.
187 <img src="gif/AliRICHDisplay.gif">
194 gAlice->SetDisplay(this);
196 // Initialize display default parameters
199 // Set front view by default
206 fDrawClusters = kTRUE;
208 fDrawRecHits = kTRUE;
219 // Create display canvas
221 if (ysize < 100) ysize = 750;
222 Int_t xsize = Int_t(size*830./ysize);
223 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
224 fCanvas->ToggleEventStatus();
226 // Create main display pad
227 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
230 fPad->SetFillColor(1);
231 fPad->SetBorderSize(2);
236 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
239 fColPad->SetFillColor(19);
240 fColPad->SetBorderSize(2);
246 // Create user interface control pad
250 // Create Range and mode pad
253 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
256 fTrigPad->SetFillColor(22);
257 fTrigPad->SetBorderSize(2);
258 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
259 fRangeSlider->SetObject(this);
260 char pickmode[] = "gAlice->Display()->SetPickMode()";
262 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
263 fPickButton->SetFillColor(38);
265 char zoommode[] = "gAlice->Display()->SetZoomMode()";
266 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
267 fZoomButton->SetFillColor(38);
269 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
270 fArcButton->SetFillColor(kGreen);
272 char butUnzoom[] = "gAlice->Display()->UnZoom()";
273 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
274 button->SetFillColor(38);
276 AppendPad(); // append display object as last object to force selection
278 fTrigPad->SetEditable(kFALSE);
279 fButtons->SetEditable(kFALSE);
285 //_____________________________________________________________________________
286 AliRICHDisplay::~AliRICHDisplay()
288 // Delete space point structure
289 if (fPoints) fPoints->Delete();
293 if (fPhits) fPhits->Delete();
297 if (fRpoints) fRpoints->Delete();
301 if (fRecpoints) fRecpoints->Delete();
305 if (fPCerenkovs) fPCerenkovs->Delete();
310 //_____________________________________________________________________________
311 void AliRICHDisplay::Clear(Option_t *)
313 // Delete graphics temporary objects
316 //_____________________________________________________________________________
317 void AliRICHDisplay::DisplayButtons()
319 // Create the user interface buttons
322 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
324 fButtons->SetFillColor(38);
325 fButtons->SetBorderSize(2);
328 // Int_t butcolor = 33;
329 Float_t dbutton = 0.08;
336 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
337 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
338 button->SetFillColor(38);
342 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
343 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
344 button->SetFillColor(38);
348 char but7[] = "gAlice->Display()->DrawViewGL()";
349 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
350 button->SetFillColor(38);
354 char but8[] = "gAlice->Display()->DrawViewX3D()";
355 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
356 button->SetFillColor(38);
360 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
361 diamond->SetFillColor(50);
362 diamond->SetTextAlign(22);
363 diamond->SetTextColor(5);
364 diamond->SetTextSize(0.11);
366 diamond->AddText(".. ");
367 diamond->AddText("ROOT");
368 diamond->AddText("RICH");
369 diamond->AddText("... ");
370 diamond->AddText(" ");
373 //_____________________________________________________________________________
374 void AliRICHDisplay::CreateColors()
376 // Create the colors palette used to display clusters
391 new TColor(color,r,g,b);
401 new TColor(color,r,g,b);
411 new TColor(color,r,g,b);
421 new TColor(color,r,g,b);
431 new TColor(color,r,g,b);
438 //_____________________________________________________________________________
439 void AliRICHDisplay::DisplayColorScale()
442 // Draw the color scale in the RICH display canvas
446 Float_t xlow, ylow, xup, yup, hs;
447 Float_t x1, y1, x2, y2;
451 gPad->SetFillColor(0);
453 gPad->Range(x1,y1,x2,y2);
454 TText *text = new TText(0,0,"");
455 text->SetTextFont(61);
456 text->SetTextSize(0.03);
457 text->SetTextAlign(22);
461 //*-* draw colortable boxes
462 hs = (y2-y1)/Float_t(22);
466 ylow = y1 + hs*(Float_t(i));
467 yup = y1 + hs*(Float_t(i+1));
469 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
470 Int_t scale=(Int_t)TMath::Exp(logscale);
471 sprintf(label,"%d",scale);
472 box = new TBox(xlow, ylow, xup, yup);
473 box->SetFillColor(color);
475 text->DrawText(xup+4, 0.5*(ylow+yup),label);
479 //______________________________________________________________________________
480 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
482 // Compute distance from point px,py to objects in event
484 gPad->SetCursor(kCross);
486 if (gPad == fTrigPad) return 9999;
488 const Int_t kBig = 9999;
490 Float_t xmin = gPad->GetX1();
491 Float_t xmax = gPad->GetX2();
492 Float_t dx = 0.02*(xmax - xmin);
493 Float_t x = gPad->AbsPixeltoX(px);
494 if (x < xmin+dx || x > xmax-dx) return dist;
495 if (fZoomMode) return 0;
499 //_____________________________________________________________________________
500 void AliRICHDisplay::Draw(Option_t *)
502 // Display current event
506 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
508 // Display the event number and title
513 //_____________________________________________________________________________
514 void AliRICHDisplay::DrawCoG()
516 // Draw hits for RICH chambers
518 if (!fDrawCoG) return;
520 for (Int_t chamber=0;chamber<kNCH;chamber++) {
529 ncog = points->GetEntriesFast();
530 for (icog=0; icog < ncog; icog++) {
531 pm = (AliRICHPoints*)points->UncheckedAt(icog);
537 void AliRICHDisplay::DrawRecHits()
539 // Draw rec hits for RICH chambers
541 if (!fDrawRecHits) return;
543 for (Int_t chamber=0;chamber<kNCH;chamber++) {
544 LoadRecHits(chamber,1);
552 nrec = points->GetEntriesFast();
553 //printf("Nrec %d\n",nrec);
554 for (irec=0; irec < nrec; irec++) {
555 pm = (AliRICHPoints*)points->UncheckedAt(irec);
561 //_____________________________________________________________________________
563 void AliRICHDisplay::DrawCerenkovs()
565 // Draw cerenkovs hits for RICH chambers
567 LoadCerenkovs(fChamber);
568 //printf("\nDrawCerenkovs\n");
570 Int_t ntracks, track;
575 cpoints = fPCerenkovs;
576 //printf ("Cpoints: %p",cpoints);
577 if (!cpoints) return;
578 ntracks = cpoints->GetEntriesFast();
579 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
580 for (track=0;track<ntracks;track++) {
581 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
584 fHitsCuts += pm->GetN();
588 //_____________________________________________________________________________
590 void AliRICHDisplay::DrawClusters()
592 // Draw clusterss for RICH chambers
594 Int_t ndigits, digit;
601 ndigits = points->GetEntriesFast();
602 for (digit=0;digit<ndigits;digit++){
603 pm = (AliRICHPoints*)points->UncheckedAt(digit);
608 for (Int_t im=0;im<3;im++) {
609 TMarker3DBox *marker=pm->GetMarker(im);
613 fClustersCuts +=pm->GetN();
617 //_____________________________________________________________________________
618 void AliRICHDisplay::DrawHits()
620 // Draw hits for RICH chambers
624 Int_t ntracks, track;
631 // ntracks = points->GetEntriesFast();
632 ntracks = fPhits->GetEntriesFast();
634 //printf("DrawHits - ntracks %d \n",ntracks);
635 for (track=0;track<ntracks;track++) {
636 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
639 fHitsCuts += pm->GetN();
644 //_____________________________________________________________________________
645 void AliRICHDisplay::DrawTitle(Option_t *option)
647 // Draw the event title
649 Float_t xmin = gPad->GetX1();
650 Float_t xmax = gPad->GetX2();
651 Float_t ymin = gPad->GetY1();
652 Float_t ymax = gPad->GetY2();
653 Float_t dx = xmax-xmin;
654 Float_t dy = ymax-ymin;
656 if (strlen(option) == 0) {
657 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
658 title->SetBit(kCanDelete);
659 title->SetFillColor(42);
662 sprintf(ptitle,"Alice event: %d, Run:%d",
663 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
664 title->AddText(ptitle);
665 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
666 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
667 nparticles, fHitsCuts,fClustersCuts);
668 title->AddText(ptitle);
671 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
672 label->SetBit(kCanDelete);
673 label->SetFillColor(42);
678 //_____________________________________________________________________________
679 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
681 // Draw a view of RICH clusters
683 gPad->SetCursor(kWatch);
684 gPad->SetFillColor(1);
688 TView *view = new TView(1);
689 Float_t range = fRrange*fRangeSlider->GetMaximum();
690 view->SetRange(-range,-range,-range,range, range, range);
697 //Display RICH Chamber Geometry
698 gAlice->GetGeometry()->Draw("same");
700 //add clusters to the pad
706 //printf("Calling DrawCoG\n");
708 //printf("Calling DrawRecHits\n");
711 /*for (Int_t i=0;i<7;i++)
714 // add itself to the list (must be last)
717 view->SetView(phi, theta, psi, iret);
720 //______________________________________________________________________________
721 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
723 // Execute action corresponding to the mouse event
725 static Float_t x0, y0, x1, y1;
727 static Int_t pxold, pyold;
728 static Int_t px0, py0;
729 static Int_t linedrawn;
732 if (px == 0 && py == 0) { //when called by sliders
733 if (event == kButton1Up) {
734 printf("Drawing event %d\n",event);
739 if (!fZoomMode && gPad->GetView()) {
740 gPad->GetView()->ExecuteRotateView(event, px, py);
744 // something to zoom ?
745 gPad->SetCursor(kCross);
750 gVirtualX->SetLineColor(-1);
751 gPad->TAttLine::Modify(); //Change line attributes only if necessary
752 x0 = gPad->AbsPixeltoX(px);
753 y0 = gPad->AbsPixeltoY(py);
755 pxold = px; pyold = py;
760 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
764 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
768 gPad->GetCanvas()->FeedbackMode(kFALSE);
769 if (px == px0) return;
770 if (py == py0) return;
771 x1 = gPad->AbsPixeltoX(px);
772 y1 = gPad->AbsPixeltoY(py);
774 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
775 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
776 gPad->Range(x0,y0,x1,y1);
777 if (fZooms < kMAXZOOM-1) {
779 fZoomX0[fZooms] = x0;
780 fZoomY0[fZooms] = y0;
781 fZoomX1[fZooms] = x1;
782 fZoomY1[fZooms] = y1;
784 gPad->Modified(kTRUE);
789 //___________________________________________
790 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
792 // Read raw clusters info and store x,y,z info in arrays fRpoints
793 // Loop on all detectors
795 if (chamber > 6) return;
797 //printf("Entering LoadCoG\n");
800 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
801 AliRICHChamber* iChamber;
803 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
804 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
805 if (pRICHrawclust == 0) return;
807 pRICH->ResetRawClusters();
810 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
811 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
812 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
813 //printf ("nrawcl:%d\n",nrawcl);
814 if (nrawcl == 0) return;
815 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
817 iChamber = &(pRICH->Chamber(chamber));
818 AliRICHRawCluster *mRaw;
819 AliRICHPoints *points = 0;
821 //loop over all raw clusters and store their position
822 points = new AliRICHPoints(nrawcl);
823 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
824 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
825 fRpoints->AddAt(points,iraw);
826 points->SetMarkerColor(3);
827 points->SetMarkerStyle(3);
828 points->SetMarkerSize(1.);
829 points->SetParticle(-1);
830 points->SetHitIndex(-1);
831 points->SetTrackIndex(-1);
832 points->SetDigitIndex(-1);
833 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
834 Float_t vectorGlob[3];
835 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
836 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
839 //___________________________________________
840 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
842 // Read rec. hits info
843 // Loop on all detectors
845 if (chamber > 6) return;
847 ///printf("Entering LoadRecHits\n");
850 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
851 AliRICHChamber* iChamber;
853 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
854 //printf ("Chamber:%d\n", chamber);
855 if (pRICHrechits1D != 0)
858 //RICH->ResetRecHits();
861 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
862 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
863 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
864 //printf ("nrechits1D:%d\n",nrechits1D);
867 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
869 iChamber = &(pRICH->Chamber(chamber));
870 AliRICHRecHit1D *mRec1D;
871 AliRICHPoints *points1D = 0;
872 //AliRICHEllipse *ellipse = 0;
874 //loop over all rechits and store their position
876 points1D = new AliRICHPoints(nrechits1D);
877 for (Int_t irec=0;irec<nrechits1D;irec++) {
878 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
879 fRecpoints->AddAt(points1D,irec);
880 points1D->SetMarkerColor(38);
881 points1D->SetMarkerStyle(8);
882 points1D->SetMarkerSize(1.);
883 points1D->SetParticle(-1);
884 points1D->SetHitIndex(-1);
885 points1D->SetTrackIndex(-1);
886 points1D->SetDigitIndex(-1);
887 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
888 Float_t vectorGlob[3];
889 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
890 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
891 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
892 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
893 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
894 //printf("Generating ellipse %d\n",irec);
895 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
896 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());
897 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
898 ellipse->CerenkovRingDrawing(chamber,irec);
899 //ellipse->SetFillStyle(1001);
900 ellipse->SetMarkerColor(38);
902 //marker->SetRefObject((TObject*)points1D);
903 //points1D->Set3DMarker(0, marker);
908 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
909 //printf ("Chamber:%d\n", chamber);
910 if (pRICHrechits3D != 0)
913 //RICH->ResetRecHits();
916 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
917 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
918 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
919 //printf ("nrechits3D:%d\n",nrechits3D);
922 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
924 iChamber = &(pRICH->Chamber(chamber));
925 AliRICHRecHit3D *mRec3D;
926 AliRICHPoints *points3D = 0;
927 //AliRICHEllipse *ellipse = 0;
929 //loop over all rechits and store their position
931 points3D = new AliRICHPoints(nrechits3D);
932 for (Int_t irec=0;irec<nrechits3D;irec++) {
933 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
934 fRecpoints->AddAt(points3D,irec);
935 points3D->SetMarkerColor(42);
936 points3D->SetMarkerStyle(8);
937 points3D->SetMarkerSize(1.);
938 points3D->SetParticle(-1);
939 points3D->SetHitIndex(-1);
940 points3D->SetTrackIndex(-1);
941 points3D->SetDigitIndex(-1);
942 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
943 Float_t vectorGlob[3];
944 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
945 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
946 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
947 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
948 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
949 //printf("Generating ellipse %d\n",irec);
950 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
951 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());
952 ellipse->CerenkovRingDrawing(chamber,irec);
953 //ellipse->SetFillStyle(1001);
954 ellipse->SetMarkerColor(42);
956 //marker->SetRefObject((TObject*)points3D);
957 //points3D->Set3DMarker(0, marker);
962 //___________________________________________
963 void AliRICHDisplay::LoadDigits()
965 // Read digits info and store x,y,z info in arrays fPoints
966 // Loop on all detectors
969 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
970 AliRICHChamber* iChamber;
971 AliSegmentation* segmentation;
975 //printf("Entering LoadDigits\n");
980 for (ich=0; ich<kNCH; ich++) {
981 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
982 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
983 if (pRICHdigits == 0) continue;
984 gAlice->ResetDigits();
985 gAlice->TreeD()->GetEvent(0);
986 Int_t ndigits = pRICHdigits->GetEntriesFast();
987 //printf("ndigits:%d\n",ndigits);
991 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
993 for (ich=0; ich<kNCH; ich++) {
994 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
995 if (pRICHdigits == 0) continue;
996 gAlice->ResetDigits();
997 gAlice->TreeD()->GetEvent(0);
998 Int_t ndigits = pRICHdigits->GetEntriesFast();
999 if (ndigits == 0) continue;
1000 iChamber = &(pRICH->Chamber(ich));
1001 segmentation=iChamber->GetSegmentationModel();
1002 Float_t dpx = segmentation->Dpx();
1003 Float_t dpy = segmentation->Dpy();
1005 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1008 AliRICHPoints *points = 0;
1009 TMarker3DBox *marker = 0;
1011 //loop over all digits and store their position
1014 for (Int_t digit=0;digit<ndigits;digit++) {
1015 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1016 points = new AliRICHPoints(npoints);
1017 fPoints->AddAt(points,counter);
1019 Int_t charge=mdig->Signal();
1020 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1021 Int_t color=701+index;
1022 if (color>722) color=722;
1023 points->SetMarkerColor(color);
1024 points->SetMarkerStyle(21);
1025 points->SetMarkerSize(0.5);
1026 Float_t xpad, ypad, zpad;
1027 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
1028 Float_t vectorLoc[3]={xpad,5,ypad};
1029 Float_t vectorGlob[3];
1030 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1031 points->SetParticle(-1);
1032 points->SetHitIndex(-1);
1033 points->SetTrackIndex(-1);
1034 points->SetDigitIndex(digit);
1035 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1036 //printf("Y position (digit): %f\n", vectorGlob[1]);
1038 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1039 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1040 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1041 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1042 dpy/2,0,dpx/2,theta,phi);
1043 marker->SetLineColor(2);
1044 marker->SetFillStyle(1001);
1045 marker->SetFillColor(color);
1046 marker->SetRefObject((TObject*)points);
1047 points->Set3DMarker(0, marker);
1048 } // loop over digits
1049 } // loop over chambers
1054 //___________________________________________
1055 void AliRICHDisplay::LoadHits(Int_t chamber)
1057 // Read hits info and store x,y,z info in arrays fPhits
1058 // Loop on all detectors
1064 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1065 AliRICHChamber* iChamber;
1067 iChamber = &(pRICH->Chamber(chamber-1));
1068 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1071 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1072 //TVector *xp = new TVector(1000);
1073 //TVector *yp = new TVector(1000);
1074 //TVector *zp = new TVector(1000);
1075 //TVector *ptrk = new TVector(1000);
1076 //TVector *phit = new TVector(1000);
1078 for (track=0; track<ntracks;track++) {
1079 gAlice->ResetHits();
1080 gAlice->TreeH()->GetEvent(track);
1081 TClonesArray *pRICHhits = pRICH->Hits();
1082 if (pRICHhits == 0) return;
1083 Int_t nhits = pRICHhits->GetEntriesFast();
1087 fPhits = new TObjArray(nAllHits);
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 if (nhits == 0) continue;
1098 AliRICHPoints *points = 0;
1099 for (Int_t hit=0;hit<nhits;hit++) {
1100 points = new AliRICHPoints(1);
1101 fPhits->AddAt(points,npoints);
1102 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1103 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1104 if (current->GetPdgCode() == 50000050) {
1105 points->SetMarkerColor(kBlue);
1106 } else if (current->GetPdgCode() == 50000051) {
1107 points->SetMarkerColor(kYellow);
1109 points->SetMarkerColor(kRed);
1111 points->SetMarkerStyle(5);
1112 points->SetMarkerSize(1.);
1113 points->SetParticle(mHit->Track());
1114 points->SetHitIndex(hit);
1115 points->SetTrackIndex(track);
1116 points->SetDigitIndex(-1);
1117 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1118 //printf("Y position: %f\n", mHit->Y());
1124 //_____________________________________________________________________________
1126 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1128 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1129 // Loop on all detectors
1134 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1135 AliRICHChamber* iChamber;
1137 iChamber = &(pRICH->Chamber(chamber-1));
1139 pRICH->SetTreeAddress();
1140 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1142 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1143 TVector *xp = new TVector(1000);
1144 TVector *yp = new TVector(1000);
1145 TVector *zp = new TVector(1000);
1146 TVector *ptrk = new TVector(1000);
1147 TVector *phit = new TVector(1000);
1148 for (Int_t track=0; track<ntracks;track++) {
1149 gAlice->ResetHits();
1150 gAlice->TreeH()->GetEvent(track);
1151 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1152 if (pRICHCerenkovs == 0) return;
1153 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1154 if (nhits == 0) continue;
1155 AliRICHCerenkov *mCerenkov;
1156 AliRICHPoints *cpoints = 0;
1160 //Display Cerenkov hits in blue
1162 for (Int_t hit=0;hit<nhits;hit++) {
1163 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1164 (*xp)(npoints)=mCerenkov->X();
1165 (*yp)(npoints)=mCerenkov->Y();
1166 (*zp)(npoints)=mCerenkov->Z();
1167 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1168 (*phit)(npoints)=Float_t(hit);
1171 if (npoints == 0) continue;
1172 cpoints = new AliRICHPoints(npoints);
1173 for (Int_t p=0;p<npoints;p++) {
1174 cpoints->SetMarkerColor(kBlue);
1175 cpoints->SetMarkerStyle(5);
1176 cpoints->SetMarkerSize(1.);
1177 cpoints->SetParticle(Int_t((*ptrk)(p)));
1178 cpoints->SetHitIndex(Int_t((*phit)(p)));
1179 cpoints->SetTrackIndex(track);
1180 cpoints->SetDigitIndex(-1);
1181 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1187 fPCerenkovs->AddAt(cpoints,track);
1191 //_____________________________________________________________________________
1192 void AliRICHDisplay::Paint(Option_t *)
1194 // Paint miscellaneous items
1198 //_____________________________________________________________________________
1199 void AliRICHDisplay::SetPickMode()
1206 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1207 fTrigPad->Modified();
1210 //_____________________________________________________________________________
1211 void AliRICHDisplay::SetZoomMode()
1218 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1219 fTrigPad->Modified();
1222 //_____________________________________________________________________________
1223 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1225 // Set chamber and cathode number
1229 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1236 //_____________________________________________________________________________
1237 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1239 // Set view range along R and Z
1248 //_____________________________________________________________________________
1249 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1251 // change viewing angles for current event
1259 TView *view = gPad->GetView();
1260 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1266 //_____________________________________________________________________________
1267 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1269 // Display (current event_number+delta)
1270 // delta = 1 shown next event
1271 // delta = -1 show previous event
1275 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1276 Int_t newEvent = currentEvent + delta;
1277 gAlice->GetEvent(newEvent);
1278 if (!gAlice->TreeD()) return;
1288 //______________________________________________________________________________
1289 void AliRICHDisplay::UnZoom()
1292 // Return to previous zoom factor
1294 if (fZooms <= 0) return;
1296 TPad *pad = (TPad*)gPad->GetPadSave();
1297 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1301 //_____________________________________________________________________________
1302 void AliRICHDisplay::ResetPoints()
1305 // Reset array of points
1313 //_____________________________________________________________________________
1314 void AliRICHDisplay::ResetRpoints()
1317 // Reset array of points
1325 //_____________________________________________________________________________
1326 void AliRICHDisplay::ResetRecpoints()
1329 // Reset array of points
1332 fRecpoints->Delete();
1337 //_____________________________________________________________________________
1338 void AliRICHDisplay::ResetPhits()
1341 // Reset array of points
1349 //_____________________________________________________________________________
1350 void AliRICHDisplay::ResetPCerenkovs()
1353 // Reset array of points
1356 fPCerenkovs->Delete();
1362 //_____________________________________________________________________________
1364 void AliRICHDisplay::DrawViewGL()
1366 // Draw current view using OPENGL
1368 TPad *pad = (TPad*)gPad->GetPadSave();
1370 TView *view = pad->GetView();
1375 //_____________________________________________________________________________
1376 void AliRICHDisplay::DrawViewX3D()
1378 // Draw current view using X3D
1380 TPad *pad = (TPad*)gPad->GetPadSave();
1382 TView *view = pad->GetView();