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