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