]>
Commit | Line | Data |
---|---|---|
65a39007 | 1 | |
2 | ////////////////////////////////////////////////////////////////////////// | |
3 | // // | |
4 | // AliFDisplay // | |
5 | // // | |
6 | // Utility class to display ALICE outline, tracks, clusters, jets,.. // | |
7 | // // | |
8 | ////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #include <TROOT.h> | |
11 | #include <TButton.h> | |
12 | #include <TCanvas.h> | |
13 | #include <TView.h> | |
14 | #include <TArc.h> | |
15 | #include <TText.h> | |
16 | #include <TPaveLabel.h> | |
17 | #include <TPaveText.h> | |
18 | #include <TList.h> | |
19 | #include <TDiamond.h> | |
20 | #include <TNode.h> | |
21 | #include <TTUBE.h> | |
22 | #include <TMath.h> | |
23 | #include <X3DBuffer.h> | |
24 | ||
25 | #include "AliFDisplay.h" | |
26 | #include "AliFFruit.h" | |
27 | #include "AliFParticle.h" | |
28 | #include "AliFast.h" | |
29 | #include "AliFMCMaker.h" | |
30 | ||
31 | ||
32 | ClassImp(AliFDisplay) | |
33 | ||
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliFDisplay::AliFDisplay() : AliFVirtualDisplay() | |
37 | { | |
38 | fParticle = 0; | |
39 | fFruits = 0; | |
40 | } | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | AliFDisplay::AliFDisplay(const char *title) : AliFVirtualDisplay() | |
44 | { | |
45 | ||
46 | gAliFast->SetDisplay(this); | |
47 | ||
48 | // Initialize display default parameters | |
49 | SetPTcut(); | |
50 | SetPTcutEGMUNU(); | |
51 | SetGeometry(); | |
52 | ||
53 | // Set front view by default | |
54 | fTheta = 0; | |
55 | fPhi = -90; | |
56 | fDrawAllViews = kFALSE; | |
57 | fDrawParticles = kTRUE; | |
58 | ||
59 | // Create display canvas | |
60 | fCanvas = new TCanvas("Canvas", (char*)title,14,47,740,650); | |
61 | fCanvas->SetEditable(kIsNotEditable); | |
62 | ||
63 | // Create main display pad | |
64 | fPad = new TPad("viewpad", "AliFast display",0.15,0,1,1); | |
65 | fPad->Draw(); | |
66 | fPad->Modified(); | |
67 | fPad->SetFillColor(1); | |
68 | fPad->SetBorderSize(2); | |
69 | ||
70 | // Create user interface control pad | |
71 | DisplayButtons(); | |
72 | fCanvas->cd(); | |
73 | ||
74 | // Create trigger view pad | |
75 | Float_t dxtr = 0.15; | |
76 | Float_t dytr = 0.45; | |
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); | |
84 | fTrigPad->Draw(); | |
85 | fTrigPad->cd(); | |
86 | fTrigPad->SetFillColor(22); | |
87 | fTrigPad->SetBorderSize(2); | |
88 | ||
89 | TText *t = new TText(); | |
90 | t->SetTextFont(61); | |
91 | t->SetTextSize(0.2); | |
92 | t->SetTextAlign(22); | |
93 | t->DrawText(0.5*dxtr, 0.93*dytr,"Trigger"); | |
94 | t->SetTextSize(0.14); | |
95 | t->SetTextAlign(22); | |
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 | |
107 | ||
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); | |
111 | ||
112 | ||
113 | // Create list to support list of fruits | |
114 | fFruits = new TList(); | |
115 | ||
116 | // Create particle manager | |
117 | fParticle = new AliFParticle("particle_manager"); | |
118 | ||
119 | fCanvas->cd(); | |
120 | fCanvas->Update(); | |
121 | ||
122 | } | |
123 | ||
124 | ||
125 | //_____________________________________________________________________________ | |
126 | AliFDisplay::~AliFDisplay() | |
127 | { | |
128 | delete fParticle; | |
129 | if (fFruits) fFruits->Delete(); | |
130 | delete fFruits; | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliFDisplay::Clear(Option_t *) | |
135 | { | |
136 | // Delete graphics temporary objects | |
137 | ||
138 | fFruits->Delete(); | |
139 | ||
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | void AliFDisplay::DisplayButtons() | |
144 | { | |
145 | // Create the user interface buttons | |
146 | ||
147 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); | |
148 | fButtons->Draw(); | |
149 | fButtons->SetFillColor(38); | |
150 | fButtons->SetBorderSize(2); | |
151 | fButtons->cd(); | |
152 | ||
153 | Int_t butcolor = 33; | |
154 | Float_t dbutton = 0.08; | |
155 | Float_t y = 0.96; | |
156 | Float_t dy = 0.014; | |
157 | Float_t x0 = 0.05; | |
158 | Float_t x1 = 0.95; | |
159 | ||
160 | TButton *button; | |
161 | char *but1 = "gAliFast->Display()->ShowNextEvent(1)"; | |
162 | button = new TButton("Next",but1,x0,y-dbutton,x1,y); | |
163 | button->SetFillColor(38); | |
164 | button->Draw(); | |
165 | ||
166 | y -= dbutton +dy; | |
167 | char *but2 = "gAliFast->Display()->ShowNextEvent(-1)"; | |
168 | button = new TButton("Previous",but2,x0,y-dbutton,x1,y); | |
169 | button->SetFillColor(38); | |
170 | button->Draw(); | |
171 | ||
172 | y -= dbutton +dy; | |
173 | char *but3 = "gAliFast->Display()->SetView(90,-90)"; | |
174 | button = new TButton("Top View",but3,x0,y-dbutton,x1,y); | |
175 | button->SetFillColor(butcolor); | |
176 | button->Draw(); | |
177 | ||
178 | y -= dbutton +dy; | |
179 | char *but4 = "gAliFast->Display()->SetView(90,0)"; | |
180 | button = new TButton("Side View",but4,x0,y-dbutton,x1,y); | |
181 | button->SetFillColor(butcolor); | |
182 | button->Draw(); | |
183 | ||
184 | y -= dbutton +dy; | |
185 | char *but5 = "gAliFast->Display()->SetView(0,-90)"; | |
186 | button = new TButton("Front View",but5,x0,y-dbutton,x1,y); | |
187 | button->SetFillColor(butcolor); | |
188 | button->Draw(); | |
189 | ||
190 | y -= dbutton +dy; | |
191 | char *but6 = "gAliFast->Display()->DrawAllViews()"; | |
192 | button = new TButton("All Views",but6,x0,y-dbutton,x1,y); | |
193 | button->SetFillColor(butcolor); | |
194 | button->Draw(); | |
195 | ||
196 | y -= dbutton +dy; | |
197 | char *but7 = "gAliFast->Display()->DrawViewGL()"; | |
198 | button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y); | |
199 | button->SetFillColor(38); | |
200 | button->Draw(); | |
201 | ||
202 | y -= dbutton +dy; | |
203 | char *but8 = "gAliFast->Display()->DrawViewX3D()"; | |
204 | button = new TButton("X3D",but8,x0,y-dbutton,x1,y); | |
205 | button->SetFillColor(38); | |
206 | button->Draw(); | |
207 | ||
208 | // display logo | |
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); | |
214 | diamond->Draw(); | |
215 | diamond->AddText(".. "); | |
216 | diamond->AddText("ROOT"); | |
217 | diamond->AddText("AliFAST"); | |
218 | diamond->AddText("... "); | |
219 | diamond->AddText(" "); | |
220 | } | |
221 | ||
222 | //_____________________________________________________________________________ | |
223 | ||
224 | Int_t AliFDisplay::DistancetoPrimitive(Int_t px, Int_t py) | |
225 | { | |
226 | // Compute distance from point px,py to objects in event | |
227 | ||
228 | if (gPad == fTrigPad) {gPad->SetCursor(kCross); return 0;} | |
229 | ||
230 | const Int_t big = 9999; | |
231 | Int_t dist = big; | |
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; | |
237 | ||
238 | // scan list of particles | |
239 | dist = fParticle->DistancetoPrimitive(px, py); | |
240 | if (dist <= 0) return 0; | |
241 | ||
242 | // scan list of fruits | |
243 | TIter nextf(fFruits); | |
244 | AliFFruit *fruit; | |
245 | while((fruit=(AliFFruit*)nextf())) { | |
246 | dist = fruit->DistancetoPrimitive(px, py); | |
247 | if (dist < 5) { | |
248 | gPad->SetSelected(fruit->Fruit()); | |
249 | gPad->SetCursor(kCross); | |
250 | return 0; | |
251 | } | |
252 | } | |
253 | ||
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); | |
258 | } | |
259 | return 0; | |
260 | } | |
261 | ||
262 | //_____________________________________________________________________________ | |
263 | void AliFDisplay::Draw(Option_t *) | |
264 | { | |
265 | // Insert current event in graphics pad list | |
266 | ||
267 | if (fDrawAllViews) { | |
268 | DrawAllViews(); | |
269 | return; | |
270 | } | |
271 | ||
272 | fPad->cd(); | |
273 | ||
274 | DrawView(fTheta, fPhi); | |
275 | ||
276 | // Display the event number and title | |
277 | fPad->cd(); | |
278 | DrawTitle(); | |
279 | } | |
280 | ||
281 | //_____________________________________________________________________________ | |
282 | void AliFDisplay::DrawAllViews() | |
283 | { | |
284 | // Draw front,top,side and 30 deg views | |
285 | ||
286 | fDrawAllViews = kTRUE; | |
287 | fPad->cd(); | |
288 | fPad->SetFillColor(15); | |
289 | fPad->Clear(); | |
290 | fPad->Divide(2,2); | |
291 | ||
292 | // draw 30 deg view | |
293 | fPad->cd(1); | |
294 | DrawView(30, 30); | |
295 | DrawTitle(); | |
296 | ||
297 | // draw front view | |
298 | fPad->cd(2); | |
299 | DrawView(0, -90); | |
300 | DrawTitle("Front"); | |
301 | ||
302 | // draw top view | |
303 | fPad->cd(3); | |
304 | DrawView(90, -90); | |
305 | DrawTitle("Top"); | |
306 | ||
307 | // draw side view | |
308 | fPad->cd(4); | |
309 | DrawView(90, 0); | |
310 | DrawTitle("Side"); | |
311 | ||
312 | fPad->cd(2); | |
313 | } | |
314 | ||
315 | //_____________________________________________________________________________ | |
316 | void AliFDisplay::DrawTitle(Option_t *option) | |
317 | { | |
318 | // Draw the event title | |
319 | ||
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); | |
330 | title->Draw(); | |
331 | char ptitle[100]; | |
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); | |
336 | } else { | |
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); | |
340 | label->Draw(); | |
341 | } | |
342 | } | |
343 | ||
344 | //_____________________________________________________________________________ | |
345 | void AliFDisplay::DrawView(Float_t theta, Float_t phi) | |
346 | { | |
347 | // Draw a view of ALIAS | |
348 | ||
349 | gPad->SetFillColor(1); | |
350 | // Display ALIAS outline | |
351 | gPad->Clear(); | |
352 | ||
353 | Int_t iret; | |
354 | TView *view = new TView(1); | |
355 | view->SetRange(-fRin, -fRin, -fZin, fRin, fRin, fZin); | |
356 | ||
357 | fNodin->Draw("same"); | |
358 | ||
359 | // add itself to the list | |
360 | AppendPad(); | |
361 | ||
362 | //Loop on all makers to add their products to the pad | |
363 | TIter next(gAliFast->Makers()); | |
364 | AliFMaker *maker; | |
365 | while ((maker = (AliFMaker*)next())) { | |
366 | maker->Draw(); | |
367 | } | |
368 | view->SetView(phi, theta, 0, iret); | |
369 | } | |
370 | ||
371 | //_____________________________________________________________________________ | |
372 | void AliFDisplay::DrawViewGL() | |
373 | { | |
374 | // Draw current view using OPENGL | |
375 | ||
376 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
377 | pad->cd(); | |
378 | TView *view = pad->GetView(); | |
379 | if (!view) return; | |
380 | pad->x3d("OPENGL"); | |
381 | } | |
382 | ||
383 | //_____________________________________________________________________________ | |
384 | void AliFDisplay::DrawViewX3D() | |
385 | { | |
386 | // Draw current view using X3D | |
387 | ||
388 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
389 | pad->cd(); | |
390 | TView *view = pad->GetView(); | |
391 | if (!view) return; | |
392 | pad->x3d(); | |
393 | } | |
394 | ||
395 | //______________________________________________________________________________ | |
396 | void AliFDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
397 | { | |
398 | //*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-* | |
399 | //*-* ========================================= | |
400 | ||
401 | if (gPad->GetView()) { | |
402 | gPad->GetView()->ExecuteRotateView(event, px, py); | |
403 | } | |
404 | } | |
405 | ||
406 | //_____________________________________________________________________________ | |
407 | void AliFDisplay::GetEvent(Int_t event) | |
408 | { | |
409 | // Read event in memory | |
410 | ||
411 | gAliFast->GetTreeEvent(event); | |
412 | ||
413 | Draw(); | |
414 | } | |
415 | ||
416 | //_____________________________________________________________________________ | |
417 | void AliFDisplay::Paint(Option_t *) | |
418 | { | |
419 | // Paint miscellaneous items | |
420 | ||
421 | } | |
422 | ||
423 | //_____________________________________________________________________________ | |
424 | void AliFDisplay::PaintFruit(TObject *obj, Float_t eta, Float_t phi, Float_t | |
425 | pt, Int_t type, Option_t *option) | |
426 | { | |
427 | // Display fruit from obj | |
428 | ||
429 | AliFFruit *fruit = new AliFFruit(obj, eta, phi, pt, type); | |
430 | fFruits->Add(fruit); | |
431 | fruit->Paint(option); | |
432 | } | |
433 | ||
434 | //_____________________________________________________________________________ | |
435 | void AliFDisplay::PaintParticles(Option_t *option) | |
436 | { | |
437 | if (fDrawParticles) fParticle->Paint(option); | |
438 | } | |
439 | ||
440 | //_____________________________________________________________________________ | |
441 | void AliFDisplay::SetGeometry(Float_t rin) | |
442 | { | |
443 | // Set ALIAS in/out outline parameters | |
444 | ||
445 | fRin = rin; | |
446 | fRout = 1.2*rin; | |
447 | fZin = 600; | |
448 | fZout = 680; | |
449 | } | |
450 | ||
451 | //_____________________________________________________________________________ | |
452 | void AliFDisplay::SetPTcut(Float_t ptcut) | |
453 | { | |
454 | fPTcut = ptcut; | |
455 | ||
456 | if (fDrawAllViews) { | |
457 | fPad->cd(1); gPad->Modified(); | |
458 | fPad->cd(2); gPad->Modified(); | |
459 | fPad->cd(3); gPad->Modified(); | |
460 | fPad->cd(4); gPad->Modified(); | |
461 | fPad->cd(); | |
462 | } | |
463 | } | |
464 | ||
465 | //_____________________________________________________________________________ | |
466 | void AliFDisplay::SetPTcutEGMUNU(Float_t ptcut) | |
467 | { | |
468 | fPTcutEGMUNU = ptcut; | |
469 | ||
470 | if (fDrawAllViews) { | |
471 | fPad->cd(1); gPad->Modified(); | |
472 | fPad->cd(2); gPad->Modified(); | |
473 | fPad->cd(3); gPad->Modified(); | |
474 | fPad->cd(4); gPad->Modified(); | |
475 | fPad->cd(); | |
476 | } | |
477 | } | |
478 | ||
479 | //_____________________________________________________________________________ | |
480 | void AliFDisplay::SetView(Float_t theta, Float_t phi) | |
481 | { | |
482 | // change viewing angles for current event | |
483 | ||
484 | fPad->cd(); | |
485 | fDrawAllViews = kFALSE; | |
486 | fPhi = phi; | |
487 | fTheta = theta; | |
488 | Int_t iret; | |
489 | ||
490 | TView *view = gPad->GetView(); | |
491 | if (view) view->SetView(fPhi, fTheta, 0, iret); | |
492 | else Draw(); | |
493 | ||
494 | gPad->Modified(); | |
495 | } | |
496 | ||
497 | //_____________________________________________________________________________ | |
498 | void AliFDisplay::ShowNextEvent(Int_t delta) | |
499 | { | |
500 | // Display (current event_number+delta) | |
501 | // delta = 1 shown next event | |
502 | // delta = -1 show previous event | |
503 | ||
504 | if (delta) { | |
505 | gAliFast->Clear(); | |
506 | Int_t current_event = gAliFast->Event(); | |
507 | Int_t new_event = current_event + delta; | |
508 | gAliFast->GetTreeEvent(new_event); | |
509 | } | |
510 | fPad->cd(); | |
511 | Draw(); | |
512 | } | |
513 | ||
514 | //______________________________________________________________________________ | |
515 | void AliFDisplay::SizeFruit() const | |
516 | { | |
517 | const Int_t npoints = 2; | |
518 | gSize3D.numPoints += npoints; | |
519 | gSize3D.numSegs += (npoints-1); | |
520 | gSize3D.numPolys += 0; | |
521 | } | |
522 | ||
523 | //______________________________________________________________________________ | |
524 | void AliFDisplay::SizeParticles() const | |
525 | { | |
526 | if (fDrawParticles) fParticle->SizeParticles(); | |
527 | } | |
528 | ||
529 | ||
530 | ||
531 | ||
532 | ||
533 | ||
534 | ||
535 | ||
536 | ||
537 |