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.17 2001/10/23 13:03:35 hristov
19 The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
21 Revision 1.16 2001/10/21 18:31:24 hristov
22 Several pointers were set to zero in the default constructors to avoid memory management problems
24 Revision 1.15 2001/10/09 07:34:09 hristov
25 Modifications needed by Root.03.01.06 (J.Chudoba)
27 Revision 1.14 2001/05/16 14:57:20 alibrary
28 New files for folders and Stack
30 Revision 1.13 2001/05/10 12:35:16 jbarbosa
31 Removed hit display, added rec. ring properties.
33 Revision 1.12 2001/03/14 18:15:03 jbarbosa
34 Changes to adapt to new IO.
35 Removed verbose output.
37 Revision 1.11 2001/02/27 15:21:34 jbarbosa
38 Transition to SDigits.
40 Revision 1.10 2001/02/13 20:18:48 jbarbosa
41 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
43 Revision 1.9 2000/11/01 15:33:11 jbarbosa
44 Updated to handle both reconstruction algorithms.
46 Revision 1.8 2000/10/03 21:44:09 morsch
47 Use AliSegmentation and AliHit abstract base classes.
49 Revision 1.7 2000/10/02 21:28:12 fca
50 Removal of useless dependecies via forward declarations
52 Revision 1.6 2000/10/02 15:46:38 jbarbosa
53 Fixed forward declarations.
55 Revision 1.5 2000/06/30 16:49:34 dibari
56 Different call for ring drawing.
58 Revision 1.4 2000/06/12 15:21:08 jbarbosa
61 Revision 1.3 2000/06/09 14:52:08 jbarbosa
62 New tentative ellipse drawing routine
64 Revision 1.1 2000/04/19 13:07:45 morsch
65 Digits, clusters and reconstruction results added.
70 //////////////////////////////////////////////////////////////////////////
74 // Utility class to display ALICE outline, tracks, hits,.. //
76 //////////////////////////////////////////////////////////////////////////
85 #include <TPolyMarker3D.h>
88 #include <TPolyMarker.h>
89 #include <TPaveLabel.h>
90 #include <TPaveText.h>
97 #include <TGeometry.h>
98 #include <TSliderBox.h>
100 #include <TVirtualX.h>
103 #include <X3DBuffer.h>
104 #include <TParticle.h>
108 #include "AliDetector.h"
110 #include "AliRICHConst.h"
111 #include "AliRICHDisplay.h"
112 #include "AliRICHPoints.h"
113 #include "AliHeader.h"
115 #include "AliRICHHit.h"
116 #include "AliRICHCerenkov.h"
117 #include "AliRICHSDigit.h"
118 #include "AliRICHDigit.h"
119 #include "AliRICHRawCluster.h"
120 #include "AliRICHRecHit1D.h"
121 #include "AliRICHRecHit3D.h"
122 #include "AliRICHEllipse.h"
124 ClassImp(AliRICHDisplay)
127 //____________________________________________________________________________
128 AliRICHDisplay::AliRICHDisplay()
131 // default constructor
141 //_____________________________________________________________________________
142 AliRICHDisplay::AliRICHDisplay(Int_t size)
144 // Create an event display object.
145 // A canvas named "edisplay" is created with a vertical size in pixels
147 // A QUICK Overview of the Event Display functions
148 // ===============================================
150 // The event display can ve invoked by executing the macro "display.C"
151 // A canvas like in the picture below will appear.
153 // On the left side of the canvas, the following buttons appear:
154 // *Next* to move to the next event
155 // *Previous* to move to the previous event
157 // *Pick* Select this option to be able to point on a track with the
158 // mouse. Once on the track, use the right button to select
159 // an action. For example, select SetMarkerAttributes to
160 // change the marker type/color/size for the track.
161 // *Zoom* Select this option (default) if you want to zoom.
162 // To zoom, simply select the selected area with the left button.
163 // *UnZoom* To revert to the previous picture size.
165 // slider R On the left side, the vertical slider can be used to
166 // set the default picture size.
168 // When you are in Zoom mode, you can click on the black part of the canvas
169 // to select special options with the right mouse button.
172 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
173 // When you are on a track, select the menu item "InspectParticle"
174 // to display the current particle attributes.
176 // You can activate the Root browser by selecting the Inspect menu
177 // in the canvas tool bar menu. Then select "Start Browser"
178 // This will open a new canvas with the browser. At this point, you may want
179 // to display some histograms (from the Trees). Go to the "File" menu
180 // of the browser and click on "New canvas".
181 // In the browser, click on item "ROOT files" in the left pane.
182 // Click on galice.root.
184 // Click on TPC for example
185 // Click on any variable (eg TPC.fX) to histogram the variable.
187 // If you are lost, you can click on HELP in any Root canvas or browser.
190 <img src="gif/AliRICHDisplay.gif">
197 gAlice->SetDisplay(this);
199 // Initialize display default parameters
202 // Set front view by default
203 //fTheta = 90; //inclined HMPID
204 //fPhi = 30; //inclined HMPID
205 fTheta = 90; //normal HMPID
206 fPhi = 90; //normal HMPID
211 fDrawClusters = kTRUE;
213 fDrawRecHits = kTRUE;
224 // Create display canvas
226 if (ysize < 100) ysize = 750;
227 Int_t xsize = Int_t(size*830./ysize);
228 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
229 fCanvas->ToggleEventStatus();
231 // Create main display pad
232 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
235 fPad->SetFillColor(1);
236 fPad->SetBorderSize(2);
241 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
244 fColPad->SetFillColor(19);
245 fColPad->SetBorderSize(2);
251 // Create user interface control pad
255 // Create Range and mode pad
258 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
261 fTrigPad->SetFillColor(22);
262 fTrigPad->SetBorderSize(2);
263 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
264 fRangeSlider->SetObject(this);
265 char pickmode[] = "gAlice->Display()->SetPickMode()";
267 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
268 fPickButton->SetFillColor(38);
270 char zoommode[] = "gAlice->Display()->SetZoomMode()";
271 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
272 fZoomButton->SetFillColor(38);
274 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
275 fArcButton->SetFillColor(kGreen);
277 char butUnzoom[] = "gAlice->Display()->UnZoom()";
278 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
279 button->SetFillColor(38);
281 AppendPad(); // append display object as last object to force selection
283 fTrigPad->SetEditable(kFALSE);
284 fButtons->SetEditable(kFALSE);
290 //_____________________________________________________________________________
291 AliRICHDisplay::~AliRICHDisplay()
293 // Delete space point structure
294 if (fPoints) fPoints->Delete();
298 if (fPhits) fPhits->Delete();
302 if (fRpoints) fRpoints->Delete();
306 if (fRecpoints) fRecpoints->Delete();
310 if (fPCerenkovs) fPCerenkovs->Delete();
315 //_____________________________________________________________________________
316 void AliRICHDisplay::Clear(Option_t *)
318 // Delete graphics temporary objects
321 //_____________________________________________________________________________
322 void AliRICHDisplay::DisplayButtons()
324 // Create the user interface buttons
327 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
329 fButtons->SetFillColor(38);
330 fButtons->SetBorderSize(2);
333 // Int_t butcolor = 33;
334 Float_t dbutton = 0.08;
341 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
342 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
343 button->SetFillColor(38);
347 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
348 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
349 button->SetFillColor(38);
353 char but7[] = "gAlice->Display()->DrawViewGL()";
354 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
355 button->SetFillColor(38);
359 char but8[] = "gAlice->Display()->DrawViewX3D()";
360 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
361 button->SetFillColor(38);
365 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
366 diamond->SetFillColor(50);
367 diamond->SetTextAlign(22);
368 diamond->SetTextColor(5);
369 diamond->SetTextSize(0.11);
371 diamond->AddText(".. ");
372 diamond->AddText("ROOT");
373 diamond->AddText("RICH");
374 diamond->AddText("... ");
375 diamond->AddText(" ");
378 //_____________________________________________________________________________
379 void AliRICHDisplay::CreateColors()
381 // Create the colors palette used to display clusters
396 new TColor(color,r,g,b);
406 new TColor(color,r,g,b);
416 new TColor(color,r,g,b);
426 new TColor(color,r,g,b);
436 new TColor(color,r,g,b);
443 //_____________________________________________________________________________
444 void AliRICHDisplay::DisplayColorScale()
447 // Draw the color scale in the RICH display canvas
451 Float_t xlow, ylow, xup, yup, hs;
452 Float_t x1, y1, x2, y2;
456 gPad->SetFillColor(0);
458 gPad->Range(x1,y1,x2,y2);
459 TText *text = new TText(0,0,"");
460 text->SetTextFont(61);
461 text->SetTextSize(0.2);
462 text->SetTextAlign(22);
466 //*-* draw colortable boxes
467 hs = (y2-y1)/Float_t(22);
471 ylow = y1 + hs*(Float_t(i));
472 yup = y1 + hs*(Float_t(i+1));
474 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
475 Int_t scale=(Int_t)TMath::Exp(logscale);
476 sprintf(label,"%d",scale);
477 box = new TBox(xlow, ylow, xup, yup);
478 box->SetFillColor(color);
480 text->DrawText(xup+4, 0.5*(ylow+yup),label);
484 //______________________________________________________________________________
485 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
487 // Compute distance from point px,py to objects in event
489 gPad->SetCursor(kCross);
491 if (gPad == fTrigPad) return 9999;
493 const Int_t kBig = 9999;
495 Float_t xmin = gPad->GetX1();
496 Float_t xmax = gPad->GetX2();
497 Float_t dx = 0.02*(xmax - xmin);
498 Float_t x = gPad->AbsPixeltoX(px);
499 if (x < xmin+dx || x > xmax-dx) return dist;
500 if (fZoomMode) return 0;
504 //_____________________________________________________________________________
505 void AliRICHDisplay::Draw(Option_t *)
507 // Display current event
511 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
513 // Display the event number and title
518 //_____________________________________________________________________________
519 void AliRICHDisplay::DrawCoG()
521 // Draw hits for RICH chambers
523 if (!fDrawCoG) return;
525 for (Int_t chamber=0;chamber<kNCH;chamber++) {
534 ncog = points->GetEntriesFast();
535 for (icog=0; icog < ncog; icog++) {
536 pm = (AliRICHPoints*)points->UncheckedAt(icog);
542 void AliRICHDisplay::DrawRecHits()
544 // Draw rec hits for RICH chambers
546 if (!fDrawRecHits) return;
548 for (Int_t chamber=0;chamber<kNCH;chamber++) {
549 LoadRecHits(chamber,1);
557 nrec = points->GetEntriesFast();
558 //printf("Nrec %d\n",nrec);
559 for (irec=0; irec < nrec; irec++) {
560 pm = (AliRICHPoints*)points->UncheckedAt(irec);
566 //_____________________________________________________________________________
568 void AliRICHDisplay::DrawCerenkovs()
570 // Draw cerenkovs hits for RICH chambers
572 LoadCerenkovs(fChamber);
573 //printf("\nDrawCerenkovs\n");
575 Int_t ntracks, track;
580 cpoints = fPCerenkovs;
581 //printf ("Cpoints: %p",cpoints);
582 if (!cpoints) return;
583 ntracks = cpoints->GetEntriesFast();
584 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
585 for (track=0;track<ntracks;track++) {
586 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
589 fHitsCuts += pm->GetN();
593 //_____________________________________________________________________________
595 void AliRICHDisplay::DrawClusters()
597 // Draw clusterss for RICH chambers
599 Int_t ndigits, digit;
606 ndigits = points->GetEntriesFast();
607 for (digit=0;digit<ndigits;digit++){
608 pm = (AliRICHPoints*)points->UncheckedAt(digit);
613 for (Int_t im=0;im<3;im++) {
614 TMarker3DBox *marker=pm->GetMarker(im);
618 fClustersCuts +=pm->GetN();
622 //_____________________________________________________________________________
623 void AliRICHDisplay::DrawHits()
625 // Draw hits for RICH chambers
629 Int_t ntracks, track;
636 // ntracks = points->GetEntriesFast();
637 ntracks = fPhits->GetEntriesFast();
639 //printf("DrawHits - ntracks %d \n",ntracks);
640 for (track=0;track<ntracks;track++) {
641 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
644 fHitsCuts += pm->GetN();
649 //_____________________________________________________________________________
650 void AliRICHDisplay::DrawTitle(Option_t *option)
652 // Draw the event title
654 Float_t xmin = gPad->GetX1();
655 Float_t xmax = gPad->GetX2();
656 Float_t ymin = gPad->GetY1();
657 Float_t ymax = gPad->GetY2();
658 Float_t dx = xmax-xmin;
659 Float_t dy = ymax-ymin;
661 if (strlen(option) == 0) {
662 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
663 title->SetBit(kCanDelete);
664 title->SetFillColor(42);
667 sprintf(ptitle,"Alice event: %d, Run:%d",
668 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
669 title->AddText(ptitle);
670 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
671 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
672 nparticles, fHitsCuts,fClustersCuts);
673 title->AddText(ptitle);
676 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
677 label->SetBit(kCanDelete);
678 label->SetFillColor(42);
683 //_____________________________________________________________________________
684 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
686 // Draw a view of RICH clusters
688 gPad->SetCursor(kWatch);
689 gPad->SetFillColor(1);
693 TView *view = new TView(1);
694 Float_t range = fRrange*fRangeSlider->GetMaximum();
695 view->SetRange(-range,-range,-range,range, range, range);
702 //Display RICH Chamber Geometry
703 gAlice->GetGeometry()->Draw("same");
705 //add clusters to the pad
711 //printf("Calling DrawCoG\n");
713 //printf("Calling DrawRecHits\n");
716 /*for (Int_t i=0;i<7;i++)
719 // add itself to the list (must be last)
722 view->SetView(phi, theta, psi, iret);
725 //______________________________________________________________________________
726 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
728 // Execute action corresponding to the mouse event
730 static Float_t x0, y0, x1, y1;
732 static Int_t pxold, pyold;
733 static Int_t px0, py0;
734 static Int_t linedrawn;
737 if (px == 0 && py == 0) { //when called by sliders
738 if (event == kButton1Up) {
739 printf("Drawing event %d\n",event);
744 if (!fZoomMode && gPad->GetView()) {
745 gPad->GetView()->ExecuteRotateView(event, px, py);
749 // something to zoom ?
750 gPad->SetCursor(kCross);
755 gVirtualX->SetLineColor(-1);
756 gPad->TAttLine::Modify(); //Change line attributes only if necessary
757 x0 = gPad->AbsPixeltoX(px);
758 y0 = gPad->AbsPixeltoY(py);
760 pxold = px; pyold = py;
765 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
769 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
773 gPad->GetCanvas()->FeedbackMode(kFALSE);
774 if (px == px0) return;
775 if (py == py0) return;
776 x1 = gPad->AbsPixeltoX(px);
777 y1 = gPad->AbsPixeltoY(py);
779 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
780 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
781 gPad->Range(x0,y0,x1,y1);
782 if (fZooms < kMAXZOOM-1) {
784 fZoomX0[fZooms] = x0;
785 fZoomY0[fZooms] = y0;
786 fZoomX1[fZooms] = x1;
787 fZoomY1[fZooms] = y1;
789 gPad->Modified(kTRUE);
794 //___________________________________________
795 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
797 // Read raw clusters info and store x,y,z info in arrays fRpoints
798 // Loop on all detectors
800 if (chamber > 6) return;
802 //printf("Entering LoadCoG\n");
805 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
806 AliRICHChamber* iChamber;
808 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
809 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
810 if (pRICHrawclust == 0) return;
812 pRICH->ResetRawClusters();
815 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
816 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
817 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
818 //printf ("nrawcl:%d\n",nrawcl);
819 if (nrawcl == 0) return;
820 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
822 iChamber = &(pRICH->Chamber(chamber));
823 AliRICHRawCluster *mRaw;
824 AliRICHPoints *points = 0;
826 //loop over all raw clusters and store their position
827 points = new AliRICHPoints(nrawcl);
828 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
829 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
830 fRpoints->AddAt(points,iraw);
831 points->SetMarkerColor(3);
832 points->SetMarkerStyle(3);
833 points->SetMarkerSize(1.);
834 points->SetParticle(-1);
835 points->SetHitIndex(-1);
836 points->SetTrackIndex(-1);
837 points->SetDigitIndex(-1);
838 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
839 Float_t vectorGlob[3];
840 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
841 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
844 //___________________________________________
845 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
847 // Read rec. hits info
848 // Loop on all detectors
850 if (chamber > 6) return;
852 ///printf("Entering LoadRecHits\n");
855 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
856 AliRICHChamber* iChamber;
858 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
859 //printf ("Chamber:%d\n", chamber);
860 if (pRICHrechits1D != 0)
863 //RICH->ResetRecHits();
866 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
867 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
868 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
869 //printf ("nrechits1D:%d\n",nrechits1D);
872 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
874 iChamber = &(pRICH->Chamber(chamber));
875 AliRICHRecHit1D *mRec1D;
876 AliRICHPoints *points1D = 0;
877 //AliRICHEllipse *ellipse = 0;
879 //loop over all rechits and store their position
881 points1D = new AliRICHPoints(nrechits1D);
882 for (Int_t irec=0;irec<nrechits1D;irec++) {
883 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
884 fRecpoints->AddAt(points1D,irec);
885 points1D->SetMarkerColor(38);
886 points1D->SetMarkerStyle(8);
887 points1D->SetMarkerSize(.5);
888 points1D->SetParticle(-1);
889 points1D->SetHitIndex(-1);
890 points1D->SetTrackIndex(-1);
891 points1D->SetDigitIndex(-1);
892 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
893 Float_t vectorGlob[3];
894 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
895 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
896 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
897 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
898 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
899 //printf("Generating ellipse %d\n",irec);
900 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
901 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());
902 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
903 ellipse->CerenkovRingDrawing(chamber,irec);
904 //ellipse->SetFillStyle(1001);
905 ellipse->SetMarkerColor(38);
907 //marker->SetRefObject((TObject*)points1D);
908 //points1D->Set3DMarker(0, marker);
913 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
914 //printf ("Chamber:%d\n", chamber);
915 if (pRICHrechits3D != 0)
918 //RICH->ResetRecHits();
921 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
922 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
923 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
924 //printf ("nrechits3D:%d\n",nrechits3D);
927 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
929 iChamber = &(pRICH->Chamber(chamber));
930 AliRICHRecHit3D *mRec3D;
931 AliRICHPoints *points3D = 0;
932 //AliRICHEllipse *ellipse = 0;
934 //loop over all rechits and store their position
936 points3D = new AliRICHPoints(nrechits3D);
937 for (Int_t irec=0;irec<nrechits3D;irec++) {
938 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
939 fRecpoints->AddAt(points3D,irec);
940 points3D->SetMarkerColor(42);
941 points3D->SetMarkerStyle(8);
942 points3D->SetMarkerSize(1.);
943 points3D->SetParticle(-1);
944 points3D->SetHitIndex(-1);
945 points3D->SetTrackIndex(-1);
946 points3D->SetDigitIndex(-1);
947 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
948 Float_t vectorGlob[3];
949 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
950 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
951 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
952 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
953 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
954 //printf("Generating ellipse %d\n",irec);
955 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
956 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());
957 //ellipse->CerenkovRingDrawing(chamber,irec);
958 //ellipse->SetFillStyle(1001);
959 ellipse->CreatePoints(chamber);
960 ellipse->SetMarkerStyle(7);
961 ellipse->SetMarkerColor(42);
962 ellipse->SetMarkerSize(1);
964 //marker->SetRefObject((TObject*)points3D);
965 //points3D->Set3DMarker(0, marker);
970 //___________________________________________
971 void AliRICHDisplay::LoadDigits()
973 // Read digits info and store x,y,z info in arrays fPoints
974 // Loop on all detectors
977 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
978 AliRICHChamber* iChamber;
979 AliSegmentation* segmentation;
983 //printf("Entering LoadDigits\n");
988 for (ich=0; ich<kNCH; ich++) {
989 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
990 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
991 if (pRICHdigits == 0) continue;
992 gAlice->ResetDigits();
993 gAlice->TreeD()->GetEvent(0);
994 Int_t ndigits = pRICHdigits->GetEntriesFast();
995 //printf("ndigits:%d\n",ndigits);
999 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
1001 for (ich=0; ich<kNCH; ich++) {
1002 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
1003 if (pRICHdigits == 0) continue;
1004 gAlice->ResetDigits();
1005 gAlice->TreeD()->GetEvent(0);
1006 Int_t ndigits = pRICHdigits->GetEntriesFast();
1007 if (ndigits == 0) continue;
1008 iChamber = &(pRICH->Chamber(ich));
1009 segmentation=iChamber->GetSegmentationModel();
1010 Float_t dpx = segmentation->Dpx();
1011 Float_t dpy = segmentation->Dpy();
1013 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1016 AliRICHPoints *points = 0;
1017 TMarker3DBox *marker = 0;
1019 //loop over all digits and store their position
1022 for (Int_t digit=0;digit<ndigits;digit++) {
1023 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1024 points = new AliRICHPoints(npoints);
1025 fPoints->AddAt(points,counter);
1027 Int_t charge=mdig->Signal();
1028 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1029 Int_t color=701+index;
1030 if (color>722) color=722;
1031 points->SetMarkerColor(color);
1032 points->SetMarkerStyle(21);
1033 points->SetMarkerSize(0.5);
1034 Float_t xpad, ypad, zpad;
1035 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
1036 Float_t vectorLoc[3]={xpad,5,ypad};
1037 Float_t vectorGlob[3];
1038 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1039 points->SetParticle(-1);
1040 points->SetHitIndex(-1);
1041 points->SetTrackIndex(-1);
1042 points->SetDigitIndex(digit);
1043 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1044 //printf("Y position (digit): %f\n", vectorGlob[1]);
1046 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1047 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1048 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1049 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1050 dpy/2,0,dpx/2,theta,phi);
1051 marker->SetLineColor(2);
1052 marker->SetFillStyle(1001);
1053 marker->SetFillColor(color);
1054 marker->SetRefObject((TObject*)points);
1055 points->Set3DMarker(0, marker);
1056 } // loop over digits
1057 } // loop over chambers
1062 //___________________________________________
1063 void AliRICHDisplay::LoadHits(Int_t chamber)
1065 // Read hits info and store x,y,z info in arrays fPhits
1066 // Loop on all detectors
1072 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1073 AliRICHChamber* iChamber;
1075 iChamber = &(pRICH->Chamber(chamber-1));
1076 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1079 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1080 //TVector *xp = new TVector(1000);
1081 //TVector *yp = new TVector(1000);
1082 //TVector *zp = new TVector(1000);
1083 //TVector *ptrk = new TVector(1000);
1084 //TVector *phit = new TVector(1000);
1086 for (track=0; track<ntracks;track++) {
1087 gAlice->ResetHits();
1088 gAlice->TreeH()->GetEvent(track);
1089 TClonesArray *pRICHhits = pRICH->Hits();
1090 if (pRICHhits == 0) return;
1091 Int_t nhits = pRICHhits->GetEntriesFast();
1095 fPhits = new TObjArray(nAllHits);
1098 for (track=0; track<ntracks;track++) {
1099 gAlice->ResetHits();
1100 gAlice->TreeH()->GetEvent(track);
1101 TClonesArray *pRICHhits = pRICH->Hits();
1102 if (pRICHhits == 0) return;
1103 Int_t nhits = pRICHhits->GetEntriesFast();
1104 if (nhits == 0) continue;
1106 AliRICHPoints *points = 0;
1107 for (Int_t hit=0;hit<nhits;hit++) {
1108 points = new AliRICHPoints(1);
1109 fPhits->AddAt(points,npoints);
1110 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1111 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1112 if (current->GetPdgCode() == 50000050) {
1113 points->SetMarkerColor(kBlue);
1114 } else if (current->GetPdgCode() == 50000051) {
1115 points->SetMarkerColor(kYellow);
1117 points->SetMarkerColor(kRed);
1119 points->SetMarkerStyle(5);
1120 points->SetMarkerSize(1.);
1121 points->SetParticle(mHit->Track());
1122 points->SetHitIndex(hit);
1123 points->SetTrackIndex(track);
1124 points->SetDigitIndex(-1);
1125 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1126 //printf("Y position: %f\n", mHit->Y());
1132 //_____________________________________________________________________________
1134 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1136 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1137 // Loop on all detectors
1142 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1143 AliRICHChamber* iChamber;
1145 iChamber = &(pRICH->Chamber(chamber-1));
1147 pRICH->SetTreeAddress();
1148 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1150 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1151 TVector *xp = new TVector(1000);
1152 TVector *yp = new TVector(1000);
1153 TVector *zp = new TVector(1000);
1154 TVector *ptrk = new TVector(1000);
1155 TVector *phit = new TVector(1000);
1156 for (Int_t track=0; track<ntracks;track++) {
1157 gAlice->ResetHits();
1158 gAlice->TreeH()->GetEvent(track);
1159 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1160 if (pRICHCerenkovs == 0) return;
1161 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1162 if (nhits == 0) continue;
1163 AliRICHCerenkov *mCerenkov;
1164 AliRICHPoints *cpoints = 0;
1168 //Display Cerenkov hits in blue
1170 for (Int_t hit=0;hit<nhits;hit++) {
1171 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1172 (*xp)(npoints)=mCerenkov->X();
1173 (*yp)(npoints)=mCerenkov->Y();
1174 (*zp)(npoints)=mCerenkov->Z();
1175 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1176 (*phit)(npoints)=Float_t(hit);
1179 if (npoints == 0) continue;
1180 cpoints = new AliRICHPoints(npoints);
1181 for (Int_t p=0;p<npoints;p++) {
1182 cpoints->SetMarkerColor(kBlue);
1183 cpoints->SetMarkerStyle(5);
1184 cpoints->SetMarkerSize(1.);
1185 cpoints->SetParticle(Int_t((*ptrk)(p)));
1186 cpoints->SetHitIndex(Int_t((*phit)(p)));
1187 cpoints->SetTrackIndex(track);
1188 cpoints->SetDigitIndex(-1);
1189 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1195 fPCerenkovs->AddAt(cpoints,track);
1199 //_____________________________________________________________________________
1200 void AliRICHDisplay::Paint(Option_t *)
1202 // Paint miscellaneous items
1206 //_____________________________________________________________________________
1207 void AliRICHDisplay::SetPickMode()
1214 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1215 fTrigPad->Modified();
1218 //_____________________________________________________________________________
1219 void AliRICHDisplay::SetZoomMode()
1226 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1227 fTrigPad->Modified();
1230 //_____________________________________________________________________________
1231 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1233 // Set chamber and cathode number
1237 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1244 //_____________________________________________________________________________
1245 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1247 // Set view range along R and Z
1256 //_____________________________________________________________________________
1257 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1259 // change viewing angles for current event
1267 TView *view = gPad->GetView();
1268 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1274 //_____________________________________________________________________________
1275 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1277 // Display (current event_number+delta)
1278 // delta = 1 shown next event
1279 // delta = -1 show previous event
1283 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1284 Int_t newEvent = currentEvent + delta;
1285 gAlice->GetEvent(newEvent);
1286 if (!gAlice->TreeD()) return;
1296 //______________________________________________________________________________
1297 void AliRICHDisplay::UnZoom()
1300 // Return to previous zoom factor
1302 if (fZooms <= 0) return;
1304 TPad *pad = (TPad*)gPad->GetPadSave();
1305 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1309 //_____________________________________________________________________________
1310 void AliRICHDisplay::ResetPoints()
1313 // Reset array of points
1321 //_____________________________________________________________________________
1322 void AliRICHDisplay::ResetRpoints()
1325 // Reset array of points
1333 //_____________________________________________________________________________
1334 void AliRICHDisplay::ResetRecpoints()
1337 // Reset array of points
1340 fRecpoints->Delete();
1345 //_____________________________________________________________________________
1346 void AliRICHDisplay::ResetPhits()
1349 // Reset array of points
1357 //_____________________________________________________________________________
1358 void AliRICHDisplay::ResetPCerenkovs()
1361 // Reset array of points
1364 fPCerenkovs->Delete();
1370 //_____________________________________________________________________________
1372 void AliRICHDisplay::DrawViewGL()
1374 // Draw current view using OPENGL
1376 TPad *pad = (TPad*)gPad->GetPadSave();
1378 TView *view = pad->GetView();
1383 //_____________________________________________________________________________
1384 void AliRICHDisplay::DrawViewX3D()
1386 // Draw current view using X3D
1388 TPad *pad = (TPad*)gPad->GetPadSave();
1390 TView *view = pad->GetView();