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 AliMUONTriggerGUI
20 /// Graphical User Interface utility class for the MUON trigger detector
21 /// It creates, after initialisation with a data file, a sensitive map
22 /// of the trigger boards
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
26 #include "AliMUONTriggerGUI.h"
27 #include "AliMUONTriggerGUIboard.h"
28 #include "AliMUONTriggerGUIdimap.h"
29 #include "AliMUONTriggerGUIbdmap.h"
31 #include "AliMpSegmentation.h"
32 #include "AliMpVSegmentation.h"
34 #include "AliMpIntPair.h"
37 #include "AliMpDEIterator.h"
38 #include "AliMUONGeometryTransformer.h"
39 #include "AliMUONTriggerCrateStore.h"
40 #include "AliMUONLocalTriggerBoard.h"
41 #include "AliMUONTriggerElectronics.h"
42 #include "AliMUONCalibrationData.h"
43 #include "AliMUONMCDataInterface.h"
46 #include "AliRunLoader.h"
47 #include "AliCDBManager.h"
52 #include <TApplication.h>
53 #include <TGDimension.h>
56 #include <TGTextEntry.h>
59 #include <TGImageMap.h>
60 #include <TGTextBuffer.h>
63 ClassImp(AliMUONTriggerGUI)
66 //__________________________________________________________________________
67 AliMUONTriggerGUI::AliMUONTriggerGUI(Int_t runNumber)
96 /// main GUI frame of the trigger monitor
105 fFileName = new TString("");
106 fEvString = new TString("");
107 fPath = new TString("");
109 fTriggerProcessor = 0;
111 fCDBManager = AliCDBManager::Instance();
112 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
113 fCDBManager->SetRun(runNumber);
114 AliMpCDB::LoadDDLStore();
115 fCalibrationData = new AliMUONCalibrationData(runNumber);
119 fMain = new TGMainFrame(gClient->GetRoot(), 750, 420);
120 fMain->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseWindow()");
124 TGMenuBar *menuBar = new TGMenuBar(fMain);
128 TGPopupMenu *menuFile = new TGPopupMenu(gClient->GetRoot());
129 //menuFile->AddLabel("");
131 menuFile->AddEntry("Run", kMFILERUN);
132 menuFile->AddEntry("Control", kMFILECNTRL);
133 menuFile->AddEntry("Exit", kMFILEEXIT);
135 menuFile->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
139 TGPopupMenu *menuCircuit = new TGPopupMenu(gClient->GetRoot());
140 //menuCircuit->AddLabel("");
142 menuCircuit->AddEntry("Open", kMCIRCUITOPEN);
144 menuCircuit->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
148 TGPopupMenu *menuMap = new TGPopupMenu(gClient->GetRoot());
149 //menuMap->AddLabel("");
151 menuMap->AddEntry("Digits map", kMMAPDIGITS);
152 menuMap->AddEntry("Reset digits", kMRESETDIGITS);
154 menuMap->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this,
155 "HandleMenu(Int_t)");
159 TGPopupMenu *menuTrigger = new TGPopupMenu(gClient->GetRoot());
160 //menuTrigger->AddLabel("");
162 menuTrigger->AddEntry("Trigger DSET", kMTRIGGERDSET);
164 menuTrigger->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
166 // Add menus to the menu bar
168 menuBar->AddPopup("File", menuFile,
169 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
172 menuBar->AddPopup("Maps", menuMap,
173 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
176 menuBar->AddPopup("Circuit", menuCircuit,
177 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
180 menuBar->AddPopup("Trigger", menuTrigger,
181 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
184 // Add menu bar to the main frame
186 fMain->AddFrame(menuBar,
187 new TGLayoutHints(kLHintsTop |
195 fImageMap = new TGImageMap(fMain,"$ALICE_ROOT/MUON/data/guimap.gif");
197 fImageMap->Connect("RegionClicked(Int_t)", "AliMUONTriggerGUI", this, "OpenBoard(Int_t)");
199 fImageMap->SetToolTipText("Map of the local boards as seen from the I.P.");
201 // Add image map to the main frame
203 fMain->AddFrame(fImageMap);
204 fMain->SetWindowName("Map of the local boards as seen from the I.P.");
206 // Resize the main frame
208 TGDimension size = fMain->GetDefaultSize();
211 fMain->MapSubwindows();
215 fBoardsInit = kFALSE;
217 //HandleMenu(kMFILERUN); // temporary
224 //__________________________________________________________________________
225 void AliMUONTriggerGUI::HandleMenu(Int_t id)
227 /// handles entry numbers in the available menus (EMenuIdentifiers)
229 TGCompositeFrame *runInput1, *runInput2, *runInput3;
230 TGCompositeFrame *control1, *control2, *circuit1, *circuit2;
231 TGLabel *runL1, *runL2, *circuitL1;
232 TGTextEntry *runText1, *runText2, *circuitText1;
233 TGTextButton *runApply, *runCancel;
234 TGTextButton *controlClose, *nextEvent, *previousEvent, *skipToEvent;
235 TGTextButton *circuitCancel, *circuitOpen;
237 //Int_t trigInfo[kNBoards*6] = {-1};
238 //Int_t nLocalTrigger = 0;
240 TString error = TString("");
241 if (id != kMFILEEXIT && id != kMFILERUN && fRunLoader == 0) {
242 error.Append("Run not initialized (Menu: File/Run)");
243 DoErrorGUI(error.Data());
259 fRunInput = new TGTransientFrame(gClient->GetRoot(), fMain, 400, 200);
260 fRunInput->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseRunInput()");
261 fRunInput->DontCallClose(); // to avoid double deletions.
263 // use hierarchical cleaning
264 fRunInput->SetCleanup(kDeepCleanup);
266 fRunInput->SetWindowName("Input file and event number");
268 // input galice and event number frames
270 runInput1 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
271 runInput2 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
275 runL1 = new TGLabel(runInput1, new TGString("Path to gAlice:"));
276 runL2 = new TGLabel(runInput2, new TGString("Event number:"));
280 runText1 = new TGTextEntry(runInput1, fTxtBuffer1 = new TGTextBuffer(100));
282 //fPath->Append("dset"); // temporary
283 //fTxtBuffer1->AddText(0,fPath->Data()); // temporary
285 runText1->SetToolTipText("Enter the path to galice.root");
286 runText1->Resize(300, runText1->GetDefaultHeight());
288 // event number text entry
290 runText2 = new TGTextEntry(runInput2, fTxtBuffer2 = new TGTextBuffer(5));
292 fEvString->Form("%d",0);
293 fTxtBuffer2->AddText(0,fEvString->Data());
295 runText2->SetToolTipText("Enter the first event number to start with");
296 runText2->Resize(300, runText2->GetDefaultHeight());
298 // add to galice frame
300 runInput1->AddFrame(runL1,
301 new TGLayoutHints(kLHintsLeft |
306 runInput1->AddFrame(runText1,
307 new TGLayoutHints(kLHintsRight |
312 // add to event number frame
314 runInput2->AddFrame(runL2,
315 new TGLayoutHints(kLHintsLeft |
320 runInput2->AddFrame(runText2,
321 new TGLayoutHints(kLHintsRight |
326 // add input frames to main input frame
328 fRunInput->AddFrame(runInput1,
329 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
331 fRunInput->AddFrame(runInput2,
332 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
334 // frame with buttons
336 runInput3 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
340 runApply = new TGTextButton(runInput3, "Apply", 1);
341 runApply->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunApply()");
342 runApply->SetToolTipText("Apply changes");
344 runCancel = new TGTextButton(runInput3, "Cancel", 2);
345 runCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunCancel()"); runCancel->SetToolTipText("Cancel changes");
349 runInput3->AddFrame(runApply,
350 new TGLayoutHints(kLHintsTop |
355 runInput3->AddFrame(runCancel,
356 new TGLayoutHints(kLHintsTop |
361 // add to the main input frame
363 fRunInput->AddFrame(runInput3,
364 new TGLayoutHints(kLHintsTop |
369 fRunInput->MapSubwindows();
371 fRunInput->MapWindow();
373 //DoRunApply(); // temporary
379 // control main frame
381 fControl = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
382 fControl->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseControl()");
383 fControl->DontCallClose(); // to avoid double deletions.
385 // use hierarchical cleaning
386 fControl->SetCleanup(kDeepCleanup);
388 fControl->SetWindowName("Run controls");
390 // frame to hold buttons
392 control1 = new TGCompositeFrame(fControl, 50, 50, kVerticalFrame);
396 controlClose = new TGTextButton(control1, "Close", 1);
397 controlClose->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoControlClose()");
398 //controlClose->Resize(300, controlClose->GetDefaultHeight());
400 nextEvent = new TGTextButton(control1, "Next event", 2);
401 nextEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoNextEvent()");
403 previousEvent = new TGTextButton(control1, "Previous event", 3);
404 previousEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoPreviousEvent()");
406 // frame to hold event skip
408 control2 = new TGCompositeFrame(fControl, 50, 50, kHorizontalFrame);
410 // skip to event text field
412 fSkipToEventTxt = new TGTextEntry(control2, fTxtBuffer2 = new TGTextBuffer(5));
414 fTxtBuffer2->AddText(0,fEvString->Data());
416 // skip to event button
418 skipToEvent = new TGTextButton(control2, "Skip to event", 1);
419 skipToEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoSkipToEvent()");
421 // add to event skip frame
423 control2->AddFrame(fSkipToEventTxt,
424 new TGLayoutHints(kLHintsTop |
429 control2->AddFrame(skipToEvent,
430 new TGLayoutHints(kLHintsTop |
437 control1->AddFrame(controlClose,
438 new TGLayoutHints(kLHintsBottom |
443 control1->AddFrame(nextEvent,
444 new TGLayoutHints(kLHintsBottom |
449 control1->AddFrame(previousEvent,
450 new TGLayoutHints(kLHintsBottom |
455 // add to the main frame
457 fControl->AddFrame(control1,
458 new TGLayoutHints(kLHintsBottom |
464 fControl->AddFrame(control2,
465 new TGLayoutHints(kLHintsTop |
470 fControl->MapSubwindows();
472 fControl->MapWindow();
479 fDiMap = new AliMUONTriggerGUIdimap(fBoards,gClient->GetRoot(), fMain, 400, 200);
480 fDiMap->SetLoader(fLoader);
481 fDiMap->SetMCDataInterface(fMCDataInterface);
482 fDiMap->DrawAllMaps();
483 } else if (!fDiMap->IsOn()) {
484 fDiMap = new AliMUONTriggerGUIdimap(fBoards,gClient->GetRoot(), fMain, 400, 200);
485 fDiMap->SetLoader(fLoader);
486 fDiMap->SetMCDataInterface(fMCDataInterface);
487 fDiMap->DrawAllMaps();
494 Int_t number, over, pos;
495 for (Int_t ib = 0; ib < kNBoards; ib++) {
496 AliMUONTriggerGUIboard *board = GetBoard(ib);
497 board->ClearXDigits();
498 board->ClearYDigits();
500 number = board->GetNumber();
501 pos = board->GetPosition();
502 over = board->GetYOver();
503 for (Int_t io = 1; io <= over; io++) {
504 if (io == pos) continue;
505 board = GetBoard(number+io-pos);
506 board->ClearYDigits();
514 fCircuit = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
515 fCircuit->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseCircuit()");
516 fCircuit->DontCallClose(); // to avoid double deletions.
518 // use hierarchical cleaning
519 fCircuit->SetCleanup(kDeepCleanup);
521 fCircuit->SetWindowName("Board circuit");
525 circuit1 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
526 circuit2 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
530 circuitL1 = new TGLabel(circuit1, new TGString("Circuit number:"));
534 circuitText1 = new TGTextEntry(circuit1, fTxtCircuit = new TGTextBuffer(10));
537 circuitCancel = new TGTextButton(circuit2, "Cancel", 1);
538 circuitCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitCancel()");
539 //circuitCancel->Resize(100, circuitCancel->GetDefaultHeight());
541 circuitOpen = new TGTextButton(circuit2, "Open", 2);
542 circuitOpen->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitOpen()");
543 //circuitOpen->Resize(100, circuitOpen->GetDefaultHeight());
547 circuit1->AddFrame(circuitL1,
548 new TGLayoutHints(kLHintsLeft |
553 circuit1->AddFrame(circuitText1,
554 new TGLayoutHints(kLHintsRight |
559 circuit2->AddFrame(circuitCancel,
560 new TGLayoutHints(kLHintsBottom |
565 circuit2->AddFrame(circuitOpen,
566 new TGLayoutHints(kLHintsBottom |
571 fCircuit->AddFrame(circuit1,
572 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
574 fCircuit->AddFrame(circuit2,
575 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
577 fCircuit->MapSubwindows();
579 fCircuit->MapWindow();
585 cout << "Trigger with boards digits....." << endl;
586 fTriggerProcessor->FeedBoardsGUI(Boards());
588 nLocalTrigger = fTriggerProcessor->TriggerGUI(trigInfo,kTRUE);
590 cout << "Trigger done with " << nLocalTrigger << " local decisions !" << endl;
592 for (Int_t ilo = 0; ilo < nLocalTrigger; ilo++) {
594 cout << "Local decision " << ilo << endl;
595 cout << "Circuit = " << trigInfo[6*ilo+0] << endl;
596 cout << "LoStripX = " << trigInfo[6*ilo+1] << endl;
597 cout << "LoStripY = " << trigInfo[6*ilo+2] << endl;
598 cout << "LoDev = " << trigInfo[6*ilo+3] << endl;
599 cout << "LoLpt = " << trigInfo[6*ilo+4] << endl;
600 cout << "LoHpt = " << trigInfo[6*ilo+5] << endl;
607 printf("Menu item %d selected\n", id);
614 //__________________________________________________________________________
615 void AliMUONTriggerGUI::CloseRunInput() const
617 /// close the run input frame
623 //__________________________________________________________________________
624 void AliMUONTriggerGUI::CloseError() const
626 /// close the error frame
632 //__________________________________________________________________________
633 void AliMUONTriggerGUI::CloseControl() const
635 /// close the event control frame
639 //gSystem->Exec("cd $PWD/mtrun; aliroot -b -q mtsim.C");
643 //__________________________________________________________________________
644 void AliMUONTriggerGUI::CloseCircuit() const
646 /// close the circuit frame
652 //__________________________________________________________________________
653 void AliMUONTriggerGUI::CloseWindow()
655 /// close the main frame and exit aplication
658 delete fMCDataInterface;
660 gApplication->Terminate();
664 //__________________________________________________________________________
665 void AliMUONTriggerGUI::DoRunApply()
667 /// apply changes in the run control frame
669 printf("Input 1 = %s \n",fTxtBuffer1->GetString());
671 TString es = TString(fTxtBuffer2->GetString());
674 printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent);
676 TString error = TString("");;
678 fPath->Form("%s",fTxtBuffer1->GetString());
679 fFileName->Form("%s",fTxtBuffer1->GetString());
680 printf("File location: %s \n",fFileName->Data());
682 if (gSystem->AccessPathName(fFileName->Data()) || !fFileName->EndsWith(".root")) {
684 error.Append("No galice file: ");
685 error.Append(fFileName->Data());
686 DoErrorGUI(error.Data());
690 TFile *ftest = new TFile(fFileName->Data(),"READ");
691 AliRun *galice = (AliRun*)ftest->Get("gAlice");
697 error.Append("No gAlice in file: ");
698 error.Append(fFileName->Data());
699 DoErrorGUI(error.Data());
710 delete fMCDataInterface;
713 fRunLoader = AliRunLoader::Open(fFileName->Data(),"MUONFolder","READ");
715 if (fRunLoader == 0x0) {
717 DoErrorGUI("No run loader !");
721 fRunLoader->LoadgAlice();
722 gAlice = fRunLoader->GetAliRun();
723 fEventsPerRun = gAlice->GetEventsPerRun();
725 fLoader = fRunLoader->GetLoader("MUONLoader");
726 fRunLoader->GetEvent(fEvent);
728 fMCDataInterface = new AliMUONMCDataInterface(fFileName->Data());
730 fRunInput->SendCloseMessage();
737 if (fDiMap->IsOn()) {
738 fDiMap->SetLoader(fLoader);
739 fDiMap->SetMCDataInterface(fMCDataInterface);
743 //fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
750 //__________________________________________________________________________
751 void AliMUONTriggerGUI::DoRunCancel()
753 /// cancel the changes in the run control frame
755 printf("Input 1 = %s \n",fTxtBuffer1->GetString());
757 TString es = TString(fTxtBuffer2->GetString());
760 printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent);
762 fRunInput->SendCloseMessage();
766 //__________________________________________________________________________
767 void AliMUONTriggerGUI::DoErrorGUI(const Char_t *wt)
769 /// show an error message in a new frame
771 fError = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
772 fError->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseError()");
773 fError->DontCallClose(); // to avoid double deletions.
775 // use hierarchical cleaning
776 fError->SetCleanup(kDeepCleanup);
778 fError->SetWindowName("Error !");
780 TGCompositeFrame *fW = new TGCompositeFrame(fError, 50, 50, kVerticalFrame);
782 TGTextButton *fErrorOK = new TGTextButton(fW, "&Ok", 1);
783 fErrorOK->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoErrorOK()");
785 fW->AddFrame(fErrorOK,
786 new TGLayoutHints(kLHintsBottom |
791 TGLabel *fWL = new TGLabel(fW, new TGString(wt));
794 new TGLayoutHints(kLHintsTop |
800 new TGLayoutHints(kLHintsLeft |
805 fError->MapSubwindows();
811 //__________________________________________________________________________
812 void AliMUONTriggerGUI::DoNextEvent()
814 /// load next event from the file
816 TString error = TString("");
818 if (fEvent < (fEventsPerRun-1)) {
820 fRunLoader->GetEvent(fEvent);
822 fEvString->Form("%d",fEvent);
823 fTxtBuffer2->RemoveText(0,5);
824 fTxtBuffer2->AddText(0,fEvString->Data());
825 fSkipToEventTxt->SetFocus();
828 error.Form("Only %d event(s) in the run !",fEventsPerRun);
829 DoErrorGUI(error.Data());
834 //__________________________________________________________________________
835 void AliMUONTriggerGUI::DoPreviousEvent()
837 /// load previous event from the input file
839 TString error = TString("");
843 fRunLoader->GetEvent(fEvent);
845 fEvString->Form("%d",fEvent);
846 fTxtBuffer2->RemoveText(0,5);
847 fTxtBuffer2->AddText(0,fEvString->Data());
848 fSkipToEventTxt->SetFocus();
851 error.Form("Already at event 0 !");
852 DoErrorGUI(error.Data());
857 //__________________________________________________________________________
858 void AliMUONTriggerGUI::DoSkipToEvent()
860 /// skip to event -input- from the input file
862 TString error = TString("");
864 TString es = TString(fTxtBuffer2->GetString());
867 if (fEvent < 0 || fEvent > (fEventsPerRun-1)) {
868 error.Form("Event number out of range !");
869 DoErrorGUI(error.Data());
871 fRunLoader->GetEvent(fEvent);
873 fRunLoader->LoadKinematics();
875 AliStack* stack = gAlice->Stack();
876 Int_t nParticles = stack->GetNtrack();
877 Int_t nPrimaries = stack->GetNprimary();
882 Double_t px, py, pz, theta, phi;
883 for (Int_t i = 0; i < nPrimaries; i++) {
884 part = stack->Particle(i);
886 if (TMath::Abs(part->GetPdgCode()) == 13) {
888 pdgCode = part->GetPdgCode();
892 theta = part->Theta();
894 printf("Kine %d px %f py %f pz %f th %f ph %f \n",pdgCode,px,py,pz,theta,phi);
902 //__________________________________________________________________________
903 void AliMUONTriggerGUI::DoErrorOK()
905 /// close the error frame
907 fError->SendCloseMessage();
911 //__________________________________________________________________________
912 void AliMUONTriggerGUI::DoControlClose()
914 /// close the event control frame
916 fControl->SendCloseMessage();
920 //__________________________________________________________________________
921 void AliMUONTriggerGUI::DoCircuitCancel()
923 /// close the circuit frame
925 fCircuit->SendCloseMessage();
929 //__________________________________________________________________________
930 void AliMUONTriggerGUI::DoCircuitOpen()
934 TString cs = TString(fTxtCircuit->GetString());
935 Int_t icirc = cs.Atoi();
937 AliMUONTriggerGUIboard *board;
939 for (Int_t ib = 0; ib < kNBoards; ib++) {
941 board = GetBoard(ib);
943 if (board->GetIdCircuit() == icirc) {
948 if (fDiMap->IsOn()) {
949 fDiMap->SelectBoard(ib);
953 fCircuit->SendCloseMessage();
961 //__________________________________________________________________________
962 AliMUONTriggerGUIboard* AliMUONTriggerGUI::GetBoard(Int_t id) const
964 /// return board with "id"
966 if (fBoards == 0) return 0;
967 void * b = fBoards->UncheckedAt(id);
968 if (b == 0) return 0;
970 return (AliMUONTriggerGUIboard*)b;
974 //__________________________________________________________________________
975 void AliMUONTriggerGUI::OpenBoard(Int_t id)
977 /// open board with "id" in a new frame
979 AliMUONTriggerGUIboard *board = GetBoard(id);
980 UShort_t status = board->GetStatus();
981 board->SetOpen(kTRUE);
983 AliMUONTriggerGUIbdmap *bf;
986 bf = new AliMUONTriggerGUIbdmap(gClient->GetRoot(), fMain, 400, 200);
988 if (status & kGood) {
989 sprintf(text,"%s (Circuit %4d) status : working",
990 board->GetBoardName(),board->GetIdCircuit());
993 if (status & kWithProblems) {
994 sprintf(text,"%s (Circuit %4d) status : has problems...",
995 board->GetBoardName(),board->GetIdCircuit());
998 if (status & kNotWorking) {
999 sprintf(text,"%s (Circuit %4d) status : not working",
1000 board->GetBoardName(),board->GetIdCircuit());
1003 if (status & kUnknown) {
1004 sprintf(text,"%s (Circuit %4d) status : unknown",
1005 board->GetBoardName(),board->GetIdCircuit());
1009 bf->SetBoard(Boards(),id);
1010 bf->SetLoader(fLoader);
1011 bf->SetCrateManager(fCrateManager);
1012 bf->SetMCDataInterface(fMCDataInterface);
1018 if (fDiMap->IsOn()) {
1019 fDiMap->SelectBoard(id);
1025 //__________________________________________________________________________
1026 void AliMUONTriggerGUI::Init()
1028 /// initialize the main GUI frame
1035 AliMUONTriggerGUIboard *board;
1036 for (Int_t ib = 0; ib < kNBoards; ib++) {
1037 board = GetBoard(ib);
1043 //__________________________________________________________________________
1044 void AliMUONTriggerGUI::InitBoards()
1046 /// create board objects and define the sensitive regions in the image map
1048 fBoardsInit = kTRUE;
1050 if (fCrateManager == 0x0) {
1051 fCrateManager = new AliMUONTriggerCrateStore();
1052 fCrateManager->ReadFromFile(fCalibrationData);
1055 Int_t nPixelX = 700;
1056 Int_t nPixelY = 676;
1058 Int_t nPixelBorderX = 40; // to guess...
1059 Int_t nPixelBorderY = 40; // to guess...
1061 Float_t boardsX = 2*257.00; // cm
1062 Float_t boardsY = 2*306.61; // cm
1066 Int_t side, col, line, nbx, detElemId = 0;
1067 UShort_t status = 1;
1068 Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
1070 Char_t name[8], text[200];
1075 TString mapspath = gSystem->Getenv("ALICE_ROOT");
1076 mapspath.Append("/MUON/data");
1079 AliMUONTriggerGUIboard *board;
1081 // regions for the image map
1083 sprintf(text,"%s/guimapp11.txt",mapspath.Data());
1084 fmap = fopen(text,"r");
1086 for (Int_t ib = 0; ib < kNBoards; ib++) {
1088 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1090 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
1092 board = new AliMUONTriggerGUIboard(ib,name);
1095 board->SetStatus(status);
1097 // calculate detElemId%100
1101 if (side == 0) detElemId = 14 - line;
1102 if (side == 1 && line < 5) detElemId = 13 + line;
1103 if (side == 1 && line >= 5) detElemId = line - 5;
1105 board->SetDetElemId(detElemId);
1107 Boards()->Add(board);
1112 x = (Int_t)(nPixelX/2 + xc * (nPixelX - 2*nPixelBorderX)/boardsX);
1113 y = (Int_t)(nPixelY/2 - yc * (nPixelY - 2*nPixelBorderY)/boardsY);
1118 w = (UInt_t)(xWidth*(nPixelX-2*nPixelBorderX)/boardsX);
1119 h = (UInt_t)(yWidth*(nPixelY-2*nPixelBorderY)/boardsY);
1133 reg = new TGRegion(5,xp,yp);
1134 fImageMap->AddRegion(*reg, ib);
1136 if (status & kGood) {
1137 sprintf(text,"%s working",name);
1139 if (status & kWithProblems) {
1140 sprintf(text,"%s has problems...",name);
1142 if (status & kNotWorking) {
1143 sprintf(text,"%s not working",name);
1145 if (status & kUnknown) {
1146 sprintf(text,"%s status unknown",name);
1149 //fImageMap->SetToolTipText(ib, text);
1155 // MT position and dimension in board
1157 for (Int_t imt = 0; imt < kNMT; imt++) {
1159 sprintf(text,"%s/guimapp%2d.txt",mapspath.Data(),11+imt);
1161 fmap = fopen(text,"r");
1163 for (Int_t ib = 0; ib < kNBoards; ib++) {
1165 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1167 board = GetBoard(ib);
1168 board->SetDimensions(imt,xCenter,yCenter,zCenter,xWidth,yWidth);
1176 // MT x-strips indices and circuit number
1177 Int_t ix, iy1, iy2, sIx, sIy1, cathode, icirc;
1178 sprintf(text,"%s/guimapix11.txt",mapspath.Data());
1180 fmap = fopen(text,"r");
1182 for (Int_t ib = 0; ib < kNBoards; ib++) {
1184 fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix,&iy1,&iy2,&name[0]);
1186 board = GetBoard(ib);
1187 board->SetXSindex(ix,iy1,iy2);
1189 // set the circuit number
1190 detElemId = board->GetDetElemId();
1191 detElemId += 100 * 11;
1193 sIx = board->GetXSix();
1194 sIy1 = board->GetXSiy1();
1195 const AliMpVSegmentation* seg =
1196 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
1198 AliMpPad pad = seg->PadByIndices(AliMpIntPair(sIx,sIy1),kTRUE);
1199 AliMpIntPair location = pad.GetLocation(0);
1201 Int_t nboard = location.GetFirst();
1202 AliMUONLocalTriggerBoard* b = fCrateManager->LocalBoard(nboard);
1203 icirc = b->GetNumber();
1204 board->SetBoardName((Char_t*)b->GetName());
1205 board->SetIdCircuit(icirc);
1207 TString crateName = b->GetCrate();
1209 sprintf(text,"%s (crate %s circuit %3d, number %3d)",board->GetBoardName(),crateName.Data(),icirc,ib);
1210 fImageMap->SetToolTipText(ib, text);
1216 // MT y-strips indices
1219 sprintf(text,"%s/guimapiy11.txt",mapspath.Data());
1221 fmap = fopen(text,"r");
1223 for (Int_t ib = 0; ib < kNBoards; ib++) {
1225 fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix1,&ix2,&iy,&name[0]);
1227 board = GetBoard(ib);
1228 board->SetYSindex(ix1,ix2,iy);
1234 // Extended y-strips over neighbouring boards
1236 sprintf(text,"%s/guimapp11.txt",mapspath.Data());
1238 fmap = fopen(text,"r");
1240 for (Int_t ib = 0; ib < kNBoards; ib++) {
1242 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1244 board = GetBoard(ib);
1246 board->SetPosition(nbx);
1248 if ((col == 2 || col == 3) && (line >= 4 && line <= 6)) {
1252 if (col == 1 && (line == 4 || line == 6)) {
1256 if (col == 7 || line == 1 || line == 9) {
1268 // Set coordinates of strips boxes
1270 for (Int_t ib = 0; ib < kNBoards; ib++) {
1272 board = GetBoard(ib);
1273 SetStripBoxes(board);
1279 //__________________________________________________________________________
1280 void AliMUONTriggerGUI::SetStripBoxes(AliMUONTriggerGUIboard *board)
1282 /// set coordinates of strip boxes
1284 gAlice = fRunLoader->GetAliRun();
1285 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1286 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
1288 const AliMpVSegmentation* seg;
1292 Int_t chamber, detElemId, maxX, maxY, ic;
1293 Float_t xpmin, xpmax, ypmin, ypmax;
1294 Float_t xg1, xg2, yg1, yg2, zg1;
1295 Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1296 Float_t xCenter, yCenter, xWidth, yWidth;
1298 for (Int_t i = 0; i < kNMT; i++) {
1302 xCenter = board->GetXCenter(i);
1303 yCenter = board->GetYCenter(i);
1304 xWidth = board->GetXWidth(i);
1305 yWidth = board->GetYWidth(i);
1307 for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1309 detElemId = it.CurrentDEId();
1311 if (detElemId%100 != board->GetDetElemId()) continue;
1313 /*---------- y-pads ic = 2 ----------*/
1316 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1318 maxX = seg->MaxPadIndexX();
1319 maxY = seg->MaxPadIndexY();
1321 for (Int_t ix = 0; ix <= maxX; ix++) {
1322 for (Int_t iy = 0; iy <= maxY; iy++) {
1324 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1326 if (!pad.IsValid()) continue;
1328 // get the pad position and dimensions
1329 xlocal1 = pad.Position().X();
1330 ylocal1 = pad.Position().Y();
1331 xlocal2 = pad.Dimensions().X();
1332 ylocal2 = pad.Dimensions().Y();
1334 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1335 // (no transformation for pad dimensions)
1339 // transform in the monitor coordinate system
1340 //xpmin = -(xg1+xg2);
1341 //xpmax = -(xg1-xg2);
1342 //ypmin = -(yg2-yg1);
1343 //ypmax = +(yg2+yg1);
1355 Int_t iX1, iX2, iY, ixDig;
1356 iX1 = board->GetYSix1();
1357 iX2 = board->GetYSix2();
1358 iY = board->GetYSiy();
1359 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1361 ypmin = -0.5*yWidth;
1362 ypmax = +0.5*yWidth;
1366 board->SetYDigBox(i,ixDig,(Double_t)xpmin,(Double_t)ypmin,
1367 (Double_t)xpmax,(Double_t)ypmax);
1374 /*---------- x-pads ic = 1 ----------*/
1377 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1379 maxX = seg->MaxPadIndexX();
1380 maxY = seg->MaxPadIndexY();
1382 for (Int_t ix = 0; ix <= maxX; ix++) {
1383 for (Int_t iy = 0; iy <= maxY; iy++) {
1385 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1387 if (!pad.IsValid()) continue;
1389 // get the pad position and dimensions
1390 xlocal1 = pad.Position().X();
1391 ylocal1 = pad.Position().Y();
1392 xlocal2 = pad.Dimensions().X();
1393 ylocal2 = pad.Dimensions().Y();
1395 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1396 // (no transformation for pad dimensions)
1400 // transform in the monitor coordinate system
1401 //xpmin = -(xg1+xg2);
1402 //xpmax = -(xg1-xg2);
1403 //ypmin = -(yg2-yg1);
1404 //ypmax = +(yg2+yg1);
1416 Int_t iX, iY1, iY2, iyDig;
1417 iX = board->GetXSix();
1418 iY1 = board->GetXSiy1();
1419 iY2 = board->GetXSiy2();
1420 if (ix == iX && iy >= iY1 && iy <= iY2) {
1424 board->SetXDigBox(i,iyDig,(Double_t)xpmin,(Double_t)ypmin,
1425 (Double_t)xpmax,(Double_t)ypmax);