]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDisplay.cxx
Consistent treatment of Post/Clean
[u/mrichter/AliRoot.git] / MUON / AliMUONDisplay.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
18//////////////////////////////////////////////////////////////////////////
19// //
20// AliDisplay //
21// //
22// Utility class to display ALICE outline, tracks, hits,.. //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include <TROOT.h>
27#include <TTree.h>
28#include <TButton.h>
29#include <TColor.h>
30#include <TCanvas.h>
31#include <TView.h>
32#include <TText.h>
33#include <TPolyMarker3D.h>
34#include <TPaveLabel.h>
35#include <TPaveText.h>
36#include <TList.h>
37#include <TDiamond.h>
38#include <TNode.h>
39#include <TArc.h>
40#include <TTUBE.h>
41#include <TSlider.h>
42#include <TSliderBox.h>
43#include <TGaxis.h>
44#include <TVirtualX.h>
45#include <TMath.h>
46#include <TMatrix.h>
94de3818 47#include <TGeometry.h>
a9e2aefa 48#include <X3DBuffer.h>
49#include <TMarker3DBox.h>
50
51#include "AliRun.h"
52#include "AliDetector.h"
53#include "AliMUON.h"
54#include "AliMUONDisplay.h"
55#include "AliMUONPoints.h"
56#include "TParticle.h"
57#include "AliMUONTriggerDecision.h"
9e1a0ddb 58#include "AliHeader.h"
a9e2aefa 59
60#include "AliMUONHit.h"
61#include "AliMUONPadHit.h"
62#include "AliMUONDigit.h"
63#include "AliMUONRawCluster.h"
64
a30a000f 65#include "AliSegmentation.h"
a9e2aefa 66#include "AliMUONResponse.h"
67#include "AliMUONChamber.h"
f665c1ea 68#include "AliMUONConstants.h"
5d12ce38 69#include "AliMC.h"
a9e2aefa 70// to manage the same zoom on both cathodes
71
72
73
74ClassImp(AliMUONDisplay)
75
76
77//_____________________________________________________________________________
78AliMUONDisplay::AliMUONDisplay()
79{
80// Constructor
81 fPoints = 0;
82 fPhits = 0;
83 fRpoints = 0;
a9e2aefa 84 fCanvas = 0;
85 fNextCathode = kFALSE;
3f5cf0b3 86 fColPad = 0;
a9e2aefa 87}
88
89//_____________________________________________________________________________
90AliMUONDisplay::AliMUONDisplay(Int_t size)
91{
92// Create an event display object.
93// A canvas named "edisplay" is created with a vertical size in pixels
94//
95// A QUICK Overview of the Event Display functions
96// ===============================================
97//
98// The event display can ve invoked by executing the macro "display.C"
99// A canvas like in the picture below will appear.
100//
101// On the left side of the canvas, the following buttons appear:
102// *Next* to move to the next event
103// *Previous* to move to the previous event
104
105// *Pick* Select this option to be able to point on a track with the
106// mouse. Once on the track, use the right button to select
107// an action. For example, select SetMarkerAttributes to
108// change the marker type/color/size for the track.
109// *Zoom* Select this option (default) if you want to zoom.
110// To zoom, simply select the selected area with the left button.
111// *UnZoom* To revert to the previous picture size.
112//
113// slider R On the left side, the vertical slider can be used to
114// set the default picture size.
115//
116// When you are in Zoom mode, you can click on the black part of the canvas
117// to select special options with the right mouse button.
118
119//
120// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
121// When you are on a track, select the menu item "InspectParticle"
122// to display the current particle attributes.
123//
124// You can activate the Root browser by selecting the Inspect menu
125// in the canvas tool bar menu. Then select "Start Browser"
126// This will open a new canvas with the browser. At this point, you may want
127// to display some histograms (from the Trees). Go to the "File" menu
128// of the browser and click on "New canvas".
129// In the browser, click on item "ROOT files" in the left pane.
130// Click on galice.root.
131// Click on TH
132// Click on TPC for example
133// Click on any variable (eg TPC.fX) to histogram the variable.
134//
135// If you are lost, you can click on HELP in any Root canvas or browser.
136//Begin_Html
137/*
138<img src="gif/AliMUONDisplay.gif">
139*/
140//End_Html
141
142
143 fPad = 0;
144
145 gAlice->SetDisplay(this);
146
147 // Initialize display default parameters
148 SetRange(200,2000);
149 // Set front view by default
150 fTheta = 0;
151 fPhi = -90;
152 fPsi = 0;
153 fChamber = 1;
154 fCathode = 1;
155 // fRzone = 1.e10;
156 fDrawClusters = kTRUE;
157 fDrawCoG = kTRUE;
a9e2aefa 158 fZoomMode = 1;
159 fZooms = 0;
160 fClustersCuts = 0;
161 fPoints = 0;
162 fPhits = 0;
163 fRpoints = 0;
a9e2aefa 164 // Create colors
165 CreateColors();
166 // Create display canvas
167 Int_t ysize = size;
168 if (ysize < 100) ysize = 750;
169 Int_t xsize = Int_t(size*830./ysize);
170 fCanvas = new TCanvas("Canvas", "MUON Clusters Display",14,47,xsize,ysize);
171 fCanvas->ToggleEventStatus();
172
173 // Create main display pad
174 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
175 fPad->Draw();
176 fPad->Modified();
177 fPad->SetFillColor(30);
178 fPad->SetBorderSize(2);
179
180 fCanvas->cd();
181
182 // Create colors pad
183 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
184 fColPad->Draw();
185 fColPad->SetFillColor(17);
186 fColPad->SetBorderSize(2);
187 fColPad->cd();
188 DisplayColorScale();
189
190 fCanvas->cd();
191 // Create user interface control pad
192 DisplayButtons();
193 fCanvas->cd();
194
195 // Create Range and mode pad
196 Float_t dxtr = 0.15;
197 Float_t dytr = 0.45;
198 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
a9e2aefa 199 fTrigPad->Draw();
200 fTrigPad->cd();
201 fTrigPad->SetFillColor(22);
202 fTrigPad->SetBorderSize(2);
203 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
204 fRangeSlider->SetObject(this);
205 char pickmode[] = "gAlice->Display()->SetPickMode()";
206 Float_t db = 0.09;
207 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
208 fPickButton->SetFillColor(38);
209 fPickButton->Draw();
210 char zoommode[] = "gAlice->Display()->SetZoomMode()";
211 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
212 fZoomButton->SetFillColor(38);
213 fZoomButton->Draw();
214 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
215 fArcButton->SetFillColor(kGreen);
216 fArcButton->Draw();
217 char butUnzoom[] = "gAlice->Display()->UnZoom()";
218 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
219 button->SetFillColor(38);
220 button->Draw();
221 AppendPad(); // append display object as last object to force selection
222
223 fCanvas->cd();
1c4b7942 224 fTrigPad->SetEditable(kFALSE);
225 fButtons->SetEditable(kFALSE);
a9e2aefa 226 fCanvas->Update();
227 fNextCathode = kFALSE;
228}
229
e0875ac1 230AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display):AliDisplay(display)
a9e2aefa 231{
232// Dummy copy constructor
233 ;
234}
235
236
237
238//_____________________________________________________________________________
239AliMUONDisplay::~AliMUONDisplay()
240{
241 // Delete space point structure
242 if (fPoints) fPoints->Delete();
243 delete fPoints;
244 fPoints = 0;
245 //
246 if (fPhits) fPhits->Delete();
247 delete fPhits;
248 fPhits = 0;
249 //
250 if (fRpoints) fRpoints->Delete();
251 delete fRpoints;
252 fRpoints = 0;
a9e2aefa 253}
254
255//_____________________________________________________________________________
256void AliMUONDisplay::Clear(Option_t *)
257{
258// Delete graphics temporary objects
259}
260
261//_____________________________________________________________________________
262void AliMUONDisplay::DisplayButtons()
263{
264// Create the user interface buttons
265
266
267 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
a9e2aefa 268 fButtons->Draw();
269 fButtons->SetFillColor(38);
270 fButtons->SetBorderSize(2);
271 fButtons->cd();
272
273// Int_t butcolor = 33;
274 Float_t dbutton = 0.08;
275 Float_t y = 0.96;
276 Float_t dy = 0.014;
277 Float_t x0 = 0.05;
278 Float_t x1 = 0.95;
279
280 TButton *button;
281 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
282 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
283 button->SetFillColor(38);
284 button->Draw();
285
286 y -= dbutton + dy;
287 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
288 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
289 button->SetFillColor(38);
290 button->Draw();
291
292 y -= dbutton + dy;
293 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
294 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
295 button->SetFillColor(38);
296 button->Draw();
297
298 y -= dbutton + dy;
299 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
300 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
301 button->SetFillColor(38);
302 button->Draw();
303
304 y -= dbutton + dy;
305 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
306 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
307 button->SetFillColor(38);
308 button->Draw();
309
310 y -= dbutton + dy;
311 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
312 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
313 button->SetFillColor(38);
314 button->Draw();
315
316 y -= dbutton + dy;
317 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
318 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
319 button->SetFillColor(38);
320 button->Draw();
321
322 // display logo
323 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
324 diamond->SetFillColor(50);
325 diamond->SetTextAlign(22);
326 diamond->SetTextColor(5);
327 diamond->SetTextSize(0.11);
328 diamond->Draw();
329 diamond->AddText(".. ");
330 diamond->AddText("ROOT");
331 diamond->AddText("MUON");
332 diamond->AddText("... ");
333 diamond->AddText(" ");
334}
335
336//_____________________________________________________________________________
337void AliMUONDisplay::CreateColors()
338{
339// Create the colors palette used to display clusters
340
341 Int_t k,i;
342 Int_t color;
343 Float_t r,g,b;
344
345 for (k=1;k<=5;k++) {
346 switch(k) {
347 case 1:
348 for (i=1;i<=5;i++) {
349 r=1.;
350 g=i*0.2;
351 b=0.;
352 color=i;
353 color=260+23-color;
354 new TColor(color,r,g,b);
355 }
356 break;
357 case 2:
358 for (i=1;i<=4;i++) {
359 r=1.1-i*0.2;
360 g=1.;
361 b=0.;
362 color=i+5;
363 color=260+23-color;
364 new TColor(color,r,g,b);
365 }
366 break;
367 case 3:
368 for (i=1;i<=4;i++) {
369 r=0.;
370 g=1.;
371 b=i*0.2+0.2;
372 color=i+9;
373 color=260+23-color;
374 new TColor(color,r,g,b);
375 }
376 break;
377 case 4:
378 for (i=1;i<=4;i++) {
379 r=0.;
380 g=1.1-i*0.2;
381 b=1.;
382 color=i+13;
383 color=260+23-color;
384 new TColor(color,r,g,b);
385 }
386 break;
387 case 5:
388 for (i=1;i<=5;i++) {
389 r=i*0.2;
390 g=0.;
391 b=1.;
392 color=i+17;
393 color=260+23-color;
394 new TColor(color,r,g,b);
395 }
396 break;
397 }
398 }
399}
400
401//_____________________________________________________________________________
402void AliMUONDisplay::DisplayColorScale()
403{
404// Display pulse height color scale
405 Int_t i;
406 Int_t color;
407 Float_t xlow, ylow, xup, yup, hs;
408 Float_t x1, y1, x2, y2;
409 x1 = y1 = 0;
410 x2 = y2 = 1.0;
411
412 TText *text = new TText(0,0,"");
413 text->SetTextFont(61);
414 text->SetTextSize(0.2);
415 text->SetTextAlign(22);
416
417 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
418 AliMUONChamber *iChamber = &(pMUON->Chamber(fChamber-1));
419 AliMUONResponse * response=iChamber->ResponseModel();
420 Int_t adcmax=1024;
08a636a8 421 if (response) adcmax = (Int_t) response->MaxAdc();
a9e2aefa 422
423
424 TBox *box;
425 char label[8];
426//*-* draw colortable boxes
427 hs = (y2-y1)/Float_t(22);
428 xlow=x1+.05;
429 xup=x2-0.5;
430 for (i=0;i<22;i++) {
431 ylow = y1 + hs*(Float_t(i));
432 yup = y1 + hs*(Float_t(i+1));
433 color = 261+i;
434 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
435 Int_t scale=(Int_t)TMath::Exp(logscale);
436 sprintf(label,"%d",scale);
437 box = new TBox(xlow, ylow, xup, yup);
438 box->Draw();
439 box->SetFillColor(color);
440 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
441 }
442}
443
444//______________________________________________________________________________
445Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
446{
447// Compute distance from point px,py to objects in event
448
449 gPad->SetCursor(kCross);
450
451 if (gPad == fTrigPad) return 9999;
452
453 const Int_t kBig = 9999;
454 Int_t dist = kBig;
455 Float_t xmin = gPad->GetX1();
456 Float_t xmax = gPad->GetX2();
457 Float_t dx = 0.02*(xmax - xmin);
458 Float_t x = gPad->AbsPixeltoX(px);
459 if (x < xmin+dx || x > xmax-dx) return dist;
460
461 if (fZoomMode) return 0;
462 else return 7;
463}
464
465//_____________________________________________________________________________
466void AliMUONDisplay::Draw(Option_t *)
467{
468// Display current event
469
470 fPad->cd();
471
472 DrawView(fTheta, fPhi, fPsi);
473 // Display the event number and title
474 fPad->cd();
475 DrawTitle();
476}
477
478void AliMUONDisplay::DrawSegmentation()
479{
480// Draw graphical representation of segmenatation
481// Attention: still experimental code
482 Int_t icat=1;
483
484 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
a30a000f 485 AliMUONChamber* iChamber;
486 AliSegmentation* seg;
a9e2aefa 487 iChamber = &(pMUON->Chamber(fChamber));
488 seg=iChamber->SegmentationModel(icat);
489 Float_t zpos=iChamber->Z();
490 Float_t r=iChamber->ROuter();
491
492 TMarker3DBox *marker;
493 if (icat == 1) {
494 for (Int_t j=0; j<seg->Npy(); j++) {
495 Float_t y0;
496 y0=j*seg->Dpy()-seg->Dpy()/2.;
802a864d 497 for (seg->FirstPad(0.,y0,0,300,0.);
a9e2aefa 498 seg->MorePads();
499 seg->NextPad())
500 {
501 if (seg->ISector()==0) continue;
802a864d 502 Float_t x,y,z;
a30a000f 503 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
a9e2aefa 504 Float_t dpx=seg->Dpx(seg->ISector())/2;
505 Float_t dpy=seg->Dpy(seg->ISector())/2;
506 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
507 marker->SetLineColor(seg->ISector()+1);
508 marker->SetFillStyle(1001);
509 marker->SetFillColor(0);
510 marker->Draw();
511 }
512 }
513 } else {
514 for (Int_t j=0; j<250; j++) {
515 Float_t x0=j*seg->Dpx();
516 Float_t y0=TMath::Sqrt(r*r-x0*x0);
517
802a864d 518 for (seg->FirstPad(x0,0,0,0,y0);
a9e2aefa 519 seg->MorePads();
520 seg->NextPad())
521 {
522 if (seg->ISector()==0) continue;
523
802a864d 524 Float_t x,y,z;
a30a000f 525 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
a9e2aefa 526 Float_t dpx=seg->Dpx(seg->ISector())/2;
527 Float_t dpy=seg->Dpy(seg->ISector())/2;
528 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
529 marker->SetLineColor(seg->ISector()+1);
530 marker->SetFillStyle(1001);
531 marker->SetFillColor(0);
532 marker->Draw();
533 }
534 }
535 }
536}
537
538//_____________________________________________________________________________
539void AliMUONDisplay::DrawClusters()
540{
541// Draw clusters for MUON chambers
542
543 Int_t ndigits, digit;
544 TObjArray *points;
545 AliMUONPoints *pm;
546
547
548 fClustersCuts = 0;
549 points = Points();
550 if (!points) return;
551 ndigits = points->GetEntriesFast();
552 for (digit=0;digit<ndigits;digit++){
553 pm = (AliMUONPoints*)points->UncheckedAt(digit);
554 if (!pm) continue;
555 Float_t *pxyz;
556 pxyz=pm->GetP();
557 for (Int_t im=0;im<3;im++) {
558 TMarker3DBox *marker=pm->GetMarker(im);
559 if (marker)
560 marker->Draw();
561 }
562 pm->Draw();
563 fClustersCuts +=pm->GetN();
564 }
565}
566
567//_____________________________________________________________________________
568void AliMUONDisplay::DrawHits()
569{
570// Draw hits for MUON chambers
571
572 LoadHits(fChamber);
573
574 Int_t ntracks, track;
575 TObjArray *points;
576 AliMUONPoints *pm;
577
578 fHitsCuts = 0;
579 points = Phits();
580 if (!points) return;
581 ntracks = points->GetEntriesFast();
582 for (track=0;track<ntracks;track++) {
583 pm = (AliMUONPoints*)points->UncheckedAt(track);
584 if (!pm) continue;
585 pm->Draw();
586 fHitsCuts += pm->GetN();
587 }
588}
589
590
591//_____________________________________________________________________________
592void AliMUONDisplay::DrawCoG()
593{
594// Draw hits for MUON chambers
595 if (!fDrawCoG) return;
596 if (fChamber > 10) return;
597 LoadCoG(fChamber,fCathode);
598
599 Int_t ncog, icog;
600 TObjArray *points;
601 AliMUONPoints *pm;
602
603 points = Rpoints();
604 if (!points) return;
605 ncog = points->GetEntriesFast();
606 for (icog=0;icog<ncog;icog++) {
607 pm = (AliMUONPoints*)points->UncheckedAt(icog);
608 if (!pm) continue;
609 pm->Draw();
610 }
611}
a9e2aefa 612//_____________________________________________________________________________
613
614void AliMUONDisplay::DrawTitle(Option_t *option)
615{
616// Draw the event title
617
618 Float_t xmin = gPad->GetX1();
619 Float_t xmax = gPad->GetX2();
620 Float_t ymin = gPad->GetY1();
621 Float_t ymax = gPad->GetY2();
622 Float_t dx = xmax-xmin;
623 Float_t dy = ymax-ymin;
624
7985603c 625
1391e633 626 AliRunLoader * RunLoader = AliRunLoader::GetRunLoader("MUONFolder");
7985603c 627
a9e2aefa 628 if (strlen(option) == 0) {
629 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
630// title->SetTextSize(0.023932);
631 title->SetTextSize(0.02);
632 title->SetBit(kCanDelete);
633 title->SetFillColor(42);
634 title->Draw();
635 char ptitle[100];
636 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
1391e633 637 RunLoader->GetEventNumber(),
a9e2aefa 638 gAlice->GetHeader()->GetRun(),
639 fChamber,
640 fCathode);
641 title->AddText(ptitle);
5d12ce38 642 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
a9e2aefa 643 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
644 nparticles, fHitsCuts,fClustersCuts);
645 title->AddText(ptitle);
646 } else {
647 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
648 label->SetBit(kCanDelete);
649 label->SetFillColor(42);
650 label->Draw();
651 }
652}
653
654//_____________________________________________________________________________
655void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
656{
657// Draw a view of MUON clusters
658 printf("\n Draw View");
659
660 gPad->SetCursor(kWatch);
661 // gPad->SetFillColor(39);
662 gPad->SetFillColor(1);
663 gPad->Clear();
664 // gPad->SetFillColor(39);
665 gPad->SetFillColor(1);
666
667
668 Int_t iret=0;
669 TView *view = new TView(1);
670
671 Float_t range = fRrange*fRangeSlider->GetMaximum();
672 view->SetRange(-range,-range,-range,range, range, range);
673 // zoom back to full scale only if DrawView not called from NextCathode
674 if (!fNextCathode) {
675 fZoomX0[0] = -1;
676 fZoomY0[0] = -1;
677 fZoomX1[0] = 1;
678 fZoomY1[0] = 1;
679 fZooms = 0;
680 }
681
682// Display MUON Chamber Geometry
a9e2aefa 683 char nodeName[7];
684 sprintf(nodeName,"MUON%d",100+fChamber);
a9e2aefa 685
686 TNode *node1=gAlice->GetGeometry()->GetNode(nodeName);
687 if (node1) node1->Draw("same");
688//add clusters to the pad
689 DrawClusters();
a9e2aefa 690 DrawHits();
691 DrawCoG();
a9e2aefa 692// DrawSegmentation();
693 // add itself to the list (must be last)
694 AppendPad();
695 view->SetView(phi, theta, psi, iret);
696}
697
698
699//______________________________________________________________________________
700void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
701{
702// Execute action corresponding to the mouse event
703
704 static Float_t x0, y0, x1, y1;
705
706 static Int_t pxold, pyold;
707 static Int_t px0, py0;
708 static Int_t linedrawn;
709 Float_t temp;
710
711 if (px == 0 && py == 0) { //when called by sliders
712 if (event == kButton1Up) {
713 Draw();
714 }
715 return;
716 }
717 if (!fZoomMode && gPad->GetView()) {
718 gPad->GetView()->ExecuteRotateView(event, px, py);
719 return;
720 }
721
722 // something to zoom ?
723 gPad->SetCursor(kCross);
724
725 switch (event) {
726
727 case kButton1Down:
728 gVirtualX->SetLineColor(-1);
729 gPad->TAttLine::Modify(); //Change line attributes only if necessary
730 x0 = gPad->AbsPixeltoX(px);
731 y0 = gPad->AbsPixeltoY(py);
732 px0 = px; py0 = py;
733 pxold = px; pyold = py;
734 linedrawn = 0;
735 return;
736
737 case kButton1Motion:
738 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
739 pxold = px;
740 pyold = py;
741 linedrawn = 1;
742 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
743 return;
744
745 case kButton1Up:
746 gPad->GetCanvas()->FeedbackMode(kFALSE);
747 if (px == px0) return;
748 if (py == py0) return;
749 x1 = gPad->AbsPixeltoX(px);
750 y1 = gPad->AbsPixeltoY(py);
751
752 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
753 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
754 gPad->Range(x0,y0,x1,y1);
97ccf8cb 755 if (fZooms < AliMUONConstants::MaxZoom()-1) {
a9e2aefa 756 fZooms++;
757 fZoomX0[fZooms] = x0;
758 fZoomY0[fZooms] = y0;
759 fZoomX1[fZooms] = x1;
760 fZoomY1[fZooms] = y1;
761 }
762 gPad->Modified(kTRUE);
763 return;
764 }
765}
766
767//___________________________________________
768void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
769{
770// Read digits info and store x,y,z info in arrays fPoints
771// Loop on all detectors
772
773 if (chamber > 14) return;
774 printf(" chamber %d \n",chamber);
08a636a8 775 fChamber = chamber;
776 fCathode = cathode;
a9e2aefa 777
778 ResetPoints();
779
08a636a8 780 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
a9e2aefa 781 AliMUONChamber* iChamber;
a30a000f 782 AliSegmentation* segmentation;
a9e2aefa 783 AliMUONResponse* response;
784
1a1cdff8 785 TClonesArray *muonDigits = pMUON->GetMUONData()->Digits(chamber-1);
a9e2aefa 786 if (muonDigits == 0) return;
787
c036fc44 788// gAlice->ResetDigits();
00f56532 789 Int_t nent = 0;
790
1a1cdff8 791 if (pMUON->GetLoader()->TreeD()) {
792 nent = (Int_t) pMUON->GetLoader()->TreeD()->GetEntries();
49b640e7 793 printf(" entries %d \n", nent);
794 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1a1cdff8 795 pMUON->GetMUONData()->GetCathode(cathode-1);
00f56532 796 }
797
a9e2aefa 798 Int_t ndigits = muonDigits->GetEntriesFast();
799 if (ndigits == 0) return;
800 if (fPoints == 0) fPoints = new TObjArray(ndigits);
801
802 iChamber = &(pMUON->Chamber(chamber-1));
803
804 segmentation = iChamber->SegmentationModel(cathode);
805 response = iChamber->ResponseModel();
08a636a8 806 Float_t zpos = iChamber->Z();
807
a9e2aefa 808 AliMUONDigit *mdig;
08a636a8 809 AliMUONPoints *points = 0;
810 TMarker3DBox *marker = 0;
a9e2aefa 811 //
812 //loop over all digits and store their position
813
08a636a8 814 Int_t npoints = 1;
815 Float_t adcmax = 1024;
4554f81d 816 if (response&&chamber<11) adcmax = response->MaxAdc();
a9e2aefa 817
08a636a8 818 for (Int_t digit = 0; digit < ndigits; digit++) {
a9e2aefa 819 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
08a636a8 820 if (mdig->Cathode() != cathode-1) continue;
4554f81d 821
a9e2aefa 822 //
823 // First get all needed parameters
824 //
08a636a8 825 Int_t charge = mdig->Signal();
826 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
827 Int_t color = 261+index;
828 Int_t colorTrigger = 2;
829 if (color > 282) color = 282;
a9e2aefa 830
831 if (chamber > 10) { // trigger chamber
4554f81d 832
08a636a8 833 Int_t sumCharge = 0;
834 for (Int_t icharge = 0; icharge < 10; icharge++) {
835 sumCharge = sumCharge+mdig->TrackCharge(icharge);
a9e2aefa 836 }
08a636a8 837 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
838 if(sumCharge <= 10 || testCharge > 0) {
839 colorTrigger = color;
a9e2aefa 840 } else {
08a636a8 841 colorTrigger = 5;
a9e2aefa 842 }
843 }
844
845 // get the center of the pad - add on x and y half of pad size
802a864d 846 Float_t xpad, ypad, zpad;
08a636a8 847 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
848
849 Int_t isec = segmentation->Sector(mdig->PadX(), mdig->PadY());
850 Float_t dpx = segmentation->Dpx(isec)/2;
851 Float_t dpy = segmentation->Dpy(isec)/2;
852//
853// segmentation->Dump();
a9e2aefa 854
a9e2aefa 855 //
856 // Then set the objects
857 //
858 points = new AliMUONPoints(npoints);
859 fPoints->AddAt(points,digit);
860 if (chamber > 10) {
861 points->SetMarkerColor(colorTrigger);
862 } else {
863 points->SetMarkerColor(color);
864 }
865 points->SetMarkerStyle(21);
866 points->SetMarkerSize(0.5);
867 points->SetParticle(-1);
868 points->SetHitIndex(-1);
869 points->SetTrackIndex(-1);
870 points->SetDigitIndex(digit);
4554f81d 871 points->SetPoint(0,xpad,ypad,zpos);
872
08a636a8 873 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
874 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
875
876
877 marker->SetLineColor(lineColor);
878 marker->SetFillStyle(1001);
879 marker->SetFillColor(color);
880 marker->SetRefObject((TObject*)points);
881 points->Set3DMarker(0, marker);
a9e2aefa 882 }
883}
884//___________________________________________
e0875ac1 885void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
a9e2aefa 886{
887// Read raw clusters info and store x,y,z info in arrays fRpoints
888// Loop on all detectors
889
890 if (chamber > 10) return;
891
892 ResetRpoints();
893
894 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
895 AliMUONChamber* iChamber;
896
ce3f5e87 897 TClonesArray *muonRawClusters = pMUON->GetMUONData()->RawClusters(chamber-1);
a9e2aefa 898
7985603c 899 if (muonRawClusters == 0) return;
a9e2aefa 900
00f56532 901 Int_t nent = 0;
7985603c 902 if (pMUON->GetMUONData()->TreeR()) {
903 nent=(Int_t) pMUON->GetMUONData()->TreeR()->GetEntries();
904 pMUON->GetMUONData()->TreeR()->GetEvent(0);
00f56532 905 }
906
a9e2aefa 907 Int_t nrawcl = muonRawClusters->GetEntriesFast();
908 if (nrawcl == 0) return;
909 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
910
911 iChamber = &(pMUON->Chamber(chamber-1));
912 Float_t zpos=iChamber->Z();
913 AliMUONRawCluster *mRaw;
914 AliMUONPoints *points = 0;
915 //
916 //loop over all raw clusters and store their position
917 points = new AliMUONPoints(nrawcl);
918 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
919 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
920 fRpoints->AddAt(points,iraw);
921 points->SetMarkerColor(51);
922 points->SetMarkerStyle(2);
923 points->SetMarkerSize(1.);
924 points->SetParticle(-1);
925 points->SetHitIndex(-1);
926 points->SetTrackIndex(-1);
927 points->SetDigitIndex(-1);
928 points->SetPoint(iraw,mRaw->fX[0],mRaw->fY[0],zpos);
929 }
930}
931//___________________________________________
a9e2aefa 932void AliMUONDisplay::LoadHits(Int_t chamber)
933{
934// Read hits info and store x,y,z info in arrays fPhits
935// Loop on all detectors
936
937 if (chamber > 14) return;
938 Int_t track;
939
940 fChamber=chamber;
941
942 ResetPhits();
943
944 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
945 AliMUONChamber* iChamber;
946
947 iChamber = &(pMUON->Chamber(chamber-1));
948 Float_t zpos=iChamber->Z();
949
7985603c 950 Int_t ntracks = (Int_t)pMUON->GetMUONData()->TreeH()->GetEntries(); //skowron
08a636a8 951 Int_t nthits = 0;
952 for (track = 0; track < ntracks; track++) {
7985603c 953 pMUON->GetMUONData()->ResetHits();
954 pMUON->GetMUONData()->GetTrack(track);//skowron
955 TClonesArray *muonHits = pMUON->GetMUONData()->Hits();
a9e2aefa 956 if (muonHits == 0) return;
957 nthits += muonHits->GetEntriesFast();
958 }
959 if (fPhits == 0) fPhits = new TObjArray(nthits);
960 Int_t nhold=0;
961 for (track=0; track<ntracks;track++) {
7985603c 962 pMUON->GetMUONData()->ResetHits();
963 pMUON->GetMUONData()->GetTrack(track);//skowron
964 TClonesArray *muonHits = pMUON->GetMUONData()->Hits();
a9e2aefa 965 if (muonHits == 0) return;
966 Int_t nhits = muonHits->GetEntriesFast();
967 if (nhits == 0) continue;
968 AliMUONHit *mHit;
969 AliMUONPoints *points = 0;
970 Int_t npoints=1;
971 for (Int_t hit=0;hit<nhits;hit++) {
972 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
08a636a8 973 Int_t nch = mHit->Chamber(); // chamber number
a9e2aefa 974 if (nch != chamber) continue;
975 //
976 // Retrieve info and set the objects
977 //
978 points = new AliMUONPoints(npoints);
979 fPhits->AddAt(points,nhold+hit);
980 points->SetMarkerColor(kRed);
981 points->SetMarkerStyle(5);
37c0cd40 982 points->SetMarkerSize(1.);
94de3818 983 points->SetParticle(mHit->Track());
a9e2aefa 984 points->SetHitIndex(hit);
985 points->SetTrackIndex(track);
986 points->SetDigitIndex(-1);
94de3818 987 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
a9e2aefa 988 }
989 nhold+=nhits;
990 }
991}
992
993//_____________________________________________________________________________
994void AliMUONDisplay::Paint(Option_t *)
995{
996// Paint miscellaneous items
997}
998
999//_____________________________________________________________________________
1000void AliMUONDisplay::SetPickMode()
1001{
1002// Set parameters for pick mode.
1003//
1004 fZoomMode = 0;
1005
1006 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1007 fTrigPad->Modified();
1008}
1009
1010//_____________________________________________________________________________
1011void AliMUONDisplay::SetZoomMode()
1012{
1013// Set parameters for zoom mode
1014 fZoomMode = 1;
1015
1016 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1017 fTrigPad->Modified();
1018}
1019
1020//_____________________________________________________________________________
1021void AliMUONDisplay::NextChamber(Int_t delta)
1022{
1023 // to go from chamber to next chamber if delta = 1
1024 // or previous chamber otherwise
1025 if (delta == 1) {
f665c1ea 1026 if (fChamber < AliMUONConstants::NCh()) fChamber++;
a9e2aefa 1027 } else {
1028 if (fChamber > 1) fChamber--;
1029 }
1030 if (!fPad) return;
1031 fPad->Clear();
1032 LoadDigits(fChamber, fCathode);
1033 Draw();
1034}
1035
1036//_____________________________________________________________________________
1037void AliMUONDisplay::NextCathode()
1038{
1039 // to switch to other cathode plane
1040 if (!fPad) return;
1041 fPad->Clear();
1042 if (fCathode == 1) {
1043 LoadDigits(fChamber, 2);
1044 } else {
1045 LoadDigits(fChamber, 1);
1046 }
1047 fNextCathode = kTRUE; // to keep the same zoom
1048 Draw();
1049 fNextCathode = kFALSE;
1050 TPad *pad = (TPad*)gPad->GetPadSave();
1051 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1052 fZoomX1[fZooms], fZoomY1[fZooms]);
1053 pad->Modified();
1054 fPad->cd();
1055 DrawTitle();
1056}
1057
1058//_____________________________________________________________________________
1059void AliMUONDisplay::Trigger()
1060{
1061 // returns Trigger Decision for current event
1062 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1063 decision->Trigger();
1064}
1065
1066
1067//_____________________________________________________________________________
1068void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1069{
1070// Set chamber and cathode number
1071 fChamber = chamber;
1072 fCathode = cathode;
1073
1074 if (!fPad) return;
1075 fPad->Clear();
1076 LoadDigits(chamber,cathode);
1077 Draw();
1078}
1079
1080void AliMUONDisplay::SetEvent(Int_t newevent)
1081{
1082// Chose event
1083 gAlice->GetEvent(newevent);
1084 fEvent=newevent;
1085 if (!gAlice->TreeD()) return;
1086 if (!fPad) return;
1087 fPad->Clear();
1088 LoadDigits(fChamber,fCathode);
1089 Draw();
1090}
1091
1092//_____________________________________________________________________________
1093void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1094{
1095// Set view range along R and Z
1096 fRrange = rrange;
1097 fZrange = zrange;
1098
1099 if (!fPad) return;
1100 fPad->Clear();
1101 Draw();
1102}
1103
1104//_____________________________________________________________________________
1105void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1106{
1107// change viewing angles for current event
1108
1109 fPad->cd();
1110 fPhi = phi;
1111 fTheta = theta;
1112 fPsi = psi;
1113 Int_t iret = 0;
1114
1115 TView *view = gPad->GetView();
1116 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1117 else Draw();
1118 gPad->Modified();
1119}
1120
1121//_____________________________________________________________________________
1122void AliMUONDisplay::ShowNextEvent(Int_t delta)
1123{
1391e633 1124
1125 AliRunLoader * RunLoader = AliRunLoader::GetRunLoader("MUONFolder");
1126
a9e2aefa 1127// Display (current event_number + delta)
1128// delta = 1 shown next event
1129// delta = -1 show previous event
1130 if (delta) {
1391e633 1131 //RunLoader->CleanDetectors();
1132 //RunLoader->CleanKinematics();
1133 Int_t currentEvent = RunLoader->GetEventNumber();
1134 Int_t newEvent = currentEvent + delta;
1135 RunLoader->GetEvent(newEvent);
1136 fEvent=newEvent;
a9e2aefa 1137 }
a9e2aefa 1138 LoadDigits(fChamber, fCathode);
1139 fPad->cd();
1140 Draw();
1141}
1142
1143//______________________________________________________________________________
1144void AliMUONDisplay::UnZoom()
1145{
1146// Unzoom
1147 if (fZooms <= 0) return;
1148 fZooms--;
1149 TPad *pad = (TPad*)gPad->GetPadSave();
1150 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1151 pad->Modified();
1152}
1153
1154//_____________________________________________________________________________
1155void AliMUONDisplay::ResetPoints()
1156{
1157 //
1158 // Reset array of points
1159 //
1160 if (fPoints) {
1161 fPoints->Delete();
1162 delete fPoints;
1163 fPoints = 0;
1164 }
1165}
1166//_____________________________________________________________________________
1167void AliMUONDisplay::ResetPhits()
1168{
1169 //
1170 // Reset array of points
1171 //
1172 if (fPhits) {
1173 fPhits->Delete();
1174 delete fPhits;
1175 fPhits = 0;
1176 }
1177}
1178//_____________________________________________________________________________
1179void AliMUONDisplay::ResetRpoints()
1180{
1181 //
1182 // Reset array of points
1183 //
1184 if (fRpoints) {
1185 fRpoints->Delete();
1186 delete fRpoints;
1187 fRpoints = 0;
1188 }
1189}
a9e2aefa 1190
1191AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay &)
1192{
1193// Dummy assignment operator
1194 return *this;
1195}
1196
1197
1198
1199
1200
1201
1202
1203
1204