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 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////
18 // Graphical User Interface utility class for the MUON trigger //
19 // - digits maps of the trigger chambers //
21 //////////////////////////////////////////////////////////////////////////
27 #include <TRootEmbeddedCanvas.h>
29 #include <TClonesArray.h>
31 #include <TPaveText.h>
33 #include <TObjArray.h>
38 #include "AliMUONDigit.h"
39 #include "AliMpSegmentation.h"
40 #include "AliMpVSegmentation.h"
41 #include "AliMUONGeometryTransformer.h"
42 #include "AliMUONData.h"
44 #include "AliMUONTriggerGUIboard.h"
45 #include "AliMUONTriggerGUIdimap.h"
48 ClassImp(AliMUONTriggerGUIdimap)
51 //__________________________________________________________________________
52 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(AliLoader *loader, TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
67 fMUONData = new AliMUONData(loader,"MUON","MUON");
68 fMUONData->SetTreeAddress("D");
70 gStyle->SetPadLeftMargin(0.05);
71 gStyle->SetPadRightMargin(0.05);
72 gStyle->SetPadTopMargin(0.05);
73 gStyle->SetPadBottomMargin(0.05);
75 gStyle->SetOptDate(0);
76 gStyle->SetOptTitle(0);
77 gStyle->SetOptStat(0);
79 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
80 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
81 fMain->DontCallClose(); // to avoid double deletions.
83 // use hierarchical cleaning
84 fMain->SetCleanup(kDeepCleanup);
86 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
88 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
89 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
91 hframe->AddFrame(closeButton,
92 new TGLayoutHints(kLHintsTop |
97 hframe->Resize(150, closeButton->GetDefaultHeight());
99 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
100 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
101 updateButton->SetToolTipText("Read the digits for the current event");
103 hframe->AddFrame(updateButton,
104 new TGLayoutHints(kLHintsTop |
109 hframe->Resize(150, updateButton->GetDefaultHeight());
111 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
112 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
113 resetButton->SetToolTipText("Redraw unselected boards");
115 hframe->AddFrame(resetButton,
116 new TGLayoutHints(kLHintsTop |
121 hframe->Resize(150, resetButton->GetDefaultHeight());
123 fMain->AddFrame(hframe,
124 new TGLayoutHints(kLHintsBottom |
129 TGTab *tab = new TGTab(fMain, 300, 300);
130 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
132 // Tabs for MT11, MT12, MT21, MT22
133 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
139 TGCompositeFrame *tf = 0;
142 tf = tab->AddTab("MT11");
144 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
145 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
146 cf1->AddFrame(fEc[0], lot);
148 tf->AddFrame(cf1, lot);
149 fEc[0]->GetCanvas()->SetBorderMode(0);
150 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
153 tf = tab->AddTab("MT12");
155 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
156 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
157 cf2->AddFrame(fEc[1], lot);
159 tf->AddFrame(cf2, lot);
160 fEc[1]->GetCanvas()->SetBorderMode(0);
161 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
164 tf = tab->AddTab("MT21");
166 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
167 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
168 cf3->AddFrame(fEc[2], lot);
170 tf->AddFrame(cf3, lot);
171 fEc[2]->GetCanvas()->SetBorderMode(0);
172 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
175 tf = tab->AddTab("MT22");
177 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
178 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
179 cf4->AddFrame(fEc[3], lot);
181 tf->AddFrame(cf4, lot);
182 fEc[3]->GetCanvas()->SetBorderMode(0);
183 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
186 new TGLayoutHints(kLHintsBottom |
192 fMain->MapSubwindows();
195 fMain->CenterOnParent();
197 fMain->SetWindowName("Chambers digit maps");
208 //__________________________________________________________________________
209 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
213 for (Int_t it = 0; it < kNMT; it++) {
214 for (Int_t ib = 0; ib < kNBoards; ib++) {
215 delete fPaveBoard[it][ib];
220 fMain->DeleteWindow();
224 //__________________________________________________________________________
225 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(const AliMUONTriggerGUIdimap& dimap)
237 Fatal("AliMUONTriggerGUIdimap","copy constructor not implemented");
241 //__________________________________________________________________________
242 AliMUONTriggerGUIdimap & AliMUONTriggerGUIdimap::operator=(const AliMUONTriggerGUIdimap& dimap)
244 /// asignment operator
247 Fatal("AliMUONTriggerGUIdimap","assignment operator not implemented");
253 //__________________________________________________________________________
254 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
256 /// draw the digits map for chamber-
258 TString mapspath = gSystem->Getenv("ALICE_ROOT");
259 mapspath.Append("/MUON/data");
261 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
268 AliRunLoader *runLoader = fLoader->GetRunLoader();
269 gAlice = runLoader->GetAliRun();
270 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
271 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
273 TClonesArray *muonDigits = fMUONData->Digits(chamber-1);
274 if (muonDigits == 0) { printf("No muonDigits \n"); return; }
275 gAlice->ResetDigits();
276 fMUONData->GetDigits();
277 Int_t nDigits = muonDigits->GetEntriesFast();
282 Char_t fntxt[6], name[8], cln[2];
283 Int_t detElemId, cathode, ix, iy, charge, color;
284 Int_t side, col, line, nbx;
285 Int_t holdS, holdL, holdC;
286 Float_t xCenter, yCenter, zCenter, xWidth, yWidth, holdXC, holdYC;
287 Float_t xMin, xMax, yMin, yMax;
288 Float_t ptx1, ptx2, pty1, pty2;
289 Float_t xpmin, xpmax, ypmin, ypmax;
290 Float_t xg1, xg2, yg1, yg2, zg1;
292 Float_t frameXmax = 0., frameYmax = 0.;
322 sprintf(fntxt,"%s/guimapp%2d.txt",mapspath.Data(),chamber);
323 FILE *ftxt = fopen(fntxt,"r");
325 for (Int_t ib = 0; ib < kNBoards; ib++) {
327 fscanf(ftxt,"%d %d %d %d %f %f %f %f %f %s \n",
328 &side,&col,&line,&nbx,
329 &xCenter,&yCenter,&xWidth,&yWidth,&zCenter,
332 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
341 xMin = xCenter - xWidth/2;
342 xMax = xCenter + xWidth/2;
343 yMin = yCenter - yWidth/2;
344 yMax = yCenter + yWidth/2;
346 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
347 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
348 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
349 fPaveBoard[chamber-11][ib]->Draw();
351 Float_t lWidth = 12.0;
355 sprintf(cln,"C%1d",holdC);
357 ptx1 = holdXC - lWidth;
358 ptx2 = holdXC + lWidth;
359 pty1 = +1.065*frameYmax - lWidth;
360 pty2 = +1.065*frameYmax + lWidth;
362 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
364 label->SetBorderSize(0);
365 label->SetBit(kCannotPick);
370 sprintf(cln,"C%1d",holdC);
372 ptx1 = holdXC - lWidth;
373 ptx2 = holdXC + lWidth;
374 pty1 = -1.065*frameYmax - lWidth;
375 pty2 = -1.065*frameYmax + lWidth;
377 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
379 label->SetBorderSize(0);
380 label->SetBit(kCannotPick);
383 if (holdS == 0 && holdC == 7) {
385 sprintf(cln,"L%1d",holdL);
387 ptx1 = -1.07*frameXmax - lWidth;
388 ptx2 = -1.07*frameXmax + lWidth;
389 pty1 = holdYC - lWidth;
390 pty2 = holdYC + lWidth;
392 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
394 label->SetBorderSize(0);
395 label->SetBit(kCannotPick);
398 if (holdS == 1 && holdC == 7) {
400 sprintf(cln,"L%1d",holdL);
402 ptx1 = +1.07*frameXmax - lWidth;
403 ptx2 = +1.07*frameXmax + lWidth;
404 pty1 = holdYC - lWidth;
405 pty2 = holdYC + lWidth;
407 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
409 label->SetBorderSize(0);
410 label->SetBit(kCannotPick);
418 // draw digits set from the board GUI
420 AliMUONTriggerGUIboard *board;
421 Int_t imt = chamber -11;
422 Int_t nStripX, nStripY;
424 for (Int_t ib = 0; ib < kNBoards; ib++) {
426 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
428 xCenter = board->GetXCenter(imt);
429 yCenter = board->GetYCenter(imt);
431 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
432 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
434 for (Int_t is = 0; is < nStripX; is++) {
436 if (board->GetXDig(imt,is) == 0) continue;
438 box = board->GetXDigBox(imt,is);
440 xpmin = box->GetX1();
441 xpmax = box->GetX2();
442 ypmin = box->GetY1();
443 ypmax = box->GetY2();
450 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
454 for (Int_t is = 0; is < nStripY; is++) {
456 if (board->GetYDig(imt,is) == 0) continue;
458 box = board->GetYDigBox(imt,is);
460 xpmin = box->GetX1();
461 xpmax = box->GetX2();
462 ypmin = box->GetY1();
463 ypmax = box->GetY2();
470 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
478 for (Int_t id = 0; id < nDigits; id++) {
480 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(id);
482 cathode = mdig->Cathode()+1;
486 detElemId=mdig->DetElemId();
487 charge = (Int_t)mdig->Signal();
488 color = 261+5*(charge-1);
489 if (color > 282) color = 282;
491 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
493 mpad = seg2->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
495 // get the pad position and dimensions
496 Float_t xlocal1 = mpad.Position().X();
497 Float_t ylocal1 = mpad.Position().Y();
498 Float_t xlocal2 = mpad.Dimensions().X();
499 Float_t ylocal2 = mpad.Dimensions().Y();
501 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
502 // (no transformation for pad dimensions)
506 // transform in the monitor coordinate system
507 //xpmin = -(xg1+xg2);
508 //xpmax = -(xg1-xg2);
509 //ypmin = -(yg2-yg1);
510 //ypmax = +(yg2+yg1);
517 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
518 boxd->SetBit(kCannotPick);
519 boxd->SetFillStyle(1001);
520 boxd->SetFillColor(2);
530 //__________________________________________________________________________
531 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
533 /// some action when chamber tab is selected...
550 //__________________________________________________________________________
551 void AliMUONTriggerGUIdimap::DoClose()
553 /// close the main frame
560 //__________________________________________________________________________
561 void AliMUONTriggerGUIdimap::DoUpdate()
563 /// update maps for another run/event
565 //fMUONData->SetLoader(fLoader);
566 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
567 fMUONData->SetTreeAddress("D");
569 for (Int_t it = 0; it < kNMT; it++) {
570 for (Int_t ib = 0; ib < kNBoards; ib++) {
571 delete fPaveBoard[it][ib];
580 AliMUONTriggerGUIboard *board;
581 for (Int_t ib = 0; ib < kNBoards; ib++) {
582 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
583 if (board->IsOpen()) SelectBoard(ib);
588 //__________________________________________________________________________
589 void AliMUONTriggerGUIdimap::DoReset()
591 /// draw unselected boards
593 for (Int_t it = 0; it < kNMT; it++) {
595 TCanvas *canvas = fEc[it]->GetCanvas();
598 for (Int_t ib = 0; ib < kNBoards; ib++) {
599 fPaveBoard[it][ib]->SetFillStyle(0);
609 //__________________________________________________________________________
610 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
612 /// highlight on the map the open board
614 for (Int_t it = 0; it < kNMT; it++) {
616 TCanvas *canvas = fEc[it]->GetCanvas();
619 fPaveBoard[it][id]->SetFillStyle(4020);
620 fPaveBoard[it][id]->SetFillColor(7);
629 //__________________________________________________________________________
630 void AliMUONTriggerGUIdimap::CloseWindow()
632 /// called when window is closed via the window manager.
634 fMain->CloseWindow();