]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerGUIdimap.cxx
The Root libraries should not be addedt to ELIBS
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGUIdimap.cxx
CommitLineData
905654c2 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
bae1aa70 16// $Id$
17
3d1463c8 18//-----------------------------------------------------------------------------
bae1aa70 19/// \class AliMUONTriggerGUIdimap
20///
21/// The digit maps of the four trigger chambers, all boards
22///
23/// \author Bogdan Vulpescu, LPC Clermont-Ferrand
3d1463c8 24//-----------------------------------------------------------------------------
905654c2 25
26#include <TCanvas.h>
905654c2 27#include <TGButton.h>
28#include <TGTab.h>
29#include <TRootEmbeddedCanvas.h>
30#include <TBox.h>
905654c2 31#include <TPave.h>
32#include <TPaveText.h>
33#include <TStyle.h>
34#include <TObjArray.h>
35
8b067dfe 36#include "AliRunLoader.h"
905654c2 37
bae1aa70 38#include "AliMUONVDigit.h"
905654c2 39#include "AliMpSegmentation.h"
40#include "AliMpVSegmentation.h"
41#include "AliMUONGeometryTransformer.h"
f9eb4448 42#include "AliMUONMCDataInterface.h"
905654c2 43
44#include "AliMUONTriggerGUIboard.h"
45#include "AliMUONTriggerGUIdimap.h"
46
8b067dfe 47#include "AliMUONDigitStoreV1.h"
bae1aa70 48
905654c2 49/// \cond CLASSIMP
50ClassImp(AliMUONTriggerGUIdimap)
51/// \endcond
52
53//__________________________________________________________________________
f9eb4448 54AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
bae1aa70 55 : TGFrame(0),
905654c2 56 fMain(0),
57 fLoader(0),
f9eb4448 58 fMCDataInterface(0),
8b067dfe 59 fRawDigitStore(0),
905654c2 60 fBoards(0),
61 fIsOn(0)
62{
63 /// frame constructor
64
905654c2 65 fIsOn = kTRUE;
66 fBoards = boards;
67
905654c2 68 gStyle->SetPadLeftMargin(0.05);
69 gStyle->SetPadRightMargin(0.05);
70 gStyle->SetPadTopMargin(0.05);
71 gStyle->SetPadBottomMargin(0.05);
72
73 gStyle->SetOptDate(0);
74 gStyle->SetOptTitle(0);
75 gStyle->SetOptStat(0);
76
77 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
78 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
79 fMain->DontCallClose(); // to avoid double deletions.
80
81 // use hierarchical cleaning
82 fMain->SetCleanup(kDeepCleanup);
83
84 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
85
86 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
87 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
88
89 hframe->AddFrame(closeButton,
90 new TGLayoutHints(kLHintsTop |
91 kLHintsLeft,
92 2, 2, 2, 2)
93 );
94
95 hframe->Resize(150, closeButton->GetDefaultHeight());
96
97 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
98 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
99 updateButton->SetToolTipText("Read the digits for the current event");
100
101 hframe->AddFrame(updateButton,
102 new TGLayoutHints(kLHintsTop |
103 kLHintsLeft,
104 2, 2, 2, 2)
105 );
106
107 hframe->Resize(150, updateButton->GetDefaultHeight());
108 /*
109 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
110 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
111 resetButton->SetToolTipText("Redraw unselected boards");
112
113 hframe->AddFrame(resetButton,
114 new TGLayoutHints(kLHintsTop |
115 kLHintsLeft,
116 2, 2, 2, 2)
117 );
118
119 hframe->Resize(150, resetButton->GetDefaultHeight());
120 */
121 fMain->AddFrame(hframe,
122 new TGLayoutHints(kLHintsBottom |
123 kLHintsLeft,
124 2, 2, 2, 2)
125 );
126
127 TGTab *tab = new TGTab(fMain, 300, 300);
128 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
129
130 // Tabs for MT11, MT12, MT21, MT22
131 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
132 kLHintsLeft |
133 kLHintsExpandX |
134 kLHintsExpandY,
135 5, 5, 5, 5);
136
137 TGCompositeFrame *tf = 0;
138
139 // Tab for MT11
140 tf = tab->AddTab("MT11");
141
142 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
143 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
144 cf1->AddFrame(fEc[0], lot);
145
146 tf->AddFrame(cf1, lot);
147 fEc[0]->GetCanvas()->SetBorderMode(0);
148 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
149
150 // Tab for MT12
151 tf = tab->AddTab("MT12");
152
153 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
154 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
155 cf2->AddFrame(fEc[1], lot);
156
157 tf->AddFrame(cf2, lot);
158 fEc[1]->GetCanvas()->SetBorderMode(0);
159 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
160
161 // Tab for MT21
162 tf = tab->AddTab("MT21");
163
164 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
165 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
166 cf3->AddFrame(fEc[2], lot);
167
168 tf->AddFrame(cf3, lot);
169 fEc[2]->GetCanvas()->SetBorderMode(0);
170 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
171
172 // Tab for MT22
173 tf = tab->AddTab("MT22");
174
175 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
176 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
177 cf4->AddFrame(fEc[3], lot);
178
179 tf->AddFrame(cf4, lot);
180 fEc[3]->GetCanvas()->SetBorderMode(0);
181 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
182
183 fMain->AddFrame(tab,
184 new TGLayoutHints(kLHintsBottom |
185 kLHintsExpandX |
186 kLHintsExpandY,
187 2, 2, 2, 2)
188 );
189
190 fMain->MapSubwindows();
191 fMain->Resize();
192
193 fMain->CenterOnParent();
194
195 fMain->SetWindowName("Chambers digit maps");
196
197 fMain->MapWindow();
198
905654c2 199}
200
201//__________________________________________________________________________
202AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
203{
204 /// destructor
205
206 for (Int_t it = 0; it < kNMT; it++) {
207 for (Int_t ib = 0; ib < kNBoards; ib++) {
208 delete fPaveBoard[it][ib];
209 }
210 }
211
905654c2 212 fMain->DeleteWindow();
213
214}
215
f9eb4448 216//__________________________________________________________________________
217void AliMUONTriggerGUIdimap::DrawAllMaps()
218{
219 /// draw maps
220
221 if (fLoader == 0x0) {
8b067dfe 222 //return;
f9eb4448 223 }
224 if (fMCDataInterface == 0x0) {
8b067dfe 225 //return;
f9eb4448 226 }
227
228 DrawMaps(11);
229 DrawMaps(12);
230 DrawMaps(13);
231 DrawMaps(14);
232
233}
234
905654c2 235//__________________________________________________________________________
236void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
237{
238 /// draw the digits map for chamber-
239
8b067dfe 240 Bool_t drawDigits = kTRUE;
241 Bool_t drawDigitsRaw = kTRUE;
242 if (fLoader == 0x0) {
243 drawDigits = kFALSE;
244 }
245 if (fRawDigitStore == 0x0) {
246 drawDigitsRaw = kFALSE;
247 }
248
249 AliMUONTriggerGUIboard *board;
905654c2 250
251 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
252 canvas->cd();
253 canvas->Clear();
254
905654c2 255 TPaveText *label;
256 TBox *boxd;
257
8b067dfe 258 Char_t cln[2];
905654c2 259 Int_t detElemId, cathode, ix, iy, charge, color;
905654c2 260 Int_t holdS, holdL, holdC;
8b067dfe 261 Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
905654c2 262 Float_t xMin, xMax, yMin, yMax;
263 Float_t ptx1, ptx2, pty1, pty2;
264 Float_t xpmin, xpmax, ypmin, ypmax;
265 Float_t xg1, xg2, yg1, yg2, zg1;
266
267 Float_t frameXmax = 0., frameYmax = 0.;
268
269 switch(chamber) {
270 case 11:
271 frameXmax = 257.0;
272 frameYmax = 306.6;
273 break;
274 case 12:
275 frameXmax = 259.7;
276 frameYmax = 309.9;
277 break;
278 case 13:
279 frameXmax = 273.0;
280 frameYmax = 325.7;
281 break;
282 case 14:
283 frameXmax = 275.7;
284 frameYmax = 329.0;
285 break;
286 }
287
288 canvas->Range(
289 -(1.15*frameXmax),
290 -(1.15*frameYmax),
291 +(1.15*frameXmax),
292 +(1.15*frameYmax)
293 );
294
295 // draw the boards
296
905654c2 297 for (Int_t ib = 0; ib < kNBoards; ib++) {
298
8b067dfe 299 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
905654c2 300
8b067dfe 301 holdS = board->GetSide();
302 holdC = board->GetCol();
303 holdL = board->GetLine();
905654c2 304
8b067dfe 305 xCenter = board->GetXCenter(chamber-11);
306 yCenter = board->GetYCenter(chamber-11);
307 xWidth = board->GetXWidth(chamber-11);
308 yWidth = board->GetYWidth(chamber-11);
905654c2 309
310 holdXC = xCenter;
311 holdYC = yCenter;
312
313 xMin = xCenter - xWidth/2;
314 xMax = xCenter + xWidth/2;
315 yMin = yCenter - yWidth/2;
316 yMax = yCenter + yWidth/2;
317
318 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
319 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
320 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
321 fPaveBoard[chamber-11][ib]->Draw();
322
323 Float_t lWidth = 12.0;
324
325 if (holdL == 9) {
326
327 sprintf(cln,"C%1d",holdC);
328
329 ptx1 = holdXC - lWidth;
330 ptx2 = holdXC + lWidth;
331 pty1 = +1.065*frameYmax - lWidth;
332 pty2 = +1.065*frameYmax + lWidth;
333
334 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
335 label->AddText(cln);
336 label->SetBorderSize(0);
337 label->SetBit(kCannotPick);
338 label->Draw();
339 }
340 if (holdL == 1) {
341
342 sprintf(cln,"C%1d",holdC);
343
344 ptx1 = holdXC - lWidth;
345 ptx2 = holdXC + lWidth;
346 pty1 = -1.065*frameYmax - lWidth;
347 pty2 = -1.065*frameYmax + lWidth;
348
349 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
350 label->AddText(cln);
351 label->SetBorderSize(0);
352 label->SetBit(kCannotPick);
353 label->Draw();
354 }
355 if (holdS == 0 && holdC == 7) {
356
357 sprintf(cln,"L%1d",holdL);
358
359 ptx1 = -1.07*frameXmax - lWidth;
360 ptx2 = -1.07*frameXmax + lWidth;
361 pty1 = holdYC - lWidth;
362 pty2 = holdYC + lWidth;
363
364 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
365 label->AddText(cln);
366 label->SetBorderSize(0);
367 label->SetBit(kCannotPick);
368 label->Draw();
369 }
370 if (holdS == 1 && holdC == 7) {
371
372 sprintf(cln,"L%1d",holdL);
373
374 ptx1 = +1.07*frameXmax - lWidth;
375 ptx2 = +1.07*frameXmax + lWidth;
376 pty1 = holdYC - lWidth;
377 pty2 = holdYC + lWidth;
378
379 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
380 label->AddText(cln);
381 label->SetBorderSize(0);
382 label->SetBit(kCannotPick);
383 label->Draw();
384 }
385
386 }
387
905654c2 388 // draw digits set from the board GUI
389
905654c2 390 Int_t imt = chamber -11;
391 Int_t nStripX, nStripY;
392 TBox *box;
393 for (Int_t ib = 0; ib < kNBoards; ib++) {
394
395 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
396
397 xCenter = board->GetXCenter(imt);
398 yCenter = board->GetYCenter(imt);
399
400 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
401 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
402
403 for (Int_t is = 0; is < nStripX; is++) {
404
405 if (board->GetXDig(imt,is) == 0) continue;
406
407 box = board->GetXDigBox(imt,is);
408
409 xpmin = box->GetX1();
410 xpmax = box->GetX2();
411 ypmin = box->GetY1();
412 ypmax = box->GetY2();
413
414 xpmin += xCenter;
415 xpmax += xCenter;
416 ypmin += yCenter;
417 ypmax += yCenter;
418
419 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
420
421 }
422
423 for (Int_t is = 0; is < nStripY; is++) {
424
425 if (board->GetYDig(imt,is) == 0) continue;
426
427 box = board->GetYDigBox(imt,is);
428
429 xpmin = box->GetX1();
430 xpmax = box->GetX2();
431 ypmin = box->GetY1();
432 ypmax = box->GetY2();
433
434 xpmin += xCenter;
435 xpmax += xCenter;
436 ypmin += yCenter;
437 ypmax += yCenter;
438
439 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
440
441 }
442
443 }
444
8b067dfe 445 // draw the digits from galice
905654c2 446
8b067dfe 447 if (drawDigits || drawDigitsRaw) {
f9eb4448 448
8b067dfe 449 AliMUONGeometryTransformer transformer;
450 transformer.LoadGeometryData("transform.dat");
905654c2 451
8b067dfe 452 AliMUONVDigitStore *digitStore = 0x0;
905654c2 453
8b067dfe 454 if (drawDigits) {
455 AliRunLoader *runLoader = fLoader->GetRunLoader();
456 digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
457 }
458 if (drawDigitsRaw) {
e1ac4804 459 digitStore = fRawDigitStore;
8b067dfe 460 }
905654c2 461
8b067dfe 462 TIter next(digitStore->CreateIterator());
463 AliMUONVDigit* mdig;
905654c2 464
8b067dfe 465 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
466
467 cathode = mdig->Cathode()+1;
468
469 ix=mdig->PadX();
470 iy=mdig->PadY();
471 detElemId=mdig->DetElemId();
472 charge = (Int_t)mdig->Charge();
473 color = 261+5*(charge-1);
474 if (color > 282) color = 282;
475
476 if (detElemId/100 != chamber) continue;
477
478 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
479
168e9c4d 480 AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
8b067dfe 481
482 // get the pad position and dimensions
6e97fbb8 483 Float_t xlocal1 = mpad.GetPositionX();
484 Float_t ylocal1 = mpad.GetPositionY();
485 Float_t xlocal2 = mpad.GetDimensionX();
486 Float_t ylocal2 = mpad.GetDimensionY();
8b067dfe 487
488 transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
489 // (no transformation for pad dimensions)
490 xg2 = xlocal2;
491 yg2 = ylocal2;
492
493 // transform in the monitor coordinate system
494 // ALICE SC
495 xpmin = +(xg1-xg2);
496 xpmax = +(xg1+xg2);
497 ypmin = -(yg2-yg1);
498 ypmax = +(yg2+yg1);
499
500 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
501 boxd->SetBit(kCannotPick);
502 boxd->SetFillStyle(1001);
503 boxd->SetFillColor(2);
504 boxd->Draw();
505
506 } // end digits loop
507
508 } // end draw digits
509
905654c2 510 canvas->Modified();
511 canvas->Update();
512
513}
514
515//__________________________________________________________________________
516void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
517{
518 /// some action when chamber tab is selected...
519
520 switch (id) {
521 case 0:
522 break;
523 case 1:
524 break;
525 case 2:
526 break;
527 case 3:
528 break;
529 default:
530 break;
531 }
532
533}
534
535//__________________________________________________________________________
536void AliMUONTriggerGUIdimap::DoClose()
537{
538 /// close the main frame
539
540 fIsOn = kFALSE;
541 CloseWindow();
542
543}
544
545//__________________________________________________________________________
546void AliMUONTriggerGUIdimap::DoUpdate()
547{
548 /// update maps for another run/event
549
905654c2 550 for (Int_t it = 0; it < kNMT; it++) {
551 for (Int_t ib = 0; ib < kNBoards; ib++) {
552 delete fPaveBoard[it][ib];
553 }
554 }
555
556 DrawMaps(11);
557 DrawMaps(12);
558 DrawMaps(13);
559 DrawMaps(14);
560
561 AliMUONTriggerGUIboard *board;
562 for (Int_t ib = 0; ib < kNBoards; ib++) {
563 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
564 if (board->IsOpen()) SelectBoard(ib);
565 }
566
567}
568
569//__________________________________________________________________________
570void AliMUONTriggerGUIdimap::DoReset()
571{
572 /// draw unselected boards
573
574 for (Int_t it = 0; it < kNMT; it++) {
575
576 TCanvas *canvas = fEc[it]->GetCanvas();
577 canvas->cd();
578
579 for (Int_t ib = 0; ib < kNBoards; ib++) {
580 fPaveBoard[it][ib]->SetFillStyle(0);
581 }
582
583 canvas->Modified();
584 canvas->Update();
585
586 }
587
588}
589
590//__________________________________________________________________________
591void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
592{
593 /// highlight on the map the open board
594
595 for (Int_t it = 0; it < kNMT; it++) {
596
597 TCanvas *canvas = fEc[it]->GetCanvas();
598 canvas->cd();
599
600 fPaveBoard[it][id]->SetFillStyle(4020);
601 fPaveBoard[it][id]->SetFillColor(7);
602
603 canvas->Modified();
604 canvas->Update();
605
606 }
607
608}
609
610//__________________________________________________________________________
611void AliMUONTriggerGUIdimap::CloseWindow()
612{
613 /// called when window is closed via the window manager.
614
615 fMain->CloseWindow();
616
617}
618
619