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.15 2001/10/09 07:34:09 hristov
19 Modifications needed by Root.03.01.06 (J.Chudoba)
21 Revision 1.14 2001/05/16 14:57:20 alibrary
22 New files for folders and Stack
24 Revision 1.13 2001/05/10 12:35:16 jbarbosa
25 Removed hit display, added rec. ring properties.
27 Revision 1.12 2001/03/14 18:15:03 jbarbosa
28 Changes to adapt to new IO.
29 Removed verbose output.
31 Revision 1.11 2001/02/27 15:21:34 jbarbosa
32 Transition to SDigits.
34 Revision 1.10 2001/02/13 20:18:48 jbarbosa
35 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
37 Revision 1.9 2000/11/01 15:33:11 jbarbosa
38 Updated to handle both reconstruction algorithms.
40 Revision 1.8 2000/10/03 21:44:09 morsch
41 Use AliSegmentation and AliHit abstract base classes.
43 Revision 1.7 2000/10/02 21:28:12 fca
44 Removal of useless dependecies via forward declarations
46 Revision 1.6 2000/10/02 15:46:38 jbarbosa
47 Fixed forward declarations.
49 Revision 1.5 2000/06/30 16:49:34 dibari
50 Different call for ring drawing.
52 Revision 1.4 2000/06/12 15:21:08 jbarbosa
55 Revision 1.3 2000/06/09 14:52:08 jbarbosa
56 New tentative ellipse drawing routine
58 Revision 1.1 2000/04/19 13:07:45 morsch
59 Digits, clusters and reconstruction results added.
64 //////////////////////////////////////////////////////////////////////////
68 // Utility class to display ALICE outline, tracks, hits,.. //
70 //////////////////////////////////////////////////////////////////////////
79 #include <TPolyMarker3D.h>
82 #include <TPolyMarker.h>
83 #include <TPaveLabel.h>
84 #include <TPaveText.h>
91 #include <TGeometry.h>
92 #include <TSliderBox.h>
94 #include <TVirtualX.h>
97 #include <X3DBuffer.h>
98 #include <TParticle.h>
102 #include "AliDetector.h"
104 #include "AliRICHConst.h"
105 #include "AliRICHDisplay.h"
106 #include "AliRICHPoints.h"
107 #include "AliHeader.h"
109 #include "AliRICHHit.h"
110 #include "AliRICHCerenkov.h"
111 #include "AliRICHSDigit.h"
112 #include "AliRICHDigit.h"
113 #include "AliRICHRawCluster.h"
114 #include "AliRICHRecHit1D.h"
115 #include "AliRICHRecHit3D.h"
116 #include "AliRICHEllipse.h"
118 ClassImp(AliRICHDisplay)
121 //____________________________________________________________________________
122 AliRICHDisplay::AliRICHDisplay()
125 // default constructor
135 //_____________________________________________________________________________
136 AliRICHDisplay::AliRICHDisplay(Int_t size)
138 // Create an event display object.
139 // A canvas named "edisplay" is created with a vertical size in pixels
141 // A QUICK Overview of the Event Display functions
142 // ===============================================
144 // The event display can ve invoked by executing the macro "display.C"
145 // A canvas like in the picture below will appear.
147 // On the left side of the canvas, the following buttons appear:
148 // *Next* to move to the next event
149 // *Previous* to move to the previous event
151 // *Pick* Select this option to be able to point on a track with the
152 // mouse. Once on the track, use the right button to select
153 // an action. For example, select SetMarkerAttributes to
154 // change the marker type/color/size for the track.
155 // *Zoom* Select this option (default) if you want to zoom.
156 // To zoom, simply select the selected area with the left button.
157 // *UnZoom* To revert to the previous picture size.
159 // slider R On the left side, the vertical slider can be used to
160 // set the default picture size.
162 // When you are in Zoom mode, you can click on the black part of the canvas
163 // to select special options with the right mouse button.
166 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
167 // When you are on a track, select the menu item "InspectParticle"
168 // to display the current particle attributes.
170 // You can activate the Root browser by selecting the Inspect menu
171 // in the canvas tool bar menu. Then select "Start Browser"
172 // This will open a new canvas with the browser. At this point, you may want
173 // to display some histograms (from the Trees). Go to the "File" menu
174 // of the browser and click on "New canvas".
175 // In the browser, click on item "ROOT files" in the left pane.
176 // Click on galice.root.
178 // Click on TPC for example
179 // Click on any variable (eg TPC.fX) to histogram the variable.
181 // If you are lost, you can click on HELP in any Root canvas or browser.
184 <img src="gif/AliRICHDisplay.gif">
191 gAlice->SetDisplay(this);
193 // Initialize display default parameters
196 // Set front view by default
203 fDrawClusters = kTRUE;
205 fDrawRecHits = kTRUE;
216 // Create display canvas
218 if (ysize < 100) ysize = 750;
219 Int_t xsize = Int_t(size*830./ysize);
220 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
221 fCanvas->ToggleEventStatus();
223 // Create main display pad
224 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
227 fPad->SetFillColor(1);
228 fPad->SetBorderSize(2);
233 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
236 fColPad->SetFillColor(19);
237 fColPad->SetBorderSize(2);
243 // Create user interface control pad
247 // Create Range and mode pad
250 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
253 fTrigPad->SetFillColor(22);
254 fTrigPad->SetBorderSize(2);
255 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
256 fRangeSlider->SetObject(this);
257 char pickmode[] = "gAlice->Display()->SetPickMode()";
259 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
260 fPickButton->SetFillColor(38);
262 char zoommode[] = "gAlice->Display()->SetZoomMode()";
263 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
264 fZoomButton->SetFillColor(38);
266 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
267 fArcButton->SetFillColor(kGreen);
269 char butUnzoom[] = "gAlice->Display()->UnZoom()";
270 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
271 button->SetFillColor(38);
273 AppendPad(); // append display object as last object to force selection
275 fTrigPad->SetEditable(kFALSE);
276 fButtons->SetEditable(kFALSE);
282 //_____________________________________________________________________________
283 AliRICHDisplay::~AliRICHDisplay()
285 // Delete space point structure
286 if (fPoints) fPoints->Delete();
290 if (fPhits) fPhits->Delete();
294 if (fRpoints) fRpoints->Delete();
298 if (fRecpoints) fRecpoints->Delete();
302 if (fPCerenkovs) fPCerenkovs->Delete();
307 //_____________________________________________________________________________
308 void AliRICHDisplay::Clear(Option_t *)
310 // Delete graphics temporary objects
313 //_____________________________________________________________________________
314 void AliRICHDisplay::DisplayButtons()
316 // Create the user interface buttons
319 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
321 fButtons->SetFillColor(38);
322 fButtons->SetBorderSize(2);
325 // Int_t butcolor = 33;
326 Float_t dbutton = 0.08;
333 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
334 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
335 button->SetFillColor(38);
339 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
340 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
341 button->SetFillColor(38);
345 char but7[] = "gAlice->Display()->DrawViewGL()";
346 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
347 button->SetFillColor(38);
351 char but8[] = "gAlice->Display()->DrawViewX3D()";
352 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
353 button->SetFillColor(38);
357 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
358 diamond->SetFillColor(50);
359 diamond->SetTextAlign(22);
360 diamond->SetTextColor(5);
361 diamond->SetTextSize(0.11);
363 diamond->AddText(".. ");
364 diamond->AddText("ROOT");
365 diamond->AddText("RICH");
366 diamond->AddText("... ");
367 diamond->AddText(" ");
370 //_____________________________________________________________________________
371 void AliRICHDisplay::CreateColors()
373 // Create the colors palette used to display clusters
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);
428 new TColor(color,r,g,b);
435 //_____________________________________________________________________________
436 void AliRICHDisplay::DisplayColorScale()
439 // Draw the color scale in the RICH display canvas
443 Float_t xlow, ylow, xup, yup, hs;
444 Float_t x1, y1, x2, y2;
448 gPad->SetFillColor(0);
450 gPad->Range(x1,y1,x2,y2);
451 TText *text = new TText(0,0,"");
452 text->SetTextFont(61);
453 text->SetTextSize(0.03);
454 text->SetTextAlign(22);
458 //*-* draw colortable boxes
459 hs = (y2-y1)/Float_t(22);
463 ylow = y1 + hs*(Float_t(i));
464 yup = y1 + hs*(Float_t(i+1));
466 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
467 Int_t scale=(Int_t)TMath::Exp(logscale);
468 sprintf(label,"%d",scale);
469 box = new TBox(xlow, ylow, xup, yup);
470 box->SetFillColor(color);
472 text->DrawText(xup+4, 0.5*(ylow+yup),label);
476 //______________________________________________________________________________
477 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
479 // Compute distance from point px,py to objects in event
481 gPad->SetCursor(kCross);
483 if (gPad == fTrigPad) return 9999;
485 const Int_t kBig = 9999;
487 Float_t xmin = gPad->GetX1();
488 Float_t xmax = gPad->GetX2();
489 Float_t dx = 0.02*(xmax - xmin);
490 Float_t x = gPad->AbsPixeltoX(px);
491 if (x < xmin+dx || x > xmax-dx) return dist;
492 if (fZoomMode) return 0;
496 //_____________________________________________________________________________
497 void AliRICHDisplay::Draw(Option_t *)
499 // Display current event
503 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
505 // Display the event number and title
510 //_____________________________________________________________________________
511 void AliRICHDisplay::DrawCoG()
513 // Draw hits for RICH chambers
515 if (!fDrawCoG) return;
517 for (Int_t chamber=0;chamber<kNCH;chamber++) {
526 ncog = points->GetEntriesFast();
527 for (icog=0; icog < ncog; icog++) {
528 pm = (AliRICHPoints*)points->UncheckedAt(icog);
534 void AliRICHDisplay::DrawRecHits()
536 // Draw rec hits for RICH chambers
538 if (!fDrawRecHits) return;
540 for (Int_t chamber=0;chamber<kNCH;chamber++) {
541 LoadRecHits(chamber,1);
549 nrec = points->GetEntriesFast();
550 //printf("Nrec %d\n",nrec);
551 for (irec=0; irec < nrec; irec++) {
552 pm = (AliRICHPoints*)points->UncheckedAt(irec);
558 //_____________________________________________________________________________
560 void AliRICHDisplay::DrawCerenkovs()
562 // Draw cerenkovs hits for RICH chambers
564 LoadCerenkovs(fChamber);
565 //printf("\nDrawCerenkovs\n");
567 Int_t ntracks, track;
572 cpoints = fPCerenkovs;
573 //printf ("Cpoints: %p",cpoints);
574 if (!cpoints) return;
575 ntracks = cpoints->GetEntriesFast();
576 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
577 for (track=0;track<ntracks;track++) {
578 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
581 fHitsCuts += pm->GetN();
585 //_____________________________________________________________________________
587 void AliRICHDisplay::DrawClusters()
589 // Draw clusterss for RICH chambers
591 Int_t ndigits, digit;
598 ndigits = points->GetEntriesFast();
599 for (digit=0;digit<ndigits;digit++){
600 pm = (AliRICHPoints*)points->UncheckedAt(digit);
605 for (Int_t im=0;im<3;im++) {
606 TMarker3DBox *marker=pm->GetMarker(im);
610 fClustersCuts +=pm->GetN();
614 //_____________________________________________________________________________
615 void AliRICHDisplay::DrawHits()
617 // Draw hits for RICH chambers
621 Int_t ntracks, track;
628 // ntracks = points->GetEntriesFast();
629 ntracks = fPhits->GetEntriesFast();
631 //printf("DrawHits - ntracks %d \n",ntracks);
632 for (track=0;track<ntracks;track++) {
633 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
636 fHitsCuts += pm->GetN();
641 //_____________________________________________________________________________
642 void AliRICHDisplay::DrawTitle(Option_t *option)
644 // Draw the event title
646 Float_t xmin = gPad->GetX1();
647 Float_t xmax = gPad->GetX2();
648 Float_t ymin = gPad->GetY1();
649 Float_t ymax = gPad->GetY2();
650 Float_t dx = xmax-xmin;
651 Float_t dy = ymax-ymin;
653 if (strlen(option) == 0) {
654 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
655 title->SetBit(kCanDelete);
656 title->SetFillColor(42);
659 sprintf(ptitle,"Alice event: %d, Run:%d",
660 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
661 title->AddText(ptitle);
662 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
663 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
664 nparticles, fHitsCuts,fClustersCuts);
665 title->AddText(ptitle);
668 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
669 label->SetBit(kCanDelete);
670 label->SetFillColor(42);
675 //_____________________________________________________________________________
676 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
678 // Draw a view of RICH clusters
680 gPad->SetCursor(kWatch);
681 gPad->SetFillColor(1);
685 TView *view = new TView(1);
686 Float_t range = fRrange*fRangeSlider->GetMaximum();
687 view->SetRange(-range,-range,-range,range, range, range);
694 //Display RICH Chamber Geometry
695 gAlice->GetGeometry()->Draw("same");
697 //add clusters to the pad
703 //printf("Calling DrawCoG\n");
705 //printf("Calling DrawRecHits\n");
708 /*for (Int_t i=0;i<7;i++)
711 // add itself to the list (must be last)
714 view->SetView(phi, theta, psi, iret);
717 //______________________________________________________________________________
718 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
720 // Execute action corresponding to the mouse event
722 static Float_t x0, y0, x1, y1;
724 static Int_t pxold, pyold;
725 static Int_t px0, py0;
726 static Int_t linedrawn;
729 if (px == 0 && py == 0) { //when called by sliders
730 if (event == kButton1Up) {
731 printf("Drawing event %d\n",event);
736 if (!fZoomMode && gPad->GetView()) {
737 gPad->GetView()->ExecuteRotateView(event, px, py);
741 // something to zoom ?
742 gPad->SetCursor(kCross);
747 gVirtualX->SetLineColor(-1);
748 gPad->TAttLine::Modify(); //Change line attributes only if necessary
749 x0 = gPad->AbsPixeltoX(px);
750 y0 = gPad->AbsPixeltoY(py);
752 pxold = px; pyold = py;
757 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
761 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
765 gPad->GetCanvas()->FeedbackMode(kFALSE);
766 if (px == px0) return;
767 if (py == py0) return;
768 x1 = gPad->AbsPixeltoX(px);
769 y1 = gPad->AbsPixeltoY(py);
771 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
772 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
773 gPad->Range(x0,y0,x1,y1);
774 if (fZooms < kMAXZOOM-1) {
776 fZoomX0[fZooms] = x0;
777 fZoomY0[fZooms] = y0;
778 fZoomX1[fZooms] = x1;
779 fZoomY1[fZooms] = y1;
781 gPad->Modified(kTRUE);
786 //___________________________________________
787 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
789 // Read raw clusters info and store x,y,z info in arrays fRpoints
790 // Loop on all detectors
792 if (chamber > 6) return;
794 //printf("Entering LoadCoG\n");
797 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
798 AliRICHChamber* iChamber;
800 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
801 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
802 if (pRICHrawclust == 0) return;
804 pRICH->ResetRawClusters();
807 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
808 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
809 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
810 //printf ("nrawcl:%d\n",nrawcl);
811 if (nrawcl == 0) return;
812 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
814 iChamber = &(pRICH->Chamber(chamber));
815 AliRICHRawCluster *mRaw;
816 AliRICHPoints *points = 0;
818 //loop over all raw clusters and store their position
819 points = new AliRICHPoints(nrawcl);
820 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
821 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
822 fRpoints->AddAt(points,iraw);
823 points->SetMarkerColor(3);
824 points->SetMarkerStyle(3);
825 points->SetMarkerSize(1.);
826 points->SetParticle(-1);
827 points->SetHitIndex(-1);
828 points->SetTrackIndex(-1);
829 points->SetDigitIndex(-1);
830 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
831 Float_t vectorGlob[3];
832 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
833 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
836 //___________________________________________
837 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
839 // Read rec. hits info
840 // Loop on all detectors
842 if (chamber > 6) return;
844 ///printf("Entering LoadRecHits\n");
847 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
848 AliRICHChamber* iChamber;
850 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
851 //printf ("Chamber:%d\n", chamber);
852 if (pRICHrechits1D != 0)
855 //RICH->ResetRecHits();
858 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
859 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
860 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
861 //printf ("nrechits1D:%d\n",nrechits1D);
864 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
866 iChamber = &(pRICH->Chamber(chamber));
867 AliRICHRecHit1D *mRec1D;
868 AliRICHPoints *points1D = 0;
869 //AliRICHEllipse *ellipse = 0;
871 //loop over all rechits and store their position
873 points1D = new AliRICHPoints(nrechits1D);
874 for (Int_t irec=0;irec<nrechits1D;irec++) {
875 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
876 fRecpoints->AddAt(points1D,irec);
877 points1D->SetMarkerColor(38);
878 points1D->SetMarkerStyle(8);
879 points1D->SetMarkerSize(1.);
880 points1D->SetParticle(-1);
881 points1D->SetHitIndex(-1);
882 points1D->SetTrackIndex(-1);
883 points1D->SetDigitIndex(-1);
884 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
885 Float_t vectorGlob[3];
886 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
887 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
888 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
889 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
890 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
891 //printf("Generating ellipse %d\n",irec);
892 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
893 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());
894 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
895 ellipse->CerenkovRingDrawing(chamber,irec);
896 //ellipse->SetFillStyle(1001);
897 ellipse->SetMarkerColor(38);
899 //marker->SetRefObject((TObject*)points1D);
900 //points1D->Set3DMarker(0, marker);
905 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
906 //printf ("Chamber:%d\n", chamber);
907 if (pRICHrechits3D != 0)
910 //RICH->ResetRecHits();
913 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
914 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
915 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
916 //printf ("nrechits3D:%d\n",nrechits3D);
919 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
921 iChamber = &(pRICH->Chamber(chamber));
922 AliRICHRecHit3D *mRec3D;
923 AliRICHPoints *points3D = 0;
924 //AliRICHEllipse *ellipse = 0;
926 //loop over all rechits and store their position
928 points3D = new AliRICHPoints(nrechits3D);
929 for (Int_t irec=0;irec<nrechits3D;irec++) {
930 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
931 fRecpoints->AddAt(points3D,irec);
932 points3D->SetMarkerColor(42);
933 points3D->SetMarkerStyle(8);
934 points3D->SetMarkerSize(1.);
935 points3D->SetParticle(-1);
936 points3D->SetHitIndex(-1);
937 points3D->SetTrackIndex(-1);
938 points3D->SetDigitIndex(-1);
939 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
940 Float_t vectorGlob[3];
941 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
942 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
943 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
944 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
945 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
946 //printf("Generating ellipse %d\n",irec);
947 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
948 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());
949 ellipse->CerenkovRingDrawing(chamber,irec);
950 //ellipse->SetFillStyle(1001);
951 ellipse->SetMarkerColor(42);
953 //marker->SetRefObject((TObject*)points3D);
954 //points3D->Set3DMarker(0, marker);
959 //___________________________________________
960 void AliRICHDisplay::LoadDigits()
962 // Read digits info and store x,y,z info in arrays fPoints
963 // Loop on all detectors
966 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
967 AliRICHChamber* iChamber;
968 AliSegmentation* segmentation;
972 //printf("Entering LoadDigits\n");
977 for (ich=0; ich<kNCH; ich++) {
978 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
979 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
980 if (pRICHdigits == 0) continue;
981 gAlice->ResetDigits();
982 gAlice->TreeD()->GetEvent(0);
983 Int_t ndigits = pRICHdigits->GetEntriesFast();
984 //printf("ndigits:%d\n",ndigits);
988 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
990 for (ich=0; ich<kNCH; ich++) {
991 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
992 if (pRICHdigits == 0) continue;
993 gAlice->ResetDigits();
994 gAlice->TreeD()->GetEvent(0);
995 Int_t ndigits = pRICHdigits->GetEntriesFast();
996 if (ndigits == 0) continue;
997 iChamber = &(pRICH->Chamber(ich));
998 segmentation=iChamber->GetSegmentationModel();
999 Float_t dpx = segmentation->Dpx();
1000 Float_t dpy = segmentation->Dpy();
1002 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1005 AliRICHPoints *points = 0;
1006 TMarker3DBox *marker = 0;
1008 //loop over all digits and store their position
1011 for (Int_t digit=0;digit<ndigits;digit++) {
1012 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1013 points = new AliRICHPoints(npoints);
1014 fPoints->AddAt(points,counter);
1016 Int_t charge=mdig->fSignal;
1017 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1018 Int_t color=701+index;
1019 if (color>722) color=722;
1020 points->SetMarkerColor(color);
1021 points->SetMarkerStyle(21);
1022 points->SetMarkerSize(0.5);
1023 Float_t xpad, ypad, zpad;
1024 segmentation->GetPadC(mdig->fPadX, mdig->fPadY,xpad, ypad, zpad);
1025 Float_t vectorLoc[3]={xpad,5,ypad};
1026 Float_t vectorGlob[3];
1027 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1028 points->SetParticle(-1);
1029 points->SetHitIndex(-1);
1030 points->SetTrackIndex(-1);
1031 points->SetDigitIndex(digit);
1032 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1033 //printf("Y position (digit): %f\n", vectorGlob[1]);
1035 segmentation->GetPadC(mdig->fPadX, mdig->fPadY, xpad, ypad, zpad);
1036 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1037 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1038 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1039 dpy/2,0,dpx/2,theta,phi);
1040 marker->SetLineColor(2);
1041 marker->SetFillStyle(1001);
1042 marker->SetFillColor(color);
1043 marker->SetRefObject((TObject*)points);
1044 points->Set3DMarker(0, marker);
1045 } // loop over digits
1046 } // loop over chambers
1051 //___________________________________________
1052 void AliRICHDisplay::LoadHits(Int_t chamber)
1054 // Read hits info and store x,y,z info in arrays fPhits
1055 // Loop on all detectors
1061 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1062 AliRICHChamber* iChamber;
1064 iChamber = &(pRICH->Chamber(chamber-1));
1065 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1068 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1069 //TVector *xp = new TVector(1000);
1070 //TVector *yp = new TVector(1000);
1071 //TVector *zp = new TVector(1000);
1072 //TVector *ptrk = new TVector(1000);
1073 //TVector *phit = new TVector(1000);
1075 for (track=0; track<ntracks;track++) {
1076 gAlice->ResetHits();
1077 gAlice->TreeH()->GetEvent(track);
1078 TClonesArray *pRICHhits = pRICH->Hits();
1079 if (pRICHhits == 0) return;
1080 Int_t nhits = pRICHhits->GetEntriesFast();
1084 fPhits = new TObjArray(nAllHits);
1087 for (track=0; track<ntracks;track++) {
1088 gAlice->ResetHits();
1089 gAlice->TreeH()->GetEvent(track);
1090 TClonesArray *pRICHhits = pRICH->Hits();
1091 if (pRICHhits == 0) return;
1092 Int_t nhits = pRICHhits->GetEntriesFast();
1093 if (nhits == 0) continue;
1095 AliRICHPoints *points = 0;
1096 for (Int_t hit=0;hit<nhits;hit++) {
1097 points = new AliRICHPoints(1);
1098 fPhits->AddAt(points,npoints);
1099 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1100 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1101 if (current->GetPdgCode() == 50000050) {
1102 points->SetMarkerColor(kBlue);
1103 } else if (current->GetPdgCode() == 50000051) {
1104 points->SetMarkerColor(kYellow);
1106 points->SetMarkerColor(kRed);
1108 points->SetMarkerStyle(5);
1109 points->SetMarkerSize(1.);
1110 points->SetParticle(mHit->Track());
1111 points->SetHitIndex(hit);
1112 points->SetTrackIndex(track);
1113 points->SetDigitIndex(-1);
1114 points->SetPoint(hit,mHit->X(), mHit->Y(), mHit->Z());
1115 //printf("Y position: %f\n", mHit->Y());
1121 //_____________________________________________________________________________
1123 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1125 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1126 // Loop on all detectors
1131 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1132 AliRICHChamber* iChamber;
1134 iChamber = &(pRICH->Chamber(chamber-1));
1136 pRICH->SetTreeAddress();
1137 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1139 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1140 TVector *xp = new TVector(1000);
1141 TVector *yp = new TVector(1000);
1142 TVector *zp = new TVector(1000);
1143 TVector *ptrk = new TVector(1000);
1144 TVector *phit = new TVector(1000);
1145 for (Int_t track=0; track<ntracks;track++) {
1146 gAlice->ResetHits();
1147 gAlice->TreeH()->GetEvent(track);
1148 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1149 if (pRICHCerenkovs == 0) return;
1150 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1151 if (nhits == 0) continue;
1152 AliRICHCerenkov *mCerenkov;
1153 AliRICHPoints *cpoints = 0;
1157 //Display Cerenkov hits in blue
1159 for (Int_t hit=0;hit<nhits;hit++) {
1160 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1161 (*xp)(npoints)=mCerenkov->X();
1162 (*yp)(npoints)=mCerenkov->Y();
1163 (*zp)(npoints)=mCerenkov->Z();
1164 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1165 (*phit)(npoints)=Float_t(hit);
1168 if (npoints == 0) continue;
1169 cpoints = new AliRICHPoints(npoints);
1170 for (Int_t p=0;p<npoints;p++) {
1171 cpoints->SetMarkerColor(kBlue);
1172 cpoints->SetMarkerStyle(5);
1173 cpoints->SetMarkerSize(1.);
1174 cpoints->SetParticle(Int_t((*ptrk)(p)));
1175 cpoints->SetHitIndex(Int_t((*phit)(p)));
1176 cpoints->SetTrackIndex(track);
1177 cpoints->SetDigitIndex(-1);
1178 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1184 fPCerenkovs->AddAt(cpoints,track);
1188 //_____________________________________________________________________________
1189 void AliRICHDisplay::Paint(Option_t *)
1191 // Paint miscellaneous items
1195 //_____________________________________________________________________________
1196 void AliRICHDisplay::SetPickMode()
1203 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1204 fTrigPad->Modified();
1207 //_____________________________________________________________________________
1208 void AliRICHDisplay::SetZoomMode()
1215 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1216 fTrigPad->Modified();
1219 //_____________________________________________________________________________
1220 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1222 // Set chamber and cathode number
1226 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1233 //_____________________________________________________________________________
1234 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1236 // Set view range along R and Z
1245 //_____________________________________________________________________________
1246 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1248 // change viewing angles for current event
1256 TView *view = gPad->GetView();
1257 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1263 //_____________________________________________________________________________
1264 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1266 // Display (current event_number+delta)
1267 // delta = 1 shown next event
1268 // delta = -1 show previous event
1272 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1273 Int_t newEvent = currentEvent + delta;
1274 gAlice->GetEvent(newEvent);
1275 if (!gAlice->TreeD()) return;
1285 //______________________________________________________________________________
1286 void AliRICHDisplay::UnZoom()
1289 // Return to previous zoom factor
1291 if (fZooms <= 0) return;
1293 TPad *pad = (TPad*)gPad->GetPadSave();
1294 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1298 //_____________________________________________________________________________
1299 void AliRICHDisplay::ResetPoints()
1302 // Reset array of points
1310 //_____________________________________________________________________________
1311 void AliRICHDisplay::ResetRpoints()
1314 // Reset array of points
1322 //_____________________________________________________________________________
1323 void AliRICHDisplay::ResetRecpoints()
1326 // Reset array of points
1329 fRecpoints->Delete();
1334 //_____________________________________________________________________________
1335 void AliRICHDisplay::ResetPhits()
1338 // Reset array of points
1346 //_____________________________________________________________________________
1347 void AliRICHDisplay::ResetPCerenkovs()
1350 // Reset array of points
1353 fPCerenkovs->Delete();
1359 //_____________________________________________________________________________
1361 void AliRICHDisplay::DrawViewGL()
1363 // Draw current view using OPENGL
1365 TPad *pad = (TPad*)gPad->GetPadSave();
1367 TView *view = pad->GetView();
1372 //_____________________________________________________________________________
1373 void AliRICHDisplay::DrawViewX3D()
1375 // Draw current view using X3D
1377 TPad *pad = (TPad*)gPad->GetPadSave();
1379 TView *view = pad->GetView();