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 //////////////////////////////////////////////////////////////////////////
22 // Utility class to display ALICE outline, tracks, hits,.. //
24 //////////////////////////////////////////////////////////////////////////
33 #include <TPolyMarker3D.h>
36 #include <TPolyMarker.h>
37 #include <TPaveLabel.h>
38 #include <TPaveText.h>
45 #include <TGeometry.h>
46 #include <TSliderBox.h>
48 #include <TVirtualX.h>
51 #include <X3DBuffer.h>
52 #include <TParticle.h>
56 #include "AliDetector.h"
58 #include "AliRICHConst.h"
59 #include "AliRICHDisplay.h"
60 #include "AliRICHPoints.h"
61 #include "AliHeader.h"
63 #include "AliRICHSDigit.h"
64 #include "AliRICHDigit.h"
65 #include "AliRICHRawCluster.h"
66 #include "AliRICHRecHit1D.h"
67 #include "AliRICHRecHit3D.h"
68 #include "AliRICHEllipse.h"
70 ClassImp(AliRICHDisplay)
73 //____________________________________________________________________________
74 AliRICHDisplay::AliRICHDisplay()
77 // default constructor
87 //_____________________________________________________________________________
88 AliRICHDisplay::AliRICHDisplay(Int_t size)
90 // Create an event display object.
91 // A canvas named "edisplay" is created with a vertical size in pixels
93 // A QUICK Overview of the Event Display functions
94 // ===============================================
96 // The event display can ve invoked by executing the macro "display.C"
97 // A canvas like in the picture below will appear.
99 // On the left side of the canvas, the following buttons appear:
100 // *Next* to move to the next event
101 // *Previous* to move to the previous event
103 // *Pick* Select this option to be able to point on a track with the
104 // mouse. Once on the track, use the right button to select
105 // an action. For example, select SetMarkerAttributes to
106 // change the marker type/color/size for the track.
107 // *Zoom* Select this option (default) if you want to zoom.
108 // To zoom, simply select the selected area with the left button.
109 // *UnZoom* To revert to the previous picture size.
111 // slider R On the left side, the vertical slider can be used to
112 // set the default picture size.
114 // When you are in Zoom mode, you can click on the black part of the canvas
115 // to select special options with the right mouse button.
118 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
119 // When you are on a track, select the menu item "InspectParticle"
120 // to display the current particle attributes.
122 // You can activate the Root browser by selecting the Inspect menu
123 // in the canvas tool bar menu. Then select "Start Browser"
124 // This will open a new canvas with the browser. At this point, you may want
125 // to display some histograms (from the Trees). Go to the "File" menu
126 // of the browser and click on "New canvas".
127 // In the browser, click on item "ROOT files" in the left pane.
128 // Click on galice.root.
130 // Click on TPC for example
131 // Click on any variable (eg TPC.fX) to histogram the variable.
133 // If you are lost, you can click on HELP in any Root canvas or browser.
136 <img src="gif/AliRICHDisplay.gif">
143 gAlice->SetDisplay(this);
145 // Initialize display default parameters
148 // Set front view by default
149 fTheta = 90; //inclined HMPID
150 fPhi = 30; //inclined HMPID
151 //fTheta = 90; //normal HMPID
152 //fPhi = 90; //normal HMPID
157 fDrawClusters = kTRUE;
159 fDrawRecHits = kTRUE;
170 // Create display canvas
172 if (ysize < 100) ysize = 750;
173 Int_t xsize = Int_t(size*830./ysize);
174 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
175 fCanvas->ToggleEventStatus();
177 // Create main display pad
178 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
181 fPad->SetFillColor(1);
182 fPad->SetBorderSize(2);
187 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
190 fColPad->SetFillColor(19);
191 fColPad->SetBorderSize(2);
197 // Create user interface control pad
201 // Create Range and mode pad
204 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
207 fTrigPad->SetFillColor(22);
208 fTrigPad->SetBorderSize(2);
209 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
210 fRangeSlider->SetObject(this);
211 char pickmode[] = "gAlice->Display()->SetPickMode()";
213 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
214 fPickButton->SetFillColor(38);
216 char zoommode[] = "gAlice->Display()->SetZoomMode()";
217 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
218 fZoomButton->SetFillColor(38);
220 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
221 fArcButton->SetFillColor(kGreen);
223 char butUnzoom[] = "gAlice->Display()->UnZoom()";
224 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
225 button->SetFillColor(38);
227 AppendPad(); // append display object as last object to force selection
229 fTrigPad->SetEditable(kFALSE);
230 fButtons->SetEditable(kFALSE);
236 //_____________________________________________________________________________
237 AliRICHDisplay::~AliRICHDisplay()
239 // Delete space point structure
240 if (fPoints) fPoints->Delete();
244 if (fPhits) fPhits->Delete();
248 if (fRpoints) fRpoints->Delete();
252 if (fRecpoints) fRecpoints->Delete();
256 if (fPCerenkovs) fPCerenkovs->Delete();
261 //_____________________________________________________________________________
262 void AliRICHDisplay::Clear(Option_t *)
264 // Delete graphics temporary objects
267 //_____________________________________________________________________________
268 void AliRICHDisplay::DisplayButtons()
270 // Create the user interface buttons
273 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
275 fButtons->SetFillColor(38);
276 fButtons->SetBorderSize(2);
279 // Int_t butcolor = 33;
280 Float_t dbutton = 0.08;
287 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
288 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
289 button->SetFillColor(38);
293 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
294 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
295 button->SetFillColor(38);
299 char but7[] = "gAlice->Display()->DrawViewGL()";
300 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
301 button->SetFillColor(38);
305 char but8[] = "gAlice->Display()->DrawViewX3D()";
306 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
307 button->SetFillColor(38);
311 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
312 diamond->SetFillColor(50);
313 diamond->SetTextAlign(22);
314 diamond->SetTextColor(5);
315 diamond->SetTextSize(0.11);
317 diamond->AddText(".. ");
318 diamond->AddText("ROOT");
319 diamond->AddText("RICH");
320 diamond->AddText("... ");
321 diamond->AddText(" ");
324 //_____________________________________________________________________________
325 void AliRICHDisplay::CreateColors()
327 // Create the colors palette used to display clusters
342 new TColor(color,r,g,b);
352 new TColor(color,r,g,b);
362 new TColor(color,r,g,b);
372 new TColor(color,r,g,b);
382 new TColor(color,r,g,b);
389 //_____________________________________________________________________________
390 void AliRICHDisplay::DisplayColorScale()
393 // Draw the color scale in the RICH display canvas
397 Float_t xlow, ylow, xup, yup, hs;
398 Float_t x1, y1, x2, y2;
402 gPad->SetFillColor(0);
404 gPad->Range(x1,y1,x2,y2);
405 TText *text = new TText(0,0,"");
406 text->SetTextFont(61);
407 text->SetTextSize(0.2);
408 text->SetTextAlign(22);
412 //*-* draw colortable boxes
413 hs = (y2-y1)/Float_t(22);
417 ylow = y1 + hs*(Float_t(i));
418 yup = y1 + hs*(Float_t(i+1));
420 Double_t logscale=Double_t(i+1)*(TMath::Log(kadc_satm)/22);
421 Int_t scale=(Int_t)TMath::Exp(logscale);
422 sprintf(label,"%d",scale);
423 box = new TBox(xlow, ylow, xup, yup);
424 box->SetFillColor(color);
426 text->DrawText(xup+4, 0.5*(ylow+yup),label);
430 //______________________________________________________________________________
431 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
433 // Compute distance from point px,py to objects in event
435 gPad->SetCursor(kCross);
437 if (gPad == fTrigPad) return 9999;
439 const Int_t kBig = 9999;
441 Float_t xmin = gPad->GetX1();
442 Float_t xmax = gPad->GetX2();
443 Float_t dx = 0.02*(xmax - xmin);
444 Float_t x = gPad->AbsPixeltoX(px);
445 if (x < xmin+dx || x > xmax-dx) return dist;
446 if (fZoomMode) return 0;
450 //_____________________________________________________________________________
451 void AliRICHDisplay::Draw(Option_t *)
453 // Display current event
457 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
459 // Display the event number and title
464 //_____________________________________________________________________________
465 void AliRICHDisplay::DrawCoG()
467 // Draw hits for RICH chambers
469 if (!fDrawCoG) return;
471 for (Int_t chamber=0;chamber<kNCH;chamber++) {
480 ncog = points->GetEntriesFast();
481 for (icog=0; icog < ncog; icog++) {
482 pm = (AliRICHPoints*)points->UncheckedAt(icog);
488 void AliRICHDisplay::DrawRecHits()
490 // Draw rec hits for RICH chambers
492 if (!fDrawRecHits) return;
494 for (Int_t chamber=0;chamber<kNCH;chamber++) {
495 LoadRecHits(chamber,1);
503 nrec = points->GetEntriesFast();
504 //printf("Nrec %d\n",nrec);
505 for (irec=0; irec < nrec; irec++) {
506 pm = (AliRICHPoints*)points->UncheckedAt(irec);
512 //_____________________________________________________________________________
514 void AliRICHDisplay::DrawCerenkovs()
516 // Draw cerenkovs hits for RICH chambers
518 LoadCerenkovs(fChamber);
519 //printf("\nDrawCerenkovs\n");
521 Int_t ntracks, track;
526 cpoints = fPCerenkovs;
527 //printf ("Cpoints: %p",cpoints);
528 if (!cpoints) return;
529 ntracks = cpoints->GetEntriesFast();
530 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
531 for (track=0;track<ntracks;track++) {
532 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
535 fHitsCuts += pm->GetN();
539 //_____________________________________________________________________________
541 void AliRICHDisplay::DrawClusters()
543 // Draw clusterss for RICH chambers
545 Int_t ndigits, digit;
552 ndigits = points->GetEntriesFast();
553 for (digit=0;digit<ndigits;digit++){
554 pm = (AliRICHPoints*)points->UncheckedAt(digit);
559 for (Int_t im=0;im<3;im++) {
560 TMarker3DBox *marker=pm->GetMarker(im);
564 fClustersCuts +=pm->GetN();
568 //_____________________________________________________________________________
569 void AliRICHDisplay::DrawHits()
571 // Draw hits for RICH chambers
575 Int_t ntracks, track;
582 // ntracks = points->GetEntriesFast();
583 ntracks = fPhits->GetEntriesFast();
585 //printf("DrawHits - ntracks %d \n",ntracks);
586 for (track=0;track<ntracks;track++) {
587 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
590 fHitsCuts += pm->GetN();
595 //_____________________________________________________________________________
596 void AliRICHDisplay::DrawTitle(Option_t *option)
598 // Draw the event title
600 Float_t xmin = gPad->GetX1();
601 Float_t xmax = gPad->GetX2();
602 Float_t ymin = gPad->GetY1();
603 Float_t ymax = gPad->GetY2();
604 Float_t dx = xmax-xmin;
605 Float_t dy = ymax-ymin;
607 if (strlen(option) == 0) {
608 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
609 title->SetBit(kCanDelete);
610 title->SetFillColor(42);
613 sprintf(ptitle,"Alice event: %d, Run:%d",
614 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
615 title->AddText(ptitle);
616 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
617 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
618 nparticles, fHitsCuts,fClustersCuts);
619 title->AddText(ptitle);
622 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
623 label->SetBit(kCanDelete);
624 label->SetFillColor(42);
629 //_____________________________________________________________________________
630 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
632 // Draw a view of RICH clusters
634 gPad->SetCursor(kWatch);
635 gPad->SetFillColor(1);
639 TView *view = new TView(1);
640 Float_t range = fRrange*fRangeSlider->GetMaximum();
641 view->SetRange(-range,-range,-range,range, range, range);
648 //Display RICH Chamber Geometry
649 gAlice->GetGeometry()->Draw("same");
651 //add clusters to the pad
657 //printf("Calling DrawCoG\n");
659 //printf("Calling DrawRecHits\n");
662 /*for (Int_t i=0;i<7;i++)
665 // add itself to the list (must be last)
668 view->SetView(phi, theta, psi, iret);
671 //______________________________________________________________________________
672 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
674 // Execute action corresponding to the mouse event
676 static Float_t x0, y0, x1, y1;
678 static Int_t pxold, pyold;
679 static Int_t px0, py0;
680 static Int_t linedrawn;
683 if (px == 0 && py == 0) { //when called by sliders
684 if (event == kButton1Up) {
685 printf("Drawing event %d\n",event);
690 if (!fZoomMode && gPad->GetView()) {
691 gPad->GetView()->ExecuteRotateView(event, px, py);
695 // something to zoom ?
696 gPad->SetCursor(kCross);
701 gVirtualX->SetLineColor(-1);
702 gPad->TAttLine::Modify(); //Change line attributes only if necessary
703 x0 = gPad->AbsPixeltoX(px);
704 y0 = gPad->AbsPixeltoY(py);
706 pxold = px; pyold = py;
711 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
715 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
719 gPad->GetCanvas()->FeedbackMode(kFALSE);
720 if (px == px0) return;
721 if (py == py0) return;
722 x1 = gPad->AbsPixeltoX(px);
723 y1 = gPad->AbsPixeltoY(py);
725 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
726 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
727 gPad->Range(x0,y0,x1,y1);
728 if (fZooms < kMAXZOOM-1) {
730 fZoomX0[fZooms] = x0;
731 fZoomY0[fZooms] = y0;
732 fZoomX1[fZooms] = x1;
733 fZoomY1[fZooms] = y1;
735 gPad->Modified(kTRUE);
740 //___________________________________________
741 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
743 // Read raw clusters info and store x,y,z info in arrays fRpoints
744 // Loop on all detectors
746 if (chamber > 6) return;
748 //printf("Entering LoadCoG\n");
751 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
752 AliRICHChamber* iChamber;
754 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
755 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
756 if (pRICHrawclust == 0) return;
758 pRICH->ResetRawClusters();
761 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
762 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
763 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
764 //printf ("nrawcl:%d\n",nrawcl);
765 if (nrawcl == 0) return;
766 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
768 iChamber = &(pRICH->Chamber(chamber));
769 AliRICHRawCluster *mRaw;
770 AliRICHPoints *points = 0;
772 //loop over all raw clusters and store their position
773 points = new AliRICHPoints(nrawcl);
774 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
775 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
776 fRpoints->AddAt(points,iraw);
777 points->SetMarkerColor(3);
778 points->SetMarkerStyle(3);
779 points->SetMarkerSize(1.);
780 points->SetParticle(-1);
781 points->SetHitIndex(-1);
782 points->SetTrackIndex(-1);
783 points->SetDigitIndex(-1);
784 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
785 Float_t vectorGlob[3];
786 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
787 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
790 //___________________________________________
791 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
793 // Read rec. hits info
794 // Loop on all detectors
796 if (chamber > 6) return;
798 ///printf("Entering LoadRecHits\n");
801 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
802 AliRICHChamber* iChamber;
804 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
805 //printf ("Chamber:%d\n", chamber);
806 if (pRICHrechits1D != 0)
809 //RICH->ResetRecHits();
812 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
813 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
814 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
815 //printf ("nrechits1D:%d\n",nrechits1D);
818 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
820 iChamber = &(pRICH->Chamber(chamber));
821 AliRICHRecHit1D *mRec1D;
822 AliRICHPoints *points1D = 0;
823 //AliRICHEllipse *ellipse = 0;
825 //loop over all rechits and store their position
827 points1D = new AliRICHPoints(nrechits1D);
828 for (Int_t irec=0;irec<nrechits1D;irec++) {
829 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
830 fRecpoints->AddAt(points1D,irec);
831 points1D->SetMarkerColor(38);
832 points1D->SetMarkerStyle(8);
833 points1D->SetMarkerSize(.5);
834 points1D->SetParticle(-1);
835 points1D->SetHitIndex(-1);
836 points1D->SetTrackIndex(-1);
837 points1D->SetDigitIndex(-1);
838 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
839 Float_t vectorGlob[3];
840 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
841 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
842 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
843 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
844 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
845 //printf("Generating ellipse %d\n",irec);
846 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
847 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());
848 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
849 ellipse->CerenkovRingDrawing(chamber,irec);
850 //ellipse->SetFillStyle(1001);
851 ellipse->SetMarkerColor(38);
853 //marker->SetRefObject((TObject*)points1D);
854 //points1D->Set3DMarker(0, marker);
859 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
860 //printf ("Chamber:%d\n", chamber);
861 if (pRICHrechits3D != 0)
864 //RICH->ResetRecHits();
867 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
868 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
869 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
870 //printf ("nrechits3D:%d\n",nrechits3D);
873 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
875 iChamber = &(pRICH->Chamber(chamber));
876 AliRICHRecHit3D *mRec3D;
877 AliRICHPoints *points3D = 0;
878 //AliRICHEllipse *ellipse = 0;
880 //loop over all rechits and store their position
882 points3D = new AliRICHPoints(nrechits3D);
883 for (Int_t irec=0;irec<nrechits3D;irec++) {
884 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
885 fRecpoints->AddAt(points3D,irec);
886 points3D->SetMarkerColor(42);
887 points3D->SetMarkerStyle(8);
888 points3D->SetMarkerSize(1.);
889 points3D->SetParticle(-1);
890 points3D->SetHitIndex(-1);
891 points3D->SetTrackIndex(-1);
892 points3D->SetDigitIndex(-1);
893 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
894 Float_t vectorGlob[3];
895 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
896 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
897 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
898 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
899 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
900 //printf("Generating ellipse %d\n",irec);
901 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
902 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());
903 //ellipse->CerenkovRingDrawing(chamber,irec);
904 //ellipse->SetFillStyle(1001);
905 ellipse->CreatePoints(chamber);
906 ellipse->SetMarkerStyle(7);
907 ellipse->SetMarkerColor(42);
908 ellipse->SetMarkerSize(1);
910 //marker->SetRefObject((TObject*)points3D);
911 //points3D->Set3DMarker(0, marker);
916 //___________________________________________
917 void AliRICHDisplay::LoadDigits()
919 // Read digits info and store x,y,z info in arrays fPoints
920 // Loop on all detectors
923 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
924 AliRICHChamber* iChamber;
925 AliSegmentation* segmentation;
929 //printf("Entering LoadDigits\n");
934 for (ich=0; ich<kNCH; ich++) {
935 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
936 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
937 if (pRICHdigits == 0) continue;
938 gAlice->ResetDigits();
939 gAlice->TreeD()->GetEvent(0);
940 Int_t ndigits = pRICHdigits->GetEntriesFast();
941 //printf("ndigits:%d\n",ndigits);
945 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
947 for (ich=0; ich<kNCH; ich++) {
948 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
949 if (pRICHdigits == 0) continue;
950 gAlice->ResetDigits();
951 gAlice->TreeD()->GetEvent(0);
952 Int_t ndigits = pRICHdigits->GetEntriesFast();
953 if (ndigits == 0) continue;
954 iChamber = &(pRICH->Chamber(ich));
955 segmentation=iChamber->GetSegmentationModel();
956 Float_t dpx = segmentation->Dpx();
957 Float_t dpy = segmentation->Dpy();
959 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
962 AliRICHPoints *points = 0;
963 TMarker3DBox *marker = 0;
965 //loop over all digits and store their position
968 for (Int_t digit=0;digit<ndigits;digit++) {
969 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
970 points = new AliRICHPoints(npoints);
971 fPoints->AddAt(points,counter);
973 Int_t charge=mdig->Signal();
974 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(kadc_satm)/22));
975 Int_t color=701+index;
976 if (color>722) color=722;
977 points->SetMarkerColor(color);
978 points->SetMarkerStyle(21);
979 points->SetMarkerSize(0.5);
980 Float_t xpad, ypad, zpad;
981 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
982 Float_t vectorLoc[3]={xpad,5,ypad};
983 Float_t vectorGlob[3];
984 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
985 points->SetParticle(-1);
986 points->SetHitIndex(-1);
987 points->SetTrackIndex(-1);
988 points->SetDigitIndex(digit);
989 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
990 //printf("Y position (digit): %f\n", vectorGlob[1]);
992 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
993 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
994 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
995 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
996 dpy/2,0,dpx/2,theta,phi);
997 marker->SetLineColor(2);
998 marker->SetFillStyle(1001);
999 marker->SetFillColor(color);
1000 marker->SetRefObject((TObject*)points);
1001 points->Set3DMarker(0, marker);
1002 } // loop over digits
1003 } // loop over chambers
1008 //___________________________________________
1009 void AliRICHDisplay::LoadHits(Int_t chamber)
1011 // Read hits info and store x,y,z info in arrays fPhits
1012 // Loop on all detectors
1018 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1019 AliRICHChamber* iChamber;
1021 iChamber = &(pRICH->Chamber(chamber-1));
1022 Int_t ntracks = (Int_t)pRICH->TreeH()->GetEntries();
1025 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1026 //TVector *xp = new TVector(1000);
1027 //TVector *yp = new TVector(1000);
1028 //TVector *zp = new TVector(1000);
1029 //TVector *ptrk = new TVector(1000);
1030 //TVector *phit = new TVector(1000);
1032 for (track=0; track<ntracks;track++) {
1033 gAlice->ResetHits();
1034 pRICH->TreeH()->GetEvent(track);
1035 TClonesArray *pRICHhits = pRICH->Hits();
1036 if (pRICHhits == 0) return;
1037 Int_t nhits = pRICHhits->GetEntriesFast();
1041 fPhits = new TObjArray(nAllHits);
1044 for (track=0; track<ntracks;track++) {
1045 gAlice->ResetHits();
1046 pRICH->TreeH()->GetEvent(track);
1047 TClonesArray *pRICHhits = pRICH->Hits();
1048 if (pRICHhits == 0) return;
1049 Int_t nhits = pRICHhits->GetEntriesFast();
1050 if (nhits == 0) continue;
1052 AliRICHPoints *points = 0;
1053 for (Int_t hit=0;hit<nhits;hit++) {
1054 points = new AliRICHPoints(1);
1055 fPhits->AddAt(points,npoints);
1056 mHit = (AliRICHhit*)pRICHhits->UncheckedAt(hit);
1057 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1058 if (current->GetPdgCode() == 50000050) {
1059 points->SetMarkerColor(kBlue);
1060 } else if (current->GetPdgCode() == 50000051) {
1061 points->SetMarkerColor(kYellow);
1063 points->SetMarkerColor(kRed);
1065 points->SetMarkerStyle(5);
1066 points->SetMarkerSize(1.);
1067 points->SetParticle(mHit->Track());
1068 points->SetHitIndex(hit);
1069 points->SetTrackIndex(track);
1070 points->SetDigitIndex(-1);
1071 points->SetPoint(0,mHit->X(), mHit->Y(), mHit->Z());
1077 //_____________________________________________________________________________
1079 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1081 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1082 // Loop on all detectors
1087 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1088 AliRICHChamber* iChamber;
1090 iChamber = &(pRICH->Chamber(chamber-1));
1092 pRICH->SetTreeAddress();
1093 Int_t ntracks = (Int_t)pRICH->TreeH()->GetEntries();
1095 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1096 TVector *xp = new TVector(1000);
1097 TVector *yp = new TVector(1000);
1098 TVector *zp = new TVector(1000);
1099 TVector *ptrk = new TVector(1000);
1100 TVector *phit = new TVector(1000);
1101 for (Int_t track=0; track<ntracks;track++) {
1102 gAlice->ResetHits();
1103 pRICH->TreeH()->GetEvent(track);
1104 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1105 if (pRICHCerenkovs == 0) return;
1106 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1107 if (nhits == 0) continue;
1108 AliRICHCerenkov *mCerenkov;
1109 AliRICHPoints *cpoints = 0;
1113 //Display Cerenkov hits in blue
1115 for (Int_t hit=0;hit<nhits;hit++) {
1116 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1117 (*xp)(npoints)=mCerenkov->X();
1118 (*yp)(npoints)=mCerenkov->Y();
1119 (*zp)(npoints)=mCerenkov->Z();
1120 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1121 (*phit)(npoints)=Float_t(hit);
1124 if (npoints == 0) continue;
1125 cpoints = new AliRICHPoints(npoints);
1126 for (Int_t p=0;p<npoints;p++) {
1127 cpoints->SetMarkerColor(kBlue);
1128 cpoints->SetMarkerStyle(5);
1129 cpoints->SetMarkerSize(1.);
1130 cpoints->SetParticle(Int_t((*ptrk)(p)));
1131 cpoints->SetHitIndex(Int_t((*phit)(p)));
1132 cpoints->SetTrackIndex(track);
1133 cpoints->SetDigitIndex(-1);
1134 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1140 fPCerenkovs->AddAt(cpoints,track);
1144 //_____________________________________________________________________________
1145 void AliRICHDisplay::Paint(Option_t *)
1147 // Paint miscellaneous items
1151 //_____________________________________________________________________________
1152 void AliRICHDisplay::SetPickMode()
1159 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1160 fTrigPad->Modified();
1163 //_____________________________________________________________________________
1164 void AliRICHDisplay::SetZoomMode()
1171 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1172 fTrigPad->Modified();
1175 //_____________________________________________________________________________
1176 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1178 // Set chamber and cathode number
1182 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1189 //_____________________________________________________________________________
1190 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1192 // Set view range along R and Z
1201 //_____________________________________________________________________________
1202 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1204 // change viewing angles for current event
1212 TView *view = gPad->GetView();
1213 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1219 //_____________________________________________________________________________
1220 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1222 // Display (current event_number+delta)
1223 // delta = 1 shown next event
1224 // delta = -1 show previous event
1228 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1229 Int_t newEvent = currentEvent + delta;
1230 gAlice->GetEvent(newEvent);
1231 if (!gAlice->TreeD()) return;
1241 //______________________________________________________________________________
1242 void AliRICHDisplay::UnZoom()
1245 // Return to previous zoom factor
1247 if (fZooms <= 0) return;
1249 TPad *pad = (TPad*)gPad->GetPadSave();
1250 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1254 //_____________________________________________________________________________
1255 void AliRICHDisplay::ResetPoints()
1258 // Reset array of points
1266 //_____________________________________________________________________________
1267 void AliRICHDisplay::ResetRpoints()
1270 // Reset array of points
1278 //_____________________________________________________________________________
1279 void AliRICHDisplay::ResetRecpoints()
1282 // Reset array of points
1285 fRecpoints->Delete();
1290 //_____________________________________________________________________________
1291 void AliRICHDisplay::ResetPhits()
1294 // Reset array of points
1302 //_____________________________________________________________________________
1303 void AliRICHDisplay::ResetPCerenkovs()
1306 // Reset array of points
1309 fPCerenkovs->Delete();
1315 //_____________________________________________________________________________
1317 void AliRICHDisplay::DrawViewGL()
1319 // Draw current view using OPENGL
1321 TPad *pad = (TPad*)gPad->GetPadSave();
1323 TView *view = pad->GetView();
1328 //_____________________________________________________________________________
1329 void AliRICHDisplay::DrawViewX3D()
1331 // Draw current view using X3D
1333 TPad *pad = (TPad*)gPad->GetPadSave();
1335 TView *view = pad->GetView();