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