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 **************************************************************************/
21 //////////////////////////////////////////////////////////////////////////
25 // Utility class to display ALICE outline, tracks, hits,.. //
27 //////////////////////////////////////////////////////////////////////////
36 #include <TPolyMarker3D.h>
37 #include <TPolyMarker.h>
38 #include <TPaveLabel.h>
39 #include <TPaveText.h>
46 #include <TSliderBox.h>
48 #include <TVirtualX.h>
51 #include <X3DBuffer.h>
55 #include "AliDetector.h"
57 #include "AliRICHConst.h"
58 #include "AliRICHDisplay.h"
59 #include "AliRICHPoints.h"
60 #include "TParticle.h"
63 ClassImp(AliRICHDisplay)
66 //____________________________________________________________________________
67 AliRICHDisplay::AliRICHDisplay()
77 //_____________________________________________________________________________
78 AliRICHDisplay::AliRICHDisplay(Int_t size)
80 // Create an event display object.
81 // A canvas named "edisplay" is created with a vertical size in pixels
83 // A QUICK Overview of the Event Display functions
84 // ===============================================
86 // The event display can ve invoked by executing the macro "display.C"
87 // A canvas like in the picture below will appear.
89 // On the left side of the canvas, the following buttons appear:
90 // *Next* to move to the next event
91 // *Previous* to move to the previous event
93 // *Pick* Select this option to be able to point on a track with the
94 // mouse. Once on the track, use the right button to select
95 // an action. For example, select SetMarkerAttributes to
96 // change the marker type/color/size for the track.
97 // *Zoom* Select this option (default) if you want to zoom.
98 // To zoom, simply select the selected area with the left button.
99 // *UnZoom* To revert to the previous picture size.
101 // slider R On the left side, the vertical slider can be used to
102 // set the default picture size.
104 // When you are in Zoom mode, you can click on the black part of the canvas
105 // to select special options with the right mouse button.
108 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
109 // When you are on a track, select the menu item "InspectParticle"
110 // to display the current particle attributes.
112 // You can activate the Root browser by selecting the Inspect menu
113 // in the canvas tool bar menu. Then select "Start Browser"
114 // This will open a new canvas with the browser. At this point, you may want
115 // to display some histograms (from the Trees). Go to the "File" menu
116 // of the browser and click on "New canvas".
117 // In the browser, click on item "ROOT files" in the left pane.
118 // Click on galice.root.
120 // Click on TPC for example
121 // Click on any variable (eg TPC.fX) to histogram the variable.
123 // If you are lost, you can click on HELP in any Root canvas or browser.
126 <img src="gif/AliRICHDisplay.gif">
133 gAlice->SetDisplay(this);
135 // Initialize display default parameters
138 // Set front view by default
145 fDrawClusters = kTRUE;
147 fDrawRecHits = kTRUE;
158 // Create display canvas
160 if (ysize < 100) ysize = 750;
161 Int_t xsize = Int_t(size*830./ysize);
162 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
163 fCanvas->ToggleEventStatus();
165 // Create main display pad
166 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
169 fPad->SetFillColor(1);
170 fPad->SetBorderSize(2);
175 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
178 fColPad->SetFillColor(19);
179 fColPad->SetBorderSize(2);
185 // Create user interface control pad
189 // Create Range and mode pad
192 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
193 fTrigPad->SetEditable(kFALSE);
196 fTrigPad->SetFillColor(22);
197 fTrigPad->SetBorderSize(2);
198 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
199 fRangeSlider->SetObject(this);
200 char pickmode[] = "gAlice->Display()->SetPickMode()";
202 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
203 fPickButton->SetFillColor(38);
205 char zoommode[] = "gAlice->Display()->SetZoomMode()";
206 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
207 fZoomButton->SetFillColor(38);
209 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
210 fArcButton->SetFillColor(kGreen);
212 char butUnzoom[] = "gAlice->Display()->UnZoom()";
213 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
214 button->SetFillColor(38);
216 AppendPad(); // append display object as last object to force selection
223 //_____________________________________________________________________________
224 AliRICHDisplay::~AliRICHDisplay()
226 // Delete space point structure
227 if (fPoints) fPoints->Delete();
231 if (fPhits) fPhits->Delete();
235 if (fRpoints) fRpoints->Delete();
239 if (fRecpoints) fRecpoints->Delete();
243 if (fPCerenkovs) fPCerenkovs->Delete();
248 //_____________________________________________________________________________
249 void AliRICHDisplay::Clear(Option_t *)
251 // Delete graphics temporary objects
254 //_____________________________________________________________________________
255 void AliRICHDisplay::DisplayButtons()
257 // Create the user interface buttons
260 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
261 fButtons->SetEditable(kFALSE);
263 fButtons->SetFillColor(38);
264 fButtons->SetBorderSize(2);
267 // Int_t butcolor = 33;
268 Float_t dbutton = 0.08;
275 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
276 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
277 button->SetFillColor(38);
281 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
282 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
283 button->SetFillColor(38);
287 char but7[] = "gAlice->Display()->DrawViewGL()";
288 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
289 button->SetFillColor(38);
293 char but8[] = "gAlice->Display()->DrawViewX3D()";
294 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
295 button->SetFillColor(38);
299 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
300 diamond->SetFillColor(50);
301 diamond->SetTextAlign(22);
302 diamond->SetTextColor(5);
303 diamond->SetTextSize(0.11);
305 diamond->AddText(".. ");
306 diamond->AddText("ROOT");
307 diamond->AddText("RICH");
308 diamond->AddText("... ");
309 diamond->AddText(" ");
312 //_____________________________________________________________________________
313 void AliRICHDisplay::CreateColors()
315 // Create the colors palette used to display clusters
330 new TColor(color,r,g,b);
340 new TColor(color,r,g,b);
350 new TColor(color,r,g,b);
360 new TColor(color,r,g,b);
370 new TColor(color,r,g,b);
377 //_____________________________________________________________________________
378 void AliRICHDisplay::DisplayColorScale()
383 Float_t xlow, ylow, xup, yup, hs;
384 Float_t x1, y1, x2, y2;
388 gPad->SetFillColor(0);
390 gPad->Range(x1,y1,x2,y2);
391 TText *text = new TText(0,0,"");
392 text->SetTextFont(61);
393 text->SetTextSize(0.03);
394 text->SetTextAlign(22);
398 //*-* draw colortable boxes
399 hs = (y2-y1)/Float_t(22);
403 ylow = y1 + hs*(Float_t(i));
404 yup = y1 + hs*(Float_t(i+1));
406 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
407 Int_t scale=(Int_t)TMath::Exp(logscale);
408 sprintf(label,"%d",scale);
409 box = new TBox(xlow, ylow, xup, yup);
410 box->SetFillColor(color);
412 text->DrawText(xup+4, 0.5*(ylow+yup),label);
416 //______________________________________________________________________________
417 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
419 // Compute distance from point px,py to objects in event
421 gPad->SetCursor(kCross);
423 if (gPad == fTrigPad) return 9999;
425 const Int_t big = 9999;
427 Float_t xmin = gPad->GetX1();
428 Float_t xmax = gPad->GetX2();
429 Float_t dx = 0.02*(xmax - xmin);
430 Float_t x = gPad->AbsPixeltoX(px);
431 if (x < xmin+dx || x > xmax-dx) return dist;
432 if (fZoomMode) return 0;
436 //_____________________________________________________________________________
437 void AliRICHDisplay::Draw(Option_t *)
439 // Display current event
443 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
445 // Display the event number and title
450 //_____________________________________________________________________________
451 void AliRICHDisplay::DrawCoG()
453 // Draw hits for RICH chambers
455 if (!fDrawCoG) return;
457 for (Int_t chamber=0;chamber<7;chamber++) {
466 ncog = points->GetEntriesFast();
467 for (icog=0; icog < ncog; icog++) {
468 pm = (AliRICHPoints*)points->UncheckedAt(icog);
474 void AliRICHDisplay::DrawRecHits()
476 // Draw rec hits for RICH chambers
478 if (!fDrawRecHits) return;
480 for (Int_t chamber=0;chamber<7;chamber++) {
481 LoadRecHits(chamber,1);
489 nrec = points->GetEntriesFast();
490 printf("Nrec %d\n",nrec);
491 for (irec=0; irec < nrec; irec++) {
492 pm = (AliRICHPoints*)points->UncheckedAt(irec);
498 //_____________________________________________________________________________
500 void AliRICHDisplay::DrawCerenkovs()
502 // Draw cerenkovs hits for RICH chambers
504 LoadCerenkovs(fChamber);
505 //printf("\nDrawCerenkovs\n");
507 Int_t ntracks, track;
512 cpoints = fPCerenkovs;
513 //printf ("Cpoints: %p",cpoints);
514 if (!cpoints) return;
515 ntracks = cpoints->GetEntriesFast();
516 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
517 for (track=0;track<ntracks;track++) {
518 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
521 fHitsCuts += pm->GetN();
525 //_____________________________________________________________________________
527 void AliRICHDisplay::DrawClusters()
529 // Draw clusterss for RICH chambers
531 Int_t ndigits, digit;
538 ndigits = points->GetEntriesFast();
539 for (digit=0;digit<ndigits;digit++){
540 pm = (AliRICHPoints*)points->UncheckedAt(digit);
545 for (Int_t im=0;im<3;im++) {
546 TMarker3DBox *marker=pm->GetMarker(im);
550 fClustersCuts +=pm->GetN();
554 //_____________________________________________________________________________
555 void AliRICHDisplay::DrawHits()
557 // Draw hits for RICH chambers
561 Int_t ntracks, track;
568 // ntracks = points->GetEntriesFast();
569 ntracks = fPhits->GetEntriesFast();
571 //printf("DrawHits - ntracks %d \n",ntracks);
572 for (track=0;track<ntracks;track++) {
573 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
576 fHitsCuts += pm->GetN();
581 //_____________________________________________________________________________
582 void AliRICHDisplay::DrawTitle(Option_t *option)
584 // Draw the event title
586 Float_t xmin = gPad->GetX1();
587 Float_t xmax = gPad->GetX2();
588 Float_t ymin = gPad->GetY1();
589 Float_t ymax = gPad->GetY2();
590 Float_t dx = xmax-xmin;
591 Float_t dy = ymax-ymin;
593 if (strlen(option) == 0) {
594 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
595 title->SetBit(kCanDelete);
596 title->SetFillColor(42);
599 sprintf(ptitle,"Alice event: %d, Run:%d",
600 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
601 title->AddText(ptitle);
602 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
603 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
604 nparticles, fHitsCuts,fClustersCuts);
605 title->AddText(ptitle);
608 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
609 label->SetBit(kCanDelete);
610 label->SetFillColor(42);
615 //_____________________________________________________________________________
616 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
618 // Draw a view of RICH clusters
620 gPad->SetCursor(kWatch);
621 gPad->SetFillColor(1);
625 TView *view = new TView(1);
626 Float_t range = fRrange*fRangeSlider->GetMaximum();
627 view->SetRange(-range,-range,-range,range, range, range);
634 //Display RICH Chamber Geometry
635 gAlice->GetGeometry()->Draw("same");
637 //add clusters to the pad
641 printf("Calling DrawCoG\n");
643 printf("Calling DrawRecHits\n");
645 /*for (Int_t i=0;i<7;i++)
648 // add itself to the list (must be last)
651 view->SetView(phi, theta, psi, iret);
654 //______________________________________________________________________________
655 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
657 // Execute action corresponding to the mouse event
659 static Float_t x0, y0, x1, y1;
661 static Int_t pxold, pyold;
662 static Int_t px0, py0;
663 static Int_t linedrawn;
666 if (px == 0 && py == 0) { //when called by sliders
667 if (event == kButton1Up) {
672 if (!fZoomMode && gPad->GetView()) {
673 gPad->GetView()->ExecuteRotateView(event, px, py);
677 // something to zoom ?
678 gPad->SetCursor(kCross);
683 gVirtualX->SetLineColor(-1);
684 gPad->TAttLine::Modify(); //Change line attributes only if necessary
685 x0 = gPad->AbsPixeltoX(px);
686 y0 = gPad->AbsPixeltoY(py);
688 pxold = px; pyold = py;
693 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
697 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
701 gPad->GetCanvas()->FeedbackMode(kFALSE);
702 if (px == px0) return;
703 if (py == py0) return;
704 x1 = gPad->AbsPixeltoX(px);
705 y1 = gPad->AbsPixeltoY(py);
707 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
708 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
709 gPad->Range(x0,y0,x1,y1);
710 if (fZooms < kMAXZOOM-1) {
712 fZoomX0[fZooms] = x0;
713 fZoomY0[fZooms] = y0;
714 fZoomX1[fZooms] = x1;
715 fZoomY1[fZooms] = y1;
717 gPad->Modified(kTRUE);
722 //___________________________________________
723 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
725 // Read raw clusters info and store x,y,z info in arrays fRpoints
726 // Loop on all detectors
728 if (chamber > 6) return;
730 printf("Entering LoadCoG\n");
733 AliRICH *RICH = (AliRICH*)gAlice->GetModule("RICH");
734 AliRICHChamber* iChamber;
736 TClonesArray *RICHrawclust = RICH->RawClustAddress(chamber);
737 printf ("Chamber:%d has adress:%p\n", chamber, RICHrawclust );
738 if (RICHrawclust == 0) return;
740 RICH->ResetRawClusters();
743 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
744 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
745 Int_t nrawcl = RICHrawclust->GetEntriesFast();
746 printf ("nrawcl:%d\n",nrawcl);
747 if (nrawcl == 0) return;
748 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
750 iChamber = &(RICH->Chamber(chamber));
751 AliRICHRawCluster *mRaw;
752 AliRICHPoints *points = 0;
754 //loop over all raw clusters and store their position
755 points = new AliRICHPoints(nrawcl);
756 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
757 mRaw = (AliRICHRawCluster*)RICHrawclust->UncheckedAt(iraw);
758 fRpoints->AddAt(points,iraw);
759 points->SetMarkerColor(3);
760 points->SetMarkerStyle(3);
761 points->SetMarkerSize(1.);
762 points->SetParticle(-1);
763 points->SetHitIndex(-1);
764 points->SetTrackIndex(-1);
765 points->SetDigitIndex(-1);
766 Float_t VecLoc[3]={mRaw->fX,6.276,mRaw->fY};
768 iChamber->LocaltoGlobal(VecLoc,VecGlob);
769 points->SetPoint(iraw,VecGlob[0],VecGlob[1],VecGlob[2]);
772 //___________________________________________
773 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
775 // Read rec. hits info
776 // Loop on all detectors
778 if (chamber > 6) return;
780 printf("Entering LoadRecHits\n");
783 AliRICH *RICH = (AliRICH*)gAlice->GetModule("RICH");
784 AliRICHChamber* iChamber;
786 TClonesArray *RICHrechits = RICH->RecHitsAddress(chamber);
787 printf ("Chamber:%d has adress:%p\n", chamber, RICHrechits );
788 if (RICHrechits == 0) return;
790 //RICH->ResetRecHits();
793 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
794 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
795 Int_t nrechits = RICHrechits->GetEntriesFast();
796 printf ("nrechits:%d\n",nrechits);
797 if (nrechits == 0) return;
798 if (fRecpoints == 0) fRecpoints = new TObjArray(nrechits);
800 iChamber = &(RICH->Chamber(chamber));
802 AliRICHPoints *points = 0;
803 //AliRICHEllipse *ellipse = 0;
805 //loop over all rechits and store their position
807 points = new AliRICHPoints(nrechits);
808 for (Int_t irec=0;irec<nrechits;irec++) {
809 mRec = (AliRICHRecHit*)RICHrechits->UncheckedAt(irec);
810 fRecpoints->AddAt(points,irec);
811 points->SetMarkerColor(38);
812 points->SetMarkerStyle(8);
813 points->SetMarkerSize(1.);
814 points->SetParticle(-1);
815 points->SetHitIndex(-1);
816 points->SetTrackIndex(-1);
817 points->SetDigitIndex(-1);
818 Float_t VecLoc[3]={mRec->fX,6.276,mRec->fY};
820 iChamber->LocaltoGlobal(VecLoc,VecGlob);
821 points->SetPoint(irec,VecGlob[0],VecGlob[1],VecGlob[2]);
822 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
823 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
824 //ellipse=new TEllipse(VecGlob[0],VecGlob[2],10,10,0,360,phi);
825 printf("Generating ellipse %d\n",irec);
826 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec->fX,mRec->fY,mRec->Omega,mRec->Theta,mRec->Phi);
827 ellipse->CreatePoints(chamber);
828 //ellipse->SetFillStyle(1001);
829 ellipse->SetMarkerColor(38);
831 //marker->SetRefObject((TObject*)points);
832 //points->Set3DMarker(0, marker);
835 //___________________________________________
836 void AliRICHDisplay::LoadDigits()
838 // Read digits info and store x,y,z info in arrays fPoints
839 // Loop on all detectors
842 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
843 AliRICHChamber* iChamber;
844 AliRICHSegmentation* segmentation;
848 for (ich=0; ich<7; ich++) {
849 TClonesArray *RICHdigits = RICH->DigitsAddress(ich);
850 if (RICHdigits == 0) continue;
851 gAlice->ResetDigits();
852 gAlice->TreeD()->GetEvent(1);
853 Int_t ndigits = RICHdigits->GetEntriesFast();
856 if (fPoints == 0) fPoints = new TObjArray(NallDigits);
858 for (ich=0; ich<7; ich++) {
859 TClonesArray *RICHdigits = RICH->DigitsAddress(ich);
860 if (RICHdigits == 0) continue;
861 gAlice->ResetDigits();
862 gAlice->TreeD()->GetEvent(1);
863 Int_t ndigits = RICHdigits->GetEntriesFast();
864 if (ndigits == 0) continue;
865 iChamber = &(RICH->Chamber(ich));
866 segmentation=iChamber->GetSegmentationModel();
867 Float_t dpx = segmentation->Dpx();
868 Float_t dpy = segmentation->Dpy();
870 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
873 AliRICHPoints *points = 0;
874 TMarker3DBox *marker = 0;
876 //loop over all digits and store their position
879 for (Int_t digit=0;digit<ndigits;digit++) {
880 mdig = (AliRICHDigit*)RICHdigits->UncheckedAt(digit);
881 points = new AliRICHPoints(npoints);
882 fPoints->AddAt(points,counter);
884 Int_t charge=mdig->fSignal;
885 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
886 Int_t color=701+index;
887 if (color>722) color=722;
888 points->SetMarkerColor(color);
889 points->SetMarkerStyle(21);
890 points->SetMarkerSize(0.5);
892 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
893 Float_t VecLoc[3]={xpad,6.276,ypad};
895 iChamber->LocaltoGlobal(VecLoc,VecGlob);
896 points->SetParticle(-1);
897 points->SetHitIndex(-1);
898 points->SetTrackIndex(-1);
899 points->SetDigitIndex(digit);
900 points->SetPoint(0,VecGlob[0],VecGlob[1],VecGlob[2]);
902 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY, xpad, ypad);
903 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
904 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
905 marker=new TMarker3DBox(VecGlob[0],VecGlob[1],VecGlob[2],
906 dpy/2,0,dpx/2,theta,phi);
907 marker->SetLineColor(2);
908 marker->SetFillStyle(1001);
909 marker->SetFillColor(color);
910 marker->SetRefObject((TObject*)points);
911 points->Set3DMarker(0, marker);
912 } // loop over digits
913 } // loop over chambers
917 //___________________________________________
918 void AliRICHDisplay::LoadHits(Int_t chamber)
920 // Read hits info and store x,y,z info in arrays fPhits
921 // Loop on all detectors
927 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
928 AliRICHChamber* iChamber;
930 iChamber = &(RICH->Chamber(chamber-1));
931 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
934 if (fPhits == 0) fPhits = new TObjArray(ntracks);
935 //TVector *xp = new TVector(1000);
936 //TVector *yp = new TVector(1000);
937 //TVector *zp = new TVector(1000);
938 //TVector *ptrk = new TVector(1000);
939 //TVector *phit = new TVector(1000);
941 for (track=0; track<ntracks;track++) {
943 gAlice->TreeH()->GetEvent(track);
944 TClonesArray *RICHhits = RICH->Hits();
945 if (RICHhits == 0) return;
946 Int_t nhits = RICHhits->GetEntriesFast();
950 fPhits = new TObjArray(NallHits);
953 for (track=0; track<ntracks;track++) {
955 gAlice->TreeH()->GetEvent(track);
956 TClonesArray *RICHhits = RICH->Hits();
957 if (RICHhits == 0) return;
958 Int_t nhits = RICHhits->GetEntriesFast();
959 if (nhits == 0) continue;
961 AliRICHPoints *points = 0;
962 for (Int_t hit=0;hit<nhits;hit++) {
963 points = new AliRICHPoints(1);
964 fPhits->AddAt(points,npoints);
965 mHit = (AliRICHHit*)RICHhits->UncheckedAt(hit);
967 (TParticle*)(*gAlice->Particles())[mHit->fTrack];
968 if (current->GetPdgCode() == 50000050) {
969 points->SetMarkerColor(kBlue);
970 } else if (current->GetPdgCode() == 50000051) {
971 points->SetMarkerColor(kYellow);
973 points->SetMarkerColor(kRed);
975 points->SetMarkerStyle(5);
976 points->SetMarkerSize(1.);
977 points->SetParticle(current->GetPdgCode());
978 points->SetHitIndex(hit);
979 points->SetTrackIndex(mHit->fTrack);
980 points->SetDigitIndex(-1);
981 points->SetPoint(hit,mHit->fX, mHit->fY, mHit->fZ);
987 //_____________________________________________________________________________
989 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
991 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
992 // Loop on all detectors
997 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
998 AliRICHChamber* iChamber;
1000 iChamber = &(RICH->Chamber(chamber-1));
1002 RICH->SetTreeAddress();
1003 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1005 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1006 TVector *xp = new TVector(1000);
1007 TVector *yp = new TVector(1000);
1008 TVector *zp = new TVector(1000);
1009 TVector *ptrk = new TVector(1000);
1010 TVector *phit = new TVector(1000);
1011 for (Int_t track=0; track<ntracks;track++) {
1012 gAlice->ResetHits();
1013 gAlice->TreeH()->GetEvent(track);
1014 TClonesArray *RICHCerenkovs = RICH->Cerenkovs();
1015 if (RICHCerenkovs == 0) return;
1016 Int_t nhits = RICHCerenkovs->GetEntriesFast();
1017 if (nhits == 0) continue;
1018 AliRICHCerenkov *mCerenkov;
1019 AliRICHPoints *cpoints = 0;
1023 //Display Cerenkov hits in blue
1025 for (Int_t hit=0;hit<nhits;hit++) {
1026 mCerenkov = (AliRICHCerenkov*)RICHCerenkovs->UncheckedAt(hit);
1027 (*xp)(npoints)=mCerenkov->fX;
1028 (*yp)(npoints)=mCerenkov->fY;
1029 (*zp)(npoints)=mCerenkov->fZ;
1030 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1031 (*phit)(npoints)=Float_t(hit);
1034 if (npoints == 0) continue;
1035 cpoints = new AliRICHPoints(npoints);
1036 for (Int_t p=0;p<npoints;p++) {
1037 cpoints->SetMarkerColor(kBlue);
1038 cpoints->SetMarkerStyle(5);
1039 cpoints->SetMarkerSize(1.);
1040 cpoints->SetParticle(Int_t((*ptrk)(p)));
1041 cpoints->SetHitIndex(Int_t((*phit)(p)));
1042 cpoints->SetTrackIndex(track);
1043 cpoints->SetDigitIndex(-1);
1044 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1050 fPCerenkovs->AddAt(cpoints,track);
1054 //_____________________________________________________________________________
1055 void AliRICHDisplay::Paint(Option_t *)
1057 // Paint miscellaneous items
1061 //_____________________________________________________________________________
1062 void AliRICHDisplay::SetPickMode()
1066 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1067 fTrigPad->Modified();
1070 //_____________________________________________________________________________
1071 void AliRICHDisplay::SetZoomMode()
1075 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1076 fTrigPad->Modified();
1079 //_____________________________________________________________________________
1080 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1082 // Set chamber and cathode number
1086 printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1093 //_____________________________________________________________________________
1094 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1096 // Set view range along R and Z
1105 //_____________________________________________________________________________
1106 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1108 // change viewing angles for current event
1116 TView *view = gPad->GetView();
1117 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1123 //_____________________________________________________________________________
1124 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1126 // Display (current event_number+delta)
1127 // delta = 1 shown next event
1128 // delta = -1 show previous event
1132 Int_t current_event = gAlice->GetHeader()->GetEvent();
1133 Int_t new_event = current_event + delta;
1134 gAlice->GetEvent(new_event);
1135 if (!gAlice->TreeD()) return;
1145 //______________________________________________________________________________
1146 void AliRICHDisplay::UnZoom()
1148 if (fZooms <= 0) return;
1150 TPad *pad = (TPad*)gPad->GetPadSave();
1151 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1155 //_____________________________________________________________________________
1156 void AliRICHDisplay::ResetPoints()
1159 // Reset array of points
1167 //_____________________________________________________________________________
1168 void AliRICHDisplay::ResetRpoints()
1171 // Reset array of points
1179 //_____________________________________________________________________________
1180 void AliRICHDisplay::ResetRecpoints()
1183 // Reset array of points
1186 fRecpoints->Delete();
1191 //_____________________________________________________________________________
1192 void AliRICHDisplay::ResetPhits()
1195 // Reset array of points
1203 //_____________________________________________________________________________
1204 void AliRICHDisplay::ResetPCerenkovs()
1207 // Reset array of points
1210 fPCerenkovs->Delete();
1216 //_____________________________________________________________________________
1218 void AliRICHDisplay::DrawViewGL()
1220 // Draw current view using OPENGL
1222 TPad *pad = (TPad*)gPad->GetPadSave();
1224 TView *view = pad->GetView();
1229 //_____________________________________________________________________________
1230 void AliRICHDisplay::DrawViewX3D()
1232 // Draw current view using X3D
1234 TPad *pad = (TPad*)gPad->GetPadSave();
1236 TView *view = pad->GetView();
1244 ClassImp(AliRICHEllipse)
1246 //________________________________________________________________________________
1247 AliRICHEllipse::AliRICHEllipse()
1257 //________________________________________________________________________________
1258 AliRICHEllipse::~AliRICHEllipse()
1269 //________________________________________________________________________________
1270 AliRICHEllipse::AliRICHEllipse(Float_t cx, Float_t cy, Float_t omega, Float_t theta, Float_t phi)
1280 //________________________________________________________________________________
1281 void AliRICHEllipse::CreatePoints(Int_t chamber)
1284 Float_t fiducial=h*TMath::Tan(fOmega+fTheta), l=h/TMath::Cos(fTheta), xtrial, y, c0, c1, c2;
1285 //TRandom *random=new TRandom();
1287 AliRICH *RICH = (AliRICH*)gAlice->GetModule("RICH");
1288 AliRICHChamber* iChamber;
1290 iChamber = &(RICH->Chamber(chamber));
1291 //cout<<"fiducial="<<fiducial<<endl;
1293 for(Float_t i=0;i<1000;i++)
1297 while((c1*c1-4*c2*c0)<=0)
1299 //Choose which side to go...
1300 if(i>250 && i<750) s1=1;
1301 //if (gRandom->Rndm(1)>.5) s1=1;
1303 //printf("s1:%d\n",s1);
1305 y=s1*i*gRandom->Rndm(Int_t(fiducial/50));
1306 //printf("Fiducial %f for omega:%f theta:%f phi:%f\n",fiducial,fOmega,fTheta,fPhi);
1307 Float_t alfa1=fTheta;
1308 Float_t theta1=fPhi;
1309 Float_t OMEGA1=fOmega;
1311 //Solve the eq for a trial x
1312 c0=-TMath::Power(y*TMath::Cos(alfa1)*TMath::Cos(theta1),2)-TMath::Power(y*TMath::Sin(alfa1),2)+TMath::Power(l*TMath::Tan(OMEGA1),2)+2*l*y*TMath::Cos(alfa1)*TMath::Sin(theta1)*TMath::Power(TMath::Tan(OMEGA1),2)+TMath::Power(y*TMath::Cos(alfa1)*TMath::Sin(theta1)*TMath::Tan(OMEGA1),2);
1313 c1=2*y*TMath::Cos(alfa1)*TMath::Sin(alfa1)-2*y*TMath::Cos(alfa1)*TMath::Power(TMath::Cos(theta1),2)*TMath::Sin(alfa1)+2*l*TMath::Sin(alfa1)*TMath::Sin(theta1)*TMath::Power(TMath::Tan(OMEGA1),2)+2*y*TMath::Cos(alfa1)*TMath::Sin(alfa1)*TMath::Power(TMath::Sin(theta1),2)*TMath::Power(TMath::Tan(OMEGA1),2);
1314 c2=-TMath::Power(TMath::Cos(alfa1),2)-TMath::Power(TMath::Cos(theta1)*TMath::Sin(alfa1),2)+TMath::Power(TMath::Sin(alfa1)*TMath::Sin(theta1)*TMath::Tan(OMEGA1),2);
1315 //cout<<"Trial: y="<<y<<"c0="<<c0<<" c1="<<c1<<" c2="<<c2<<endl;
1316 //printf("Result:%f\n\n",c1*c1-4*c2*c0);
1320 //Choose which side to go...
1321 //if(gRandom->Rndm(1)>.5) s=1;
1324 //if (gRandom->Rndm(1)>.5) s2=1;
1326 xtrial=fCx+(-c1+s2*TMath::Sqrt(c1*c1-4*c2*c0))/(2*c2);
1327 //cout<<"x="<<xtrial<<" y="<<cy+y<<endl;
1328 //printf("Coordinates: %f %f\n",xtrial,fCy+y);
1330 Float_t VecLoc[3]={xtrial/.8,6.276,(fCy+y)/.8};
1332 iChamber->LocaltoGlobal(VecLoc,VecGlob);
1333 SetPoint(i,VecGlob[0],VecGlob[1],VecGlob[2]);
1334 //printf("Coordinates: %f %f %f\n",VecGlob[0],VecGlob[1],VecGlob[2]);