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.14 2001/05/16 14:57:20 alibrary
19 New files for folders and Stack
21 Revision 1.13 2001/05/10 12:35:16 jbarbosa
22 Removed hit display, added rec. ring properties.
24 Revision 1.12 2001/03/14 18:15:03 jbarbosa
25 Changes to adapt to new IO.
26 Removed verbose output.
28 Revision 1.11 2001/02/27 15:21:34 jbarbosa
29 Transition to SDigits.
31 Revision 1.10 2001/02/13 20:18:48 jbarbosa
32 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
34 Revision 1.9 2000/11/01 15:33:11 jbarbosa
35 Updated to handle both reconstruction algorithms.
37 Revision 1.8 2000/10/03 21:44:09 morsch
38 Use AliSegmentation and AliHit abstract base classes.
40 Revision 1.7 2000/10/02 21:28:12 fca
41 Removal of useless dependecies via forward declarations
43 Revision 1.6 2000/10/02 15:46:38 jbarbosa
44 Fixed forward declarations.
46 Revision 1.5 2000/06/30 16:49:34 dibari
47 Different call for ring drawing.
49 Revision 1.4 2000/06/12 15:21:08 jbarbosa
52 Revision 1.3 2000/06/09 14:52:08 jbarbosa
53 New tentative ellipse drawing routine
55 Revision 1.1 2000/04/19 13:07:45 morsch
56 Digits, clusters and reconstruction results added.
61 //////////////////////////////////////////////////////////////////////////
65 // Utility class to display ALICE outline, tracks, hits,.. //
67 //////////////////////////////////////////////////////////////////////////
76 #include <TPolyMarker3D.h>
79 #include <TPolyMarker.h>
80 #include <TPaveLabel.h>
81 #include <TPaveText.h>
88 #include <TGeometry.h>
89 #include <TSliderBox.h>
91 #include <TVirtualX.h>
94 #include <X3DBuffer.h>
95 #include <TParticle.h>
99 #include "AliDetector.h"
101 #include "AliRICHConst.h"
102 #include "AliRICHDisplay.h"
103 #include "AliRICHPoints.h"
104 #include "AliHeader.h"
106 #include "AliRICHHit.h"
107 #include "AliRICHCerenkov.h"
108 #include "AliRICHSDigit.h"
109 #include "AliRICHDigit.h"
110 #include "AliRICHRawCluster.h"
111 #include "AliRICHRecHit1D.h"
112 #include "AliRICHRecHit3D.h"
113 #include "AliRICHEllipse.h"
115 ClassImp(AliRICHDisplay)
118 //____________________________________________________________________________
119 AliRICHDisplay::AliRICHDisplay()
122 // default constructor
132 //_____________________________________________________________________________
133 AliRICHDisplay::AliRICHDisplay(Int_t size)
135 // Create an event display object.
136 // A canvas named "edisplay" is created with a vertical size in pixels
138 // A QUICK Overview of the Event Display functions
139 // ===============================================
141 // The event display can ve invoked by executing the macro "display.C"
142 // A canvas like in the picture below will appear.
144 // On the left side of the canvas, the following buttons appear:
145 // *Next* to move to the next event
146 // *Previous* to move to the previous event
148 // *Pick* Select this option to be able to point on a track with the
149 // mouse. Once on the track, use the right button to select
150 // an action. For example, select SetMarkerAttributes to
151 // change the marker type/color/size for the track.
152 // *Zoom* Select this option (default) if you want to zoom.
153 // To zoom, simply select the selected area with the left button.
154 // *UnZoom* To revert to the previous picture size.
156 // slider R On the left side, the vertical slider can be used to
157 // set the default picture size.
159 // When you are in Zoom mode, you can click on the black part of the canvas
160 // to select special options with the right mouse button.
163 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
164 // When you are on a track, select the menu item "InspectParticle"
165 // to display the current particle attributes.
167 // You can activate the Root browser by selecting the Inspect menu
168 // in the canvas tool bar menu. Then select "Start Browser"
169 // This will open a new canvas with the browser. At this point, you may want
170 // to display some histograms (from the Trees). Go to the "File" menu
171 // of the browser and click on "New canvas".
172 // In the browser, click on item "ROOT files" in the left pane.
173 // Click on galice.root.
175 // Click on TPC for example
176 // Click on any variable (eg TPC.fX) to histogram the variable.
178 // If you are lost, you can click on HELP in any Root canvas or browser.
181 <img src="gif/AliRICHDisplay.gif">
188 gAlice->SetDisplay(this);
190 // Initialize display default parameters
193 // Set front view by default
200 fDrawClusters = kTRUE;
202 fDrawRecHits = kTRUE;
213 // Create display canvas
215 if (ysize < 100) ysize = 750;
216 Int_t xsize = Int_t(size*830./ysize);
217 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
218 fCanvas->ToggleEventStatus();
220 // Create main display pad
221 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
224 fPad->SetFillColor(1);
225 fPad->SetBorderSize(2);
230 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
233 fColPad->SetFillColor(19);
234 fColPad->SetBorderSize(2);
240 // Create user interface control pad
244 // Create Range and mode pad
247 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
250 fTrigPad->SetFillColor(22);
251 fTrigPad->SetBorderSize(2);
252 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
253 fRangeSlider->SetObject(this);
254 char pickmode[] = "gAlice->Display()->SetPickMode()";
256 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
257 fPickButton->SetFillColor(38);
259 char zoommode[] = "gAlice->Display()->SetZoomMode()";
260 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
261 fZoomButton->SetFillColor(38);
263 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
264 fArcButton->SetFillColor(kGreen);
266 char butUnzoom[] = "gAlice->Display()->UnZoom()";
267 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
268 button->SetFillColor(38);
270 AppendPad(); // append display object as last object to force selection
272 fTrigPad->SetEditable(kFALSE);
273 fButtons->SetEditable(kFALSE);
279 //_____________________________________________________________________________
280 AliRICHDisplay::~AliRICHDisplay()
282 // Delete space point structure
283 if (fPoints) fPoints->Delete();
287 if (fPhits) fPhits->Delete();
291 if (fRpoints) fRpoints->Delete();
295 if (fRecpoints) fRecpoints->Delete();
299 if (fPCerenkovs) fPCerenkovs->Delete();
304 //_____________________________________________________________________________
305 void AliRICHDisplay::Clear(Option_t *)
307 // Delete graphics temporary objects
310 //_____________________________________________________________________________
311 void AliRICHDisplay::DisplayButtons()
313 // Create the user interface buttons
316 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
318 fButtons->SetFillColor(38);
319 fButtons->SetBorderSize(2);
322 // Int_t butcolor = 33;
323 Float_t dbutton = 0.08;
330 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
331 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
332 button->SetFillColor(38);
336 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
337 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
338 button->SetFillColor(38);
342 char but7[] = "gAlice->Display()->DrawViewGL()";
343 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
344 button->SetFillColor(38);
348 char but8[] = "gAlice->Display()->DrawViewX3D()";
349 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
350 button->SetFillColor(38);
354 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
355 diamond->SetFillColor(50);
356 diamond->SetTextAlign(22);
357 diamond->SetTextColor(5);
358 diamond->SetTextSize(0.11);
360 diamond->AddText(".. ");
361 diamond->AddText("ROOT");
362 diamond->AddText("RICH");
363 diamond->AddText("... ");
364 diamond->AddText(" ");
367 //_____________________________________________________________________________
368 void AliRICHDisplay::CreateColors()
370 // Create the colors palette used to display clusters
385 new TColor(color,r,g,b);
395 new TColor(color,r,g,b);
405 new TColor(color,r,g,b);
415 new TColor(color,r,g,b);
425 new TColor(color,r,g,b);
432 //_____________________________________________________________________________
433 void AliRICHDisplay::DisplayColorScale()
436 // Draw the color scale in the RICH display canvas
440 Float_t xlow, ylow, xup, yup, hs;
441 Float_t x1, y1, x2, y2;
445 gPad->SetFillColor(0);
447 gPad->Range(x1,y1,x2,y2);
448 TText *text = new TText(0,0,"");
449 text->SetTextFont(61);
450 text->SetTextSize(0.03);
451 text->SetTextAlign(22);
455 //*-* draw colortable boxes
456 hs = (y2-y1)/Float_t(22);
460 ylow = y1 + hs*(Float_t(i));
461 yup = y1 + hs*(Float_t(i+1));
463 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
464 Int_t scale=(Int_t)TMath::Exp(logscale);
465 sprintf(label,"%d",scale);
466 box = new TBox(xlow, ylow, xup, yup);
467 box->SetFillColor(color);
469 text->DrawText(xup+4, 0.5*(ylow+yup),label);
473 //______________________________________________________________________________
474 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
476 // Compute distance from point px,py to objects in event
478 gPad->SetCursor(kCross);
480 if (gPad == fTrigPad) return 9999;
482 const Int_t kBig = 9999;
484 Float_t xmin = gPad->GetX1();
485 Float_t xmax = gPad->GetX2();
486 Float_t dx = 0.02*(xmax - xmin);
487 Float_t x = gPad->AbsPixeltoX(px);
488 if (x < xmin+dx || x > xmax-dx) return dist;
489 if (fZoomMode) return 0;
493 //_____________________________________________________________________________
494 void AliRICHDisplay::Draw(Option_t *)
496 // Display current event
500 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
502 // Display the event number and title
507 //_____________________________________________________________________________
508 void AliRICHDisplay::DrawCoG()
510 // Draw hits for RICH chambers
512 if (!fDrawCoG) return;
514 for (Int_t chamber=0;chamber<kNCH;chamber++) {
523 ncog = points->GetEntriesFast();
524 for (icog=0; icog < ncog; icog++) {
525 pm = (AliRICHPoints*)points->UncheckedAt(icog);
531 void AliRICHDisplay::DrawRecHits()
533 // Draw rec hits for RICH chambers
535 if (!fDrawRecHits) return;
537 for (Int_t chamber=0;chamber<kNCH;chamber++) {
538 LoadRecHits(chamber,1);
546 nrec = points->GetEntriesFast();
547 //printf("Nrec %d\n",nrec);
548 for (irec=0; irec < nrec; irec++) {
549 pm = (AliRICHPoints*)points->UncheckedAt(irec);
555 //_____________________________________________________________________________
557 void AliRICHDisplay::DrawCerenkovs()
559 // Draw cerenkovs hits for RICH chambers
561 LoadCerenkovs(fChamber);
562 //printf("\nDrawCerenkovs\n");
564 Int_t ntracks, track;
569 cpoints = fPCerenkovs;
570 //printf ("Cpoints: %p",cpoints);
571 if (!cpoints) return;
572 ntracks = cpoints->GetEntriesFast();
573 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
574 for (track=0;track<ntracks;track++) {
575 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
578 fHitsCuts += pm->GetN();
582 //_____________________________________________________________________________
584 void AliRICHDisplay::DrawClusters()
586 // Draw clusterss for RICH chambers
588 Int_t ndigits, digit;
595 ndigits = points->GetEntriesFast();
596 for (digit=0;digit<ndigits;digit++){
597 pm = (AliRICHPoints*)points->UncheckedAt(digit);
602 for (Int_t im=0;im<3;im++) {
603 TMarker3DBox *marker=pm->GetMarker(im);
607 fClustersCuts +=pm->GetN();
611 //_____________________________________________________________________________
612 void AliRICHDisplay::DrawHits()
614 // Draw hits for RICH chambers
618 Int_t ntracks, track;
625 // ntracks = points->GetEntriesFast();
626 ntracks = fPhits->GetEntriesFast();
628 //printf("DrawHits - ntracks %d \n",ntracks);
629 for (track=0;track<ntracks;track++) {
630 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
633 fHitsCuts += pm->GetN();
638 //_____________________________________________________________________________
639 void AliRICHDisplay::DrawTitle(Option_t *option)
641 // Draw the event title
643 Float_t xmin = gPad->GetX1();
644 Float_t xmax = gPad->GetX2();
645 Float_t ymin = gPad->GetY1();
646 Float_t ymax = gPad->GetY2();
647 Float_t dx = xmax-xmin;
648 Float_t dy = ymax-ymin;
650 if (strlen(option) == 0) {
651 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
652 title->SetBit(kCanDelete);
653 title->SetFillColor(42);
656 sprintf(ptitle,"Alice event: %d, Run:%d",
657 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
658 title->AddText(ptitle);
659 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
660 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
661 nparticles, fHitsCuts,fClustersCuts);
662 title->AddText(ptitle);
665 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
666 label->SetBit(kCanDelete);
667 label->SetFillColor(42);
672 //_____________________________________________________________________________
673 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
675 // Draw a view of RICH clusters
677 gPad->SetCursor(kWatch);
678 gPad->SetFillColor(1);
682 TView *view = new TView(1);
683 Float_t range = fRrange*fRangeSlider->GetMaximum();
684 view->SetRange(-range,-range,-range,range, range, range);
691 //Display RICH Chamber Geometry
692 gAlice->GetGeometry()->Draw("same");
694 //add clusters to the pad
700 //printf("Calling DrawCoG\n");
702 //printf("Calling DrawRecHits\n");
705 /*for (Int_t i=0;i<7;i++)
708 // add itself to the list (must be last)
711 view->SetView(phi, theta, psi, iret);
714 //______________________________________________________________________________
715 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
717 // Execute action corresponding to the mouse event
719 static Float_t x0, y0, x1, y1;
721 static Int_t pxold, pyold;
722 static Int_t px0, py0;
723 static Int_t linedrawn;
726 if (px == 0 && py == 0) { //when called by sliders
727 if (event == kButton1Up) {
728 printf("Drawing event %d\n",event);
733 if (!fZoomMode && gPad->GetView()) {
734 gPad->GetView()->ExecuteRotateView(event, px, py);
738 // something to zoom ?
739 gPad->SetCursor(kCross);
744 gVirtualX->SetLineColor(-1);
745 gPad->TAttLine::Modify(); //Change line attributes only if necessary
746 x0 = gPad->AbsPixeltoX(px);
747 y0 = gPad->AbsPixeltoY(py);
749 pxold = px; pyold = py;
754 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
758 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
762 gPad->GetCanvas()->FeedbackMode(kFALSE);
763 if (px == px0) return;
764 if (py == py0) return;
765 x1 = gPad->AbsPixeltoX(px);
766 y1 = gPad->AbsPixeltoY(py);
768 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
769 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
770 gPad->Range(x0,y0,x1,y1);
771 if (fZooms < kMAXZOOM-1) {
773 fZoomX0[fZooms] = x0;
774 fZoomY0[fZooms] = y0;
775 fZoomX1[fZooms] = x1;
776 fZoomY1[fZooms] = y1;
778 gPad->Modified(kTRUE);
783 //___________________________________________
784 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
786 // Read raw clusters info and store x,y,z info in arrays fRpoints
787 // Loop on all detectors
789 if (chamber > 6) return;
791 //printf("Entering LoadCoG\n");
794 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
795 AliRICHChamber* iChamber;
797 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
798 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
799 if (pRICHrawclust == 0) return;
801 pRICH->ResetRawClusters();
804 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
805 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
806 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
807 //printf ("nrawcl:%d\n",nrawcl);
808 if (nrawcl == 0) return;
809 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
811 iChamber = &(pRICH->Chamber(chamber));
812 AliRICHRawCluster *mRaw;
813 AliRICHPoints *points = 0;
815 //loop over all raw clusters and store their position
816 points = new AliRICHPoints(nrawcl);
817 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
818 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
819 fRpoints->AddAt(points,iraw);
820 points->SetMarkerColor(3);
821 points->SetMarkerStyle(3);
822 points->SetMarkerSize(1.);
823 points->SetParticle(-1);
824 points->SetHitIndex(-1);
825 points->SetTrackIndex(-1);
826 points->SetDigitIndex(-1);
827 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
828 Float_t vectorGlob[3];
829 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
830 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
833 //___________________________________________
834 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
836 // Read rec. hits info
837 // Loop on all detectors
839 if (chamber > 6) return;
841 ///printf("Entering LoadRecHits\n");
844 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
845 AliRICHChamber* iChamber;
847 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
848 //printf ("Chamber:%d\n", chamber);
849 if (pRICHrechits1D != 0)
852 //RICH->ResetRecHits();
855 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
856 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
857 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
858 //printf ("nrechits1D:%d\n",nrechits1D);
861 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
863 iChamber = &(pRICH->Chamber(chamber));
864 AliRICHRecHit1D *mRec1D;
865 AliRICHPoints *points1D = 0;
866 //AliRICHEllipse *ellipse = 0;
868 //loop over all rechits and store their position
870 points1D = new AliRICHPoints(nrechits1D);
871 for (Int_t irec=0;irec<nrechits1D;irec++) {
872 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
873 fRecpoints->AddAt(points1D,irec);
874 points1D->SetMarkerColor(38);
875 points1D->SetMarkerStyle(8);
876 points1D->SetMarkerSize(1.);
877 points1D->SetParticle(-1);
878 points1D->SetHitIndex(-1);
879 points1D->SetTrackIndex(-1);
880 points1D->SetDigitIndex(-1);
881 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
882 Float_t vectorGlob[3];
883 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
884 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
885 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
886 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
887 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
888 //printf("Generating ellipse %d\n",irec);
889 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
890 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());
891 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
892 ellipse->CerenkovRingDrawing(chamber,irec);
893 //ellipse->SetFillStyle(1001);
894 ellipse->SetMarkerColor(38);
896 //marker->SetRefObject((TObject*)points1D);
897 //points1D->Set3DMarker(0, marker);
902 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
903 //printf ("Chamber:%d\n", chamber);
904 if (pRICHrechits3D != 0)
907 //RICH->ResetRecHits();
910 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
911 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
912 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
913 //printf ("nrechits3D:%d\n",nrechits3D);
916 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
918 iChamber = &(pRICH->Chamber(chamber));
919 AliRICHRecHit3D *mRec3D;
920 AliRICHPoints *points3D = 0;
921 //AliRICHEllipse *ellipse = 0;
923 //loop over all rechits and store their position
925 points3D = new AliRICHPoints(nrechits3D);
926 for (Int_t irec=0;irec<nrechits3D;irec++) {
927 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
928 fRecpoints->AddAt(points3D,irec);
929 points3D->SetMarkerColor(42);
930 points3D->SetMarkerStyle(8);
931 points3D->SetMarkerSize(1.);
932 points3D->SetParticle(-1);
933 points3D->SetHitIndex(-1);
934 points3D->SetTrackIndex(-1);
935 points3D->SetDigitIndex(-1);
936 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
937 Float_t vectorGlob[3];
938 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
939 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
940 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
941 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
942 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
943 //printf("Generating ellipse %d\n",irec);
944 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
945 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());
946 ellipse->CerenkovRingDrawing(chamber,irec);
947 //ellipse->SetFillStyle(1001);
948 ellipse->SetMarkerColor(42);
950 //marker->SetRefObject((TObject*)points3D);
951 //points3D->Set3DMarker(0, marker);
956 //___________________________________________
957 void AliRICHDisplay::LoadDigits()
959 // Read digits info and store x,y,z info in arrays fPoints
960 // Loop on all detectors
963 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
964 AliRICHChamber* iChamber;
965 AliSegmentation* segmentation;
969 //printf("Entering LoadDigits\n");
974 for (ich=0; ich<kNCH; ich++) {
975 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
976 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
977 if (pRICHdigits == 0) continue;
978 gAlice->ResetDigits();
979 gAlice->TreeD()->GetEvent(0);
980 Int_t ndigits = pRICHdigits->GetEntriesFast();
981 //printf("ndigits:%d\n",ndigits);
985 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
987 for (ich=0; ich<kNCH; ich++) {
988 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
989 if (pRICHdigits == 0) continue;
990 gAlice->ResetDigits();
991 gAlice->TreeD()->GetEvent(0);
992 Int_t ndigits = pRICHdigits->GetEntriesFast();
993 if (ndigits == 0) continue;
994 iChamber = &(pRICH->Chamber(ich));
995 segmentation=iChamber->GetSegmentationModel();
996 Float_t dpx = segmentation->Dpx();
997 Float_t dpy = segmentation->Dpy();
999 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1002 AliRICHPoints *points = 0;
1003 TMarker3DBox *marker = 0;
1005 //loop over all digits and store their position
1008 for (Int_t digit=0;digit<ndigits;digit++) {
1009 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1010 points = new AliRICHPoints(npoints);
1011 fPoints->AddAt(points,counter);
1013 Int_t charge=mdig->fSignal;
1014 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1015 Int_t color=701+index;
1016 if (color>722) color=722;
1017 points->SetMarkerColor(color);
1018 points->SetMarkerStyle(21);
1019 points->SetMarkerSize(0.5);
1020 Float_t xpad, ypad, zpad;
1021 segmentation->GetPadC(mdig->fPadX, mdig->fPadY,xpad, ypad, zpad);
1022 Float_t vectorLoc[3]={xpad,5,ypad};
1023 Float_t vectorGlob[3];
1024 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1025 points->SetParticle(-1);
1026 points->SetHitIndex(-1);
1027 points->SetTrackIndex(-1);
1028 points->SetDigitIndex(digit);
1029 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1030 //printf("Y position (digit): %f\n", vectorGlob[1]);
1032 segmentation->GetPadC(mdig->fPadX, mdig->fPadY, xpad, ypad, zpad);
1033 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1034 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1035 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1036 dpy/2,0,dpx/2,theta,phi);
1037 marker->SetLineColor(2);
1038 marker->SetFillStyle(1001);
1039 marker->SetFillColor(color);
1040 marker->SetRefObject((TObject*)points);
1041 points->Set3DMarker(0, marker);
1042 } // loop over digits
1043 } // loop over chambers
1048 //___________________________________________
1049 void AliRICHDisplay::LoadHits(Int_t chamber)
1051 // Read hits info and store x,y,z info in arrays fPhits
1052 // Loop on all detectors
1058 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1059 AliRICHChamber* iChamber;
1061 iChamber = &(pRICH->Chamber(chamber-1));
1062 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1065 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1066 //TVector *xp = new TVector(1000);
1067 //TVector *yp = new TVector(1000);
1068 //TVector *zp = new TVector(1000);
1069 //TVector *ptrk = new TVector(1000);
1070 //TVector *phit = new TVector(1000);
1072 for (track=0; track<ntracks;track++) {
1073 gAlice->ResetHits();
1074 gAlice->TreeH()->GetEvent(track);
1075 TClonesArray *pRICHhits = pRICH->Hits();
1076 if (pRICHhits == 0) return;
1077 Int_t nhits = pRICHhits->GetEntriesFast();
1081 fPhits = new TObjArray(nAllHits);
1084 for (track=0; track<ntracks;track++) {
1085 gAlice->ResetHits();
1086 gAlice->TreeH()->GetEvent(track);
1087 TClonesArray *pRICHhits = pRICH->Hits();
1088 if (pRICHhits == 0) return;
1089 Int_t nhits = pRICHhits->GetEntriesFast();
1090 if (nhits == 0) continue;
1092 AliRICHPoints *points = 0;
1093 for (Int_t hit=0;hit<nhits;hit++) {
1094 points = new AliRICHPoints(1);
1095 fPhits->AddAt(points,npoints);
1096 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1097 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1098 if (current->GetPdgCode() == 50000050) {
1099 points->SetMarkerColor(kBlue);
1100 } else if (current->GetPdgCode() == 50000051) {
1101 points->SetMarkerColor(kYellow);
1103 points->SetMarkerColor(kRed);
1105 points->SetMarkerStyle(5);
1106 points->SetMarkerSize(1.);
1107 points->SetParticle(mHit->Track());
1108 points->SetHitIndex(hit);
1109 points->SetTrackIndex(track);
1110 points->SetDigitIndex(-1);
1111 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1112 //printf("Y position: %f\n", mHit->Y());
1118 //_____________________________________________________________________________
1120 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1122 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1123 // Loop on all detectors
1128 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1129 AliRICHChamber* iChamber;
1131 iChamber = &(pRICH->Chamber(chamber-1));
1133 pRICH->SetTreeAddress();
1134 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1136 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1137 TVector *xp = new TVector(1000);
1138 TVector *yp = new TVector(1000);
1139 TVector *zp = new TVector(1000);
1140 TVector *ptrk = new TVector(1000);
1141 TVector *phit = new TVector(1000);
1142 for (Int_t track=0; track<ntracks;track++) {
1143 gAlice->ResetHits();
1144 gAlice->TreeH()->GetEvent(track);
1145 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1146 if (pRICHCerenkovs == 0) return;
1147 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1148 if (nhits == 0) continue;
1149 AliRICHCerenkov *mCerenkov;
1150 AliRICHPoints *cpoints = 0;
1154 //Display Cerenkov hits in blue
1156 for (Int_t hit=0;hit<nhits;hit++) {
1157 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1158 (*xp)(npoints)=mCerenkov->X();
1159 (*yp)(npoints)=mCerenkov->Y();
1160 (*zp)(npoints)=mCerenkov->Z();
1161 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1162 (*phit)(npoints)=Float_t(hit);
1165 if (npoints == 0) continue;
1166 cpoints = new AliRICHPoints(npoints);
1167 for (Int_t p=0;p<npoints;p++) {
1168 cpoints->SetMarkerColor(kBlue);
1169 cpoints->SetMarkerStyle(5);
1170 cpoints->SetMarkerSize(1.);
1171 cpoints->SetParticle(Int_t((*ptrk)(p)));
1172 cpoints->SetHitIndex(Int_t((*phit)(p)));
1173 cpoints->SetTrackIndex(track);
1174 cpoints->SetDigitIndex(-1);
1175 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1181 fPCerenkovs->AddAt(cpoints,track);
1185 //_____________________________________________________________________________
1186 void AliRICHDisplay::Paint(Option_t *)
1188 // Paint miscellaneous items
1192 //_____________________________________________________________________________
1193 void AliRICHDisplay::SetPickMode()
1200 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1201 fTrigPad->Modified();
1204 //_____________________________________________________________________________
1205 void AliRICHDisplay::SetZoomMode()
1212 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1213 fTrigPad->Modified();
1216 //_____________________________________________________________________________
1217 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1219 // Set chamber and cathode number
1223 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1230 //_____________________________________________________________________________
1231 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1233 // Set view range along R and Z
1242 //_____________________________________________________________________________
1243 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1245 // change viewing angles for current event
1253 TView *view = gPad->GetView();
1254 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1260 //_____________________________________________________________________________
1261 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1263 // Display (current event_number+delta)
1264 // delta = 1 shown next event
1265 // delta = -1 show previous event
1269 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1270 Int_t newEvent = currentEvent + delta;
1271 gAlice->GetEvent(newEvent);
1272 if (!gAlice->TreeD()) return;
1282 //______________________________________________________________________________
1283 void AliRICHDisplay::UnZoom()
1286 // Return to previous zoom factor
1288 if (fZooms <= 0) return;
1290 TPad *pad = (TPad*)gPad->GetPadSave();
1291 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1295 //_____________________________________________________________________________
1296 void AliRICHDisplay::ResetPoints()
1299 // Reset array of points
1307 //_____________________________________________________________________________
1308 void AliRICHDisplay::ResetRpoints()
1311 // Reset array of points
1319 //_____________________________________________________________________________
1320 void AliRICHDisplay::ResetRecpoints()
1323 // Reset array of points
1326 fRecpoints->Delete();
1331 //_____________________________________________________________________________
1332 void AliRICHDisplay::ResetPhits()
1335 // Reset array of points
1343 //_____________________________________________________________________________
1344 void AliRICHDisplay::ResetPCerenkovs()
1347 // Reset array of points
1350 fPCerenkovs->Delete();
1356 //_____________________________________________________________________________
1358 void AliRICHDisplay::DrawViewGL()
1360 // Draw current view using OPENGL
1362 TPad *pad = (TPad*)gPad->GetPadSave();
1364 TView *view = pad->GetView();
1369 //_____________________________________________________________________________
1370 void AliRICHDisplay::DrawViewX3D()
1372 // Draw current view using X3D
1374 TPad *pad = (TPad*)gPad->GetPadSave();
1376 TView *view = pad->GetView();