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