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