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.19 2002/11/04 08:59:20 morsch
19 Correct orientation of modules. (J. Barbosa)
21 Revision 1.18 2002/10/29 14:24:19 morsch
22 Minor corrections on the display (adc counts readable, ...).
25 Revision 1.17 2001/10/23 13:03:35 hristov
26 The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
28 Revision 1.16 2001/10/21 18:31:24 hristov
29 Several pointers were set to zero in the default constructors to avoid memory management problems
31 Revision 1.15 2001/10/09 07:34:09 hristov
32 Modifications needed by Root.03.01.06 (J.Chudoba)
34 Revision 1.14 2001/05/16 14:57:20 alibrary
35 New files for folders and Stack
37 Revision 1.13 2001/05/10 12:35:16 jbarbosa
38 Removed hit display, added rec. ring properties.
40 Revision 1.12 2001/03/14 18:15:03 jbarbosa
41 Changes to adapt to new IO.
42 Removed verbose output.
44 Revision 1.11 2001/02/27 15:21:34 jbarbosa
45 Transition to SDigits.
47 Revision 1.10 2001/02/13 20:18:48 jbarbosa
48 Corrected some more positioning of points. Changes in LoadDigits to accomodate the new IO.
50 Revision 1.9 2000/11/01 15:33:11 jbarbosa
51 Updated to handle both reconstruction algorithms.
53 Revision 1.8 2000/10/03 21:44:09 morsch
54 Use AliSegmentation and AliHit abstract base classes.
56 Revision 1.7 2000/10/02 21:28:12 fca
57 Removal of useless dependecies via forward declarations
59 Revision 1.6 2000/10/02 15:46:38 jbarbosa
60 Fixed forward declarations.
62 Revision 1.5 2000/06/30 16:49:34 dibari
63 Different call for ring drawing.
65 Revision 1.4 2000/06/12 15:21:08 jbarbosa
68 Revision 1.3 2000/06/09 14:52:08 jbarbosa
69 New tentative ellipse drawing routine
71 Revision 1.1 2000/04/19 13:07:45 morsch
72 Digits, clusters and reconstruction results added.
77 //////////////////////////////////////////////////////////////////////////
81 // Utility class to display ALICE outline, tracks, hits,.. //
83 //////////////////////////////////////////////////////////////////////////
92 #include <TPolyMarker3D.h>
95 #include <TPolyMarker.h>
96 #include <TPaveLabel.h>
97 #include <TPaveText.h>
104 #include <TGeometry.h>
105 #include <TSliderBox.h>
107 #include <TVirtualX.h>
110 #include <X3DBuffer.h>
111 #include <TParticle.h>
115 #include "AliDetector.h"
117 #include "AliRICHConst.h"
118 #include "AliRICHDisplay.h"
119 #include "AliRICHPoints.h"
120 #include "AliHeader.h"
122 #include "AliRICHHit.h"
123 #include "AliRICHCerenkov.h"
124 #include "AliRICHSDigit.h"
125 #include "AliRICHDigit.h"
126 #include "AliRICHRawCluster.h"
127 #include "AliRICHRecHit1D.h"
128 #include "AliRICHRecHit3D.h"
129 #include "AliRICHEllipse.h"
131 ClassImp(AliRICHDisplay)
134 //____________________________________________________________________________
135 AliRICHDisplay::AliRICHDisplay()
138 // default constructor
148 //_____________________________________________________________________________
149 AliRICHDisplay::AliRICHDisplay(Int_t size)
151 // Create an event display object.
152 // A canvas named "edisplay" is created with a vertical size in pixels
154 // A QUICK Overview of the Event Display functions
155 // ===============================================
157 // The event display can ve invoked by executing the macro "display.C"
158 // A canvas like in the picture below will appear.
160 // On the left side of the canvas, the following buttons appear:
161 // *Next* to move to the next event
162 // *Previous* to move to the previous event
164 // *Pick* Select this option to be able to point on a track with the
165 // mouse. Once on the track, use the right button to select
166 // an action. For example, select SetMarkerAttributes to
167 // change the marker type/color/size for the track.
168 // *Zoom* Select this option (default) if you want to zoom.
169 // To zoom, simply select the selected area with the left button.
170 // *UnZoom* To revert to the previous picture size.
172 // slider R On the left side, the vertical slider can be used to
173 // set the default picture size.
175 // When you are in Zoom mode, you can click on the black part of the canvas
176 // to select special options with the right mouse button.
179 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
180 // When you are on a track, select the menu item "InspectParticle"
181 // to display the current particle attributes.
183 // You can activate the Root browser by selecting the Inspect menu
184 // in the canvas tool bar menu. Then select "Start Browser"
185 // This will open a new canvas with the browser. At this point, you may want
186 // to display some histograms (from the Trees). Go to the "File" menu
187 // of the browser and click on "New canvas".
188 // In the browser, click on item "ROOT files" in the left pane.
189 // Click on galice.root.
191 // Click on TPC for example
192 // Click on any variable (eg TPC.fX) to histogram the variable.
194 // If you are lost, you can click on HELP in any Root canvas or browser.
197 <img src="gif/AliRICHDisplay.gif">
204 gAlice->SetDisplay(this);
206 // Initialize display default parameters
209 // Set front view by default
210 fTheta = 90; //inclined HMPID
211 fPhi = 30; //inclined HMPID
212 //fTheta = 90; //normal HMPID
213 //fPhi = 90; //normal HMPID
218 fDrawClusters = kTRUE;
220 fDrawRecHits = kTRUE;
231 // Create display canvas
233 if (ysize < 100) ysize = 750;
234 Int_t xsize = Int_t(size*830./ysize);
235 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
236 fCanvas->ToggleEventStatus();
238 // Create main display pad
239 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
242 fPad->SetFillColor(1);
243 fPad->SetBorderSize(2);
248 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
251 fColPad->SetFillColor(19);
252 fColPad->SetBorderSize(2);
258 // Create user interface control pad
262 // Create Range and mode pad
265 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
268 fTrigPad->SetFillColor(22);
269 fTrigPad->SetBorderSize(2);
270 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
271 fRangeSlider->SetObject(this);
272 char pickmode[] = "gAlice->Display()->SetPickMode()";
274 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
275 fPickButton->SetFillColor(38);
277 char zoommode[] = "gAlice->Display()->SetZoomMode()";
278 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
279 fZoomButton->SetFillColor(38);
281 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
282 fArcButton->SetFillColor(kGreen);
284 char butUnzoom[] = "gAlice->Display()->UnZoom()";
285 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
286 button->SetFillColor(38);
288 AppendPad(); // append display object as last object to force selection
290 fTrigPad->SetEditable(kFALSE);
291 fButtons->SetEditable(kFALSE);
297 //_____________________________________________________________________________
298 AliRICHDisplay::~AliRICHDisplay()
300 // Delete space point structure
301 if (fPoints) fPoints->Delete();
305 if (fPhits) fPhits->Delete();
309 if (fRpoints) fRpoints->Delete();
313 if (fRecpoints) fRecpoints->Delete();
317 if (fPCerenkovs) fPCerenkovs->Delete();
322 //_____________________________________________________________________________
323 void AliRICHDisplay::Clear(Option_t *)
325 // Delete graphics temporary objects
328 //_____________________________________________________________________________
329 void AliRICHDisplay::DisplayButtons()
331 // Create the user interface buttons
334 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
336 fButtons->SetFillColor(38);
337 fButtons->SetBorderSize(2);
340 // Int_t butcolor = 33;
341 Float_t dbutton = 0.08;
348 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
349 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
350 button->SetFillColor(38);
354 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
355 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
356 button->SetFillColor(38);
360 char but7[] = "gAlice->Display()->DrawViewGL()";
361 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
362 button->SetFillColor(38);
366 char but8[] = "gAlice->Display()->DrawViewX3D()";
367 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
368 button->SetFillColor(38);
372 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
373 diamond->SetFillColor(50);
374 diamond->SetTextAlign(22);
375 diamond->SetTextColor(5);
376 diamond->SetTextSize(0.11);
378 diamond->AddText(".. ");
379 diamond->AddText("ROOT");
380 diamond->AddText("RICH");
381 diamond->AddText("... ");
382 diamond->AddText(" ");
385 //_____________________________________________________________________________
386 void AliRICHDisplay::CreateColors()
388 // Create the colors palette used to display clusters
403 new TColor(color,r,g,b);
413 new TColor(color,r,g,b);
423 new TColor(color,r,g,b);
433 new TColor(color,r,g,b);
443 new TColor(color,r,g,b);
450 //_____________________________________________________________________________
451 void AliRICHDisplay::DisplayColorScale()
454 // Draw the color scale in the RICH display canvas
458 Float_t xlow, ylow, xup, yup, hs;
459 Float_t x1, y1, x2, y2;
463 gPad->SetFillColor(0);
465 gPad->Range(x1,y1,x2,y2);
466 TText *text = new TText(0,0,"");
467 text->SetTextFont(61);
468 text->SetTextSize(0.2);
469 text->SetTextAlign(22);
473 //*-* draw colortable boxes
474 hs = (y2-y1)/Float_t(22);
478 ylow = y1 + hs*(Float_t(i));
479 yup = y1 + hs*(Float_t(i+1));
481 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
482 Int_t scale=(Int_t)TMath::Exp(logscale);
483 sprintf(label,"%d",scale);
484 box = new TBox(xlow, ylow, xup, yup);
485 box->SetFillColor(color);
487 text->DrawText(xup+4, 0.5*(ylow+yup),label);
491 //______________________________________________________________________________
492 Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
494 // Compute distance from point px,py to objects in event
496 gPad->SetCursor(kCross);
498 if (gPad == fTrigPad) return 9999;
500 const Int_t kBig = 9999;
502 Float_t xmin = gPad->GetX1();
503 Float_t xmax = gPad->GetX2();
504 Float_t dx = 0.02*(xmax - xmin);
505 Float_t x = gPad->AbsPixeltoX(px);
506 if (x < xmin+dx || x > xmax-dx) return dist;
507 if (fZoomMode) return 0;
511 //_____________________________________________________________________________
512 void AliRICHDisplay::Draw(Option_t *)
514 // Display current event
518 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
520 // Display the event number and title
525 //_____________________________________________________________________________
526 void AliRICHDisplay::DrawCoG()
528 // Draw hits for RICH chambers
530 if (!fDrawCoG) return;
532 for (Int_t chamber=0;chamber<kNCH;chamber++) {
541 ncog = points->GetEntriesFast();
542 for (icog=0; icog < ncog; icog++) {
543 pm = (AliRICHPoints*)points->UncheckedAt(icog);
549 void AliRICHDisplay::DrawRecHits()
551 // Draw rec hits for RICH chambers
553 if (!fDrawRecHits) return;
555 for (Int_t chamber=0;chamber<kNCH;chamber++) {
556 LoadRecHits(chamber,1);
564 nrec = points->GetEntriesFast();
565 //printf("Nrec %d\n",nrec);
566 for (irec=0; irec < nrec; irec++) {
567 pm = (AliRICHPoints*)points->UncheckedAt(irec);
573 //_____________________________________________________________________________
575 void AliRICHDisplay::DrawCerenkovs()
577 // Draw cerenkovs hits for RICH chambers
579 LoadCerenkovs(fChamber);
580 //printf("\nDrawCerenkovs\n");
582 Int_t ntracks, track;
587 cpoints = fPCerenkovs;
588 //printf ("Cpoints: %p",cpoints);
589 if (!cpoints) return;
590 ntracks = cpoints->GetEntriesFast();
591 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
592 for (track=0;track<ntracks;track++) {
593 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
596 fHitsCuts += pm->GetN();
600 //_____________________________________________________________________________
602 void AliRICHDisplay::DrawClusters()
604 // Draw clusterss for RICH chambers
606 Int_t ndigits, digit;
613 ndigits = points->GetEntriesFast();
614 for (digit=0;digit<ndigits;digit++){
615 pm = (AliRICHPoints*)points->UncheckedAt(digit);
620 for (Int_t im=0;im<3;im++) {
621 TMarker3DBox *marker=pm->GetMarker(im);
625 fClustersCuts +=pm->GetN();
629 //_____________________________________________________________________________
630 void AliRICHDisplay::DrawHits()
632 // Draw hits for RICH chambers
636 Int_t ntracks, track;
643 // ntracks = points->GetEntriesFast();
644 ntracks = fPhits->GetEntriesFast();
646 //printf("DrawHits - ntracks %d \n",ntracks);
647 for (track=0;track<ntracks;track++) {
648 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
651 fHitsCuts += pm->GetN();
656 //_____________________________________________________________________________
657 void AliRICHDisplay::DrawTitle(Option_t *option)
659 // Draw the event title
661 Float_t xmin = gPad->GetX1();
662 Float_t xmax = gPad->GetX2();
663 Float_t ymin = gPad->GetY1();
664 Float_t ymax = gPad->GetY2();
665 Float_t dx = xmax-xmin;
666 Float_t dy = ymax-ymin;
668 if (strlen(option) == 0) {
669 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
670 title->SetBit(kCanDelete);
671 title->SetFillColor(42);
674 sprintf(ptitle,"Alice event: %d, Run:%d",
675 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
676 title->AddText(ptitle);
677 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
678 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
679 nparticles, fHitsCuts,fClustersCuts);
680 title->AddText(ptitle);
683 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
684 label->SetBit(kCanDelete);
685 label->SetFillColor(42);
690 //_____________________________________________________________________________
691 void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
693 // Draw a view of RICH clusters
695 gPad->SetCursor(kWatch);
696 gPad->SetFillColor(1);
700 TView *view = new TView(1);
701 Float_t range = fRrange*fRangeSlider->GetMaximum();
702 view->SetRange(-range,-range,-range,range, range, range);
709 //Display RICH Chamber Geometry
710 gAlice->GetGeometry()->Draw("same");
712 //add clusters to the pad
718 //printf("Calling DrawCoG\n");
720 //printf("Calling DrawRecHits\n");
723 /*for (Int_t i=0;i<7;i++)
726 // add itself to the list (must be last)
729 view->SetView(phi, theta, psi, iret);
732 //______________________________________________________________________________
733 void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
735 // Execute action corresponding to the mouse event
737 static Float_t x0, y0, x1, y1;
739 static Int_t pxold, pyold;
740 static Int_t px0, py0;
741 static Int_t linedrawn;
744 if (px == 0 && py == 0) { //when called by sliders
745 if (event == kButton1Up) {
746 printf("Drawing event %d\n",event);
751 if (!fZoomMode && gPad->GetView()) {
752 gPad->GetView()->ExecuteRotateView(event, px, py);
756 // something to zoom ?
757 gPad->SetCursor(kCross);
762 gVirtualX->SetLineColor(-1);
763 gPad->TAttLine::Modify(); //Change line attributes only if necessary
764 x0 = gPad->AbsPixeltoX(px);
765 y0 = gPad->AbsPixeltoY(py);
767 pxold = px; pyold = py;
772 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
776 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
780 gPad->GetCanvas()->FeedbackMode(kFALSE);
781 if (px == px0) return;
782 if (py == py0) return;
783 x1 = gPad->AbsPixeltoX(px);
784 y1 = gPad->AbsPixeltoY(py);
786 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
787 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
788 gPad->Range(x0,y0,x1,y1);
789 if (fZooms < kMAXZOOM-1) {
791 fZoomX0[fZooms] = x0;
792 fZoomY0[fZooms] = y0;
793 fZoomX1[fZooms] = x1;
794 fZoomY1[fZooms] = y1;
796 gPad->Modified(kTRUE);
801 //___________________________________________
802 void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
804 // Read raw clusters info and store x,y,z info in arrays fRpoints
805 // Loop on all detectors
807 if (chamber > 6) return;
809 //printf("Entering LoadCoG\n");
812 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
813 AliRICHChamber* iChamber;
815 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
816 //printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
817 if (pRICHrawclust == 0) return;
819 pRICH->ResetRawClusters();
822 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
823 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
824 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
825 //printf ("nrawcl:%d\n",nrawcl);
826 if (nrawcl == 0) return;
827 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
829 iChamber = &(pRICH->Chamber(chamber));
830 AliRICHRawCluster *mRaw;
831 AliRICHPoints *points = 0;
833 //loop over all raw clusters and store their position
834 points = new AliRICHPoints(nrawcl);
835 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
836 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
837 fRpoints->AddAt(points,iraw);
838 points->SetMarkerColor(3);
839 points->SetMarkerStyle(3);
840 points->SetMarkerSize(1.);
841 points->SetParticle(-1);
842 points->SetHitIndex(-1);
843 points->SetTrackIndex(-1);
844 points->SetDigitIndex(-1);
845 Float_t vectorLoc[3]={mRaw->fX,5,mRaw->fY};
846 Float_t vectorGlob[3];
847 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
848 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
851 //___________________________________________
852 void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
854 // Read rec. hits info
855 // Loop on all detectors
857 if (chamber > 6) return;
859 ///printf("Entering LoadRecHits\n");
862 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
863 AliRICHChamber* iChamber;
865 TClonesArray *pRICHrechits1D = pRICH->RecHitsAddress1D(chamber);
866 //printf ("Chamber:%d\n", chamber);
867 if (pRICHrechits1D != 0)
870 //RICH->ResetRecHits();
873 Int_t nent1D=(Int_t)gAlice->TreeR()->GetEntries();
874 gAlice->TreeR()->GetEvent(nent1D-1+cathode-1);
875 Int_t nrechits1D = pRICHrechits1D->GetEntriesFast();
876 //printf ("nrechits1D:%d\n",nrechits1D);
879 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
881 iChamber = &(pRICH->Chamber(chamber));
882 AliRICHRecHit1D *mRec1D;
883 AliRICHPoints *points1D = 0;
884 //AliRICHEllipse *ellipse = 0;
886 //loop over all rechits and store their position
888 points1D = new AliRICHPoints(nrechits1D);
889 for (Int_t irec=0;irec<nrechits1D;irec++) {
890 mRec1D = (AliRICHRecHit1D*)pRICHrechits1D->UncheckedAt(irec);
891 fRecpoints->AddAt(points1D,irec);
892 points1D->SetMarkerColor(38);
893 points1D->SetMarkerStyle(8);
894 points1D->SetMarkerSize(.5);
895 points1D->SetParticle(-1);
896 points1D->SetHitIndex(-1);
897 points1D->SetTrackIndex(-1);
898 points1D->SetDigitIndex(-1);
899 Float_t vectorLoc[3]={mRec1D->fX,5,mRec1D->fY};
900 Float_t vectorGlob[3];
901 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
902 points1D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
903 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
904 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
905 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
906 //printf("Generating ellipse %d\n",irec);
907 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec1D->fX,mRec1D->fY,mRec1D->fOmega,mRec1D->fTheta,mRec1D->fPhi,mRec1D->fEmissPoint);
908 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());
909 printf("fEmissPoint:%f\n",mRec1D->fEmissPoint);
910 ellipse->CerenkovRingDrawing(chamber,irec);
911 //ellipse->SetFillStyle(1001);
912 ellipse->SetMarkerColor(38);
914 //marker->SetRefObject((TObject*)points1D);
915 //points1D->Set3DMarker(0, marker);
920 TClonesArray *pRICHrechits3D = pRICH->RecHitsAddress3D(chamber);
921 //printf ("Chamber:%d\n", chamber);
922 if (pRICHrechits3D != 0)
925 //RICH->ResetRecHits();
928 Int_t nent3D=(Int_t)gAlice->TreeR()->GetEntries();
929 gAlice->TreeR()->GetEvent(nent3D-1+cathode-1);
930 Int_t nrechits3D = pRICHrechits3D->GetEntriesFast();
931 //printf ("nrechits3D:%d\n",nrechits3D);
934 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
936 iChamber = &(pRICH->Chamber(chamber));
937 AliRICHRecHit3D *mRec3D;
938 AliRICHPoints *points3D = 0;
939 //AliRICHEllipse *ellipse = 0;
941 //loop over all rechits and store their position
943 points3D = new AliRICHPoints(nrechits3D);
944 for (Int_t irec=0;irec<nrechits3D;irec++) {
945 mRec3D = (AliRICHRecHit3D*)pRICHrechits3D->UncheckedAt(irec);
946 fRecpoints->AddAt(points3D,irec);
947 points3D->SetMarkerColor(42);
948 points3D->SetMarkerStyle(8);
949 points3D->SetMarkerSize(1.);
950 points3D->SetParticle(-1);
951 points3D->SetHitIndex(-1);
952 points3D->SetTrackIndex(-1);
953 points3D->SetDigitIndex(-1);
954 Float_t vectorLoc[3]={mRec3D->fX,5,mRec3D->fY};
955 Float_t vectorGlob[3];
956 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
957 points3D->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
958 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
959 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
960 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
961 //printf("Generating ellipse %d\n",irec);
962 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec3D->fX,mRec3D->fY,mRec3D->fOmega,mRec3D->fTheta,mRec3D->fPhi,0.75);
963 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());
964 //ellipse->CerenkovRingDrawing(chamber,irec);
965 //ellipse->SetFillStyle(1001);
966 ellipse->CreatePoints(chamber);
967 ellipse->SetMarkerStyle(7);
968 ellipse->SetMarkerColor(42);
969 ellipse->SetMarkerSize(1);
971 //marker->SetRefObject((TObject*)points3D);
972 //points3D->Set3DMarker(0, marker);
977 //___________________________________________
978 void AliRICHDisplay::LoadDigits()
980 // Read digits info and store x,y,z info in arrays fPoints
981 // Loop on all detectors
984 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
985 AliRICHChamber* iChamber;
986 AliSegmentation* segmentation;
990 //printf("Entering LoadDigits\n");
995 for (ich=0; ich<kNCH; ich++) {
996 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
997 //printf ("Chamber:%d has adress:%p\n", ich, pRICHdigits );
998 if (pRICHdigits == 0) continue;
999 gAlice->ResetDigits();
1000 gAlice->TreeD()->GetEvent(0);
1001 Int_t ndigits = pRICHdigits->GetEntriesFast();
1002 //printf("ndigits:%d\n",ndigits);
1003 nAllDigits+=ndigits;
1006 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
1008 for (ich=0; ich<kNCH; ich++) {
1009 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
1010 if (pRICHdigits == 0) continue;
1011 gAlice->ResetDigits();
1012 gAlice->TreeD()->GetEvent(0);
1013 Int_t ndigits = pRICHdigits->GetEntriesFast();
1014 if (ndigits == 0) continue;
1015 iChamber = &(pRICH->Chamber(ich));
1016 segmentation=iChamber->GetSegmentationModel();
1017 Float_t dpx = segmentation->Dpx();
1018 Float_t dpy = segmentation->Dpy();
1020 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
1023 AliRICHPoints *points = 0;
1024 TMarker3DBox *marker = 0;
1026 //loop over all digits and store their position
1029 for (Int_t digit=0;digit<ndigits;digit++) {
1030 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
1031 points = new AliRICHPoints(npoints);
1032 fPoints->AddAt(points,counter);
1034 Int_t charge=mdig->Signal();
1035 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
1036 Int_t color=701+index;
1037 if (color>722) color=722;
1038 points->SetMarkerColor(color);
1039 points->SetMarkerStyle(21);
1040 points->SetMarkerSize(0.5);
1041 Float_t xpad, ypad, zpad;
1042 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
1043 Float_t vectorLoc[3]={xpad,5,ypad};
1044 Float_t vectorGlob[3];
1045 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
1046 points->SetParticle(-1);
1047 points->SetHitIndex(-1);
1048 points->SetTrackIndex(-1);
1049 points->SetDigitIndex(digit);
1050 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
1051 //printf("Y position (digit): %f\n", vectorGlob[1]);
1053 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1054 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
1055 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
1056 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
1057 dpy/2,0,dpx/2,theta,phi);
1058 marker->SetLineColor(2);
1059 marker->SetFillStyle(1001);
1060 marker->SetFillColor(color);
1061 marker->SetRefObject((TObject*)points);
1062 points->Set3DMarker(0, marker);
1063 } // loop over digits
1064 } // loop over chambers
1069 //___________________________________________
1070 void AliRICHDisplay::LoadHits(Int_t chamber)
1072 // Read hits info and store x,y,z info in arrays fPhits
1073 // Loop on all detectors
1079 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1080 AliRICHChamber* iChamber;
1082 iChamber = &(pRICH->Chamber(chamber-1));
1083 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1086 if (fPhits == 0) fPhits = new TObjArray(ntracks);
1087 //TVector *xp = new TVector(1000);
1088 //TVector *yp = new TVector(1000);
1089 //TVector *zp = new TVector(1000);
1090 //TVector *ptrk = new TVector(1000);
1091 //TVector *phit = new TVector(1000);
1093 for (track=0; track<ntracks;track++) {
1094 gAlice->ResetHits();
1095 gAlice->TreeH()->GetEvent(track);
1096 TClonesArray *pRICHhits = pRICH->Hits();
1097 if (pRICHhits == 0) return;
1098 Int_t nhits = pRICHhits->GetEntriesFast();
1102 fPhits = new TObjArray(nAllHits);
1105 for (track=0; track<ntracks;track++) {
1106 gAlice->ResetHits();
1107 gAlice->TreeH()->GetEvent(track);
1108 TClonesArray *pRICHhits = pRICH->Hits();
1109 if (pRICHhits == 0) return;
1110 Int_t nhits = pRICHhits->GetEntriesFast();
1111 if (nhits == 0) continue;
1113 AliRICHPoints *points = 0;
1114 for (Int_t hit=0;hit<nhits;hit++) {
1115 points = new AliRICHPoints(1);
1116 fPhits->AddAt(points,npoints);
1117 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
1118 TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
1119 if (current->GetPdgCode() == 50000050) {
1120 points->SetMarkerColor(kBlue);
1121 } else if (current->GetPdgCode() == 50000051) {
1122 points->SetMarkerColor(kYellow);
1124 points->SetMarkerColor(kRed);
1126 points->SetMarkerStyle(5);
1127 points->SetMarkerSize(1.);
1128 points->SetParticle(mHit->Track());
1129 points->SetHitIndex(hit);
1130 points->SetTrackIndex(track);
1131 points->SetDigitIndex(-1);
1132 points->SetPoint(0,mHit->X(), mHit->Y(), mHit->Z());
1138 //_____________________________________________________________________________
1140 void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1142 // Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1143 // Loop on all detectors
1148 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
1149 AliRICHChamber* iChamber;
1151 iChamber = &(pRICH->Chamber(chamber-1));
1153 pRICH->SetTreeAddress();
1154 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1156 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1157 TVector *xp = new TVector(1000);
1158 TVector *yp = new TVector(1000);
1159 TVector *zp = new TVector(1000);
1160 TVector *ptrk = new TVector(1000);
1161 TVector *phit = new TVector(1000);
1162 for (Int_t track=0; track<ntracks;track++) {
1163 gAlice->ResetHits();
1164 gAlice->TreeH()->GetEvent(track);
1165 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1166 if (pRICHCerenkovs == 0) return;
1167 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
1168 if (nhits == 0) continue;
1169 AliRICHCerenkov *mCerenkov;
1170 AliRICHPoints *cpoints = 0;
1174 //Display Cerenkov hits in blue
1176 for (Int_t hit=0;hit<nhits;hit++) {
1177 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
1178 (*xp)(npoints)=mCerenkov->X();
1179 (*yp)(npoints)=mCerenkov->Y();
1180 (*zp)(npoints)=mCerenkov->Z();
1181 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1182 (*phit)(npoints)=Float_t(hit);
1185 if (npoints == 0) continue;
1186 cpoints = new AliRICHPoints(npoints);
1187 for (Int_t p=0;p<npoints;p++) {
1188 cpoints->SetMarkerColor(kBlue);
1189 cpoints->SetMarkerStyle(5);
1190 cpoints->SetMarkerSize(1.);
1191 cpoints->SetParticle(Int_t((*ptrk)(p)));
1192 cpoints->SetHitIndex(Int_t((*phit)(p)));
1193 cpoints->SetTrackIndex(track);
1194 cpoints->SetDigitIndex(-1);
1195 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1201 fPCerenkovs->AddAt(cpoints,track);
1205 //_____________________________________________________________________________
1206 void AliRICHDisplay::Paint(Option_t *)
1208 // Paint miscellaneous items
1212 //_____________________________________________________________________________
1213 void AliRICHDisplay::SetPickMode()
1220 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1221 fTrigPad->Modified();
1224 //_____________________________________________________________________________
1225 void AliRICHDisplay::SetZoomMode()
1232 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1233 fTrigPad->Modified();
1236 //_____________________________________________________________________________
1237 void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1239 // Set chamber and cathode number
1243 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1250 //_____________________________________________________________________________
1251 void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1253 // Set view range along R and Z
1262 //_____________________________________________________________________________
1263 void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1265 // change viewing angles for current event
1273 TView *view = gPad->GetView();
1274 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1280 //_____________________________________________________________________________
1281 void AliRICHDisplay::ShowNextEvent(Int_t delta)
1283 // Display (current event_number+delta)
1284 // delta = 1 shown next event
1285 // delta = -1 show previous event
1289 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1290 Int_t newEvent = currentEvent + delta;
1291 gAlice->GetEvent(newEvent);
1292 if (!gAlice->TreeD()) return;
1302 //______________________________________________________________________________
1303 void AliRICHDisplay::UnZoom()
1306 // Return to previous zoom factor
1308 if (fZooms <= 0) return;
1310 TPad *pad = (TPad*)gPad->GetPadSave();
1311 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1315 //_____________________________________________________________________________
1316 void AliRICHDisplay::ResetPoints()
1319 // Reset array of points
1327 //_____________________________________________________________________________
1328 void AliRICHDisplay::ResetRpoints()
1331 // Reset array of points
1339 //_____________________________________________________________________________
1340 void AliRICHDisplay::ResetRecpoints()
1343 // Reset array of points
1346 fRecpoints->Delete();
1351 //_____________________________________________________________________________
1352 void AliRICHDisplay::ResetPhits()
1355 // Reset array of points
1363 //_____________________________________________________________________________
1364 void AliRICHDisplay::ResetPCerenkovs()
1367 // Reset array of points
1370 fPCerenkovs->Delete();
1376 //_____________________________________________________________________________
1378 void AliRICHDisplay::DrawViewGL()
1380 // Draw current view using OPENGL
1382 TPad *pad = (TPad*)gPad->GetPadSave();
1384 TView *view = pad->GetView();
1389 //_____________________________________________________________________________
1390 void AliRICHDisplay::DrawViewX3D()
1392 // Draw current view using X3D
1394 TPad *pad = (TPad*)gPad->GetPadSave();
1396 TView *view = pad->GetView();