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