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