]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
86a9484d | 18 | Revision 1.15 2001/05/16 14:57:22 alibrary |
19 | New files for folders and Stack | |
20 | ||
9e1a0ddb | 21 | Revision 1.14 2001/01/26 19:58:48 hristov |
22 | Major upgrade of AliRoot code | |
23 | ||
2ab0c725 | 24 | Revision 1.13 2000/12/21 15:30:18 fca |
25 | Correcting coding convention violations | |
26 | ||
b23a502f | 27 | Revision 1.12 2000/12/12 13:18:59 hristov |
28 | Protection against FPE | |
29 | ||
33d37c81 | 30 | Revision 1.11 2000/11/30 07:12:48 alibrary |
31 | Introducing new Rndm and QA classes | |
32 | ||
65fb704d | 33 | Revision 1.10 2000/10/02 21:28:14 fca |
34 | Removal of useless dependecies via forward declarations | |
35 | ||
94de3818 | 36 | Revision 1.9 2000/07/13 16:19:09 fca |
37 | Mainly coding conventions + some small bug fixes | |
38 | ||
ef42d733 | 39 | Revision 1.8 2000/07/11 18:24:59 fca |
40 | Coding convention corrections + few minor bug fixes | |
41 | ||
aee8290b | 42 | Revision 1.7 1999/11/10 07:37:06 fca |
43 | Pads do not inherit editability from canvas any more | |
44 | ||
38b32e9f | 45 | Revision 1.6 1999/11/09 07:38:52 fca |
46 | Changes for compatibility with version 2.23 of ROOT | |
47 | ||
084c1b4a | 48 | Revision 1.5 1999/09/29 09:24:29 fca |
49 | Introduction of the Copyright and cvs Log | |
50 | ||
4c039060 | 51 | */ |
52 | ||
fe4da5cc | 53 | |
54 | ////////////////////////////////////////////////////////////////////////// | |
55 | // // | |
56 | // AliDisplay // | |
57 | // // | |
58 | // Utility class to display ALICE outline, tracks, hits,.. // | |
59 | // // | |
60 | ////////////////////////////////////////////////////////////////////////// | |
61 | ||
fe4da5cc | 62 | #include <TTree.h> |
63 | #include <TButton.h> | |
64 | #include <TCanvas.h> | |
65 | #include <TView.h> | |
fe4da5cc | 66 | #include <TPaveLabel.h> |
67 | #include <TPaveText.h> | |
fe4da5cc | 68 | #include <TDiamond.h> |
fe4da5cc | 69 | #include <TArc.h> |
fe4da5cc | 70 | #include <TSlider.h> |
71 | #include <TSliderBox.h> | |
72 | #include <TGaxis.h> | |
084c1b4a | 73 | #include <TVirtualX.h> |
fe4da5cc | 74 | #include <TMath.h> |
fe4da5cc | 75 | |
76 | #include "AliRun.h" | |
77 | #include "AliDetector.h" | |
78 | #include "AliDisplay.h" | |
79 | #include "AliPoints.h" | |
1578254f | 80 | #include "TParticle.h" |
94de3818 | 81 | #include "TGeometry.h" |
9e1a0ddb | 82 | #include "AliHeader.h" |
fe4da5cc | 83 | |
aee8290b | 84 | static const Float_t kptcutmax = 2; |
85 | static const Float_t ketacutmax = 1.5; | |
fe4da5cc | 86 | |
87 | ClassImp(AliDisplay) | |
88 | ||
89 | ||
90 | //_____________________________________________________________________________ | |
91 | AliDisplay::AliDisplay() | |
92 | { | |
aee8290b | 93 | // |
94 | // Default constructor | |
95 | // | |
96 | fCanvas = 0; | |
fe4da5cc | 97 | } |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | AliDisplay::AliDisplay(Int_t size) | |
101 | { | |
102 | // Create an event display object. | |
103 | // A canvas named "edisplay" is created with a vertical size in pixels | |
104 | // | |
105 | // A QUICK Overview of the Event Display functions | |
106 | // =============================================== | |
107 | // | |
108 | // The event display can ve invoked by executing the macro "display.C" | |
109 | // A canvas like in the picture below will appear. | |
110 | // | |
111 | // On the left side of the canvas, the following buttons appear: | |
112 | // *Next* to move to the next event | |
113 | // *Previous* to move to the previous event | |
114 | // *Top View* to display a top view of the current event | |
115 | // *Side View* to display a side view of the current event | |
116 | // *Front View* to display a front view of the current event | |
117 | // *All Views* to display front/side/top/30-30 views of the current event | |
118 | // *OpenGL* to use OpenGl to view the current event. | |
119 | // Note that OpenGL cannot be used across the network. | |
120 | // Before using OpenGL, load the GL libraries | |
121 | // by executing the macro GL.C (in $ROOTSYS/macros/GL.C. | |
122 | // Once in GL, click the HELP button of the GL canvas. | |
123 | // *X3D* to use X3D to view the current event (Unix only). | |
124 | // Once in X3D, type M to see the list of all possible options. | |
125 | // for example type J to zoom, K to unzoom | |
126 | // use the mouse to rotate. | |
127 | // *Pick* Select this option to be able to point on a track with the | |
128 | // mouse. Once on the track, use the right button to select | |
129 | // an action. For example, select SetMarkerAttributes to | |
130 | // change the marker type/color/size for the track. | |
131 | // *Zoom* Select this option (default) if you want to zoom. | |
132 | // To zoom, simply select the selected area with the left button. | |
133 | // *UnZoom* To revert to the previous picture size. | |
134 | // | |
135 | // slider R On the left side, the vertical slider can be used to | |
136 | // set the default picture size. | |
137 | // slider pcut At the top of the canvas, a slider can be used to change | |
138 | // the momentum cut (or range) to display tracks. | |
139 | // slider eta On the right side of the canvas, a vertical slider can be used | |
140 | // to specify a rapidity range for the tracks. | |
141 | // | |
142 | // When you are in Zoom mode, you can click on the black part of the canvas | |
143 | // to select special options with the right mouse button. | |
144 | // This will display a pop-up menu with items like: | |
145 | // *Disable detector* | |
146 | // *Enable detector*, etc. | |
147 | // For example select "Disable detector". You get a dialog box. | |
148 | // Diable detector TRD for example. | |
149 | // | |
150 | // When you are in pick mode, you can "Inspect" the object pointed by the mouse. | |
151 | // When you are on a track, select the menu item "InspectParticle" | |
152 | // to display the current particle attributes. | |
153 | // | |
154 | // You can activate the Root browser by selecting the Inspect menu | |
155 | // in the canvas tool bar menu. Then select "Start Browser" | |
156 | // This will open a new canvas with the browser. At this point, you may want | |
157 | // to display some histograms (from the Trees). Go to the "File" menu | |
158 | // of the browser and click on "New canvas". | |
159 | // In the browser, click on item "ROOT files" in the left pane. | |
160 | // Click on galice.root. | |
161 | // Click on TH | |
162 | // Click on TPC for example | |
163 | // Click on any variable (eg TPC.fX) to histogram the variable. | |
164 | // | |
165 | // If you are lost, you can click on HELP in any Root canvas or browser. | |
166 | //Begin_Html | |
167 | /* | |
1439f98e | 168 | <img src="picts/alidisplay.gif"> |
fe4da5cc | 169 | */ |
170 | //End_Html | |
171 | ||
172 | fPad = 0; | |
173 | gAlice->SetDisplay(this); | |
174 | ||
175 | // Initialize display default parameters | |
176 | SetRange(); | |
177 | SetPTcut(); | |
178 | ||
179 | // Set front view by default | |
180 | fTheta = 0; | |
181 | fPhi = -90; | |
182 | fPsi = 0; | |
183 | fDrawAllViews = kFALSE; | |
184 | fDrawHits = kTRUE; | |
185 | fDrawParticles = kTRUE; | |
186 | fZoomMode = 1; | |
187 | fZooms = 0; | |
188 | fHitsCuts = 0; | |
189 | ||
190 | // Create display canvas | |
191 | Int_t ysize = size; | |
192 | if (ysize < 100) ysize = 750; | |
193 | Int_t xsize = Int_t(size*830./ysize); | |
194 | fCanvas = new TCanvas("Canvas", "ALICE Event Display",14,47,xsize,ysize); | |
fe4da5cc | 195 | fCanvas->ToggleEventStatus(); |
196 | ||
197 | // Create main display pad | |
198 | fPad = new TPad("viewpad", "Alice display",0.15,0,0.97,0.96); | |
199 | fPad->Draw(); | |
200 | fPad->Modified(); | |
201 | fPad->SetFillColor(1); | |
202 | fPad->SetBorderSize(2); | |
203 | ||
204 | // Create user interface control pad | |
205 | DisplayButtons(); | |
206 | fCanvas->cd(); | |
207 | ||
208 | // Create Range and mode pad | |
209 | Float_t dxtr = 0.15; | |
210 | Float_t dytr = 0.45; | |
211 | fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr); | |
212 | fTrigPad->Draw(); | |
213 | fTrigPad->cd(); | |
214 | fTrigPad->SetFillColor(22); | |
215 | fTrigPad->SetBorderSize(2); | |
216 | fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98); | |
217 | fRangeSlider->SetObject(this); | |
218 | char pickmode[] = "gAlice->Display()->SetPickMode()"; | |
219 | Float_t db = 0.09; | |
220 | fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db); | |
221 | fPickButton->SetFillColor(38); | |
222 | fPickButton->Draw(); | |
223 | char zoommode[] = "gAlice->Display()->SetZoomMode()"; | |
224 | fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db); | |
225 | fZoomButton->SetFillColor(38); | |
226 | fZoomButton->Draw(); | |
227 | fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db); | |
228 | fArcButton->SetFillColor(kGreen); | |
229 | fArcButton->Draw(); | |
230 | char butUnzoom[] = "gAlice->Display()->UnZoom()"; | |
231 | TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15); | |
232 | button->SetFillColor(38); | |
233 | button->Draw(); | |
234 | AppendPad(); // append display object as last object to force selection | |
235 | ||
236 | // Create momentum cut slider pad | |
237 | fCanvas->cd(); | |
238 | fCutPad = new TPad("cutSlider", "pcut slider pad",dxtr,.96,1,1); | |
239 | fCutPad->Draw(); | |
240 | fCutPad->cd(); | |
241 | fCutPad->SetFillColor(22); | |
242 | fCutPad->SetBorderSize(2); | |
243 | fCutSlider = new TSlider("pcut","Momentum cut",0,0,1,1); | |
aee8290b | 244 | fCutSlider->SetRange(fPTcut/kptcutmax,1); |
fe4da5cc | 245 | fCutSlider->SetObject(this); |
246 | fCutSlider->SetFillColor(45); | |
247 | TSliderBox *sbox = (TSliderBox*)fCutSlider->GetListOfPrimitives()->First(); | |
248 | sbox->SetFillColor(46); | |
249 | fCutSlider->cd(); | |
aee8290b | 250 | TGaxis *cutaxis = new TGaxis(0.02,0.8,0.98,0.8,0,kptcutmax,510,""); |
fe4da5cc | 251 | cutaxis->SetLabelSize(0.5); |
252 | cutaxis->SetTitleSize(0.6); | |
253 | cutaxis->SetTitleOffset(0.5); | |
254 | cutaxis->SetTitle("pcut . "); | |
255 | fCutSlider->GetListOfPrimitives()->AddFirst(cutaxis); | |
256 | ||
257 | // Create rapidity cut slider pad | |
258 | fCanvas->cd(); | |
259 | fEtaPad = new TPad("EtaSlider", "Eta slider pad",0.97,0,1,0.96); | |
260 | fEtaPad->Draw(); | |
261 | fEtaPad->cd(); | |
262 | fEtaPad->SetFillColor(22); | |
263 | fEtaPad->SetBorderSize(2); | |
264 | fEtaSlider = new TSlider("etacut","Rapidity cut",0,0,1,1); | |
265 | fEtaSlider->SetObject(this); | |
266 | fEtaSlider->SetFillColor(45); | |
267 | TSliderBox *sbox2 = (TSliderBox*)fEtaSlider->GetListOfPrimitives()->First(); | |
268 | sbox2->SetFillColor(46); | |
269 | fEtaSlider->cd(); | |
aee8290b | 270 | TGaxis *etaaxis = new TGaxis(0.9,0.02,0.9,0.98,-ketacutmax,ketacutmax,510,""); |
fe4da5cc | 271 | etaaxis->SetLabelSize(0.5); |
272 | etaaxis->SetTitleSize(0.6); | |
273 | etaaxis->SetTitleOffset(0.2); | |
274 | cutaxis->SetTitle("Etacut . "); | |
275 | fEtaSlider->GetListOfPrimitives()->AddFirst(etaaxis); | |
276 | fCanvas->cd(); | |
86a9484d | 277 | |
278 | fTrigPad->SetEditable(kFALSE); | |
279 | fButtons->SetEditable(kFALSE); | |
fe4da5cc | 280 | |
281 | ||
282 | fCanvas->cd(); | |
283 | fCanvas->Update(); | |
284 | } | |
285 | ||
286 | ||
aee8290b | 287 | //_____________________________________________________________________________ |
288 | AliDisplay::AliDisplay(const AliDisplay &disp) | |
289 | { | |
290 | // | |
291 | // Copy constructor | |
292 | // | |
293 | disp.Copy(*this); | |
294 | } | |
295 | ||
fe4da5cc | 296 | //_____________________________________________________________________________ |
297 | AliDisplay::~AliDisplay() | |
298 | { | |
aee8290b | 299 | // |
300 | // Destructor | |
301 | // | |
fe4da5cc | 302 | } |
303 | ||
304 | //_____________________________________________________________________________ | |
305 | void AliDisplay::Clear(Option_t *) | |
306 | { | |
307 | // Delete graphics temporary objects | |
308 | } | |
309 | ||
aee8290b | 310 | //_____________________________________________________________________________ |
311 | void AliDisplay::Copy(AliDisplay &disp) const | |
312 | { | |
313 | // | |
314 | // Copy *this onto disp -- not implemented | |
315 | // | |
316 | Fatal("Copy","Not implemented~\n"); | |
317 | } | |
318 | ||
fe4da5cc | 319 | //---------------------------------------------------------------------------- |
b23a502f | 320 | void AliDisplay::ShowTrack(Int_t idx) |
321 | { | |
322 | // | |
323 | // Display track idx | |
324 | // | |
aee8290b | 325 | AliDetector *mTPC=(AliDetector*)gAlice->GetModule("TPC"); |
326 | TObjArray *points=mTPC->Points(); | |
fe4da5cc | 327 | int ntracks=points->GetEntriesFast(); |
328 | for (int track=0;track<ntracks;track++) { | |
329 | AliPoints *pm = (AliPoints*)points->UncheckedAt(track); | |
330 | if (!pm) continue; | |
331 | if (idx == pm->GetIndex()) { | |
332 | pm->SetMarkerColor(2); | |
333 | pm->SetMarkerStyle(22); | |
334 | pm->Draw("same"); | |
335 | // fPad->Update(); | |
336 | // fPad->Modified(); | |
2ab0c725 | 337 | // TClonesArray *particles=gAlice->Particles(); |
338 | // TParticle *p = (TParticle*)particles->UncheckedAt(idx); | |
339 | TParticle *p = gAlice->Particle(idx); | |
fe4da5cc | 340 | printf("\nTrack index %d\n",idx); |
1578254f | 341 | printf("Particle ID %d\n",p->GetPdgCode()); |
342 | printf("Parent %d\n",p->GetFirstMother()); | |
343 | printf("First child %d\n",p->GetFirstDaughter()); | |
344 | printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz()); | |
fe4da5cc | 345 | return; |
346 | } | |
347 | } | |
348 | } | |
349 | ||
350 | //---------------------------------------------------------------------------- | |
351 | void AliDisplay::HideTrack(Int_t idx) { | |
ef42d733 | 352 | // |
353 | // Hide track on display | |
354 | // | |
aee8290b | 355 | AliDetector *mTPC=(AliDetector*)gAlice->GetModule("TPC"); |
356 | TObjArray *points=mTPC->Points(); | |
fe4da5cc | 357 | int ntracks=points->GetEntriesFast(); |
358 | for (int track=0;track<ntracks;track++) { | |
359 | AliPoints *pm = (AliPoints*)points->UncheckedAt(track); | |
360 | if (!pm) continue; | |
361 | if (idx == pm->GetIndex()) { | |
362 | pm->SetMarkerColor(5); | |
363 | pm->SetMarkerStyle(1); | |
364 | pm->Draw("same"); | |
365 | // fPad->Update(); | |
366 | // fPad->Modified(); | |
367 | return; | |
368 | } | |
369 | } | |
370 | } | |
371 | ||
372 | //_____________________________________________________________________________ | |
373 | void AliDisplay::DisableDetector(const char *name) | |
374 | { | |
375 | // Disable detector name from graphics views | |
376 | ||
8494b010 | 377 | AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name); |
378 | if (!module) return; | |
379 | module->Disable(); | |
fe4da5cc | 380 | Draw(); |
381 | } | |
382 | ||
383 | //_____________________________________________________________________________ | |
384 | void AliDisplay::DisplayButtons() | |
385 | { | |
386 | // Create the user interface buttons | |
387 | ||
388 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); | |
389 | fButtons->Draw(); | |
390 | fButtons->SetFillColor(38); | |
391 | fButtons->SetBorderSize(2); | |
392 | fButtons->cd(); | |
393 | ||
394 | Int_t butcolor = 33; | |
395 | Float_t dbutton = 0.08; | |
396 | Float_t y = 0.96; | |
397 | Float_t dy = 0.014; | |
398 | Float_t x0 = 0.05; | |
399 | Float_t x1 = 0.95; | |
400 | ||
401 | TButton *button; | |
402 | char but1[] = "gAlice->Display()->ShowNextEvent(1)"; | |
403 | button = new TButton("Next",but1,x0,y-dbutton,x1,y); | |
404 | button->SetFillColor(38); | |
405 | button->Draw(); | |
406 | ||
407 | y -= dbutton +dy; | |
408 | char but2[] = "gAlice->Display()->ShowNextEvent(-1)"; | |
409 | button = new TButton("Previous",but2,x0,y-dbutton,x1,y); | |
410 | button->SetFillColor(38); | |
411 | button->Draw(); | |
412 | ||
413 | y -= dbutton +dy; | |
414 | char but3[] = "gAlice->Display()->SetView(90,-90,90)"; | |
415 | button = new TButton("Top View",but3,x0,y-dbutton,x1,y); | |
416 | button->SetFillColor(butcolor); | |
417 | button->Draw(); | |
418 | ||
419 | y -= dbutton +dy; | |
420 | char but4[] = "gAlice->Display()->SetView(90,0,-90)"; | |
421 | button = new TButton("Side View",but4,x0,y-dbutton,x1,y); | |
422 | button->SetFillColor(butcolor); | |
423 | button->Draw(); | |
424 | ||
425 | y -= dbutton +dy; | |
426 | char but5[] = "gAlice->Display()->SetView(0,-90,0)"; | |
427 | button = new TButton("Front View",but5,x0,y-dbutton,x1,y); | |
428 | button->SetFillColor(butcolor); | |
429 | button->Draw(); | |
430 | ||
431 | y -= dbutton +dy; | |
432 | char but6[] = "gAlice->Display()->DrawAllViews()"; | |
433 | button = new TButton("All Views",but6,x0,y-dbutton,x1,y); | |
434 | button->SetFillColor(butcolor); | |
435 | button->Draw(); | |
436 | ||
437 | y -= dbutton +dy; | |
438 | char but7[] = "gAlice->Display()->DrawViewGL()"; | |
439 | button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y); | |
440 | button->SetFillColor(38); | |
441 | button->Draw(); | |
442 | ||
443 | y -= dbutton +dy; | |
444 | char but8[] = "gAlice->Display()->DrawViewX3D()"; | |
445 | button = new TButton("X3D",but8,x0,y-dbutton,x1,y); | |
446 | button->SetFillColor(38); | |
447 | button->Draw(); | |
448 | ||
449 | // display logo | |
450 | TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22); | |
451 | diamond->SetFillColor(50); | |
452 | diamond->SetTextAlign(22); | |
453 | diamond->SetTextColor(5); | |
454 | diamond->SetTextSize(0.11); | |
455 | diamond->Draw(); | |
456 | diamond->AddText(".. "); | |
457 | diamond->AddText("ROOT"); | |
458 | diamond->AddText("ALICE"); | |
459 | diamond->AddText("... "); | |
460 | diamond->AddText(" "); | |
461 | } | |
462 | ||
463 | //______________________________________________________________________________ | |
464 | Int_t AliDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
465 | { | |
466 | // Compute distance from point px,py to objects in event | |
467 | ||
468 | gPad->SetCursor(kCross); | |
469 | ||
470 | if (gPad == fTrigPad) return 9999; | |
471 | if (gPad == fCutPad) return 9999; | |
472 | if (gPad == fEtaPad) return 9999; | |
473 | ||
aee8290b | 474 | const Int_t kbig = 9999; |
475 | Int_t dist = kbig; | |
fe4da5cc | 476 | Float_t xmin = gPad->GetX1(); |
477 | Float_t xmax = gPad->GetX2(); | |
478 | Float_t dx = 0.02*(xmax - xmin); | |
479 | Float_t x = gPad->AbsPixeltoX(px); | |
480 | if (x < xmin+dx || x > xmax-dx) return dist; | |
481 | ||
482 | if (fZoomMode) return 0; | |
483 | else return 7; | |
484 | } | |
485 | ||
486 | //_____________________________________________________________________________ | |
487 | void AliDisplay::Draw(Option_t *) | |
488 | { | |
489 | // Display current event | |
490 | ||
491 | if (fDrawAllViews) { | |
492 | DrawAllViews(); | |
493 | return; | |
494 | } | |
495 | ||
496 | fPad->cd(); | |
497 | ||
498 | DrawView(fTheta, fPhi, fPsi); | |
499 | ||
500 | // Display the event number and title | |
501 | fPad->cd(); | |
502 | DrawTitle(); | |
503 | } | |
504 | ||
505 | //_____________________________________________________________________________ | |
506 | void AliDisplay::DrawAllViews() | |
507 | { | |
508 | // Draw front,top,side and 30 deg views | |
509 | ||
510 | fDrawAllViews = kTRUE; | |
511 | fPad->cd(); | |
512 | fPad->SetFillColor(15); | |
513 | fPad->Clear(); | |
514 | fPad->Divide(2,2); | |
515 | ||
516 | // draw 30 deg view | |
517 | fPad->cd(1); | |
518 | DrawView(30, 30, 0); | |
519 | DrawTitle(); | |
520 | ||
521 | // draw front view | |
522 | fPad->cd(2); | |
523 | DrawView(0, -90,0); | |
524 | DrawTitle("Front"); | |
525 | ||
526 | // draw top view | |
527 | fPad->cd(3); | |
528 | DrawView(90, -90, 90); | |
529 | DrawTitle("Top"); | |
530 | ||
531 | // draw side view | |
532 | fPad->cd(4); | |
533 | DrawView(90, 0, -90); | |
534 | DrawTitle("Side"); | |
535 | ||
536 | fPad->cd(2); | |
537 | } | |
538 | ||
539 | //_____________________________________________________________________________ | |
540 | void AliDisplay::DrawHits() | |
541 | { | |
542 | // Draw hits for all ALICE detectors | |
543 | ||
544 | Float_t cutmin, cutmax, etamin, etamax, pmom, smin, smax, eta, theta, r; | |
545 | Float_t *pxyz; | |
546 | Int_t ntracks,track; | |
1578254f | 547 | TParticle *particle; |
fe4da5cc | 548 | TObjArray *points; |
549 | AliPoints *pm; | |
550 | ||
551 | //Get cut slider | |
552 | smax = fCutSlider->GetMaximum(); | |
553 | smin = fCutSlider->GetMinimum(); | |
aee8290b | 554 | cutmin = kptcutmax*smin; |
555 | if (smax < 0.98) cutmax = kptcutmax*smax; | |
fe4da5cc | 556 | else cutmax = 100000; |
557 | ||
558 | //Get eta slider | |
559 | smax = fEtaSlider->GetMaximum(); | |
560 | smin = fEtaSlider->GetMinimum(); | |
aee8290b | 561 | etamin = ketacutmax*(2*smin-1); |
562 | etamax = ketacutmax*(2*smax-1); | |
fe4da5cc | 563 | if (smin < 0.02) etamin = -1000; |
564 | if (smax > 0.98) etamax = 1000; | |
565 | ||
8494b010 | 566 | TIter next(gAlice->Modules()); |
567 | AliModule *module; | |
fe4da5cc | 568 | fHitsCuts = 0; |
8494b010 | 569 | while((module = (AliModule*)next())) { |
570 | if (!module->IsActive()) continue; | |
571 | points = module->Points(); | |
fe4da5cc | 572 | if (!points) continue; |
573 | ntracks = points->GetEntriesFast(); | |
574 | for (track=0;track<ntracks;track++) { | |
575 | pm = (AliPoints*)points->UncheckedAt(track); | |
576 | if (!pm) continue; | |
577 | particle = pm->GetParticle(); | |
578 | if (!particle) continue; | |
1578254f | 579 | pmom = particle->P(); |
fe4da5cc | 580 | if (pmom < cutmin) continue; |
581 | if (pmom > cutmax) continue; | |
582 | // as a first approximation, take eta of first point | |
583 | pxyz = pm->GetP(); | |
584 | r = TMath::Sqrt(pxyz[0]*pxyz[0] + pxyz[1]*pxyz[1]); | |
585 | theta = TMath::ATan2(r,TMath::Abs(pxyz[2])); | |
33d37c81 | 586 | if(theta) eta = -TMath::Log(TMath::Abs(TMath::Tan(0.5*theta))); else eta = 1e10; |
fe4da5cc | 587 | if (pxyz[2] < 0) eta = -eta; |
588 | if (eta < etamin || eta > etamax) continue; | |
589 | pm->Draw(); | |
590 | fHitsCuts += pm->GetN(); | |
591 | } | |
592 | } | |
593 | } | |
594 | ||
595 | //_____________________________________________________________________________ | |
596 | void AliDisplay::DrawTitle(Option_t *option) | |
597 | { | |
598 | // Draw the event title | |
599 | ||
600 | Float_t xmin = gPad->GetX1(); | |
601 | Float_t xmax = gPad->GetX2(); | |
602 | Float_t ymin = gPad->GetY1(); | |
603 | Float_t ymax = gPad->GetY2(); | |
604 | Float_t dx = xmax-xmin; | |
605 | Float_t dy = ymax-ymin; | |
606 | ||
607 | if (strlen(option) == 0) { | |
608 | TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy); | |
609 | title->SetBit(kCanDelete); | |
610 | title->SetFillColor(42); | |
611 | title->Draw(); | |
612 | char ptitle[100]; | |
613 | sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun()); | |
614 | title->AddText(ptitle); | |
615 | Int_t nparticles = gAlice->Particles()->GetEntriesFast(); | |
616 | sprintf(ptitle,"Nparticles = %d Nhits = %d",nparticles, fHitsCuts); | |
617 | title->AddText(ptitle); | |
618 | } else { | |
619 | TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option); | |
620 | label->SetBit(kCanDelete); | |
621 | label->SetFillColor(42); | |
622 | label->Draw(); | |
623 | } | |
624 | } | |
625 | ||
626 | //_____________________________________________________________________________ | |
627 | void AliDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi) | |
628 | { | |
629 | // Draw a view of ALICE | |
630 | ||
631 | gPad->SetCursor(kWatch); | |
632 | gPad->SetFillColor(1); | |
633 | gPad->Clear(); | |
634 | ||
635 | Int_t iret; | |
636 | TView *view = new TView(1); | |
637 | Float_t range = fRrange*fRangeSlider->GetMaximum(); | |
638 | view->SetRange(-range,-range,-range,range, range, range); | |
639 | fZoomX0[0] = -1; | |
640 | fZoomY0[0] = -1; | |
641 | fZoomX1[0] = 1; | |
642 | fZoomY1[0] = 1; | |
643 | fZooms = 0; | |
644 | ||
645 | // Display Alice Geometry | |
646 | gAlice->GetGeometry()->Draw("same"); | |
647 | ||
648 | //Loop on all detectors to add their products to the pad | |
649 | DrawHits(); | |
650 | ||
651 | // add itself to the list (must be last) | |
652 | AppendPad(); | |
653 | ||
654 | view->SetView(phi, theta, psi, iret); | |
655 | } | |
656 | ||
657 | //_____________________________________________________________________________ | |
658 | void AliDisplay::DrawViewGL() | |
659 | { | |
660 | // Draw current view using OPENGL | |
661 | ||
662 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
663 | pad->cd(); | |
664 | TView *view = pad->GetView(); | |
665 | if (!view) return; | |
666 | pad->x3d("OPENGL"); | |
667 | } | |
668 | ||
669 | //_____________________________________________________________________________ | |
670 | void AliDisplay::DrawViewX3D() | |
671 | { | |
672 | // Draw current view using X3D | |
673 | ||
674 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
675 | pad->cd(); | |
676 | TView *view = pad->GetView(); | |
677 | if (!view) return; | |
678 | pad->x3d(); | |
679 | } | |
680 | ||
681 | //_____________________________________________________________________________ | |
682 | void AliDisplay::EnableDetector(const char *name) | |
683 | { | |
684 | // Enable detector name in graphics views | |
685 | ||
8494b010 | 686 | AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name); |
687 | if (!module) return; | |
688 | module->Enable(); | |
fe4da5cc | 689 | Draw(); |
690 | } | |
691 | ||
692 | //______________________________________________________________________________ | |
693 | void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
694 | { | |
695 | // Execute action corresponding to the mouse event | |
696 | ||
697 | static Float_t x0, y0, x1, y1; | |
698 | ||
699 | static Int_t pxold, pyold; | |
700 | static Int_t px0, py0; | |
701 | static Int_t linedrawn; | |
702 | Float_t temp; | |
703 | ||
704 | if (px == 0 && py == 0) { //when called by sliders | |
705 | if (event == kButton1Up) { | |
706 | Draw(); | |
707 | } | |
708 | return; | |
709 | } | |
710 | if (!fZoomMode && gPad->GetView()) { | |
711 | gPad->GetView()->ExecuteRotateView(event, px, py); | |
712 | return; | |
713 | } | |
714 | ||
715 | // something to zoom ? | |
716 | // fPad->SetCursor(kCross); | |
717 | gPad->SetCursor(kCross); | |
718 | ||
719 | switch (event) { | |
720 | ||
721 | case kButton1Down: | |
084c1b4a | 722 | gVirtualX->SetLineColor(-1); |
fe4da5cc | 723 | gPad->TAttLine::Modify(); //Change line attributes only if necessary |
724 | x0 = gPad->AbsPixeltoX(px); | |
725 | y0 = gPad->AbsPixeltoY(py); | |
726 | px0 = px; py0 = py; | |
727 | pxold = px; pyold = py; | |
728 | linedrawn = 0; | |
729 | return; | |
730 | ||
731 | case kButton1Motion: | |
084c1b4a | 732 | if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
fe4da5cc | 733 | pxold = px; |
734 | pyold = py; | |
735 | linedrawn = 1; | |
084c1b4a | 736 | gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
fe4da5cc | 737 | return; |
738 | ||
739 | case kButton1Up: | |
740 | gPad->GetCanvas()->FeedbackMode(kFALSE); | |
741 | if (px == px0) return; | |
742 | if (py == py0) return; | |
743 | x1 = gPad->AbsPixeltoX(px); | |
744 | y1 = gPad->AbsPixeltoY(py); | |
745 | ||
746 | if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;} | |
747 | if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;} | |
748 | gPad->Range(x0,y0,x1,y1); | |
749 | if (fZooms < kMAXZOOMS-1) { | |
750 | fZooms++; | |
751 | fZoomX0[fZooms] = x0; | |
752 | fZoomY0[fZooms] = y0; | |
753 | fZoomX1[fZooms] = x1; | |
754 | fZoomY1[fZooms] = y1; | |
755 | } | |
756 | gPad->Modified(kTRUE); | |
757 | return; | |
758 | } | |
759 | ||
760 | } | |
761 | ||
762 | //___________________________________________ | |
763 | void AliDisplay::LoadPoints() | |
764 | { | |
765 | // Read hits info and store x,y,z info in arrays fPoints | |
766 | // Loop on all detectors | |
767 | ||
768 | gAlice->ResetPoints(); | |
8494b010 | 769 | TIter next(gAlice->Modules()); |
770 | AliModule *module; | |
fe4da5cc | 771 | Int_t ntracks = gAlice->GetNtrack(); |
772 | for (Int_t track=0; track<ntracks;track++) { | |
773 | gAlice->ResetHits(); | |
774 | gAlice->TreeH()->GetEvent(track); | |
8494b010 | 775 | while((module = (AliModule*)next())) { |
776 | module->LoadPoints(track); | |
fe4da5cc | 777 | } |
778 | next.Reset(); | |
779 | } | |
780 | } | |
781 | ||
782 | //_____________________________________________________________________________ | |
783 | void AliDisplay::Paint(Option_t *) | |
784 | { | |
785 | // Paint miscellaneous items | |
786 | ||
787 | } | |
788 | ||
789 | //_____________________________________________________________________________ | |
790 | void AliDisplay::SetPickMode() | |
791 | { | |
ef42d733 | 792 | // |
793 | // Set Pick Mode -- disable zoom | |
794 | // | |
fe4da5cc | 795 | fZoomMode = 0; |
796 | ||
797 | fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC()); | |
798 | fTrigPad->Modified(); | |
799 | } | |
800 | ||
801 | //_____________________________________________________________________________ | |
802 | void AliDisplay::SetZoomMode() | |
803 | { | |
ef42d733 | 804 | // |
805 | // Set Zoom Mode -- disable pick | |
806 | // | |
fe4da5cc | 807 | fZoomMode = 1; |
808 | ||
809 | fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC()); | |
810 | fTrigPad->Modified(); | |
811 | } | |
812 | ||
813 | //_____________________________________________________________________________ | |
814 | void AliDisplay::SetPTcut(Float_t ptcut) | |
815 | { | |
ef42d733 | 816 | // |
817 | // Set Pt Cut | |
818 | // | |
fe4da5cc | 819 | fPTcut = ptcut; |
820 | ||
821 | if (!fPad) return; | |
822 | fPad->Clear(); | |
823 | Draw(); | |
824 | } | |
825 | ||
826 | //_____________________________________________________________________________ | |
827 | void AliDisplay::SetRange(Float_t rrange, Float_t zrange) | |
828 | { | |
829 | // Set view range along R and Z | |
830 | fRrange = rrange; | |
831 | fZrange = zrange; | |
832 | ||
833 | if (!fPad) return; | |
834 | fPad->Clear(); | |
835 | Draw(); | |
836 | } | |
837 | ||
838 | //_____________________________________________________________________________ | |
839 | void AliDisplay::SetView(Float_t theta, Float_t phi, Float_t psi) | |
840 | { | |
841 | // change viewing angles for current event | |
842 | ||
843 | fPad->cd(); | |
844 | fDrawAllViews = kFALSE; | |
845 | fPhi = phi; | |
846 | fTheta = theta; | |
847 | fPsi = psi; | |
848 | Int_t iret = 0; | |
849 | ||
850 | TView *view = gPad->GetView(); | |
851 | if (view) view->SetView(fPhi, fTheta, fPsi, iret); | |
852 | else Draw(); | |
853 | ||
854 | gPad->Modified(); | |
855 | } | |
856 | ||
857 | //_____________________________________________________________________________ | |
858 | void AliDisplay::ShowNextEvent(Int_t delta) | |
859 | { | |
860 | // Display (current event_number+delta) | |
861 | // delta = 1 shown next event | |
862 | // delta = -1 show previous event | |
863 | ||
864 | if (delta) { | |
865 | gAlice->Clear(); | |
aee8290b | 866 | Int_t currentEvent = gAlice->GetHeader()->GetEvent(); |
867 | Int_t newEvent = currentEvent + delta; | |
868 | gAlice->GetEvent(newEvent); | |
fe4da5cc | 869 | if (!gAlice->TreeH()) return; |
870 | } | |
871 | LoadPoints(); | |
872 | fPad->cd(); | |
873 | Draw(); | |
874 | } | |
875 | ||
876 | //______________________________________________________________________________ | |
877 | void AliDisplay::UnZoom() | |
878 | { | |
aee8290b | 879 | // |
880 | // Resets ZOOM | |
881 | // | |
882 | if (fZooms <= 0) return; | |
883 | fZooms--; | |
884 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
885 | pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]); | |
886 | pad->Modified(); | |
887 | } | |
888 | ||
889 | //_____________________________________________________________________________ | |
890 | AliDisplay & AliDisplay::operator=(const AliDisplay &disp) | |
891 | { | |
892 | // | |
893 | // Assignment operator | |
894 | // | |
895 | disp.Copy(*this); | |
896 | return (*this); | |
fe4da5cc | 897 | } |