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