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 AliMUONTriggerGUIbdmap
21 /// The gui map of a single board object, strips/digits
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
26 #include <TPolyLine.h>
29 #include <TRootEmbeddedCanvas.h>
31 #include <TPaveText.h>
32 #include <TGTextEdit.h>
35 #include <TObjArray.h>
40 #include "AliMUONVDigit.h"
41 #include "AliMpVSegmentation.h"
42 #include "AliMpSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
44 #include "AliMpDEIterator.h"
45 #include "AliMUONLocalTrigger.h"
46 #include "AliMUONLocalTriggerBoard.h"
47 #include "AliMUONTriggerCrateStore.h"
48 #include "AliMUONMCDataInterface.h"
49 #include "AliMUONVTriggerStore.h"
50 #include "AliMUONVDigitStore.h"
51 #include "AliMpDEManager.h"
53 #include "AliMUONTriggerGUIboard.h"
54 #include "AliMUONTriggerGUIbdmap.h"
57 ClassImp(AliMUONTriggerGUIbdmap)
60 //__________________________________________________________________________
61 AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
84 gStyle->SetPadLeftMargin(0.05);
85 gStyle->SetPadRightMargin(0.05);
86 gStyle->SetPadTopMargin(0.05);
87 gStyle->SetPadBottomMargin(0.05);
89 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
90 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIbdmap", this, "CloseWindow()");
91 fMain->DontCallClose(); // to avoid double deletions.
93 // use hierarchical cleaning
94 fMain->SetCleanup(kDeepCleanup);
96 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
98 // strips/digits canvases
102 TRootEmbeddedCanvas *recanvas[4];
104 for (Int_t i = 0; i < kNMT; i++) {
106 sprintf(ecname,"%1d",i+1);
107 recanvas[i] = new TRootEmbeddedCanvas(ecname,fMain,fCanvasSize,fCanvasSize);
109 fCanvas[i] = recanvas[i]->GetCanvas();
111 fCanvas[i]->SetBorderMode(0);
112 fCanvas[i]->SetBit(kNoContextMenu);
114 fCanvas[i]->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
115 "AliMUONTriggerGUIbdmap",this,
116 "EditStrips(Int_t,Int_t,Int_t,TObject*)");
118 fMain->AddFrame(recanvas[i],
120 new TGTableLayoutHints(2,5,2,6,
121 kLHintsExpandX|kLHintsExpandY |
122 kLHintsShrinkX|kLHintsShrinkY |
123 kLHintsFillX|kLHintsFillY)
125 new TGLayoutHints(kLHintsTop |
132 //TGDimension size = fMain->GetDefaultSize();
133 //fMain->Resize(size);
137 TGCompositeFrame *cf0 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
139 TGCompositeFrame *cf1 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
141 cf1->AddFrame(fXStrips = new TGCheckButton(cf1, "Draw X strips and digits", 1),
142 new TGLayoutHints(kLHintsTop |
147 cf1->Resize(fXStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
149 cf1->AddFrame(fYStrips = new TGCheckButton(cf1, "Draw Y strips and digits", 2),
150 new TGLayoutHints(kLHintsTop |
155 cf1->Resize(fYStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
157 cf1->AddFrame(fEditStrips = new TGCheckButton(cf1, "Set/unset strips", 3),
158 new TGLayoutHints(kLHintsTop |
163 fXStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
164 fYStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
165 fEditStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleEditButton()");
168 new TGLayoutHints(kLHintsTop |
173 TGCompositeFrame *cf2 = new TGCompositeFrame(cf0, 60, 20, kHorizontalFrame | kFixedWidth);
175 TGTextButton *digitsButton = new TGTextButton(cf2, "Digits", 4);
176 digitsButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoDigits()");
178 //cf2->Resize(digitsButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
180 cf2->AddFrame(digitsButton,
181 new TGLayoutHints(kLHintsTop |
187 TGTextButton *dresetButton = new TGTextButton(cf2, "Reset", 5);
188 dresetButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "ResetDigits()");
190 //cf2->Resize(dresetButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
192 cf2->AddFrame(dresetButton,
193 new TGLayoutHints(kLHintsTop |
199 TGTextButton *closeButton = new TGTextButton(cf2, "Close", 6);
200 closeButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoClose()");
202 //cf2->Resize(closeButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
204 cf2->AddFrame(closeButton,
205 new TGLayoutHints(kLHintsTop |
212 new TGLayoutHints(kLHintsTop |
217 // editor window for the local trigger
219 TGCompositeFrame *cf3 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
221 fLocTrigE = new TGTextEdit(cf3, 100, 100, kSunkenFrame | kDoubleBorder);
222 cf3->AddFrame(fLocTrigE,
223 new TGLayoutHints(kLHintsExpandX |
229 new TGLayoutHints(kLHintsTop |
235 new TGLayoutHints(kLHintsTop |
240 fIsEditable = kFALSE;
244 fMain->MapSubwindows();
247 fMain->CenterOnParent();
249 //fMain->MapWindow();
250 //gClient->WaitFor(fMain);
254 //__________________________________________________________________________
255 AliMUONTriggerGUIbdmap::~AliMUONTriggerGUIbdmap()
259 fMain->DeleteWindow();
263 //__________________________________________________________________________
264 void AliMUONTriggerGUIbdmap::Show()
266 /// map the main frame
273 //__________________________________________________________________________
274 void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
276 /// print the local trigger
281 sprintf(buffer,"Local trigger info\n");
282 fLocTrigE->LoadBuffer(buffer);
284 AliRunLoader *runLoader = fLoader->GetRunLoader();
285 gAlice = runLoader->GetAliRun();
287 AliMUONVTriggerStore *triggerStore = fMCDataInterface->TriggerStore(runLoader->GetEventNumber());
289 Int_t circuitNumber = fBoard->GetIdCircuit();
291 UShort_t x2m, x2u, x2d;
293 Int_t loStripX, loStripY, loDev, loCircuit, iStripX, iStripY, loLpt, loHpt;
294 AliMUONLocalTrigger *mlt;
296 TIter next(triggerStore->CreateLocalIterator());
298 while ( ( mlt = static_cast<AliMUONLocalTrigger*>(next()) ) )
300 loCircuit = mlt->LoCircuit();
302 if (loCircuit == circuitNumber) {
304 AliMUONLocalTriggerBoard* ltb = fCrateManager->LocalBoard(loCircuit);
305 x2d = ltb->GetSwitch(0);
306 x2m = ltb->GetSwitch(1);
307 x2u = ltb->GetSwitch(2);
309 loStripX = mlt->LoStripX();
310 loStripY = mlt->LoStripY();
311 loDev = mlt->LoDev();
312 loLpt = mlt->LoLpt();
313 loHpt = mlt->LoHpt();
315 iStripX = loStripX/2;
316 if ((x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) {
317 iStripY = loStripY/2;
322 sprintf(buffer,"Circuit = %03d",loCircuit);
323 txt.LoadBuffer(buffer);
324 fLocTrigE->AddText(&txt);
326 sprintf(buffer,"LoStripX = %2d",loStripX);
327 txt.LoadBuffer(buffer);
328 fLocTrigE->AddText(&txt);
330 sprintf(buffer,"LoStripY = %2d",loStripY);
331 txt.LoadBuffer(buffer);
332 fLocTrigE->AddText(&txt);
334 sprintf(buffer,"LoDev = %2d",loDev);
335 txt.LoadBuffer(buffer);
336 fLocTrigE->AddText(&txt);
338 sprintf(buffer,"--------------------");
339 txt.LoadBuffer(buffer);
340 fLocTrigE->AddText(&txt);
342 sprintf(buffer,"X-strip = %2d ( %2d )",iStripX,(loStripX+loDev+1)/2);
343 txt.LoadBuffer(buffer);
344 fLocTrigE->AddText(&txt);
346 sprintf(buffer,"Y-strip = %2d",iStripY);
347 txt.LoadBuffer(buffer);
348 fLocTrigE->AddText(&txt);
350 sprintf(buffer,"--------------------");
351 txt.LoadBuffer(buffer);
352 fLocTrigE->AddText(&txt);
354 sprintf(buffer,"LoLpt = %2d",loLpt);
355 txt.LoadBuffer(buffer);
356 fLocTrigE->AddText(&txt);
358 sprintf(buffer,"LoHpt = %2d",loHpt);
359 txt.LoadBuffer(buffer);
360 fLocTrigE->AddText(&txt);
370 //__________________________________________________________________________
371 void AliMUONTriggerGUIbdmap::Init()
373 /// initialize the boards in the four MT
375 TString mapspath = gSystem->Getenv("ALICE_ROOT");
376 mapspath.Append("/MUON/data");
378 TString mapName[kNMT];
379 mapName[0] = TString(mapspath.Data());
380 mapName[1] = TString(mapspath.Data());
381 mapName[2] = TString(mapspath.Data());
382 mapName[3] = TString(mapspath.Data());
383 mapName[0].Append("/guimapp11.txt");
384 mapName[1].Append("/guimapp12.txt");
385 mapName[2].Append("/guimapp13.txt");
386 mapName[3].Append("/guimapp14.txt");
388 Int_t side, col, line, nbx;
389 Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
393 for (Int_t i = 0; i < kNMT; i++) {
395 fmap = fopen(mapName[i].Data(),"r");
397 for (Int_t ib = 0; ib < kNBoards; ib++) {
399 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
402 sprintf(name,"LC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
405 sprintf(name,"RC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
408 if (strncmp(name,fBoard->GetBoardName(),7) == 0) {
411 fXCenter[i] = xCenter;
412 fYCenter[i] = yCenter;
424 for (Int_t i = 0; i < kNMT; i++) {
425 xw = 1.20*fXWidth[i];
426 yw = 1.20*fYWidth[i];
427 fCanvas[i]->Range(-xw/2,-yw/2,+xw/2,+yw/2);
428 for (Int_t is = 0; is < kNS; is++) {
430 fXDigPL[i][is] = new TPolyLine(5);
431 fYDigPL[i][is] = new TPolyLine(5);
432 fXDigPL[i][is]->SetBit(kCannotPick);
433 fYDigPL[i][is]->SetBit(kCannotPick);
434 fXDigPL[i][is]->SetLineColor(4);
435 fYDigPL[i][is]->SetLineColor(4);
437 fXDigBox[i][is] = new TBox(0,0,0,0);
438 fYDigBox[i][is] = new TBox(0,0,0,0);
439 fXDigBox[i][is]->SetBit(kCannotPick);
440 fYDigBox[i][is]->SetBit(kCannotPick);
441 fXDigBox[i][is]->SetFillStyle(0);
442 fYDigBox[i][is]->SetFillStyle(0);
443 fXDigBox[i][is]->SetLineColor(4);
444 fYDigBox[i][is]->SetLineColor(4);
458 fNStripX = fBoard->GetXSiy2() - fBoard->GetXSiy1() + 1;
459 fNStripY = fBoard->GetYSix2() - fBoard->GetYSix1() + 1;
463 //__________________________________________________________________________
464 void AliMUONTriggerGUIbdmap::HandleEditButton()
466 /// handle the editable check button
468 if (((fXOn && !fYOn) || (!fXOn && fYOn)) &&
469 (fEditStrips->GetState() == kButtonDown)) {
472 fIsEditable = kFALSE;
477 //__________________________________________________________________________
478 void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *sel)
485 Double_t xf1, yf1, xf2, yf2;
487 Double_t xMin, xMax, yMin, yMax;
488 Float_t xd, yd, fxDim, fyDim, cDim;
491 cDim = (Float_t)fCanvasSize;
493 // the (x,y) event does not really go up to the canvas size...
498 if (event == kButton1Down) {
500 cs = TString(sel->GetName());
505 fCanvas[iMT]->GetRange(xf1,yf1,xf2,yf2);
506 fxDim = (Float_t)xf2;
507 fyDim = (Float_t)yf2;
509 //xd = fxDim*(+2.0*(Float_t)(x)/cDim - 1.0);
510 //yd = fyDim*(-2.0*(Float_t)(y)/cDim + 1.0);
512 xd = +(2.0*fxDim*(Float_t)(x))/cDim - fxDim;
513 yd = -(2.0*fyDim*(Float_t)(y))/cDim + fyDim;
517 for (Int_t ix = 0; ix < fNStripX; ix++) {
519 px = fXDigPL[iMT][ix]->GetX();
520 py = fXDigPL[iMT][ix]->GetY();
526 for (Int_t ip = 0; ip < np; ip++) {
527 xMin = TMath::Min(xMin,px[ip]);
528 xMax = TMath::Max(xMax,px[ip]);
529 yMin = TMath::Min(yMin,py[ip]);
530 yMax = TMath::Max(yMax,py[ip]);
533 if (yd > (Float_t)yMin && yd < (Float_t)yMax) {
535 if (fXDigBox[iMT][ix]->GetFillStyle() == 0) {
537 fXDigBox[iMT][ix]->SetFillStyle(1001);
538 fXDigBox[iMT][ix]->SetFillColor(2);
540 sprintf(cln,"%2d",ix);
542 fXLabelL[iMT][ix]->Clear();
543 fXLabelL[iMT][ix]->AddText(cln);
544 fXLabelL[iMT][ix]->Draw();
546 fXLabelR[iMT][ix]->Clear();
547 fXLabelR[iMT][ix]->AddText(cln);
548 fXLabelR[iMT][ix]->Draw();
550 fXDigBox[iMT][ix]->SetX1(xMin);
551 fXDigBox[iMT][ix]->SetY1(yMin);
552 fXDigBox[iMT][ix]->SetX2(xMax);
553 fXDigBox[iMT][ix]->SetY2(yMax);
555 fXDigBox[iMT][ix]->Draw();
557 } else if (fXDigBox[iMT][ix]->GetFillStyle() == 1001) {
559 fXDigBox[iMT][ix]->SetFillStyle(0);
561 fXLabelL[iMT][ix]->Clear();
562 fXLabelL[iMT][ix]->Draw();
564 fXLabelR[iMT][ix]->Clear();
565 fXLabelR[iMT][ix]->Draw();
567 fXDigBox[iMT][ix]->SetX1(-fBoard->GetXCenter(iMT));
568 fXDigBox[iMT][ix]->SetY1(-fBoard->GetYCenter(iMT));
569 fXDigBox[iMT][ix]->SetX2(-fBoard->GetXCenter(iMT));
570 fXDigBox[iMT][ix]->SetY2(-fBoard->GetYCenter(iMT));
572 fXDigBox[iMT][ix]->Draw();
576 if (!fXDigBox[iMT][ix]->TestBit(kObjInCanvas))
577 fXDigBox[iMT][ix]->Draw();
579 fCanvas[iMT]->Modified();
580 fCanvas[iMT]->Update();
591 for (Int_t iy = 0; iy < fNStripY; iy++) {
593 px = fYDigPL[iMT][iy]->GetX();
594 py = fYDigPL[iMT][iy]->GetY();
600 for (Int_t ip = 0; ip < np; ip++) {
601 xMin = TMath::Min(xMin,px[ip]);
602 xMax = TMath::Max(xMax,px[ip]);
603 yMin = TMath::Min(yMin,py[ip]);
604 yMax = TMath::Max(yMax,py[ip]);
607 if (xd > (Float_t)xMin && xd < (Float_t)xMax) {
609 if (fYDigBox[iMT][iy]->GetFillStyle() == 0) {
611 fYDigBox[iMT][iy]->SetFillStyle(1001);
612 fYDigBox[iMT][iy]->SetFillColor(2);
614 sprintf(cln,"%2d",iy);
616 fYLabelL[iMT][iy]->Clear();
617 fYLabelL[iMT][iy]->AddText(cln);
618 fYLabelL[iMT][iy]->Draw();
620 fYLabelR[iMT][iy]->Clear();
621 fYLabelR[iMT][iy]->AddText(cln);
622 fYLabelR[iMT][iy]->Draw();
624 fYDigBox[iMT][iy]->SetX1(xMin);
625 fYDigBox[iMT][iy]->SetY1(yMin);
626 fYDigBox[iMT][iy]->SetX2(xMax);
627 fYDigBox[iMT][iy]->SetY2(yMax);
629 //fYDigBox[iMT][iy]->Draw();
631 } else if (fYDigBox[iMT][iy]->GetFillStyle() == 1001) {
633 fYDigBox[iMT][iy]->SetFillStyle(0);
635 fYLabelL[iMT][iy]->Clear();
636 fYLabelL[iMT][iy]->Draw();
638 fYLabelR[iMT][iy]->Clear();
639 fYLabelR[iMT][iy]->Draw();
641 fYDigBox[iMT][iy]->SetX1(-fBoard->GetXCenter(iMT));
642 fYDigBox[iMT][iy]->SetY1(-fBoard->GetYCenter(iMT));
643 fYDigBox[iMT][iy]->SetX2(-fBoard->GetXCenter(iMT));
644 fYDigBox[iMT][iy]->SetY2(-fBoard->GetYCenter(iMT));
646 //fYDigBox[iMT][iy]->Draw();
650 if (!fYDigBox[iMT][iy]->TestBit(kObjInCanvas))
651 fYDigBox[iMT][iy]->Draw();
653 fCanvas[iMT]->Modified();
654 fCanvas[iMT]->Update();
663 } // end button event
669 //__________________________________________________________________________
670 void AliMUONTriggerGUIbdmap::DoDigits()
672 /// set the board digits from GUI input (set/unset)
675 Int_t number = fBoard->GetNumber();
677 pos = fBoard->GetPosition();
678 over = fBoard->GetYOver();
679 AliMUONTriggerGUIboard *board;
681 for (Int_t imt = 0; imt < kNMT; imt++) {
683 for (Int_t ix = 0; ix < fNStripX; ix++) {
684 if (fXDigBox[imt][ix]->GetFillStyle() == 0) {
687 if (fXDigBox[imt][ix]->GetFillStyle() == 1001) {
690 fBoard->SetDigitX(imt,ix,amp);
693 for (Int_t iy = 0; iy < fNStripY; iy++) {
694 if (fYDigBox[imt][iy]->GetFillStyle() == 0) {
697 if (fYDigBox[imt][iy]->GetFillStyle() == 1001) {
700 fBoard->SetDigitY(imt,iy,amp);
703 for (Int_t io = 1; io <= over; io++) {
704 if (io == pos) continue;
705 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
706 board->SetDigitY(imt,iy,amp);
715 //__________________________________________________________________________
716 void AliMUONTriggerGUIbdmap::ResetDigits()
718 /// set the board digits from GUI input (set/unset)
721 Int_t number = fBoard->GetNumber();
722 AliMUONTriggerGUIboard *board;
724 pos = fBoard->GetPosition();
725 over = fBoard->GetYOver();
727 for (Int_t imt = 0; imt < kNMT; imt++) {
728 for (Int_t ix = 0; ix < fNStripX; ix++) {
729 fXDigBox[imt][ix]->SetFillStyle(0);
730 fXDigBox[imt][ix]->SetX1(-fBoard->GetXCenter(imt));
731 fXDigBox[imt][ix]->SetY1(-fBoard->GetYCenter(imt));
732 fXDigBox[imt][ix]->SetX2(-fBoard->GetXCenter(imt));
733 fXDigBox[imt][ix]->SetY2(-fBoard->GetYCenter(imt));
735 fBoard->SetDigitX(imt,ix,amp);
737 for (Int_t iy = 0; iy < fNStripY; iy++) {
738 fYDigBox[imt][iy]->SetFillStyle(0);
739 fYDigBox[imt][iy]->SetX1(-fBoard->GetXCenter(imt));
740 fYDigBox[imt][iy]->SetY1(-fBoard->GetYCenter(imt));
741 fYDigBox[imt][iy]->SetX2(-fBoard->GetXCenter(imt));
742 fYDigBox[imt][iy]->SetY2(-fBoard->GetYCenter(imt));
744 fBoard->SetDigitY(imt,iy,amp);
747 for (Int_t io = 1; io <= over; io++) {
748 if (io == pos) continue;
749 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
751 board->SetDigitY(imt,iy,amp);
758 fBoard->ClearXDigits();
759 fBoard->ClearYDigits();
762 for (Int_t io = 1; io <= over; io++) {
763 if (io == pos) continue;
764 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
765 board->ClearYDigits();
768 fXStrips->SetState(kButtonUp);
769 fYStrips->SetState(kButtonUp);
770 fEditStrips->SetState(kButtonUp);
771 fIsEditable = kFALSE;
779 //__________________________________________________________________________
780 void AliMUONTriggerGUIbdmap::HandleButtons(Int_t id)
782 /// handle the check buttons
785 TGButton *btn = (TGButton *) gTQSender;
786 id = btn->WidgetId();
790 if(fXStrips->GetState() == kButtonDown &&
791 fYStrips->GetState() == kButtonDown ) {
794 DrawStrips(kTRUE,kTRUE);
795 DrawDigits(kTRUE,kTRUE);
802 if(fXStrips->GetState() == kButtonDown &&
803 fYStrips->GetState() == kButtonUp ) {
806 DrawStrips(kTRUE,kFALSE);
807 DrawDigits(kTRUE,kFALSE);
814 if(fXStrips->GetState() == kButtonUp &&
815 fYStrips->GetState() == kButtonDown ) {
818 DrawStrips(kFALSE,kTRUE);
819 DrawDigits(kFALSE,kTRUE);
826 if(fXStrips->GetState() == kButtonUp &&
827 fYStrips->GetState() == kButtonUp ) {
839 //__________________________________________________________________________
840 void AliMUONTriggerGUIbdmap::DrawClear()
842 /// draw the frame of the board image in the canvas
844 for (Int_t i = 0; i < kNMT; i++) {
849 fCanvas[i]->Modified();
850 fCanvas[i]->Update();
856 //__________________________________________________________________________
857 void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
859 /// draw the digits in "x" or/and "y"
861 AliRunLoader *runLoader = fLoader->GetRunLoader();
862 gAlice = runLoader->GetAliRun();
863 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
864 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
866 AliMUONTriggerGUIboard *board;
867 Int_t over, pos, number;
868 const AliMpVSegmentation* seg;
870 Int_t cathode, detElemId, ix, iy, charge;
871 Int_t chamber, np = 5;
873 Float_t xpmin, xpmax, ypmin, ypmax;
874 Float_t xg1, xg2, yg1, yg2, zg1;
875 Float_t xdw, ydw, xcw, ycw;
876 Double_t xc1, xc2, yc1, yc2;
879 Double_t xMin, xMax, yMin, yMax;
882 number = fBoard->GetNumber();
883 pos = fBoard->GetPosition();
884 over = fBoard->GetYOver();
886 AliMUONVDigitStore *digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
888 for (Int_t i = 0; i < kNMT; i++) {
892 fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
893 xcw = (Float_t)(0.5*(xc2-xc1));
894 ycw = (Float_t)(0.5*(yc2-yc1));
898 AliMpIntPair deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
899 TIter next(digitStore->CreateIterator(deRange.GetFirst(),deRange.GetSecond()));
902 while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
904 cathode = mdig->Cathode()+1;
908 detElemId = mdig->DetElemId();
909 charge = (Int_t)mdig->Charge();
911 Bool_t triggerBgn = kFALSE;
912 Int_t schg = (Int_t)(charge + 0.5);
913 // APPLY CONDITION ON SOFT BACKGROUND
914 Int_t tchg = schg - (Int_t(schg/10))*10;
915 if (schg<=10 || tchg>0) {
921 if (detElemId%100 != fBoard->GetDetElemId()) continue;
923 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode-1));
925 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
927 //if (cathode == 1) printf("GUI x: ix %d iy %d \n",ix,iy);
928 //if (cathode == 2) printf("GUI y: ix %d iy %d \n",ix,iy);
930 // get the pad position and dimensions
931 Float_t xlocal1 = pad.Position().X();
932 Float_t ylocal1 = pad.Position().Y();
933 Float_t xlocal2 = pad.Dimensions().X();
934 Float_t ylocal2 = pad.Dimensions().Y();
936 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
937 // (no transformation for pad dimensions)
941 // transform in the monitor coordinate system
942 //xpmin = -(xg1+xg2);
943 //xpmax = -(xg1-xg2);
944 //ypmin = -(yg2-yg1);
945 //ypmax = +(yg2+yg1);
952 xpmin -= fXCenter[i];
953 xpmax -= fXCenter[i];
954 ypmin -= fYCenter[i];
955 ypmax -= fYCenter[i];
961 if ((xdw > ydw) && bx) {
963 //printf("X strips mdig->Cathode() = %1d \n",mdig->Cathode());
966 iX = fBoard->GetXSix();
967 iY1 = fBoard->GetXSiy1();
968 iY2 = fBoard->GetXSiy2();
969 if (ix == iX && iy >= iY1 && iy <= iY2) {
970 //printf("Digit indices (x-strip) ix = %3d iy = %3d board = %s %d chamber = %2d \n",ix,iy,fBoard->GetBoardName(),fBoard->GetNumber(),chamber);
972 xpmin += 0.01*fXWidth[i];
973 xpmax -= 0.01*fXWidth[i];
977 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
978 boxd->SetFillStyle(1001);
979 if (triggerBgn) boxd->SetFillColor(6);
980 else boxd->SetFillColor(5);
981 boxd->SetBit(kCannotPick);
984 fXDigBox[i][iy-iY1]->SetFillStyle(1001);
985 fXDigBox[i][iy-iY1]->SetFillColor(2);
986 fXDigBox[i][iy-iY1]->SetX1(xpmin);
987 fXDigBox[i][iy-iY1]->SetY1(ypmin);
988 fXDigBox[i][iy-iY1]->SetX2(xpmax);
989 fXDigBox[i][iy-iY1]->SetY2(ypmax);
990 fXDigBox[i][iy-iY1]->Draw();
992 sprintf(cln,"%2d",(iy-iY1));
993 fXLabelL[i][iy-iY1]->Clear();
994 fXLabelL[i][iy-iY1]->AddText(cln);
995 fXLabelL[i][iy-iY1]->Draw();
996 fXLabelR[i][iy-iY1]->Clear();
997 fXLabelR[i][iy-iY1]->AddText(cln);
998 fXLabelR[i][iy-iY1]->Draw();
1000 fBoard->SetDigitX(i,iy-iY1,charge);
1007 if ((xdw < ydw) && by) {
1009 //printf("Y strips mdig->Cathode() = %1d \n",mdig->Cathode());
1012 iX1 = fBoard->GetYSix1();
1013 iX2 = fBoard->GetYSix2();
1014 iY = fBoard->GetYSiy();
1015 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1016 //printf("Digit indices (y-strip) ix = %3d iy = %3d board = %s chamber = %2d \n",ix,iy,fBoard->GetBoardName(),chamber);
1017 ypmin = -0.5*fYWidth[i];
1018 ypmax = +0.5*fYWidth[i];
1020 ypmin = -0.5*fYWidth[i];
1021 ypmax = +0.5*fYWidth[i];
1022 ypmin += 0.01*fYWidth[i];
1023 ypmax -= 0.01*fYWidth[i];
1027 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
1028 boxd->SetFillStyle(1001);
1029 if (triggerBgn) boxd->SetFillColor(6);
1030 else boxd->SetFillColor(5);
1031 boxd->SetBit(kCannotPick);
1034 fYDigBox[i][ix-iX1]->SetFillStyle(1001);
1035 fYDigBox[i][ix-iX1]->SetFillColor(2);
1036 fYDigBox[i][ix-iX1]->SetX1(xpmin);
1037 fYDigBox[i][ix-iX1]->SetY1(ypmin);
1038 fYDigBox[i][ix-iX1]->SetX2(xpmax);
1039 fYDigBox[i][ix-iX1]->SetY2(ypmax);
1040 fYDigBox[i][ix-iX1]->Draw();
1042 sprintf(cln,"%2d",(ix-iX1));
1043 fYLabelL[i][ix-iX1]->Clear();
1044 fYLabelL[i][ix-iX1]->AddText(cln);
1045 fYLabelL[i][ix-iX1]->Draw();
1046 fYLabelR[i][ix-iX1]->Clear();
1047 fYLabelR[i][ix-iX1]->AddText(cln);
1048 fYLabelR[i][ix-iX1]->Draw();
1050 fBoard->SetDigitY(i,ix-iX1,charge);
1052 // extended y-strips
1053 for (Int_t io = 1; io <= over; io++) {
1054 if (io == pos) continue;
1055 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
1056 board->SetDigitY(i,ix-iX1,charge);
1062 } // end digits loop
1067 for (ix = 0; ix < fNStripX; ix++) {
1068 //if (fBoard->GetXDig(i,ix) > 0) {
1069 if (fXDigBox[i][ix]->GetFillStyle() == 1001 ||
1070 fBoard->GetXDig(i,ix) > 0) {
1072 px = fXDigPL[i][ix]->GetX();
1073 py = fXDigPL[i][ix]->GetY();
1079 for (Int_t ip = 0; ip < np; ip++) {
1080 xMin = TMath::Min(xMin,px[ip]);
1081 xMax = TMath::Max(xMax,px[ip]);
1082 yMin = TMath::Min(yMin,py[ip]);
1083 yMax = TMath::Max(yMax,py[ip]);
1086 if (fXDigBox[i][ix]->GetFillStyle() == 0) {
1087 fXDigBox[i][ix]->SetFillStyle(1001);
1088 fXDigBox[i][ix]->SetFillColor(2);
1089 fXDigBox[i][ix]->SetX1(xMin);
1090 fXDigBox[i][ix]->SetY1(yMin);
1091 fXDigBox[i][ix]->SetX2(xMax);
1092 fXDigBox[i][ix]->SetY2(yMax);
1095 sprintf(cln,"%2d",ix);
1097 fXLabelL[i][ix]->Clear();
1098 fXLabelL[i][ix]->AddText(cln);
1099 fXLabelL[i][ix]->Draw();
1101 fXLabelR[i][ix]->Clear();
1102 fXLabelR[i][ix]->AddText(cln);
1103 fXLabelR[i][ix]->Draw();
1105 fXDigBox[i][ix]->Draw();
1116 for (iy = 0; iy < fNStripY; iy++) {
1117 //if (fBoard->GetYDig(i,iy) > 0) {
1118 if (fYDigBox[i][iy]->GetFillStyle() == 1001 ||
1119 fBoard->GetYDig(i,iy) > 0) {
1121 px = fYDigPL[i][iy]->GetX();
1122 py = fYDigPL[i][iy]->GetY();
1128 for (Int_t ip = 0; ip < np; ip++) {
1129 xMin = TMath::Min(xMin,px[ip]);
1130 xMax = TMath::Max(xMax,px[ip]);
1131 yMin = TMath::Min(yMin,py[ip]);
1132 yMax = TMath::Max(yMax,py[ip]);
1135 if (fYDigBox[i][iy]->GetFillStyle() == 0) {
1136 fYDigBox[i][iy]->SetFillStyle(1001);
1137 fYDigBox[i][iy]->SetFillColor(2);
1138 fYDigBox[i][iy]->SetX1(xMin);
1139 fYDigBox[i][iy]->SetY1(yMin);
1140 fYDigBox[i][iy]->SetX2(xMax);
1141 fYDigBox[i][iy]->SetY2(yMax);
1144 sprintf(cln,"%2d",iy);
1146 fYLabelL[i][iy]->Clear();
1147 fYLabelL[i][iy]->AddText(cln);
1148 fYLabelL[i][iy]->Draw();
1150 fYLabelR[i][iy]->Clear();
1151 fYLabelR[i][iy]->AddText(cln);
1152 fYLabelR[i][iy]->Draw();
1155 fYDigBox[i][iy]->Draw();
1163 fCanvas[i]->Modified();
1164 fCanvas[i]->Update();
1166 } // end canvas loop
1172 //__________________________________________________________________________
1173 void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
1175 /// draw the "x" or/and "y" strips
1177 AliRunLoader *runLoader = fLoader->GetRunLoader();
1178 gAlice = runLoader->GetAliRun();
1179 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1180 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
1182 const AliMpVSegmentation* seg;
1186 Float_t xg1, xg2, yg1, yg2, zg1;
1187 Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1188 Int_t detElemId, ic, maxX, maxY;
1189 Float_t xdw, ydw, xpmin, xpmax, ypmin, ypmax;
1190 Float_t ptx1, ptx2, pty1, pty2;
1192 Double_t xc1, xc2, yc1, yc2;
1195 Bool_t makeLabelsX = kFALSE;
1196 Bool_t makeLabelsY = kFALSE;
1198 if (bx && !fLabelX) {
1199 makeLabelsX = kTRUE;
1203 if (by && !fLabelY) {
1204 makeLabelsY = kTRUE;
1208 for (Int_t i = 0; i < kNMT; i++) {
1212 fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
1213 xcw = (Float_t)(0.5*(xc2-xc1));
1214 ycw = (Float_t)(0.5*(yc2-yc1));
1218 for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1220 detElemId = it.CurrentDEId();
1222 if (detElemId%100 != fBoard->GetDetElemId()) continue;
1224 /*---------- y-pads ic = 2 ----------*/
1227 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1229 maxX = seg->MaxPadIndexX();
1230 maxY = seg->MaxPadIndexY();
1232 for (Int_t ix = 0; ix <= maxX; ix++) {
1233 for (Int_t iy = 0; iy <= maxY; iy++) {
1235 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1237 if (!pad.IsValid()) continue;
1239 // get the pad position and dimensions
1240 xlocal1 = pad.Position().X();
1241 ylocal1 = pad.Position().Y();
1242 xlocal2 = pad.Dimensions().X();
1243 ylocal2 = pad.Dimensions().Y();
1245 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1246 // (no transformation for pad dimensions)
1250 // transform in the monitor coordinate system
1251 //xpmin = -(xg1+xg2);
1252 //xpmax = -(xg1-xg2);
1253 //ypmin = -(yg2-yg1);
1254 //ypmax = +(yg2+yg1);
1261 xpmin -= fXCenter[i];
1262 xpmax -= fXCenter[i];
1263 ypmin -= fYCenter[i];
1264 ypmax -= fYCenter[i];
1272 Int_t iX1, iX2, iY, ixDig;
1273 iX1 = fBoard->GetYSix1();
1274 iX2 = fBoard->GetYSix2();
1275 iY = fBoard->GetYSiy();
1276 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1278 ypmin = -0.5*fYWidth[i];
1279 ypmax = +0.5*fYWidth[i];
1281 ypmin += 0.01*fYWidth[i];
1282 ypmax -= 0.01*fYWidth[i];
1287 fYDigPL[i][ixDig]->SetPoint(0,xpmin,ypmin);
1288 fYDigPL[i][ixDig]->SetPoint(1,xpmax,ypmin);
1289 fYDigPL[i][ixDig]->SetPoint(2,xpmax,ypmax);
1290 fYDigPL[i][ixDig]->SetPoint(3,xpmin,ypmax);
1291 fYDigPL[i][ixDig]->SetPoint(4,xpmin,ypmin);
1292 fYDigPL[i][ixDig]->Draw();
1294 fYDigBox[i][ixDig]->SetFillStyle(1001);
1295 fYDigBox[i][ixDig]->SetFillColor(5);
1296 fYDigBox[i][ixDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1299 sprintf(cln,"%2d",(ix-iX1));
1303 pty1 = 1.065*ypmin - 0.04*ycw;
1304 pty2 = 1.065*ypmin + 0.04*ycw;
1305 fYLabelL[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1306 fYLabelL[i][ix-iX1]->SetBorderSize(0);
1307 fYLabelL[i][ix-iX1]->SetBit(kCannotPick);
1309 pty1 = 1.065*ypmax - 0.04*ycw;
1310 pty2 = 1.065*ypmax + 0.04*ycw;
1311 fYLabelR[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1312 fYLabelR[i][ix-iX1]->SetBorderSize(0);
1313 fYLabelR[i][ix-iX1]->SetBit(kCannotPick);
1324 /*---------- x-pads ic = 1 ----------*/
1327 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1329 maxX = seg->MaxPadIndexX();
1330 maxY = seg->MaxPadIndexY();
1332 for (Int_t ix = 0; ix <= maxX; ix++) {
1333 for (Int_t iy = 0; iy <= maxY; iy++) {
1335 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1337 if (!pad.IsValid()) continue;
1339 // get the pad position and dimensions
1340 xlocal1 = pad.Position().X();
1341 ylocal1 = pad.Position().Y();
1342 xlocal2 = pad.Dimensions().X();
1343 ylocal2 = pad.Dimensions().Y();
1345 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1346 // (no transformation for pad dimensions)
1350 // transform in the monitor coordinate system
1351 //xpmin = -(xg1+xg2);
1352 //xpmax = -(xg1-xg2);
1353 //ypmin = -(yg2-yg1);
1354 //ypmax = +(yg2+yg1);
1361 xpmin -= fXCenter[i];
1362 xpmax -= fXCenter[i];
1363 ypmin -= fYCenter[i];
1364 ypmax -= fYCenter[i];
1371 Int_t iX, iY1, iY2, iyDig;
1372 iX = fBoard->GetXSix();
1373 iY1 = fBoard->GetXSiy1();
1374 iY2 = fBoard->GetXSiy2();
1375 if (ix == iX && iy >= iY1 && iy <= iY2) {
1377 xpmin += 0.01*fXWidth[i];
1378 xpmax -= 0.01*fXWidth[i];
1383 fXDigPL[i][iyDig]->SetPoint(0,xpmin,ypmin);
1384 fXDigPL[i][iyDig]->SetPoint(1,xpmax,ypmin);
1385 fXDigPL[i][iyDig]->SetPoint(2,xpmax,ypmax);
1386 fXDigPL[i][iyDig]->SetPoint(3,xpmin,ypmax);
1387 fXDigPL[i][iyDig]->SetPoint(4,xpmin,ypmin);
1388 fXDigPL[i][iyDig]->Draw();
1390 fXDigBox[i][iyDig]->SetFillStyle(1001);
1391 fXDigBox[i][iyDig]->SetFillColor(5);
1392 fXDigBox[i][iyDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1395 sprintf(cln,"%2d",(iy-iY1));
1399 ptx1 = 1.065*xpmin - 0.04*xcw;
1400 ptx2 = 1.065*xpmin + 0.04*xcw;
1401 fXLabelL[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1402 fXLabelL[i][iy-iY1]->SetBorderSize(0);
1403 fXLabelL[i][iy-iY1]->SetBit(kCannotPick);
1405 ptx1 = 1.065*xpmax - 0.04*xcw;
1406 ptx2 = 1.065*xpmax + 0.04*xcw;
1407 fXLabelR[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1408 fXLabelR[i][iy-iY1]->SetBorderSize(0);
1409 fXLabelR[i][iy-iY1]->SetBit(kCannotPick);
1422 fCanvas[i]->Modified();
1423 fCanvas[i]->Update();
1431 //__________________________________________________________________________
1432 void AliMUONTriggerGUIbdmap::CloseWindow()
1434 /// close dialog in response to window manager close.
1440 //__________________________________________________________________________
1441 void AliMUONTriggerGUIbdmap::DoClose()
1443 /// handle Close button.
1445 fBoard->SetOpen(kFALSE);
1446 TTimer::SingleShot(150,"AliMUONTriggerGUIbdmap",this,"CloseWindow()");