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.12 2001/03/14 18:15:03 jbarbosa
19 Changes to adapt to new IO.
20 Removed verbose output.
22 Revision 1.11 2001/02/27 15:21:34 jbarbosa
23 Transition to SDigits.
25 Revision 1.10 2001/02/13 20:18:48 jbarbosa
26 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
28 Revision 1.9 2000/11/01 15:33:11 jbarbosa
29 Updated to handle both reconstruction algorithms.
31 Revision 1.8 2000/10/03 21:44:09 morsch
32 Use AliSegmentation and AliHit abstract base classes.
34 Revision 1.7 2000/10/02 21:28:12 fca
35 Removal of useless dependecies via forward declarations
37 Revision 1.6 2000/10/02 15:46:38 jbarbosa
38 Fixed forward declarations.
40 Revision 1.5 2000/06/30 16:49:34 dibari
41 Different call for ring drawing.
43 Revision 1.4 2000/06/12 15:21:08 jbarbosa
46 Revision 1.3 2000/06/09 14:52:08 jbarbosa
47 New tentative ellipse drawing routine
49 Revision 1.1 2000/04/19 13:07:45 morsch
50 Digits, clusters and reconstruction results added.
55 //////////////////////////////////////////////////////////////////////////
59 // Utility class to display ALICE outline, tracks, hits,.. //
61 //////////////////////////////////////////////////////////////////////////
70 #include <TPolyMarker3D.h>
73 #include <TPolyMarker.h>
74 #include <TPaveLabel.h>
75 #include <TPaveText.h>
82 #include <TGeometry.h>
83 #include <TSliderBox.h>
85 #include <TVirtualX.h>
88 #include <X3DBuffer.h>
89 #include <TParticle.h>
93 #include "AliDetector.h"
95 #include "AliRICHConst.h"
96 #include "AliRICHDisplay.h"
97 #include "AliRICHPoints.h"
99 #include "AliRICHHit.h"
100 #include "AliRICHCerenkov.h"
101 #include "AliRICHSDigit.h"
102 #include "AliRICHDigit.h"
103 #include "AliRICHRawCluster.h"
104 #include "AliRICHRecHit1D.h"
105 #include "AliRICHRecHit3D.h"
106 #include "AliRICHEllipse.h"
108 ClassImp(AliRICHDisplay)
111 //____________________________________________________________________________
112 AliRICHDisplay::AliRICHDisplay()
115 // default constructor
125 //_____________________________________________________________________________
126 AliRICHDisplay::AliRICHDisplay(Int_t size)
128 // Create an event display object.
129 // A canvas named "edisplay" is created with a vertical size in pixels
131 // A QUICK Overview of the Event Display functions
132 // ===============================================
134 // The event display can ve invoked by executing the macro "display.C"
135 // A canvas like in the picture below will appear.
137 // On the left side of the canvas, the following buttons appear:
138 // *Next* to move to the next event
139 // *Previous* to move to the previous event
141 // *Pick* Select this option to be able to point on a track with the
142 // mouse. Once on the track, use the right button to select
143 // an action. For example, select SetMarkerAttributes to
144 // change the marker type/color/size for the track.
145 // *Zoom* Select this option (default) if you want to zoom.
146 // To zoom, simply select the selected area with the left button.
147 // *UnZoom* To revert to the previous picture size.
149 // slider R On the left side, the vertical slider can be used to
150 // set the default picture size.
152 // When you are in Zoom mode, you can click on the black part of the canvas
153 // to select special options with the right mouse button.
156 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
157 // When you are on a track, select the menu item "InspectParticle"
158 // to display the current particle attributes.
160 // You can activate the Root browser by selecting the Inspect menu
161 // in the canvas tool bar menu. Then select "Start Browser"
162 // This will open a new canvas with the browser. At this point, you may want
163 // to display some histograms (from the Trees). Go to the "File" menu
164 // of the browser and click on "New canvas".
165 // In the browser, click on item "ROOT files" in the left pane.
166 // Click on galice.root.
168 // Click on TPC for example
169 // Click on any variable (eg TPC.fX) to histogram the variable.
171 // If you are lost, you can click on HELP in any Root canvas or browser.
174 <img src="gif/AliRICHDisplay.gif">
181 gAlice->SetDisplay(this);
183 // Initialize display default parameters
186 // Set front view by default
193 fDrawClusters = kTRUE;
195 fDrawRecHits = kTRUE;
206 // Create display canvas
208 if (ysize < 100) ysize = 750;
209 Int_t xsize = Int_t(size*830./ysize);
210 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
211 fCanvas->ToggleEventStatus();
213 // Create main display pad
214 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
217 fPad->SetFillColor(1);
218 fPad->SetBorderSize(2);
223 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
226 fColPad->SetFillColor(19);
227 fColPad->SetBorderSize(2);
233 // Create user interface control pad
237 // Create Range and mode pad
240 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
241 fTrigPad->SetEditable(kFALSE);
244 fTrigPad->SetFillColor(22);
245 fTrigPad->SetBorderSize(2);
246 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
247 fRangeSlider->SetObject(this);
248 char pickmode[] = "gAlice->Display()->SetPickMode()";
250 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
251 fPickButton->SetFillColor(38);
253 char zoommode[] = "gAlice->Display()->SetZoomMode()";
254 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
255 fZoomButton->SetFillColor(38);
257 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
258 fArcButton->SetFillColor(kGreen);
260 char butUnzoom[] = "gAlice->Display()->UnZoom()";
261 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
262 button->SetFillColor(38);
264 AppendPad(); // append display object as last object to force selection
271 //_____________________________________________________________________________
272 AliRICHDisplay::~AliRICHDisplay()
274 // Delete space point structure
275 if (fPoints) fPoints->Delete();
279 if (fPhits) fPhits->Delete();
283 if (fRpoints) fRpoints->Delete();
287 if (fRecpoints) fRecpoints->Delete();
291 if (fPCerenkovs) fPCerenkovs->Delete();
296 //_____________________________________________________________________________
297 void AliRICHDisplay::Clear(Option_t *)
299 // Delete graphics temporary objects
302 //_____________________________________________________________________________
303 void AliRICHDisplay::DisplayButtons()
305 // Create the user interface buttons
308 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
309 fButtons->SetEditable(kFALSE);
311 fButtons->SetFillColor(38);
312 fButtons->SetBorderSize(2);
315 // Int_t butcolor = 33;
316 Float_t dbutton = 0.08;
323 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
324 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
325 button->SetFillColor(38);
329 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
330 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
331 button->SetFillColor(38);
335 char but7[] = "gAlice->Display()->DrawViewGL()";
336 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
337 button->SetFillColor(38);
341 char but8[] = "gAlice->Display()->DrawViewX3D()";
342 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
343 button->SetFillColor(38);
347 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
348 diamond->SetFillColor(50);
349 diamond->SetTextAlign(22);
350 diamond->SetTextColor(5);
351 diamond->SetTextSize(0.11);
353 diamond->AddText(".. ");
354 diamond->AddText("ROOT");
355 diamond->AddText("RICH");
356 diamond->AddText("... ");
357 diamond->AddText(" ");
360 //_____________________________________________________________________________
361 void AliRICHDisplay::CreateColors()
363 // Create the colors palette used to display clusters
378 new TColor(color,r,g,b);
388 new TColor(color,r,g,b);
398 new TColor(color,r,g,b);
408 new TColor(color,r,g,b);
418 new TColor(color,r,g,b);
425 //_____________________________________________________________________________
426 void AliRICHDisplay::DisplayColorScale()
429 // Draw the color scale in the RICH display canvas
433 Float_t xlow, ylow, xup, yup, hs;
434 Float_t x1, y1, x2, y2;
438 gPad->SetFillColor(0);
440 gPad->Range(x1,y1,x2,y2);
441 TText *text = new TText(0,0,"");
442 text->SetTextFont(61);
443 text->SetTextSize(0.03);
444 text->SetTextAlign(22);
448 //*-* draw colortable boxes
449 hs = (y2-y1)/Float_t(22);
453 ylow = y1 + hs*(Float_t(i));
454 yup = y1 + hs*(Float_t(i+1));
456 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
457 Int_t scale=(Int_t)TMath::Exp(logscale);
458 sprintf(label,"%d",scale);
459 box = new TBox(xlow, ylow, xup, yup);
460 box->SetFillColor(color);
462 text->DrawText(xup+4, 0.5*(ylow+yup),label);
466 //______________________________________________________________________________
467 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
469 // Compute distance from point px,py to objects in event
471 gPad->SetCursor(kCross);
473 if (gPad == fTrigPad) return 9999;
475 const Int_t kBig = 9999;
477 Float_t xmin = gPad->GetX1();
478 Float_t xmax = gPad->GetX2();
479 Float_t dx = 0.02*(xmax - xmin);
480 Float_t x = gPad->AbsPixeltoX(px);
481 if (x < xmin+dx || x > xmax-dx) return dist;
482 if (fZoomMode) return 0;
486 //_____________________________________________________________________________
487 void AliRICHDisplay::Draw(Option_t *)
489 // Display current event
493 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
495 // Display the event number and title
500 //_____________________________________________________________________________
501 void AliRICHDisplay::DrawCoG()
503 // Draw hits for RICH chambers
505 if (!fDrawCoG) return;
507 for (Int_t chamber=0;chamber<kNCH;chamber++) {
516 ncog = points->GetEntriesFast();
517 for (icog=0; icog < ncog; icog++) {
518 pm = (AliRICHPoints*)points->UncheckedAt(icog);
524 void AliRICHDisplay::DrawRecHits()
526 // Draw rec hits for RICH chambers
528 if (!fDrawRecHits) return;
530 for (Int_t chamber=0;chamber<kNCH;chamber++) {
531 LoadRecHits(chamber,1);
539 nrec = points->GetEntriesFast();
540 //printf("Nrec %d\n",nrec);
541 for (irec=0; irec < nrec; irec++) {
542 pm = (AliRICHPoints*)points->UncheckedAt(irec);
548 //_____________________________________________________________________________
550 void AliRICHDisplay::DrawCerenkovs()
552 // Draw cerenkovs hits for RICH chambers
554 LoadCerenkovs(fChamber);
555 //printf("\nDrawCerenkovs\n");
557 Int_t ntracks, track;
562 cpoints = fPCerenkovs;
563 //printf ("Cpoints: %p",cpoints);
564 if (!cpoints) return;
565 ntracks = cpoints->GetEntriesFast();
566 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
567 for (track=0;track<ntracks;track++) {
568 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
571 fHitsCuts += pm->GetN();
575 //_____________________________________________________________________________
577 void AliRICHDisplay::DrawClusters()
579 // Draw clusterss for RICH chambers
581 Int_t ndigits, digit;
588 ndigits = points->GetEntriesFast();
589 for (digit=0;digit<ndigits;digit++){
590 pm = (AliRICHPoints*)points->UncheckedAt(digit);
595 for (Int_t im=0;im<3;im++) {
596 TMarker3DBox *marker=pm->GetMarker(im);
600 fClustersCuts +=pm->GetN();
604 //_____________________________________________________________________________
605 void AliRICHDisplay::DrawHits()
607 // Draw hits for RICH chambers
611 Int_t ntracks, track;
618 // ntracks = points->GetEntriesFast();
619 ntracks = fPhits->GetEntriesFast();
621 //printf("DrawHits - ntracks %d \n",ntracks);
622 for (track=0;track<ntracks;track++) {
623 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
626 fHitsCuts += pm->GetN();
631 //_____________________________________________________________________________
632 void AliRICHDisplay::DrawTitle(Option_t *option)
634 // Draw the event title
636 Float_t xmin = gPad->GetX1();
637 Float_t xmax = gPad->GetX2();
638 Float_t ymin = gPad->GetY1();
639 Float_t ymax = gPad->GetY2();
640 Float_t dx = xmax-xmin;
641 Float_t dy = ymax-ymin;
643 if (strlen(option) == 0) {
644 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
645 title->SetBit(kCanDelete);
646 title->SetFillColor(42);
649 sprintf(ptitle,"Alice event: %d, Run:%d",
650 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
651 title->AddText(ptitle);
652 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
653 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
654 nparticles, fHitsCuts,fClustersCuts);
655 title->AddText(ptitle);
658 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
659 label->SetBit(kCanDelete);
660 label->SetFillColor(42);
665 //_____________________________________________________________________________
666 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
668 // Draw a view of RICH clusters
670 gPad->SetCursor(kWatch);
671 gPad->SetFillColor(1);
675 TView *view = new TView(1);
676 Float_t range = fRrange*fRangeSlider->GetMaximum();
677 view->SetRange(-range,-range,-range,range, range, range);
684 //Display RICH Chamber Geometry
685 gAlice->GetGeometry()->Draw("same");
687 //add clusters to the pad
693 //printf("Calling DrawCoG\n");
695 //printf("Calling DrawRecHits\n");
698 /*for (Int_t i=0;i<7;i++)
701 // add itself to the list (must be last)
704 view->SetView(phi, theta, psi, iret);
707 //______________________________________________________________________________
708 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
710 // Execute action corresponding to the mouse event
712 static Float_t x0, y0, x1, y1;
714 static Int_t pxold, pyold;
715 static Int_t px0, py0;
716 static Int_t linedrawn;
719 if (px == 0 && py == 0) { //when called by sliders
720 if (event == kButton1Up) {
721 printf("Drawing event %d\n",event);
726 if (!fZoomMode && gPad->GetView()) {
727 gPad->GetView()->ExecuteRotateView(event, px, py);
731 // something to zoom ?
732 gPad->SetCursor(kCross);
737 gVirtualX->SetLineColor(-1);
738 gPad->TAttLine::Modify(); //Change line attributes only if necessary
739 x0 = gPad->AbsPixeltoX(px);
740 y0 = gPad->AbsPixeltoY(py);
742 pxold = px; pyold = py;
747 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
751 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
755 gPad->GetCanvas()->FeedbackMode(kFALSE);
756 if (px == px0) return;
757 if (py == py0) return;
758 x1 = gPad->AbsPixeltoX(px);
759 y1 = gPad->AbsPixeltoY(py);
761 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
762 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
763 gPad->Range(x0,y0,x1,y1);
764 if (fZooms < kMAXZOOM-1) {
766 fZoomX0[fZooms] = x0;
767 fZoomY0[fZooms] = y0;
768 fZoomX1[fZooms] = x1;
769 fZoomY1[fZooms] = y1;
771 gPad->Modified(kTRUE);
776 //___________________________________________
777 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
779 // Read raw clusters info and store x,y,z info in arrays fRpoints
780 // Loop on all detectors
782 if (chamber > 6) return;
784 //printf("Entering LoadCoG\n");
787 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
788 AliRICHChamber* iChamber;
790 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
791 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
792 if (pRICHrawclust == 0) return;
794 pRICH->ResetRawClusters();
797 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
798 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
799 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
800 //printf ("nrawcl:%d\n",nrawcl);
801 if (nrawcl == 0) return;
802 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
804 iChamber = &(pRICH->Chamber(chamber));
805 AliRICHRawCluster *mRaw;
806 AliRICHPoints *points = 0;
808 //loop over all raw clusters and store their position
809 points = new AliRICHPoints(nrawcl);
810 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
811 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
812 fRpoints->AddAt(points,iraw);
813 points->SetMarkerColor(3);
814 points->SetMarkerStyle(3);
815 points->SetMarkerSize(1.);
816 points->SetParticle(-1);
817 points->SetHitIndex(-1);
818 points->SetTrackIndex(-1);
819 points->SetDigitIndex(-1);
820 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
821 Float_t vectorGlob[3];
822 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
823 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
826 //___________________________________________
827 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
829 // Read rec. hits info
830 // Loop on all detectors
832 if (chamber > 6) return;
834 ///printf("Entering LoadRecHits\n");
837 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
838 AliRICHChamber* iChamber;
840 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
841 //printf ("Chamber:%d\n", chamber);
842 if (pRICHrechits1D != 0)
845 //RICH->ResetRecHits();
848 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
849 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
850 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
851 //printf ("nrechits1D:%d\n",nrechits1D);
854 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
856 iChamber = &(pRICH->Chamber(chamber));
857 AliRICHRecHit1D *mRec1D;
858 AliRICHPoints *points1D = 0;
859 //AliRICHEllipse *ellipse = 0;
861 //loop over all rechits and store their position
863 points1D = new AliRICHPoints(nrechits1D);
864 for (Int_t irec=0;irec<nrechits1D;irec++) {
865 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
866 fRecpoints->AddAt(points1D,irec);
867 points1D->SetMarkerColor(38);
868 points1D->SetMarkerStyle(8);
869 points1D->SetMarkerSize(1.);
870 points1D->SetParticle(-1);
871 points1D->SetHitIndex(-1);
872 points1D->SetTrackIndex(-1);
873 points1D->SetDigitIndex(-1);
874 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
875 Float_t vectorGlob[3];
876 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
877 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
878 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
879 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
880 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
881 //printf("Generating ellipse %d\n",irec);
882 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
883 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());
884 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
885 ellipse->CerenkovRingDrawing(chamber,irec);
886 //ellipse->SetFillStyle(1001);
887 ellipse->SetMarkerColor(38);
889 //marker->SetRefObject((TObject*)points1D);
890 //points1D->Set3DMarker(0, marker);
895 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
896 //printf ("Chamber:%d\n", chamber);
897 if (pRICHrechits3D != 0)
900 //RICH->ResetRecHits();
903 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
904 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
905 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
906 //printf ("nrechits3D:%d\n",nrechits3D);
909 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
911 iChamber = &(pRICH->Chamber(chamber));
912 AliRICHRecHit3D *mRec3D;
913 AliRICHPoints *points3D = 0;
914 //AliRICHEllipse *ellipse = 0;
916 //loop over all rechits and store their position
918 points3D = new AliRICHPoints(nrechits3D);
919 for (Int_t irec=0;irec<nrechits3D;irec++) {
920 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
921 fRecpoints->AddAt(points3D,irec);
922 points3D->SetMarkerColor(42);
923 points3D->SetMarkerStyle(8);
924 points3D->SetMarkerSize(1.);
925 points3D->SetParticle(-1);
926 points3D->SetHitIndex(-1);
927 points3D->SetTrackIndex(-1);
928 points3D->SetDigitIndex(-1);
929 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
930 Float_t vectorGlob[3];
931 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
932 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
933 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
934 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
935 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
936 //printf("Generating ellipse %d\n",irec);
937 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
938 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());
939 ellipse->CerenkovRingDrawing(chamber,irec);
940 //ellipse->SetFillStyle(1001);
941 ellipse->SetMarkerColor(42);
943 //marker->SetRefObject((TObject*)points3D);
944 //points3D->Set3DMarker(0, marker);
949 //___________________________________________
950 void AliRICHDisplay::LoadDigits()
952 // Read digits info and store x,y,z info in arrays fPoints
953 // Loop on all detectors
956 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
957 AliRICHChamber* iChamber;
958 AliSegmentation* segmentation;
962 //printf("Entering LoadDigits\n");
967 for (ich=0; ich<kNCH; ich++) {
968 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
969 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
970 if (pRICHdigits == 0) continue;
971 gAlice->ResetDigits();
972 gAlice->TreeD()->GetEvent(0);
973 Int_t ndigits = pRICHdigits->GetEntriesFast();
974 //printf("ndigits:%d\n",ndigits);
978 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
980 for (ich=0; ich<kNCH; ich++) {
981 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
982 if (pRICHdigits == 0) continue;
983 gAlice->ResetDigits();
984 gAlice->TreeD()->GetEvent(0);
985 Int_t ndigits = pRICHdigits->GetEntriesFast();
986 if (ndigits == 0) continue;
987 iChamber = &(pRICH->Chamber(ich));
988 segmentation=iChamber->GetSegmentationModel();
989 Float_t dpx = segmentation->Dpx();
990 Float_t dpy = segmentation->Dpy();
992 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
995 AliRICHPoints *points = 0;
996 TMarker3DBox *marker = 0;
998 //loop over all digits and store their position
1001 for (Int_t digit=0;digit<ndigits;digit++) {
1002 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1003 points = new AliRICHPoints(npoints);
1004 fPoints->AddAt(points,counter);
1006 Int_t charge=mdig->fSignal;
1007 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1008 Int_t color=701+index;
1009 if (color>722) color=722;
1010 points->SetMarkerColor(color);
1011 points->SetMarkerStyle(21);
1012 points->SetMarkerSize(0.5);
1013 Float_t xpad, ypad, zpad;
1014 segmentation->GetPadC(mdig->fPadX, mdig->fPadY,xpad, ypad, zpad);
1015 Float_t vectorLoc[3]={xpad,5,ypad};
1016 Float_t vectorGlob[3];
1017 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1018 points->SetParticle(-1);
1019 points->SetHitIndex(-1);
1020 points->SetTrackIndex(-1);
1021 points->SetDigitIndex(digit);
1022 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1023 //printf("Y position (digit): %f\n", vectorGlob[1]);
1025 segmentation->GetPadC(mdig->fPadX, mdig->fPadY, xpad, ypad, zpad);
1026 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1027 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1028 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1029 dpy/2,0,dpx/2,theta,phi);
1030 marker->SetLineColor(2);
1031 marker->SetFillStyle(1001);
1032 marker->SetFillColor(color);
1033 marker->SetRefObject((TObject*)points);
1034 points->Set3DMarker(0, marker);
1035 } // loop over digits
1036 } // loop over chambers
1041 //___________________________________________
1042 void AliRICHDisplay::LoadHits(Int_t chamber)
1044 // Read hits info and store x,y,z info in arrays fPhits
1045 // Loop on all detectors
1051 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1052 AliRICHChamber* iChamber;
1054 iChamber = &(pRICH->Chamber(chamber-1));
1055 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1058 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1059 //TVector *xp = new TVector(1000);
1060 //TVector *yp = new TVector(1000);
1061 //TVector *zp = new TVector(1000);
1062 //TVector *ptrk = new TVector(1000);
1063 //TVector *phit = new TVector(1000);
1065 for (track=0; track<ntracks;track++) {
1066 gAlice->ResetHits();
1067 gAlice->TreeH()->GetEvent(track);
1068 TClonesArray *pRICHhits = pRICH->Hits();
1069 if (pRICHhits == 0) return;
1070 Int_t nhits = pRICHhits->GetEntriesFast();
1074 fPhits = new TObjArray(nAllHits);
1077 for (track=0; track<ntracks;track++) {
1078 gAlice->ResetHits();
1079 gAlice->TreeH()->GetEvent(track);
1080 TClonesArray *pRICHhits = pRICH->Hits();
1081 if (pRICHhits == 0) return;
1082 Int_t nhits = pRICHhits->GetEntriesFast();
1083 if (nhits == 0) continue;
1085 AliRICHPoints *points = 0;
1086 for (Int_t hit=0;hit<nhits;hit++) {
1087 points = new AliRICHPoints(1);
1088 fPhits->AddAt(points,npoints);
1089 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1090 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1091 if (current->GetPdgCode() == 50000050) {
1092 points->SetMarkerColor(kBlue);
1093 } else if (current->GetPdgCode() == 50000051) {
1094 points->SetMarkerColor(kYellow);
1096 points->SetMarkerColor(kRed);
1098 points->SetMarkerStyle(5);
1099 points->SetMarkerSize(1.);
1100 points->SetParticle(mHit->Track());
1101 points->SetHitIndex(hit);
1102 points->SetTrackIndex(track);
1103 points->SetDigitIndex(-1);
1104 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1105 //printf("Y position: %f\n", mHit->Y());
1111 //_____________________________________________________________________________
1113 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1115 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1116 // Loop on all detectors
1121 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1122 AliRICHChamber* iChamber;
1124 iChamber = &(pRICH->Chamber(chamber-1));
1126 pRICH->SetTreeAddress();
1127 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1129 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1130 TVector *xp = new TVector(1000);
1131 TVector *yp = new TVector(1000);
1132 TVector *zp = new TVector(1000);
1133 TVector *ptrk = new TVector(1000);
1134 TVector *phit = new TVector(1000);
1135 for (Int_t track=0; track<ntracks;track++) {
1136 gAlice->ResetHits();
1137 gAlice->TreeH()->GetEvent(track);
1138 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1139 if (pRICHCerenkovs == 0) return;
1140 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1141 if (nhits == 0) continue;
1142 AliRICHCerenkov *mCerenkov;
1143 AliRICHPoints *cpoints = 0;
1147 //Display Cerenkov hits in blue
1149 for (Int_t hit=0;hit<nhits;hit++) {
1150 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1151 (*xp)(npoints)=mCerenkov->X();
1152 (*yp)(npoints)=mCerenkov->Y();
1153 (*zp)(npoints)=mCerenkov->Z();
1154 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1155 (*phit)(npoints)=Float_t(hit);
1158 if (npoints == 0) continue;
1159 cpoints = new AliRICHPoints(npoints);
1160 for (Int_t p=0;p<npoints;p++) {
1161 cpoints->SetMarkerColor(kBlue);
1162 cpoints->SetMarkerStyle(5);
1163 cpoints->SetMarkerSize(1.);
1164 cpoints->SetParticle(Int_t((*ptrk)(p)));
1165 cpoints->SetHitIndex(Int_t((*phit)(p)));
1166 cpoints->SetTrackIndex(track);
1167 cpoints->SetDigitIndex(-1);
1168 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1174 fPCerenkovs->AddAt(cpoints,track);
1178 //_____________________________________________________________________________
1179 void AliRICHDisplay::Paint(Option_t *)
1181 // Paint miscellaneous items
1185 //_____________________________________________________________________________
1186 void AliRICHDisplay::SetPickMode()
1193 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1194 fTrigPad->Modified();
1197 //_____________________________________________________________________________
1198 void AliRICHDisplay::SetZoomMode()
1205 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1206 fTrigPad->Modified();
1209 //_____________________________________________________________________________
1210 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1212 // Set chamber and cathode number
1216 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1223 //_____________________________________________________________________________
1224 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1226 // Set view range along R and Z
1235 //_____________________________________________________________________________
1236 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1238 // change viewing angles for current event
1246 TView *view = gPad->GetView();
1247 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1253 //_____________________________________________________________________________
1254 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1256 // Display (current event_number+delta)
1257 // delta = 1 shown next event
1258 // delta = -1 show previous event
1262 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1263 Int_t newEvent = currentEvent + delta;
1264 gAlice->GetEvent(newEvent);
1265 if (!gAlice->TreeD()) return;
1275 //______________________________________________________________________________
1276 void AliRICHDisplay::UnZoom()
1279 // Return to previous zoom factor
1281 if (fZooms <= 0) return;
1283 TPad *pad = (TPad*)gPad->GetPadSave();
1284 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1288 //_____________________________________________________________________________
1289 void AliRICHDisplay::ResetPoints()
1292 // Reset array of points
1300 //_____________________________________________________________________________
1301 void AliRICHDisplay::ResetRpoints()
1304 // Reset array of points
1312 //_____________________________________________________________________________
1313 void AliRICHDisplay::ResetRecpoints()
1316 // Reset array of points
1319 fRecpoints->Delete();
1324 //_____________________________________________________________________________
1325 void AliRICHDisplay::ResetPhits()
1328 // Reset array of points
1336 //_____________________________________________________________________________
1337 void AliRICHDisplay::ResetPCerenkovs()
1340 // Reset array of points
1343 fPCerenkovs->Delete();
1349 //_____________________________________________________________________________
1351 void AliRICHDisplay::DrawViewGL()
1353 // Draw current view using OPENGL
1355 TPad *pad = (TPad*)gPad->GetPadSave();
1357 TView *view = pad->GetView();
1362 //_____________________________________________________________________________
1363 void AliRICHDisplay::DrawViewX3D()
1365 // Draw current view using X3D
1367 TPad *pad = (TPad*)gPad->GetPadSave();
1369 TView *view = pad->GetView();