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$ |
38b32e9f |
18 | Revision 1.6 1999/11/09 07:38:51 fca |
19 | Changes for compatibility with version 2.23 of ROOT |
20 | |
084c1b4a |
21 | Revision 1.5 1999/09/29 09:24:29 fca |
22 | Introduction of the Copyright and cvs Log |
23 | |
4c039060 |
24 | */ |
25 | |
ddae0931 |
26 | |
27 | ////////////////////////////////////////////////////////////////////////// |
28 | // // |
29 | // AliDisplay // |
30 | // // |
31 | // Utility class to display ALICE outline, tracks, hits,.. // |
32 | // // |
33 | ////////////////////////////////////////////////////////////////////////// |
34 | |
35 | #include <TROOT.h> |
36 | #include <TTree.h> |
37 | #include <TButton.h> |
38 | #include <TColor.h> |
39 | #include <TCanvas.h> |
40 | #include <TView.h> |
41 | #include <TText.h> |
42 | #include <TPolyMarker3D.h> |
43 | #include <TPolyMarker.h> |
44 | #include <TPaveLabel.h> |
45 | #include <TPaveText.h> |
46 | #include <TList.h> |
47 | #include <TDiamond.h> |
48 | #include <TNode.h> |
49 | #include <TArc.h> |
50 | #include <TTUBE.h> |
51 | #include <TSlider.h> |
52 | #include <TSliderBox.h> |
53 | #include <TGaxis.h> |
084c1b4a |
54 | #include <TVirtualX.h> |
ddae0931 |
55 | #include <TMath.h> |
56 | #include <X3DBuffer.h> |
57 | |
58 | #include "AliRun.h" |
59 | #include "AliDetector.h" |
60 | #include "AliRICH.h" |
61 | #include "AliRICHConst.h" |
62 | #include "AliRICHdisplay.h" |
63 | #include "AliRICHpoints.h" |
64 | #include "TParticle.h" |
65 | |
66 | |
67 | ClassImp(AliRICHdisplay) |
68 | |
69 | |
70 | //____________________________________________________________________________ |
71 | AliRICHdisplay::AliRICHdisplay() |
72 | { |
73 | fPoints = 0; |
74 | fPhits = 0; |
75 | fPCerenkovs = 0; |
76 | fCanvas = 0; |
77 | } |
78 | |
79 | //_____________________________________________________________________________ |
80 | AliRICHdisplay::AliRICHdisplay(Int_t size) |
81 | { |
82 | // Create an event display object. |
83 | // A canvas named "edisplay" is created with a vertical size in pixels |
84 | // |
85 | // A QUICK Overview of the Event Display functions |
86 | // =============================================== |
87 | // |
88 | // The event display can ve invoked by executing the macro "display.C" |
89 | // A canvas like in the picture below will appear. |
90 | // |
91 | // On the left side of the canvas, the following buttons appear: |
92 | // *Next* to move to the next event |
93 | // *Previous* to move to the previous event |
94 | |
95 | // *Pick* Select this option to be able to point on a track with the |
96 | // mouse. Once on the track, use the right button to select |
97 | // an action. For example, select SetMarkerAttributes to |
98 | // change the marker type/color/size for the track. |
99 | // *Zoom* Select this option (default) if you want to zoom. |
100 | // To zoom, simply select the selected area with the left button. |
101 | // *UnZoom* To revert to the previous picture size. |
102 | // |
103 | // slider R On the left side, the vertical slider can be used to |
104 | // set the default picture size. |
105 | // |
106 | // When you are in Zoom mode, you can click on the black part of the canvas |
107 | // to select special options with the right mouse button. |
108 | |
109 | // |
110 | // When you are in pick mode, you can "Inspect" the object pointed by the mouse. |
111 | // When you are on a track, select the menu item "InspectParticle" |
112 | // to display the current particle attributes. |
113 | // |
114 | // You can activate the Root browser by selecting the Inspect menu |
115 | // in the canvas tool bar menu. Then select "Start Browser" |
116 | // This will open a new canvas with the browser. At this point, you may want |
117 | // to display some histograms (from the Trees). Go to the "File" menu |
118 | // of the browser and click on "New canvas". |
119 | // In the browser, click on item "ROOT files" in the left pane. |
120 | // Click on galice.root. |
121 | // Click on TH |
122 | // Click on TPC for example |
123 | // Click on any variable (eg TPC.fX) to histogram the variable. |
124 | // |
125 | // If you are lost, you can click on HELP in any Root canvas or browser. |
126 | //Begin_Html |
127 | /* |
128 | <img src="gif/aliRICHdisplay.gif"> |
129 | */ |
130 | //End_Html |
131 | |
132 | |
133 | fPad = 0; |
134 | |
135 | gAlice->SetDisplay(this); |
136 | |
137 | // Initialize display default parameters |
138 | SetRange(); |
139 | |
140 | // Set front view by default |
141 | fTheta = 90; |
142 | fPhi = 90; |
143 | fPsi = 0; |
144 | fChamber = 1; |
145 | fCathode = 1; |
146 | // fRzone = 1.e10; |
147 | fDrawClusters = kTRUE; |
148 | fZoomMode = 1; |
149 | fZooms = 0; |
150 | fClustersCuts = 0; |
151 | fPoints = 0; |
152 | fPCerenkovs = 0; |
153 | fPhits = 0; |
154 | // Create colors |
155 | CreateColors(); |
156 | // Create display canvas |
157 | Int_t ysize = size; |
158 | if (ysize < 100) ysize = 750; |
159 | Int_t xsize = Int_t(size*830./ysize); |
160 | fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize); |
ddae0931 |
161 | fCanvas->ToggleEventStatus(); |
162 | |
163 | // Create main display pad |
164 | fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1); |
165 | fPad->Draw(); |
166 | fPad->Modified(); |
167 | fPad->SetFillColor(1); |
168 | fPad->SetBorderSize(2); |
169 | |
170 | fCanvas->cd(); |
171 | |
172 | // Create colors pad |
173 | fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1); |
174 | fColPad->Draw(); |
175 | fColPad->Modified(); |
176 | fColPad->SetFillColor(19); |
177 | fColPad->SetBorderSize(2); |
178 | fColPad->cd(); |
179 | DisplayColorScale(); |
180 | |
181 | fCanvas->cd(); |
182 | |
183 | // Create user interface control pad |
184 | DisplayButtons(); |
185 | fCanvas->cd(); |
186 | |
187 | // Create Range and mode pad |
188 | Float_t dxtr = 0.15; |
189 | Float_t dytr = 0.45; |
190 | fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr); |
38b32e9f |
191 | fTrigPad->SetEditable(kFALSE); |
ddae0931 |
192 | fTrigPad->Draw(); |
193 | fTrigPad->cd(); |
194 | fTrigPad->SetFillColor(22); |
195 | fTrigPad->SetBorderSize(2); |
196 | fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98); |
197 | fRangeSlider->SetObject(this); |
198 | char pickmode[] = "gAlice->Display()->SetPickMode()"; |
199 | Float_t db = 0.09; |
200 | fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db); |
201 | fPickButton->SetFillColor(38); |
202 | fPickButton->Draw(); |
203 | char zoommode[] = "gAlice->Display()->SetZoomMode()"; |
204 | fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db); |
205 | fZoomButton->SetFillColor(38); |
206 | fZoomButton->Draw(); |
207 | fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db); |
208 | fArcButton->SetFillColor(kGreen); |
209 | fArcButton->Draw(); |
210 | char butUnzoom[] = "gAlice->Display()->UnZoom()"; |
211 | TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15); |
212 | button->SetFillColor(38); |
213 | button->Draw(); |
214 | AppendPad(); // append display object as last object to force selection |
215 | |
216 | fCanvas->cd(); |
217 | fCanvas->Update(); |
218 | } |
219 | |
220 | |
221 | //_____________________________________________________________________________ |
222 | AliRICHdisplay::~AliRICHdisplay() |
223 | { |
224 | // Delete space point structure |
225 | if (fPoints) fPoints->Delete(); |
226 | delete fPoints; |
227 | fPoints = 0; |
228 | // |
229 | if (fPhits) fPhits->Delete(); |
230 | delete fPhits; |
231 | fPhits = 0; |
232 | // |
233 | if (fPCerenkovs) fPCerenkovs->Delete(); |
234 | delete fPCerenkovs; |
235 | fPCerenkovs = 0; |
236 | } |
237 | |
238 | //_____________________________________________________________________________ |
239 | void AliRICHdisplay::Clear(Option_t *) |
240 | { |
241 | // Delete graphics temporary objects |
242 | } |
243 | |
244 | //_____________________________________________________________________________ |
245 | void AliRICHdisplay::DisplayButtons() |
246 | { |
247 | // Create the user interface buttons |
248 | |
249 | |
250 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); |
38b32e9f |
251 | fButtons->SetEditable(kFALSE); |
ddae0931 |
252 | fButtons->Draw(); |
253 | fButtons->SetFillColor(38); |
254 | fButtons->SetBorderSize(2); |
255 | fButtons->cd(); |
256 | |
257 | // Int_t butcolor = 33; |
258 | Float_t dbutton = 0.08; |
259 | Float_t y = 0.96; |
260 | Float_t dy = 0.014; |
261 | Float_t x0 = 0.05; |
262 | Float_t x1 = 0.95; |
263 | |
264 | TButton *button; |
265 | char but1[] = "gAlice->Display()->ShowNextEvent(1)"; |
266 | button = new TButton("Next",but1,x0,y-dbutton,x1,y); |
267 | button->SetFillColor(38); |
268 | button->Draw(); |
269 | |
270 | y -= dbutton +dy; |
271 | char but2[] = "gAlice->Display()->ShowNextEvent(-1)"; |
272 | button = new TButton("Previous",but2,x0,y-dbutton,x1,y); |
273 | button->SetFillColor(38); |
274 | button->Draw(); |
275 | |
276 | // display logo |
277 | TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22); |
278 | diamond->SetFillColor(50); |
279 | diamond->SetTextAlign(22); |
280 | diamond->SetTextColor(5); |
281 | diamond->SetTextSize(0.11); |
282 | diamond->Draw(); |
283 | diamond->AddText(".. "); |
284 | diamond->AddText("ROOT"); |
285 | diamond->AddText("RICH"); |
286 | diamond->AddText("... "); |
287 | diamond->AddText(" "); |
288 | } |
289 | |
290 | //_____________________________________________________________________________ |
291 | void AliRICHdisplay::CreateColors() |
292 | { |
293 | // Create the colors palette used to display clusters |
294 | |
295 | Int_t k,i; |
296 | Int_t color; |
297 | Float_t r,g,b; |
298 | |
299 | for (k=1;k<=5;k++) { |
300 | switch(k) { |
301 | case 1: |
302 | for (i=1;i<=5;i++) { |
303 | r=1.; |
304 | g=i*0.2; |
305 | b=0.; |
306 | color=i; |
307 | color=50+23-color; |
308 | new TColor(color,r,g,b); |
309 | } |
310 | break; |
311 | case 2: |
312 | for (i=1;i<=4;i++) { |
313 | r=1.1-i*0.2; |
314 | g=1.; |
315 | b=0.; |
316 | color=i+5; |
317 | color=50+23-color; |
318 | new TColor(color,r,g,b); |
319 | } |
320 | break; |
321 | case 3: |
322 | for (i=1;i<=4;i++) { |
323 | r=0.; |
324 | g=1.; |
325 | b=i*0.2+0.2; |
326 | color=i+9; |
327 | color=50+23-color; |
328 | new TColor(color,r,g,b); |
329 | } |
330 | break; |
331 | case 4: |
332 | for (i=1;i<=4;i++) { |
333 | r=0.; |
334 | g=1.1-i*0.2; |
335 | b=1.; |
336 | color=i+13; |
337 | color=50+23-color; |
338 | new TColor(color,r,g,b); |
339 | } |
340 | break; |
341 | case 5: |
342 | for (i=1;i<=5;i++) { |
343 | r=i*0.2; |
344 | g=0.; |
345 | b=1.; |
346 | color=i+17; |
347 | color=50+23-color; |
348 | new TColor(color,r,g,b); |
349 | } |
350 | break; |
351 | } |
352 | |
353 | } |
354 | |
355 | } |
356 | |
357 | //_____________________________________________________________________________ |
358 | void AliRICHdisplay::DisplayColorScale() |
359 | { |
360 | |
361 | Int_t i; |
362 | Int_t color; |
363 | Float_t xlow, ylow, xup, yup, hs; |
364 | Float_t x1, y1, x2, y2; |
365 | x1 = y1 = 0; |
366 | x2 = y2 = 20; |
367 | |
368 | gPad->SetFillColor(0); |
369 | gPad->Clear(); |
370 | gPad->Range(x1,y1,x2,y2); |
371 | TText *text = new TText(0,0,""); |
372 | text->SetTextFont(61); |
373 | text->SetTextSize(0.03); |
374 | text->SetTextAlign(22); |
375 | |
376 | TBox *box; |
377 | char label[8]; |
378 | //*-* draw colortable boxes |
379 | hs = (y2-y1)/Float_t(22); |
380 | xlow=x1+1; |
381 | xup=x2-9; |
382 | for (i=0;i<22;i++) { |
383 | ylow = y1 + hs*(Float_t(i)); |
384 | yup = y1 + hs*(Float_t(i+1)); |
385 | color = 51+i; |
386 | Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22); |
387 | Int_t scale=(Int_t)TMath::Exp(logscale); |
388 | sprintf(label,"%d",scale); |
389 | box = new TBox(xlow, ylow, xup, yup); |
390 | box->SetFillColor(color); |
391 | box->Draw(); |
392 | text->DrawText(xup+4, 0.5*(ylow+yup),label); |
393 | } |
394 | } |
395 | |
396 | //______________________________________________________________________________ |
397 | Int_t AliRICHdisplay::DistancetoPrimitive(Int_t px, Int_t) |
398 | { |
399 | // Compute distance from point px,py to objects in event |
400 | |
401 | gPad->SetCursor(kCross); |
402 | |
403 | if (gPad == fTrigPad) return 9999; |
404 | |
405 | const Int_t big = 9999; |
406 | Int_t dist = big; |
407 | Float_t xmin = gPad->GetX1(); |
408 | Float_t xmax = gPad->GetX2(); |
409 | Float_t dx = 0.02*(xmax - xmin); |
410 | Float_t x = gPad->AbsPixeltoX(px); |
411 | if (x < xmin+dx || x > xmax-dx) return dist; |
412 | |
413 | if (fZoomMode) return 0; |
414 | else return 7; |
415 | } |
416 | |
417 | //_____________________________________________________________________________ |
418 | void AliRICHdisplay::Draw(Option_t *) |
419 | { |
420 | // Display current event |
421 | |
422 | fPad->cd(); |
423 | |
424 | DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames |
425 | |
426 | // Display the event number and title |
427 | fPad->cd(); |
428 | DrawTitle(); |
429 | } |
430 | |
431 | |
432 | //_____________________________________________________________________________ |
433 | |
434 | void AliRICHdisplay::DrawCerenkovs() |
435 | { |
436 | // Draw cerenkovs hits for RICH chambers |
437 | |
438 | LoadCerenkovs(fChamber); |
439 | printf("\nDrawCerenkovs\n"); |
440 | |
441 | Int_t ntracks, track; |
442 | TObjArray *cpoints; |
443 | AliRICHpoints *pm; |
444 | |
445 | fHitsCuts = 0; |
446 | cpoints = fPCerenkovs; |
447 | printf ("Cpoints: %p",cpoints); |
448 | if (!cpoints) return; |
449 | ntracks = cpoints->GetEntriesFast(); |
450 | printf("DrawCerenkovs - ntracks %d \n",ntracks); |
451 | for (track=0;track<ntracks;track++) { |
452 | pm = (AliRICHpoints*)cpoints->UncheckedAt(track); |
453 | if (!pm) continue; |
454 | pm->Draw(); |
455 | fHitsCuts += pm->GetN(); |
456 | } |
457 | } |
458 | |
459 | //_____________________________________________________________________________ |
460 | void AliRICHdisplay::DrawClusters() |
461 | { |
462 | // Draw clusterss for RICH chambers |
463 | |
464 | Int_t ndigits, digit; |
465 | TObjArray *points; |
466 | AliRICHpoints *pm; |
467 | |
468 | fClustersCuts = 0; |
469 | points = fPoints; |
470 | if (!points) return; |
471 | ndigits = points->GetEntriesFast(); |
472 | printf("DrawClusters - ndigits %d \n",ndigits); |
473 | for (digit=0;digit<ndigits;digit++){ |
474 | pm = (AliRICHpoints*)points->UncheckedAt(digit); |
475 | if (!pm) continue; |
476 | pm->Draw(); |
477 | fClustersCuts +=pm->GetN(); |
478 | } |
479 | } |
480 | |
481 | //_____________________________________________________________________________ |
482 | void AliRICHdisplay::DrawHits() |
483 | { |
484 | // Draw hits for RICH chambers |
485 | |
486 | LoadHits(fChamber); |
487 | |
488 | Int_t ntracks, track; |
489 | TObjArray *points; |
490 | AliRICHpoints *pm; |
491 | |
492 | fHitsCuts = 0; |
493 | points = Phits(); |
494 | if (!points) return; |
495 | ntracks = points->GetEntriesFast(); |
496 | printf("DrawHits - ntracks %d \n",ntracks); |
497 | for (track=0;track<ntracks;track++) { |
498 | pm = (AliRICHpoints*)points->UncheckedAt(track); |
499 | if (!pm) continue; |
500 | pm->Draw(); |
501 | fHitsCuts += pm->GetN(); |
502 | } |
503 | } |
504 | |
505 | |
506 | //_____________________________________________________________________________ |
507 | void AliRICHdisplay::DrawTitle(Option_t *option) |
508 | { |
509 | // Draw the event title |
510 | |
511 | Float_t xmin = gPad->GetX1(); |
512 | Float_t xmax = gPad->GetX2(); |
513 | Float_t ymin = gPad->GetY1(); |
514 | Float_t ymax = gPad->GetY2(); |
515 | Float_t dx = xmax-xmin; |
516 | Float_t dy = ymax-ymin; |
517 | |
518 | if (strlen(option) == 0) { |
519 | TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy); |
520 | title->SetBit(kCanDelete); |
521 | title->SetFillColor(42); |
522 | title->Draw(); |
523 | char ptitle[100]; |
524 | sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun()); |
525 | title->AddText(ptitle); |
526 | Int_t nparticles = gAlice->Particles()->GetEntriesFast(); |
527 | sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",nparticles, fHitsCuts,fClustersCuts); |
528 | title->AddText(ptitle); |
529 | } else { |
530 | TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option); |
531 | label->SetBit(kCanDelete); |
532 | label->SetFillColor(42); |
533 | label->Draw(); |
534 | } |
535 | } |
536 | |
537 | //_____________________________________________________________________________ |
538 | void AliRICHdisplay::DrawView(Float_t theta, Float_t phi, Float_t psi) |
539 | { |
540 | // Draw a view of RICH clusters |
541 | |
542 | gPad->SetCursor(kWatch); |
543 | gPad->SetFillColor(1); |
544 | gPad->Clear(); |
545 | |
546 | Int_t iret; |
547 | TView *view = new TView(1); |
548 | Float_t range = fRrange*fRangeSlider->GetMaximum(); |
549 | view->SetRange(-range,-range,-range,range, range, range); |
550 | fZoomX0[0] = -1; |
551 | fZoomY0[0] = -1; |
552 | fZoomX1[0] = 1; |
553 | fZoomY1[0] = 1; |
554 | fZooms = 0; |
555 | |
556 | //Display RICH Chamber Geometry |
557 | gAlice->GetGeometry()->Draw("same"); |
558 | |
559 | //add clusters to the pad |
560 | DrawClusters(); |
561 | DrawHits(); |
562 | DrawCerenkovs(); |
563 | |
564 | // add itself to the list (must be last) |
565 | AppendPad(); |
566 | |
567 | view->SetView(phi, theta, psi, iret); |
568 | } |
569 | |
570 | |
571 | //______________________________________________________________________________ |
572 | void AliRICHdisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
573 | { |
574 | // Execute action corresponding to the mouse event |
575 | |
576 | static Float_t x0, y0, x1, y1; |
577 | |
578 | static Int_t pxold, pyold; |
579 | static Int_t px0, py0; |
580 | static Int_t linedrawn; |
581 | Float_t temp; |
582 | |
583 | if (px == 0 && py == 0) { //when called by sliders |
584 | if (event == kButton1Up) { |
585 | Draw(); |
586 | } |
587 | return; |
588 | } |
589 | if (!fZoomMode && gPad->GetView()) { |
590 | gPad->GetView()->ExecuteRotateView(event, px, py); |
591 | return; |
592 | } |
593 | |
594 | // something to zoom ? |
595 | gPad->SetCursor(kCross); |
596 | |
597 | switch (event) { |
598 | |
599 | case kButton1Down: |
084c1b4a |
600 | gVirtualX->SetLineColor(-1); |
ddae0931 |
601 | gPad->TAttLine::Modify(); //Change line attributes only if necessary |
602 | x0 = gPad->AbsPixeltoX(px); |
603 | y0 = gPad->AbsPixeltoY(py); |
604 | px0 = px; py0 = py; |
605 | pxold = px; pyold = py; |
606 | linedrawn = 0; |
607 | return; |
608 | |
609 | case kButton1Motion: |
084c1b4a |
610 | if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
ddae0931 |
611 | pxold = px; |
612 | pyold = py; |
613 | linedrawn = 1; |
084c1b4a |
614 | gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
ddae0931 |
615 | return; |
616 | |
617 | case kButton1Up: |
618 | gPad->GetCanvas()->FeedbackMode(kFALSE); |
619 | if (px == px0) return; |
620 | if (py == py0) return; |
621 | x1 = gPad->AbsPixeltoX(px); |
622 | y1 = gPad->AbsPixeltoY(py); |
623 | |
624 | if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;} |
625 | if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;} |
626 | gPad->Range(x0,y0,x1,y1); |
627 | if (fZooms < kMAXZOOM-1) { |
628 | fZooms++; |
629 | fZoomX0[fZooms] = x0; |
630 | fZoomY0[fZooms] = y0; |
631 | fZoomX1[fZooms] = x1; |
632 | fZoomY1[fZooms] = y1; |
633 | } |
634 | gPad->Modified(kTRUE); |
635 | return; |
636 | } |
637 | |
638 | } |
639 | |
640 | //___________________________________________ |
641 | void AliRICHdisplay::LoadDigits() |
642 | { |
643 | // Read digits info and store x,y,z info in arrays fPoints |
644 | // Loop on all detectors |
645 | |
646 | printf("Entering Load-digits"); |
647 | |
648 | |
649 | ResetPoints(); |
650 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); |
651 | AliRICHchamber* iChamber; |
652 | AliRICHsegmentation* segmentation; |
653 | Int_t NallDigits=0; |
c90dd3e2 |
654 | Int_t ich; |
ddae0931 |
655 | |
c90dd3e2 |
656 | for (ich=0; ich<7; ich++) { |
ddae0931 |
657 | TClonesArray *RICHdigits = RICH->DigitsAddress(ich); |
658 | if (RICHdigits == 0) continue; |
659 | gAlice->ResetDigits(); |
660 | gAlice->TreeD()->GetEvent(1); |
661 | Int_t ndigits = RICHdigits->GetEntriesFast(); |
662 | printf("Found %d digits in chamber %d \n",ndigits,ich); |
663 | NallDigits+=ndigits; |
664 | } |
665 | if (fPoints == 0) fPoints = new TObjArray(NallDigits); |
666 | Int_t counter=0; |
c90dd3e2 |
667 | for (ich=0; ich<7; ich++) { |
ddae0931 |
668 | TClonesArray *RICHdigits = RICH->DigitsAddress(ich); |
669 | if (RICHdigits == 0) continue; |
670 | gAlice->ResetDigits(); |
671 | gAlice->TreeD()->GetEvent(1); |
672 | Int_t ndigits = RICHdigits->GetEntriesFast(); |
673 | printf("Found %d digits in chamber %d \n",ndigits,ich); |
674 | if (ndigits == 0) continue; |
675 | |
676 | |
677 | |
678 | iChamber = &(RICH->Chamber(ich)); |
679 | printf("LoadPoints - chamber %d \n",ich); |
680 | segmentation=iChamber->GetSegmentationModel(1); |
681 | Float_t dpx = segmentation->Dpx(); |
682 | Float_t dpy = segmentation->Dpy(); |
683 | printf("LoadPoints - dpx, dpy %f %f \n",dpx,dpy); |
684 | AliRICHdigit *mdig; |
685 | AliRICHpoints *points = 0; |
686 | // |
687 | //loop over all digits and store their position |
688 | Int_t npoints=1; |
689 | |
690 | for (Int_t digit=0;digit<ndigits;digit++) { |
691 | mdig = (AliRICHdigit*)RICHdigits->UncheckedAt(digit); |
692 | points = new AliRICHpoints(npoints); |
693 | fPoints->AddAt(points,counter); |
694 | counter++; |
695 | Int_t charge=mdig->fSignal; |
696 | Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22)); |
697 | Int_t color=51+index; |
698 | if (color>72) color=72; |
699 | points->SetMarkerColor(color); |
700 | points->SetMarkerStyle(21); |
701 | points->SetMarkerSize(0.5); |
702 | // get the center of the pad - add on x and y half of pad size |
703 | Float_t xpad, ypad; |
704 | segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad); |
705 | printf("\n chamber x,y, %d %f %f ", ich, xpad, ypad); |
706 | |
707 | Float_t VecLoc[3]={xpad,0,ypad}; |
708 | Float_t VecGlob[3]; |
709 | iChamber->LocaltoGlobal(VecLoc,VecGlob); |
710 | points->SetParticle(-1); |
711 | points->SetHitIndex(-1); |
712 | points->SetTrackIndex(-1); |
713 | points->SetDigitIndex(digit); |
714 | points->SetPoint(0,VecGlob[0],VecGlob[1],VecGlob[2]); |
715 | } // loop over digits |
716 | } // loop over chambers |
717 | } |
718 | |
719 | |
720 | //___________________________________________ |
721 | void AliRICHdisplay::LoadHits(Int_t chamber) |
722 | { |
723 | // Read hits info and store x,y,z info in arrays fPhits |
724 | // Loop on all detectors |
725 | |
726 | printf("Entering Load-hits"); |
727 | |
728 | fChamber=chamber; |
729 | ResetPhits(); |
730 | |
731 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); |
732 | AliRICHchamber* iChamber; |
733 | |
734 | iChamber = &(RICH->Chamber(chamber-1)); |
735 | Float_t zpos=iChamber->ZPosition(); |
736 | printf("LoadHits - zpos %f \n",zpos); |
737 | |
738 | Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries(); |
739 | printf("ntracks %d\n",ntracks); |
740 | Int_t ntrks = gAlice->GetNtrack(); |
741 | printf("ntrks %d\n",ntrks); |
742 | |
743 | if (fPhits == 0) fPhits = new TObjArray(ntracks); |
744 | TVector *xp = new TVector(1000); |
745 | TVector *yp = new TVector(1000); |
746 | TVector *zp = new TVector(1000); |
747 | TVector *ptrk = new TVector(1000); |
748 | TVector *phit = new TVector(1000); |
749 | for (Int_t track=0; track<ntracks;track++) { |
750 | gAlice->ResetHits(); |
751 | gAlice->TreeH()->GetEvent(track); |
752 | TClonesArray *RICHhits = RICH->Hits(); |
753 | if (RICHhits == 0) return; |
754 | Int_t nhits = RICHhits->GetEntriesFast(); |
755 | if (nhits == 0) continue; |
756 | AliRICHhit *mHit; |
757 | AliRICHpoints *points = 0; |
758 | Int_t npoints=0; |
759 | for (Int_t hit=0;hit<nhits;hit++) { |
760 | mHit = (AliRICHhit*)RICHhits->UncheckedAt(hit); |
761 | (*xp)(npoints)=mHit->fX; |
762 | (*yp)(npoints)=mHit->fY; |
763 | (*zp)(npoints)=mHit->fZ; |
764 | (*ptrk)(npoints)=Float_t(mHit->GetTrack()); |
765 | (*phit)(npoints)=Float_t(hit); |
766 | npoints++; |
767 | } |
768 | |
769 | if (npoints == 0) continue; |
770 | points = new AliRICHpoints(npoints); |
771 | for (Int_t p=0;p<npoints;p++) { |
772 | points->SetMarkerColor(kRed); |
773 | points->SetMarkerStyle(5); |
774 | points->SetMarkerSize(1.); |
775 | points->SetParticle(Int_t((*ptrk)(p))); |
776 | points->SetHitIndex(Int_t((*phit)(p))); |
777 | points->SetTrackIndex(track); |
778 | points->SetDigitIndex(-1); |
779 | points->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p)); |
780 | } |
781 | xp->Zero(); |
782 | yp->Zero(); |
783 | ptrk->Zero(); |
784 | phit->Zero(); |
785 | fPhits->AddAt(points,track); |
786 | } |
787 | |
788 | } |
789 | |
790 | //_____________________________________________________________________________ |
791 | |
792 | void AliRICHdisplay::LoadCerenkovs(Int_t chamber) |
793 | { |
794 | // Read cerenkov hits info and store x,y,z info in array fPCerenkovs |
795 | // Loop on all detectors |
796 | |
797 | printf("Entering Load-Cerenkovs"); |
798 | |
799 | fChamber=chamber; |
800 | ResetPCerenkovs(); |
801 | |
802 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); |
803 | AliRICHchamber* iChamber; |
804 | |
805 | iChamber = &(RICH->Chamber(chamber-1)); |
806 | Float_t zpos=iChamber->ZPosition(); |
807 | printf("LoadCerenkovs - zpos %f \n",zpos); |
808 | |
809 | RICH->SetTreeAddress(); |
810 | Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries(); |
811 | printf("ntracks %d\n",ntracks); |
812 | Int_t ntrks = gAlice->GetNtrack(); |
813 | printf("ntrks %d\n",ntrks); |
814 | |
815 | if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks); |
816 | TVector *xp = new TVector(1000); |
817 | TVector *yp = new TVector(1000); |
818 | TVector *zp = new TVector(1000); |
819 | TVector *ptrk = new TVector(1000); |
820 | TVector *phit = new TVector(1000); |
821 | for (Int_t track=0; track<ntracks;track++) { |
822 | gAlice->ResetHits(); |
823 | gAlice->TreeH()->GetEvent(track); |
824 | TClonesArray *RICHCerenkovs = RICH->Cerenkovs(); |
825 | printf("RICHCerenkovs %p\n",RICHCerenkovs); |
826 | if (RICHCerenkovs == 0) return; |
827 | Int_t nhits = RICHCerenkovs->GetEntriesFast(); |
828 | if (nhits == 0) continue; |
829 | printf("nhits %d \n",nhits); |
830 | AliRICHCerenkov *mCerenkov; |
831 | AliRICHpoints *cpoints = 0; |
832 | Int_t npoints=0; |
833 | |
834 | //Display Cerenkov hits in blue |
835 | |
836 | for (Int_t hit=0;hit<nhits;hit++) { |
837 | mCerenkov = (AliRICHCerenkov*)RICHCerenkovs->UncheckedAt(hit); |
838 | (*xp)(npoints)=mCerenkov->fX; |
839 | (*yp)(npoints)=mCerenkov->fY; |
840 | (*zp)(npoints)=mCerenkov->fZ; |
841 | (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack()); |
842 | (*phit)(npoints)=Float_t(hit); |
843 | printf("track, trk %d %d\n",track,mCerenkov->GetTrack()); |
844 | npoints++; |
845 | } |
846 | if (npoints == 0) continue; |
847 | printf("npoints %d \n",npoints); |
848 | cpoints = new AliRICHpoints(npoints); |
849 | for (Int_t p=0;p<npoints;p++) { |
850 | cpoints->SetMarkerColor(kBlue); |
851 | cpoints->SetMarkerStyle(3); |
852 | cpoints->SetMarkerSize(1.); |
853 | cpoints->SetParticle(Int_t((*ptrk)(p))); |
854 | Int_t index=cpoints->GetIndex(); |
855 | printf("index %d \n",index); |
856 | cpoints->SetHitIndex(Int_t((*phit)(p))); |
857 | cpoints->SetTrackIndex(track); |
858 | cpoints->SetDigitIndex(-1); |
859 | cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p)); |
860 | } |
861 | xp->Zero(); |
862 | yp->Zero(); |
863 | ptrk->Zero(); |
864 | phit->Zero(); |
865 | fPCerenkovs->AddAt(cpoints,track); |
866 | } |
867 | } |
868 | |
869 | //_____________________________________________________________________________ |
870 | void AliRICHdisplay::Paint(Option_t *) |
871 | { |
872 | // Paint miscellaneous items |
873 | |
874 | } |
875 | |
876 | //_____________________________________________________________________________ |
877 | void AliRICHdisplay::SetPickMode() |
878 | { |
879 | fZoomMode = 0; |
880 | |
881 | fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC()); |
882 | fTrigPad->Modified(); |
883 | } |
884 | |
885 | //_____________________________________________________________________________ |
886 | void AliRICHdisplay::SetZoomMode() |
887 | { |
888 | fZoomMode = 1; |
889 | |
890 | fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC()); |
891 | fTrigPad->Modified(); |
892 | } |
893 | |
894 | //_____________________________________________________________________________ |
895 | void AliRICHdisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode) |
896 | { |
897 | // Set chamber and cathode number |
898 | fChamber = chamber; |
899 | fCathode = cathode; |
900 | |
901 | printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode); |
902 | if (!fPad) return; |
903 | fPad->Clear(); |
904 | LoadDigits(); |
905 | Draw(); |
906 | } |
907 | |
908 | //_____________________________________________________________________________ |
909 | void AliRICHdisplay::SetRange(Float_t rrange, Float_t zrange) |
910 | { |
911 | // Set view range along R and Z |
912 | fRrange = rrange; |
913 | fZrange = zrange; |
914 | |
915 | if (!fPad) return; |
916 | fPad->Clear(); |
917 | Draw(); |
918 | } |
919 | |
920 | //_____________________________________________________________________________ |
921 | void AliRICHdisplay::SetView(Float_t theta, Float_t phi, Float_t psi) |
922 | { |
923 | // change viewing angles for current event |
924 | |
925 | fPad->cd(); |
926 | fPhi = phi; |
927 | fTheta = theta; |
928 | fPsi = psi; |
929 | Int_t iret = 0; |
930 | |
931 | TView *view = gPad->GetView(); |
932 | if (view) view->SetView(fPhi, fTheta, fPsi, iret); |
933 | else Draw(); |
934 | |
935 | gPad->Modified(); |
936 | } |
937 | |
938 | //_____________________________________________________________________________ |
939 | void AliRICHdisplay::ShowNextEvent(Int_t delta) |
940 | { |
941 | // Display (current event_number+delta) |
942 | // delta = 1 shown next event |
943 | // delta = -1 show previous event |
944 | |
945 | if (delta) { |
946 | gAlice->Clear(); |
947 | Int_t current_event = gAlice->GetHeader()->GetEvent(); |
948 | Int_t new_event = current_event + delta; |
949 | gAlice->GetEvent(new_event); |
950 | if (!gAlice->TreeD()) return; |
951 | } |
952 | LoadDigits(); |
953 | DrawClusters(); |
954 | fPad->cd(); |
955 | Draw(); |
956 | |
957 | |
958 | } |
959 | |
960 | //______________________________________________________________________________ |
961 | void AliRICHdisplay::UnZoom() |
962 | { |
963 | if (fZooms <= 0) return; |
964 | fZooms--; |
965 | TPad *pad = (TPad*)gPad->GetPadSave(); |
966 | pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]); |
967 | pad->Modified(); |
968 | } |
969 | |
970 | //_____________________________________________________________________________ |
971 | void AliRICHdisplay::ResetPoints() |
972 | { |
973 | // |
974 | // Reset array of points |
975 | // |
976 | if (fPoints) { |
977 | fPoints->Delete(); |
978 | delete fPoints; |
979 | fPoints = 0; |
980 | } |
981 | } |
982 | //_____________________________________________________________________________ |
983 | void AliRICHdisplay::ResetPhits() |
984 | { |
985 | // |
986 | // Reset array of points |
987 | // |
988 | if (fPhits) { |
989 | fPhits->Delete(); |
990 | delete fPhits; |
991 | fPhits = 0; |
992 | } |
993 | } |
994 | //_____________________________________________________________________________ |
995 | void AliRICHdisplay::ResetPCerenkovs() |
996 | { |
997 | // |
998 | // Reset array of points |
999 | // |
1000 | if (fPCerenkovs) { |
1001 | fPCerenkovs->Delete(); |
1002 | delete fPCerenkovs; |
1003 | fPCerenkovs = 0; |
1004 | } |
1005 | } |