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>
31 #include <TClonesArray.h>
33 #include <TPaveText.h>
35 #include <TObjArray.h>
40 #include "AliMUONVDigit.h"
41 #include "AliMpSegmentation.h"
42 #include "AliMpVSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
44 #include "AliMUONMCDataInterface.h"
46 #include "AliMUONTriggerGUIboard.h"
47 #include "AliMUONTriggerGUIdimap.h"
49 #include "AliMUONVDigitStore.h"
52 ClassImp(AliMUONTriggerGUIdimap)
55 //__________________________________________________________________________
56 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
69 gStyle->SetPadLeftMargin(0.05);
70 gStyle->SetPadRightMargin(0.05);
71 gStyle->SetPadTopMargin(0.05);
72 gStyle->SetPadBottomMargin(0.05);
74 gStyle->SetOptDate(0);
75 gStyle->SetOptTitle(0);
76 gStyle->SetOptStat(0);
78 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
79 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
80 fMain->DontCallClose(); // to avoid double deletions.
82 // use hierarchical cleaning
83 fMain->SetCleanup(kDeepCleanup);
85 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
87 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
88 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
90 hframe->AddFrame(closeButton,
91 new TGLayoutHints(kLHintsTop |
96 hframe->Resize(150, closeButton->GetDefaultHeight());
98 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
99 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
100 updateButton->SetToolTipText("Read the digits for the current event");
102 hframe->AddFrame(updateButton,
103 new TGLayoutHints(kLHintsTop |
108 hframe->Resize(150, updateButton->GetDefaultHeight());
110 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
111 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
112 resetButton->SetToolTipText("Redraw unselected boards");
114 hframe->AddFrame(resetButton,
115 new TGLayoutHints(kLHintsTop |
120 hframe->Resize(150, resetButton->GetDefaultHeight());
122 fMain->AddFrame(hframe,
123 new TGLayoutHints(kLHintsBottom |
128 TGTab *tab = new TGTab(fMain, 300, 300);
129 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
131 // Tabs for MT11, MT12, MT21, MT22
132 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
138 TGCompositeFrame *tf = 0;
141 tf = tab->AddTab("MT11");
143 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
144 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
145 cf1->AddFrame(fEc[0], lot);
147 tf->AddFrame(cf1, lot);
148 fEc[0]->GetCanvas()->SetBorderMode(0);
149 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
152 tf = tab->AddTab("MT12");
154 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
155 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
156 cf2->AddFrame(fEc[1], lot);
158 tf->AddFrame(cf2, lot);
159 fEc[1]->GetCanvas()->SetBorderMode(0);
160 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
163 tf = tab->AddTab("MT21");
165 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
166 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
167 cf3->AddFrame(fEc[2], lot);
169 tf->AddFrame(cf3, lot);
170 fEc[2]->GetCanvas()->SetBorderMode(0);
171 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
174 tf = tab->AddTab("MT22");
176 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
177 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
178 cf4->AddFrame(fEc[3], lot);
180 tf->AddFrame(cf4, lot);
181 fEc[3]->GetCanvas()->SetBorderMode(0);
182 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
185 new TGLayoutHints(kLHintsBottom |
191 fMain->MapSubwindows();
194 fMain->CenterOnParent();
196 fMain->SetWindowName("Chambers digit maps");
202 //__________________________________________________________________________
203 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
207 for (Int_t it = 0; it < kNMT; it++) {
208 for (Int_t ib = 0; ib < kNBoards; ib++) {
209 delete fPaveBoard[it][ib];
213 fMain->DeleteWindow();
217 //__________________________________________________________________________
218 void AliMUONTriggerGUIdimap::DrawAllMaps()
222 if (fLoader == 0x0) {
225 if (fMCDataInterface == 0x0) {
236 //__________________________________________________________________________
237 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
239 /// draw the digits map for chamber-
241 TString mapspath = gSystem->Getenv("ALICE_ROOT");
242 mapspath.Append("/MUON/data");
244 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
248 AliRunLoader *runLoader = fLoader->GetRunLoader();
249 gAlice = runLoader->GetAliRun();
250 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
251 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
253 AliMUONVDigitStore *digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
258 Char_t fntxt[256], name[8], cln[2];
259 Int_t detElemId, cathode, ix, iy, charge, color;
260 Int_t side, col, line, nbx;
261 Int_t holdS, holdL, holdC;
262 Float_t xCenter, yCenter, zCenter, xWidth, yWidth, holdXC, holdYC;
263 Float_t xMin, xMax, yMin, yMax;
264 Float_t ptx1, ptx2, pty1, pty2;
265 Float_t xpmin, xpmax, ypmin, ypmax;
266 Float_t xg1, xg2, yg1, yg2, zg1;
268 Float_t frameXmax = 0., frameYmax = 0.;
298 sprintf(fntxt,"%s/guimapp%2d.txt",mapspath.Data(),chamber);
299 FILE *ftxt = fopen(fntxt,"r");
301 for (Int_t ib = 0; ib < kNBoards; ib++) {
303 fscanf(ftxt,"%d %d %d %d %f %f %f %f %f %s \n",
304 &side,&col,&line,&nbx,
305 &xCenter,&yCenter,&xWidth,&yWidth,&zCenter,
308 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
317 xMin = xCenter - xWidth/2;
318 xMax = xCenter + xWidth/2;
319 yMin = yCenter - yWidth/2;
320 yMax = yCenter + yWidth/2;
322 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
323 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
324 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
325 fPaveBoard[chamber-11][ib]->Draw();
327 Float_t lWidth = 12.0;
331 sprintf(cln,"C%1d",holdC);
333 ptx1 = holdXC - lWidth;
334 ptx2 = holdXC + lWidth;
335 pty1 = +1.065*frameYmax - lWidth;
336 pty2 = +1.065*frameYmax + lWidth;
338 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
340 label->SetBorderSize(0);
341 label->SetBit(kCannotPick);
346 sprintf(cln,"C%1d",holdC);
348 ptx1 = holdXC - lWidth;
349 ptx2 = holdXC + lWidth;
350 pty1 = -1.065*frameYmax - lWidth;
351 pty2 = -1.065*frameYmax + lWidth;
353 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
355 label->SetBorderSize(0);
356 label->SetBit(kCannotPick);
359 if (holdS == 0 && holdC == 7) {
361 sprintf(cln,"L%1d",holdL);
363 ptx1 = -1.07*frameXmax - lWidth;
364 ptx2 = -1.07*frameXmax + lWidth;
365 pty1 = holdYC - lWidth;
366 pty2 = holdYC + lWidth;
368 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
370 label->SetBorderSize(0);
371 label->SetBit(kCannotPick);
374 if (holdS == 1 && holdC == 7) {
376 sprintf(cln,"L%1d",holdL);
378 ptx1 = +1.07*frameXmax - lWidth;
379 ptx2 = +1.07*frameXmax + lWidth;
380 pty1 = holdYC - lWidth;
381 pty2 = holdYC + lWidth;
383 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
385 label->SetBorderSize(0);
386 label->SetBit(kCannotPick);
394 // draw digits set from the board GUI
396 AliMUONTriggerGUIboard *board;
397 Int_t imt = chamber -11;
398 Int_t nStripX, nStripY;
400 for (Int_t ib = 0; ib < kNBoards; ib++) {
402 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
404 xCenter = board->GetXCenter(imt);
405 yCenter = board->GetYCenter(imt);
407 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
408 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
410 for (Int_t is = 0; is < nStripX; is++) {
412 if (board->GetXDig(imt,is) == 0) continue;
414 box = board->GetXDigBox(imt,is);
416 xpmin = box->GetX1();
417 xpmax = box->GetX2();
418 ypmin = box->GetY1();
419 ypmax = box->GetY2();
426 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
430 for (Int_t is = 0; is < nStripY; is++) {
432 if (board->GetYDig(imt,is) == 0) continue;
434 box = board->GetYDigBox(imt,is);
436 xpmin = box->GetX1();
437 xpmax = box->GetX2();
438 ypmin = box->GetY1();
439 ypmax = box->GetY2();
446 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
454 TIter next(digitStore->CreateIterator());
457 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) )
459 cathode = mdig->Cathode()+1;
463 detElemId=mdig->DetElemId();
464 charge = (Int_t)mdig->Charge();
465 color = 261+5*(charge-1);
466 if (color > 282) color = 282;
468 if (detElemId/100 != chamber) continue;
470 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
472 AliMpPad mpad = seg2->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
474 // get the pad position and dimensions
475 Float_t xlocal1 = mpad.Position().X();
476 Float_t ylocal1 = mpad.Position().Y();
477 Float_t xlocal2 = mpad.Dimensions().X();
478 Float_t ylocal2 = mpad.Dimensions().Y();
480 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
481 // (no transformation for pad dimensions)
485 // transform in the monitor coordinate system
486 //xpmin = -(xg1+xg2);
487 //xpmax = -(xg1-xg2);
488 //ypmin = -(yg2-yg1);
489 //ypmax = +(yg2+yg1);
496 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
497 boxd->SetBit(kCannotPick);
498 boxd->SetFillStyle(1001);
499 boxd->SetFillColor(2);
509 //__________________________________________________________________________
510 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
512 /// some action when chamber tab is selected...
529 //__________________________________________________________________________
530 void AliMUONTriggerGUIdimap::DoClose()
532 /// close the main frame
539 //__________________________________________________________________________
540 void AliMUONTriggerGUIdimap::DoUpdate()
542 /// update maps for another run/event
544 for (Int_t it = 0; it < kNMT; it++) {
545 for (Int_t ib = 0; ib < kNBoards; ib++) {
546 delete fPaveBoard[it][ib];
555 AliMUONTriggerGUIboard *board;
556 for (Int_t ib = 0; ib < kNBoards; ib++) {
557 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
558 if (board->IsOpen()) SelectBoard(ib);
563 //__________________________________________________________________________
564 void AliMUONTriggerGUIdimap::DoReset()
566 /// draw unselected boards
568 for (Int_t it = 0; it < kNMT; it++) {
570 TCanvas *canvas = fEc[it]->GetCanvas();
573 for (Int_t ib = 0; ib < kNBoards; ib++) {
574 fPaveBoard[it][ib]->SetFillStyle(0);
584 //__________________________________________________________________________
585 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
587 /// highlight on the map the open board
589 for (Int_t it = 0; it < kNMT; it++) {
591 TCanvas *canvas = fEc[it]->GetCanvas();
594 fPaveBoard[it][id]->SetFillStyle(4020);
595 fPaveBoard[it][id]->SetFillColor(7);
604 //__________________________________________________________________________
605 void AliMUONTriggerGUIdimap::CloseWindow()
607 /// called when window is closed via the window manager.
609 fMain->CloseWindow();