]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerGUIdimap.cxx
Overload the Clone() method of TObject to replace the method CreateCopy().
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGUIdimap.cxx
CommitLineData
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
bae1aa70 16// $Id$
17
3d1463c8 18//-----------------------------------------------------------------------------
bae1aa70 19/// \class AliMUONTriggerGUIdimap
20///
21/// The digit maps of the four trigger chambers, all boards
22///
23/// \author Bogdan Vulpescu, LPC Clermont-Ferrand
3d1463c8 24//-----------------------------------------------------------------------------
905654c2 25
26#include <TCanvas.h>
905654c2 27#include <TGButton.h>
28#include <TGTab.h>
29#include <TRootEmbeddedCanvas.h>
30#include <TBox.h>
31#include <TClonesArray.h>
32#include <TPave.h>
33#include <TPaveText.h>
34#include <TStyle.h>
35#include <TObjArray.h>
36
37#include "AliRun.h"
38
39#include "AliMUON.h"
bae1aa70 40#include "AliMUONVDigit.h"
905654c2 41#include "AliMpSegmentation.h"
42#include "AliMpVSegmentation.h"
43#include "AliMUONGeometryTransformer.h"
905654c2 44
45#include "AliMUONTriggerGUIboard.h"
46#include "AliMUONTriggerGUIdimap.h"
47
bae1aa70 48#include "AliMUONVDigitStore.h"
49
905654c2 50/// \cond CLASSIMP
51ClassImp(AliMUONTriggerGUIdimap)
52/// \endcond
53
54//__________________________________________________________________________
55AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(AliLoader *loader, TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
bae1aa70 56 : TGFrame(0),
905654c2 57 fMain(0),
58 fLoader(0),
905654c2 59 fBoards(0),
60 fIsOn(0)
61{
62 /// frame constructor
63
64 fLoader = loader;
65 fIsOn = kTRUE;
66 fBoards = boards;
67
905654c2 68 gStyle->SetPadLeftMargin(0.05);
69 gStyle->SetPadRightMargin(0.05);
70 gStyle->SetPadTopMargin(0.05);
71 gStyle->SetPadBottomMargin(0.05);
72
73 gStyle->SetOptDate(0);
74 gStyle->SetOptTitle(0);
75 gStyle->SetOptStat(0);
76
77 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
78 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
79 fMain->DontCallClose(); // to avoid double deletions.
80
81 // use hierarchical cleaning
82 fMain->SetCleanup(kDeepCleanup);
83
84 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
85
86 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
87 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
88
89 hframe->AddFrame(closeButton,
90 new TGLayoutHints(kLHintsTop |
91 kLHintsLeft,
92 2, 2, 2, 2)
93 );
94
95 hframe->Resize(150, closeButton->GetDefaultHeight());
96
97 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
98 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
99 updateButton->SetToolTipText("Read the digits for the current event");
100
101 hframe->AddFrame(updateButton,
102 new TGLayoutHints(kLHintsTop |
103 kLHintsLeft,
104 2, 2, 2, 2)
105 );
106
107 hframe->Resize(150, updateButton->GetDefaultHeight());
108 /*
109 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
110 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
111 resetButton->SetToolTipText("Redraw unselected boards");
112
113 hframe->AddFrame(resetButton,
114 new TGLayoutHints(kLHintsTop |
115 kLHintsLeft,
116 2, 2, 2, 2)
117 );
118
119 hframe->Resize(150, resetButton->GetDefaultHeight());
120 */
121 fMain->AddFrame(hframe,
122 new TGLayoutHints(kLHintsBottom |
123 kLHintsLeft,
124 2, 2, 2, 2)
125 );
126
127 TGTab *tab = new TGTab(fMain, 300, 300);
128 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
129
130 // Tabs for MT11, MT12, MT21, MT22
131 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
132 kLHintsLeft |
133 kLHintsExpandX |
134 kLHintsExpandY,
135 5, 5, 5, 5);
136
137 TGCompositeFrame *tf = 0;
138
139 // Tab for MT11
140 tf = tab->AddTab("MT11");
141
142 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
143 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
144 cf1->AddFrame(fEc[0], lot);
145
146 tf->AddFrame(cf1, lot);
147 fEc[0]->GetCanvas()->SetBorderMode(0);
148 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
149
150 // Tab for MT12
151 tf = tab->AddTab("MT12");
152
153 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
154 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
155 cf2->AddFrame(fEc[1], lot);
156
157 tf->AddFrame(cf2, lot);
158 fEc[1]->GetCanvas()->SetBorderMode(0);
159 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
160
161 // Tab for MT21
162 tf = tab->AddTab("MT21");
163
164 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
165 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
166 cf3->AddFrame(fEc[2], lot);
167
168 tf->AddFrame(cf3, lot);
169 fEc[2]->GetCanvas()->SetBorderMode(0);
170 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
171
172 // Tab for MT22
173 tf = tab->AddTab("MT22");
174
175 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
176 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
177 cf4->AddFrame(fEc[3], lot);
178
179 tf->AddFrame(cf4, lot);
180 fEc[3]->GetCanvas()->SetBorderMode(0);
181 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
182
183 fMain->AddFrame(tab,
184 new TGLayoutHints(kLHintsBottom |
185 kLHintsExpandX |
186 kLHintsExpandY,
187 2, 2, 2, 2)
188 );
189
190 fMain->MapSubwindows();
191 fMain->Resize();
192
193 fMain->CenterOnParent();
194
195 fMain->SetWindowName("Chambers digit maps");
196
197 fMain->MapWindow();
198
199 DrawMaps(11);
200 DrawMaps(12);
201 DrawMaps(13);
202 DrawMaps(14);
203
204}
205
206//__________________________________________________________________________
207AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
208{
209 /// destructor
210
211 for (Int_t it = 0; it < kNMT; it++) {
212 for (Int_t ib = 0; ib < kNBoards; ib++) {
213 delete fPaveBoard[it][ib];
214 }
215 }
216
905654c2 217 fMain->DeleteWindow();
218
219}
220
905654c2 221//__________________________________________________________________________
222void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
223{
224 /// draw the digits map for chamber-
225
226 TString mapspath = gSystem->Getenv("ALICE_ROOT");
227 mapspath.Append("/MUON/data");
228
229 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
230 canvas->cd();
231 canvas->Clear();
232
905654c2 233 AliMpPad mpad;
234
235 AliRunLoader *runLoader = fLoader->GetRunLoader();
236 gAlice = runLoader->GetAliRun();
237 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
238 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
239
bae1aa70 240 fLoader->LoadDigits("READ");
241 TTree* treeD = fLoader->TreeD();
242 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
905654c2 243
244 TPaveText *label;
245 TBox *boxd;
246
247 Char_t fntxt[6], name[8], cln[2];
248 Int_t detElemId, cathode, ix, iy, charge, color;
249 Int_t side, col, line, nbx;
250 Int_t holdS, holdL, holdC;
251 Float_t xCenter, yCenter, zCenter, xWidth, yWidth, holdXC, holdYC;
252 Float_t xMin, xMax, yMin, yMax;
253 Float_t ptx1, ptx2, pty1, pty2;
254 Float_t xpmin, xpmax, ypmin, ypmax;
255 Float_t xg1, xg2, yg1, yg2, zg1;
256
257 Float_t frameXmax = 0., frameYmax = 0.;
258
259 switch(chamber) {
260 case 11:
261 frameXmax = 257.0;
262 frameYmax = 306.6;
263 break;
264 case 12:
265 frameXmax = 259.7;
266 frameYmax = 309.9;
267 break;
268 case 13:
269 frameXmax = 273.0;
270 frameYmax = 325.7;
271 break;
272 case 14:
273 frameXmax = 275.7;
274 frameYmax = 329.0;
275 break;
276 }
277
278 canvas->Range(
279 -(1.15*frameXmax),
280 -(1.15*frameYmax),
281 +(1.15*frameXmax),
282 +(1.15*frameYmax)
283 );
284
285 // draw the boards
286
287 sprintf(fntxt,"%s/guimapp%2d.txt",mapspath.Data(),chamber);
288 FILE *ftxt = fopen(fntxt,"r");
289
290 for (Int_t ib = 0; ib < kNBoards; ib++) {
291
292 fscanf(ftxt,"%d %d %d %d %f %f %f %f %f %s \n",
293 &side,&col,&line,&nbx,
294 &xCenter,&yCenter,&xWidth,&yWidth,&zCenter,
295 &name[0]);
296
297 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
298
299 holdS = side;
300 holdC = col;
301 holdL = line;
302
303 holdXC = xCenter;
304 holdYC = yCenter;
305
306 xMin = xCenter - xWidth/2;
307 xMax = xCenter + xWidth/2;
308 yMin = yCenter - yWidth/2;
309 yMax = yCenter + yWidth/2;
310
311 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
312 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
313 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
314 fPaveBoard[chamber-11][ib]->Draw();
315
316 Float_t lWidth = 12.0;
317
318 if (holdL == 9) {
319
320 sprintf(cln,"C%1d",holdC);
321
322 ptx1 = holdXC - lWidth;
323 ptx2 = holdXC + lWidth;
324 pty1 = +1.065*frameYmax - lWidth;
325 pty2 = +1.065*frameYmax + lWidth;
326
327 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
328 label->AddText(cln);
329 label->SetBorderSize(0);
330 label->SetBit(kCannotPick);
331 label->Draw();
332 }
333 if (holdL == 1) {
334
335 sprintf(cln,"C%1d",holdC);
336
337 ptx1 = holdXC - lWidth;
338 ptx2 = holdXC + lWidth;
339 pty1 = -1.065*frameYmax - lWidth;
340 pty2 = -1.065*frameYmax + lWidth;
341
342 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
343 label->AddText(cln);
344 label->SetBorderSize(0);
345 label->SetBit(kCannotPick);
346 label->Draw();
347 }
348 if (holdS == 0 && holdC == 7) {
349
350 sprintf(cln,"L%1d",holdL);
351
352 ptx1 = -1.07*frameXmax - lWidth;
353 ptx2 = -1.07*frameXmax + lWidth;
354 pty1 = holdYC - lWidth;
355 pty2 = holdYC + lWidth;
356
357 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
358 label->AddText(cln);
359 label->SetBorderSize(0);
360 label->SetBit(kCannotPick);
361 label->Draw();
362 }
363 if (holdS == 1 && holdC == 7) {
364
365 sprintf(cln,"L%1d",holdL);
366
367 ptx1 = +1.07*frameXmax - lWidth;
368 ptx2 = +1.07*frameXmax + lWidth;
369 pty1 = holdYC - lWidth;
370 pty2 = holdYC + lWidth;
371
372 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
373 label->AddText(cln);
374 label->SetBorderSize(0);
375 label->SetBit(kCannotPick);
376 label->Draw();
377 }
378
379 }
380
381 fclose(ftxt);
382
383 // draw digits set from the board GUI
384
385 AliMUONTriggerGUIboard *board;
386 Int_t imt = chamber -11;
387 Int_t nStripX, nStripY;
388 TBox *box;
389 for (Int_t ib = 0; ib < kNBoards; ib++) {
390
391 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
392
393 xCenter = board->GetXCenter(imt);
394 yCenter = board->GetYCenter(imt);
395
396 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
397 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
398
399 for (Int_t is = 0; is < nStripX; is++) {
400
401 if (board->GetXDig(imt,is) == 0) continue;
402
403 box = board->GetXDigBox(imt,is);
404
405 xpmin = box->GetX1();
406 xpmax = box->GetX2();
407 ypmin = box->GetY1();
408 ypmax = box->GetY2();
409
410 xpmin += xCenter;
411 xpmax += xCenter;
412 ypmin += yCenter;
413 ypmax += yCenter;
414
415 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
416
417 }
418
419 for (Int_t is = 0; is < nStripY; is++) {
420
421 if (board->GetYDig(imt,is) == 0) continue;
422
423 box = board->GetYDigBox(imt,is);
424
425 xpmin = box->GetX1();
426 xpmax = box->GetX2();
427 ypmin = box->GetY1();
428 ypmax = box->GetY2();
429
430 xpmin += xCenter;
431 xpmax += xCenter;
432 ypmin += yCenter;
433 ypmax += yCenter;
434
435 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
436
437 }
438
439 }
440
441 // draw the digits
442
bae1aa70 443 TIter next(digitStore->CreateIterator());
444 AliMUONVDigit* mdig;
445
446 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) )
447 {
905654c2 448 cathode = mdig->Cathode()+1;
449
450 ix=mdig->PadX();
451 iy=mdig->PadY();
452 detElemId=mdig->DetElemId();
bae1aa70 453 charge = (Int_t)mdig->Charge();
905654c2 454 color = 261+5*(charge-1);
455 if (color > 282) color = 282;
456
457 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
458
459 mpad = seg2->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
460
461 // get the pad position and dimensions
462 Float_t xlocal1 = mpad.Position().X();
463 Float_t ylocal1 = mpad.Position().Y();
464 Float_t xlocal2 = mpad.Dimensions().X();
465 Float_t ylocal2 = mpad.Dimensions().Y();
466
467 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
468 // (no transformation for pad dimensions)
469 xg2 = xlocal2;
470 yg2 = ylocal2;
471
472 // transform in the monitor coordinate system
473 //xpmin = -(xg1+xg2);
474 //xpmax = -(xg1-xg2);
475 //ypmin = -(yg2-yg1);
476 //ypmax = +(yg2+yg1);
477 // ALICE SC
478 xpmin = +(xg1-xg2);
479 xpmax = +(xg1+xg2);
480 ypmin = -(yg2-yg1);
481 ypmax = +(yg2+yg1);
482
483 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
484 boxd->SetBit(kCannotPick);
485 boxd->SetFillStyle(1001);
486 boxd->SetFillColor(2);
487 boxd->Draw();
488
489 } // end digits loop
490
bae1aa70 491 delete digitStore;
905654c2 492 canvas->Modified();
493 canvas->Update();
494
495}
496
497//__________________________________________________________________________
498void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
499{
500 /// some action when chamber tab is selected...
501
502 switch (id) {
503 case 0:
504 break;
505 case 1:
506 break;
507 case 2:
508 break;
509 case 3:
510 break;
511 default:
512 break;
513 }
514
515}
516
517//__________________________________________________________________________
518void AliMUONTriggerGUIdimap::DoClose()
519{
520 /// close the main frame
521
522 fIsOn = kFALSE;
523 CloseWindow();
524
525}
526
527//__________________________________________________________________________
528void AliMUONTriggerGUIdimap::DoUpdate()
529{
530 /// update maps for another run/event
531
905654c2 532 for (Int_t it = 0; it < kNMT; it++) {
533 for (Int_t ib = 0; ib < kNBoards; ib++) {
534 delete fPaveBoard[it][ib];
535 }
536 }
537
538 DrawMaps(11);
539 DrawMaps(12);
540 DrawMaps(13);
541 DrawMaps(14);
542
543 AliMUONTriggerGUIboard *board;
544 for (Int_t ib = 0; ib < kNBoards; ib++) {
545 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
546 if (board->IsOpen()) SelectBoard(ib);
547 }
548
549}
550
551//__________________________________________________________________________
552void AliMUONTriggerGUIdimap::DoReset()
553{
554 /// draw unselected boards
555
556 for (Int_t it = 0; it < kNMT; it++) {
557
558 TCanvas *canvas = fEc[it]->GetCanvas();
559 canvas->cd();
560
561 for (Int_t ib = 0; ib < kNBoards; ib++) {
562 fPaveBoard[it][ib]->SetFillStyle(0);
563 }
564
565 canvas->Modified();
566 canvas->Update();
567
568 }
569
570}
571
572//__________________________________________________________________________
573void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
574{
575 /// highlight on the map the open board
576
577 for (Int_t it = 0; it < kNMT; it++) {
578
579 TCanvas *canvas = fEc[it]->GetCanvas();
580 canvas->cd();
581
582 fPaveBoard[it][id]->SetFillStyle(4020);
583 fPaveBoard[it][id]->SetFillColor(7);
584
585 canvas->Modified();
586 canvas->Update();
587
588 }
589
590}
591
592//__________________________________________________________________________
593void AliMUONTriggerGUIdimap::CloseWindow()
594{
595 /// called when window is closed via the window manager.
596
597 fMain->CloseWindow();
598
599}
600
601