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.13 2001/05/10 12:35:16 jbarbosa
19 Removed hit display, added rec. ring properties.
21 Revision 1.12 2001/03/14 18:15:03 jbarbosa
22 Changes to adapt to new IO.
23 Removed verbose output.
25 Revision 1.11 2001/02/27 15:21:34 jbarbosa
26 Transition to SDigits.
28 Revision 1.10 2001/02/13 20:18:48 jbarbosa
29 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
31 Revision 1.9 2000/11/01 15:33:11 jbarbosa
32 Updated to handle both reconstruction algorithms.
34 Revision 1.8 2000/10/03 21:44:09 morsch
35 Use AliSegmentation and AliHit abstract base classes.
37 Revision 1.7 2000/10/02 21:28:12 fca
38 Removal of useless dependecies via forward declarations
40 Revision 1.6 2000/10/02 15:46:38 jbarbosa
41 Fixed forward declarations.
43 Revision 1.5 2000/06/30 16:49:34 dibari
44 Different call for ring drawing.
46 Revision 1.4 2000/06/12 15:21:08 jbarbosa
49 Revision 1.3 2000/06/09 14:52:08 jbarbosa
50 New tentative ellipse drawing routine
52 Revision 1.1 2000/04/19 13:07:45 morsch
53 Digits, clusters and reconstruction results added.
58 //////////////////////////////////////////////////////////////////////////
62 // Utility class to display ALICE outline, tracks, hits,.. //
64 //////////////////////////////////////////////////////////////////////////
73 #include <TPolyMarker3D.h>
76 #include <TPolyMarker.h>
77 #include <TPaveLabel.h>
78 #include <TPaveText.h>
85 #include <TGeometry.h>
86 #include <TSliderBox.h>
88 #include <TVirtualX.h>
91 #include <X3DBuffer.h>
92 #include <TParticle.h>
96 #include "AliDetector.h"
98 #include "AliRICHConst.h"
99 #include "AliRICHDisplay.h"
100 #include "AliRICHPoints.h"
101 #include "AliHeader.h"
103 #include "AliRICHHit.h"
104 #include "AliRICHCerenkov.h"
105 #include "AliRICHSDigit.h"
106 #include "AliRICHDigit.h"
107 #include "AliRICHRawCluster.h"
108 #include "AliRICHRecHit1D.h"
109 #include "AliRICHRecHit3D.h"
110 #include "AliRICHEllipse.h"
112 ClassImp(AliRICHDisplay)
115 //____________________________________________________________________________
116 AliRICHDisplay::AliRICHDisplay()
119 // default constructor
129 //_____________________________________________________________________________
130 AliRICHDisplay::AliRICHDisplay(Int_t size)
132 // Create an event display object.
133 // A canvas named "edisplay" is created with a vertical size in pixels
135 // A QUICK Overview of the Event Display functions
136 // ===============================================
138 // The event display can ve invoked by executing the macro "display.C"
139 // A canvas like in the picture below will appear.
141 // On the left side of the canvas, the following buttons appear:
142 // *Next* to move to the next event
143 // *Previous* to move to the previous event
145 // *Pick* Select this option to be able to point on a track with the
146 // mouse. Once on the track, use the right button to select
147 // an action. For example, select SetMarkerAttributes to
148 // change the marker type/color/size for the track.
149 // *Zoom* Select this option (default) if you want to zoom.
150 // To zoom, simply select the selected area with the left button.
151 // *UnZoom* To revert to the previous picture size.
153 // slider R On the left side, the vertical slider can be used to
154 // set the default picture size.
156 // When you are in Zoom mode, you can click on the black part of the canvas
157 // to select special options with the right mouse button.
160 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
161 // When you are on a track, select the menu item "InspectParticle"
162 // to display the current particle attributes.
164 // You can activate the Root browser by selecting the Inspect menu
165 // in the canvas tool bar menu. Then select "Start Browser"
166 // This will open a new canvas with the browser. At this point, you may want
167 // to display some histograms (from the Trees). Go to the "File" menu
168 // of the browser and click on "New canvas".
169 // In the browser, click on item "ROOT files" in the left pane.
170 // Click on galice.root.
172 // Click on TPC for example
173 // Click on any variable (eg TPC.fX) to histogram the variable.
175 // If you are lost, you can click on HELP in any Root canvas or browser.
178 <img src="gif/AliRICHDisplay.gif">
185 gAlice->SetDisplay(this);
187 // Initialize display default parameters
190 // Set front view by default
197 fDrawClusters = kTRUE;
199 fDrawRecHits = kTRUE;
210 // Create display canvas
212 if (ysize < 100) ysize = 750;
213 Int_t xsize = Int_t(size*830./ysize);
214 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
215 fCanvas->ToggleEventStatus();
217 // Create main display pad
218 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
221 fPad->SetFillColor(1);
222 fPad->SetBorderSize(2);
227 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
230 fColPad->SetFillColor(19);
231 fColPad->SetBorderSize(2);
237 // Create user interface control pad
241 // Create Range and mode pad
244 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
245 fTrigPad->SetEditable(kFALSE);
248 fTrigPad->SetFillColor(22);
249 fTrigPad->SetBorderSize(2);
250 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
251 fRangeSlider->SetObject(this);
252 char pickmode[] = "gAlice->Display()->SetPickMode()";
254 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
255 fPickButton->SetFillColor(38);
257 char zoommode[] = "gAlice->Display()->SetZoomMode()";
258 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
259 fZoomButton->SetFillColor(38);
261 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
262 fArcButton->SetFillColor(kGreen);
264 char butUnzoom[] = "gAlice->Display()->UnZoom()";
265 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
266 button->SetFillColor(38);
268 AppendPad(); // append display object as last object to force selection
275 //_____________________________________________________________________________
276 AliRICHDisplay::~AliRICHDisplay()
278 // Delete space point structure
279 if (fPoints) fPoints->Delete();
283 if (fPhits) fPhits->Delete();
287 if (fRpoints) fRpoints->Delete();
291 if (fRecpoints) fRecpoints->Delete();
295 if (fPCerenkovs) fPCerenkovs->Delete();
300 //_____________________________________________________________________________
301 void AliRICHDisplay::Clear(Option_t *)
303 // Delete graphics temporary objects
306 //_____________________________________________________________________________
307 void AliRICHDisplay::DisplayButtons()
309 // Create the user interface buttons
312 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
313 fButtons->SetEditable(kFALSE);
315 fButtons->SetFillColor(38);
316 fButtons->SetBorderSize(2);
319 // Int_t butcolor = 33;
320 Float_t dbutton = 0.08;
327 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
328 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
329 button->SetFillColor(38);
333 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
334 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
335 button->SetFillColor(38);
339 char but7[] = "gAlice->Display()->DrawViewGL()";
340 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
341 button->SetFillColor(38);
345 char but8[] = "gAlice->Display()->DrawViewX3D()";
346 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
347 button->SetFillColor(38);
351 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
352 diamond->SetFillColor(50);
353 diamond->SetTextAlign(22);
354 diamond->SetTextColor(5);
355 diamond->SetTextSize(0.11);
357 diamond->AddText(".. ");
358 diamond->AddText("ROOT");
359 diamond->AddText("RICH");
360 diamond->AddText("... ");
361 diamond->AddText(" ");
364 //_____________________________________________________________________________
365 void AliRICHDisplay::CreateColors()
367 // Create the colors palette used to display clusters
382 new TColor(color,r,g,b);
392 new TColor(color,r,g,b);
402 new TColor(color,r,g,b);
412 new TColor(color,r,g,b);
422 new TColor(color,r,g,b);
429 //_____________________________________________________________________________
430 void AliRICHDisplay::DisplayColorScale()
433 // Draw the color scale in the RICH display canvas
437 Float_t xlow, ylow, xup, yup, hs;
438 Float_t x1, y1, x2, y2;
442 gPad->SetFillColor(0);
444 gPad->Range(x1,y1,x2,y2);
445 TText *text = new TText(0,0,"");
446 text->SetTextFont(61);
447 text->SetTextSize(0.03);
448 text->SetTextAlign(22);
452 //*-* draw colortable boxes
453 hs = (y2-y1)/Float_t(22);
457 ylow = y1 + hs*(Float_t(i));
458 yup = y1 + hs*(Float_t(i+1));
460 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
461 Int_t scale=(Int_t)TMath::Exp(logscale);
462 sprintf(label,"%d",scale);
463 box = new TBox(xlow, ylow, xup, yup);
464 box->SetFillColor(color);
466 text->DrawText(xup+4, 0.5*(ylow+yup),label);
470 //______________________________________________________________________________
471 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
473 // Compute distance from point px,py to objects in event
475 gPad->SetCursor(kCross);
477 if (gPad == fTrigPad) return 9999;
479 const Int_t kBig = 9999;
481 Float_t xmin = gPad->GetX1();
482 Float_t xmax = gPad->GetX2();
483 Float_t dx = 0.02*(xmax - xmin);
484 Float_t x = gPad->AbsPixeltoX(px);
485 if (x < xmin+dx || x > xmax-dx) return dist;
486 if (fZoomMode) return 0;
490 //_____________________________________________________________________________
491 void AliRICHDisplay::Draw(Option_t *)
493 // Display current event
497 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
499 // Display the event number and title
504 //_____________________________________________________________________________
505 void AliRICHDisplay::DrawCoG()
507 // Draw hits for RICH chambers
509 if (!fDrawCoG) return;
511 for (Int_t chamber=0;chamber<kNCH;chamber++) {
520 ncog = points->GetEntriesFast();
521 for (icog=0; icog < ncog; icog++) {
522 pm = (AliRICHPoints*)points->UncheckedAt(icog);
528 void AliRICHDisplay::DrawRecHits()
530 // Draw rec hits for RICH chambers
532 if (!fDrawRecHits) return;
534 for (Int_t chamber=0;chamber<kNCH;chamber++) {
535 LoadRecHits(chamber,1);
543 nrec = points->GetEntriesFast();
544 //printf("Nrec %d\n",nrec);
545 for (irec=0; irec < nrec; irec++) {
546 pm = (AliRICHPoints*)points->UncheckedAt(irec);
552 //_____________________________________________________________________________
554 void AliRICHDisplay::DrawCerenkovs()
556 // Draw cerenkovs hits for RICH chambers
558 LoadCerenkovs(fChamber);
559 //printf("\nDrawCerenkovs\n");
561 Int_t ntracks, track;
566 cpoints = fPCerenkovs;
567 //printf ("Cpoints: %p",cpoints);
568 if (!cpoints) return;
569 ntracks = cpoints->GetEntriesFast();
570 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
571 for (track=0;track<ntracks;track++) {
572 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
575 fHitsCuts += pm->GetN();
579 //_____________________________________________________________________________
581 void AliRICHDisplay::DrawClusters()
583 // Draw clusterss for RICH chambers
585 Int_t ndigits, digit;
592 ndigits = points->GetEntriesFast();
593 for (digit=0;digit<ndigits;digit++){
594 pm = (AliRICHPoints*)points->UncheckedAt(digit);
599 for (Int_t im=0;im<3;im++) {
600 TMarker3DBox *marker=pm->GetMarker(im);
604 fClustersCuts +=pm->GetN();
608 //_____________________________________________________________________________
609 void AliRICHDisplay::DrawHits()
611 // Draw hits for RICH chambers
615 Int_t ntracks, track;
622 // ntracks = points->GetEntriesFast();
623 ntracks = fPhits->GetEntriesFast();
625 //printf("DrawHits - ntracks %d \n",ntracks);
626 for (track=0;track<ntracks;track++) {
627 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
630 fHitsCuts += pm->GetN();
635 //_____________________________________________________________________________
636 void AliRICHDisplay::DrawTitle(Option_t *option)
638 // Draw the event title
640 Float_t xmin = gPad->GetX1();
641 Float_t xmax = gPad->GetX2();
642 Float_t ymin = gPad->GetY1();
643 Float_t ymax = gPad->GetY2();
644 Float_t dx = xmax-xmin;
645 Float_t dy = ymax-ymin;
647 if (strlen(option) == 0) {
648 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
649 title->SetBit(kCanDelete);
650 title->SetFillColor(42);
653 sprintf(ptitle,"Alice event: %d, Run:%d",
654 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
655 title->AddText(ptitle);
656 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
657 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
658 nparticles, fHitsCuts,fClustersCuts);
659 title->AddText(ptitle);
662 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
663 label->SetBit(kCanDelete);
664 label->SetFillColor(42);
669 //_____________________________________________________________________________
670 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
672 // Draw a view of RICH clusters
674 gPad->SetCursor(kWatch);
675 gPad->SetFillColor(1);
679 TView *view = new TView(1);
680 Float_t range = fRrange*fRangeSlider->GetMaximum();
681 view->SetRange(-range,-range,-range,range, range, range);
688 //Display RICH Chamber Geometry
689 gAlice->GetGeometry()->Draw("same");
691 //add clusters to the pad
697 //printf("Calling DrawCoG\n");
699 //printf("Calling DrawRecHits\n");
702 /*for (Int_t i=0;i<7;i++)
705 // add itself to the list (must be last)
708 view->SetView(phi, theta, psi, iret);
711 //______________________________________________________________________________
712 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
714 // Execute action corresponding to the mouse event
716 static Float_t x0, y0, x1, y1;
718 static Int_t pxold, pyold;
719 static Int_t px0, py0;
720 static Int_t linedrawn;
723 if (px == 0 && py == 0) { //when called by sliders
724 if (event == kButton1Up) {
725 printf("Drawing event %d\n",event);
730 if (!fZoomMode && gPad->GetView()) {
731 gPad->GetView()->ExecuteRotateView(event, px, py);
735 // something to zoom ?
736 gPad->SetCursor(kCross);
741 gVirtualX->SetLineColor(-1);
742 gPad->TAttLine::Modify(); //Change line attributes only if necessary
743 x0 = gPad->AbsPixeltoX(px);
744 y0 = gPad->AbsPixeltoY(py);
746 pxold = px; pyold = py;
751 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
755 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
759 gPad->GetCanvas()->FeedbackMode(kFALSE);
760 if (px == px0) return;
761 if (py == py0) return;
762 x1 = gPad->AbsPixeltoX(px);
763 y1 = gPad->AbsPixeltoY(py);
765 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
766 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
767 gPad->Range(x0,y0,x1,y1);
768 if (fZooms < kMAXZOOM-1) {
770 fZoomX0[fZooms] = x0;
771 fZoomY0[fZooms] = y0;
772 fZoomX1[fZooms] = x1;
773 fZoomY1[fZooms] = y1;
775 gPad->Modified(kTRUE);
780 //___________________________________________
781 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
783 // Read raw clusters info and store x,y,z info in arrays fRpoints
784 // Loop on all detectors
786 if (chamber > 6) return;
788 //printf("Entering LoadCoG\n");
791 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
792 AliRICHChamber* iChamber;
794 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
795 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
796 if (pRICHrawclust == 0) return;
798 pRICH->ResetRawClusters();
801 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
802 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
803 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
804 //printf ("nrawcl:%d\n",nrawcl);
805 if (nrawcl == 0) return;
806 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
808 iChamber = &(pRICH->Chamber(chamber));
809 AliRICHRawCluster *mRaw;
810 AliRICHPoints *points = 0;
812 //loop over all raw clusters and store their position
813 points = new AliRICHPoints(nrawcl);
814 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
815 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
816 fRpoints->AddAt(points,iraw);
817 points->SetMarkerColor(3);
818 points->SetMarkerStyle(3);
819 points->SetMarkerSize(1.);
820 points->SetParticle(-1);
821 points->SetHitIndex(-1);
822 points->SetTrackIndex(-1);
823 points->SetDigitIndex(-1);
824 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
825 Float_t vectorGlob[3];
826 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
827 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
830 //___________________________________________
831 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
833 // Read rec. hits info
834 // Loop on all detectors
836 if (chamber > 6) return;
838 ///printf("Entering LoadRecHits\n");
841 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
842 AliRICHChamber* iChamber;
844 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
845 //printf ("Chamber:%d\n", chamber);
846 if (pRICHrechits1D != 0)
849 //RICH->ResetRecHits();
852 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
853 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
854 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
855 //printf ("nrechits1D:%d\n",nrechits1D);
858 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
860 iChamber = &(pRICH->Chamber(chamber));
861 AliRICHRecHit1D *mRec1D;
862 AliRICHPoints *points1D = 0;
863 //AliRICHEllipse *ellipse = 0;
865 //loop over all rechits and store their position
867 points1D = new AliRICHPoints(nrechits1D);
868 for (Int_t irec=0;irec<nrechits1D;irec++) {
869 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
870 fRecpoints->AddAt(points1D,irec);
871 points1D->SetMarkerColor(38);
872 points1D->SetMarkerStyle(8);
873 points1D->SetMarkerSize(1.);
874 points1D->SetParticle(-1);
875 points1D->SetHitIndex(-1);
876 points1D->SetTrackIndex(-1);
877 points1D->SetDigitIndex(-1);
878 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
879 Float_t vectorGlob[3];
880 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
881 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
882 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
883 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
884 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
885 //printf("Generating ellipse %d\n",irec);
886 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
887 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());
888 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
889 ellipse->CerenkovRingDrawing(chamber,irec);
890 //ellipse->SetFillStyle(1001);
891 ellipse->SetMarkerColor(38);
893 //marker->SetRefObject((TObject*)points1D);
894 //points1D->Set3DMarker(0, marker);
899 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
900 //printf ("Chamber:%d\n", chamber);
901 if (pRICHrechits3D != 0)
904 //RICH->ResetRecHits();
907 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
908 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
909 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
910 //printf ("nrechits3D:%d\n",nrechits3D);
913 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
915 iChamber = &(pRICH->Chamber(chamber));
916 AliRICHRecHit3D *mRec3D;
917 AliRICHPoints *points3D = 0;
918 //AliRICHEllipse *ellipse = 0;
920 //loop over all rechits and store their position
922 points3D = new AliRICHPoints(nrechits3D);
923 for (Int_t irec=0;irec<nrechits3D;irec++) {
924 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
925 fRecpoints->AddAt(points3D,irec);
926 points3D->SetMarkerColor(42);
927 points3D->SetMarkerStyle(8);
928 points3D->SetMarkerSize(1.);
929 points3D->SetParticle(-1);
930 points3D->SetHitIndex(-1);
931 points3D->SetTrackIndex(-1);
932 points3D->SetDigitIndex(-1);
933 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
934 Float_t vectorGlob[3];
935 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
936 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
937 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
938 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
939 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
940 //printf("Generating ellipse %d\n",irec);
941 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
942 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());
943 ellipse->CerenkovRingDrawing(chamber,irec);
944 //ellipse->SetFillStyle(1001);
945 ellipse->SetMarkerColor(42);
947 //marker->SetRefObject((TObject*)points3D);
948 //points3D->Set3DMarker(0, marker);
953 //___________________________________________
954 void AliRICHDisplay::LoadDigits()
956 // Read digits info and store x,y,z info in arrays fPoints
957 // Loop on all detectors
960 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
961 AliRICHChamber* iChamber;
962 AliSegmentation* segmentation;
966 //printf("Entering LoadDigits\n");
971 for (ich=0; ich<kNCH; ich++) {
972 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
973 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
974 if (pRICHdigits == 0) continue;
975 gAlice->ResetDigits();
976 gAlice->TreeD()->GetEvent(0);
977 Int_t ndigits = pRICHdigits->GetEntriesFast();
978 //printf("ndigits:%d\n",ndigits);
982 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
984 for (ich=0; ich<kNCH; ich++) {
985 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
986 if (pRICHdigits == 0) continue;
987 gAlice->ResetDigits();
988 gAlice->TreeD()->GetEvent(0);
989 Int_t ndigits = pRICHdigits->GetEntriesFast();
990 if (ndigits == 0) continue;
991 iChamber = &(pRICH->Chamber(ich));
992 segmentation=iChamber->GetSegmentationModel();
993 Float_t dpx = segmentation->Dpx();
994 Float_t dpy = segmentation->Dpy();
996 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
999 AliRICHPoints *points = 0;
1000 TMarker3DBox *marker = 0;
1002 //loop over all digits and store their position
1005 for (Int_t digit=0;digit<ndigits;digit++) {
1006 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1007 points = new AliRICHPoints(npoints);
1008 fPoints->AddAt(points,counter);
1010 Int_t charge=mdig->fSignal;
1011 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1012 Int_t color=701+index;
1013 if (color>722) color=722;
1014 points->SetMarkerColor(color);
1015 points->SetMarkerStyle(21);
1016 points->SetMarkerSize(0.5);
1017 Float_t xpad, ypad, zpad;
1018 segmentation->GetPadC(mdig->fPadX, mdig->fPadY,xpad, ypad, zpad);
1019 Float_t vectorLoc[3]={xpad,5,ypad};
1020 Float_t vectorGlob[3];
1021 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1022 points->SetParticle(-1);
1023 points->SetHitIndex(-1);
1024 points->SetTrackIndex(-1);
1025 points->SetDigitIndex(digit);
1026 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1027 //printf("Y position (digit): %f\n", vectorGlob[1]);
1029 segmentation->GetPadC(mdig->fPadX, mdig->fPadY, xpad, ypad, zpad);
1030 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1031 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1032 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1033 dpy/2,0,dpx/2,theta,phi);
1034 marker->SetLineColor(2);
1035 marker->SetFillStyle(1001);
1036 marker->SetFillColor(color);
1037 marker->SetRefObject((TObject*)points);
1038 points->Set3DMarker(0, marker);
1039 } // loop over digits
1040 } // loop over chambers
1045 //___________________________________________
1046 void AliRICHDisplay::LoadHits(Int_t chamber)
1048 // Read hits info and store x,y,z info in arrays fPhits
1049 // Loop on all detectors
1055 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1056 AliRICHChamber* iChamber;
1058 iChamber = &(pRICH->Chamber(chamber-1));
1059 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1062 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1063 //TVector *xp = new TVector(1000);
1064 //TVector *yp = new TVector(1000);
1065 //TVector *zp = new TVector(1000);
1066 //TVector *ptrk = new TVector(1000);
1067 //TVector *phit = new TVector(1000);
1069 for (track=0; track<ntracks;track++) {
1070 gAlice->ResetHits();
1071 gAlice->TreeH()->GetEvent(track);
1072 TClonesArray *pRICHhits = pRICH->Hits();
1073 if (pRICHhits == 0) return;
1074 Int_t nhits = pRICHhits->GetEntriesFast();
1078 fPhits = new TObjArray(nAllHits);
1081 for (track=0; track<ntracks;track++) {
1082 gAlice->ResetHits();
1083 gAlice->TreeH()->GetEvent(track);
1084 TClonesArray *pRICHhits = pRICH->Hits();
1085 if (pRICHhits == 0) return;
1086 Int_t nhits = pRICHhits->GetEntriesFast();
1087 if (nhits == 0) continue;
1089 AliRICHPoints *points = 0;
1090 for (Int_t hit=0;hit<nhits;hit++) {
1091 points = new AliRICHPoints(1);
1092 fPhits->AddAt(points,npoints);
1093 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1094 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1095 if (current->GetPdgCode() == 50000050) {
1096 points->SetMarkerColor(kBlue);
1097 } else if (current->GetPdgCode() == 50000051) {
1098 points->SetMarkerColor(kYellow);
1100 points->SetMarkerColor(kRed);
1102 points->SetMarkerStyle(5);
1103 points->SetMarkerSize(1.);
1104 points->SetParticle(mHit->Track());
1105 points->SetHitIndex(hit);
1106 points->SetTrackIndex(track);
1107 points->SetDigitIndex(-1);
1108 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1109 //printf("Y position: %f\n", mHit->Y());
1115 //_____________________________________________________________________________
1117 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1119 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1120 // Loop on all detectors
1125 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1126 AliRICHChamber* iChamber;
1128 iChamber = &(pRICH->Chamber(chamber-1));
1130 pRICH->SetTreeAddress();
1131 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1133 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1134 TVector *xp = new TVector(1000);
1135 TVector *yp = new TVector(1000);
1136 TVector *zp = new TVector(1000);
1137 TVector *ptrk = new TVector(1000);
1138 TVector *phit = new TVector(1000);
1139 for (Int_t track=0; track<ntracks;track++) {
1140 gAlice->ResetHits();
1141 gAlice->TreeH()->GetEvent(track);
1142 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1143 if (pRICHCerenkovs == 0) return;
1144 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1145 if (nhits == 0) continue;
1146 AliRICHCerenkov *mCerenkov;
1147 AliRICHPoints *cpoints = 0;
1151 //Display Cerenkov hits in blue
1153 for (Int_t hit=0;hit<nhits;hit++) {
1154 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1155 (*xp)(npoints)=mCerenkov->X();
1156 (*yp)(npoints)=mCerenkov->Y();
1157 (*zp)(npoints)=mCerenkov->Z();
1158 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1159 (*phit)(npoints)=Float_t(hit);
1162 if (npoints == 0) continue;
1163 cpoints = new AliRICHPoints(npoints);
1164 for (Int_t p=0;p<npoints;p++) {
1165 cpoints->SetMarkerColor(kBlue);
1166 cpoints->SetMarkerStyle(5);
1167 cpoints->SetMarkerSize(1.);
1168 cpoints->SetParticle(Int_t((*ptrk)(p)));
1169 cpoints->SetHitIndex(Int_t((*phit)(p)));
1170 cpoints->SetTrackIndex(track);
1171 cpoints->SetDigitIndex(-1);
1172 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1178 fPCerenkovs->AddAt(cpoints,track);
1182 //_____________________________________________________________________________
1183 void AliRICHDisplay::Paint(Option_t *)
1185 // Paint miscellaneous items
1189 //_____________________________________________________________________________
1190 void AliRICHDisplay::SetPickMode()
1197 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1198 fTrigPad->Modified();
1201 //_____________________________________________________________________________
1202 void AliRICHDisplay::SetZoomMode()
1209 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1210 fTrigPad->Modified();
1213 //_____________________________________________________________________________
1214 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1216 // Set chamber and cathode number
1220 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1227 //_____________________________________________________________________________
1228 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1230 // Set view range along R and Z
1239 //_____________________________________________________________________________
1240 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1242 // change viewing angles for current event
1250 TView *view = gPad->GetView();
1251 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1257 //_____________________________________________________________________________
1258 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1260 // Display (current event_number+delta)
1261 // delta = 1 shown next event
1262 // delta = -1 show previous event
1266 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1267 Int_t newEvent = currentEvent + delta;
1268 gAlice->GetEvent(newEvent);
1269 if (!gAlice->TreeD()) return;
1279 //______________________________________________________________________________
1280 void AliRICHDisplay::UnZoom()
1283 // Return to previous zoom factor
1285 if (fZooms <= 0) return;
1287 TPad *pad = (TPad*)gPad->GetPadSave();
1288 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1292 //_____________________________________________________________________________
1293 void AliRICHDisplay::ResetPoints()
1296 // Reset array of points
1304 //_____________________________________________________________________________
1305 void AliRICHDisplay::ResetRpoints()
1308 // Reset array of points
1316 //_____________________________________________________________________________
1317 void AliRICHDisplay::ResetRecpoints()
1320 // Reset array of points
1323 fRecpoints->Delete();
1328 //_____________________________________________________________________________
1329 void AliRICHDisplay::ResetPhits()
1332 // Reset array of points
1340 //_____________________________________________________________________________
1341 void AliRICHDisplay::ResetPCerenkovs()
1344 // Reset array of points
1347 fPCerenkovs->Delete();
1353 //_____________________________________________________________________________
1355 void AliRICHDisplay::DrawViewGL()
1357 // Draw current view using OPENGL
1359 TPad *pad = (TPad*)gPad->GetPadSave();
1361 TView *view = pad->GetView();
1366 //_____________________________________________________________________________
1367 void AliRICHDisplay::DrawViewX3D()
1369 // Draw current view using X3D
1371 TPad *pad = (TPad*)gPad->GetPadSave();
1373 TView *view = pad->GetView();