]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHDisplay.cxx
Correct log and Id tag.
[u/mrichter/AliRoot.git] / RICH / AliRICHDisplay.cxx
CommitLineData
8278a469 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17 $Log$
237c933d 18 Revision 1.3 2000/06/09 14:52:08 jbarbosa
19 New tentative ellipse drawing routine
20
0976a54b 21 Revision 1.1 2000/04/19 13:07:45 morsch
22 Digits, clusters and reconstruction results added.
23
8278a469 24*/
25
26
27//////////////////////////////////////////////////////////////////////////
28// //
29// AliDisplay //
30// //
31// Utility class to display ALICE outline, tracks, hits,.. //
32// //
33//////////////////////////////////////////////////////////////////////////
34
35#include <TROOT.h>
36#include <TTree.h>
37#include <TButton.h>
38#include <TColor.h>
39#include <TCanvas.h>
40#include <TView.h>
41#include <TText.h>
42#include <TPolyMarker3D.h>
43#include <TPolyMarker.h>
44#include <TPaveLabel.h>
45#include <TPaveText.h>
46#include <TList.h>
47#include <TDiamond.h>
48#include <TNode.h>
49#include <TArc.h>
50#include <TTUBE.h>
51#include <TSlider.h>
52#include <TSliderBox.h>
53#include <TGaxis.h>
54#include <TVirtualX.h>
55#include <TMath.h>
56#include <TRandom.h>
57#include <X3DBuffer.h>
237c933d 58#include <TParticle.h>
8278a469 59
60#include "AliRun.h"
61#include "AliPDG.h"
62#include "AliDetector.h"
63#include "AliRICH.h"
64#include "AliRICHConst.h"
65#include "AliRICHDisplay.h"
66#include "AliRICHPoints.h"
8278a469 67
237c933d 68#include "AliRICHHit.h"
69#include "AliRICHCerenkov.h"
70#include "AliRICHPadHit.h"
71#include "AliRICHDigit.h"
72#include "AliRICHRawCluster.h"
73#include "AliRICHRecHit.h"
74#include "AliRICHEllipse.h"
8278a469 75
76ClassImp(AliRICHDisplay)
77
78
79//____________________________________________________________________________
80AliRICHDisplay::AliRICHDisplay()
81{
237c933d 82
83// default constructor
84
8278a469 85 fPoints = 0;
86 fPhits = 0;
87 fPCerenkovs = 0;
88 fCanvas = 0;
89 fRpoints = 0;
90 fRecpoints = 0;
91}
92
93//_____________________________________________________________________________
94AliRICHDisplay::AliRICHDisplay(Int_t size)
95{
96// Create an event display object.
97// A canvas named "edisplay" is created with a vertical size in pixels
98//
99// A QUICK Overview of the Event Display functions
100// ===============================================
101//
102// The event display can ve invoked by executing the macro "display.C"
103// A canvas like in the picture below will appear.
104//
105// On the left side of the canvas, the following buttons appear:
106// *Next* to move to the next event
107// *Previous* to move to the previous event
108
109// *Pick* Select this option to be able to point on a track with the
110// mouse. Once on the track, use the right button to select
111// an action. For example, select SetMarkerAttributes to
112// change the marker type/color/size for the track.
113// *Zoom* Select this option (default) if you want to zoom.
114// To zoom, simply select the selected area with the left button.
115// *UnZoom* To revert to the previous picture size.
116//
117// slider R On the left side, the vertical slider can be used to
118// set the default picture size.
119//
120// When you are in Zoom mode, you can click on the black part of the canvas
121// to select special options with the right mouse button.
122
123//
124// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
125// When you are on a track, select the menu item "InspectParticle"
126// to display the current particle attributes.
127//
128// You can activate the Root browser by selecting the Inspect menu
129// in the canvas tool bar menu. Then select "Start Browser"
130// This will open a new canvas with the browser. At this point, you may want
131// to display some histograms (from the Trees). Go to the "File" menu
132// of the browser and click on "New canvas".
133// In the browser, click on item "ROOT files" in the left pane.
134// Click on galice.root.
135// Click on TH
136// Click on TPC for example
137// Click on any variable (eg TPC.fX) to histogram the variable.
138//
139// If you are lost, you can click on HELP in any Root canvas or browser.
140//Begin_Html
141/*
142 <img src="gif/AliRICHDisplay.gif">
143*/
144//End_Html
145
146
147 fPad = 0;
148
149 gAlice->SetDisplay(this);
150
151 // Initialize display default parameters
152 SetRange();
153
154 // Set front view by default
155 fTheta = 90;
156 fPhi = 90;
157 fPsi = 0;
158 fChamber = 1;
159 fCathode = 1;
160 // fRzone = 1.e10;
161 fDrawClusters = kTRUE;
162 fDrawCoG = kTRUE;
163 fDrawRecHits = kTRUE;
164 fZoomMode = 1;
165 fZooms = 0;
166 fClustersCuts = 0;
167 fPoints = 0;
168 fPCerenkovs = 0;
169 fPhits = 0;
170 fRpoints = 0;
171 fRecpoints = 0;
172 // Create colors
173 CreateColors();
174 // Create display canvas
175 Int_t ysize = size;
176 if (ysize < 100) ysize = 750;
177 Int_t xsize = Int_t(size*830./ysize);
178 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
179 fCanvas->ToggleEventStatus();
180
181 // Create main display pad
182 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
183 fPad->Draw();
184 fPad->Modified();
185 fPad->SetFillColor(1);
186 fPad->SetBorderSize(2);
187
188 fCanvas->cd();
189
190 // Create colors pad
191 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
192 fColPad->Draw();
193 fColPad->Modified();
194 fColPad->SetFillColor(19);
195 fColPad->SetBorderSize(2);
196 fColPad->cd();
197 DisplayColorScale();
198
199 fCanvas->cd();
200
201 // Create user interface control pad
202 DisplayButtons();
203 fCanvas->cd();
204
205 // Create Range and mode pad
206 Float_t dxtr = 0.15;
207 Float_t dytr = 0.45;
208 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
209 fTrigPad->SetEditable(kFALSE);
210 fTrigPad->Draw();
211 fTrigPad->cd();
212 fTrigPad->SetFillColor(22);
213 fTrigPad->SetBorderSize(2);
214 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
215 fRangeSlider->SetObject(this);
216 char pickmode[] = "gAlice->Display()->SetPickMode()";
217 Float_t db = 0.09;
218 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
219 fPickButton->SetFillColor(38);
220 fPickButton->Draw();
221 char zoommode[] = "gAlice->Display()->SetZoomMode()";
222 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
223 fZoomButton->SetFillColor(38);
224 fZoomButton->Draw();
225 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
226 fArcButton->SetFillColor(kGreen);
227 fArcButton->Draw();
228 char butUnzoom[] = "gAlice->Display()->UnZoom()";
229 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
230 button->SetFillColor(38);
231 button->Draw();
232 AppendPad(); // append display object as last object to force selection
233
234 fCanvas->cd();
235 fCanvas->Update();
236}
237
238
239//_____________________________________________________________________________
240AliRICHDisplay::~AliRICHDisplay()
241{
242 // Delete space point structure
243 if (fPoints) fPoints->Delete();
244 delete fPoints;
245 fPoints = 0;
246 //
247 if (fPhits) fPhits->Delete();
248 delete fPhits;
249 fPhits = 0;
250 //
251 if (fRpoints) fRpoints->Delete();
252 delete fRpoints;
253 fRpoints = 0;
254 //
255 if (fRecpoints) fRecpoints->Delete();
256 delete fRecpoints;
257 fRecpoints = 0;
258 //
259 if (fPCerenkovs) fPCerenkovs->Delete();
260 delete fPCerenkovs;
261 fPCerenkovs = 0;
262}
263
264//_____________________________________________________________________________
265void AliRICHDisplay::Clear(Option_t *)
266{
267// Delete graphics temporary objects
268}
269
270//_____________________________________________________________________________
271void AliRICHDisplay::DisplayButtons()
272{
273// Create the user interface buttons
274
275
276 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
277 fButtons->SetEditable(kFALSE);
278 fButtons->Draw();
279 fButtons->SetFillColor(38);
280 fButtons->SetBorderSize(2);
281 fButtons->cd();
282
283 // Int_t butcolor = 33;
284 Float_t dbutton = 0.08;
285 Float_t y = 0.96;
286 Float_t dy = 0.014;
287 Float_t x0 = 0.05;
288 Float_t x1 = 0.95;
289
290 TButton *button;
291 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
292 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
293 button->SetFillColor(38);
294 button->Draw();
295
296 y -= dbutton +dy;
297 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
298 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
299 button->SetFillColor(38);
300 button->Draw();
301
302 y -= dbutton +dy;
303 char but7[] = "gAlice->Display()->DrawViewGL()";
304 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
305 button->SetFillColor(38);
306 button->Draw();
307
308 y -= dbutton +dy;
309 char but8[] = "gAlice->Display()->DrawViewX3D()";
310 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
311 button->SetFillColor(38);
312 button->Draw();
313
314 // display logo
315 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
316 diamond->SetFillColor(50);
317 diamond->SetTextAlign(22);
318 diamond->SetTextColor(5);
319 diamond->SetTextSize(0.11);
320 diamond->Draw();
321 diamond->AddText(".. ");
322 diamond->AddText("ROOT");
323 diamond->AddText("RICH");
324 diamond->AddText("... ");
325 diamond->AddText(" ");
326}
327
328//_____________________________________________________________________________
329void AliRICHDisplay::CreateColors()
330{
331// Create the colors palette used to display clusters
332
333 Int_t k,i;
334 Int_t color;
335 Float_t r,g,b;
336
337 for (k=1;k<=5;k++) {
338 switch(k) {
339 case 1:
340 for (i=1;i<=5;i++) {
341 r=1.;
342 g=i*0.2;
343 b=0.;
344 color=i;
345 color=700+23-color;
346 new TColor(color,r,g,b);
347 }
348 break;
349 case 2:
350 for (i=1;i<=4;i++) {
351 r=1.1-i*0.2;
352 g=1.;
353 b=0.;
354 color=i+5;
355 color=700+23-color;
356 new TColor(color,r,g,b);
357 }
358 break;
359 case 3:
360 for (i=1;i<=4;i++) {
361 r=0.;
362 g=1.;
363 b=i*0.2+0.2;
364 color=i+9;
365 color=700+23-color;
366 new TColor(color,r,g,b);
367 }
368 break;
369 case 4:
370 for (i=1;i<=4;i++) {
371 r=0.;
372 g=1.1-i*0.2;
373 b=1.;
374 color=i+13;
375 color=700+23-color;
376 new TColor(color,r,g,b);
377 }
378 break;
379 case 5:
380 for (i=1;i<=5;i++) {
381 r=i*0.2;
382 g=0.;
383 b=1.;
384 color=i+17;
385 color=700+23-color;
386 new TColor(color,r,g,b);
387 }
388 break;
389 }
390 }
391}
392
393//_____________________________________________________________________________
394void AliRICHDisplay::DisplayColorScale()
395{
237c933d 396
397// Draw the color scale in the RICH display canvas
8278a469 398
399 Int_t i;
400 Int_t color;
401 Float_t xlow, ylow, xup, yup, hs;
402 Float_t x1, y1, x2, y2;
403 x1 = y1 = 0;
404 x2 = y2 = 20;
405
406 gPad->SetFillColor(0);
407 gPad->Clear();
408 gPad->Range(x1,y1,x2,y2);
409 TText *text = new TText(0,0,"");
410 text->SetTextFont(61);
411 text->SetTextSize(0.03);
412 text->SetTextAlign(22);
413
414 TBox *box;
415 char label[8];
416//*-* draw colortable boxes
417 hs = (y2-y1)/Float_t(22);
418 xlow=x1+1;
419 xup=x2-9;
420 for (i=0;i<22;i++) {
421 ylow = y1 + hs*(Float_t(i));
422 yup = y1 + hs*(Float_t(i+1));
423 color = 701+i;
424 Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22);
425 Int_t scale=(Int_t)TMath::Exp(logscale);
426 sprintf(label,"%d",scale);
427 box = new TBox(xlow, ylow, xup, yup);
428 box->SetFillColor(color);
429 box->Draw();
430 text->DrawText(xup+4, 0.5*(ylow+yup),label);
431 }
432}
433
434//______________________________________________________________________________
435Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
436{
437// Compute distance from point px,py to objects in event
438
439 gPad->SetCursor(kCross);
440
441 if (gPad == fTrigPad) return 9999;
442
237c933d 443 const Int_t kBig = 9999;
444 Int_t dist = kBig;
8278a469 445 Float_t xmin = gPad->GetX1();
446 Float_t xmax = gPad->GetX2();
447 Float_t dx = 0.02*(xmax - xmin);
448 Float_t x = gPad->AbsPixeltoX(px);
449 if (x < xmin+dx || x > xmax-dx) return dist;
450 if (fZoomMode) return 0;
451 else return 7;
452}
453
454//_____________________________________________________________________________
455void AliRICHDisplay::Draw(Option_t *)
456{
457// Display current event
458
459 fPad->cd();
460
461 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
462
463 // Display the event number and title
464 fPad->cd();
465 DrawTitle();
466}
467
468//_____________________________________________________________________________
469void AliRICHDisplay::DrawCoG()
470{
471// Draw hits for RICH chambers
472
473 if (!fDrawCoG) return;
474 ResetRpoints();
237c933d 475 for (Int_t chamber=0;chamber<kNCH;chamber++) {
8278a469 476 LoadCoG(chamber,1);
477 }
478
479 Int_t ncog, icog;
480 TObjArray *points;
481 AliRICHPoints *pm;
482 points = fRpoints;
483 if (!points) return;
484 ncog = points->GetEntriesFast();
485 for (icog=0; icog < ncog; icog++) {
486 pm = (AliRICHPoints*)points->UncheckedAt(icog);
487 if (!pm) continue;
488 pm->Draw();
489 }
490}
491
492void AliRICHDisplay::DrawRecHits()
493{
494// Draw rec hits for RICH chambers
495
496 if (!fDrawRecHits) return;
497 //ResetRecpoints();
237c933d 498 for (Int_t chamber=0;chamber<kNCH;chamber++) {
8278a469 499 LoadRecHits(chamber,1);
500 }
501
502 Int_t nrec, irec;
503 TObjArray *points;
504 AliRICHPoints *pm;
505 points = fRecpoints;
506 if (!points) return;
507 nrec = points->GetEntriesFast();
508 printf("Nrec %d\n",nrec);
509 for (irec=0; irec < nrec; irec++) {
510 pm = (AliRICHPoints*)points->UncheckedAt(irec);
511 if (!pm) continue;
512 pm->Draw();
513 }
514}
515
516//_____________________________________________________________________________
517
518void AliRICHDisplay::DrawCerenkovs()
519{
520// Draw cerenkovs hits for RICH chambers
521
522 LoadCerenkovs(fChamber);
523 //printf("\nDrawCerenkovs\n");
524
525 Int_t ntracks, track;
526 TObjArray *cpoints;
527 AliRICHPoints *pm;
528
529 fHitsCuts = 0;
530 cpoints = fPCerenkovs;
531 //printf ("Cpoints: %p",cpoints);
532 if (!cpoints) return;
533 ntracks = cpoints->GetEntriesFast();
534 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
535 for (track=0;track<ntracks;track++) {
536 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
537 if (!pm) continue;
538 pm->Draw();
539 fHitsCuts += pm->GetN();
540 }
541}
542
543//_____________________________________________________________________________
544
545void AliRICHDisplay::DrawClusters()
546{
547// Draw clusterss for RICH chambers
548
549 Int_t ndigits, digit;
550 TObjArray *points;
551 AliRICHPoints *pm;
552
553 fClustersCuts = 0;
554 points = fPoints;
555 if (!points) return;
556 ndigits = points->GetEntriesFast();
557 for (digit=0;digit<ndigits;digit++){
558 pm = (AliRICHPoints*)points->UncheckedAt(digit);
559 if (!pm) continue;
560 pm->Draw();
561 Float_t *pxyz;
562 pxyz=pm->GetP();
563 for (Int_t im=0;im<3;im++) {
564 TMarker3DBox *marker=pm->GetMarker(im);
565 if (marker)
566 marker->Draw();
567 }
568 fClustersCuts +=pm->GetN();
569 }
570}
571
572//_____________________________________________________________________________
573void AliRICHDisplay::DrawHits()
574{
575// Draw hits for RICH chambers
576
577 LoadHits(fChamber);
578
579 Int_t ntracks, track;
580 TObjArray *points;
581 AliRICHPoints *pm;
582
583 fHitsCuts = 0;
584 points = Phits();
585 if (!fPhits) return;
586// ntracks = points->GetEntriesFast();
587 ntracks = fPhits->GetEntriesFast();
588
589 //printf("DrawHits - ntracks %d \n",ntracks);
590 for (track=0;track<ntracks;track++) {
591 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
592 if (!pm) continue;
593 pm->Draw();
594 fHitsCuts += pm->GetN();
595 }
596}
597
598
599//_____________________________________________________________________________
600void AliRICHDisplay::DrawTitle(Option_t *option)
601{
602// Draw the event title
603
604 Float_t xmin = gPad->GetX1();
605 Float_t xmax = gPad->GetX2();
606 Float_t ymin = gPad->GetY1();
607 Float_t ymax = gPad->GetY2();
608 Float_t dx = xmax-xmin;
609 Float_t dy = ymax-ymin;
610
611 if (strlen(option) == 0) {
612 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
613 title->SetBit(kCanDelete);
614 title->SetFillColor(42);
615 title->Draw();
616 char ptitle[100];
617 sprintf(ptitle,"Alice event: %d, Run:%d",
618 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
619 title->AddText(ptitle);
620 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
621 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
622 nparticles, fHitsCuts,fClustersCuts);
623 title->AddText(ptitle);
624 } else {
625 TPaveLabel *label =
626 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
627 label->SetBit(kCanDelete);
628 label->SetFillColor(42);
629 label->Draw();
630 }
631}
632
633//_____________________________________________________________________________
634void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
635{
636// Draw a view of RICH clusters
637
638 gPad->SetCursor(kWatch);
639 gPad->SetFillColor(1);
640 gPad->Clear();
641
642 Int_t iret;
643 TView *view = new TView(1);
644 Float_t range = fRrange*fRangeSlider->GetMaximum();
645 view->SetRange(-range,-range,-range,range, range, range);
646 fZoomX0[0] = -1;
647 fZoomY0[0] = -1;
648 fZoomX1[0] = 1;
649 fZoomY1[0] = 1;
650 fZooms = 0;
651
652 //Display RICH Chamber Geometry
653 gAlice->GetGeometry()->Draw("same");
654
655 //add clusters to the pad
656 DrawClusters();
657 DrawHits();
658// DrawCerenkovs();
659 printf("Calling DrawCoG\n");
660 DrawCoG();
661 printf("Calling DrawRecHits\n");
662 DrawRecHits();
663 /*for (Int_t i=0;i<7;i++)
664 LoadRecHits(i,1);*/
665
666 // add itself to the list (must be last)
667 AppendPad();
668
669 view->SetView(phi, theta, psi, iret);
670}
671
672//______________________________________________________________________________
673void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
674{
675// Execute action corresponding to the mouse event
676
677 static Float_t x0, y0, x1, y1;
678
679 static Int_t pxold, pyold;
680 static Int_t px0, py0;
681 static Int_t linedrawn;
682 Float_t temp;
683
684 if (px == 0 && py == 0) { //when called by sliders
685 if (event == kButton1Up) {
686 Draw();
687 }
688 return;
689 }
690 if (!fZoomMode && gPad->GetView()) {
691 gPad->GetView()->ExecuteRotateView(event, px, py);
692 return;
693 }
694
695 // something to zoom ?
696 gPad->SetCursor(kCross);
697
698 switch (event) {
699
700 case kButton1Down:
701 gVirtualX->SetLineColor(-1);
702 gPad->TAttLine::Modify(); //Change line attributes only if necessary
703 x0 = gPad->AbsPixeltoX(px);
704 y0 = gPad->AbsPixeltoY(py);
705 px0 = px; py0 = py;
706 pxold = px; pyold = py;
707 linedrawn = 0;
708 return;
709
710 case kButton1Motion:
711 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
712 pxold = px;
713 pyold = py;
714 linedrawn = 1;
715 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
716 return;
717
718 case kButton1Up:
719 gPad->GetCanvas()->FeedbackMode(kFALSE);
720 if (px == px0) return;
721 if (py == py0) return;
722 x1 = gPad->AbsPixeltoX(px);
723 y1 = gPad->AbsPixeltoY(py);
724
725 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
726 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
727 gPad->Range(x0,y0,x1,y1);
728 if (fZooms < kMAXZOOM-1) {
729 fZooms++;
730 fZoomX0[fZooms] = x0;
731 fZoomY0[fZooms] = y0;
732 fZoomX1[fZooms] = x1;
733 fZoomY1[fZooms] = y1;
734 }
735 gPad->Modified(kTRUE);
736 return;
737 }
738
739}
740//___________________________________________
741void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
742{
743// Read raw clusters info and store x,y,z info in arrays fRpoints
744// Loop on all detectors
745
746 if (chamber > 6) return;
747
748 printf("Entering LoadCoG\n");
749
750
237c933d 751 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
8278a469 752 AliRICHChamber* iChamber;
753
237c933d 754 TClonesArray *pRICHrawclust = pRICH->RawClustAddress(chamber);
755 printf ("Chamber:%d has adress:%p\n", chamber, pRICHrawclust );
756 if (pRICHrawclust == 0) return;
8278a469 757
237c933d 758 pRICH->ResetRawClusters();
8278a469 759
760
761 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
762 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
237c933d 763 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
8278a469 764 printf ("nrawcl:%d\n",nrawcl);
765 if (nrawcl == 0) return;
766 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
767
237c933d 768 iChamber = &(pRICH->Chamber(chamber));
8278a469 769 AliRICHRawCluster *mRaw;
770 AliRICHPoints *points = 0;
771 //
772 //loop over all raw clusters and store their position
773 points = new AliRICHPoints(nrawcl);
774 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
237c933d 775 mRaw = (AliRICHRawCluster*)pRICHrawclust->UncheckedAt(iraw);
8278a469 776 fRpoints->AddAt(points,iraw);
777 points->SetMarkerColor(3);
778 points->SetMarkerStyle(3);
779 points->SetMarkerSize(1.);
780 points->SetParticle(-1);
781 points->SetHitIndex(-1);
782 points->SetTrackIndex(-1);
783 points->SetDigitIndex(-1);
237c933d 784 Float_t vectorLoc[3]={mRaw->fX,6.276,mRaw->fY};
785 Float_t vectorGlob[3];
786 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
787 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
8278a469 788 }
789}
790//___________________________________________
791void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
792{
793// Read rec. hits info
794// Loop on all detectors
795
796 if (chamber > 6) return;
797
798 printf("Entering LoadRecHits\n");
799
800
237c933d 801 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
8278a469 802 AliRICHChamber* iChamber;
803
237c933d 804 TClonesArray *pRICHrechits = pRICH->RecHitsAddress(chamber);
805 printf ("Chamber:%d has adress:%p\n", chamber, pRICHrechits );
806 if (pRICHrechits == 0) return;
8278a469 807
808 //RICH->ResetRecHits();
809
810
811 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
812 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
237c933d 813 Int_t nrechits = pRICHrechits->GetEntriesFast();
8278a469 814 printf ("nrechits:%d\n",nrechits);
815 if (nrechits == 0) return;
0976a54b 816 if (fRecpoints == 0) fRecpoints = new TObjArray(50);
8278a469 817
237c933d 818 iChamber = &(pRICH->Chamber(chamber));
8278a469 819 AliRICHRecHit *mRec;
820 AliRICHPoints *points = 0;
821 //AliRICHEllipse *ellipse = 0;
822 //
823 //loop over all rechits and store their position
824
825 points = new AliRICHPoints(nrechits);
826 for (Int_t irec=0;irec<nrechits;irec++) {
237c933d 827 mRec = (AliRICHRecHit*)pRICHrechits->UncheckedAt(irec);
8278a469 828 fRecpoints->AddAt(points,irec);
829 points->SetMarkerColor(38);
830 points->SetMarkerStyle(8);
831 points->SetMarkerSize(1.);
832 points->SetParticle(-1);
833 points->SetHitIndex(-1);
834 points->SetTrackIndex(-1);
835 points->SetDigitIndex(-1);
237c933d 836 Float_t vectorLoc[3]={mRec->fX,6.276,mRec->fY};
837 Float_t vectorGlob[3];
838 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
839 points->SetPoint(irec,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
8278a469 840 //Float_t theta = iChamber->GetRotMatrix()->GetTheta();
841 //Float_t phi = iChamber->GetRotMatrix()->GetPhi();
237c933d 842 //ellipse=new TEllipse(vectorGlob[0],vectorGlob[2],10,10,0,360,phi);
8278a469 843 printf("Generating ellipse %d\n",irec);
237c933d 844 AliRICHEllipse *ellipse=new AliRICHEllipse(mRec->fX,mRec->fY,mRec->fOmega,mRec->fTheta,mRec->fPhi);
8278a469 845 ellipse->CreatePoints(chamber);
846 //ellipse->SetFillStyle(1001);
847 ellipse->SetMarkerColor(38);
848 ellipse->Draw();
849 //marker->SetRefObject((TObject*)points);
850 //points->Set3DMarker(0, marker);
851 }
852}
853//___________________________________________
854void AliRICHDisplay::LoadDigits()
855{
856// Read digits info and store x,y,z info in arrays fPoints
857// Loop on all detectors
858
859 ResetPoints();
237c933d 860 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
8278a469 861 AliRICHChamber* iChamber;
862 AliRICHSegmentation* segmentation;
237c933d 863 Int_t nAllDigits=0;
8278a469 864 Int_t ich;
865
237c933d 866 for (ich=0; ich<kNCH; ich++) {
867 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
868 if (pRICHdigits == 0) continue;
8278a469 869 gAlice->ResetDigits();
870 gAlice->TreeD()->GetEvent(1);
237c933d 871 Int_t ndigits = pRICHdigits->GetEntriesFast();
872 nAllDigits+=ndigits;
8278a469 873 }
237c933d 874 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
8278a469 875 Int_t counter=0;
237c933d 876 for (ich=0; ich<kNCH; ich++) {
877 TClonesArray *pRICHdigits = pRICH->DigitsAddress(ich);
878 if (pRICHdigits == 0) continue;
8278a469 879 gAlice->ResetDigits();
880 gAlice->TreeD()->GetEvent(1);
237c933d 881 Int_t ndigits = pRICHdigits->GetEntriesFast();
8278a469 882 if (ndigits == 0) continue;
237c933d 883 iChamber = &(pRICH->Chamber(ich));
8278a469 884 segmentation=iChamber->GetSegmentationModel();
885 Float_t dpx = segmentation->Dpx();
886 Float_t dpy = segmentation->Dpy();
887
888 //printf("Dpx:%d, Dpy:%d\n",dpx,dpy);
889
890 AliRICHDigit *mdig;
891 AliRICHPoints *points = 0;
892 TMarker3DBox *marker = 0;
893 //
894 //loop over all digits and store their position
895 Int_t npoints=1;
896
897 for (Int_t digit=0;digit<ndigits;digit++) {
237c933d 898 mdig = (AliRICHDigit*)pRICHdigits->UncheckedAt(digit);
8278a469 899 points = new AliRICHPoints(npoints);
900 fPoints->AddAt(points,counter);
901 counter++;
902 Int_t charge=mdig->fSignal;
903 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
904 Int_t color=701+index;
905 if (color>722) color=722;
906 points->SetMarkerColor(color);
907 points->SetMarkerStyle(21);
908 points->SetMarkerSize(0.5);
909 Float_t xpad, ypad;
910 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
237c933d 911 Float_t vectorLoc[3]={xpad,6.276,ypad};
912 Float_t vectorGlob[3];
913 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
8278a469 914 points->SetParticle(-1);
915 points->SetHitIndex(-1);
916 points->SetTrackIndex(-1);
917 points->SetDigitIndex(digit);
237c933d 918 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
8278a469 919
920 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY, xpad, ypad);
921 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
922 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
237c933d 923 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
8278a469 924 dpy/2,0,dpx/2,theta,phi);
925 marker->SetLineColor(2);
926 marker->SetFillStyle(1001);
927 marker->SetFillColor(color);
928 marker->SetRefObject((TObject*)points);
929 points->Set3DMarker(0, marker);
930 } // loop over digits
931 } // loop over chambers
932}
933
934
935//___________________________________________
936void AliRICHDisplay::LoadHits(Int_t chamber)
937{
938// Read hits info and store x,y,z info in arrays fPhits
939// Loop on all detectors
940
941
942 fChamber=chamber;
943 ResetPhits();
944
237c933d 945 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
8278a469 946 AliRICHChamber* iChamber;
947
237c933d 948 iChamber = &(pRICH->Chamber(chamber-1));
8278a469 949 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
950 Int_t track;
951
952 if (fPhits == 0) fPhits = new TObjArray(ntracks);
953 //TVector *xp = new TVector(1000);
954 //TVector *yp = new TVector(1000);
955 //TVector *zp = new TVector(1000);
956 //TVector *ptrk = new TVector(1000);
957 //TVector *phit = new TVector(1000);
237c933d 958 Int_t nAllHits=0;
8278a469 959 for (track=0; track<ntracks;track++) {
960 gAlice->ResetHits();
961 gAlice->TreeH()->GetEvent(track);
237c933d 962 TClonesArray *pRICHhits = pRICH->Hits();
963 if (pRICHhits == 0) return;
964 Int_t nhits = pRICHhits->GetEntriesFast();
965 nAllHits+=nhits;
8278a469 966 }
967
237c933d 968 fPhits = new TObjArray(nAllHits);
8278a469 969
970 Int_t npoints=0;
971 for (track=0; track<ntracks;track++) {
972 gAlice->ResetHits();
973 gAlice->TreeH()->GetEvent(track);
237c933d 974 TClonesArray *pRICHhits = pRICH->Hits();
975 if (pRICHhits == 0) return;
976 Int_t nhits = pRICHhits->GetEntriesFast();
8278a469 977 if (nhits == 0) continue;
978 AliRICHHit *mHit;
979 AliRICHPoints *points = 0;
980 for (Int_t hit=0;hit<nhits;hit++) {
981 points = new AliRICHPoints(1);
982 fPhits->AddAt(points,npoints);
237c933d 983 mHit = (AliRICHHit*)pRICHhits->UncheckedAt(hit);
8278a469 984 TParticle *current =
985 (TParticle*)(*gAlice->Particles())[mHit->fTrack];
986 if (current->GetPdgCode() == 50000050) {
987 points->SetMarkerColor(kBlue);
988 } else if (current->GetPdgCode() == 50000051) {
989 points->SetMarkerColor(kYellow);
990 } else {
991 points->SetMarkerColor(kRed);
992 }
993 points->SetMarkerStyle(5);
994 points->SetMarkerSize(1.);
0976a54b 995 points->SetParticle(mHit->fTrack);
8278a469 996 points->SetHitIndex(hit);
0976a54b 997 points->SetTrackIndex(track);
8278a469 998 points->SetDigitIndex(-1);
999 points->SetPoint(hit,mHit->fX, mHit->fY, mHit->fZ);
1000 npoints++;
1001 }
1002 }
1003}
1004
1005//_____________________________________________________________________________
1006
1007void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
1008{
1009// Read cerenkov hits info and store x,y,z info in array fPCerenkovs
1010// Loop on all detectors
1011
1012 fChamber=chamber;
1013 ResetPCerenkovs();
1014
237c933d 1015 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
8278a469 1016 AliRICHChamber* iChamber;
1017
237c933d 1018 iChamber = &(pRICH->Chamber(chamber-1));
8278a469 1019
237c933d 1020 pRICH->SetTreeAddress();
8278a469 1021 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
1022
1023 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
1024 TVector *xp = new TVector(1000);
1025 TVector *yp = new TVector(1000);
1026 TVector *zp = new TVector(1000);
1027 TVector *ptrk = new TVector(1000);
1028 TVector *phit = new TVector(1000);
1029 for (Int_t track=0; track<ntracks;track++) {
1030 gAlice->ResetHits();
1031 gAlice->TreeH()->GetEvent(track);
237c933d 1032 TClonesArray *pRICHCerenkovs = pRICH->Cerenkovs();
1033 if (pRICHCerenkovs == 0) return;
1034 Int_t nhits = pRICHCerenkovs->GetEntriesFast();
8278a469 1035 if (nhits == 0) continue;
1036 AliRICHCerenkov *mCerenkov;
1037 AliRICHPoints *cpoints = 0;
1038 Int_t npoints=0;
1039
1040
1041//Display Cerenkov hits in blue
1042
1043 for (Int_t hit=0;hit<nhits;hit++) {
237c933d 1044 mCerenkov = (AliRICHCerenkov*)pRICHCerenkovs->UncheckedAt(hit);
8278a469 1045 (*xp)(npoints)=mCerenkov->fX;
1046 (*yp)(npoints)=mCerenkov->fY;
1047 (*zp)(npoints)=mCerenkov->fZ;
1048 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
1049 (*phit)(npoints)=Float_t(hit);
1050 npoints++;
1051 }
1052 if (npoints == 0) continue;
1053 cpoints = new AliRICHPoints(npoints);
1054 for (Int_t p=0;p<npoints;p++) {
1055 cpoints->SetMarkerColor(kBlue);
1056 cpoints->SetMarkerStyle(5);
1057 cpoints->SetMarkerSize(1.);
1058 cpoints->SetParticle(Int_t((*ptrk)(p)));
1059 cpoints->SetHitIndex(Int_t((*phit)(p)));
1060 cpoints->SetTrackIndex(track);
1061 cpoints->SetDigitIndex(-1);
1062 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
1063 }
1064 xp->Zero();
1065 yp->Zero();
1066 ptrk->Zero();
1067 phit->Zero();
1068 fPCerenkovs->AddAt(cpoints,track);
1069 }
1070}
1071
1072//_____________________________________________________________________________
1073void AliRICHDisplay::Paint(Option_t *)
1074{
1075// Paint miscellaneous items
1076
1077}
1078
1079//_____________________________________________________________________________
1080void AliRICHDisplay::SetPickMode()
1081{
237c933d 1082
1083// Toggle pick mode
1084
8278a469 1085 fZoomMode = 0;
1086
1087 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1088 fTrigPad->Modified();
1089}
1090
1091//_____________________________________________________________________________
1092void AliRICHDisplay::SetZoomMode()
1093{
237c933d 1094
1095// Toggle Zoom mode
1096
8278a469 1097 fZoomMode = 1;
1098
1099 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1100 fTrigPad->Modified();
1101}
1102
1103//_____________________________________________________________________________
1104void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1105{
1106// Set chamber and cathode number
1107 fChamber = chamber;
1108 fCathode = cathode;
1109
1110 printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
1111 if (!fPad) return;
1112 fPad->Clear();
1113 LoadDigits();
1114 Draw();
1115}
1116
1117//_____________________________________________________________________________
1118void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
1119{
1120// Set view range along R and Z
1121 fRrange = rrange;
1122 fZrange = zrange;
1123
1124 if (!fPad) return;
1125 fPad->Clear();
1126 Draw();
1127}
1128
1129//_____________________________________________________________________________
1130void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1131{
1132// change viewing angles for current event
1133
1134 fPad->cd();
1135 fPhi = phi;
1136 fTheta = theta;
1137 fPsi = psi;
1138 Int_t iret = 0;
1139
1140 TView *view = gPad->GetView();
1141 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1142 else Draw();
1143
1144 gPad->Modified();
1145}
1146
1147//_____________________________________________________________________________
1148void AliRICHDisplay::ShowNextEvent(Int_t delta)
1149{
1150// Display (current event_number+delta)
1151// delta = 1 shown next event
1152// delta = -1 show previous event
1153
1154 if (delta) {
1155 gAlice->Clear();
237c933d 1156 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
1157 Int_t newEvent = currentEvent + delta;
1158 gAlice->GetEvent(newEvent);
8278a469 1159 if (!gAlice->TreeD()) return;
1160 }
1161 LoadDigits();
1162 DrawClusters();
1163 fPad->cd();
1164 Draw();
1165
1166
1167}
1168
1169//______________________________________________________________________________
1170void AliRICHDisplay::UnZoom()
1171{
237c933d 1172
1173// Return to previous zoom factor
1174
8278a469 1175 if (fZooms <= 0) return;
1176 fZooms--;
1177 TPad *pad = (TPad*)gPad->GetPadSave();
1178 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1179 pad->Modified();
1180}
1181
1182//_____________________________________________________________________________
1183void AliRICHDisplay::ResetPoints()
1184{
1185 //
1186 // Reset array of points
1187 //
1188 if (fPoints) {
1189 fPoints->Delete();
1190 delete fPoints;
1191 fPoints = 0;
1192 }
1193}
1194//_____________________________________________________________________________
1195void AliRICHDisplay::ResetRpoints()
1196{
1197 //
1198 // Reset array of points
1199 //
1200 if (fRpoints) {
1201 fRpoints->Delete();
1202 delete fRpoints;
1203 fRpoints = 0;
1204 }
1205}
1206//_____________________________________________________________________________
1207void AliRICHDisplay::ResetRecpoints()
1208{
1209 //
1210 // Reset array of points
1211 //
1212 if (fRecpoints) {
1213 fRecpoints->Delete();
1214 delete fRecpoints;
1215 fRecpoints = 0;
1216 }
1217}
1218//_____________________________________________________________________________
1219void AliRICHDisplay::ResetPhits()
1220{
1221 //
1222 // Reset array of points
1223 //
1224 if (fPhits) {
1225 fPhits->Delete();
1226 delete fPhits;
1227 fPhits = 0;
1228 }
1229}
1230//_____________________________________________________________________________
1231void AliRICHDisplay::ResetPCerenkovs()
1232{
1233 //
1234 // Reset array of points
1235 //
1236 if (fPCerenkovs) {
1237 fPCerenkovs->Delete();
1238 delete fPCerenkovs;
1239 fPCerenkovs = 0;
1240 }
1241}
1242
1243//_____________________________________________________________________________
1244
1245void AliRICHDisplay::DrawViewGL()
1246{
1247// Draw current view using OPENGL
1248
1249 TPad *pad = (TPad*)gPad->GetPadSave();
1250 pad->cd();
1251 TView *view = pad->GetView();
1252 if (!view) return;
1253 pad->x3d("OPENGL");
1254}
1255
1256//_____________________________________________________________________________
1257void AliRICHDisplay::DrawViewX3D()
1258{
1259// Draw current view using X3D
1260
1261 TPad *pad = (TPad*)gPad->GetPadSave();
1262 pad->cd();
1263 TView *view = pad->GetView();
1264 if (!view) return;
1265 pad->x3d();
1266}