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 "AliRICHHit.h"
64 #include "AliRICHCerenkov.h"
65 #include "AliRICHSDigit.h"
66 #include "AliRICHDigit.h"
67 #include "AliRICHRawCluster.h"
68 #include "AliRICHRecHit1D.h"
69 #include "AliRICHRecHit3D.h"
70 #include "AliRICHEllipse.h"
72 ClassImp(AliRICHDisplay)
75 //____________________________________________________________________________
76 AliRICHDisplay::AliRICHDisplay()
79 // default constructor
89 //_____________________________________________________________________________
90 AliRICHDisplay::AliRICHDisplay(Int_t size)
92 // Create an event display object.
93 // A canvas named "edisplay" is created with a vertical size in pixels
95 // A QUICK Overview of the Event Display functions
96 // ===============================================
98 // The event display can ve invoked by executing the macro "display.C"
99 // A canvas like in the picture below will appear.
101 // On the left side of the canvas, the following buttons appear:
102 // *Next* to move to the next event
103 // *Previous* to move to the previous event
105 // *Pick* Select this option to be able to point on a track with the
106 // mouse. Once on the track, use the right button to select
107 // an action. For example, select SetMarkerAttributes to
108 // change the marker type/color/size for the track.
109 // *Zoom* Select this option (default) if you want to zoom.
110 // To zoom, simply select the selected area with the left button.
111 // *UnZoom* To revert to the previous picture size.
113 // slider R On the left side, the vertical slider can be used to
114 // set the default picture size.
116 // When you are in Zoom mode, you can click on the black part of the canvas
117 // to select special options with the right mouse button.
120 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
121 // When you are on a track, select the menu item "InspectParticle"
122 // to display the current particle attributes.
124 // You can activate the Root browser by selecting the Inspect menu
125 // in the canvas tool bar menu. Then select "Start Browser"
126 // This will open a new canvas with the browser. At this point, you may want
127 // to display some histograms (from the Trees). Go to the "File" menu
128 // of the browser and click on "New canvas".
129 // In the browser, click on item "ROOT files" in the left pane.
130 // Click on galice.root.
132 // Click on TPC for example
133 // Click on any variable (eg TPC.fX) to histogram the variable.
135 // If you are lost, you can click on HELP in any Root canvas or browser.
138 <img src="gif/AliRICHDisplay.gif">
145 gAlice->SetDisplay(this);
147 // Initialize display default parameters
150 // Set front view by default
151 fTheta = 90; //inclined HMPID
152 fPhi = 30; //inclined HMPID
153 //fTheta = 90; //normal HMPID
154 //fPhi = 90; //normal HMPID
159 fDrawClusters = kTRUE;
161 fDrawRecHits = kTRUE;
172 // Create display canvas
174 if (ysize < 100) ysize = 750;
175 Int_t xsize = Int_t(size*830./ysize);
176 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
177 fCanvas->ToggleEventStatus();
179 // Create main display pad
180 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
183 fPad->SetFillColor(1);
184 fPad->SetBorderSize(2);
189 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
192 fColPad->SetFillColor(19);
193 fColPad->SetBorderSize(2);
199 // Create user interface control pad
203 // Create Range and mode pad
206 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
209 fTrigPad->SetFillColor(22);
210 fTrigPad->SetBorderSize(2);
211 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
212 fRangeSlider->SetObject(this);
213 char pickmode[] = "gAlice->Display()->SetPickMode()";
215 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
216 fPickButton->SetFillColor(38);
218 char zoommode[] = "gAlice->Display()->SetZoomMode()";
219 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
220 fZoomButton->SetFillColor(38);
222 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
223 fArcButton->SetFillColor(kGreen);
225 char butUnzoom[] = "gAlice->Display()->UnZoom()";
226 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
227 button->SetFillColor(38);
229 AppendPad(); // append display object as last object to force selection
231 fTrigPad->SetEditable(kFALSE);
232 fButtons->SetEditable(kFALSE);
238 //_____________________________________________________________________________
239 AliRICHDisplay::~AliRICHDisplay()
241 // Delete space point structure
242 if (fPoints) fPoints->Delete();
246 if (fPhits) fPhits->Delete();
250 if (fRpoints) fRpoints->Delete();
254 if (fRecpoints) fRecpoints->Delete();
258 if (fPCerenkovs) fPCerenkovs->Delete();
263 //_____________________________________________________________________________
264 void AliRICHDisplay::Clear(Option_t *)
266 // Delete graphics temporary objects
269 //_____________________________________________________________________________
270 void AliRICHDisplay::DisplayButtons()
272 // Create the user interface buttons
275 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
277 fButtons->SetFillColor(38);
278 fButtons->SetBorderSize(2);
281 // Int_t butcolor = 33;
282 Float_t dbutton = 0.08;
289 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
290 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
291 button->SetFillColor(38);
295 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
296 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
297 button->SetFillColor(38);
301 char but7[] = "gAlice->Display()->DrawViewGL()";
302 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
303 button->SetFillColor(38);
307 char but8[] = "gAlice->Display()->DrawViewX3D()";
308 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
309 button->SetFillColor(38);
313 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
314 diamond->SetFillColor(50);
315 diamond->SetTextAlign(22);
316 diamond->SetTextColor(5);
317 diamond->SetTextSize(0.11);
319 diamond->AddText(".. ");
320 diamond->AddText("ROOT");
321 diamond->AddText("RICH");
322 diamond->AddText("... ");
323 diamond->AddText(" ");
326 //_____________________________________________________________________________
327 void AliRICHDisplay::CreateColors()
329 // Create the colors palette used to display clusters
344 new TColor(color,r,g,b);
354 new TColor(color,r,g,b);
364 new TColor(color,r,g,b);
374 new TColor(color,r,g,b);
384 new TColor(color,r,g,b);
391 //_____________________________________________________________________________
392 void AliRICHDisplay::DisplayColorScale()
395 // Draw the color scale in the RICH display canvas
399 Float_t xlow, ylow, xup, yup, hs;
400 Float_t x1, y1, x2, y2;
404 gPad->SetFillColor(0);
406 gPad->Range(x1,y1,x2,y2);
407 TText *text = new TText(0,0,"");
408 text->SetTextFont(61);
409 text->SetTextSize(0.2);
410 text->SetTextAlign(22);
414 //*-* draw colortable boxes
415 hs = (y2-y1)/Float_t(22);
419 ylow = y1 + hs*(Float_t(i));
420 yup = y1 + hs*(Float_t(i+1));
422 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
423 Int_t scale=(Int_t)TMath::Exp(logscale);
424 sprintf(label,"%d",scale);
425 box = new TBox(xlow, ylow, xup, yup);
426 box->SetFillColor(color);
428 text->DrawText(xup+4, 0.5*(ylow+yup),label);
432 //______________________________________________________________________________
433 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
435 // Compute distance from point px,py to objects in event
437 gPad->SetCursor(kCross);
439 if (gPad == fTrigPad) return 9999;
441 const Int_t kBig = 9999;
443 Float_t xmin = gPad->GetX1();
444 Float_t xmax = gPad->GetX2();
445 Float_t dx = 0.02*(xmax - xmin);
446 Float_t x = gPad->AbsPixeltoX(px);
447 if (x < xmin+dx || x > xmax-dx) return dist;
448 if (fZoomMode) return 0;
452 //_____________________________________________________________________________
453 void AliRICHDisplay::Draw(Option_t *)
455 // Display current event
459 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
461 // Display the event number and title
466 //_____________________________________________________________________________
467 void AliRICHDisplay::DrawCoG()
469 // Draw hits for RICH chambers
471 if (!fDrawCoG) return;
473 for (Int_t chamber=0;chamber<kNCH;chamber++) {
482 ncog = points->GetEntriesFast();
483 for (icog=0; icog < ncog; icog++) {
484 pm = (AliRICHPoints*)points->UncheckedAt(icog);
490 void AliRICHDisplay::DrawRecHits()
492 // Draw rec hits for RICH chambers
494 if (!fDrawRecHits) return;
496 for (Int_t chamber=0;chamber<kNCH;chamber++) {
497 LoadRecHits(chamber,1);
505 nrec = points->GetEntriesFast();
506 //printf("Nrec %d\n",nrec);
507 for (irec=0; irec < nrec; irec++) {
508 pm = (AliRICHPoints*)points->UncheckedAt(irec);
514 //_____________________________________________________________________________
516 void AliRICHDisplay::DrawCerenkovs()
518 // Draw cerenkovs hits for RICH chambers
520 LoadCerenkovs(fChamber);
521 //printf("\nDrawCerenkovs\n");
523 Int_t ntracks, track;
528 cpoints = fPCerenkovs;
529 //printf ("Cpoints: %p",cpoints);
530 if (!cpoints) return;
531 ntracks = cpoints->GetEntriesFast();
532 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
533 for (track=0;track<ntracks;track++) {
534 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
537 fHitsCuts += pm->GetN();
541 //_____________________________________________________________________________
543 void AliRICHDisplay::DrawClusters()
545 // Draw clusterss for RICH chambers
547 Int_t ndigits, digit;
554 ndigits = points->GetEntriesFast();
555 for (digit=0;digit<ndigits;digit++){
556 pm = (AliRICHPoints*)points->UncheckedAt(digit);
561 for (Int_t im=0;im<3;im++) {
562 TMarker3DBox *marker=pm->GetMarker(im);
566 fClustersCuts +=pm->GetN();
570 //_____________________________________________________________________________
571 void AliRICHDisplay::DrawHits()
573 // Draw hits for RICH chambers
577 Int_t ntracks, track;
584 // ntracks = points->GetEntriesFast();
585 ntracks = fPhits->GetEntriesFast();
587 //printf("DrawHits - ntracks %d \n",ntracks);
588 for (track=0;track<ntracks;track++) {
589 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
592 fHitsCuts += pm->GetN();
597 //_____________________________________________________________________________
598 void AliRICHDisplay::DrawTitle(Option_t *option)
600 // Draw the event title
602 Float_t xmin = gPad->GetX1();
603 Float_t xmax = gPad->GetX2();
604 Float_t ymin = gPad->GetY1();
605 Float_t ymax = gPad->GetY2();
606 Float_t dx = xmax-xmin;
607 Float_t dy = ymax-ymin;
609 if (strlen(option) == 0) {
610 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
611 title->SetBit(kCanDelete);
612 title->SetFillColor(42);
615 sprintf(ptitle,"Alice event: %d, Run:%d",
616 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
617 title->AddText(ptitle);
618 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
619 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
620 nparticles, fHitsCuts,fClustersCuts);
621 title->AddText(ptitle);
624 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
625 label->SetBit(kCanDelete);
626 label->SetFillColor(42);
631 //_____________________________________________________________________________
632 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
634 // Draw a view of RICH clusters
636 gPad->SetCursor(kWatch);
637 gPad->SetFillColor(1);
641 TView *view = new TView(1);
642 Float_t range = fRrange*fRangeSlider->GetMaximum();
643 view->SetRange(-range,-range,-range,range, range, range);
650 //Display RICH Chamber Geometry
651 gAlice->GetGeometry()->Draw("same");
653 //add clusters to the pad
659 //printf("Calling DrawCoG\n");
661 //printf("Calling DrawRecHits\n");
664 /*for (Int_t i=0;i<7;i++)
667 // add itself to the list (must be last)
670 view->SetView(phi, theta, psi, iret);
673 //______________________________________________________________________________
674 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
676 // Execute action corresponding to the mouse event
678 static Float_t x0, y0, x1, y1;
680 static Int_t pxold, pyold;
681 static Int_t px0, py0;
682 static Int_t linedrawn;
685 if (px == 0 && py == 0) { //when called by sliders
686 if (event == kButton1Up) {
687 printf("Drawing event %d\n",event);
692 if (!fZoomMode && gPad->GetView()) {
693 gPad->GetView()->ExecuteRotateView(event, px, py);
697 // something to zoom ?
698 gPad->SetCursor(kCross);
703 gVirtualX->SetLineColor(-1);
704 gPad->TAttLine::Modify(); //Change line attributes only if necessary
705 x0 = gPad->AbsPixeltoX(px);
706 y0 = gPad->AbsPixeltoY(py);
708 pxold = px; pyold = py;
713 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
717 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
721 gPad->GetCanvas()->FeedbackMode(kFALSE);
722 if (px == px0) return;
723 if (py == py0) return;
724 x1 = gPad->AbsPixeltoX(px);
725 y1 = gPad->AbsPixeltoY(py);
727 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
728 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
729 gPad->Range(x0,y0,x1,y1);
730 if (fZooms < kMAXZOOM-1) {
732 fZoomX0[fZooms] = x0;
733 fZoomY0[fZooms] = y0;
734 fZoomX1[fZooms] = x1;
735 fZoomY1[fZooms] = y1;
737 gPad->Modified(kTRUE);
742 //___________________________________________
743 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
745 // Read raw clusters info and store x,y,z info in arrays fRpoints
746 // Loop on all detectors
748 if (chamber > 6) return;
750 //printf("Entering LoadCoG\n");
753 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
754 AliRICHChamber* iChamber;
756 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
757 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
758 if (pRICHrawclust == 0) return;
760 pRICH->ResetRawClusters();
763 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
764 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
765 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
766 //printf ("nrawcl:%d\n",nrawcl);
767 if (nrawcl == 0) return;
768 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
770 iChamber = &(pRICH->Chamber(chamber));
771 AliRICHRawCluster *mRaw;
772 AliRICHPoints *points = 0;
774 //loop over all raw clusters and store their position
775 points = new AliRICHPoints(nrawcl);
776 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
777 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
778 fRpoints->AddAt(points,iraw);
779 points->SetMarkerColor(3);
780 points->SetMarkerStyle(3);
781 points->SetMarkerSize(1.);
782 points->SetParticle(-1);
783 points->SetHitIndex(-1);
784 points->SetTrackIndex(-1);
785 points->SetDigitIndex(-1);
786 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
787 Float_t vectorGlob[3];
788 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
789 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
792 //___________________________________________
793 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
795 // Read rec. hits info
796 // Loop on all detectors
798 if (chamber > 6) return;
800 ///printf("Entering LoadRecHits\n");
803 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
804 AliRICHChamber* iChamber;
806 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
807 //printf ("Chamber:%d\n", chamber);
808 if (pRICHrechits1D != 0)
811 //RICH->ResetRecHits();
814 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
815 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
816 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
817 //printf ("nrechits1D:%d\n",nrechits1D);
820 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
822 iChamber = &(pRICH->Chamber(chamber));
823 AliRICHRecHit1D *mRec1D;
824 AliRICHPoints *points1D = 0;
825 //AliRICHEllipse *ellipse = 0;
827 //loop over all rechits and store their position
829 points1D = new AliRICHPoints(nrechits1D);
830 for (Int_t irec=0;irec<nrechits1D;irec++) {
831 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
832 fRecpoints->AddAt(points1D,irec);
833 points1D->SetMarkerColor(38);
834 points1D->SetMarkerStyle(8);
835 points1D->SetMarkerSize(.5);
836 points1D->SetParticle(-1);
837 points1D->SetHitIndex(-1);
838 points1D->SetTrackIndex(-1);
839 points1D->SetDigitIndex(-1);
840 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
841 Float_t vectorGlob[3];
842 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
843 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
844 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
845 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
846 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
847 //printf("Generating ellipse %d\n",irec);
848 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
849 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());
850 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
851 ellipse->CerenkovRingDrawing(chamber,irec);
852 //ellipse->SetFillStyle(1001);
853 ellipse->SetMarkerColor(38);
855 //marker->SetRefObject((TObject*)points1D);
856 //points1D->Set3DMarker(0, marker);
861 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
862 //printf ("Chamber:%d\n", chamber);
863 if (pRICHrechits3D != 0)
866 //RICH->ResetRecHits();
869 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
870 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
871 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
872 //printf ("nrechits3D:%d\n",nrechits3D);
875 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
877 iChamber = &(pRICH->Chamber(chamber));
878 AliRICHRecHit3D *mRec3D;
879 AliRICHPoints *points3D = 0;
880 //AliRICHEllipse *ellipse = 0;
882 //loop over all rechits and store their position
884 points3D = new AliRICHPoints(nrechits3D);
885 for (Int_t irec=0;irec<nrechits3D;irec++) {
886 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
887 fRecpoints->AddAt(points3D,irec);
888 points3D->SetMarkerColor(42);
889 points3D->SetMarkerStyle(8);
890 points3D->SetMarkerSize(1.);
891 points3D->SetParticle(-1);
892 points3D->SetHitIndex(-1);
893 points3D->SetTrackIndex(-1);
894 points3D->SetDigitIndex(-1);
895 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
896 Float_t vectorGlob[3];
897 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
898 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
899 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
900 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
901 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
902 //printf("Generating ellipse %d\n",irec);
903 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
904 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());
905 //ellipse->CerenkovRingDrawing(chamber,irec);
906 //ellipse->SetFillStyle(1001);
907 ellipse->CreatePoints(chamber);
908 ellipse->SetMarkerStyle(7);
909 ellipse->SetMarkerColor(42);
910 ellipse->SetMarkerSize(1);
912 //marker->SetRefObject((TObject*)points3D);
913 //points3D->Set3DMarker(0, marker);
918 //___________________________________________
919 void AliRICHDisplay::LoadDigits()
921 // Read digits info and store x,y,z info in arrays fPoints
922 // Loop on all detectors
925 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
926 AliRICHChamber* iChamber;
927 AliSegmentation* segmentation;
931 //printf("Entering LoadDigits\n");
936 for (ich=0; ich<kNCH; ich++) {
937 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
938 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
939 if (pRICHdigits == 0) continue;
940 gAlice->ResetDigits();
941 gAlice->TreeD()->GetEvent(0);
942 Int_t ndigits = pRICHdigits->GetEntriesFast();
943 //printf("ndigits:%d\n",ndigits);
947 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
949 for (ich=0; ich<kNCH; ich++) {
950 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
951 if (pRICHdigits == 0) continue;
952 gAlice->ResetDigits();
953 gAlice->TreeD()->GetEvent(0);
954 Int_t ndigits = pRICHdigits->GetEntriesFast();
955 if (ndigits == 0) continue;
956 iChamber = &(pRICH->Chamber(ich));
957 segmentation=iChamber->GetSegmentationModel();
958 Float_t dpx = segmentation->Dpx();
959 Float_t dpy = segmentation->Dpy();
961 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
964 AliRICHPoints *points = 0;
965 TMarker3DBox *marker = 0;
967 //loop over all digits and store their position
970 for (Int_t digit=0;digit<ndigits;digit++) {
971 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
972 points = new AliRICHPoints(npoints);
973 fPoints->AddAt(points,counter);
975 Int_t charge=mdig->Signal();
976 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
977 Int_t color=701+index;
978 if (color>722) color=722;
979 points->SetMarkerColor(color);
980 points->SetMarkerStyle(21);
981 points->SetMarkerSize(0.5);
982 Float_t xpad, ypad, zpad;
983 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
984 Float_t vectorLoc[3]={xpad,5,ypad};
985 Float_t vectorGlob[3];
986 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
987 points->SetParticle(-1);
988 points->SetHitIndex(-1);
989 points->SetTrackIndex(-1);
990 points->SetDigitIndex(digit);
991 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
992 //printf("Y position (digit): %f\n", vectorGlob[1]);
994 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
995 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
996 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
997 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
998 dpy/2,0,dpx/2,theta,phi);
999 marker->SetLineColor(2);
1000 marker->SetFillStyle(1001);
1001 marker->SetFillColor(color);
1002 marker->SetRefObject((TObject*)points);
1003 points->Set3DMarker(0, marker);
1004 } // loop over digits
1005 } // loop over chambers
1010 //___________________________________________
1011 void AliRICHDisplay::LoadHits(Int_t chamber)
1013 // Read hits info and store x,y,z info in arrays fPhits
1014 // Loop on all detectors
1020 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1021 AliRICHChamber* iChamber;
1023 iChamber = &(pRICH->Chamber(chamber-1));
1024 Int_t ntracks = (Int_t)pRICH->TreeH()->GetEntries();
1027 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1028 //TVector *xp = new TVector(1000);
1029 //TVector *yp = new TVector(1000);
1030 //TVector *zp = new TVector(1000);
1031 //TVector *ptrk = new TVector(1000);
1032 //TVector *phit = new TVector(1000);
1034 for (track=0; track<ntracks;track++) {
1035 gAlice->ResetHits();
1036 pRICH->TreeH()->GetEvent(track);
1037 TClonesArray *pRICHhits = pRICH->Hits();
1038 if (pRICHhits == 0) return;
1039 Int_t nhits = pRICHhits->GetEntriesFast();
1043 fPhits = new TObjArray(nAllHits);
1046 for (track=0; track<ntracks;track++) {
1047 gAlice->ResetHits();
1048 pRICH->TreeH()->GetEvent(track);
1049 TClonesArray *pRICHhits = pRICH->Hits();
1050 if (pRICHhits == 0) return;
1051 Int_t nhits = pRICHhits->GetEntriesFast();
1052 if (nhits == 0) continue;
1054 AliRICHPoints *points = 0;
1055 for (Int_t hit=0;hit<nhits;hit++) {
1056 points = new AliRICHPoints(1);
1057 fPhits->AddAt(points,npoints);
1058 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1059 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1060 if (current->GetPdgCode() == 50000050) {
1061 points->SetMarkerColor(kBlue);
1062 } else if (current->GetPdgCode() == 50000051) {
1063 points->SetMarkerColor(kYellow);
1065 points->SetMarkerColor(kRed);
1067 points->SetMarkerStyle(5);
1068 points->SetMarkerSize(1.);
1069 points->SetParticle(mHit->Track());
1070 points->SetHitIndex(hit);
1071 points->SetTrackIndex(track);
1072 points->SetDigitIndex(-1);
1073 points->SetPoint(0,mHit->X(), mHit->Y(), mHit->Z());
1079 //_____________________________________________________________________________
1081 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1083 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1084 // Loop on all detectors
1089 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1090 AliRICHChamber* iChamber;
1092 iChamber = &(pRICH->Chamber(chamber-1));
1094 pRICH->SetTreeAddress();
1095 Int_t ntracks = (Int_t)pRICH->TreeH()->GetEntries();
1097 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1098 TVector *xp = new TVector(1000);
1099 TVector *yp = new TVector(1000);
1100 TVector *zp = new TVector(1000);
1101 TVector *ptrk = new TVector(1000);
1102 TVector *phit = new TVector(1000);
1103 for (Int_t track=0; track<ntracks;track++) {
1104 gAlice->ResetHits();
1105 pRICH->TreeH()->GetEvent(track);
1106 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1107 if (pRICHCerenkovs == 0) return;
1108 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1109 if (nhits == 0) continue;
1110 AliRICHCerenkov *mCerenkov;
1111 AliRICHPoints *cpoints = 0;
1115 //Display Cerenkov hits in blue
1117 for (Int_t hit=0;hit<nhits;hit++) {
1118 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1119 (*xp)(npoints)=mCerenkov->X();
1120 (*yp)(npoints)=mCerenkov->Y();
1121 (*zp)(npoints)=mCerenkov->Z();
1122 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1123 (*phit)(npoints)=Float_t(hit);
1126 if (npoints == 0) continue;
1127 cpoints = new AliRICHPoints(npoints);
1128 for (Int_t p=0;p<npoints;p++) {
1129 cpoints->SetMarkerColor(kBlue);
1130 cpoints->SetMarkerStyle(5);
1131 cpoints->SetMarkerSize(1.);
1132 cpoints->SetParticle(Int_t((*ptrk)(p)));
1133 cpoints->SetHitIndex(Int_t((*phit)(p)));
1134 cpoints->SetTrackIndex(track);
1135 cpoints->SetDigitIndex(-1);
1136 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1142 fPCerenkovs->AddAt(cpoints,track);
1146 //_____________________________________________________________________________
1147 void AliRICHDisplay::Paint(Option_t *)
1149 // Paint miscellaneous items
1153 //_____________________________________________________________________________
1154 void AliRICHDisplay::SetPickMode()
1161 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1162 fTrigPad->Modified();
1165 //_____________________________________________________________________________
1166 void AliRICHDisplay::SetZoomMode()
1173 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1174 fTrigPad->Modified();
1177 //_____________________________________________________________________________
1178 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1180 // Set chamber and cathode number
1184 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1191 //_____________________________________________________________________________
1192 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1194 // Set view range along R and Z
1203 //_____________________________________________________________________________
1204 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1206 // change viewing angles for current event
1214 TView *view = gPad->GetView();
1215 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1221 //_____________________________________________________________________________
1222 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1224 // Display (current event_number+delta)
1225 // delta = 1 shown next event
1226 // delta = -1 show previous event
1230 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1231 Int_t newEvent = currentEvent + delta;
1232 gAlice->GetEvent(newEvent);
1233 if (!gAlice->TreeD()) return;
1243 //______________________________________________________________________________
1244 void AliRICHDisplay::UnZoom()
1247 // Return to previous zoom factor
1249 if (fZooms <= 0) return;
1251 TPad *pad = (TPad*)gPad->GetPadSave();
1252 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1256 //_____________________________________________________________________________
1257 void AliRICHDisplay::ResetPoints()
1260 // Reset array of points
1268 //_____________________________________________________________________________
1269 void AliRICHDisplay::ResetRpoints()
1272 // Reset array of points
1280 //_____________________________________________________________________________
1281 void AliRICHDisplay::ResetRecpoints()
1284 // Reset array of points
1287 fRecpoints->Delete();
1292 //_____________________________________________________________________________
1293 void AliRICHDisplay::ResetPhits()
1296 // Reset array of points
1304 //_____________________________________________________________________________
1305 void AliRICHDisplay::ResetPCerenkovs()
1308 // Reset array of points
1311 fPCerenkovs->Delete();
1317 //_____________________________________________________________________________
1319 void AliRICHDisplay::DrawViewGL()
1321 // Draw current view using OPENGL
1323 TPad *pad = (TPad*)gPad->GetPadSave();
1325 TView *view = pad->GetView();
1330 //_____________________________________________________________________________
1331 void AliRICHDisplay::DrawViewX3D()
1333 // Draw current view using X3D
1335 TPad *pad = (TPad*)gPad->GetPadSave();
1337 TView *view = pad->GetView();