]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSdisplay.cxx
update info about cvs installation using cvs account
[u/mrichter/AliRoot.git] / ITS / AliITSdisplay.cxx
CommitLineData
e8189707 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
18Revision 1.10 1999/11/10 07:37:04 fca
19Pads do not inherit editability from canvas any more
20
21Revision 1.9 1999/11/09 07:38:51 fca
22Changes for compatibility with version 2.23 of ROOT
23
24Revision 1.8 1999/09/29 09:24:23 fca
25Introduction of the Copyright and cvs Log
26
27*/
28
29
30//////////////////////////////////////////////////////////////////////////
31// //
32// AliDisplay //
33// //
34// Utility class to display ALICE outline, tracks, hits,.. //
35// //
36//////////////////////////////////////////////////////////////////////////
37
38#include <TROOT.h>
39#include <TTree.h>
40#include <TButton.h>
41#include <TColor.h>
42#include <TStyle.h>
43#include <TCanvas.h>
44#include <TView.h>
45#include <TText.h>
46#include <TPolyMarker3D.h>
47#include <TPaveLabel.h>
48#include <TPaveText.h>
49#include <TList.h>
50#include <TDiamond.h>
51#include <TNode.h>
52#include <TArc.h>
53#include <TTUBE.h>
54#include <TSlider.h>
55#include <TSliderBox.h>
56#include <TGaxis.h>
57#include <TVirtualX.h>
58#include <TMath.h>
59#include <TMatrix.h>
60#include <TH2.h>
61#include <TObjArray.h>
62#include <X3DBuffer.h>
63
64#include "AliRun.h"
65#include "AliDetector.h"
66#include "AliITS.h"
67#include "AliITSdigitNew.h"
68#include "AliITSMap.h"
69#include "AliITSresponseV0.h"
70#include "AliITSdisplay.h"
71#include "AliITSpoints.h"
72#include "TParticle.h"
73
74
75const Int_t kMAXHIST = 20;
76
77static Int_t sModule=0;
78
79
80ClassImp(AliITSdisplay)
81
82
83//_____________________________________________________________________________
84AliITSdisplay::AliITSdisplay()
85{
86 fPoints = 0;
87 fPhits = 0;
88 fRpoints = 0;
89 fR2points = 0;
90 fCpoints = 0;
91 fCanvas = 0;
92
93 fMap = 0;
94
95}
96
97//_____________________________________________________________________________
98AliITSdisplay::AliITSdisplay(Int_t size)
99{
100// Create an event display object.
101// A canvas named "edisplay" is created with a vertical size in pixels
102//
103// A QUICK Overview of the Event Display functions
104// ===============================================
105//
106// The event display can ve invoked by executing the macro "display.C"
107// A canvas like in the picture below will appear.
108//
109// On the left side of the canvas, the following buttons appear:
110// *Next* to move to the next event
111// *Previous* to move to the previous event
112
113// *Pick* Select this option to be able to point on a track with the
114// mouse. Once on the track, use the right button to select
115// an action. For example, select SetMarkerAttributes to
116// change the marker type/color/size for the track.
117// *Zoom* Select this option (default) if you want to zoom.
118// To zoom, simply select the selected area with the left button.
119// *UnZoom* To revert to the previous picture size.
120//
121// slider R On the left side, the vertical slider can be used to
122// set the default picture size.
123//
124// When you are in Zoom mode, you can click on the black part of the canvas
125// to select special options with the right mouse button.
126
127//
128// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
129// When you are on a track, select the menu item "InspectParticle"
130// to display the current particle attributes.
131//
132// You can activate the Root browser by selecting the Inspect menu
133// in the canvas tool bar menu. Then select "Start Browser"
134// This will open a new canvas with the browser. At this point, you may want
135// to display some histograms (from the Trees). Go to the "File" menu
136// of the browser and click on "New canvas".
137// In the browser, click on item "ROOT files" in the left pane.
138// Click on galice.root.
139// Click on TH
140// Click on TPC for example
141// Click on any variable (eg TPC.fX) to histogram the variable.
142//
143// If you are lost, you can click on HELP in any Root canvas or browser.
144//Begin_Html
145/*
146<img src="gif/aliITSdisplay.gif">
147*/
148//End_Html
149
150
151 fPad = 0;
152
153 gAlice->SetDisplay(this);
154
155 // Set module view by default
156 fTheta = -90;
157 fPhi = 90;
158 fPsi = 180;
159
160 fYmodule = 0;
161
162 fModule = 393;
163 fNmodules = 0;
164
165 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
166 AliITSgeom *gm=ITS->GetITSgeom();
167 gm->GetModuleId(fModule,fLayer,fLadder,fDetector);
168
169 // fRzone = 1.e10;
170 fDrawClusters = kTRUE;
171 fDrawCoG = kTRUE;
172 fDrawCathCor = kFALSE;
173 fDrawHist = kFALSE;
174
175 fMap = 0;
176
177
178 fZoomMode = 1;
179 fZooms = 0;
180 fClustersCuts = 0;
181 fPoints = 0;
182 fPhits = 0;
183 fRpoints = 0;
184 fR2points = 0;
185 fCpoints = 0;
186
187 /*
188 // Initialize display default parameters
189 SetRange(3.5,3.5);
190 // Create colors
191 CreateColors();
192 // Create display canvas
193 Int_t ysize = size;
194 if (ysize < 100) ysize = 750;
195 Int_t xsize = Int_t(size*830./ysize);
196 fCanvas = new TCanvas("ModuleCanvas", "ITS Clusters Display",14,47,xsize,ysize);
197 fCanvas->ToggleEventStatus();
198
199 // Create main display pad
200 fPad = new TPad("mviewpad", "ITS display",0.15,0,0.9,1);
201 fPad->Draw();
202 fPad->Modified();
203 fPad->SetFillColor(1);
204 fPad->SetBorderSize(2);
205
206 fCanvas->cd();
207
208 // Create colors pad
209 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
210 fColPad->Draw();
211 fColPad->Modified();
212 fColPad->SetFillColor(19);
213 fColPad->SetBorderSize(2);
214 fColPad->cd();
215 DisplayColorScale();
216
217 fCanvas->cd();
218
219 // Create user interface control pad
220 DisplayButtons();
221 fCanvas->cd();
222
223 // Create Range and mode pad
224 Float_t dxtr = 0.15;
225 Float_t dytr = 0.45;
226 fTrigPad = new TPad("mtrigger", "range and mode pad",0,0,dxtr,dytr);
227 fTrigPad->SetEditable(kFALSE);
228 fTrigPad->Draw();
229 fTrigPad->cd();
230 fTrigPad->SetFillColor(22);
231 fTrigPad->SetBorderSize(2);
232 fRangeSlider = new TSlider("mrange","range",0.7,0.42,0.9,0.98);
233 fRangeSlider->SetObject(this);
234 //char pickmode[] = "gAlice->Display()->SetPickMode()";
235 char pickmode[] = "((AliITSdisplay*)(gAlice->Display()))->SetPickMode()";
236 Float_t db = 0.09;
237 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
238 fPickButton->SetFillColor(38);
239 fPickButton->Draw();
240 //char zoommode[] = "gAlice->Display()->SetZoomMode()";
241 char zoommode[] = "((AliITSdisplay*)(gAlice->Display()))->SetZoomMode()";
242 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
243 fZoomButton->SetFillColor(38);
244 fZoomButton->Draw();
245 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
246 fArcButton->SetFillColor(kGreen);
247 fArcButton->Draw();
248 //char butUnzoom[] = "gAlice->Display()->UnZoom()";
249 char butUnzoom[] = "((AliITSdisplay*)(gAlice->Display()))->UnZoom()";
250 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
251 button->SetFillColor(38);
252 button->Draw();
253 AppendPad(); // append display object as last object to force selection
254
255 fCanvas->cd();
256 fCanvas->Update();
257 */
258
259 CreateModuleCanvas(size);
260
261}
262
263//_____________________________________________________________________________
264void AliITSdisplay::CreateModuleCanvas(Int_t size)
265{
266
267 // Initialize display default parameters
268 SetRange(3.5,3.5);
269 // Create colors
270 CreateColors();
271 // Create display canvas
272 Int_t ysize = size;
273 if (ysize < 100) ysize = 750;
274 Int_t xsize = Int_t(size*830./ysize);
275 fCanvas = new TCanvas("ModuleCanvas", "ITS Clusters Display",14,47,xsize,ysize);
276 fCanvas->ToggleEventStatus();
277
278 Int_t wtopx, wtopy;
279 UInt_t ww,wh;
280 fCanvas->GetCanvasPar(wtopx,wtopy,ww,wh);
281
282 Float_t cx = gStyle->GetScreenFactor();
283
284 printf("CreateCanvas: cx wtopx wtopy ww wh %f %d %d %d %d\n", cx,wtopx,wtopy,ww,wh);
285
286 Int_t dum1,dum2;
287 UInt_t fCw,fCh;
288
289 Int_t fCanvasID=fCanvas->GetCanvasID();
290 gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
291
292 printf("CreateCanvas: fCw, fCh %d %d \n", fCw, fCh );
293
294
295
296 // Create main display pad
297 fPad = new TPad("mviewpad", "ITS display",0.15,0,0.9,1);
298 fPad->Draw();
299 fPad->Modified();
300 fPad->SetFillColor(1);
301 fPad->SetBorderSize(2);
302
303 fCanvas->cd();
304
305 // Create colors pad
306 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
307 fColPad->Draw();
308 fColPad->Modified();
309 fColPad->SetFillColor(19);
310 fColPad->SetBorderSize(2);
311 fColPad->cd();
312 DisplayColorScale();
313
314 fCanvas->cd();
315
316 // Create user interface control pad
317 DisplayButtons();
318 fCanvas->cd();
319
320 // Create Range and mode pad
321 Float_t dxtr = 0.15;
322 Float_t dytr = 0.45;
323 fTrigPad = new TPad("mtrigger", "range and mode pad",0,0,dxtr,dytr);
324 fTrigPad->SetEditable(kFALSE);
325 fTrigPad->Draw();
326 fTrigPad->cd();
327 fTrigPad->SetFillColor(22);
328 fTrigPad->SetBorderSize(2);
329 fRangeSlider = new TSlider("mrange","range",0.7,0.42,0.9,0.98);
330 fRangeSlider->SetObject(this);
331
332 // to use "gAlice->Display()->SetPickMode()" KEEP "trigger" instead
333 // of "mtrigger" and "range" instead of "mrange" !!!! - do NOT change
334 // the pad names if mix methods from AliDisplay and AliITSdisplay !
335
336 //char pickmode[] = "gAlice->Display()->SetPickMode()";
337 char pickmode[] = "((AliITSdisplay*)(gAlice->Display()))->SetPickMode()";
338 Float_t db = 0.09;
339 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
340 fPickButton->SetFillColor(38);
341 fPickButton->Draw();
342 //char zoommode[] = "gAlice->Display()->SetZoomMode()";
343 char zoommode[] = "((AliITSdisplay*)(gAlice->Display()))->SetZoomMode()";
344 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
345 fZoomButton->SetFillColor(38);
346 fZoomButton->Draw();
347 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
348 fArcButton->SetFillColor(kGreen);
349 fArcButton->Draw();
350 //char butUnzoom[] = "gAlice->Display()->UnZoom()";
351 char butUnzoom[] = "((AliITSdisplay*)(gAlice->Display()))->UnZoom()";
352 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
353 button->SetFillColor(38);
354 button->Draw();
355 AppendPad(); // append display object as last object to force selection
356
357 fCanvas->cd();
358 fCanvas->Update();
359}
360
361
362//_____________________________________________________________________________
363AliITSdisplay::~AliITSdisplay()
364{
365 // Delete space point structure
366 if (fPoints) fPoints->Delete();
367 delete fPoints;
368 fPoints = 0;
369 //
370 if (fPhits) fPhits->Delete();
371 delete fPhits;
372 fPhits = 0;
373 //
374 if (fRpoints) fRpoints->Delete();
375 delete fRpoints;
376 fRpoints = 0;
377//
378 if (fR2points) fR2points->Delete();
379 delete fR2points;
380 fR2points = 0;
381//
382 if (fCpoints) fCpoints->Delete();
383 delete fCpoints;
384 fCpoints = 0;
385}
386
387//_____________________________________________________________________________
388void AliITSdisplay::Clear(Option_t *)
389{
390// Delete graphics temporary objects
391}
392
393//_____________________________________________________________________________
394void AliITSdisplay::DisplayButtons()
395{
396// Create the user interface buttons
397
398
399 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
400 fButtons->SetEditable(kFALSE);
401 fButtons->Draw();
402 fButtons->SetFillColor(38);
403 fButtons->SetBorderSize(2);
404 fButtons->cd();
405
406// Int_t butcolor = 33;
407 Float_t dbutton = 0.08;
408 Float_t y = 0.96;
409 Float_t dy = 0.014;
410 Float_t x0 = 0.05;
411 Float_t x1 = 0.95;
412
413 TButton *button;
414 char but1[] = "((AliITSdisplay*)(gAlice->Display()))->ShowNextEvent(1)";
415 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
416 button->SetFillColor(38);
417 button->Draw();
418
419 y -= dbutton +dy;
420 //char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
421 char but2[] = "((AliITSdisplay*)(gAlice->Display()))->ShowNextEvent(-1)";
422 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
423 button->SetFillColor(38);
424 button->Draw();
425
426 y -= dbutton + dy;
427 char but3[] = "((AliITSdisplay*)(gAlice->Display()))->NextModule(1)";
428 button = new TButton("Module +", but3, x0, y - dbutton, x1, y);
429 button->SetFillColor(38);
430 button->Draw();
431
432 y -= dbutton + dy;
433 char but4[] = "((AliITSdisplay*)(gAlice->Display()))->NextModule(-1)";
434 button = new TButton("Module -", but4, x0, y - dbutton, x1, y);
435 button->SetFillColor(38);
436 button->Draw();
437
438 y -= dbutton + dy;
439 char but5[] = "((AliITSdisplay*)(gAlice->Display()))->DrawHistograms()";
440 button = new TButton("DrawHist", but5, x0, y - dbutton, x1, y);
441 button->SetFillColor(38);
442 button->Draw();
443 /*
444 y -= dbutton +dy;
445 char but6[] = "((AliITSdisplay*)(gAlice->Display()))->Trigger()";
446 button = new TButton("Trigger",but6,x0,y-dbutton,x1,y);
447 button->SetFillColor(38);
448 button->Draw();
449 */
450 // display logo
451 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
452 diamond->SetFillColor(50);
453 diamond->SetTextAlign(22);
454 diamond->SetTextColor(5);
455 diamond->SetTextSize(0.11);
456 diamond->Draw();
457 diamond->AddText(".. ");
458 diamond->AddText("ROOT");
459 diamond->AddText("ITS");
460 diamond->AddText("... ");
461 diamond->AddText(" ");
462}
463
464//_____________________________________________________________________________
465void AliITSdisplay::CreateColors()
466{
467// Create the colors palette used to display clusters
468
469 Int_t k,i;
470 Int_t color;
471 Float_t r,g,b;
472
473 for (k=1;k<=5;k++) {
474 switch(k) {
475 case 1:
476 for (i=1;i<=5;i++) {
477 r=1.;
478 g=i*0.2;
479 b=0.;
480 color=i;
481 color=260+23-color;
482 new TColor(color,r,g,b);
483 }
484 break;
485 case 2:
486 for (i=1;i<=4;i++) {
487 r=1.1-i*0.2;
488 g=1.;
489 b=0.;
490 color=i+5;
491 color=260+23-color;
492 new TColor(color,r,g,b);
493 }
494 break;
495 case 3:
496 for (i=1;i<=4;i++) {
497 r=0.;
498 g=1.;
499 b=i*0.2+0.2;
500 color=i+9;
501 color=260+23-color;
502 new TColor(color,r,g,b);
503 }
504 break;
505 case 4:
506 for (i=1;i<=4;i++) {
507 r=0.;
508 g=1.1-i*0.2;
509 b=1.;
510 color=i+13;
511 color=260+23-color;
512 new TColor(color,r,g,b);
513 }
514 break;
515 case 5:
516 for (i=1;i<=5;i++) {
517 r=i*0.2;
518 g=0.;
519 b=1.;
520 color=i+17;
521 color=260+23-color;
522 new TColor(color,r,g,b);
523 }
524 break;
525 }
526
527 }
528
529}
530
531//_____________________________________________________________________________
532void AliITSdisplay::DisplayColorScale()
533{
534
535 Int_t i;
536 Int_t color;
537 Float_t xlow, ylow, xup, yup, hs;
538 Float_t x1, y1, x2, y2;
539 x1 = y1 = 0;
540 x2 = y2 = 20;
541
542 printf("DisplayColorScale - gPad %p\n",gPad);
543
544 /*
545 gPad->SetFillColor(0);
546 gPad->Clear();
547 gPad->Range(x1,y1,x2,y2);
548 */
549
550 fColPad->SetFillColor(0);
551 fColPad->Clear();
552 fColPad->Range(x1,y1,x2,y2);
553
554 TText *text = new TText(0,0,"");
555 text->SetTextFont(61);
556 text->SetTextSize(0.2);
557 text->SetTextAlign(22);
558
559 /*
560 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
561 AliMUONchamber *iChamber = &(MUON->Chamber(fChamber-1));
562 AliMUONresponse * response=iChamber->GetResponseModel();
563 Int_t adcmax= (Int_t) response->MaxAdc();
564 */
565
566 Int_t adcmax=1024;
567
568
569 TBox *box;
570 char label[8];
571//*-* draw colortable boxes
572 hs = (y2-y1)/Float_t(22);
573 xlow=x1+1;
574 xup=x2-9;
575 for (i=0;i<22;i++) {
576 ylow = y1 + hs*(Float_t(i));
577 yup = y1 + hs*(Float_t(i+1));
578 color = 261+i;
579 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
580 Int_t scale=(Int_t)TMath::Exp(logscale);
581 sprintf(label,"%d",scale);
582 box = new TBox(xlow, ylow, xup, yup);
583 box->SetFillColor(color);
584 box->Draw();
585 text->DrawText(xup+4, 0.5*(ylow+yup),label);
586 }
587}
588
589//______________________________________________________________________________
590Int_t AliITSdisplay::DistancetoPrimitive(Int_t px, Int_t)
591{
592// Compute distance from point px,py to objects in event
593
594 gPad->SetCursor(kCross);
595
596 if (gPad == fTrigPad) return 9999;
597
598 const Int_t big = 9999;
599 Int_t dist = big;
600 Float_t xmin = gPad->GetX1();
601 Float_t xmax = gPad->GetX2();
602 Float_t dx = 0.02*(xmax - xmin);
603 Float_t x = gPad->AbsPixeltoX(px);
604 if (x < xmin+dx || x > xmax-dx) return dist;
605
606 if (fZoomMode) return 0;
607 else return 7;
608}
609
610//_____________________________________________________________________________
611void AliITSdisplay::Draw(Option_t *)
612{
613// Display current event
614
615 printf("Draw\n");
616
617 fPad->cd();
618
619 DrawView(fTheta, fPhi, fPsi);
620 // Display the event number and title
621 fPad->cd();
622 DrawTitle();
623}
624
625
626//_____________________________________________________________________________
627void AliITSdisplay::DrawClusters()
628{
629// Draw clusters for ITS modules
630
631 if (!fDrawClusters) return;
632
633 Int_t ndigits, digit;
634 TObjArray *points;
635 AliITSpoints *pm;
636
637 LoadDigits(fModule);
638
639 fClustersCuts = 0;
640 points = Points();
641 if (!points) return;
642 ndigits = points->GetEntriesFast();
643 for (digit=0;digit<ndigits;digit++){
644 pm = (AliITSpoints*)points->UncheckedAt(digit);
645 if (!pm) continue;
646 Float_t *pxyz;
647 pxyz=pm->GetP();
648 TMarker3DBox *marker=pm->GetMarker(0);
649 if (marker) marker->Draw();
650 pm->Draw();
651 fClustersCuts +=pm->GetN();
652
653 }
654
655 sModule=fModule;
656}
657
658//_____________________________________________________________________________
659void AliITSdisplay::DrawHits()
660{
661// Draw hits for ITS modules
662
663 LoadHits(fModule);
664
665 Int_t ntracks, track;
666 TObjArray *points;
667 AliITSpoints *pm;
668
669 fHitsCuts = 0;
670 points = Phits();
671 if (!points) return;
672 ntracks = points->GetEntriesFast();
673 for (track=0;track<ntracks;track++) {
674 pm = (AliITSpoints*)points->UncheckedAt(track);
675 if (!pm) continue;
676 pm->Draw();
677 fHitsCuts += pm->GetN();
678 }
679}
680
681
682//_____________________________________________________________________________
683void AliITSdisplay::DrawCoG()
684{
685// Draw rec hits for ITS module
686
687 /*
688 if (!fDrawCoG) return;
689 LoadCoG(fChamber,fCathode);
690
691 Int_t ncog, icog;
692 TObjArray *points;
693 AliITSpoints *pm;
694
695 points = Rpoints();
696 if (!points) return;
697 ncog = points->GetEntriesFast();
698 for (icog=0;icog<ncog;icog++) {
699 pm = (AliITSpoints*)points->UncheckedAt(icog);
700 if (!pm) continue;
701 pm->Draw();
702 }
703 */
704}
705//_____________________________________________________________________________
706void AliITSdisplay::DrawCoG2()
707{
708// Draw rec hits for ITS module
709
710 /*
711
712 if (!fDrawCoG) return;
713
714
715 if (fCathode==1) {
716 LoadCoG2(fChamber,2);
717 } else if (fCathode==2) {
718 LoadCoG2(fChamber,1);
719 }
720
721 Int_t ncog, icog;
722 TObjArray *points;
723 AliITSpoints *pm;
724
725 points = R2points();
726 if (!points) return;
727 ncog = points->GetEntriesFast();
728 for (icog=0;icog<ncog;icog++) {
729 pm = (AliITSpoints*)points->UncheckedAt(icog);
730 if (!pm) continue;
731 pm->Draw();
732 }
733 */
734}
735//_____________________________________________________________________________
736void AliITSdisplay::DrawCathCor()
737{
738// Draw hits for ITS chambers
739
740 /*
741
742 if (!fDrawCathCor) return;
743
744 LoadCathCor(fChamber);
745
746 Int_t ncog, icog;
747 TObjArray *points;
748 AliITSpoints *pm;
749
750 points = Cpoints();
751 if (!points) return;
752 ncog = points->GetEntriesFast();
753 for (icog=0;icog<ncog;icog++) {
754 pm = (AliITSpoints*)points->UncheckedAt(icog);
755 if (!pm) continue;
756 pm->Draw();
757 }
758 */
759}
760
761//_____________________________________________________________________________
762void AliITSdisplay::DrawTitle(Option_t *option)
763{
764// Draw the event title
765
766 Float_t xmin = gPad->GetX1();
767 Float_t xmax = gPad->GetX2();
768 Float_t ymin = gPad->GetY1();
769 Float_t ymax = gPad->GetY2();
770 Float_t dx = xmax-xmin;
771 Float_t dy = ymax-ymin;
772
773 if (strlen(option) == 0) {
774 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
775 title->SetBit(kCanDelete);
776 title->SetFillColor(42);
777 title->Draw();
778 char ptitle[100];
779 sprintf(ptitle,"Alice event: %d, Run:%d Module:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun(),fModule);
780 title->AddText(ptitle);
781 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
782 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",nparticles, fHitsCuts,fClustersCuts);
783 title->AddText(ptitle);
784 } else {
785 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
786 label->SetBit(kCanDelete);
787 label->SetFillColor(42);
788 label->Draw();
789 }
790}
791
792//_____________________________________________________________________________
793void AliITSdisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
794{
795// Draw a view of ITS clusters
796
797 printf("DrawView - fPad gPad %p %p\n",fPad,gPad);
798
799 gPad->SetCursor(kWatch);
800 gPad->SetFillColor(1);
801 gPad->Clear();
802 gPad->SetFillColor(1);
803
804 Int_t iret=0;
805 TView *view = new TView(1);
806
807 printf("DrawView - view %p \n",view);
808
809 Float_t range = fRrange*fRangeSlider->GetMaximum();
810
811 printf("DrawView - range fRrange fRangeSlider %f %f %f \n",range,fRrange,fRangeSlider->GetMaximum());
812 view->SetRange(-range,-range,-range,range, range, range);
813 fZoomX0[0] = -1;
814 fZoomY0[0] = -1;
815 fZoomX1[0] = 1;
816 fZoomY1[0] = 1;
817 fZooms = 0;
818
819// Display ITS Chamber Geometry
820// gAlice->GetGeometry()->Draw("same");
821 char NodeName[7];
822 sprintf(NodeName,"ITS%d",100+fModule);
823 printf("Node name %s\n", NodeName);
824
825 TNode *node1=gAlice->GetGeometry()->GetNode(NodeName);
826 if (node1) node1->Draw("same");
827
828//add clusters to the pad
829 DrawClusters();
830 DrawHits();
831 //DrawCoG();
832 // DrawCoG2();
833 //DrawCathCor();
834
835 printf("DrawView - before append fPad gPad %p %p\n",fPad,gPad);
836 // add itself to the list (must be last)
837 AppendPad();
838 view->SetView(phi, theta, psi, iret);
839}
840
841
842//______________________________________________________________________________
843void AliITSdisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
844{
845// Execute action corresponding to the mouse event
846
847 static Float_t x0, y0, x1, y1;
848
849 static Int_t pxold, pyold;
850 static Int_t px0, py0;
851 static Int_t linedrawn;
852 Float_t temp;
853
854
855 /*
856 //printf("ExecuteEvent - px py %d %d\n",px,py);
857
858 int px1 = gPad->GetEventX();
859 int py1 = gPad->GetEventY();
860 float uxmin = gPad->GetUxmin();
861 float uxmax = gPad->GetUxmax();
862 int pxmin = gPad->XtoAbsPixel(uxmin);
863 int pxmax = gPad->XtoAbsPixel(uxmax);
864
865 //printf("ExecuteEvent - px1 py1 uxmin uxmax pxmin pxmax %d %d %f %f %d %d\n",px1,py1,uxmin,uxmax,pxmin,pxmax);
866
867 Float_t x = gPad->AbsPixeltoX(px);
868 Float_t y = gPad->AbsPixeltoY(py);
869 //printf("x=%.3g, y=%.3g \n",gPad->PadtoX(x),gPad->PadtoY(y));
870
871 TObject *select = gPad->GetSelected();
872 if(!select) {printf("no select \n"); return;}
873 if (select->InheritsFrom("AliITSdisplay")) printf("Inherits from AliITSdisplay \n");
874
875 if (select->InheritsFrom("TCanvas")) printf("Inherits from TCanvas \n");
876 if (select->InheritsFrom("TView")) printf("Inherits from TView \n");
877
878 Float_t x,y;
879
880 // x,y in the -1,1 scale
881 x = gPad->AbsPixeltoX(px);
882 y = gPad->AbsPixeltoY(py);
883
884 printf("abspixeltoX: px py %d %d x=%.3g, y=%.3g \n",px,py,x,y);
885 printf("x=%.3g, y=%.3g \n",gPad->PadtoX(x),gPad->PadtoY(y));
886
887 // it should be smth like ? - no !
888 x = gPad->AbsPixeltoX(px)*fRrange*fRangeSlider->GetMaximum();
889 y = gPad->AbsPixeltoY(py)*fRrange*fRangeSlider->GetMaximum();
890 // now find out how to convert these x,y to x,y in detector system
891
892 Int_t dum1,dum2;
893 UInt_t fCw, fCh;
894 Float_t fYsizeReal, fXsizeReal;
895
896 Int_t fCanvasID=fCanvas->GetCanvasID();
897 gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
898
899 printf("Exec: fCw, fCh %d %d \n", fCw, fCh );
900
901 if (fCw < fCh) {
902 fYsizeReal = 20;
903 fXsizeReal = fYsizeReal*Float_t(fCw)/Float_t(fCh);
904 }
905 else {
906 fXsizeReal = 20;
907 fYsizeReal = fXsizeReal*Float_t(fCh)/Float_t(fCw);
908 }
909
910 printf("Exec: fYsizeReal, fXsizeReal %f %f \n",fYsizeReal, fXsizeReal);
911
912 fXsizeReal = fXsizeReal*Float_t(px)/Float_t(fCw);
913 fYsizeReal = fYsizeReal*Float_t(py)/Float_t(fCh);
914
915 printf("Exec: fYsizeReal, fXsizeReal %f %f \n",fYsizeReal, fXsizeReal);
916
917 */
918
919 if (!gPad) return;
920
921 Float_t scale[3],center[3];
922 Int_t irep;
923 gPad->GetView()->FindScope(scale,center,irep);
924 for(int i=0;i<3;i++) {
925 //printf("Exec: scale center irep %f %f %d \n",scale[i],center[i],irep);
926 }
927 Float_t x,y;
928 // x,y in the -1,1 scale
929 x = gPad->AbsPixeltoX(px);
930 y = gPad->AbsPixeltoY(py);
931 Float_t xhit=x*scale[0]/(fRrange*fRangeSlider->GetMaximum());
932 Float_t yhit=y*scale[0]/(fRrange*fRangeSlider->GetMaximum());
933 //printf("Exec: x*scale y*scale xhit yhit%f %f %f %f \n",x*scale[0],y*scale[1],xhit,yhit);
934
935 Int_t anode, timebin;
936 GetPadIxy(anode,timebin,x*scale[0],y*scale[0]);
937 //printf("Exec: anode timebin %d %d \n",anode,timebin);
938
939
940 if (px == 0 && py == 0) { //when called by sliders
941 if (event == kButton1Up) {
942 Draw();
943 }
944 return;
945 }
946 if (!fZoomMode && gPad->GetView()) {
947 gPad->GetView()->ExecuteRotateView(event, px, py);
948 return;
949 }
950
951 // something to zoom ?
952 gPad->SetCursor(kCross);
953
954 switch (event) {
955
956 case kButton1Down:
957 gVirtualX->SetLineColor(-1);
958 gPad->TAttLine::Modify(); //Change line attributes only if necessary
959 x0 = gPad->AbsPixeltoX(px);
960 y0 = gPad->AbsPixeltoY(py);
961 px0 = px; py0 = py;
962 pxold = px; pyold = py;
963 linedrawn = 0;
964 return;
965
966 case kButton1Motion:
967 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
968 pxold = px;
969 pyold = py;
970 linedrawn = 1;
971 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
972 return;
973
974 case kButton1Up:
975 gPad->GetCanvas()->FeedbackMode(kFALSE);
976 if (px == px0) return;
977 if (py == py0) return;
978 x1 = gPad->AbsPixeltoX(px);
979 y1 = gPad->AbsPixeltoY(py);
980
981 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
982 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
983 gPad->Range(x0,y0,x1,y1);
984 if (fZooms < kMAXZOOM-1) {
985 fZooms++;
986 fZoomX0[fZooms] = x0;
987 fZoomY0[fZooms] = y0;
988 fZoomX1[fZooms] = x1;
989 fZoomY1[fZooms] = y1;
990 }
991 gPad->Modified(kTRUE);
992 return;
993 }
994
995}
996//___________________________________________
997void AliITSdisplay::LoadDigits(Int_t module)
998{
999// Read digits info and store x,y,z info in arrays fPoints
1000
1001 printf("LoadDigits - fZooms %d\n",fZooms);
1002
1003 if (module > fNmodules ) return;
1004
1005 fModule=module;
1006
1007 ResetPoints();
1008
1009 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1010 AliITSgeom *geom = ITS->GetITSgeom();
1011
1012 // get detector type
1013 AliITSDetType *iDetType = ITS->DetType(fLayer);
1014 Int_t id=(Int_t)((fLayer-1)/2);
1015
1016 // for the moment do only SDD
1017 if (id != 1) return;
1018
1019 TClonesArray *ITSdigits = ITS->DigitsAddress(id);
1020 if (ITSdigits == 0) return;
1021
1022 Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
1023 printf("Entries in TreeD - nent %d\n",nent);
1024 Int_t lastSPD=geom->GetLastSPD();
1025 Int_t lastSDD=geom->GetLastSDD();
1026 if (nent < lastSDD) {
1027 printf("You have not done the digitisation for all det types !!!");
1028 module=fModule-lastSPD;
1029 }
1030
1031
1032 ITS->ResetDigits();
1033 gAlice->TreeD()->GetEvent(module);
1034 //gAlice->TreeD()->GetEvent(nent-nofmodules+module-1);
1035 Int_t ndigits = ITSdigits->GetEntriesFast();
1036 printf("Found %d digits for module %d in det type %d \n",ndigits,fModule,id+1);
1037 if (ndigits == 0) return;
1038 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1039
1040 //AliITSresponseV0* resp = (AliITSresponseV0*)iDetType->GetResponseModel();
1041 AliITSresponse* resp = (AliITSresponse*)iDetType->GetResponseModel();
1042 resp->SetDetSize(38400,75200);
1043 resp->SetDetParam(376,256,40.,6.);
1044
1045 if (!fMap) fMap = new AliITSMapA2(resp);
1046 if (sModule != fModule) fMap->ClearMap();
1047
1048
1049 // if parameters in response where changed during digitisation set these
1050 // parameters here as well !! resp->SetDetParam(....), SetDetSize(...)
1051 // or pass in the constructor of display the pointer to a response
1052 // instantiation done in ITSdisplay.C !
1053
1054 AliITSdigitSDD *mdig;
1055 AliITSpoints *points = 0;
1056 TMarker3DBox *marker=0;
1057 Float_t xl[3], dx[3];
1058 //
1059 //loop over all digits and store their position
1060 Int_t adcsatm=1024;
1061 Int_t npoints=1;
1062 for (Int_t digit=0;digit<ndigits;digit++) {
1063 mdig = (AliITSdigitSDD*)ITSdigits->UncheckedAt(digit);
1064 //
1065 // First get all needed parameters
1066 //
1067 Int_t charge=0;
1068 Int_t chargecolor=0;
1069 Int_t signal=mdig->fSignal;
1070 for (int i=0;i<3;i++) {charge += mdig->fTcharges[i];}
1071 //printf("charge %d\n",charge);
1072 Int_t chargeindex=Int_t(TMath::Log(charge)/(TMath::Log(adcsatm)/22));
1073 Int_t index=Int_t(TMath::Log(signal)/(TMath::Log(adcsatm)/22));
1074 Int_t color=261+index;
1075 if (color>282) color=282;
1076 if (charge) chargecolor=261+chargeindex;
1077 if (chargecolor>282) chargecolor=282;
1078 Int_t anode=mdig->fCellX ;
1079 Int_t timebin=mdig->fCellY;
1080 fMap->SetHit(anode,timebin,(Double_t)signal);
1081 // get the center of the pad - add on x and y half of pad size
1082 GetPadCxy(anode,timebin,xl,dx);
1083
1084 Float_t xpad=xl[0];
1085 Float_t ypad=xl[1];
1086 Float_t zpad=xl[2];
1087
1088 Float_t dpx=dx[0];
1089 Float_t dpy=dx[1];
1090 Float_t dpz=dx[2];
1091
1092 //printf("anode timebin charge signal %d %d %d %d \n",anode, timebin,charge,signal);
1093 //printf("xpad ypad zpad %f %f %f\n",xpad,ypad,zpad);
1094 //printf(" dpx dpz %f %f \n",dpx,dpz);
1095 //
1096 // Then set the objects
1097 //
1098 points = new AliITSpoints(npoints);
1099 fPoints->AddAt(points,digit);
1100
1101 points->SetMarkerColor(color);
1102 points->SetMarkerStyle(21);
1103 //points->SetMarkerSize(0.5);
1104 points->SetMarkerSize(0.7);
1105 points->SetParticle(-1);
1106 points->SetDigitIndex(digit);
1107 points->SetPoint(0,xpad,ypad,zpad);
1108 marker=new TMarker3DBox(xpad,ypad,zpad,dpx,dpy,dpz,0,0);
1109 //marker->SetLineColor(2);
1110 marker->SetLineColor(chargecolor);
1111 marker->SetFillStyle(1001);
1112 marker->SetFillColor(color);
1113 marker->SetRefObject((TObject*)points);
1114 points->Set3DMarker(0, marker);
1115
1116 }
1117}
1118//___________________________________________
1119void AliITSdisplay::GetPadCxy(Int_t anode, Int_t timebin, Float_t *xl, Float_t *dx )
1120
1121{
1122 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1123 // get detector type
1124 AliITSDetType *iDetType = ITS->DetType(fLayer);
1125 AliITSresponse* resp = (AliITSresponse*)iDetType->GetResponseModel();
1126
1127
1128 Int_t na,ns;
1129 Float_t clock, speed;
1130 resp->GetDetParam(na,ns,clock,speed);
1131 //printf("resp na ns clock speed %p %d %d %f %f\n",resp,na,ns,clock,speed);
1132
1133 Float_t timestep=1000./clock;
1134 Float_t pitch=resp->Pitch();
1135 Float_t width=resp->Width();
1136 Float_t length=resp->Length();
1137 //printf("timestep pitch width length %f %f %f %f \n",timestep,pitch,width,length);
1138
1139 const Float_t kconv=10000; // um->cm
1140
1141
1142 //Float_t driftpath=timebin*timestep*speed;
1143 Float_t driftpath=(timebin+1)*timestep*speed;
1144 if (anode >= na) xl[0]=(length-driftpath)/kconv;
1145 else xl[0]= -(length-driftpath)/kconv;
1146 if (anode >= na) anode-=na;
1147 //xl[2]=(anode*pitch-width/2)/kconv;
1148 xl[2]=((anode+1)*pitch-width/2)/kconv;
1149 xl[1]=fYmodule;
1150 //printf("anode timebin %d %d \n",anode,timebin);
1151 //printf("anode*pitch timebin*timestep*speed %f %f\n",anode*pitch,timebin*timestep*speed);
1152
1153 // keep these for drawing
1154 //dx[0]=timestep*speed/kconv/2.1;
1155 //dx[1]=0;
1156 //dx[2]=pitch/kconv/2.05;
1157
1158 dx[0]=timestep*speed/kconv/2;
1159 dx[1]=0;
1160 dx[2]=pitch/kconv/2;
1161}
1162
1163//___________________________________________
1164void AliITSdisplay::GetPadIxy(Int_t &anode, Int_t &timebin,Float_t x,Float_t z)
1165{
1166 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1167 // get detector type
1168 AliITSDetType *iDetType = ITS->DetType(fLayer);
1169 AliITSresponse* resp = (AliITSresponse*)iDetType->GetResponseModel();
1170
1171
1172 Int_t na,ns;
1173 Float_t clock, speed;
1174 resp->GetDetParam(na,ns,clock,speed);
1175
1176 Float_t timestep=1000./clock;
1177 Float_t pitch=resp->Pitch();
1178 Float_t width=resp->Width();
1179 Float_t length=resp->Length();
1180
1181 const Float_t kconv=10000; // cm->um
1182
1183 Float_t driftpath=length-TMath::Abs(kconv*x);
1184 timebin=(Int_t)(driftpath/speed/timestep);
1185 anode=kconv*z/pitch + na/2;
1186 if (x > 0) anode += na;
1187
1188 timebin+=1;
1189 anode+=1;
1190 //printf("anode timebin %d %d\n",anode,timebin);
1191
1192}
1193//___________________________________________
1194void AliITSdisplay::LoadCoG(Int_t chamber, Int_t cathode)
1195{
1196// Read raw clusters info and store x,y,z info in arrays fRpoints
1197// Loop on all detectors
1198
1199 /*
1200
1201 if (chamber > 10) return;
1202
1203 ResetRpoints();
1204
1205 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1206 AliITSchamber* iChamber;
1207
1208 TClonesArray *ITSrawclust = ITS->RawClustAddress(chamber-1);
1209 if (ITSrawclust == 0) return;
1210
1211 ITS->ResetRawClusters();
1212
1213
1214 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
1215 gAlice->TreeR()->GetEvent(nent-2+cathode-1);
1216 //gAlice->TreeR()->GetEvent(cathode);
1217 Int_t nrawcl = ITSrawclust->GetEntriesFast();
1218 if (nrawcl == 0) return;
1219 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1220
1221 iChamber = &(ITS->Chamber(chamber-1));
1222 Float_t zpos=iChamber->ZPosition();
1223 AliITSRawCluster *mRaw;
1224 AliITSpoints *points = 0;
1225 //
1226 //loop over all raw clusters and store their position
1227 points = new AliITSpoints(nrawcl);
1228 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1229 mRaw = (AliITSRawCluster*)ITSrawclust->UncheckedAt(iraw);
1230 fRpoints->AddAt(points,iraw);
1231 points->SetMarkerColor(51);
1232 points->SetMarkerStyle(2);
1233 points->SetMarkerSize(1.);
1234 points->SetParticle(-1);
1235 points->SetHitIndex(-1);
1236 points->SetTrackIndex(-1);
1237 points->SetDigitIndex(-1);
1238 points->SetPoint(iraw,mRaw->fX,mRaw->fY,zpos);
1239 }
1240 */
1241}
1242//___________________________________________
1243void AliITSdisplay::LoadCoG2(Int_t chamber, Int_t cathode)
1244{
1245// Read raw clusters info and store x,y,z info in arrays fRpoints
1246// Loop on all detectors
1247 /*
1248
1249 if (chamber > 10) return;
1250
1251 ResetR2points();
1252
1253 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1254 AliMUONchamber* iChamber;
1255
1256 TClonesArray *MUONrawclust = MUON->RawClustAddress(chamber-1);
1257 if (MUONrawclust == 0) return;
1258
1259 MUON->ResetRawClusters();
1260
1261 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
1262 gAlice->TreeR()->GetEvent(nent-2+cathode-1);
1263 //gAlice->TreeR()->GetEvent(cathode);
1264 Int_t nrawcl = MUONrawclust->GetEntriesFast();
1265 if (nrawcl == 0) return;
1266 if (fR2points == 0) fR2points = new TObjArray(nrawcl);
1267
1268 iChamber = &(MUON->Chamber(chamber-1));
1269 Float_t zpos=iChamber->ZPosition();
1270 AliMUONRawCluster *mRaw;
1271 AliMUONpoints *points = 0;
1272 //
1273 //loop over all raw clusters and store their position
1274 points = new AliMUONpoints(nrawcl);
1275 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1276 mRaw = (AliMUONRawCluster*)MUONrawclust->UncheckedAt(iraw);
1277 fR2points->AddAt(points,iraw);
1278 points->SetMarkerColor(51);
1279 points->SetMarkerStyle(4);
1280 points->SetMarkerSize(1.3);
1281 points->SetParticle(-1);
1282 points->SetHitIndex(-1);
1283 points->SetTrackIndex(-1);
1284 points->SetDigitIndex(-1);
1285 points->SetPoint(iraw,mRaw->fX,mRaw->fY,zpos);
1286 }
1287 */
1288}
1289//___________________________________________
1290void AliITSdisplay::LoadCathCor(Int_t chamber)
1291{
1292// Read correlation info and store x,y,z info in arrays fCpoints
1293// Loop on all detectors
1294
1295 /*
1296 if (chamber > 10) return;
1297 fChamber=chamber;
1298 ResetCpoints();
1299
1300 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
1301 AliMUONchamber* iChamber;
1302 iChamber = &(MUON->Chamber(chamber-1));
1303 Float_t zpos=iChamber->ZPosition(); // check with Andreas
1304
1305
1306 //new
1307 MUON->GetTreeC(fEvent);
1308 TTree *TC=MUON->TreeC();
1309 if (!TC) return;
1310 // Int_t nent=(Int_t)TC->GetEntries();
1311
1312 TClonesArray *MUONcorrel = MUON->CathCorrelAddress(chamber-1);
1313 if (MUONcorrel == 0) return;
1314
1315 MUON->ResetCorrelation();
1316 TC->GetEvent();
1317
1318 Int_t ncor = MUONcorrel->GetEntries();
1319 if (!ncor) return;
1320 if (!fCpoints) fCpoints = new TObjArray(ncor);
1321
1322 AliMUONcorrelation *mCor;
1323 AliMUONpoints *points = 0;
1324 //
1325 //loop over all raw clusters and store their position
1326 points = new AliMUONpoints(ncor);
1327 for (Int_t icor=0;icor<ncor;icor++) {
1328 mCor = (AliMUONcorrelation*)MUONcorrel->UncheckedAt(icor);
1329 fCpoints->AddAt(points,icor);
1330 points->SetMarkerColor(4);
1331 points->SetMarkerStyle(4);
1332 points->SetMarkerSize(0.8);
1333 points->SetParticle(-1);
1334 points->SetHitIndex(-1);
1335 points->SetTrackIndex(-1);
1336 points->SetDigitIndex(-1);
1337 points->SetPoint(icor,mCor->fX[0],mCor->fY[0],zpos);
1338 }
1339 */
1340}
1341
1342//___________________________________________
1343void AliITSdisplay::LoadHits(Int_t module)
1344{
1345
1346// Read hits info and store x,y,z info in arrays fPhits
1347// Loop on all detectors
1348
1349
1350 if (module > fNmodules || fNmodules==0) return;
1351
1352 fModule=module;
1353 printf("LoadModuleHits - fModule module %d %d\n",fModule,module);
1354
1355 ResetPhits();
1356
1357 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1358 AliITSgeom *geom = ITS->GetITSgeom();
1359
1360 // try fITSmodules first (memory) - check also TreeH with the condition
1361 // if (module != fModule) continue; - see the speed
1362
1363 TObjArray *mods = ITS->GetModules();
1364 Int_t nentries=(Int_t)mods->GetEntriesFast();
1365 printf("nentries %d\n",nentries);
1366
1367 AliITSmodule *mod = (AliITSmodule *)mods->UncheckedAt(fModule);
1368 TObjArray *fHits = mod->GetHits();
1369 Int_t nhits = fHits->GetEntriesFast();
1370 if (fPhits == 0) fPhits = new TObjArray(nhits);
1371 printf("LoadModuleHits - fPhits fModule nhits %p %d %d\n",fPhits,fModule,nhits);
1372 AliITSpoints *points = 0;
1373 AliITShit *mHit = 0;
1374 Int_t idtrack, idhit;
1375 for (Int_t hit=0;hit<nhits;hit++) {
1376 mHit = (AliITShit*)fHits->UncheckedAt(hit);
1377 mod->GetHitTrackAndHitIndex(hit,idtrack,idhit);
1378 printf("hit eloss %d %f\n",hit,mHit->GetIonization());
1379 printf("layer ladder det %d %d %d\n",mHit->GetLayer(),mHit->GetLadder(),mHit->GetDetector());
1380 if (!mHit->GetIonization()) continue;
1381 //fYmodule=mHit->fY;
1382 Float_t xl[3], xg[3];
1383 xg[0]=mHit->fX;
1384 xg[1]=mHit->fY;
1385 xg[2]=mHit->fZ;
1386
1387 geom->GtoL(fModule,xg,xl);
1388 printf("hit xhit yhit zhit %d %f %f %f\n",hit,xl[0],xl[1],xl[2]);
1389 Float_t x,y,z,tof;
1390 mHit->GetPositionL(x,y,z,tof);
1391 printf("hit x y z %d %f %f %f\n",hit,x,y,z);
1392
1393 fYmodule=xl[1];
1394 //
1395 // Retrieve info and set the objects
1396 //
1397 points = new AliITSpoints();
1398 points->SetMarkerColor(kRed);
1399 points->SetMarkerStyle(5);
1400 points->SetMarkerSize(1.);
1401 points->SetParticle(mHit->fTrack);
1402 points->SetHitIndex(idhit);
1403 points->SetTrackIndex(idtrack);
1404 //points->SetPoint(0,mHit->fX,mHit->fY,mHit->fZ);
1405 points->SetPoint(0,xl[0],xl[1],xl[2]);
1406 fPhits->AddAt(points,hit);
1407 }
1408
1409}
1410
1411//_____________________________________________________________________________
1412void AliITSdisplay::NextModule(Int_t delta)
1413{
1414 // to go from module to next module if delta = 1
1415 // or previous module otherwise
1416 if (delta == 1) {
1417 if (fModule < fNmodules) fModule++;
1418 } else {
1419 if (fModule > 1) fModule--;
1420 }
1421 if (!fPad) return;
1422 fPad->Clear();
1423 Draw();
1424}
1425
1426//_____________________________________________________________________________
1427void AliITSdisplay::Paint(Option_t *)
1428{
1429// Paint miscellaneous items
1430
1431}
1432
1433//_____________________________________________________________________________
1434void AliITSdisplay::DrawHistograms()
1435{
1436
1437 // better write a class for this - see TInspectCanvas - with a methode
1438 // called xxxx and here just do smth like it's done for Inspect() in TObject
1439 //gROOT->ProcessLine(Form("TInspectCanvas::Inspector((TObject *)0x%lx);",(Long_t)this));
1440 // with xxxx instead of Inspector - so one can create buttons on the
1441 // new canvas and have more choices
1442
1443
1444 printf("DrawHistograms: fZooms fZoomMode %d %d ! \n",fZooms,fZoomMode);
1445
1446 if (!fZooms) return;
1447
1448 Float_t scale[3],center[3];
1449 Int_t irep;
1450 gPad->GetView()->FindScope(scale,center,irep);
1451
1452 Int_t amin, tmin, amax, tmax;
1453 GetPadIxy(amin,tmin, fZoomX0[fZooms]*scale[0], fZoomY0[fZooms]*scale[0]);
1454 printf("DrawHist: amin tmin %d %d \n",amin,tmin);
1455 GetPadIxy(amax,tmax, fZoomX1[fZooms]*scale[0], fZoomY1[fZooms]*scale[0]);
1456 printf("DrawHist: amax tmax %d %d \n",amax,tmax);
1457
1458 if ((fZoomX0[fZooms] < 0 && fZoomX1[fZooms] > 0) || (fZoomX0[fZooms] > 0 && fZoomX1[fZooms] < 0) ) tmax=256;
1459
1460 if( amax-amin > kMAXHIST) {
1461 Error("DrawHistograms","Too many histograms %d! Zoom a smaller area and try again!",amax-amin);
1462 return;
1463 }
1464 Int_t nbinx = amax-amin;
1465 Int_t nbiny = tmax-tmin;
1466
1467 fDrawHist = kTRUE;
1468 TObjArray *fHis=0;
1469
1470 //create or set the new canvas c2
1471 TVirtualPad *padsav = gPad;
1472 TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
1473 /*
1474 if(c2) {
1475 if (fHis) {
1476 fHis->Delete();
1477 delete fHis;
1478 }
1479 }
1480 */
1481 if(c2) delete c2->GetPrimitive("h2map");
1482 else c2=new TCanvas("c2","c2",14,47,830,750);
1483 c2->cd();
1484
1485 TPad *hpad = new TPad("hpad","",0.01,0.01,0.99,0.99);
1486 hpad->SetFillColor(0);
1487 //hpad->Draw();
1488 hpad->Divide(2,nbinx/2,0.,0.);
1489 hpad->Draw();
1490
1491 char title[30], name[10];
1492 sprintf(title,"Signal map for module %d",fModule);
1493 TH2F *fTH2F = new TH2F("h2map",title,nbinx,amin,amax,nbiny,tmin,tmax);
1494 fHis=new TObjArray(nbinx);
1495
1496 //TH1F *h1=new TH1F(" ","",nbiny,(float)tmin,(float)tmax);
1497
1498 for (int i=amin;i<amax;i++) {
1499 //h1->Reset();
1500 printf("i, i-amin %d %d \n",i,i-amin);
1501 (*fHis)[i-amin] = new TH1F(" "," ",nbiny,(float)tmin,(float)tmax);
1502 //sprintf(title,"Projection on anode=%d",i);
1503 sprintf(title,"anode=%d",i);
1504 sprintf(name,"h%d",i);
1505 ((TH1F*)((*fHis)[i-amin]))->SetTitle(title);
1506 ((TH1F*)((*fHis)[i-amin]))->SetTitleSize(2.);
1507 ((TH1F*)((*fHis)[i-amin]))->SetTitleOffset(2.);
1508 ((TH1F*)((*fHis)[i-amin]))->SetLabelSize(0.05);
1509 //((TH1F*)((*fHis)[i-amin]))->SetYTitle(title);
1510 ((TH1F*)((*fHis)[i-amin]))->SetName(name);
1511 ((TH1F*)((*fHis)[i-amin]))->SetStats(0);
1512 //h1->SetTitle(title);
1513 //h1->SetTitleSize(0.04);
1514 //h1->SetYTitle(title);
1515 //h1->SetName(title);
1516 hpad->cd(i-amin+1);
1517 for (int j=tmin;j<tmax;j++) {
1518 ((TH1F*)((*fHis)[i-amin]))->Fill((float)j,(float)fMap->GetSignal(i,j));
1519 //h1->Fill((float)j,(float)fMap->GetSignal(i,j));
1520 fTH2F->Fill((float)i,(float)j,(float)fMap->GetSignal(i,j));
1521 }
1522 ((TH1F*)((*fHis)[i-amin]))->Smooth(1);
1523 //((TH1F*)((*fHis)[i-amin]))->Fit("gaus","ql");
1524 ((TH1F*)((*fHis)[i-amin]))->Draw();
1525 //h1->Fit("gaus","ql");
1526 //h1->Draw();
1527 //hpad->Update();
1528 }
1529 c2->Update();
1530 //c2->SetFillColor(1);
1531 //fTH2F->Draw("LEGO2");
1532
1533 padsav->cd();
1534
1535 fDrawHist=kFALSE;
1536
1537 /*
1538 if (fHis) {
1539 fHis->Delete();
1540 delete fHis;
1541 }
1542
1543 */
1544
1545
1546 /*
1547 //create or set the new canvas c2
1548 TVirtualPad *padsav = gPad;
1549 TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
1550 if(c2) delete c2->GetPrimitive("Projection");
1551 if(c2) delete c2->GetPrimitive("h2map");
1552 else c2=new TCanvas("c2","c2",14,47,830,750);
1553 c2->cd();
1554
1555 c2->SetFillColor(1);
1556 fTH2F->Draw("LEGO2");
1557
1558 TPad *hpad = new TPad("hpad","",0.01,0.01,0.99,0.99);
1559 hpad->SetFillColor(11);
1560 hpad->Divide(1,nbinx/2,0.,0.);
1561 hpad->Draw();
1562 // -empty projections !!
1563
1564 //draw slice corresponding to mouse position
1565 for(int i=amin;i<amax;i++) {
1566 hpad->cd(i-amin+1);
1567 //Int_t biny = fTH2F->GetYaxis()->FindBin(y);
1568 //TH1D *hp = fTH2F->ProjectionX("",biny,biny);
1569 TH1D *hp = fTH2F->ProjectionY("",i,i);
1570 char title[80];
1571 sprintf(title,"Projection on anode=%d",i);
1572 hp->SetName("Projection");
1573 hp->SetTitle(title);
1574 //hp->Fit("gaus","ql");
1575 hp->Draw();
1576 hpad->Update();
1577 }
1578 c2->Update();
1579 padsav->cd();
1580
1581 fDrawHist=kFALSE;
1582 */
1583}
1584
1585//_____________________________________________________________________________
1586void AliITSdisplay::SetPickMode()
1587{
1588 fZoomMode = 0;
1589
1590 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1591 fTrigPad->Modified();
1592}
1593
1594//_____________________________________________________________________________
1595void AliITSdisplay::SetZoomMode()
1596{
1597 fZoomMode = 1;
1598
1599 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1600 fTrigPad->Modified();
1601}
1602
1603//_____________________________________________________________________________
1604void AliITSdisplay::SetModule(Int_t layer, Int_t ladder, Int_t detector)
1605{
1606// Set chamber and cathode number
1607 fLayer = layer;
1608 fLadder = ladder;
1609 fDetector = ladder;
1610
1611 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1612 AliITSgeom *gm=ITS->GetITSgeom();
1613 fModule=gm->GetModuleIndex(fLayer,fLadder,fDetector);
1614
1615 if (!fPad) return;
1616 fPad->Clear();
1617 Draw();
1618}
1619
1620//_____________________________________________________________________________
1621void AliITSdisplay::SetModuleNumber(Int_t module)
1622{
1623// Set chamber and cathode number
1624 fModule=module;
1625
1626 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1627 AliITSgeom *gm=ITS->GetITSgeom();
1628 gm->GetModuleId(fModule,fLayer,fLadder,fDetector);
1629
1630 if (!fPad) return;
1631 fPad->Clear();
1632 Draw();
1633}
1634//_____________________________________________________________________________
1635void AliITSdisplay::SetRange(Float_t rrange, Float_t zrange)
1636{
1637// Set view range along R and Z
1638 fRrange = rrange;
1639 fZrange = zrange;
1640
1641 if (!fPad) return;
1642 fPad->Clear();
1643 Draw();
1644}
1645
1646//_____________________________________________________________________________
1647void AliITSdisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1648{
1649// change viewing angles for current event
1650
1651 fPad->cd();
1652 fPhi = phi;
1653 fTheta = theta;
1654 fPsi = psi;
1655 Int_t iret = 0;
1656
1657 TView *view = gPad->GetView();
1658 printf("SetView view %p \n",view);
1659 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1660 Draw();
1661 //else Draw();
1662
1663 gPad->Modified();
1664}
1665
1666//_____________________________________________________________________________
1667void AliITSdisplay::ShowNextEvent(Int_t delta)
1668{
1669// Display (current event_number+delta)
1670// delta = 1 shown next event
1671// delta = -1 show previous event
1672 if (delta) {
1673 gAlice->Clear();
1674 Int_t current_event = gAlice->GetHeader()->GetEvent();
1675 Int_t new_event = current_event + delta;
1676 gAlice->GetEvent(new_event);
1677 fEvent=new_event;
1678 if (!gAlice->TreeD() || !gAlice->TreeD() ) return;
1679 }
1680 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1681 ITS->ClearModules();
1682 ITS->InitModules(-1,fNmodules);
1683 ITS->FillModules(fEvent,0,fNmodules," "," "); //memory problems ?
1684
1685 fPad->cd();
1686 Draw();
1687}
1688
1689//_____________________________________________________________________________
1690
1691void AliITSdisplay::SetEvent(Int_t newevent)
1692{
1693 gAlice->GetEvent(newevent);
1694 fEvent=newevent;
1695 if (!gAlice->TreeD() || !gAlice->TreeD() ) return;
1696 if (!fPad) return;
1697 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
1698 ITS->ClearModules();
1699 ITS->InitModules(-1,fNmodules);
1700 ITS->FillModules(fEvent,0,fNmodules," "," "); //memory problems ?
1701 fPad->cd();
1702 fPad->Clear();
1703 Draw();
1704
1705}
1706//______________________________________________________________________________
1707void AliITSdisplay::UnZoom()
1708{
1709 printf("UnZoom - fZooms %d\n",fZooms);
1710 if (fZooms <= 0) return;
1711 fZooms--;
1712 TPad *pad = (TPad*)gPad->GetPadSave();
1713 printf("UnZoom - pad fPad gPad %p %p %p\n",pad,fPad,gPad);
1714
1715 //pad->cd();
1716
1717 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1718 pad->Modified();
1719}
1720
1721//_____________________________________________________________________________
1722void AliITSdisplay::ResetPoints()
1723{
1724 //
1725 // Reset array of points
1726 //
1727 if (fPoints) {
1728 fPoints->Delete();
1729 delete fPoints;
1730 fPoints = 0;
1731 }
1732}
1733//_____________________________________________________________________________
1734void AliITSdisplay::ResetPhits()
1735{
1736 //
1737 // Reset array of points
1738 //
1739 if (fPhits) {
1740 fPhits->Delete();
1741 delete fPhits;
1742 fPhits = 0;
1743 }
1744}
1745//_____________________________________________________________________________
1746void AliITSdisplay::ResetRpoints()
1747{
1748 //
1749 // Reset array of points
1750 //
1751 if (fRpoints) {
1752 fRpoints->Delete();
1753 delete fRpoints;
1754 fRpoints = 0;
1755 }
1756}
1757//_____________________________________________________________________________
1758void AliITSdisplay::ResetR2points()
1759{
1760 //
1761 // Reset array of points
1762 //
1763 if (fR2points) {
1764 fR2points->Delete();
1765 delete fR2points;
1766 fR2points = 0;
1767 }
1768}
1769//_____________________________________________________________________________
1770void AliITSdisplay::ResetCpoints()
1771{
1772 //
1773 // Reset array of points
1774 //
1775 if (fCpoints) {
1776 fCpoints->Delete();
1777 delete fCpoints;
1778 fCpoints = 0;
1779 }
1780}
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791