1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerGUIdimap
21 /// The digit maps of the four trigger chambers, all boards
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
29 #include <TRootEmbeddedCanvas.h>
32 #include <TPaveText.h>
34 #include <TObjArray.h>
36 #include "AliLoader.h"
37 #include "AliRunLoader.h"
39 #include "AliMUONVDigit.h"
40 #include "AliMpSegmentation.h"
41 #include "AliMpVSegmentation.h"
42 #include "AliMUONGeometryTransformer.h"
43 #include "AliMUONMCDataInterface.h"
45 #include "AliMUONTriggerGUIboard.h"
46 #include "AliMUONTriggerGUIdimap.h"
48 #include "AliMUONDigitStoreV1.h"
53 ClassImp(AliMUONTriggerGUIdimap)
56 //__________________________________________________________________________
57 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
71 gStyle->SetPadLeftMargin(0.05);
72 gStyle->SetPadRightMargin(0.05);
73 gStyle->SetPadTopMargin(0.05);
74 gStyle->SetPadBottomMargin(0.05);
76 gStyle->SetOptDate(0);
77 gStyle->SetOptTitle(0);
78 gStyle->SetOptStat(0);
80 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
81 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
82 fMain->DontCallClose(); // to avoid double deletions.
84 // use hierarchical cleaning
85 fMain->SetCleanup(kDeepCleanup);
87 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
89 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
90 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
92 hframe->AddFrame(closeButton,
93 new TGLayoutHints(kLHintsTop |
98 hframe->Resize(150, closeButton->GetDefaultHeight());
100 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
101 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
102 updateButton->SetToolTipText("Read the digits for the current event");
104 hframe->AddFrame(updateButton,
105 new TGLayoutHints(kLHintsTop |
110 hframe->Resize(150, updateButton->GetDefaultHeight());
112 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
113 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
114 resetButton->SetToolTipText("Redraw unselected boards");
116 hframe->AddFrame(resetButton,
117 new TGLayoutHints(kLHintsTop |
122 hframe->Resize(150, resetButton->GetDefaultHeight());
124 fMain->AddFrame(hframe,
125 new TGLayoutHints(kLHintsBottom |
130 TGTab *tab = new TGTab(fMain, 300, 300);
131 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
133 // Tabs for MT11, MT12, MT21, MT22
134 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
140 TGCompositeFrame *tf = 0;
143 tf = tab->AddTab("MT11");
145 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
146 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
147 cf1->AddFrame(fEc[0], lot);
149 tf->AddFrame(cf1, lot);
150 fEc[0]->GetCanvas()->SetBorderMode(0);
151 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
154 tf = tab->AddTab("MT12");
156 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
157 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
158 cf2->AddFrame(fEc[1], lot);
160 tf->AddFrame(cf2, lot);
161 fEc[1]->GetCanvas()->SetBorderMode(0);
162 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
165 tf = tab->AddTab("MT21");
167 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
168 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
169 cf3->AddFrame(fEc[2], lot);
171 tf->AddFrame(cf3, lot);
172 fEc[2]->GetCanvas()->SetBorderMode(0);
173 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
176 tf = tab->AddTab("MT22");
178 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
179 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
180 cf4->AddFrame(fEc[3], lot);
182 tf->AddFrame(cf4, lot);
183 fEc[3]->GetCanvas()->SetBorderMode(0);
184 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
187 new TGLayoutHints(kLHintsBottom |
193 fMain->MapSubwindows();
196 fMain->CenterOnParent();
198 fMain->SetWindowName("Chambers digit maps");
204 //__________________________________________________________________________
205 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
209 for (Int_t it = 0; it < kNMT; it++) {
210 for (Int_t ib = 0; ib < kNBoards; ib++) {
211 delete fPaveBoard[it][ib];
215 fMain->DeleteWindow();
219 //__________________________________________________________________________
220 void AliMUONTriggerGUIdimap::DrawAllMaps()
224 if (fLoader == 0x0) {
227 if (fMCDataInterface == 0x0) {
238 //__________________________________________________________________________
239 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
241 /// draw the digits map for chamber-
243 Bool_t drawDigits = kTRUE;
244 Bool_t drawDigitsRaw = kTRUE;
245 if (fLoader == 0x0) {
248 if (fRawDigitStore == 0x0) {
249 drawDigitsRaw = kFALSE;
252 AliMUONTriggerGUIboard *board;
254 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
261 Char_t cln[4]; // must be 4 long - room for terminating '\0'
262 Int_t detElemId, cathode, ix, iy, charge, color;
263 Int_t holdS, holdL, holdC;
264 Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
265 Float_t xMin, xMax, yMin, yMax;
266 Float_t ptx1, ptx2, pty1, pty2;
267 Float_t xpmin, xpmax, ypmin, ypmax;
268 Float_t xg1, xg2, yg1, yg2, zg1;
270 Float_t frameXmax = 0., frameYmax = 0.;
300 for (Int_t ib = 0; ib < kNBoards; ib++) {
302 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
304 holdS = board->GetSide();
305 holdC = board->GetCol();
306 holdL = board->GetLine();
308 xCenter = board->GetXCenter(chamber-11);
309 yCenter = board->GetYCenter(chamber-11);
310 xWidth = board->GetXWidth(chamber-11);
311 yWidth = board->GetYWidth(chamber-11);
316 xMin = xCenter - xWidth/2;
317 xMax = xCenter + xWidth/2;
318 yMin = yCenter - yWidth/2;
319 yMax = yCenter + yWidth/2;
321 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
322 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
323 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
324 fPaveBoard[chamber-11][ib]->Draw();
326 Float_t lWidth = 12.0;
330 snprintf(cln,4,"C%1d",holdC);
332 ptx1 = holdXC - lWidth;
333 ptx2 = holdXC + lWidth;
334 pty1 = +1.065*frameYmax - lWidth;
335 pty2 = +1.065*frameYmax + lWidth;
337 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
339 label->SetBorderSize(0);
340 label->SetBit(kCannotPick);
345 snprintf(cln,4,"C%1d",holdC);
347 ptx1 = holdXC - lWidth;
348 ptx2 = holdXC + lWidth;
349 pty1 = -1.065*frameYmax - lWidth;
350 pty2 = -1.065*frameYmax + lWidth;
352 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
354 label->SetBorderSize(0);
355 label->SetBit(kCannotPick);
358 if (holdS == 0 && holdC == 7) {
360 snprintf(cln,4,"L%1d",holdL);
362 ptx1 = -1.07*frameXmax - lWidth;
363 ptx2 = -1.07*frameXmax + lWidth;
364 pty1 = holdYC - lWidth;
365 pty2 = holdYC + lWidth;
367 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
369 label->SetBorderSize(0);
370 label->SetBit(kCannotPick);
373 if (holdS == 1 && holdC == 7) {
375 snprintf(cln,4,"L%1d",holdL);
377 ptx1 = +1.07*frameXmax - lWidth;
378 ptx2 = +1.07*frameXmax + lWidth;
379 pty1 = holdYC - lWidth;
380 pty2 = holdYC + lWidth;
382 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
384 label->SetBorderSize(0);
385 label->SetBit(kCannotPick);
391 // draw digits set from the board GUI
393 Int_t imt = chamber -11;
394 Int_t nStripX, nStripY;
396 for (Int_t ib = 0; ib < kNBoards; ib++) {
398 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
400 xCenter = board->GetXCenter(imt);
401 yCenter = board->GetYCenter(imt);
403 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
404 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
406 for (Int_t is = 0; is < nStripX; is++) {
408 if (board->GetXDig(imt,is) == 0) continue;
410 box = board->GetXDigBox(imt,is);
412 xpmin = box->GetX1();
413 xpmax = box->GetX2();
414 ypmin = box->GetY1();
415 ypmax = box->GetY2();
422 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
426 for (Int_t is = 0; is < nStripY; is++) {
428 if (board->GetYDig(imt,is) == 0) continue;
430 box = board->GetYDigBox(imt,is);
432 xpmin = box->GetX1();
433 xpmax = box->GetX2();
434 ypmin = box->GetY1();
435 ypmax = box->GetY2();
442 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
448 // draw the digits from galice
450 if (drawDigits || drawDigitsRaw) {
452 AliMUONGeometryTransformer transformer;
453 transformer.LoadGeometryData("transform.dat");
455 AliMUONVDigitStore *digitStore = 0x0;
458 AliRunLoader *runLoader = fLoader->GetRunLoader();
459 digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
462 digitStore = fRawDigitStore;
465 TIter next(digitStore->CreateIterator());
468 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
470 cathode = mdig->Cathode()+1;
474 detElemId=mdig->DetElemId();
475 charge = (Int_t)mdig->Charge();
476 color = 261+5*(charge-1);
477 if (color > 282) color = 282;
479 if (detElemId/100 != chamber) continue;
481 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
483 AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
485 // get the pad position and dimensions
486 Float_t xlocal1 = mpad.GetPositionX();
487 Float_t ylocal1 = mpad.GetPositionY();
488 Float_t xlocal2 = mpad.GetDimensionX();
489 Float_t ylocal2 = mpad.GetDimensionY();
491 transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
492 // (no transformation for pad dimensions)
496 // transform in the monitor coordinate system
503 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
504 boxd->SetBit(kCannotPick);
505 boxd->SetFillStyle(1001);
506 boxd->SetFillColor(2);
518 //__________________________________________________________________________
519 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
521 /// some action when chamber tab is selected...
538 //__________________________________________________________________________
539 void AliMUONTriggerGUIdimap::DoClose()
541 /// close the main frame
548 //__________________________________________________________________________
549 void AliMUONTriggerGUIdimap::DoUpdate()
551 /// update maps for another run/event
553 for (Int_t it = 0; it < kNMT; it++) {
554 for (Int_t ib = 0; ib < kNBoards; ib++) {
555 delete fPaveBoard[it][ib];
564 AliMUONTriggerGUIboard *board;
565 for (Int_t ib = 0; ib < kNBoards; ib++) {
566 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
567 if (board->IsOpen()) SelectBoard(ib);
572 //__________________________________________________________________________
573 void AliMUONTriggerGUIdimap::DoReset()
575 /// draw unselected boards
577 for (Int_t it = 0; it < kNMT; it++) {
579 TCanvas *canvas = fEc[it]->GetCanvas();
582 for (Int_t ib = 0; ib < kNBoards; ib++) {
583 fPaveBoard[it][ib]->SetFillStyle(0);
593 //__________________________________________________________________________
594 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
596 /// highlight on the map the open board
598 for (Int_t it = 0; it < kNMT; it++) {
600 TCanvas *canvas = fEc[it]->GetCanvas();
603 fPaveBoard[it][id]->SetFillStyle(4020);
604 fPaveBoard[it][id]->SetFillColor(7);
613 //__________________________________________________________________________
614 void AliMUONTriggerGUIdimap::CloseWindow()
616 /// called when window is closed via the window manager.
618 fMain->CloseWindow();