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