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.18 2002/10/29 14:24:19 morsch
19 Minor corrections on the display (adc counts readable, ...).
22 Revision 1.17 2001/10/23 13:03:35 hristov
23 The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
25 Revision 1.16 2001/10/21 18:31:24 hristov
26 Several pointers were set to zero in the default constructors to avoid memory management problems
28 Revision 1.15 2001/10/09 07:34:09 hristov
29 Modifications needed by Root.03.01.06 (J.Chudoba)
31 Revision 1.14 2001/05/16 14:57:20 alibrary
32 New files for folders and Stack
34 Revision 1.13 2001/05/10 12:35:16 jbarbosa
35 Removed hit display, added rec. ring properties.
37 Revision 1.12 2001/03/14 18:15:03 jbarbosa
38 Changes to adapt to new IO.
39 Removed verbose output.
41 Revision 1.11 2001/02/27 15:21:34 jbarbosa
42 Transition to SDigits.
44 Revision 1.10 2001/02/13 20:18:48 jbarbosa
45 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
47 Revision 1.9 2000/11/01 15:33:11 jbarbosa
48 Updated to handle both reconstruction algorithms.
50 Revision 1.8 2000/10/03 21:44:09 morsch
51 Use AliSegmentation and AliHit abstract base classes.
53 Revision 1.7 2000/10/02 21:28:12 fca
54 Removal of useless dependecies via forward declarations
56 Revision 1.6 2000/10/02 15:46:38 jbarbosa
57 Fixed forward declarations.
59 Revision 1.5 2000/06/30 16:49:34 dibari
60 Different call for ring drawing.
62 Revision 1.4 2000/06/12 15:21:08 jbarbosa
65 Revision 1.3 2000/06/09 14:52:08 jbarbosa
66 New tentative ellipse drawing routine
68 Revision 1.1 2000/04/19 13:07:45 morsch
69 Digits, clusters and reconstruction results added.
74 //////////////////////////////////////////////////////////////////////////
78 // Utility class to display ALICE outline, tracks, hits,.. //
80 //////////////////////////////////////////////////////////////////////////
89 #include <TPolyMarker3D.h>
92 #include <TPolyMarker.h>
93 #include <TPaveLabel.h>
94 #include <TPaveText.h>
101 #include <TGeometry.h>
102 #include <TSliderBox.h>
104 #include <TVirtualX.h>
107 #include <X3DBuffer.h>
108 #include <TParticle.h>
112 #include "AliDetector.h"
114 #include "AliRICHConst.h"
115 #include "AliRICHDisplay.h"
116 #include "AliRICHPoints.h"
117 #include "AliHeader.h"
119 #include "AliRICHHit.h"
120 #include "AliRICHCerenkov.h"
121 #include "AliRICHSDigit.h"
122 #include "AliRICHDigit.h"
123 #include "AliRICHRawCluster.h"
124 #include "AliRICHRecHit1D.h"
125 #include "AliRICHRecHit3D.h"
126 #include "AliRICHEllipse.h"
128 ClassImp(AliRICHDisplay)
131 //____________________________________________________________________________
132 AliRICHDisplay::AliRICHDisplay()
135 // default constructor
145 //_____________________________________________________________________________
146 AliRICHDisplay::AliRICHDisplay(Int_t size)
148 // Create an event display object.
149 // A canvas named "edisplay" is created with a vertical size in pixels
151 // A QUICK Overview of the Event Display functions
152 // ===============================================
154 // The event display can ve invoked by executing the macro "display.C"
155 // A canvas like in the picture below will appear.
157 // On the left side of the canvas, the following buttons appear:
158 // *Next* to move to the next event
159 // *Previous* to move to the previous event
161 // *Pick* Select this option to be able to point on a track with the
162 // mouse. Once on the track, use the right button to select
163 // an action. For example, select SetMarkerAttributes to
164 // change the marker type/color/size for the track.
165 // *Zoom* Select this option (default) if you want to zoom.
166 // To zoom, simply select the selected area with the left button.
167 // *UnZoom* To revert to the previous picture size.
169 // slider R On the left side, the vertical slider can be used to
170 // set the default picture size.
172 // When you are in Zoom mode, you can click on the black part of the canvas
173 // to select special options with the right mouse button.
176 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
177 // When you are on a track, select the menu item "InspectParticle"
178 // to display the current particle attributes.
180 // You can activate the Root browser by selecting the Inspect menu
181 // in the canvas tool bar menu. Then select "Start Browser"
182 // This will open a new canvas with the browser. At this point, you may want
183 // to display some histograms (from the Trees). Go to the "File" menu
184 // of the browser and click on "New canvas".
185 // In the browser, click on item "ROOT files" in the left pane.
186 // Click on galice.root.
188 // Click on TPC for example
189 // Click on any variable (eg TPC.fX) to histogram the variable.
191 // If you are lost, you can click on HELP in any Root canvas or browser.
194 <img src="gif/AliRICHDisplay.gif">
201 gAlice->SetDisplay(this);
203 // Initialize display default parameters
206 // Set front view by default
207 fTheta = 90; //inclined HMPID
208 fPhi = 30; //inclined HMPID
209 //fTheta = 90; //normal HMPID
210 //fPhi = 90; //normal HMPID
215 fDrawClusters = kTRUE;
217 fDrawRecHits = kTRUE;
228 // Create display canvas
230 if (ysize < 100) ysize = 750;
231 Int_t xsize = Int_t(size*830./ysize);
232 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
233 fCanvas->ToggleEventStatus();
235 // Create main display pad
236 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
239 fPad->SetFillColor(1);
240 fPad->SetBorderSize(2);
245 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
248 fColPad->SetFillColor(19);
249 fColPad->SetBorderSize(2);
255 // Create user interface control pad
259 // Create Range and mode pad
262 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
265 fTrigPad->SetFillColor(22);
266 fTrigPad->SetBorderSize(2);
267 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
268 fRangeSlider->SetObject(this);
269 char pickmode[] = "gAlice->Display()->SetPickMode()";
271 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
272 fPickButton->SetFillColor(38);
274 char zoommode[] = "gAlice->Display()->SetZoomMode()";
275 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
276 fZoomButton->SetFillColor(38);
278 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
279 fArcButton->SetFillColor(kGreen);
281 char butUnzoom[] = "gAlice->Display()->UnZoom()";
282 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
283 button->SetFillColor(38);
285 AppendPad(); // append display object as last object to force selection
287 fTrigPad->SetEditable(kFALSE);
288 fButtons->SetEditable(kFALSE);
294 //_____________________________________________________________________________
295 AliRICHDisplay::~AliRICHDisplay()
297 // Delete space point structure
298 if (fPoints) fPoints->Delete();
302 if (fPhits) fPhits->Delete();
306 if (fRpoints) fRpoints->Delete();
310 if (fRecpoints) fRecpoints->Delete();
314 if (fPCerenkovs) fPCerenkovs->Delete();
319 //_____________________________________________________________________________
320 void AliRICHDisplay::Clear(Option_t *)
322 // Delete graphics temporary objects
325 //_____________________________________________________________________________
326 void AliRICHDisplay::DisplayButtons()
328 // Create the user interface buttons
331 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
333 fButtons->SetFillColor(38);
334 fButtons->SetBorderSize(2);
337 // Int_t butcolor = 33;
338 Float_t dbutton = 0.08;
345 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
346 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
347 button->SetFillColor(38);
351 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
352 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
353 button->SetFillColor(38);
357 char but7[] = "gAlice->Display()->DrawViewGL()";
358 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
359 button->SetFillColor(38);
363 char but8[] = "gAlice->Display()->DrawViewX3D()";
364 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
365 button->SetFillColor(38);
369 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
370 diamond->SetFillColor(50);
371 diamond->SetTextAlign(22);
372 diamond->SetTextColor(5);
373 diamond->SetTextSize(0.11);
375 diamond->AddText(".. ");
376 diamond->AddText("ROOT");
377 diamond->AddText("RICH");
378 diamond->AddText("... ");
379 diamond->AddText(" ");
382 //_____________________________________________________________________________
383 void AliRICHDisplay::CreateColors()
385 // Create the colors palette used to display clusters
400 new TColor(color,r,g,b);
410 new TColor(color,r,g,b);
420 new TColor(color,r,g,b);
430 new TColor(color,r,g,b);
440 new TColor(color,r,g,b);
447 //_____________________________________________________________________________
448 void AliRICHDisplay::DisplayColorScale()
451 // Draw the color scale in the RICH display canvas
455 Float_t xlow, ylow, xup, yup, hs;
456 Float_t x1, y1, x2, y2;
460 gPad->SetFillColor(0);
462 gPad->Range(x1,y1,x2,y2);
463 TText *text = new TText(0,0,"");
464 text->SetTextFont(61);
465 text->SetTextSize(0.2);
466 text->SetTextAlign(22);
470 //*-* draw colortable boxes
471 hs = (y2-y1)/Float_t(22);
475 ylow = y1 + hs*(Float_t(i));
476 yup = y1 + hs*(Float_t(i+1));
478 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
479 Int_t scale=(Int_t)TMath::Exp(logscale);
480 sprintf(label,"%d",scale);
481 box = new TBox(xlow, ylow, xup, yup);
482 box->SetFillColor(color);
484 text->DrawText(xup+4, 0.5*(ylow+yup),label);
488 //______________________________________________________________________________
489 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
491 // Compute distance from point px,py to objects in event
493 gPad->SetCursor(kCross);
495 if (gPad == fTrigPad) return 9999;
497 const Int_t kBig = 9999;
499 Float_t xmin = gPad->GetX1();
500 Float_t xmax = gPad->GetX2();
501 Float_t dx = 0.02*(xmax - xmin);
502 Float_t x = gPad->AbsPixeltoX(px);
503 if (x < xmin+dx || x > xmax-dx) return dist;
504 if (fZoomMode) return 0;
508 //_____________________________________________________________________________
509 void AliRICHDisplay::Draw(Option_t *)
511 // Display current event
515 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
517 // Display the event number and title
522 //_____________________________________________________________________________
523 void AliRICHDisplay::DrawCoG()
525 // Draw hits for RICH chambers
527 if (!fDrawCoG) return;
529 for (Int_t chamber=0;chamber<kNCH;chamber++) {
538 ncog = points->GetEntriesFast();
539 for (icog=0; icog < ncog; icog++) {
540 pm = (AliRICHPoints*)points->UncheckedAt(icog);
546 void AliRICHDisplay::DrawRecHits()
548 // Draw rec hits for RICH chambers
550 if (!fDrawRecHits) return;
552 for (Int_t chamber=0;chamber<kNCH;chamber++) {
553 LoadRecHits(chamber,1);
561 nrec = points->GetEntriesFast();
562 //printf("Nrec %d\n",nrec);
563 for (irec=0; irec < nrec; irec++) {
564 pm = (AliRICHPoints*)points->UncheckedAt(irec);
570 //_____________________________________________________________________________
572 void AliRICHDisplay::DrawCerenkovs()
574 // Draw cerenkovs hits for RICH chambers
576 LoadCerenkovs(fChamber);
577 //printf("\nDrawCerenkovs\n");
579 Int_t ntracks, track;
584 cpoints = fPCerenkovs;
585 //printf ("Cpoints: %p",cpoints);
586 if (!cpoints) return;
587 ntracks = cpoints->GetEntriesFast();
588 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
589 for (track=0;track<ntracks;track++) {
590 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
593 fHitsCuts += pm->GetN();
597 //_____________________________________________________________________________
599 void AliRICHDisplay::DrawClusters()
601 // Draw clusterss for RICH chambers
603 Int_t ndigits, digit;
610 ndigits = points->GetEntriesFast();
611 for (digit=0;digit<ndigits;digit++){
612 pm = (AliRICHPoints*)points->UncheckedAt(digit);
617 for (Int_t im=0;im<3;im++) {
618 TMarker3DBox *marker=pm->GetMarker(im);
622 fClustersCuts +=pm->GetN();
626 //_____________________________________________________________________________
627 void AliRICHDisplay::DrawHits()
629 // Draw hits for RICH chambers
633 Int_t ntracks, track;
640 // ntracks = points->GetEntriesFast();
641 ntracks = fPhits->GetEntriesFast();
643 //printf("DrawHits - ntracks %d \n",ntracks);
644 for (track=0;track<ntracks;track++) {
645 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
648 fHitsCuts += pm->GetN();
653 //_____________________________________________________________________________
654 void AliRICHDisplay::DrawTitle(Option_t *option)
656 // Draw the event title
658 Float_t xmin = gPad->GetX1();
659 Float_t xmax = gPad->GetX2();
660 Float_t ymin = gPad->GetY1();
661 Float_t ymax = gPad->GetY2();
662 Float_t dx = xmax-xmin;
663 Float_t dy = ymax-ymin;
665 if (strlen(option) == 0) {
666 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
667 title->SetBit(kCanDelete);
668 title->SetFillColor(42);
671 sprintf(ptitle,"Alice event: %d, Run:%d",
672 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
673 title->AddText(ptitle);
674 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
675 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
676 nparticles, fHitsCuts,fClustersCuts);
677 title->AddText(ptitle);
680 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
681 label->SetBit(kCanDelete);
682 label->SetFillColor(42);
687 //_____________________________________________________________________________
688 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
690 // Draw a view of RICH clusters
692 gPad->SetCursor(kWatch);
693 gPad->SetFillColor(1);
697 TView *view = new TView(1);
698 Float_t range = fRrange*fRangeSlider->GetMaximum();
699 view->SetRange(-range,-range,-range,range, range, range);
706 //Display RICH Chamber Geometry
707 gAlice->GetGeometry()->Draw("same");
709 //add clusters to the pad
715 //printf("Calling DrawCoG\n");
717 //printf("Calling DrawRecHits\n");
720 /*for (Int_t i=0;i<7;i++)
723 // add itself to the list (must be last)
726 view->SetView(phi, theta, psi, iret);
729 //______________________________________________________________________________
730 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
732 // Execute action corresponding to the mouse event
734 static Float_t x0, y0, x1, y1;
736 static Int_t pxold, pyold;
737 static Int_t px0, py0;
738 static Int_t linedrawn;
741 if (px == 0 && py == 0) { //when called by sliders
742 if (event == kButton1Up) {
743 printf("Drawing event %d\n",event);
748 if (!fZoomMode && gPad->GetView()) {
749 gPad->GetView()->ExecuteRotateView(event, px, py);
753 // something to zoom ?
754 gPad->SetCursor(kCross);
759 gVirtualX->SetLineColor(-1);
760 gPad->TAttLine::Modify(); //Change line attributes only if necessary
761 x0 = gPad->AbsPixeltoX(px);
762 y0 = gPad->AbsPixeltoY(py);
764 pxold = px; pyold = py;
769 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
773 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
777 gPad->GetCanvas()->FeedbackMode(kFALSE);
778 if (px == px0) return;
779 if (py == py0) return;
780 x1 = gPad->AbsPixeltoX(px);
781 y1 = gPad->AbsPixeltoY(py);
783 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
784 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
785 gPad->Range(x0,y0,x1,y1);
786 if (fZooms < kMAXZOOM-1) {
788 fZoomX0[fZooms] = x0;
789 fZoomY0[fZooms] = y0;
790 fZoomX1[fZooms] = x1;
791 fZoomY1[fZooms] = y1;
793 gPad->Modified(kTRUE);
798 //___________________________________________
799 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
801 // Read raw clusters info and store x,y,z info in arrays fRpoints
802 // Loop on all detectors
804 if (chamber > 6) return;
806 //printf("Entering LoadCoG\n");
809 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
810 AliRICHChamber* iChamber;
812 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
813 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
814 if (pRICHrawclust == 0) return;
816 pRICH->ResetRawClusters();
819 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
820 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
821 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
822 //printf ("nrawcl:%d\n",nrawcl);
823 if (nrawcl == 0) return;
824 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
826 iChamber = &(pRICH->Chamber(chamber));
827 AliRICHRawCluster *mRaw;
828 AliRICHPoints *points = 0;
830 //loop over all raw clusters and store their position
831 points = new AliRICHPoints(nrawcl);
832 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
833 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
834 fRpoints->AddAt(points,iraw);
835 points->SetMarkerColor(3);
836 points->SetMarkerStyle(3);
837 points->SetMarkerSize(1.);
838 points->SetParticle(-1);
839 points->SetHitIndex(-1);
840 points->SetTrackIndex(-1);
841 points->SetDigitIndex(-1);
842 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
843 Float_t vectorGlob[3];
844 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
845 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
848 //___________________________________________
849 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
851 // Read rec. hits info
852 // Loop on all detectors
854 if (chamber > 6) return;
856 ///printf("Entering LoadRecHits\n");
859 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
860 AliRICHChamber* iChamber;
862 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
863 //printf ("Chamber:%d\n", chamber);
864 if (pRICHrechits1D != 0)
867 //RICH->ResetRecHits();
870 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
871 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
872 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
873 //printf ("nrechits1D:%d\n",nrechits1D);
876 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
878 iChamber = &(pRICH->Chamber(chamber));
879 AliRICHRecHit1D *mRec1D;
880 AliRICHPoints *points1D = 0;
881 //AliRICHEllipse *ellipse = 0;
883 //loop over all rechits and store their position
885 points1D = new AliRICHPoints(nrechits1D);
886 for (Int_t irec=0;irec<nrechits1D;irec++) {
887 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
888 fRecpoints->AddAt(points1D,irec);
889 points1D->SetMarkerColor(38);
890 points1D->SetMarkerStyle(8);
891 points1D->SetMarkerSize(.5);
892 points1D->SetParticle(-1);
893 points1D->SetHitIndex(-1);
894 points1D->SetTrackIndex(-1);
895 points1D->SetDigitIndex(-1);
896 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
897 Float_t vectorGlob[3];
898 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
899 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
900 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
901 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
902 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
903 //printf("Generating ellipse %d\n",irec);
904 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
905 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());
906 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
907 ellipse->CerenkovRingDrawing(chamber,irec);
908 //ellipse->SetFillStyle(1001);
909 ellipse->SetMarkerColor(38);
911 //marker->SetRefObject((TObject*)points1D);
912 //points1D->Set3DMarker(0, marker);
917 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
918 //printf ("Chamber:%d\n", chamber);
919 if (pRICHrechits3D != 0)
922 //RICH->ResetRecHits();
925 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
926 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
927 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
928 //printf ("nrechits3D:%d\n",nrechits3D);
931 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
933 iChamber = &(pRICH->Chamber(chamber));
934 AliRICHRecHit3D *mRec3D;
935 AliRICHPoints *points3D = 0;
936 //AliRICHEllipse *ellipse = 0;
938 //loop over all rechits and store their position
940 points3D = new AliRICHPoints(nrechits3D);
941 for (Int_t irec=0;irec<nrechits3D;irec++) {
942 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
943 fRecpoints->AddAt(points3D,irec);
944 points3D->SetMarkerColor(42);
945 points3D->SetMarkerStyle(8);
946 points3D->SetMarkerSize(1.);
947 points3D->SetParticle(-1);
948 points3D->SetHitIndex(-1);
949 points3D->SetTrackIndex(-1);
950 points3D->SetDigitIndex(-1);
951 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
952 Float_t vectorGlob[3];
953 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
954 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
955 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
956 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
957 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
958 //printf("Generating ellipse %d\n",irec);
959 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
960 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());
961 //ellipse->CerenkovRingDrawing(chamber,irec);
962 //ellipse->SetFillStyle(1001);
963 ellipse->CreatePoints(chamber);
964 ellipse->SetMarkerStyle(7);
965 ellipse->SetMarkerColor(42);
966 ellipse->SetMarkerSize(1);
968 //marker->SetRefObject((TObject*)points3D);
969 //points3D->Set3DMarker(0, marker);
974 //___________________________________________
975 void AliRICHDisplay::LoadDigits()
977 // Read digits info and store x,y,z info in arrays fPoints
978 // Loop on all detectors
981 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
982 AliRICHChamber* iChamber;
983 AliSegmentation* segmentation;
987 //printf("Entering LoadDigits\n");
992 for (ich=0; ich<kNCH; ich++) {
993 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
994 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
995 if (pRICHdigits == 0) continue;
996 gAlice->ResetDigits();
997 gAlice->TreeD()->GetEvent(0);
998 Int_t ndigits = pRICHdigits->GetEntriesFast();
999 //printf("ndigits:%d\n",ndigits);
1000 nAllDigits+=ndigits;
1003 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
1005 for (ich=0; ich<kNCH; ich++) {
1006 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
1007 if (pRICHdigits == 0) continue;
1008 gAlice->ResetDigits();
1009 gAlice->TreeD()->GetEvent(0);
1010 Int_t ndigits = pRICHdigits->GetEntriesFast();
1011 if (ndigits == 0) continue;
1012 iChamber = &(pRICH->Chamber(ich));
1013 segmentation=iChamber->GetSegmentationModel();
1014 Float_t dpx = segmentation->Dpx();
1015 Float_t dpy = segmentation->Dpy();
1017 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1020 AliRICHPoints *points = 0;
1021 TMarker3DBox *marker = 0;
1023 //loop over all digits and store their position
1026 for (Int_t digit=0;digit<ndigits;digit++) {
1027 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1028 points = new AliRICHPoints(npoints);
1029 fPoints->AddAt(points,counter);
1031 Int_t charge=mdig->Signal();
1032 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1033 Int_t color=701+index;
1034 if (color>722) color=722;
1035 points->SetMarkerColor(color);
1036 points->SetMarkerStyle(21);
1037 points->SetMarkerSize(0.5);
1038 Float_t xpad, ypad, zpad;
1039 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
1040 Float_t vectorLoc[3]={xpad,5,ypad};
1041 Float_t vectorGlob[3];
1042 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1043 points->SetParticle(-1);
1044 points->SetHitIndex(-1);
1045 points->SetTrackIndex(-1);
1046 points->SetDigitIndex(digit);
1047 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1048 //printf("Y position (digit): %f\n", vectorGlob[1]);
1050 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1051 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1052 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1053 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1054 dpy/2,0,dpx/2,theta,phi);
1055 marker->SetLineColor(2);
1056 marker->SetFillStyle(1001);
1057 marker->SetFillColor(color);
1058 marker->SetRefObject((TObject*)points);
1059 points->Set3DMarker(0, marker);
1060 } // loop over digits
1061 } // loop over chambers
1066 //___________________________________________
1067 void AliRICHDisplay::LoadHits(Int_t chamber)
1069 // Read hits info and store x,y,z info in arrays fPhits
1070 // Loop on all detectors
1076 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1077 AliRICHChamber* iChamber;
1079 iChamber = &(pRICH->Chamber(chamber-1));
1080 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1083 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1084 //TVector *xp = new TVector(1000);
1085 //TVector *yp = new TVector(1000);
1086 //TVector *zp = new TVector(1000);
1087 //TVector *ptrk = new TVector(1000);
1088 //TVector *phit = new TVector(1000);
1090 for (track=0; track<ntracks;track++) {
1091 gAlice->ResetHits();
1092 gAlice->TreeH()->GetEvent(track);
1093 TClonesArray *pRICHhits = pRICH->Hits();
1094 if (pRICHhits == 0) return;
1095 Int_t nhits = pRICHhits->GetEntriesFast();
1099 fPhits = new TObjArray(nAllHits);
1102 for (track=0; track<ntracks;track++) {
1103 gAlice->ResetHits();
1104 gAlice->TreeH()->GetEvent(track);
1105 TClonesArray *pRICHhits = pRICH->Hits();
1106 if (pRICHhits == 0) return;
1107 Int_t nhits = pRICHhits->GetEntriesFast();
1108 if (nhits == 0) continue;
1110 AliRICHPoints *points = 0;
1111 for (Int_t hit=0;hit<nhits;hit++) {
1112 points = new AliRICHPoints(1);
1113 fPhits->AddAt(points,npoints);
1114 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1115 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1116 if (current->GetPdgCode() == 50000050) {
1117 points->SetMarkerColor(kBlue);
1118 } else if (current->GetPdgCode() == 50000051) {
1119 points->SetMarkerColor(kYellow);
1121 points->SetMarkerColor(kRed);
1123 points->SetMarkerStyle(5);
1124 points->SetMarkerSize(1.);
1125 points->SetParticle(mHit->Track());
1126 points->SetHitIndex(hit);
1127 points->SetTrackIndex(track);
1128 points->SetDigitIndex(-1);
1129 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1130 //printf("Y position: %f\n", mHit->Y());
1136 //_____________________________________________________________________________
1138 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1140 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1141 // Loop on all detectors
1146 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1147 AliRICHChamber* iChamber;
1149 iChamber = &(pRICH->Chamber(chamber-1));
1151 pRICH->SetTreeAddress();
1152 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1154 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1155 TVector *xp = new TVector(1000);
1156 TVector *yp = new TVector(1000);
1157 TVector *zp = new TVector(1000);
1158 TVector *ptrk = new TVector(1000);
1159 TVector *phit = new TVector(1000);
1160 for (Int_t track=0; track<ntracks;track++) {
1161 gAlice->ResetHits();
1162 gAlice->TreeH()->GetEvent(track);
1163 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1164 if (pRICHCerenkovs == 0) return;
1165 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1166 if (nhits == 0) continue;
1167 AliRICHCerenkov *mCerenkov;
1168 AliRICHPoints *cpoints = 0;
1172 //Display Cerenkov hits in blue
1174 for (Int_t hit=0;hit<nhits;hit++) {
1175 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1176 (*xp)(npoints)=mCerenkov->X();
1177 (*yp)(npoints)=mCerenkov->Y();
1178 (*zp)(npoints)=mCerenkov->Z();
1179 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1180 (*phit)(npoints)=Float_t(hit);
1183 if (npoints == 0) continue;
1184 cpoints = new AliRICHPoints(npoints);
1185 for (Int_t p=0;p<npoints;p++) {
1186 cpoints->SetMarkerColor(kBlue);
1187 cpoints->SetMarkerStyle(5);
1188 cpoints->SetMarkerSize(1.);
1189 cpoints->SetParticle(Int_t((*ptrk)(p)));
1190 cpoints->SetHitIndex(Int_t((*phit)(p)));
1191 cpoints->SetTrackIndex(track);
1192 cpoints->SetDigitIndex(-1);
1193 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1199 fPCerenkovs->AddAt(cpoints,track);
1203 //_____________________________________________________________________________
1204 void AliRICHDisplay::Paint(Option_t *)
1206 // Paint miscellaneous items
1210 //_____________________________________________________________________________
1211 void AliRICHDisplay::SetPickMode()
1218 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1219 fTrigPad->Modified();
1222 //_____________________________________________________________________________
1223 void AliRICHDisplay::SetZoomMode()
1230 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1231 fTrigPad->Modified();
1234 //_____________________________________________________________________________
1235 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1237 // Set chamber and cathode number
1241 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1248 //_____________________________________________________________________________
1249 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1251 // Set view range along R and Z
1260 //_____________________________________________________________________________
1261 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1263 // change viewing angles for current event
1271 TView *view = gPad->GetView();
1272 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1278 //_____________________________________________________________________________
1279 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1281 // Display (current event_number+delta)
1282 // delta = 1 shown next event
1283 // delta = -1 show previous event
1287 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1288 Int_t newEvent = currentEvent + delta;
1289 gAlice->GetEvent(newEvent);
1290 if (!gAlice->TreeD()) return;
1300 //______________________________________________________________________________
1301 void AliRICHDisplay::UnZoom()
1304 // Return to previous zoom factor
1306 if (fZooms <= 0) return;
1308 TPad *pad = (TPad*)gPad->GetPadSave();
1309 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1313 //_____________________________________________________________________________
1314 void AliRICHDisplay::ResetPoints()
1317 // Reset array of points
1325 //_____________________________________________________________________________
1326 void AliRICHDisplay::ResetRpoints()
1329 // Reset array of points
1337 //_____________________________________________________________________________
1338 void AliRICHDisplay::ResetRecpoints()
1341 // Reset array of points
1344 fRecpoints->Delete();
1349 //_____________________________________________________________________________
1350 void AliRICHDisplay::ResetPhits()
1353 // Reset array of points
1361 //_____________________________________________________________________________
1362 void AliRICHDisplay::ResetPCerenkovs()
1365 // Reset array of points
1368 fPCerenkovs->Delete();
1374 //_____________________________________________________________________________
1376 void AliRICHDisplay::DrawViewGL()
1378 // Draw current view using OPENGL
1380 TPad *pad = (TPad*)gPad->GetPadSave();
1382 TView *view = pad->GetView();
1387 //_____________________________________________________________________________
1388 void AliRICHDisplay::DrawViewX3D()
1390 // Draw current view using X3D
1392 TPad *pad = (TPad*)gPad->GetPadSave();
1394 TView *view = pad->GetView();