2 //////////////////////////////////////////////////////////////////////////
6 // Utility class to display ALICE outline, tracks, clusters, jets,.. //
8 //////////////////////////////////////////////////////////////////////////
16 #include <TPaveLabel.h>
17 #include <TPaveText.h>
23 #include <X3DBuffer.h>
25 #include "AliFDisplay.h"
26 #include "AliFFruit.h"
27 #include "AliFParticle.h"
29 #include "AliFMCMaker.h"
35 //_____________________________________________________________________________
36 AliFDisplay::AliFDisplay() : AliFVirtualDisplay()
42 //_____________________________________________________________________________
43 AliFDisplay::AliFDisplay(const char *title) : AliFVirtualDisplay()
46 gAliFast->SetDisplay(this);
48 // Initialize display default parameters
53 // Set front view by default
56 fDrawAllViews = kFALSE;
57 fDrawParticles = kTRUE;
59 // Create display canvas
60 fCanvas = new TCanvas("Canvas", (char*)title,14,47,740,650);
61 fCanvas->SetEditable(kIsNotEditable);
63 // Create main display pad
64 fPad = new TPad("viewpad", "AliFast display",0.15,0,1,1);
67 fPad->SetFillColor(1);
68 fPad->SetBorderSize(2);
70 // Create user interface control pad
74 // Create trigger view pad
77 Float_t xt = 0.3*dxtr;
78 Float_t yt = 0.8*dytr;
79 Float_t dyt = 0.07*dytr;
80 Float_t xarc = 0.7*dxtr;
81 Float_t rarc = 0.3*dyt;
82 fTrigPad = new TPad("TrigPad", "trigger pad",0,0,dxtr,dytr);
83 fTrigPad->Range(0,0,dxtr,dytr);
86 fTrigPad->SetFillColor(22);
87 fTrigPad->SetBorderSize(2);
89 TText *t = new TText();
93 t->DrawText(0.5*dxtr, 0.93*dytr,"Trigger");
96 t->DrawText(xt,yt, "EM1");
97 t->DrawText(xt,yt-dyt, "PH1");
98 t->DrawText(xt,yt-2*dyt,"EM2");
99 t->DrawText(xt,yt-3*dyt,"MU1");
100 t->DrawText(xt,yt-4*dyt,"MU2");
101 t->DrawText(xt,yt-5*dyt,"EMU");
102 t->DrawText(xt,yt-6*dyt,"JT1");
103 t->DrawText(xt,yt-7*dyt,"JT2");
104 t->DrawText(xt,yt-8*dyt,"JT3");
105 t->DrawText(xt,yt-9*dyt,"ALL");
106 AppendPad(); // append display object as last object to force selection
108 fTubin = new TTUBE("tubin","inner tube"," ", fRin, fRin+5, fZin);
109 fNodin = new TNode("nodin","ALIAS outline","tubin",0,0,0," ");
110 fNodin->SetLineColor(7);
113 // Create list to support list of fruits
114 fFruits = new TList();
116 // Create particle manager
117 fParticle = new AliFParticle("particle_manager");
125 //_____________________________________________________________________________
126 AliFDisplay::~AliFDisplay()
129 if (fFruits) fFruits->Delete();
133 //_____________________________________________________________________________
134 void AliFDisplay::Clear(Option_t *)
136 // Delete graphics temporary objects
142 //_____________________________________________________________________________
143 void AliFDisplay::DisplayButtons()
145 // Create the user interface buttons
147 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
149 fButtons->SetFillColor(38);
150 fButtons->SetBorderSize(2);
154 Float_t dbutton = 0.08;
161 char *but1 = "gAliFast->Display()->ShowNextEvent(1)";
162 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
163 button->SetFillColor(38);
167 char *but2 = "gAliFast->Display()->ShowNextEvent(-1)";
168 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
169 button->SetFillColor(38);
173 char *but3 = "gAliFast->Display()->SetView(90,-90)";
174 button = new TButton("Top View",but3,x0,y-dbutton,x1,y);
175 button->SetFillColor(butcolor);
179 char *but4 = "gAliFast->Display()->SetView(90,0)";
180 button = new TButton("Side View",but4,x0,y-dbutton,x1,y);
181 button->SetFillColor(butcolor);
185 char *but5 = "gAliFast->Display()->SetView(0,-90)";
186 button = new TButton("Front View",but5,x0,y-dbutton,x1,y);
187 button->SetFillColor(butcolor);
191 char *but6 = "gAliFast->Display()->DrawAllViews()";
192 button = new TButton("All Views",but6,x0,y-dbutton,x1,y);
193 button->SetFillColor(butcolor);
197 char *but7 = "gAliFast->Display()->DrawViewGL()";
198 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
199 button->SetFillColor(38);
203 char *but8 = "gAliFast->Display()->DrawViewX3D()";
204 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
205 button->SetFillColor(38);
209 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
210 diamond->SetFillColor(50);
211 diamond->SetTextAlign(22);
212 diamond->SetTextColor(5);
213 diamond->SetTextSize(0.11);
215 diamond->AddText(".. ");
216 diamond->AddText("ROOT");
217 diamond->AddText("AliFAST");
218 diamond->AddText("... ");
219 diamond->AddText(" ");
222 //_____________________________________________________________________________
224 Int_t AliFDisplay::DistancetoPrimitive(Int_t px, Int_t py)
226 // Compute distance from point px,py to objects in event
228 if (gPad == fTrigPad) {gPad->SetCursor(kCross); return 0;}
230 const Int_t big = 9999;
232 Float_t xmin = gPad->GetX1();
233 Float_t xmax = gPad->GetX2();
234 Float_t dx = 0.05*(xmax - xmin);
235 Float_t x = gPad->AbsPixeltoX(px);
236 if (x < xmin+dx || x > xmax-dx) return dist;
238 // scan list of particles
239 dist = fParticle->DistancetoPrimitive(px, py);
240 if (dist <= 0) return 0;
242 // scan list of fruits
243 TIter nextf(fFruits);
245 while((fruit=(AliFFruit*)nextf())) {
246 dist = fruit->DistancetoPrimitive(px, py);
248 gPad->SetSelected(fruit->Fruit());
249 gPad->SetCursor(kCross);
254 // scan list of detectors (currently only one tube)
255 dist = fNodin->DistancetoPrimitive(px, py);
256 if (gPad->GetCanvas()->GetSelected() == gPad->GetView()) {
257 gPad->SetSelected(this);
262 //_____________________________________________________________________________
263 void AliFDisplay::Draw(Option_t *)
265 // Insert current event in graphics pad list
274 DrawView(fTheta, fPhi);
276 // Display the event number and title
281 //_____________________________________________________________________________
282 void AliFDisplay::DrawAllViews()
284 // Draw front,top,side and 30 deg views
286 fDrawAllViews = kTRUE;
288 fPad->SetFillColor(15);
315 //_____________________________________________________________________________
316 void AliFDisplay::DrawTitle(Option_t *option)
318 // Draw the event title
320 Float_t xmin = gPad->GetX1();
321 Float_t xmax = gPad->GetX2();
322 Float_t ymin = gPad->GetY1();
323 Float_t ymax = gPad->GetY2();
324 Float_t dx = xmax-xmin;
325 Float_t dy = ymax-ymin;
326 if (strlen(option) == 0) {
327 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
328 title->SetBit(kCanDelete);
329 title->SetFillColor(42);
332 sprintf(ptitle,"Pythia event: %d, Run:%d",gAliFast->Event(), gAliFast->Run());
333 title->AddText(ptitle);
334 sprintf(ptitle,"Pythia Mode: %s",gAliFast->MCMaker()->GetTitle());
335 title->AddText(ptitle);
337 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
338 label->SetBit(kCanDelete);
339 label->SetFillColor(42);
344 //_____________________________________________________________________________
345 void AliFDisplay::DrawView(Float_t theta, Float_t phi)
347 // Draw a view of ALIAS
349 gPad->SetFillColor(1);
350 // Display ALIAS outline
354 TView *view = new TView(1);
355 view->SetRange(-fRin, -fRin, -fZin, fRin, fRin, fZin);
357 fNodin->Draw("same");
359 // add itself to the list
362 //Loop on all makers to add their products to the pad
363 TIter next(gAliFast->Makers());
365 while ((maker = (AliFMaker*)next())) {
368 view->SetView(phi, theta, 0, iret);
371 //_____________________________________________________________________________
372 void AliFDisplay::DrawViewGL()
374 // Draw current view using OPENGL
376 TPad *pad = (TPad*)gPad->GetPadSave();
378 TView *view = pad->GetView();
383 //_____________________________________________________________________________
384 void AliFDisplay::DrawViewX3D()
386 // Draw current view using X3D
388 TPad *pad = (TPad*)gPad->GetPadSave();
390 TView *view = pad->GetView();
395 //______________________________________________________________________________
396 void AliFDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
398 //*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
399 //*-* =========================================
401 if (gPad->GetView()) {
402 gPad->GetView()->ExecuteRotateView(event, px, py);
406 //_____________________________________________________________________________
407 void AliFDisplay::GetEvent(Int_t event)
409 // Read event in memory
411 gAliFast->GetTreeEvent(event);
416 //_____________________________________________________________________________
417 void AliFDisplay::Paint(Option_t *)
419 // Paint miscellaneous items
423 //_____________________________________________________________________________
424 void AliFDisplay::PaintFruit(TObject *obj, Float_t eta, Float_t phi, Float_t
425 pt, Int_t type, Option_t *option)
427 // Display fruit from obj
429 AliFFruit *fruit = new AliFFruit(obj, eta, phi, pt, type);
431 fruit->Paint(option);
434 //_____________________________________________________________________________
435 void AliFDisplay::PaintParticles(Option_t *option)
437 if (fDrawParticles) fParticle->Paint(option);
440 //_____________________________________________________________________________
441 void AliFDisplay::SetGeometry(Float_t rin)
443 // Set ALIAS in/out outline parameters
451 //_____________________________________________________________________________
452 void AliFDisplay::SetPTcut(Float_t ptcut)
457 fPad->cd(1); gPad->Modified();
458 fPad->cd(2); gPad->Modified();
459 fPad->cd(3); gPad->Modified();
460 fPad->cd(4); gPad->Modified();
465 //_____________________________________________________________________________
466 void AliFDisplay::SetPTcutEGMUNU(Float_t ptcut)
468 fPTcutEGMUNU = ptcut;
471 fPad->cd(1); gPad->Modified();
472 fPad->cd(2); gPad->Modified();
473 fPad->cd(3); gPad->Modified();
474 fPad->cd(4); gPad->Modified();
479 //_____________________________________________________________________________
480 void AliFDisplay::SetView(Float_t theta, Float_t phi)
482 // change viewing angles for current event
485 fDrawAllViews = kFALSE;
490 TView *view = gPad->GetView();
491 if (view) view->SetView(fPhi, fTheta, 0, iret);
497 //_____________________________________________________________________________
498 void AliFDisplay::ShowNextEvent(Int_t delta)
500 // Display (current event_number+delta)
501 // delta = 1 shown next event
502 // delta = -1 show previous event
506 Int_t current_event = gAliFast->Event();
507 Int_t new_event = current_event + delta;
508 gAliFast->GetTreeEvent(new_event);
514 //______________________________________________________________________________
515 void AliFDisplay::SizeFruit() const
517 const Int_t npoints = 2;
518 gSize3D.numPoints += npoints;
519 gSize3D.numSegs += (npoints-1);
520 gSize3D.numPolys += 0;
523 //______________________________________________________________________________
524 void AliFDisplay::SizeParticles() const
526 if (fDrawParticles) fParticle->SizeParticles();