]>
Commit | Line | Data |
---|---|---|
215d5755 | 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 | // $Id$ | |
17 | // $MpId$ | |
18 | ||
19 | #include "AliMpDEVisu.h" | |
e4d2775e | 20 | |
21 | #include "AliMpSlatMotifMap.h" | |
22 | #include "AliMpSt345Reader.h" | |
23 | #include "AliMpSectorReader.h" | |
24 | #include "AliMpSlat.h" | |
25 | #include "AliMpPCB.h" | |
e4d2775e | 26 | #include "AliMpSectorReader.h" |
27 | #include "AliMpSector.h" | |
28 | #include "AliMpRow.h" | |
29 | #include "AliMpVRowSegment.h" | |
e4d2775e | 30 | #include "AliMpVPainter.h" |
e4d2775e | 31 | #include "AliMpMotifPosition.h" |
32 | #include "AliMpMotifMap.h" | |
e4d2775e | 33 | #include "AliMpDEIterator.h" |
34 | #include "AliMpDEManager.h" | |
35 | #include "AliMpDetElement.h" | |
36 | #include "AliMpStationType.h" | |
37 | #include "AliMpSegmentation.h" | |
38 | #include "AliMpPad.h" | |
39 | #include "AliMpDDLStore.h" | |
ab167304 | 40 | #include "AliMpManuStore.h" |
215d5755 | 41 | #include "AliMpVPadIterator.h" |
37ec2d4a | 42 | #include "AliMpCDB.h" |
ab167304 | 43 | #include "AliMpDataStreams.h" |
e4d2775e | 44 | |
215d5755 | 45 | #include "AliLog.h" |
46 | ||
47 | #include <TMath.h> | |
48 | #include <TString.h> | |
215d5755 | 49 | #include <TCanvas.h> |
50 | #include <TGButton.h> | |
51 | #include <TRootEmbeddedCanvas.h> | |
52 | #include <TGLabel.h> | |
53 | #include <TGComboBox.h> | |
54 | #include <TGNumberEntry.h> | |
55 | #include <TGTextView.h> | |
56 | #include <TGTextEntry.h> | |
e4d2775e | 57 | |
58 | // Category: graphics | |
3d1463c8 | 59 | |
60 | //----------------------------------------------------------------------------- | |
e4d2775e | 61 | // Class AliMpDEVisu |
62 | // ----------------------- | |
63 | // GUI for drawing segmentation | |
64 | // motif manu and associated channels | |
65 | // date: 2007/01/26 | |
66 | // Author: Ch. Finck | |
3d1463c8 | 67 | //----------------------------------------------------------------------------- |
e4d2775e | 68 | |
69 | /// \cond CLASSIMP | |
70 | ClassImp(AliMpDEVisu) | |
71 | /// \endcond | |
72 | ||
73 | //_________________________________________________________________ | |
74 | AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h) | |
215d5755 | 75 | : TGFrame(gClient->GetRoot(), w, h), |
76 | fkMainWindow(gClient->GetRoot()), | |
77 | fMain(new TGMainFrame(gClient->GetRoot(), w, h)), | |
78 | fEcanvas(0x0), | |
79 | fChamberCombo(0x0), | |
80 | fDECombo(0x0), | |
81 | fNumberEntry(0x0), | |
82 | fPlaneButton(0x0), | |
83 | fZoomButton(0x0), | |
d58f6c58 | 84 | fNameDECombo(0x0), |
215d5755 | 85 | fLogMessage(0x0), |
86 | fLogFile(0x0), | |
87 | fTrashList(0x0), | |
88 | fDEComboIdx(), | |
d58f6c58 | 89 | fNameDEComboIdx(), |
90 | fDEOccurrence(1026), | |
215d5755 | 91 | fCurrentPlane(AliMp::kBendingPlane), |
92 | fCurrentDetElem(100), | |
93 | fCurrentDEName(), | |
7d5d0cc5 | 94 | fkSegmentation(), |
4a3224ff | 95 | fDDLStore(0x0), |
ab167304 | 96 | fManuStore(0x0), |
215d5755 | 97 | fZoomMode(false) |
e4d2775e | 98 | { |
215d5755 | 99 | /// Standard constructor |
e4d2775e | 100 | |
37ec2d4a | 101 | // Load mapping |
331a617a | 102 | if ( ! AliMpCDB::LoadDDLStore() ) { |
37ec2d4a | 103 | AliFatal("Could not access mapping from OCDB !"); |
104 | } | |
37ec2d4a | 105 | |
ab167304 | 106 | if ( ! AliMpCDB::LoadManuStore() ) { |
107 | AliFatal("Could not access run-dependent mapping from OCDB !"); | |
108 | } | |
37ec2d4a | 109 | |
ab167304 | 110 | fDDLStore = AliMpDDLStore::Instance(); |
111 | fManuStore = AliMpManuStore::Instance(); | |
37ec2d4a | 112 | |
215d5755 | 113 | fTrashList.SetOwner(kFALSE); |
114 | ||
115 | // Create canvas widget | |
116 | ||
117 | Int_t width = Int_t(w*0.99); | |
118 | Int_t height = Int_t(h*0.99); | |
119 | ||
120 | fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain, width, height); | |
121 | fEcanvas->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", | |
122 | "AliMpDEVisu", | |
123 | this, | |
124 | "HandleMovement(Int_t, Int_t, Int_t, TObject*)"); | |
125 | ||
126 | // Create a horizontal frame widget with buttons | |
127 | TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,width,height/6); | |
128 | ||
129 | TGTextButton *draw = new TGTextButton(hframe,"&Draw"); | |
130 | draw->Connect("Clicked()","AliMpDEVisu",this,"DrawDE()"); | |
131 | hframe->AddFrame(draw, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
132 | ||
133 | TGTextButton *exit = new TGTextButton(hframe,"&Exit","gApplication->Terminate(0)"); | |
134 | hframe->AddFrame(exit, new TGLayoutHints(kLHintsLeft| kLHintsCenterY,5,5,3,4)); | |
135 | ||
136 | ||
137 | Int_t i = 0; | |
138 | Char_t text[20]; | |
139 | ||
140 | // chamber label | |
141 | TGLabel* chamberLabel = new TGLabel(hframe, "Chamber :"); | |
142 | hframe->AddFrame(chamberLabel, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
143 | fChamberCombo = new TGComboBox(hframe, kChamberCombo); | |
144 | ||
145 | fDEComboIdx.Set(26); | |
146 | for(i = 0; i < 10; i++) | |
147 | { | |
148 | sprintf(text,"%d",i+1); | |
149 | fChamberCombo->AddEntry(text,i); | |
150 | } | |
151 | fChamberCombo->Resize(40,20); | |
152 | fChamberCombo->Select(0); | |
153 | fChamberCombo->Associate(this); | |
154 | hframe->AddFrame(fChamberCombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
155 | ||
156 | // DE label | |
157 | TGLabel* detElemLabel = new TGLabel(hframe, "DE :"); | |
158 | hframe->AddFrame(detElemLabel, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
159 | fDECombo = new TGComboBox(hframe, kDECombo); | |
160 | UpdateComboDE(); | |
161 | ||
162 | fDECombo->Resize(80,20); | |
163 | fDECombo->Select(0); | |
164 | fDECombo->Associate(this); | |
165 | hframe->AddFrame(fDECombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
d58f6c58 | 166 | fDEOccurrence.Reset(-1); |
167 | ||
215d5755 | 168 | TGTextButton *next = new TGTextButton(hframe,"&Next"); |
169 | next->Connect("Clicked()","AliMpDEVisu",this,"NextDE()"); | |
170 | hframe->AddFrame(next, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,5,5,3,4)); | |
171 | ||
172 | // DE name | |
173 | TGLabel* detElemName = new TGLabel(hframe, "Name :"); | |
174 | hframe->AddFrame(detElemName, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
175 | ||
176 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
177 | fCurrentDEName = detElem->GetDEName(); | |
d58f6c58 | 178 | fNameDECombo = new TGComboBox(hframe, kDEName); |
179 | ||
09840862 | 180 | UpdateNameView(kTRUE); |
d58f6c58 | 181 | fNameDECombo->Resize(160, 20); |
182 | fNameDECombo->Select(0); | |
183 | fNameDECombo->Associate(this); | |
184 | hframe->AddFrame(fNameDECombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
215d5755 | 185 | |
186 | // plane type | |
187 | fPlaneButton = new TGCheckButton(hframe, "NB Plane", kPlaneType); | |
188 | fPlaneButton->SetState(kButtonUp); | |
189 | fPlaneButton->Associate(this); | |
190 | hframe->AddFrame(fPlaneButton, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
191 | ||
192 | ||
193 | // button motif | |
194 | TGTextButton* drawManu = new TGTextButton(hframe,"&Search"); | |
195 | drawManu->Connect("Clicked()","AliMpDEVisu",this,"DrawManuMotif(Bool_t)"); | |
196 | drawManu->SetToolTipText("Search for a given manu number"); | |
197 | hframe->AddFrame(drawManu, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
198 | ||
199 | // entry manu | |
200 | fNumberEntry = new TGNumberEntry(hframe, 0, 4, -1, | |
201 | TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, | |
202 | TGNumberFormat::kNELLimitMinMax, 1, 1500); | |
203 | fNumberEntry->Resize(60,20); | |
204 | hframe->AddFrame(fNumberEntry, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 0, 9, 0)); | |
205 | ||
206 | // reset button | |
207 | TGTextButton *resetManu = new TGTextButton(hframe,"&Reset"); | |
208 | resetManu->Connect("Clicked()","AliMpDEVisu",this,"ResetManu()"); | |
209 | hframe->AddFrame(resetManu, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,10,5,3,4)); | |
210 | ||
211 | // delete window button | |
212 | TGTextButton* deletePopup = new TGTextButton(hframe,"&Delete_Popup"); | |
213 | deletePopup->Connect("Clicked()","AliMpDEVisu",this,"DeletePopUp()"); | |
214 | deletePopup->SetToolTipText("Delete motif popup window"); | |
215 | hframe->AddFrame(deletePopup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
216 | ||
217 | ||
218 | // log mesg | |
219 | TGHorizontalFrame *logFrame = new TGHorizontalFrame(fMain, width/2, height/6); | |
220 | ||
221 | TGLabel* logName = new TGLabel(logFrame, "Log MSG:"); | |
222 | logFrame->AddFrame(logName, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 2, 0)); | |
223 | ||
224 | fLogMessage = new TGTextView(logFrame, width/2, 60); | |
225 | fLogMessage->ShowBottom(); | |
226 | ||
227 | logFrame->AddFrame(fLogMessage, new TGLayoutHints(kLHintsLeft, 10, 0, 2, 0)); | |
228 | ||
229 | // clear log mesg | |
e4d2775e | 230 | TGTextButton* clearLog = new TGTextButton(logFrame,"&Clear"); |
215d5755 | 231 | clearLog->Connect("Clicked()","AliMpDEVisu",this,"ClearLogMessage()"); |
232 | clearLog->SetToolTipText("Clear log message"); | |
233 | logFrame->AddFrame(clearLog, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
234 | ||
235 | // save log mesg | |
236 | TGTextButton* saveLog = new TGTextButton(logFrame,"&Save"); | |
237 | saveLog->Connect("Clicked()","AliMpDEVisu",this,"SaveLogMessage()"); | |
238 | saveLog->SetToolTipText("Save log message into file"); | |
239 | logFrame->AddFrame(saveLog, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,5,5,3,4)); | |
240 | ||
241 | // log file name | |
242 | fLogFile = new TGTextEntry(logFrame,"AliMpDEVisu.log"); | |
243 | fLogFile->SetToolTipText("Default log file name"); | |
244 | logFrame->AddFrame(fLogFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 0, 9, 0)); | |
245 | ||
246 | // zoom mode | |
247 | fZoomButton = new TGCheckButton(logFrame, new TGHotString("&Zoom Mode"), kZoomMode); | |
248 | fZoomButton->Associate(this); | |
249 | fZoomButton->SetState(kButtonUp); | |
e4d2775e | 250 | |
215d5755 | 251 | logFrame->AddFrame(fZoomButton, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 20, 0, 9, 0)); |
252 | ||
253 | // frame | |
254 | fMain->AddFrame(hframe, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,10,10)); | |
255 | fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,10)); | |
256 | ||
257 | fMain->AddFrame(logFrame, new TGLayoutHints(kLHintsLeft,2,2,2,10)); | |
258 | ||
259 | // Set a name to the main frame | |
260 | fMain->SetWindowName("MUON Detection Element Visualization"); | |
261 | ||
262 | // Map all subwindows of main frame | |
263 | fMain->MapSubwindows(); | |
264 | ||
265 | // Initialize the layout algorithm | |
266 | fMain->Resize(fMain->GetDefaultSize()); | |
267 | ||
268 | // Map main frame | |
269 | fMain->MapWindow(); | |
270 | ||
271 | // instance segmentation | |
7d5d0cc5 | 272 | fkSegmentation = AliMpSegmentation::Instance()->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); |
215d5755 | 273 | fLogMessage->AddLine("Segmentation loaded"); |
274 | fLogMessage->ShowBottom(); | |
e4d2775e | 275 | } |
276 | ||
277 | //____________________________________________________________ | |
278 | AliMpDEVisu::~AliMpDEVisu() | |
279 | { | |
215d5755 | 280 | /// Clean up used widgets: frames, buttons, layouthints |
281 | ||
282 | fChamberCombo->Delete(); | |
283 | fDECombo->Delete(); | |
284 | fNumberEntry->Delete(); | |
285 | fPlaneButton->Delete(); | |
d58f6c58 | 286 | fNameDECombo->Delete(); |
215d5755 | 287 | fLogMessage->Delete(); |
288 | fLogFile->Delete(); | |
289 | fMain->Cleanup(); | |
290 | delete fMain; | |
e4d2775e | 291 | } |
292 | ||
293 | //__________________________________________________________ | |
294 | void AliMpDEVisu::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* /*select*/) | |
295 | { | |
215d5755 | 296 | /// handle cursor mouvement |
297 | ||
298 | static Int_t eventXold, eventYold; | |
299 | static Int_t eventX0, eventY0; | |
300 | static Int_t linedrawn; | |
301 | ||
e4d2775e | 302 | |
215d5755 | 303 | // enable again KeyAutoRepeat after HandleKey |
304 | if (eventType == kKeyPress) { | |
305 | gVirtualX->SetKeyAutoRepeat(kTRUE); | |
306 | } | |
e4d2775e | 307 | |
215d5755 | 308 | fEcanvas->GetCanvas()->cd(); |
e4d2775e | 309 | |
215d5755 | 310 | // zoom mode |
311 | if (fZoomMode) { | |
312 | ||
313 | if (eventType == kButton1Down) { | |
314 | gVirtualX->SetLineWidth(3); | |
315 | eventX0 = eventX; eventY0 = eventY; | |
316 | eventXold = eventX; eventYold = eventY; | |
317 | linedrawn = 0; | |
318 | } | |
319 | ||
320 | if (eventType == kButton1Motion) { | |
321 | if (linedrawn) gVirtualX->DrawBox(eventX0, eventY0, eventXold, eventYold, TVirtualX::kHollow); | |
322 | eventXold = eventX; | |
323 | eventYold = eventY; | |
324 | linedrawn = 1; | |
325 | gVirtualX->DrawBox(eventX0, eventY0, eventXold, eventYold, TVirtualX::kHollow); | |
326 | } | |
327 | ||
328 | if (eventType == kButton1Up) | |
329 | { | |
330 | if ( (eventX0 - eventX) && (eventY0 - eventY) ) | |
331 | { | |
332 | PopUpZoom(eventX0,eventY0,eventX,eventY); | |
333 | linedrawn=1; | |
334 | } | |
335 | } | |
336 | ||
337 | ||
338 | } else { | |
339 | ||
340 | // click mode | |
341 | ||
342 | if (eventType == kButton1Down) { | |
343 | ||
344 | // calculated in pixel | |
e4d2775e | 345 | Double_t x = 0.; |
346 | Double_t y = 0.; | |
215d5755 | 347 | |
348 | EventToReal(eventX,eventY,x,y); | |
349 | ||
350 | // get manu | |
6e97fbb8 | 351 | AliMpPad pad = fkSegmentation->PadByPosition(x,y, false); |
215d5755 | 352 | |
e4d2775e | 353 | if (!pad.IsValid()) { |
215d5755 | 354 | |
355 | fLogMessage->AddLine(Form("PopupManuMotif: No manu for DE: %d at position (%5.2f, %5.2f)", | |
356 | fCurrentDetElem, x, y)); | |
357 | fLogMessage->ShowBottom(); | |
358 | return; | |
e4d2775e | 359 | } |
215d5755 | 360 | |
168e9c4d | 361 | Int_t manu = pad.GetManuId(); |
215d5755 | 362 | |
e4d2775e | 363 | fNumberEntry->SetNumber(manu); |
215d5755 | 364 | |
365 | ||
366 | fLogMessage->AddLine(Form("PopupManuMotif: DE: %d, manu: %d at position: %5.2f, %5.2f", | |
367 | fCurrentDetElem, manu, x, y)); | |
e4d2775e | 368 | fLogMessage->ShowBottom(); |
215d5755 | 369 | |
e4d2775e | 370 | DrawManuMotif(true); |
215d5755 | 371 | |
e4d2775e | 372 | } |
215d5755 | 373 | } |
e4d2775e | 374 | } |
375 | ||
376 | //__________________________________________________________ | |
215d5755 | 377 | void AliMpDEVisu::DrawDE(Bool_t info) |
e4d2775e | 378 | { |
215d5755 | 379 | /// Draws function graphics in randomly choosen interval |
380 | ||
381 | if (info) | |
e4d2775e | 382 | InfoDE(); |
215d5755 | 383 | |
384 | fEcanvas->GetCanvas()->cd(); | |
385 | fEcanvas->GetCanvas()->SetEditable(kTRUE); | |
386 | ||
09840862 | 387 | fNameDECombo->Select(fDEOccurrence[fCurrentDetElem]); |
388 | TGLBEntry* entry = fNameDECombo->GetSelectedEntry(); | |
389 | entry->SetBackgroundColor(0xDDDDDD); | |
390 | ||
215d5755 | 391 | if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) { |
e4d2775e | 392 | |
215d5755 | 393 | DrawSlat("PMCI"); |
394 | ||
395 | } else { | |
396 | ||
397 | DrawQuadrant("RSMCI"); | |
398 | ||
399 | } | |
400 | DeletePopUp(); | |
401 | fEcanvas->GetCanvas()->SetEditable(kFALSE); | |
402 | ||
e4d2775e | 403 | } |
404 | ||
405 | //__________________________________________________________ | |
406 | void AliMpDEVisu::DrawManuMotif(Bool_t popup) | |
407 | { | |
71a2d3aa | 408 | /// Draw manu motif in yellow and popup channel motif window |
e4d2775e | 409 | |
215d5755 | 410 | fEcanvas->GetCanvas()->SetEditable(kTRUE); |
411 | ||
412 | if (!fNumberEntry->GetIntNumber()) return; | |
413 | ||
414 | Char_t command[255]; | |
415 | ||
416 | if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) { | |
417 | ||
418 | sprintf(command, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber()); | |
419 | ||
420 | DrawSlat(command, popup); | |
421 | ||
422 | } else { | |
423 | ||
424 | sprintf(command, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber()); | |
425 | ||
426 | DrawQuadrant(command, popup); | |
427 | ||
428 | } | |
429 | ||
430 | fEcanvas->GetCanvas()->SetEditable(kFALSE); | |
e4d2775e | 431 | } |
432 | ||
433 | //__________________________________________________________ | |
434 | void AliMpDEVisu::DrawSlat(Option_t* option, Bool_t popup) | |
435 | { | |
215d5755 | 436 | /// draw slat segmentation |
437 | ||
438 | TCanvas *canvas = fEcanvas->GetCanvas(); | |
439 | canvas->Clear(); | |
440 | ||
441 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
442 | TString nameType = detElem->GetSegType(); | |
ab167304 | 443 | |
444 | AliMpDataStreams dataStreams; | |
445 | ||
183279c1 | 446 | AliMpSlatMotifMap mm; |
447 | ||
448 | AliMpSt345Reader reader(dataStreams,&mm); | |
215d5755 | 449 | AliMpSlat* slatCurrent = reader.ReadSlat(nameType.Data(), fCurrentPlane); |
450 | AliMpSlat* slatOther = reader.ReadSlat(nameType.Data(), AliMp::OtherPlaneType(fCurrentPlane)); | |
451 | ||
452 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(slatCurrent); | |
453 | painter->Draw(option); | |
454 | ||
455 | canvas->Update(); | |
456 | ||
457 | Int_t numberOfManu = | |
458 | slatCurrent->GetNofElectronicCards() + | |
459 | slatOther->GetNofElectronicCards(); | |
460 | ||
461 | fLogMessage->AddLine(Form("DrawSlat: number of manus: %d", numberOfManu)); | |
462 | fLogMessage->ShowBottom(); | |
463 | ||
464 | if (popup) | |
465 | PopUpManuMotif(slatCurrent); | |
e4d2775e | 466 | |
e4d2775e | 467 | } |
468 | ||
469 | //__________________________________________________________ | |
215d5755 | 470 | void AliMpDEVisu::DrawQuadrant(Option_t* option, Bool_t popup) |
e4d2775e | 471 | { |
215d5755 | 472 | /// draw quadrant segmentation |
473 | ||
474 | TCanvas *canvas = fEcanvas->GetCanvas(); | |
475 | canvas->Clear(); | |
476 | ||
477 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
4e51cfd2 | 478 | AliMq::Station12Type station = detElem->GetStation12Type(); |
e4d2775e | 479 | |
ab167304 | 480 | AliMpDataStreams dataStreams; |
481 | ||
482 | AliMpSectorReader readerCurrent(dataStreams, station, fCurrentPlane); | |
215d5755 | 483 | AliMpSector* sectorCurrent = readerCurrent.BuildSector(); |
484 | ||
ab167304 | 485 | AliMpSectorReader readerOther(dataStreams, station, AliMp::OtherPlaneType(fCurrentPlane)); |
215d5755 | 486 | AliMpSector* sectorOther = readerOther.BuildSector(); |
487 | ||
488 | AliMpVPainter *painter = AliMpVPainter::CreatePainter(sectorCurrent); | |
489 | painter->Draw(option); | |
490 | ||
491 | canvas->Update(); | |
492 | ||
493 | Int_t numberOfManu = | |
e4d2775e | 494 | sectorCurrent->GetMotifMap()->GetNofMotifPositions() + |
495 | sectorOther->GetMotifMap()->GetNofMotifPositions(); | |
e4d2775e | 496 | |
215d5755 | 497 | fLogMessage->AddLine(Form("DrawQuadrant: number of manus: %d", numberOfManu)); |
498 | fLogMessage->ShowBottom(); | |
499 | ||
500 | if (popup) | |
501 | PopUpManuMotif(sectorCurrent); | |
502 | ||
503 | } | |
504 | ||
505 | //______________________________________________________________________________ | |
506 | void | |
6e97fbb8 | 507 | AliMpDEVisu::EventToReal(Int_t eventX, Int_t eventY, |
508 | Double_t& x, Double_t& y) const | |
215d5755 | 509 | { |
510 | /// estimate graphic pad sizes | |
e4d2775e | 511 | |
6e97fbb8 | 512 | static Double_t ulx(gPad->XtoPixel(0.01)); |
513 | static Double_t uly(gPad->YtoPixel(0.99)); | |
514 | static Double_t brx(gPad->XtoPixel(0.99)); | |
515 | static Double_t bry(gPad->YtoPixel(0.01)); | |
e4d2775e | 516 | |
6e97fbb8 | 517 | static Double_t padDimX = brx - ulx; |
518 | static Double_t padDimY = bry - uly; | |
215d5755 | 519 | |
520 | // get DE dimension (half size) | |
6e97fbb8 | 521 | Double_t deDimX(fkSegmentation->GetDimensionX()*2.0); |
522 | Double_t deDimY(fkSegmentation->GetDimensionY()*2.0); | |
215d5755 | 523 | |
6e97fbb8 | 524 | if ( AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) |
215d5755 | 525 | { |
526 | // origin at center | |
6e97fbb8 | 527 | x = (eventX - ulx - padDimX/2.)/(padDimX)*deDimX; |
528 | y = (bry - eventY - padDimY/2.)/(padDimY)*deDimY; | |
215d5755 | 529 | |
530 | } | |
531 | else | |
532 | { | |
533 | // origin at bottom left | |
6e97fbb8 | 534 | x = (eventX - ulx)/(padDimX)*deDimX; |
535 | y = (bry - eventY)/(padDimY)*deDimY; | |
215d5755 | 536 | } |
537 | ||
e4d2775e | 538 | } |
539 | ||
540 | //__________________________________________________________ | |
541 | void AliMpDEVisu::ResetManu() | |
542 | { | |
215d5755 | 543 | /// reset manu search entry |
544 | fLogMessage->AddLine("Reset Motif Search Entry:"); | |
545 | fLogMessage->ShowBottom(); | |
546 | fNumberEntry->SetNumber(0); | |
547 | ||
e4d2775e | 548 | } |
549 | ||
550 | //__________________________________________________________ | |
551 | void AliMpDEVisu::DeletePopUp() | |
552 | { | |
553 | /// delete motif popup windows | |
215d5755 | 554 | |
555 | if (fTrashList.GetEntries() > 0) | |
556 | { | |
557 | fLogMessage->AddLine("Delete Motif PopUp Windows:"); | |
558 | fLogMessage->ShowBottom(); | |
559 | ||
560 | fTrashList.Delete(); | |
561 | } | |
e4d2775e | 562 | } |
563 | ||
564 | //__________________________________________________________ | |
565 | void AliMpDEVisu::SaveLogMessage() | |
566 | { | |
215d5755 | 567 | /// save log message into log file |
568 | ||
569 | TString logFile = fLogFile->GetDisplayText(); | |
570 | fLogMessage->GetText()->Save(logFile.Data()); | |
e4d2775e | 571 | |
215d5755 | 572 | fLogMessage->AddLine(Form("SaveLogMessage: saving log message into logfile: %s", logFile.Data())); |
573 | fLogMessage->ShowBottom(); | |
e4d2775e | 574 | } |
575 | ||
576 | //__________________________________________________________ | |
577 | void AliMpDEVisu::ClearLogMessage() | |
578 | { | |
215d5755 | 579 | /// clear log message |
580 | fLogMessage->GetText()->Clear(); | |
581 | fLogMessage->AddLine("ClearLogMessage: clear log messages:"); | |
582 | fLogMessage->ShowBottom(); | |
e4d2775e | 583 | } |
584 | ||
585 | //__________________________________________________________ | |
586 | void AliMpDEVisu::InfoDE() | |
587 | { | |
215d5755 | 588 | /// info concerning the whole DE |
589 | ||
590 | AliMpDetElement* detElem = fDDLStore->GetDetElement(fCurrentDetElem); | |
591 | Int_t ddlId = detElem->GetDdlId(); | |
592 | Int_t numberOfBus = detElem->GetNofBusPatches(); | |
593 | ||
594 | Int_t vec[24]; | |
595 | for (Int_t i = 0; i < detElem->GetNofBusPatches(); ++i) | |
596 | vec[i] = detElem->GetBusPatchId(i); | |
e4d2775e | 597 | |
215d5755 | 598 | Int_t firstBus = TMath::MinElement(detElem->GetNofBusPatches(), vec); |
599 | Int_t lastBus = TMath::MaxElement(detElem->GetNofBusPatches(), vec); | |
600 | ||
ab167304 | 601 | Int_t numberOfSerialManu = fManuStore->NofManus(detElem->GetId()); // number of manu with an identified serial number |
215d5755 | 602 | |
603 | fLogMessage->AddLine(Form("DrawDE: detection element: %d, name: %s", | |
604 | fCurrentDetElem, fCurrentDEName.Data())); | |
605 | fLogMessage->ShowBottom(); | |
606 | ||
607 | fLogMessage->AddLine(Form("DrawDE: DDL: %d, number of buspatches %d from %d to %d", | |
608 | ddlId, numberOfBus, firstBus, lastBus)); | |
609 | fLogMessage->ShowBottom(); | |
610 | ||
611 | if (numberOfSerialManu != 0) { // not available yet for all DE | |
612 | fLogMessage->AddLine(Form("DrawDE: number of manus with serial number: %d", numberOfSerialManu)); | |
e4d2775e | 613 | fLogMessage->ShowBottom(); |
215d5755 | 614 | } |
615 | ||
e4d2775e | 616 | } |
617 | ||
618 | //__________________________________________________________ | |
619 | Bool_t AliMpDEVisu::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/) | |
620 | { | |
215d5755 | 621 | /// process message from widgets actions/entries |
e4d2775e | 622 | |
215d5755 | 623 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); |
624 | ||
625 | switch(GET_MSG(msg)) | |
626 | { | |
e4d2775e | 627 | case kC_COMMAND: |
628 | switch (GET_SUBMSG(msg)) | |
629 | { | |
215d5755 | 630 | case kCM_COMBOBOX: |
631 | ||
632 | switch (parm1) | |
633 | { | |
634 | case kChamberCombo: | |
635 | UpdateComboDE(); | |
09840862 | 636 | UpdateNameView(kTRUE); |
215d5755 | 637 | break; |
638 | ||
639 | case kDECombo: | |
640 | UpdateNameView(); | |
641 | break; | |
d58f6c58 | 642 | |
643 | case kDEName: | |
644 | UpdateComboCH(); | |
645 | break; | |
215d5755 | 646 | } |
647 | break; | |
648 | ||
649 | case kCM_CHECKBUTTON: | |
650 | switch (parm1) | |
651 | { | |
652 | case kPlaneType: | |
653 | if (fPlaneButton->GetState() == kButtonDown) { | |
654 | fCurrentPlane = AliMp::kNonBendingPlane; | |
655 | if (fNumberEntry->GetIntNumber() && fNumberEntry->GetIntNumber() <= 1024) | |
656 | fNumberEntry->SetNumber(fNumberEntry->GetIntNumber() + 1024); | |
657 | } else { | |
658 | fCurrentPlane = AliMp::kBendingPlane; | |
659 | if (fNumberEntry->GetIntNumber() && fNumberEntry->GetIntNumber() > 1024) | |
660 | fNumberEntry->SetNumber(fNumberEntry->GetIntNumber() - 1024); | |
661 | } | |
662 | DrawDE(); | |
7d5d0cc5 | 663 | fkSegmentation = AliMpSegmentation::Instance() |
215d5755 | 664 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); |
665 | break; | |
666 | ||
667 | case kZoomMode: | |
668 | if (fZoomButton->GetState() == kButtonDown) | |
669 | fZoomMode = true; | |
670 | else | |
671 | fZoomMode = false; | |
672 | break; | |
673 | } | |
674 | break; | |
675 | ||
e4d2775e | 676 | } |
677 | break; | |
215d5755 | 678 | } |
679 | return true; | |
e4d2775e | 680 | } |
681 | ||
97c15de5 | 682 | //__________________________________________________________ |
683 | void AliMpDEVisu::NextDE() | |
684 | { | |
215d5755 | 685 | /// select next DE |
686 | ||
687 | Int_t next = fDECombo->GetSelected() + 1; | |
688 | ||
689 | if (next < fDECombo->GetNumberOfEntries()) | |
690 | fDECombo->Select(next); | |
691 | else | |
692 | fDECombo->Select(0); | |
693 | ||
694 | UpdateNameView(); | |
695 | DrawDE(); | |
97c15de5 | 696 | } |
697 | ||
d58f6c58 | 698 | //__________________________________________________________ |
699 | void AliMpDEVisu::UpdateComboCH() | |
700 | { | |
701 | /// update Chamber/DE in respect to DE Name | |
702 | ||
703 | fCurrentDEName = fNameDEComboIdx[fNameDECombo->GetSelected()]; | |
704 | ||
705 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDEName); | |
706 | ||
09840862 | 707 | Int_t idx = AliMpDEManager::GetChamberId(detElem->GetId()); |
708 | fChamberCombo->Select(idx); | |
d58f6c58 | 709 | |
710 | UpdateComboDE(); | |
711 | ||
09840862 | 712 | idx = detElem->GetId() % 100; |
713 | fDECombo->Select(idx); | |
d58f6c58 | 714 | |
715 | fCurrentDetElem = fDEComboIdx[fDECombo->GetSelected()]; | |
716 | ||
7d5d0cc5 | 717 | fkSegmentation = AliMpSegmentation::Instance() |
d58f6c58 | 718 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); |
719 | } | |
720 | ||
e4d2775e | 721 | //__________________________________________________________ |
722 | void AliMpDEVisu::UpdateComboDE() | |
723 | { | |
215d5755 | 724 | /// update DE in respect to selected chamber |
725 | ||
726 | fDECombo->RemoveAll(); | |
727 | ||
728 | AliMpDEIterator it; | |
729 | Int_t i = 0; | |
730 | fDEComboIdx.Reset(); | |
215d5755 | 731 | |
732 | for ( it.First(fChamberCombo->GetSelected()); ! it.IsDone(); it.Next() ) { | |
d58f6c58 | 733 | fDECombo->AddEntry(Form("%d",it.CurrentDE()->GetId()), i); |
215d5755 | 734 | fDEComboIdx[i++] = it.CurrentDE()->GetId(); |
735 | } | |
736 | fDECombo->Select(0); | |
e4d2775e | 737 | } |
738 | ||
739 | //__________________________________________________________ | |
09840862 | 740 | void AliMpDEVisu::UpdateNameView(Bool_t firstTime) |
e4d2775e | 741 | { |
215d5755 | 742 | /// update DE name in respect to selected DE id. |
d58f6c58 | 743 | |
215d5755 | 744 | fCurrentDetElem = fDEComboIdx[fDECombo->GetSelected()]; |
d58f6c58 | 745 | |
215d5755 | 746 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); |
d58f6c58 | 747 | |
215d5755 | 748 | fCurrentDEName = detElem->GetDEName(); |
e4d2775e | 749 | |
09840862 | 750 | if (firstTime) { |
751 | AliMpDEIterator it; | |
752 | ||
753 | fNameDECombo->RemoveAll(); | |
754 | ||
755 | for ( it.First(fChamberCombo->GetSelected()); !it.IsDone(); it.Next() ) { | |
756 | ||
757 | Int_t detElemId = it.CurrentDE()->GetId(); | |
758 | TString deName = it.CurrentDE()->GetDEName(); | |
759 | ||
760 | Int_t idx = fNameDECombo->GetNumberOfEntries(); | |
761 | fNameDECombo->AddEntry(deName.Data(), idx); | |
762 | fNameDEComboIdx[idx] = deName; | |
763 | fDEOccurrence[detElemId] = idx; | |
764 | } | |
d58f6c58 | 765 | } |
766 | ||
767 | fNameDECombo->Select(fDEOccurrence[fCurrentDetElem]); | |
7d5d0cc5 | 768 | fkSegmentation = AliMpSegmentation::Instance() |
215d5755 | 769 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); |
770 | } | |
e4d2775e | 771 | |
215d5755 | 772 | //______________________________________________________________________________ |
773 | void | |
774 | AliMpDEVisu::CreatePopupWindow(Int_t w, Int_t h, const char* windowName, | |
775 | AliMpVPainter* painter, | |
776 | const char* option) | |
777 | { | |
71a2d3aa | 778 | /// Create transient frame |
215d5755 | 779 | |
780 | TCanvas* c = new TCanvas(windowName,windowName,-200,100,w,h); | |
e4d2775e | 781 | |
215d5755 | 782 | Int_t n = fTrashList.GetEntries(); |
783 | ||
784 | c->Connect("Closed()","AliMpDEVisu",this,Form("ClosePopupWindow(=%d)",n)); | |
785 | ||
786 | fTrashList.AddLast(c); | |
787 | ||
788 | c->Draw(); | |
789 | ||
790 | painter->Draw(option); | |
791 | ||
792 | c->Update(); | |
e4d2775e | 793 | } |
794 | ||
795 | //__________________________________________________________ | |
796 | void AliMpDEVisu::PopUpManuMotif(AliMpSlat* slat) | |
797 | { | |
215d5755 | 798 | /// pop up manu window motif painter for slat |
799 | ||
800 | // motif painter | |
801 | AliMpMotifPosition* motifPosFound = 0x0; | |
802 | AliMpMotifPosition* motifPos = 0x0; | |
803 | Int_t manuId = 0; | |
e4d2775e | 804 | |
630711ed | 805 | for ( Int_t i = 0; i < slat->GetSize(); ++i ) { |
215d5755 | 806 | |
e4d2775e | 807 | AliMpPCB* pcb = slat->GetPCB(i); |
215d5755 | 808 | |
630711ed | 809 | for ( Int_t j = 0; j < slat->GetPCB(i)->GetSize(); ++j ) { |
e4d2775e | 810 | |
97c15de5 | 811 | motifPos = pcb->GetMotifPosition(j); |
e4d2775e | 812 | |
215d5755 | 813 | manuId = motifPos->GetID(); |
e4d2775e | 814 | if (manuId == (Int_t)fNumberEntry->GetIntNumber()) { |
215d5755 | 815 | motifPosFound = motifPos; |
816 | break; | |
e4d2775e | 817 | } |
818 | } | |
819 | if (motifPosFound) | |
215d5755 | 820 | break; |
e4d2775e | 821 | } |
97c15de5 | 822 | |
215d5755 | 823 | if(motifPosFound) |
824 | { | |
825 | InfoManuMotif(motifPosFound); | |
97c15de5 | 826 | |
6e97fbb8 | 827 | Double_t dimensionX(motifPosFound->GetDimensionX()); |
828 | Double_t dimensionY(motifPosFound->GetDimensionY()); | |
97c15de5 | 829 | |
215d5755 | 830 | Int_t h = 500; |
6e97fbb8 | 831 | Int_t w = Int_t(h*dimensionX/dimensionY); |
215d5755 | 832 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound); |
833 | ||
834 | CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()), | |
835 | painter,"ZT"); | |
836 | } | |
e4d2775e | 837 | } |
215d5755 | 838 | |
e4d2775e | 839 | //__________________________________________________________ |
840 | void AliMpDEVisu::PopUpManuMotif(AliMpSector* sector) | |
841 | { | |
215d5755 | 842 | /// pop up manu window motif painter for sector |
843 | ||
844 | // motif painter | |
845 | AliMpMotifPosition* motifPosFound = 0x0; | |
846 | AliMpMotifPosition* motifPos = 0x0; | |
847 | Int_t manuId = 0; | |
97c15de5 | 848 | |
215d5755 | 849 | for (Int_t iRow = 0; iRow < sector->GetNofRows(); ++iRow) { |
850 | ||
851 | AliMpRow* row = sector->GetRow(iRow); | |
852 | ||
853 | for (Int_t iRowSeg = 0; iRowSeg < sector->GetRow(iRow)->GetNofRowSegments(); ++iRowSeg){ | |
854 | ||
bf0d3528 | 855 | for (Int_t iRowSeg2 = 0; iRowSeg2 < row->GetNofRowSegments(); ++iRowSeg2) { |
856 | AliMpVRowSegment *rowSegment = row->GetRowSegment(iRowSeg2); | |
215d5755 | 857 | |
858 | for (Int_t iMotif = 0; iMotif < rowSegment->GetNofMotifs(); ++iMotif){ | |
859 | ||
860 | Int_t motifPositionId = rowSegment->GetMotifPositionId(iMotif); | |
861 | motifPos = rowSegment->GetRow() | |
862 | ->GetMotifMap()->FindMotifPosition(motifPositionId); | |
863 | ||
864 | manuId = motifPos->GetID(); | |
865 | if (manuId == (Int_t)fNumberEntry->GetIntNumber()) { | |
866 | motifPosFound = motifPos; | |
867 | break; | |
868 | } | |
869 | } | |
870 | if (motifPosFound) | |
871 | break; | |
872 | } | |
873 | } | |
874 | if (motifPosFound) | |
875 | break; | |
876 | } | |
877 | ||
878 | if(motifPosFound) | |
879 | { | |
e4d2775e | 880 | |
215d5755 | 881 | InfoManuMotif(motifPosFound); |
e4d2775e | 882 | |
6e97fbb8 | 883 | Double_t dimensionX(motifPosFound->GetDimensionX()); |
884 | Double_t dimensionY(motifPosFound->GetDimensionY()); | |
e4d2775e | 885 | |
215d5755 | 886 | // Create transient frame |
887 | Int_t h = 400; | |
6e97fbb8 | 888 | Int_t w = Int_t(h*dimensionX/dimensionY); |
e4d2775e | 889 | |
215d5755 | 890 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound); |
891 | ||
892 | CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()), | |
893 | painter,"ZT"); | |
894 | ||
895 | } | |
896 | } | |
e4d2775e | 897 | |
215d5755 | 898 | //__________________________________________________________ |
899 | void AliMpDEVisu::InfoManuMotif(AliMpMotifPosition* motifPos) | |
900 | { | |
901 | /// info for popup manu motif | |
e4d2775e | 902 | |
215d5755 | 903 | // log message |
904 | Int_t manuId = fNumberEntry->GetIntNumber(); | |
6e97fbb8 | 905 | |
215d5755 | 906 | fLogMessage->AddLine(Form("PopupManuMotif: motif dimension: %5.2f, %5.2f", |
6e97fbb8 | 907 | motifPos->GetDimensionX()*2., |
908 | motifPos->GetDimensionY()*2.)); | |
215d5755 | 909 | |
910 | fLogMessage->AddLine( Form("PopupManuMotif: pad dimension: %4.2f, %4.2f", | |
6e97fbb8 | 911 | motifPos->GetMotif()->GetPadDimensionX(0)*2., |
912 | motifPos->GetMotif()->GetPadDimensionY(0)*2. )); | |
e4d2775e | 913 | |
215d5755 | 914 | fLogMessage->AddLine( Form("PopupManuMotif: manu: %d, serial number: %d, buspatch: %d", |
ab167304 | 915 | manuId, |
916 | fManuStore->GetManuSerial(fCurrentDetElem, manuId), | |
917 | fDDLStore->GetBusPatchId(fCurrentDetElem, manuId)) ); | |
97c15de5 | 918 | |
215d5755 | 919 | fLogMessage->ShowBottom(); |
e4d2775e | 920 | |
215d5755 | 921 | } |
e4d2775e | 922 | |
215d5755 | 923 | //______________________________________________________________________________ |
924 | void AliMpDEVisu::PopUpZoom(Int_t ix0, Int_t iy0, Int_t ix1, Int_t iy1) | |
925 | { | |
926 | /// popup zoom window | |
e4d2775e | 927 | |
215d5755 | 928 | Double_t x0,y0; |
929 | EventToReal(ix0,iy0,x0,y0); | |
930 | Double_t x1,y1; | |
931 | EventToReal(ix1,iy1,x1,y1); | |
e4d2775e | 932 | |
215d5755 | 933 | fLogMessage->AddLine(Form("PopUpZoom: zoom positions (x0, y0: %6.2f, %6.2f), (x1, y1: %6.2f, %6.2f)", |
934 | x0, y0, x1, y1)); | |
935 | fLogMessage->ShowBottom(); | |
936 | ||
937 | // Create transient frame | |
938 | Int_t h = 500;//TMath::Abs(x1-x0); | |
939 | Int_t w = 500;//TMath::Abs(y1-y0); | |
e4d2775e | 940 | |
6e97fbb8 | 941 | AliMpArea area((x0+x1)/2.0,(y0+y1)/2.0, |
942 | TMath::Abs(x1-x0)/2.0,TMath::Abs(y1-y0)/2.0); | |
215d5755 | 943 | // area.Print(); |
944 | ||
945 | if ( area.IsValid() ) | |
946 | { | |
7d5d0cc5 | 947 | AliMpVPadIterator* iterator = fkSegmentation->CreateIterator(area); |
215d5755 | 948 | if (iterator) |
949 | { | |
950 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(iterator); | |
951 | CreatePopupWindow(w,h,"Zoom",painter,""); | |
e4d2775e | 952 | } |
215d5755 | 953 | else |
954 | { | |
955 | AliError("could not get iterator for that area"); | |
e4d2775e | 956 | } |
215d5755 | 957 | |
958 | delete iterator; | |
959 | } | |
97c15de5 | 960 | } |
961 | ||
962 | //__________________________________________________________ | |
215d5755 | 963 | void AliMpDEVisu::ClosePopupWindow(Int_t id) |
97c15de5 | 964 | { |
215d5755 | 965 | /// close signal |
966 | fEcanvas->GetCanvas()->cd(); | |
967 | fTrashList.RemoveAt(id); | |
e4d2775e | 968 | } |