]>
Commit | Line | Data |
---|---|---|
905654c2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | ////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // Graphical User Interface utility class for the MUON trigger // | |
19 | // // | |
20 | ////////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | #include "AliMUONTriggerGUI.h" | |
23 | #include "AliMUONTriggerGUIboard.h" | |
24 | #include "AliMUONTriggerGUIdimap.h" | |
25 | #include "AliMUONTriggerGUIbdmap.h" | |
26 | ||
27 | #include "AliMpSegmentation.h" | |
28 | #include "AliMpVSegmentation.h" | |
29 | #include "AliMpPad.h" | |
30 | #include "AliMpIntPair.h" | |
31 | #include "AliMUON.h" | |
32 | #include "AliMUONData.h" | |
33 | #include "AliMpDEIterator.h" | |
34 | #include "AliMUONGeometryTransformer.h" | |
35 | #include "AliMUONTriggerCrateStore.h" | |
36 | #include "AliMUONLocalTriggerBoard.h" | |
37 | #include "AliMUONTriggerElectronics.h" | |
38 | #include "AliMUONCalibrationData.h" | |
39 | ||
40 | #include "AliRun.h" | |
41 | #include "AliRunLoader.h" | |
42 | #include "AliCDBManager.h" | |
43 | ||
44 | #include <TSystem.h> | |
45 | #include <TGLabel.h> | |
46 | #include <TGFrame.h> | |
47 | #include <TApplication.h> | |
48 | #include <TGDimension.h> | |
49 | #include <TString.h> | |
50 | #include <TGMenu.h> | |
51 | #include <TGTextEntry.h> | |
52 | #include <TGButton.h> | |
53 | #include <TFile.h> | |
54 | #include <TGImageMap.h> | |
55 | #include <TGTextBuffer.h> | |
56 | ||
57 | /// \cond CLASSIMP | |
58 | ClassImp(AliMUONTriggerGUI) | |
59 | /// \endcond | |
60 | ||
61 | //__________________________________________________________________________ | |
62 | AliMUONTriggerGUI::AliMUONTriggerGUI() | |
63 | : TObject(), | |
64 | fMain(0), | |
65 | fImageMap(0), | |
66 | fTxtBuffer1(0), | |
67 | fTxtBuffer2(0), | |
68 | fTxtCircuit(0), | |
69 | fRunInput(0), | |
70 | fError(0), | |
71 | fControl(0), | |
72 | fCircuit(0), | |
73 | fSkipToEventTxt(0), | |
74 | fFileName(0), | |
75 | fPath(0), | |
76 | fEvString(0), | |
77 | fChamber(0), | |
78 | fEvent(0), | |
79 | fEventsPerRun(0), | |
80 | fLoader(0), | |
81 | fRunLoader(0), | |
82 | fCDBManager(0), | |
83 | fCalibrationData(0), | |
84 | fBoardsInit(0), | |
85 | fDiMap(0), | |
86 | fTriggerProcessor(0), | |
87 | fMUONData(0), | |
88 | fBoards(0) | |
89 | { | |
90 | /// main GUI frame of the trigger monitor | |
91 | ||
92 | fChamber = 0; | |
93 | fEvent = 0; | |
94 | fEventsPerRun = 0; | |
95 | fRunLoader = 0; | |
96 | fDiMap = 0; | |
97 | ||
98 | fBoards = 0; | |
99 | fFileName = new TString(""); | |
100 | fEvString = new TString(""); | |
101 | fPath = new TString(""); | |
102 | ||
103 | fTriggerProcessor = 0; | |
104 | ||
105 | fCDBManager = AliCDBManager::Instance(); | |
106 | fCDBManager->SetDefaultStorage("local://$ALICE_ROOT"); | |
107 | fCalibrationData = new AliMUONCalibrationData(0); // runnumber zero | |
108 | ||
109 | // Main frame | |
110 | ||
111 | fMain = new TGMainFrame(gClient->GetRoot(), 750, 420); | |
112 | fMain->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseWindow()"); | |
113 | ||
114 | // Menu bar | |
115 | ||
116 | TGMenuBar *menuBar = new TGMenuBar(fMain); | |
117 | ||
118 | // File menu | |
119 | ||
120 | TGPopupMenu *menuFile = new TGPopupMenu(gClient->GetRoot()); | |
121 | //menuFile->AddLabel(""); | |
122 | ||
123 | menuFile->AddEntry("Run", kMFILERUN); | |
124 | menuFile->AddEntry("Control", kMFILECNTRL); | |
125 | menuFile->AddEntry("Exit", kMFILEEXIT); | |
126 | ||
127 | menuFile->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)"); | |
128 | ||
129 | // Circuit menu | |
130 | ||
131 | TGPopupMenu *menuCircuit = new TGPopupMenu(gClient->GetRoot()); | |
132 | //menuCircuit->AddLabel(""); | |
133 | ||
134 | menuCircuit->AddEntry("Open", kMCIRCUITOPEN); | |
135 | ||
136 | menuCircuit->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)"); | |
137 | ||
138 | // Digits map menu | |
139 | ||
140 | TGPopupMenu *menuMap = new TGPopupMenu(gClient->GetRoot()); | |
141 | //menuMap->AddLabel(""); | |
142 | ||
143 | menuMap->AddEntry("Digits map", kMMAPDIGITS); | |
144 | menuMap->AddEntry("Reset digits", kMRESETDIGITS); | |
145 | ||
146 | menuMap->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, | |
147 | "HandleMenu(Int_t)"); | |
148 | ||
149 | // Trigger menu | |
150 | ||
151 | TGPopupMenu *menuTrigger = new TGPopupMenu(gClient->GetRoot()); | |
152 | //menuTrigger->AddLabel(""); | |
153 | ||
154 | menuTrigger->AddEntry("Trigger DSET", kMTRIGGERDSET); | |
155 | ||
156 | menuTrigger->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)"); | |
157 | ||
158 | // Add menus to the menu bar | |
159 | ||
160 | menuBar->AddPopup("File", menuFile, | |
161 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2) | |
162 | ); | |
163 | ||
164 | menuBar->AddPopup("Maps", menuMap, | |
165 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2) | |
166 | ); | |
167 | ||
168 | menuBar->AddPopup("Circuit", menuCircuit, | |
169 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2) | |
170 | ); | |
171 | ||
172 | menuBar->AddPopup("Trigger", menuTrigger, | |
173 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2) | |
174 | ); | |
175 | ||
176 | // Add menu bar to the main frame | |
177 | ||
178 | fMain->AddFrame(menuBar, | |
179 | new TGLayoutHints(kLHintsTop | | |
180 | kLHintsLeft | | |
181 | kLHintsExpandX, | |
182 | 0, 0, 1, 1) | |
183 | ); | |
184 | ||
185 | // The image map | |
186 | ||
187 | fImageMap = new TGImageMap(fMain,"$ALICE_ROOT/MUON/data/guimap.gif"); | |
188 | ||
189 | fImageMap->Connect("RegionClicked(Int_t)", "AliMUONTriggerGUI", this, "OpenBoard(Int_t)"); | |
190 | ||
191 | fImageMap->SetToolTipText("Map of the local boards as seen from the I.P."); | |
192 | ||
193 | // Add image map to the main frame | |
194 | ||
195 | fMain->AddFrame(fImageMap); | |
196 | fMain->SetWindowName("Map of the local boards as seen from the I.P."); | |
197 | ||
198 | // Resize the main frame | |
199 | ||
200 | TGDimension size = fMain->GetDefaultSize(); | |
201 | fMain->Resize(size); | |
202 | ||
203 | fMain->MapSubwindows(); | |
204 | ||
205 | fMain->MapWindow(); | |
206 | ||
207 | fBoardsInit = kFALSE; | |
208 | ||
209 | //HandleMenu(kMFILERUN); // temporary | |
210 | ||
211 | //InitBoards(); | |
212 | //Init(); | |
213 | ||
214 | } | |
215 | ||
216 | //__________________________________________________________________________ | |
217 | AliMUONTriggerGUI::AliMUONTriggerGUI(const AliMUONTriggerGUI& gui) | |
218 | : TObject(), | |
219 | fMain(0), | |
220 | fImageMap(0), | |
221 | fTxtBuffer1(0), | |
222 | fTxtBuffer2(0), | |
223 | fTxtCircuit(0), | |
224 | fRunInput(0), | |
225 | fError(0), | |
226 | fControl(0), | |
227 | fCircuit(0), | |
228 | fSkipToEventTxt(0), | |
229 | fFileName(0), | |
230 | fPath(0), | |
231 | fEvString(0), | |
232 | fChamber(0), | |
233 | fEvent(0), | |
234 | fEventsPerRun(0), | |
235 | fLoader(0), | |
236 | fRunLoader(0), | |
237 | fCDBManager(0), | |
238 | fCalibrationData(0), | |
239 | fBoardsInit(0), | |
240 | fDiMap(0), | |
241 | fTriggerProcessor(0), | |
242 | fMUONData(0), | |
243 | fBoards(0) | |
244 | { | |
245 | /// copy constructor | |
246 | ||
247 | gui.Dump(); | |
248 | Fatal("AliMUONTriggerGUI","copy constructor not implemented"); | |
249 | ||
250 | } | |
251 | ||
252 | //__________________________________________________________________________ | |
253 | AliMUONTriggerGUI & AliMUONTriggerGUI::operator=(const AliMUONTriggerGUI& gui) | |
254 | { | |
255 | /// asignment operator | |
256 | ||
257 | gui.Dump(); | |
258 | Fatal("AliMUONTriggerGUI","assignment operator not implemented"); | |
259 | ||
260 | return *this; | |
261 | ||
262 | } | |
263 | ||
264 | //__________________________________________________________________________ | |
265 | void AliMUONTriggerGUI::HandleMenu(Int_t id) | |
266 | { | |
267 | /// handles entry numbers in the available menus (EMenuIdentifiers) | |
268 | ||
269 | TGCompositeFrame *runInput1, *runInput2, *runInput3; | |
270 | TGCompositeFrame *control1, *control2, *circuit1, *circuit2; | |
271 | TGLabel *runL1, *runL2, *circuitL1; | |
272 | TGTextEntry *runText1, *runText2, *circuitText1; | |
273 | TGTextButton *runApply, *runCancel; | |
274 | TGTextButton *controlClose, *nextEvent, *previousEvent, *skipToEvent; | |
275 | TGTextButton *circuitCancel, *circuitOpen; | |
276 | ||
277 | Int_t trigInfo[kNBoards*6] = {-1}; | |
278 | Int_t nLocalTrigger = 0; | |
279 | ||
280 | TString error = TString(""); | |
281 | if (id != kMFILEEXIT && id != kMFILERUN && fRunLoader == 0) { | |
282 | error.Append("Run not initialized (Menu: File/Run)"); | |
283 | DoErrorGUI(error.Data()); | |
284 | return; | |
285 | } | |
286 | ||
287 | switch (id) { | |
288 | ||
289 | case kMFILEEXIT: | |
290 | ||
291 | printf("\nBye. \n"); | |
292 | CloseWindow(); | |
293 | break; | |
294 | ||
295 | case kMFILERUN: | |
296 | ||
297 | // input main frame | |
298 | ||
299 | fRunInput = new TGTransientFrame(gClient->GetRoot(), fMain, 400, 200); | |
300 | fRunInput->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseRunInput()"); | |
301 | fRunInput->DontCallClose(); // to avoid double deletions. | |
302 | ||
303 | // use hierarchical cleaning | |
304 | fRunInput->SetCleanup(kDeepCleanup); | |
305 | ||
306 | fRunInput->SetWindowName("Input file and event number"); | |
307 | ||
308 | // input galice and event number frames | |
309 | ||
310 | runInput1 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame); | |
311 | runInput2 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame); | |
312 | ||
313 | // .. with labels | |
314 | ||
315 | runL1 = new TGLabel(runInput1, new TGString("Path to gAlice:")); | |
316 | runL2 = new TGLabel(runInput2, new TGString("Event number:")); | |
317 | ||
318 | // galice text entry | |
319 | ||
320 | runText1 = new TGTextEntry(runInput1, fTxtBuffer1 = new TGTextBuffer(100)); | |
321 | ||
322 | //fPath->Append("dset"); // temporary | |
323 | //fTxtBuffer1->AddText(0,fPath->Data()); // temporary | |
324 | ||
325 | runText1->SetToolTipText("Enter the path to galice.root"); | |
326 | runText1->Resize(300, runText1->GetDefaultHeight()); | |
327 | ||
328 | // event number text entry | |
329 | ||
330 | runText2 = new TGTextEntry(runInput2, fTxtBuffer2 = new TGTextBuffer(5)); | |
331 | ||
332 | fEvString->Form("%d",0); | |
333 | fTxtBuffer2->AddText(0,fEvString->Data()); | |
334 | ||
335 | runText2->SetToolTipText("Enter the first event number to start with"); | |
336 | runText2->Resize(300, runText2->GetDefaultHeight()); | |
337 | ||
338 | // add to galice frame | |
339 | ||
340 | runInput1->AddFrame(runL1, | |
341 | new TGLayoutHints(kLHintsLeft | | |
342 | kLHintsCenterY, | |
343 | 3, 5, 0, 0) | |
344 | ); | |
345 | ||
346 | runInput1->AddFrame(runText1, | |
347 | new TGLayoutHints(kLHintsRight | | |
348 | kLHintsCenterY, | |
349 | 0, 2, 0, 0) | |
350 | ); | |
351 | ||
352 | // add to event number frame | |
353 | ||
354 | runInput2->AddFrame(runL2, | |
355 | new TGLayoutHints(kLHintsLeft | | |
356 | kLHintsCenterY, | |
357 | 3, 5, 0, 0) | |
358 | ); | |
359 | ||
360 | runInput2->AddFrame(runText2, | |
361 | new TGLayoutHints(kLHintsRight | | |
362 | kLHintsCenterY, | |
363 | 0, 2, 0, 0) | |
364 | ); | |
365 | ||
366 | // add input frames to main input frame | |
367 | ||
368 | fRunInput->AddFrame(runInput1, | |
369 | new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0)); | |
370 | ||
371 | fRunInput->AddFrame(runInput2, | |
372 | new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0)); | |
373 | ||
374 | // frame with buttons | |
375 | ||
376 | runInput3 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame); | |
377 | ||
378 | // buttons | |
379 | ||
380 | runApply = new TGTextButton(runInput3, "Apply", 1); | |
381 | runApply->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunApply()"); | |
382 | runApply->SetToolTipText("Apply changes"); | |
383 | ||
384 | runCancel = new TGTextButton(runInput3, "Cancel", 2); | |
385 | runCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunCancel()"); runCancel->SetToolTipText("Cancel changes"); | |
386 | ||
387 | // add buttons | |
388 | ||
389 | runInput3->AddFrame(runApply, | |
390 | new TGLayoutHints(kLHintsTop | | |
391 | kLHintsLeft, | |
392 | 3, 3, 2, 2) | |
393 | ); | |
394 | ||
395 | runInput3->AddFrame(runCancel, | |
396 | new TGLayoutHints(kLHintsTop | | |
397 | kLHintsLeft, | |
398 | 3, 3, 2, 2) | |
399 | ); | |
400 | ||
401 | // add to the main input frame | |
402 | ||
403 | fRunInput->AddFrame(runInput3, | |
404 | new TGLayoutHints(kLHintsTop | | |
405 | kLHintsExpandX, | |
406 | 2, 2, 3, 0) | |
407 | ); | |
408 | ||
409 | fRunInput->MapSubwindows(); | |
410 | fRunInput->Resize(); | |
411 | fRunInput->MapWindow(); | |
412 | ||
413 | //DoRunApply(); // temporary | |
414 | ||
415 | break; | |
416 | ||
417 | case kMFILECNTRL: | |
418 | ||
419 | // control main frame | |
420 | ||
421 | fControl = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50); | |
422 | fControl->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseControl()"); | |
423 | fControl->DontCallClose(); // to avoid double deletions. | |
424 | ||
425 | // use hierarchical cleaning | |
426 | fControl->SetCleanup(kDeepCleanup); | |
427 | ||
428 | fControl->SetWindowName("Run controls"); | |
429 | ||
430 | // frame to hold buttons | |
431 | ||
432 | control1 = new TGCompositeFrame(fControl, 50, 50, kVerticalFrame); | |
433 | ||
434 | // buttons | |
435 | ||
436 | controlClose = new TGTextButton(control1, "Close", 1); | |
437 | controlClose->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoControlClose()"); | |
438 | //controlClose->Resize(300, controlClose->GetDefaultHeight()); | |
439 | ||
440 | nextEvent = new TGTextButton(control1, "Next event", 2); | |
441 | nextEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoNextEvent()"); | |
442 | ||
443 | previousEvent = new TGTextButton(control1, "Previous event", 3); | |
444 | previousEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoPreviousEvent()"); | |
445 | ||
446 | // frame to hold event skip | |
447 | ||
448 | control2 = new TGCompositeFrame(fControl, 50, 50, kHorizontalFrame); | |
449 | ||
450 | // skip to event text field | |
451 | ||
452 | fSkipToEventTxt = new TGTextEntry(control2, fTxtBuffer2 = new TGTextBuffer(5)); | |
453 | ||
454 | fTxtBuffer2->AddText(0,fEvString->Data()); | |
455 | ||
456 | // skip to event button | |
457 | ||
458 | skipToEvent = new TGTextButton(control2, "Skip to event", 1); | |
459 | skipToEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoSkipToEvent()"); | |
460 | ||
461 | // add to event skip frame | |
462 | ||
463 | control2->AddFrame(fSkipToEventTxt, | |
464 | new TGLayoutHints(kLHintsTop | | |
465 | kLHintsRight, | |
466 | 10, 10, 5, 5) | |
467 | ); | |
468 | ||
469 | control2->AddFrame(skipToEvent, | |
470 | new TGLayoutHints(kLHintsTop | | |
471 | kLHintsRight, | |
472 | 10, 10, 5, 5) | |
473 | ); | |
474 | ||
475 | // add buttons | |
476 | ||
477 | control1->AddFrame(controlClose, | |
478 | new TGLayoutHints(kLHintsBottom | | |
479 | kLHintsExpandX, | |
480 | 10, 10, 5, 5) | |
481 | ); | |
482 | ||
483 | control1->AddFrame(nextEvent, | |
484 | new TGLayoutHints(kLHintsBottom | | |
485 | kLHintsExpandX, | |
486 | 10, 10, 5, 5) | |
487 | ); | |
488 | ||
489 | control1->AddFrame(previousEvent, | |
490 | new TGLayoutHints(kLHintsBottom | | |
491 | kLHintsExpandX, | |
492 | 10, 10, 5, 5) | |
493 | ); | |
494 | ||
495 | // add to the main frame | |
496 | ||
497 | fControl->AddFrame(control1, | |
498 | new TGLayoutHints(kLHintsBottom | | |
499 | kLHintsLeft | | |
500 | kLHintsCenterY, | |
501 | 3, 5, 0, 0) | |
502 | ); | |
503 | ||
504 | fControl->AddFrame(control2, | |
505 | new TGLayoutHints(kLHintsTop | | |
506 | kLHintsCenterX, | |
507 | 3, 5, 0, 0) | |
508 | ); | |
509 | ||
510 | fControl->MapSubwindows(); | |
511 | fControl->Resize(); | |
512 | fControl->MapWindow(); | |
513 | ||
514 | break; | |
515 | ||
516 | case kMMAPDIGITS: | |
517 | ||
518 | if (fDiMap == 0) { | |
519 | fDiMap = new AliMUONTriggerGUIdimap(fLoader,fBoards,gClient->GetRoot(), fMain, 400, 200); | |
520 | } else if (!fDiMap->IsOn()) { | |
521 | fDiMap = new AliMUONTriggerGUIdimap(fLoader,fBoards,gClient->GetRoot(), fMain, 400, 200); | |
522 | } | |
523 | ||
524 | break; | |
525 | ||
526 | case kMRESETDIGITS: | |
527 | ||
528 | Int_t number, over, pos; | |
529 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
530 | AliMUONTriggerGUIboard *board = GetBoard(ib); | |
531 | board->ClearXDigits(); | |
532 | board->ClearYDigits(); | |
533 | // extended y-strips | |
534 | number = board->GetNumber(); | |
535 | pos = board->GetPosition(); | |
536 | over = board->GetYOver(); | |
537 | for (Int_t io = 1; io <= over; io++) { | |
538 | if (io == pos) continue; | |
539 | board = GetBoard(number+io-pos); | |
540 | board->ClearYDigits(); | |
541 | } | |
542 | } | |
543 | ||
544 | break; | |
545 | ||
546 | case kMCIRCUITOPEN: | |
547 | ||
548 | fCircuit = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50); | |
549 | fCircuit->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseCircuit()"); | |
550 | fCircuit->DontCallClose(); // to avoid double deletions. | |
551 | ||
552 | // use hierarchical cleaning | |
553 | fCircuit->SetCleanup(kDeepCleanup); | |
554 | ||
555 | fCircuit->SetWindowName("Board circuit"); | |
556 | ||
557 | // sub-frames | |
558 | ||
559 | circuit1 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame); | |
560 | circuit2 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame); | |
561 | ||
562 | // labels | |
563 | ||
564 | circuitL1 = new TGLabel(circuit1, new TGString("Circuit number:")); | |
565 | ||
566 | // text entry | |
567 | ||
568 | circuitText1 = new TGTextEntry(circuit1, fTxtCircuit = new TGTextBuffer(10)); | |
569 | // buttons | |
570 | ||
571 | circuitCancel = new TGTextButton(circuit2, "Cancel", 1); | |
572 | circuitCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitCancel()"); | |
573 | //circuitCancel->Resize(100, circuitCancel->GetDefaultHeight()); | |
574 | ||
575 | circuitOpen = new TGTextButton(circuit2, "Open", 2); | |
576 | circuitOpen->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitOpen()"); | |
577 | //circuitOpen->Resize(100, circuitOpen->GetDefaultHeight()); | |
578 | ||
579 | // adding | |
580 | ||
581 | circuit1->AddFrame(circuitL1, | |
582 | new TGLayoutHints(kLHintsLeft | | |
583 | kLHintsCenterY, | |
584 | 5, 5, 2, 2) | |
585 | ); | |
586 | ||
587 | circuit1->AddFrame(circuitText1, | |
588 | new TGLayoutHints(kLHintsRight | | |
589 | kLHintsCenterY, | |
590 | 0, 2, 2, 2) | |
591 | ); | |
592 | ||
593 | circuit2->AddFrame(circuitCancel, | |
594 | new TGLayoutHints(kLHintsBottom | | |
595 | kLHintsCenterY, | |
596 | 5, 5, 2, 2) | |
597 | ); | |
598 | ||
599 | circuit2->AddFrame(circuitOpen, | |
600 | new TGLayoutHints(kLHintsBottom | | |
601 | kLHintsCenterY, | |
602 | 5, 5, 2, 2) | |
603 | ); | |
604 | ||
605 | fCircuit->AddFrame(circuit1, | |
606 | new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0)); | |
607 | ||
608 | fCircuit->AddFrame(circuit2, | |
609 | new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0)); | |
610 | ||
611 | fCircuit->MapSubwindows(); | |
612 | fCircuit->Resize(); | |
613 | fCircuit->MapWindow(); | |
614 | ||
615 | break; | |
616 | ||
617 | case kMTRIGGERDSET: | |
618 | ||
619 | //cout << "Trigger with fMUONData digits....." << endl; | |
620 | /* | |
621 | fMUONData->SetTreeAddress("D"); | |
622 | fMUONData->GetDigits(); | |
623 | fTriggerProcessor = new AliMUONTriggerElectronics(fMUONData,fCalibrationData); | |
624 | fTriggerProcessor->FeedM(); | |
625 | */ | |
626 | cout << "Trigger with boards digits....." << endl; | |
627 | fTriggerProcessor->FeedBoardsGUI(Boards()); | |
628 | ||
629 | nLocalTrigger = fTriggerProcessor->TriggerGUI(trigInfo,kTRUE); | |
630 | ||
631 | cout << "Trigger done with " << nLocalTrigger << " local decisions !" << endl; | |
632 | ||
633 | for (Int_t ilo = 0; ilo < nLocalTrigger; ilo++) { | |
634 | ||
635 | cout << "Local decision " << ilo << endl; | |
636 | cout << "Circuit = " << trigInfo[6*ilo+0] << endl; | |
637 | cout << "LoStripX = " << trigInfo[6*ilo+1] << endl; | |
638 | cout << "LoStripY = " << trigInfo[6*ilo+2] << endl; | |
639 | cout << "LoDev = " << trigInfo[6*ilo+3] << endl; | |
640 | cout << "LoLpt = " << trigInfo[6*ilo+4] << endl; | |
641 | cout << "LoHpt = " << trigInfo[6*ilo+5] << endl; | |
642 | cout << endl; | |
643 | } | |
644 | ||
645 | break; | |
646 | ||
647 | default: | |
648 | printf("Menu item %d selected\n", id); | |
649 | break; | |
650 | ||
651 | } | |
652 | ||
653 | } | |
654 | ||
655 | //__________________________________________________________________________ | |
656 | void AliMUONTriggerGUI::CloseRunInput() const | |
657 | { | |
658 | /// close the run input frame | |
659 | ||
660 | delete fRunInput; | |
661 | ||
662 | } | |
663 | ||
664 | //__________________________________________________________________________ | |
665 | void AliMUONTriggerGUI::CloseError() const | |
666 | { | |
667 | /// close the error frame | |
668 | ||
669 | delete fError; | |
670 | ||
671 | } | |
672 | ||
673 | //__________________________________________________________________________ | |
674 | void AliMUONTriggerGUI::CloseControl() const | |
675 | { | |
676 | /// close the event control frame | |
677 | ||
678 | delete fControl; | |
679 | ||
680 | //gSystem->Exec("cd $PWD/mtrun; aliroot -b -q mtsim.C"); | |
681 | ||
682 | } | |
683 | ||
684 | //__________________________________________________________________________ | |
685 | void AliMUONTriggerGUI::CloseCircuit() const | |
686 | { | |
687 | /// close the circuit frame | |
688 | ||
689 | delete fCircuit; | |
690 | ||
691 | } | |
692 | ||
693 | //__________________________________________________________________________ | |
694 | void AliMUONTriggerGUI::CloseWindow() | |
695 | { | |
696 | /// close the main frame and exit aplication | |
697 | ||
698 | delete fRunLoader; | |
699 | printf("\n"); | |
700 | gApplication->Terminate(); | |
701 | ||
702 | } | |
703 | ||
704 | //__________________________________________________________________________ | |
705 | void AliMUONTriggerGUI::DoRunApply() | |
706 | { | |
707 | /// apply changes in the run control frame | |
708 | ||
709 | printf("Input 1 = %s \n",fTxtBuffer1->GetString()); | |
710 | ||
711 | TString es = TString(fTxtBuffer2->GetString()); | |
712 | fEvent = es.Atoi(); | |
713 | ||
714 | printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent); | |
715 | ||
716 | TString error = TString("");; | |
717 | ||
718 | fPath->Form("%s",fTxtBuffer1->GetString()); | |
719 | fFileName->Form("%s",fTxtBuffer1->GetString()); | |
720 | printf("File location: %s \n",fFileName->Data()); | |
721 | ||
722 | if (gSystem->AccessPathName(fFileName->Data()) || !fFileName->EndsWith(".root")) { | |
723 | ||
724 | error.Append("No galice file: "); | |
725 | error.Append(fFileName->Data()); | |
726 | DoErrorGUI(error.Data()); | |
727 | ||
728 | } else { | |
729 | ||
730 | TFile *ftest = new TFile(fFileName->Data(),"READ"); | |
731 | AliRun *galice = (AliRun*)ftest->Get("gAlice"); | |
732 | if (galice == 0) { | |
733 | ||
734 | ftest->Close(); | |
735 | delete ftest; | |
736 | ||
737 | error.Append("No gAlice in file: "); | |
738 | error.Append(fFileName->Data()); | |
739 | DoErrorGUI(error.Data()); | |
740 | ||
741 | return; | |
742 | ||
743 | } else { | |
744 | ftest->Close(); | |
745 | delete ftest; | |
746 | } | |
747 | ||
748 | if (fRunLoader) delete fRunLoader; | |
749 | ||
750 | fRunLoader = AliRunLoader::Open(fFileName->Data(),"MUONFolder","READ"); | |
751 | ||
752 | if (fRunLoader == 0x0) { | |
753 | ||
754 | DoErrorGUI("No run loader !"); | |
755 | ||
756 | } else { | |
757 | ||
758 | fRunLoader->LoadgAlice(); | |
759 | gAlice = fRunLoader->GetAliRun(); | |
760 | fEventsPerRun = gAlice->GetEventsPerRun(); | |
761 | ||
762 | fLoader = fRunLoader->GetLoader("MUONLoader"); | |
763 | fLoader->LoadDigits("READ"); | |
764 | fRunLoader->GetEvent(fEvent); | |
765 | ||
766 | fRunInput->SendCloseMessage(); | |
767 | ||
768 | if (!fBoardsInit) { | |
769 | InitBoards(); | |
770 | } | |
771 | ||
772 | if (fDiMap) { | |
773 | if (fDiMap->IsOn()) { | |
774 | fDiMap->SetLoader(fLoader); | |
775 | } | |
776 | } | |
777 | ||
778 | fMUONData = new AliMUONData(fLoader,"MUON","MUON"); | |
779 | fMUONData->SetTreeAddress("D,GLT"); | |
780 | ||
781 | fTriggerProcessor = new AliMUONTriggerElectronics(0,fCalibrationData); | |
782 | /* | |
783 | fRunLoader->LoadKinematics(); | |
784 | ||
785 | AliStack* stack = gAlice->Stack(); | |
786 | Int_t nParticles = stack->GetNtrack(); | |
787 | Int_t nPrimaries = stack->GetNprimary(); | |
788 | ||
789 | TParticle *part; | |
790 | Int_t nMuons = 0; | |
791 | Int_t pdgCode; | |
792 | Double_t px, py, pz, theta, phi; | |
793 | for (Int_t i = 0; i < nPrimaries; i++) { | |
794 | part = stack->Particle(i); | |
795 | if (!part) continue; | |
796 | if (TMath::Abs(part->GetPdgCode()) == 13) { | |
797 | nMuons++; | |
798 | pdgCode = part->GetPdgCode(); | |
799 | px = part->Px(); | |
800 | py = part->Py(); | |
801 | pz = part->Pz(); | |
802 | theta = part->Theta(); | |
803 | phi = part->Phi(); | |
804 | printf("Kine %d px %f py %f pz %f th %f ph %f \n",pdgCode,px,py,pz,theta,phi); | |
805 | } | |
806 | } | |
807 | */ | |
808 | } | |
809 | ||
810 | } | |
811 | ||
812 | } | |
813 | ||
814 | //__________________________________________________________________________ | |
815 | void AliMUONTriggerGUI::DoRunCancel() | |
816 | { | |
817 | /// cancel the changes in the run control frame | |
818 | ||
819 | printf("Input 1 = %s \n",fTxtBuffer1->GetString()); | |
820 | ||
821 | TString es = TString(fTxtBuffer2->GetString()); | |
822 | fEvent = es.Atoi(); | |
823 | ||
824 | printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent); | |
825 | ||
826 | fRunInput->SendCloseMessage(); | |
827 | ||
828 | } | |
829 | ||
830 | //__________________________________________________________________________ | |
831 | void AliMUONTriggerGUI::DoErrorGUI(const Char_t *wt) | |
832 | { | |
833 | /// show an error message in a new frame | |
834 | ||
835 | fError = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50); | |
836 | fError->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseError()"); | |
837 | fError->DontCallClose(); // to avoid double deletions. | |
838 | ||
839 | // use hierarchical cleaning | |
840 | fError->SetCleanup(kDeepCleanup); | |
841 | ||
842 | fError->SetWindowName("Error !"); | |
843 | ||
844 | TGCompositeFrame *fW = new TGCompositeFrame(fError, 50, 50, kVerticalFrame); | |
845 | ||
846 | TGTextButton *fErrorOK = new TGTextButton(fW, "&Ok", 1); | |
847 | fErrorOK->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoErrorOK()"); | |
848 | ||
849 | fW->AddFrame(fErrorOK, | |
850 | new TGLayoutHints(kLHintsBottom | | |
851 | kLHintsCenterX, | |
852 | 5, 5, 5, 5) | |
853 | ); | |
854 | ||
855 | TGLabel *fWL = new TGLabel(fW, new TGString(wt)); | |
856 | ||
857 | fW->AddFrame(fWL, | |
858 | new TGLayoutHints(kLHintsTop | | |
859 | kLHintsCenterX, | |
860 | 5, 5, 5, 5) | |
861 | ); | |
862 | ||
863 | fError->AddFrame(fW, | |
864 | new TGLayoutHints(kLHintsLeft | | |
865 | kLHintsCenterY, | |
866 | 5, 5, 5, 5) | |
867 | ); | |
868 | ||
869 | fError->MapSubwindows(); | |
870 | fError->Resize(); | |
871 | fError->MapWindow(); | |
872 | ||
873 | } | |
874 | ||
875 | //__________________________________________________________________________ | |
876 | void AliMUONTriggerGUI::DoNextEvent() | |
877 | { | |
878 | /// load next event from the file | |
879 | ||
880 | TString error = TString(""); | |
881 | ||
882 | if (fEvent < (fEventsPerRun-1)) { | |
883 | fEvent++; | |
884 | fRunLoader->GetEvent(fEvent); | |
885 | ||
886 | fEvString->Form("%d",fEvent); | |
887 | fTxtBuffer2->RemoveText(0,5); | |
888 | fTxtBuffer2->AddText(0,fEvString->Data()); | |
889 | fSkipToEventTxt->SetFocus(); | |
890 | ||
891 | } else { | |
892 | error.Form("Only %d event(s) in the run !",fEventsPerRun); | |
893 | DoErrorGUI(error.Data()); | |
894 | } | |
895 | ||
896 | } | |
897 | ||
898 | //__________________________________________________________________________ | |
899 | void AliMUONTriggerGUI::DoPreviousEvent() | |
900 | { | |
901 | /// load previous event from the input file | |
902 | ||
903 | TString error = TString(""); | |
904 | ||
905 | if (fEvent > 0) { | |
906 | fEvent--; | |
907 | fRunLoader->GetEvent(fEvent); | |
908 | ||
909 | fEvString->Form("%d",fEvent); | |
910 | fTxtBuffer2->RemoveText(0,5); | |
911 | fTxtBuffer2->AddText(0,fEvString->Data()); | |
912 | fSkipToEventTxt->SetFocus(); | |
913 | ||
914 | } else { | |
915 | error.Form("Already at event 0 !"); | |
916 | DoErrorGUI(error.Data()); | |
917 | } | |
918 | ||
919 | } | |
920 | ||
921 | //__________________________________________________________________________ | |
922 | void AliMUONTriggerGUI::DoSkipToEvent() | |
923 | { | |
924 | /// skip to event -input- from the input file | |
925 | ||
926 | TString error = TString(""); | |
927 | ||
928 | TString es = TString(fTxtBuffer2->GetString()); | |
929 | fEvent = es.Atoi(); | |
930 | ||
931 | if (fEvent < 0 || fEvent > (fEventsPerRun-1)) { | |
932 | error.Form("Event number out of range !"); | |
933 | DoErrorGUI(error.Data()); | |
934 | } else { | |
935 | fRunLoader->GetEvent(fEvent); | |
936 | /* | |
937 | fRunLoader->LoadKinematics(); | |
938 | ||
939 | AliStack* stack = gAlice->Stack(); | |
940 | Int_t nParticles = stack->GetNtrack(); | |
941 | Int_t nPrimaries = stack->GetNprimary(); | |
942 | ||
943 | TParticle *part; | |
944 | Int_t nMuons = 0; | |
945 | Int_t pdgCode; | |
946 | Double_t px, py, pz, theta, phi; | |
947 | for (Int_t i = 0; i < nPrimaries; i++) { | |
948 | part = stack->Particle(i); | |
949 | if (!part) continue; | |
950 | if (TMath::Abs(part->GetPdgCode()) == 13) { | |
951 | nMuons++; | |
952 | pdgCode = part->GetPdgCode(); | |
953 | px = part->Px(); | |
954 | py = part->Py(); | |
955 | pz = part->Pz(); | |
956 | theta = part->Theta(); | |
957 | phi = part->Phi(); | |
958 | printf("Kine %d px %f py %f pz %f th %f ph %f \n",pdgCode,px,py,pz,theta,phi); | |
959 | } | |
960 | } | |
961 | */ | |
962 | } | |
963 | ||
964 | } | |
965 | ||
966 | //__________________________________________________________________________ | |
967 | void AliMUONTriggerGUI::DoErrorOK() | |
968 | { | |
969 | /// close the error frame | |
970 | ||
971 | fError->SendCloseMessage(); | |
972 | ||
973 | } | |
974 | ||
975 | //__________________________________________________________________________ | |
976 | void AliMUONTriggerGUI::DoControlClose() | |
977 | { | |
978 | /// close the event control frame | |
979 | ||
980 | fControl->SendCloseMessage(); | |
981 | ||
982 | } | |
983 | ||
984 | //__________________________________________________________________________ | |
985 | void AliMUONTriggerGUI::DoCircuitCancel() | |
986 | { | |
987 | /// close the circuit frame | |
988 | ||
989 | fCircuit->SendCloseMessage(); | |
990 | ||
991 | } | |
992 | ||
993 | //__________________________________________________________________________ | |
994 | void AliMUONTriggerGUI::DoCircuitOpen() | |
995 | { | |
996 | /// open a circuit | |
997 | ||
998 | TString cs = TString(fTxtCircuit->GetString()); | |
999 | Int_t icirc = cs.Atoi(); | |
1000 | ||
1001 | AliMUONTriggerGUIboard *board; | |
1002 | ||
1003 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1004 | ||
1005 | board = GetBoard(ib); | |
1006 | ||
1007 | if (board->GetIdCircuit() == icirc) { | |
1008 | ||
1009 | OpenBoard(ib); | |
1010 | ||
1011 | if (fDiMap) { | |
1012 | if (fDiMap->IsOn()) { | |
1013 | fDiMap->SelectBoard(ib); | |
1014 | } | |
1015 | } | |
1016 | ||
1017 | fCircuit->SendCloseMessage(); | |
1018 | return; | |
1019 | } | |
1020 | ||
1021 | } | |
1022 | ||
1023 | } | |
1024 | ||
1025 | //__________________________________________________________________________ | |
1026 | AliMUONTriggerGUIboard* AliMUONTriggerGUI::GetBoard(Int_t id) const | |
1027 | { | |
1028 | /// return board with "id" | |
1029 | ||
1030 | if (fBoards == 0) return 0; | |
1031 | void * b = fBoards->UncheckedAt(id); | |
1032 | if (b == 0) return 0; | |
1033 | ||
1034 | return (AliMUONTriggerGUIboard*)b; | |
1035 | ||
1036 | } | |
1037 | ||
1038 | //__________________________________________________________________________ | |
1039 | void AliMUONTriggerGUI::OpenBoard(Int_t id) | |
1040 | { | |
1041 | /// open board with "id" in a new frame | |
1042 | ||
1043 | AliMUONTriggerGUIboard *board = GetBoard(id); | |
1044 | UShort_t status = board->GetStatus(); | |
1045 | board->SetOpen(kTRUE); | |
1046 | ||
1047 | AliMUONTriggerGUIbdmap *bf; | |
1048 | Char_t text[200]; | |
1049 | ||
1050 | bf = new AliMUONTriggerGUIbdmap(gClient->GetRoot(), fMain, 400, 200); | |
1051 | ||
1052 | if (status & kGood) { | |
1053 | sprintf(text,"%s (Circuit %4d) status : working", | |
1054 | board->GetBoardName(),board->GetIdCircuit()); | |
1055 | } | |
1056 | ||
1057 | if (status & kWithProblems) { | |
1058 | sprintf(text,"%s (Circuit %4d) status : has problems...", | |
1059 | board->GetBoardName(),board->GetIdCircuit()); | |
1060 | } | |
1061 | ||
1062 | if (status & kNotWorking) { | |
1063 | sprintf(text,"%s (Circuit %4d) status : not working", | |
1064 | board->GetBoardName(),board->GetIdCircuit()); | |
1065 | } | |
1066 | ||
1067 | if (status & kUnknown) { | |
1068 | sprintf(text,"%s (Circuit %4d) status : unknown", | |
1069 | board->GetBoardName(),board->GetIdCircuit()); | |
1070 | } | |
1071 | ||
1072 | bf->SetName(text); | |
1073 | bf->SetBoard(Boards(),id); | |
1074 | bf->SetLoader(fLoader); | |
1075 | bf->Init(); | |
1076 | ||
1077 | bf->Show(); | |
1078 | ||
1079 | if (fDiMap) { | |
1080 | if (fDiMap->IsOn()) { | |
1081 | fDiMap->SelectBoard(id); | |
1082 | } | |
1083 | } | |
1084 | ||
1085 | } | |
1086 | ||
1087 | //__________________________________________________________________________ | |
1088 | void AliMUONTriggerGUI::Init() | |
1089 | { | |
1090 | /// initialize the main GUI frame | |
1091 | ||
1092 | if (!fBoardsInit) { | |
1093 | InitBoards(); | |
1094 | } | |
1095 | ||
1096 | /* | |
1097 | AliMUONTriggerGUIboard *board; | |
1098 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1099 | board = GetBoard(ib); | |
1100 | board->Dump(); | |
1101 | } | |
1102 | */ | |
1103 | } | |
1104 | ||
1105 | //__________________________________________________________________________ | |
1106 | void AliMUONTriggerGUI::InitBoards() | |
1107 | { | |
1108 | /// create board objects and define the sensitive regions in the image map | |
1109 | ||
1110 | fBoardsInit = kTRUE; | |
1111 | ||
1112 | AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore(); | |
1113 | crateManager->ReadFromFile(); | |
1114 | ||
1115 | Int_t nPixelX = 700; | |
1116 | Int_t nPixelY = 676; | |
1117 | ||
1118 | Int_t nPixelBorderX = 40; // to guess... | |
1119 | Int_t nPixelBorderY = 40; // to guess... | |
1120 | ||
1121 | Float_t boardsX = 2*257.00; // cm | |
1122 | Float_t boardsY = 2*306.61; // cm | |
1123 | ||
1124 | FILE *fmap; | |
1125 | ||
1126 | Int_t side, col, line, nbx, detElemId = 0; | |
1127 | UShort_t status = 1; | |
1128 | Float_t xCenter, yCenter, zCenter, xWidth, yWidth; | |
1129 | Float_t xc, yc; | |
1130 | Char_t name[8], text[200]; | |
1131 | Int_t x, y; | |
1132 | UInt_t w, h; | |
1133 | Int_t xp[5]; | |
1134 | Int_t yp[5]; | |
1135 | TString mapspath = gSystem->Getenv("ALICE_ROOT"); | |
1136 | mapspath.Append("/MUON/data"); | |
1137 | ||
1138 | TGRegion *reg; | |
1139 | AliMUONTriggerGUIboard *board; | |
1140 | ||
1141 | // regions for the image map | |
1142 | ||
1143 | sprintf(text,"%s/guimapp11.txt",mapspath.Data()); | |
1144 | fmap = fopen(text,"r"); | |
1145 | ||
1146 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1147 | ||
1148 | fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]); | |
1149 | ||
1150 | //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name); | |
1151 | ||
1152 | board = new AliMUONTriggerGUIboard(ib,name); | |
1153 | ||
1154 | status = 1; | |
1155 | board->SetStatus(status); | |
1156 | ||
1157 | // calculate detElemId%100 | |
1158 | // side=0 left | |
1159 | // side=1 right | |
1160 | // ALICE SC | |
1161 | if (side == 0) detElemId = 14 - line; | |
1162 | if (side == 1 && line < 5) detElemId = 13 + line; | |
1163 | if (side == 1 && line >= 5) detElemId = line - 5; | |
1164 | ||
1165 | board->SetDetElemId(detElemId); | |
1166 | ||
1167 | Boards()->Add(board); | |
1168 | ||
1169 | xc = xCenter; | |
1170 | yc = yCenter; | |
1171 | ||
1172 | x = (Int_t)(nPixelX/2 + xc * (nPixelX - 2*nPixelBorderX)/boardsX); | |
1173 | y = (Int_t)(nPixelY/2 - yc * (nPixelY - 2*nPixelBorderY)/boardsY); | |
1174 | ||
1175 | if (x < 0) x = 0; | |
1176 | if (y < 0) y = 0; | |
1177 | ||
1178 | w = (UInt_t)(xWidth*(nPixelX-2*nPixelBorderX)/boardsX); | |
1179 | h = (UInt_t)(yWidth*(nPixelY-2*nPixelBorderY)/boardsY); | |
1180 | ||
1181 | xp[0] = x-w/2; | |
1182 | xp[1] = x+w/2; | |
1183 | xp[2] = x+w/2; | |
1184 | xp[3] = x-w/2; | |
1185 | xp[4] = x-w/2; | |
1186 | ||
1187 | yp[0] = y-h/2; | |
1188 | yp[1] = y-h/2; | |
1189 | yp[2] = y+h/2; | |
1190 | yp[3] = y+h/2; | |
1191 | yp[4] = y-h/2; | |
1192 | ||
1193 | reg = new TGRegion(5,xp,yp); | |
1194 | fImageMap->AddRegion(*reg, ib); | |
1195 | ||
1196 | if (status & kGood) { | |
1197 | sprintf(text,"%s working",name); | |
1198 | } | |
1199 | if (status & kWithProblems) { | |
1200 | sprintf(text,"%s has problems...",name); | |
1201 | } | |
1202 | if (status & kNotWorking) { | |
1203 | sprintf(text,"%s not working",name); | |
1204 | } | |
1205 | if (status & kUnknown) { | |
1206 | sprintf(text,"%s status unknown",name); | |
1207 | } | |
1208 | ||
1209 | //fImageMap->SetToolTipText(ib, text); | |
1210 | ||
1211 | } | |
1212 | ||
1213 | fclose(fmap); | |
1214 | ||
1215 | // MT position and dimension in board | |
1216 | ||
1217 | for (Int_t imt = 0; imt < kNMT; imt++) { | |
1218 | ||
1219 | sprintf(text,"%s/guimapp%2d.txt",mapspath.Data(),11+imt); | |
1220 | ||
1221 | fmap = fopen(text,"r"); | |
1222 | ||
1223 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1224 | ||
1225 | fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]); | |
1226 | ||
1227 | board = GetBoard(ib); | |
1228 | board->SetDimensions(imt,xCenter,yCenter,zCenter,xWidth,yWidth); | |
1229 | ||
1230 | } | |
1231 | ||
1232 | fclose(fmap); | |
1233 | ||
1234 | } | |
1235 | ||
1236 | // MT x-strips indices and circuit number | |
1237 | Int_t ix, iy1, iy2, sIx, sIy1, cathode, icirc; | |
1238 | sprintf(text,"%s/guimapix11.txt",mapspath.Data()); | |
1239 | ||
1240 | fmap = fopen(text,"r"); | |
1241 | ||
1242 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1243 | ||
1244 | fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix,&iy1,&iy2,&name[0]); | |
1245 | ||
1246 | board = GetBoard(ib); | |
1247 | board->SetXSindex(ix,iy1,iy2); | |
1248 | ||
1249 | // set the circuit number | |
1250 | detElemId = board->GetDetElemId(); | |
1251 | detElemId += 100 * 11; | |
1252 | cathode = 0; | |
1253 | sIx = board->GetXSix(); | |
1254 | sIy1 = board->GetXSiy1(); | |
1255 | const AliMpVSegmentation* seg = | |
1256 | AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode)); | |
1257 | ||
1258 | AliMpPad pad = seg->PadByIndices(AliMpIntPair(sIx,sIy1),kTRUE); | |
1259 | AliMpIntPair location = pad.GetLocation(0); | |
1260 | ||
1261 | Int_t nboard = location.GetFirst(); | |
1262 | AliMUONLocalTriggerBoard* b = crateManager->LocalBoard(nboard); | |
1263 | icirc = b->GetNumber(); | |
1264 | board->SetBoardName((Char_t*)b->GetName()); | |
1265 | board->SetIdCircuit(icirc); | |
1266 | ||
1267 | TString crateName = b->GetCrate(); | |
1268 | ||
1269 | sprintf(text,"%s (crate %s circuit %3d, number %3d)",board->GetBoardName(),crateName.Data(),icirc,ib); | |
1270 | fImageMap->SetToolTipText(ib, text); | |
1271 | ||
1272 | } | |
1273 | ||
1274 | fclose(fmap); | |
1275 | ||
1276 | // MT y-strips indices | |
1277 | Int_t ix1, ix2, iy; | |
1278 | ||
1279 | sprintf(text,"%s/guimapiy11.txt",mapspath.Data()); | |
1280 | ||
1281 | fmap = fopen(text,"r"); | |
1282 | ||
1283 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1284 | ||
1285 | fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix1,&ix2,&iy,&name[0]); | |
1286 | ||
1287 | board = GetBoard(ib); | |
1288 | board->SetYSindex(ix1,ix2,iy); | |
1289 | ||
1290 | } | |
1291 | ||
1292 | fclose(fmap); | |
1293 | ||
1294 | // Extended y-strips over neighbouring boards | |
1295 | ||
1296 | sprintf(text,"%s/guimapp11.txt",mapspath.Data()); | |
1297 | ||
1298 | fmap = fopen(text,"r"); | |
1299 | ||
1300 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1301 | ||
1302 | fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]); | |
1303 | ||
1304 | board = GetBoard(ib); | |
1305 | ||
1306 | board->SetPosition(nbx); | |
1307 | ||
1308 | if ((col == 2 || col == 3) && (line >= 4 && line <= 6)) { | |
1309 | board->SetYOver(4); | |
1310 | } else | |
1311 | ||
1312 | if (col == 1 && (line == 4 || line == 6)) { | |
1313 | board->SetYOver(3); | |
1314 | } else | |
1315 | ||
1316 | if (col == 7 || line == 1 || line == 9) { | |
1317 | board->SetYOver(1); | |
1318 | } else | |
1319 | ||
1320 | { | |
1321 | board->SetYOver(2); | |
1322 | } | |
1323 | ||
1324 | } | |
1325 | ||
1326 | fclose(fmap); | |
1327 | ||
1328 | // Set coordinates of strips boxes | |
1329 | ||
1330 | for (Int_t ib = 0; ib < kNBoards; ib++) { | |
1331 | ||
1332 | board = GetBoard(ib); | |
1333 | SetStripBoxes(board); | |
1334 | ||
1335 | } | |
1336 | ||
1337 | } | |
1338 | ||
1339 | //__________________________________________________________________________ | |
1340 | void AliMUONTriggerGUI::SetStripBoxes(AliMUONTriggerGUIboard *board) | |
1341 | { | |
1342 | /// set coordinates of strip boxes | |
1343 | ||
1344 | gAlice = fRunLoader->GetAliRun(); | |
1345 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
1346 | const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer(); | |
1347 | ||
1348 | const AliMpVSegmentation* seg; | |
1349 | AliMpPad pad; | |
1350 | AliMpDEIterator it; | |
1351 | ||
1352 | Int_t chamber, detElemId, maxX, maxY, ic; | |
1353 | Float_t xpmin, xpmax, ypmin, ypmax; | |
1354 | Float_t xg1, xg2, yg1, yg2, zg1; | |
1355 | Float_t xlocal1, xlocal2, ylocal1, ylocal2; | |
1356 | Float_t xCenter, yCenter, xWidth, yWidth; | |
1357 | ||
1358 | for (Int_t i = 0; i < kNMT; i++) { | |
1359 | ||
1360 | chamber = 11+i; | |
1361 | ||
1362 | xCenter = board->GetXCenter(i); | |
1363 | yCenter = board->GetYCenter(i); | |
1364 | xWidth = board->GetXWidth(i); | |
1365 | yWidth = board->GetYWidth(i); | |
1366 | ||
1367 | for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) { | |
1368 | ||
1369 | detElemId = it.CurrentDEId(); | |
1370 | ||
1371 | if (detElemId%100 != board->GetDetElemId()) continue; | |
1372 | ||
1373 | /*---------- y-pads ic = 2 ----------*/ | |
1374 | ic = 2; | |
1375 | ||
1376 | seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1)); | |
1377 | ||
1378 | maxX = seg->MaxPadIndexX(); | |
1379 | maxY = seg->MaxPadIndexY(); | |
1380 | ||
1381 | for (Int_t ix = 0; ix <= maxX; ix++) { | |
1382 | for (Int_t iy = 0; iy <= maxY; iy++) { | |
1383 | ||
1384 | pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE); | |
1385 | ||
1386 | if (!pad.IsValid()) continue; | |
1387 | ||
1388 | // get the pad position and dimensions | |
1389 | xlocal1 = pad.Position().X(); | |
1390 | ylocal1 = pad.Position().Y(); | |
1391 | xlocal2 = pad.Dimensions().X(); | |
1392 | ylocal2 = pad.Dimensions().Y(); | |
1393 | ||
1394 | kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1); | |
1395 | // (no transformation for pad dimensions) | |
1396 | xg2 = xlocal2; | |
1397 | yg2 = ylocal2; | |
1398 | ||
1399 | // transform in the monitor coordinate system | |
1400 | //xpmin = -(xg1+xg2); | |
1401 | //xpmax = -(xg1-xg2); | |
1402 | //ypmin = -(yg2-yg1); | |
1403 | //ypmax = +(yg2+yg1); | |
1404 | // ALICE SC | |
1405 | xpmin = +(xg1-xg2); | |
1406 | xpmax = +(xg1+xg2); | |
1407 | ypmin = -(yg2-yg1); | |
1408 | ypmax = +(yg2+yg1); | |
1409 | ||
1410 | xpmin -= xCenter; | |
1411 | xpmax -= xCenter; | |
1412 | ypmin -= yCenter; | |
1413 | ypmax -= yCenter; | |
1414 | ||
1415 | Int_t iX1, iX2, iY, ixDig; | |
1416 | iX1 = board->GetYSix1(); | |
1417 | iX2 = board->GetYSix2(); | |
1418 | iY = board->GetYSiy(); | |
1419 | if (ix >= iX1 && ix <= iX2 && iy == iY) { | |
1420 | ||
1421 | ypmin = -0.5*yWidth; | |
1422 | ypmax = +0.5*yWidth; | |
1423 | ||
1424 | ixDig = ix - iX1; | |
1425 | ||
1426 | board->SetYDigBox(i,ixDig,(Double_t)xpmin,(Double_t)ypmin, | |
1427 | (Double_t)xpmax,(Double_t)ypmax); | |
1428 | ||
1429 | } | |
1430 | ||
1431 | } // end maxY | |
1432 | } // end maxX | |
1433 | ||
1434 | /*---------- x-pads ic = 1 ----------*/ | |
1435 | ic = 1; | |
1436 | ||
1437 | seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1)); | |
1438 | ||
1439 | maxX = seg->MaxPadIndexX(); | |
1440 | maxY = seg->MaxPadIndexY(); | |
1441 | ||
1442 | for (Int_t ix = 0; ix <= maxX; ix++) { | |
1443 | for (Int_t iy = 0; iy <= maxY; iy++) { | |
1444 | ||
1445 | pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE); | |
1446 | ||
1447 | if (!pad.IsValid()) continue; | |
1448 | ||
1449 | // get the pad position and dimensions | |
1450 | xlocal1 = pad.Position().X(); | |
1451 | ylocal1 = pad.Position().Y(); | |
1452 | xlocal2 = pad.Dimensions().X(); | |
1453 | ylocal2 = pad.Dimensions().Y(); | |
1454 | ||
1455 | kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1); | |
1456 | // (no transformation for pad dimensions) | |
1457 | xg2 = xlocal2; | |
1458 | yg2 = ylocal2; | |
1459 | ||
1460 | // transform in the monitor coordinate system | |
1461 | //xpmin = -(xg1+xg2); | |
1462 | //xpmax = -(xg1-xg2); | |
1463 | //ypmin = -(yg2-yg1); | |
1464 | //ypmax = +(yg2+yg1); | |
1465 | // ALICE SC | |
1466 | xpmin = +(xg1+xg2); | |
1467 | xpmax = +(xg1-xg2); | |
1468 | ypmin = -(yg2-yg1); | |
1469 | ypmax = +(yg2+yg1); | |
1470 | ||
1471 | xpmin -= xCenter; | |
1472 | xpmax -= xCenter; | |
1473 | ypmin -= yCenter; | |
1474 | ypmax -= yCenter; | |
1475 | ||
1476 | Int_t iX, iY1, iY2, iyDig; | |
1477 | iX = board->GetXSix(); | |
1478 | iY1 = board->GetXSiy1(); | |
1479 | iY2 = board->GetXSiy2(); | |
1480 | if (ix == iX && iy >= iY1 && iy <= iY2) { | |
1481 | ||
1482 | iyDig = iy - iY1; | |
1483 | ||
1484 | board->SetXDigBox(i,iyDig,(Double_t)xpmin,(Double_t)ypmin, | |
1485 | (Double_t)xpmax,(Double_t)ypmax); | |
1486 | ||
1487 | } | |
1488 | ||
1489 | } // end maxY | |
1490 | } // end maxX | |
1491 | ||
1492 | } // end detElemId | |
1493 | ||
1494 | } // end kNMT loop | |
1495 | ||
1496 | } | |
1497 |