AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTriggerGUIdimap.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 
18 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
25 
26 #include <TCanvas.h>
27 #include <TGButton.h>
28 #include <TGTab.h>
29 #include <TRootEmbeddedCanvas.h>
30 #include <TBox.h>
31 #include <TPave.h>
32 #include <TPaveText.h>
33 #include <TStyle.h>
34 #include <TObjArray.h>
35 
36 #include "AliLoader.h"
37 #include "AliRunLoader.h"
38 
39 #include "AliMUONVDigit.h"
40 #include "AliMpSegmentation.h"
41 #include "AliMpVSegmentation.h"
43 #include "AliMUONMCDataInterface.h"
44 
45 #include "AliMUONTriggerGUIboard.h"
46 #include "AliMUONTriggerGUIdimap.h"
47 
48 #include "AliMUONDigitStoreV1.h"
49 
50 #include <cstdio>
51 
55 
56 //__________________________________________________________________________
57 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
58  : TGFrame(0),
59  fMain(0),
60  fLoader(0),
61  fMCDataInterface(0),
62  fRawDigitStore(0),
63  fBoards(0),
64  fIsOn(0)
65 {
67 
68  fIsOn = kTRUE;
69  fBoards = boards;
70 
71  gStyle->SetPadLeftMargin(0.05);
72  gStyle->SetPadRightMargin(0.05);
73  gStyle->SetPadTopMargin(0.05);
74  gStyle->SetPadBottomMargin(0.05);
75 
76  gStyle->SetOptDate(0);
77  gStyle->SetOptTitle(0);
78  gStyle->SetOptStat(0);
79 
80  fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
81  fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
82  fMain->DontCallClose(); // to avoid double deletions.
83 
84  // use hierarchical cleaning
85  fMain->SetCleanup(kDeepCleanup);
86 
87  TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
88 
89  TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
90  closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
91 
92  hframe->AddFrame(closeButton,
93  new TGLayoutHints(kLHintsTop |
94  kLHintsLeft,
95  2, 2, 2, 2)
96  );
97 
98  hframe->Resize(150, closeButton->GetDefaultHeight());
99 
100  TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
101  updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
102  updateButton->SetToolTipText("Read the digits for the current event");
103 
104  hframe->AddFrame(updateButton,
105  new TGLayoutHints(kLHintsTop |
106  kLHintsLeft,
107  2, 2, 2, 2)
108  );
109 
110  hframe->Resize(150, updateButton->GetDefaultHeight());
111  /*
112  TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
113  resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
114  resetButton->SetToolTipText("Redraw unselected boards");
115 
116  hframe->AddFrame(resetButton,
117  new TGLayoutHints(kLHintsTop |
118  kLHintsLeft,
119  2, 2, 2, 2)
120  );
121 
122  hframe->Resize(150, resetButton->GetDefaultHeight());
123  */
124  fMain->AddFrame(hframe,
125  new TGLayoutHints(kLHintsBottom |
126  kLHintsLeft,
127  2, 2, 2, 2)
128  );
129 
130  TGTab *tab = new TGTab(fMain, 300, 300);
131  //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
132 
133  // Tabs for MT11, MT12, MT21, MT22
134  TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
135  kLHintsLeft |
136  kLHintsExpandX |
137  kLHintsExpandY,
138  5, 5, 5, 5);
139 
140  TGCompositeFrame *tf = 0;
141 
142  // Tab for MT11
143  tf = tab->AddTab("MT11");
144 
145  TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
146  fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
147  cf1->AddFrame(fEc[0], lot);
148 
149  tf->AddFrame(cf1, lot);
150  fEc[0]->GetCanvas()->SetBorderMode(0);
151  fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
152 
153  // Tab for MT12
154  tf = tab->AddTab("MT12");
155 
156  TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
157  fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
158  cf2->AddFrame(fEc[1], lot);
159 
160  tf->AddFrame(cf2, lot);
161  fEc[1]->GetCanvas()->SetBorderMode(0);
162  fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
163 
164  // Tab for MT21
165  tf = tab->AddTab("MT21");
166 
167  TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
168  fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
169  cf3->AddFrame(fEc[2], lot);
170 
171  tf->AddFrame(cf3, lot);
172  fEc[2]->GetCanvas()->SetBorderMode(0);
173  fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
174 
175  // Tab for MT22
176  tf = tab->AddTab("MT22");
177 
178  TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
179  fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
180  cf4->AddFrame(fEc[3], lot);
181 
182  tf->AddFrame(cf4, lot);
183  fEc[3]->GetCanvas()->SetBorderMode(0);
184  fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
185 
186  fMain->AddFrame(tab,
187  new TGLayoutHints(kLHintsBottom |
188  kLHintsExpandX |
189  kLHintsExpandY,
190  2, 2, 2, 2)
191  );
192 
193  fMain->MapSubwindows();
194  fMain->Resize();
195 
196  fMain->CenterOnParent();
197 
198  fMain->SetWindowName("Chambers digit maps");
199 
200  fMain->MapWindow();
201 
202 }
203 
204 //__________________________________________________________________________
206 {
208 
209  for (Int_t it = 0; it < kNMT; it++) {
210  for (Int_t ib = 0; ib < kNBoards; ib++) {
211  delete fPaveBoard[it][ib];
212  }
213  }
214 
215  fMain->DeleteWindow();
216 
217 }
218 
219 //__________________________________________________________________________
221 {
223 
224  if (fLoader == 0x0) {
225  //return;
226  }
227  if (fMCDataInterface == 0x0) {
228  //return;
229  }
230 
231  DrawMaps(11);
232  DrawMaps(12);
233  DrawMaps(13);
234  DrawMaps(14);
235 
236 }
237 
238 //__________________________________________________________________________
240 {
242 
243  Bool_t drawDigits = kTRUE;
244  Bool_t drawDigitsRaw = kTRUE;
245  if (fLoader == 0x0) {
246  drawDigits = kFALSE;
247  }
248  if (fRawDigitStore == 0x0) {
249  drawDigitsRaw = kFALSE;
250  }
251 
252  AliMUONTriggerGUIboard *board;
253 
254  TCanvas *canvas = fEc[chamber-11]->GetCanvas();
255  canvas->cd();
256  canvas->Clear();
257 
258  TPaveText *label;
259  TBox *boxd;
260 
261  Char_t cln[4]; // must be 4 long - room for terminating '\0'
262  Int_t detElemId, cathode, ix, iy, charge, color;
263  Int_t holdS, holdL, holdC;
264  Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
265  Float_t xMin, xMax, yMin, yMax;
266  Float_t ptx1, ptx2, pty1, pty2;
267  Float_t xpmin, xpmax, ypmin, ypmax;
268  Float_t xg1, xg2, yg1, yg2, zg1;
269 
270  Float_t frameXmax = 0., frameYmax = 0.;
271 
272  switch(chamber) {
273  case 11:
274  frameXmax = 257.0;
275  frameYmax = 306.6;
276  break;
277  case 12:
278  frameXmax = 259.7;
279  frameYmax = 309.9;
280  break;
281  case 13:
282  frameXmax = 273.0;
283  frameYmax = 325.7;
284  break;
285  case 14:
286  frameXmax = 275.7;
287  frameYmax = 329.0;
288  break;
289  }
290 
291  canvas->Range(
292  -(1.15*frameXmax),
293  -(1.15*frameYmax),
294  +(1.15*frameXmax),
295  +(1.15*frameYmax)
296  );
297 
298  // draw the boards
299 
300  for (Int_t ib = 0; ib < kNBoards; ib++) {
301 
302  board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
303 
304  holdS = board->GetSide();
305  holdC = board->GetCol();
306  holdL = board->GetLine();
307 
308  xCenter = board->GetXCenter(chamber-11);
309  yCenter = board->GetYCenter(chamber-11);
310  xWidth = board->GetXWidth(chamber-11);
311  yWidth = board->GetYWidth(chamber-11);
312 
313  holdXC = xCenter;
314  holdYC = yCenter;
315 
316  xMin = xCenter - xWidth/2;
317  xMax = xCenter + xWidth/2;
318  yMin = yCenter - yWidth/2;
319  yMax = yCenter + yWidth/2;
320 
321  fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
322  fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
323  fPaveBoard[chamber-11][ib]->SetFillStyle(0);
324  fPaveBoard[chamber-11][ib]->Draw();
325 
326  Float_t lWidth = 12.0;
327 
328  if (holdL == 9) {
329 
330  snprintf(cln,4,"C%1d",holdC);
331 
332  ptx1 = holdXC - lWidth;
333  ptx2 = holdXC + lWidth;
334  pty1 = +1.065*frameYmax - lWidth;
335  pty2 = +1.065*frameYmax + lWidth;
336 
337  label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
338  label->AddText(cln);
339  label->SetBorderSize(0);
340  label->SetBit(kCannotPick);
341  label->Draw();
342  }
343  if (holdL == 1) {
344 
345  snprintf(cln,4,"C%1d",holdC);
346 
347  ptx1 = holdXC - lWidth;
348  ptx2 = holdXC + lWidth;
349  pty1 = -1.065*frameYmax - lWidth;
350  pty2 = -1.065*frameYmax + lWidth;
351 
352  label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
353  label->AddText(cln);
354  label->SetBorderSize(0);
355  label->SetBit(kCannotPick);
356  label->Draw();
357  }
358  if (holdS == 0 && holdC == 7) {
359 
360  snprintf(cln,4,"L%1d",holdL);
361 
362  ptx1 = -1.07*frameXmax - lWidth;
363  ptx2 = -1.07*frameXmax + lWidth;
364  pty1 = holdYC - lWidth;
365  pty2 = holdYC + lWidth;
366 
367  label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
368  label->AddText(cln);
369  label->SetBorderSize(0);
370  label->SetBit(kCannotPick);
371  label->Draw();
372  }
373  if (holdS == 1 && holdC == 7) {
374 
375  snprintf(cln,4,"L%1d",holdL);
376 
377  ptx1 = +1.07*frameXmax - lWidth;
378  ptx2 = +1.07*frameXmax + lWidth;
379  pty1 = holdYC - lWidth;
380  pty2 = holdYC + lWidth;
381 
382  label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
383  label->AddText(cln);
384  label->SetBorderSize(0);
385  label->SetBit(kCannotPick);
386  label->Draw();
387  }
388 
389  }
390 
391  // draw digits set from the board GUI
392 
393  Int_t imt = chamber -11;
394  Int_t nStripX, nStripY;
395  TBox *box;
396  for (Int_t ib = 0; ib < kNBoards; ib++) {
397 
398  board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
399 
400  xCenter = board->GetXCenter(imt);
401  yCenter = board->GetYCenter(imt);
402 
403  nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
404  nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
405 
406  for (Int_t is = 0; is < nStripX; is++) {
407 
408  if (board->GetXDig(imt,is) == 0) continue;
409 
410  box = board->GetXDigBox(imt,is);
411 
412  xpmin = box->GetX1();
413  xpmax = box->GetX2();
414  ypmin = box->GetY1();
415  ypmax = box->GetY2();
416 
417  xpmin += xCenter;
418  xpmax += xCenter;
419  ypmin += yCenter;
420  ypmax += yCenter;
421 
422  box->DrawBox(xpmin,ypmin,xpmax,ypmax);
423 
424  }
425 
426  for (Int_t is = 0; is < nStripY; is++) {
427 
428  if (board->GetYDig(imt,is) == 0) continue;
429 
430  box = board->GetYDigBox(imt,is);
431 
432  xpmin = box->GetX1();
433  xpmax = box->GetX2();
434  ypmin = box->GetY1();
435  ypmax = box->GetY2();
436 
437  xpmin += xCenter;
438  xpmax += xCenter;
439  ypmin += yCenter;
440  ypmax += yCenter;
441 
442  box->DrawBox(xpmin,ypmin,xpmax,ypmax);
443 
444  }
445 
446  }
447 
448  // draw the digits from galice
449 
450  if (drawDigits || drawDigitsRaw) {
451 
452  AliMUONGeometryTransformer transformer;
453  transformer.LoadGeometryData("transform.dat");
454 
455  AliMUONVDigitStore *digitStore = 0x0;
456 
457  if (drawDigits) {
458  AliRunLoader *runLoader = fLoader->GetRunLoader();
459  digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
460  }
461  if (drawDigitsRaw) {
462  digitStore = fRawDigitStore;
463  }
464 
465  TIter next(digitStore->CreateIterator());
466  AliMUONVDigit* mdig;
467 
468  while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
469 
470  cathode = mdig->Cathode()+1;
471 
472  ix=mdig->PadX();
473  iy=mdig->PadY();
474  detElemId=mdig->DetElemId();
475  charge = (Int_t)mdig->Charge();
476  color = 261+5*(charge-1);
477  if (color > 282) color = 282;
478 
479  if (detElemId/100 != chamber) continue;
480 
482 
483  AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
484 
485  // get the pad position and dimensions
486  Float_t xlocal1 = mpad.GetPositionX();
487  Float_t ylocal1 = mpad.GetPositionY();
488  Float_t xlocal2 = mpad.GetDimensionX();
489  Float_t ylocal2 = mpad.GetDimensionY();
490 
491  transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
492  // (no transformation for pad dimensions)
493  xg2 = xlocal2;
494  yg2 = ylocal2;
495 
496  // transform in the monitor coordinate system
497  // ALICE SC
498  xpmin = +(xg1-xg2);
499  xpmax = +(xg1+xg2);
500  ypmin = -(yg2-yg1);
501  ypmax = +(yg2+yg1);
502 
503  boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
504  boxd->SetBit(kCannotPick);
505  boxd->SetFillStyle(1001);
506  boxd->SetFillColor(2);
507  boxd->Draw();
508 
509  } // end digits loop
510 
511  } // end draw digits
512 
513  canvas->Modified();
514  canvas->Update();
515 
516 }
517 
518 //__________________________________________________________________________
519 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
520 {
522 
523  switch (id) {
524  case 0:
525  break;
526  case 1:
527  break;
528  case 2:
529  break;
530  case 3:
531  break;
532  default:
533  break;
534  }
535 
536 }
537 
538 //__________________________________________________________________________
540 {
542 
543  fIsOn = kFALSE;
544  CloseWindow();
545 
546 }
547 
548 //__________________________________________________________________________
550 {
552 
553  for (Int_t it = 0; it < kNMT; it++) {
554  for (Int_t ib = 0; ib < kNBoards; ib++) {
555  delete fPaveBoard[it][ib];
556  }
557  }
558 
559  DrawMaps(11);
560  DrawMaps(12);
561  DrawMaps(13);
562  DrawMaps(14);
563 
564  AliMUONTriggerGUIboard *board;
565  for (Int_t ib = 0; ib < kNBoards; ib++) {
566  board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
567  if (board->IsOpen()) SelectBoard(ib);
568  }
569 
570 }
571 
572 //__________________________________________________________________________
574 {
576 
577  for (Int_t it = 0; it < kNMT; it++) {
578 
579  TCanvas *canvas = fEc[it]->GetCanvas();
580  canvas->cd();
581 
582  for (Int_t ib = 0; ib < kNBoards; ib++) {
583  fPaveBoard[it][ib]->SetFillStyle(0);
584  }
585 
586  canvas->Modified();
587  canvas->Update();
588 
589  }
590 
591 }
592 
593 //__________________________________________________________________________
595 {
597 
598  for (Int_t it = 0; it < kNMT; it++) {
599 
600  TCanvas *canvas = fEc[it]->GetCanvas();
601  canvas->cd();
602 
603  fPaveBoard[it][id]->SetFillStyle(4020);
604  fPaveBoard[it][id]->SetFillColor(7);
605 
606  canvas->Modified();
607  canvas->Update();
608 
609  }
610 
611 }
612 
613 //__________________________________________________________________________
615 {
617 
618  fMain->CloseWindow();
619 
620 }
621 
622 
Int_t GetYSix1() const
get first x-index in detector element for a y-strip
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Int_t GetSide() const
get detector side (Left=0 , Right=1)
TStyle * gStyle
Interface for a digit container.
Int_t GetYDig(Int_t imt, Int_t is) const
get the digit amplitude for a y-strip in a given chamber
static AliMpSegmentation * Instance(Bool_t warn=true)
Bool_t LoadGeometryData(const TString &fileName)
#define TObjArray
Int_t GetCol() const
get column
Top container class for geometry transformations.
TBox * GetXDigBox(Int_t imt, Int_t is) const
get x-strip box for display
Float_t GetYCenter(Int_t imt) const
get y-center of the board in chamber imt
Bool_t fIsOn
True if the map is open.
TObjArray * fBoards
Array of boards.
Int_t GetYSix2() const
get last x-index in detector element for a y-strip
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual TIterator * CreateIterator() const =0
Create an iterator to loop over all our digits.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
AliMUONVDigitStore * DigitStore(Int_t event)
TGTransientFrame * fMain
Main frame.
Int_t GetLine() const
get line
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
Float_t GetXWidth(Int_t imt) const
get x-width of the board in chamber imt
Int_t GetXSiy2() const
get last y-index in detector element for an x-strip
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
AliMUONMCDataInterface * fMCDataInterface
MC data interface.
Trigger GUI utility class: digits maps of the trigger chambers.
Float_t GetYWidth(Int_t imt) const
get y-width of the board in chamber imt
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
Float_t GetXCenter(Int_t imt) const
get x-center of the board in chamber imt
TBox * GetYDigBox(Int_t imt, Int_t is) const
get y-strip box for display
Int_t GetXSiy1() const
get first y-index in detector element for an x-strip
Trigger GUI utility class: single board object.
AliMUONDigitStoreV1 * fRawDigitStore
Raw data digit store.
The abstract base class for the segmentation.
Bool_t IsOpen() const
true if this board has a gui active
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
TPave * fPaveBoard[kNMT][kNBoards]
Drawing of the board.
AliLoader * fLoader
The MUON loader.
int main(int argc, char **argv)
Definition: TPCCEda.cxx:91
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
TRootEmbeddedCanvas * fEc[kNMT]
Canvases for drawing the digits.
Int_t GetXDig(Int_t imt, Int_t is) const
get the digit amplitude for an x-strip in a given chamber