]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerGUIbdmap.cxx
mixing example
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGUIbdmap.cxx
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 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerGUIbdmap
20 ///
21 /// The gui map of a single board object, strips/digits
22 ///
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
25
26 #include <TPolyLine.h>
27 #include <TStyle.h>
28 #include <TGButton.h>
29 #include <TRootEmbeddedCanvas.h>
30 #include <TBox.h>
31 #include <TPaveText.h>
32 #include <TGTextEdit.h>
33 #include <TGText.h>
34 #include <TTimer.h>
35 #include <TObjArray.h>
36 #include <TCanvas.h>
37
38 #include "AliRun.h"
39 #include "AliMUON.h"
40 #include "AliMUONVDigit.h"
41 #include "AliMpVSegmentation.h"
42 #include "AliMpSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
44 #include "AliMpDEIterator.h"
45 #include "AliMUONLocalTrigger.h"
46 #include "AliMUONLocalTriggerBoard.h"
47 #include "AliMUONTriggerCrateStore.h"
48 #include "AliMUONMCDataInterface.h"
49 #include "AliMUONVTriggerStore.h"
50 #include "AliMUONVDigitStore.h"
51 #include "AliMpDEManager.h"
52
53 #include "AliMUONTriggerGUIboard.h"
54 #include "AliMUONTriggerGUIbdmap.h"
55
56 /// \cond CLASSIMP
57 ClassImp(AliMUONTriggerGUIbdmap)
58 /// \endcond
59
60 //__________________________________________________________________________
61 AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
62   : TGFrame(0),
63     fMain(0),
64     fLocTrigE(0),
65     fBoard(0),
66     fLoader(0),
67     fMCDataInterface(0),
68     fXStrips(0),
69     fYStrips(0),
70     fEditStrips(0),
71     fXOn(0),
72     fYOn(0),
73     fLabelX(0),
74     fLabelY(0),
75     fIsEditable(0),
76     fCanvasSize(0),
77     fNStripX(0),
78     fNStripY(0),
79     fBoards(0),
80     fCrateManager(0)
81 {
82   /// frame constructor
83
84   gStyle->SetPadLeftMargin(0.05);
85   gStyle->SetPadRightMargin(0.05);
86   gStyle->SetPadTopMargin(0.05);
87   gStyle->SetPadBottomMargin(0.05);
88
89   fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
90   fMain->Connect("CloseWindow()", "AliMUONTriggerGUIbdmap", this, "CloseWindow()");
91   fMain->DontCallClose(); // to avoid double deletions.
92   
93   // use hierarchical cleaning
94   fMain->SetCleanup(kDeepCleanup);
95
96   fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
97
98   // strips/digits canvases
99   
100   fCanvasSize = 200;
101
102   TRootEmbeddedCanvas *recanvas[4];
103   Char_t ecname[1];
104   for (Int_t i = 0; i < kNMT; i++) {
105
106     sprintf(ecname,"%1d",i+1);
107     recanvas[i] = new TRootEmbeddedCanvas(ecname,fMain,fCanvasSize,fCanvasSize);
108     
109     fCanvas[i] = recanvas[i]->GetCanvas();
110     
111     fCanvas[i]->SetBorderMode(0);
112     fCanvas[i]->SetBit(kNoContextMenu);
113     
114     fCanvas[i]->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
115                         "AliMUONTriggerGUIbdmap",this,
116                         "EditStrips(Int_t,Int_t,Int_t,TObject*)");
117
118     fMain->AddFrame(recanvas[i],
119                     /*
120                     new TGTableLayoutHints(2,5,2,6,
121                                            kLHintsExpandX|kLHintsExpandY |
122                                            kLHintsShrinkX|kLHintsShrinkY |
123                                            kLHintsFillX|kLHintsFillY)
124                     */
125                     new TGLayoutHints(kLHintsTop | 
126                                       kLHintsLeft, 
127                                       2, 2, 2, 2)
128                     );
129
130   }
131
132   //TGDimension size = fMain->GetDefaultSize();
133   //fMain->Resize(size);
134     
135   // the other frames
136
137   TGCompositeFrame *cf0 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
138
139   TGCompositeFrame *cf1 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
140
141   cf1->AddFrame(fXStrips = new TGCheckButton(cf1, "Draw X strips and digits", 1),
142                 new TGLayoutHints(kLHintsTop | 
143                                   kLHintsLeft, 
144                                   2, 2, 2, 2)
145                 );
146
147   cf1->Resize(fXStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
148
149   cf1->AddFrame(fYStrips = new TGCheckButton(cf1, "Draw Y strips and digits", 2),
150                 new TGLayoutHints(kLHintsTop | 
151                                   kLHintsLeft, 
152                                   2, 2, 2, 2)          
153                 );
154
155   cf1->Resize(fYStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
156
157   cf1->AddFrame(fEditStrips = new TGCheckButton(cf1, "Set/unset strips", 3),
158                 new TGLayoutHints(kLHintsTop | 
159                                   kLHintsLeft, 
160                                   2, 2, 2, 2)          
161                 );
162
163   fXStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
164   fYStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
165   fEditStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleEditButton()");
166
167   cf0->AddFrame(cf1, 
168                 new TGLayoutHints(kLHintsTop | 
169                                   kLHintsExpandX, 
170                                   2, 2, 2, 2)          
171                 );
172   
173   TGCompositeFrame *cf2 = new TGCompositeFrame(cf0, 60, 20, kHorizontalFrame | kFixedWidth);
174
175   TGTextButton *digitsButton = new TGTextButton(cf2, "Digits", 4);
176   digitsButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoDigits()");
177
178   //cf2->Resize(digitsButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
179
180   cf2->AddFrame(digitsButton, 
181                 new TGLayoutHints(kLHintsTop | 
182                                   kLHintsLeft |
183                                   kLHintsExpandX, 
184                                   2, 2, 5, 5)          
185                 );
186
187   TGTextButton *dresetButton = new TGTextButton(cf2, "Reset", 5);
188   dresetButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "ResetDigits()");
189
190   //cf2->Resize(dresetButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
191
192   cf2->AddFrame(dresetButton, 
193                 new TGLayoutHints(kLHintsTop | 
194                                   kLHintsLeft |
195                                   kLHintsExpandX, 
196                                   2, 2, 5, 5)          
197                 );
198
199   TGTextButton *closeButton = new TGTextButton(cf2, "Close", 6);
200   closeButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoClose()");
201
202   //cf2->Resize(closeButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
203
204   cf2->AddFrame(closeButton, 
205                 new TGLayoutHints(kLHintsTop | 
206                                   kLHintsLeft |
207                                   kLHintsExpandX, 
208                                   2, 2, 5, 5)          
209                 );
210
211   cf0->AddFrame(cf2, 
212                   new TGLayoutHints(kLHintsTop | 
213                                     kLHintsExpandX, 
214                                     2, 2, 2, 2)        
215                   );
216   
217   // editor window for the local trigger
218
219   TGCompositeFrame *cf3 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
220
221   fLocTrigE = new TGTextEdit(cf3, 100, 100, kSunkenFrame | kDoubleBorder);
222   cf3->AddFrame(fLocTrigE, 
223                 new TGLayoutHints(kLHintsExpandX | 
224                                   kLHintsExpandY, 
225                                   3, 3, 3, 3)
226                 );
227
228   cf0->AddFrame(cf3, 
229                   new TGLayoutHints(kLHintsTop | 
230                                     kLHintsExpandX, 
231                                     2, 2, 2, 2)        
232                   );
233   
234   fMain->AddFrame(cf0, 
235                   new TGLayoutHints(kLHintsTop | 
236                                     kLHintsExpandX, 
237                                     2, 2, 2, 2)        
238                   );
239   
240   fIsEditable = kFALSE;
241   fLabelX = kFALSE;
242   fLabelY = kFALSE;
243
244   fMain->MapSubwindows();
245   fMain->Resize();
246   
247   fMain->CenterOnParent();
248
249   //fMain->MapWindow();
250   //gClient->WaitFor(fMain);
251   
252 }
253
254 //__________________________________________________________________________
255 AliMUONTriggerGUIbdmap::~AliMUONTriggerGUIbdmap()
256 {
257   /// frame destructor
258
259   fMain->DeleteWindow();
260
261 }
262
263 //__________________________________________________________________________
264 void AliMUONTriggerGUIbdmap::Show()
265 {
266   /// map the main frame
267
268   fMain->MapWindow();
269   LocalTriggerInfo();
270
271 }
272
273 //__________________________________________________________________________
274 void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
275 {
276   /// print the local trigger
277   
278   TGText txt;
279   Char_t buffer[20];
280
281   sprintf(buffer,"Local trigger info\n");
282   fLocTrigE->LoadBuffer(buffer);
283
284   AliRunLoader *runLoader = fLoader->GetRunLoader();
285   gAlice = runLoader->GetAliRun();
286
287   AliMUONVTriggerStore *triggerStore = fMCDataInterface->TriggerStore(runLoader->GetEventNumber());
288
289   Int_t circuitNumber = fBoard->GetIdCircuit();
290
291   UShort_t x2m, x2u, x2d;
292
293   Int_t loStripX, loStripY, loDev, loCircuit, iStripX, iStripY, loLpt, loHpt;
294   AliMUONLocalTrigger *mlt;
295
296   TIter next(triggerStore->CreateLocalIterator());
297   
298   while ( ( mlt = static_cast<AliMUONLocalTrigger*>(next()) ) )
299   {    
300     loCircuit = mlt->LoCircuit();
301
302     if (loCircuit == circuitNumber) {
303
304       AliMUONLocalTriggerBoard* ltb = fCrateManager->LocalBoard(loCircuit);
305       x2d = ltb->GetSwitch(0);
306       x2m = ltb->GetSwitch(1);
307       x2u = ltb->GetSwitch(2);
308
309       loStripX = mlt->LoStripX();
310       loStripY = mlt->LoStripY();
311       loDev    = mlt->LoDev();
312       loLpt    = mlt->LoLpt();
313       loHpt    = mlt->LoHpt();
314
315       iStripX = loStripX/2;
316       if ((x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) {
317         iStripY = loStripY/2;
318       } else {
319         iStripY = loStripY;
320       }
321
322       sprintf(buffer,"Circuit = %03d",loCircuit);
323       txt.LoadBuffer(buffer);
324       fLocTrigE->AddText(&txt);
325
326       sprintf(buffer,"LoStripX = %2d",loStripX);
327       txt.LoadBuffer(buffer);
328       fLocTrigE->AddText(&txt);
329
330       sprintf(buffer,"LoStripY = %2d",loStripY);
331       txt.LoadBuffer(buffer);
332       fLocTrigE->AddText(&txt);
333
334       sprintf(buffer,"LoDev = %2d",loDev);
335       txt.LoadBuffer(buffer);
336       fLocTrigE->AddText(&txt);
337
338       sprintf(buffer,"--------------------");
339       txt.LoadBuffer(buffer);
340       fLocTrigE->AddText(&txt);
341
342       sprintf(buffer,"X-strip = %2d ( %2d )",iStripX,(loStripX+loDev+1)/2);
343       txt.LoadBuffer(buffer);
344       fLocTrigE->AddText(&txt);
345
346       sprintf(buffer,"Y-strip = %2d",iStripY);
347       txt.LoadBuffer(buffer);
348       fLocTrigE->AddText(&txt);
349
350       sprintf(buffer,"--------------------");
351       txt.LoadBuffer(buffer);
352       fLocTrigE->AddText(&txt);
353
354       sprintf(buffer,"LoLpt = %2d",loLpt);
355       txt.LoadBuffer(buffer);
356       fLocTrigE->AddText(&txt);
357
358       sprintf(buffer,"LoHpt = %2d",loHpt);
359       txt.LoadBuffer(buffer);
360       fLocTrigE->AddText(&txt);
361
362       break;
363
364     }
365
366   }
367   
368 }
369
370 //__________________________________________________________________________
371 void AliMUONTriggerGUIbdmap::Init()
372 {
373   /// initialize the boards in the four MT
374
375   TString mapspath = gSystem->Getenv("ALICE_ROOT");
376   mapspath.Append("/MUON/data");
377
378   TString mapName[kNMT];
379   mapName[0] = TString(mapspath.Data());
380   mapName[1] = TString(mapspath.Data());
381   mapName[2] = TString(mapspath.Data());
382   mapName[3] = TString(mapspath.Data());
383   mapName[0].Append("/guimapp11.txt");
384   mapName[1].Append("/guimapp12.txt");
385   mapName[2].Append("/guimapp13.txt");
386   mapName[3].Append("/guimapp14.txt");
387
388   Int_t side, col, line, nbx;
389   Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
390   Char_t name[8];
391
392   FILE *fmap;
393   for (Int_t i = 0; i < kNMT; i++) {
394
395     fmap = fopen(mapName[i].Data(),"r");
396
397     for (Int_t ib = 0; ib < kNBoards; ib++) {
398
399       fscanf(fmap,"%d   %d   %d   %d   %f   %f   %f   %f   %f   %s   \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
400
401       if (side == 0) {
402         sprintf(name,"LC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
403       }
404       if (side == 1) {
405         sprintf(name,"RC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
406       }
407
408       if (strncmp(name,fBoard->GetBoardName(),7) == 0) {
409         fXWidth[i]  = xWidth;
410         fYWidth[i]  = yWidth; 
411         fXCenter[i] = xCenter;
412         fYCenter[i] = yCenter; 
413
414         fclose(fmap);
415
416         break;
417       }
418
419     }
420
421   }
422
423   Float_t xw, yw;
424   for (Int_t i = 0; i < kNMT; i++) {
425     xw = 1.20*fXWidth[i];
426     yw = 1.20*fYWidth[i];
427     fCanvas[i]->Range(-xw/2,-yw/2,+xw/2,+yw/2);
428     for (Int_t is = 0; is < kNS; is++) {
429
430       fXDigPL[i][is] = new TPolyLine(5);
431       fYDigPL[i][is] = new TPolyLine(5);
432       fXDigPL[i][is]->SetBit(kCannotPick);
433       fYDigPL[i][is]->SetBit(kCannotPick);
434       fXDigPL[i][is]->SetLineColor(4);
435       fYDigPL[i][is]->SetLineColor(4);
436
437       fXDigBox[i][is] = new TBox(0,0,0,0);
438       fYDigBox[i][is] = new TBox(0,0,0,0);
439       fXDigBox[i][is]->SetBit(kCannotPick);
440       fYDigBox[i][is]->SetBit(kCannotPick);
441       fXDigBox[i][is]->SetFillStyle(0);
442       fYDigBox[i][is]->SetFillStyle(0);
443       fXDigBox[i][is]->SetLineColor(4);
444       fYDigBox[i][is]->SetLineColor(4);
445
446       fXLabelL[i][is] = 0;
447       fXLabelR[i][is] = 0;
448       fYLabelL[i][is] = 0;
449       fYLabelR[i][is] = 0;
450
451     }
452   }
453
454
455   fXOn = kFALSE;
456   fYOn = kFALSE;
457
458   fNStripX = fBoard->GetXSiy2() - fBoard->GetXSiy1() + 1;
459   fNStripY = fBoard->GetYSix2() - fBoard->GetYSix1() + 1;
460
461 }
462
463 //__________________________________________________________________________
464 void AliMUONTriggerGUIbdmap::HandleEditButton()
465 {
466   /// handle the editable check button
467
468   if (((fXOn && !fYOn) || (!fXOn && fYOn)) && 
469       (fEditStrips->GetState() == kButtonDown)) {
470     fIsEditable = kTRUE;
471   } else {
472     fIsEditable = kFALSE;
473   }
474
475 }
476
477 //__________________________________________________________________________
478 void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *sel)
479 {
480   /// set/unset strips
481
482   TString cs;
483   Int_t iMT;
484   Double_t *px, *py;
485   Double_t xf1, yf1, xf2, yf2;
486   Int_t np = 5;
487   Double_t xMin, xMax, yMin, yMax;
488   Float_t xd, yd, fxDim, fyDim, cDim;
489   Char_t cln[2];
490
491   cDim = (Float_t)fCanvasSize;
492   
493   // the (x,y) event does not really go up to the canvas size...
494   cDim = 196.0;
495
496   if (fIsEditable) {
497
498     if (event == kButton1Down) {
499       
500       cs = TString(sel->GetName());
501       iMT = cs.Atoi()-1;
502
503       fCanvas[iMT]->cd();
504
505       fCanvas[iMT]->GetRange(xf1,yf1,xf2,yf2);      
506       fxDim = (Float_t)xf2;
507       fyDim = (Float_t)yf2;
508
509       //xd = fxDim*(+2.0*(Float_t)(x)/cDim - 1.0);
510       //yd = fyDim*(-2.0*(Float_t)(y)/cDim + 1.0);
511
512       xd = +(2.0*fxDim*(Float_t)(x))/cDim - fxDim;
513       yd = -(2.0*fyDim*(Float_t)(y))/cDim + fyDim;
514
515       if (fXOn) {
516
517         for (Int_t ix = 0; ix < fNStripX; ix++) {
518           
519           px = fXDigPL[iMT][ix]->GetX();
520           py = fXDigPL[iMT][ix]->GetY();
521
522           xMin = +9999.;
523           xMax = -9999.;
524           yMin = +9999.;
525           yMax = -9999.;
526           for (Int_t ip = 0; ip < np; ip++) {
527             xMin = TMath::Min(xMin,px[ip]);
528             xMax = TMath::Max(xMax,px[ip]);
529             yMin = TMath::Min(yMin,py[ip]);
530             yMax = TMath::Max(yMax,py[ip]);
531           }
532             
533           if (yd > (Float_t)yMin && yd < (Float_t)yMax) {
534
535             if (fXDigBox[iMT][ix]->GetFillStyle() == 0) {
536
537               fXDigBox[iMT][ix]->SetFillStyle(1001);
538               fXDigBox[iMT][ix]->SetFillColor(2);
539
540               sprintf(cln,"%2d",ix);
541
542               fXLabelL[iMT][ix]->Clear();
543               fXLabelL[iMT][ix]->AddText(cln);
544               fXLabelL[iMT][ix]->Draw();
545
546               fXLabelR[iMT][ix]->Clear();
547               fXLabelR[iMT][ix]->AddText(cln);
548               fXLabelR[iMT][ix]->Draw();
549
550               fXDigBox[iMT][ix]->SetX1(xMin);
551               fXDigBox[iMT][ix]->SetY1(yMin);
552               fXDigBox[iMT][ix]->SetX2(xMax);
553               fXDigBox[iMT][ix]->SetY2(yMax);
554
555               fXDigBox[iMT][ix]->Draw();
556
557             } else if (fXDigBox[iMT][ix]->GetFillStyle() == 1001) {
558
559               fXDigBox[iMT][ix]->SetFillStyle(0);
560
561               fXLabelL[iMT][ix]->Clear();
562               fXLabelL[iMT][ix]->Draw();
563
564               fXLabelR[iMT][ix]->Clear();
565               fXLabelR[iMT][ix]->Draw();
566
567               fXDigBox[iMT][ix]->SetX1(-fBoard->GetXCenter(iMT));
568               fXDigBox[iMT][ix]->SetY1(-fBoard->GetYCenter(iMT));
569               fXDigBox[iMT][ix]->SetX2(-fBoard->GetXCenter(iMT));
570               fXDigBox[iMT][ix]->SetY2(-fBoard->GetYCenter(iMT));
571
572               fXDigBox[iMT][ix]->Draw();
573
574             }
575
576             if (!fXDigBox[iMT][ix]->TestBit(kObjInCanvas))
577               fXDigBox[iMT][ix]->Draw();
578
579             fCanvas[iMT]->Modified();
580             fCanvas[iMT]->Update();
581
582             break;
583             
584           } 
585         }
586
587       }
588
589       if (fYOn) {
590
591         for (Int_t iy = 0; iy < fNStripY; iy++) {
592
593           px = fYDigPL[iMT][iy]->GetX();
594           py = fYDigPL[iMT][iy]->GetY();
595
596           xMin = +9999.;
597           xMax = -9999.;
598           yMin = +9999.;
599           yMax = -9999.;
600           for (Int_t ip = 0; ip < np; ip++) {
601             xMin = TMath::Min(xMin,px[ip]);
602             xMax = TMath::Max(xMax,px[ip]);
603             yMin = TMath::Min(yMin,py[ip]);
604             yMax = TMath::Max(yMax,py[ip]);
605           }
606
607           if (xd > (Float_t)xMin && xd < (Float_t)xMax) {
608
609             if (fYDigBox[iMT][iy]->GetFillStyle() == 0) {
610
611               fYDigBox[iMT][iy]->SetFillStyle(1001);
612               fYDigBox[iMT][iy]->SetFillColor(2);
613
614               sprintf(cln,"%2d",iy);
615
616               fYLabelL[iMT][iy]->Clear();
617               fYLabelL[iMT][iy]->AddText(cln);
618               fYLabelL[iMT][iy]->Draw();
619
620               fYLabelR[iMT][iy]->Clear();
621               fYLabelR[iMT][iy]->AddText(cln);
622               fYLabelR[iMT][iy]->Draw();
623
624               fYDigBox[iMT][iy]->SetX1(xMin);
625               fYDigBox[iMT][iy]->SetY1(yMin);
626               fYDigBox[iMT][iy]->SetX2(xMax);
627               fYDigBox[iMT][iy]->SetY2(yMax);
628               
629               //fYDigBox[iMT][iy]->Draw();
630
631             } else if (fYDigBox[iMT][iy]->GetFillStyle() == 1001) {
632
633               fYDigBox[iMT][iy]->SetFillStyle(0);
634
635               fYLabelL[iMT][iy]->Clear();
636               fYLabelL[iMT][iy]->Draw();
637
638               fYLabelR[iMT][iy]->Clear();
639               fYLabelR[iMT][iy]->Draw();
640
641               fYDigBox[iMT][iy]->SetX1(-fBoard->GetXCenter(iMT));
642               fYDigBox[iMT][iy]->SetY1(-fBoard->GetYCenter(iMT));
643               fYDigBox[iMT][iy]->SetX2(-fBoard->GetXCenter(iMT));
644               fYDigBox[iMT][iy]->SetY2(-fBoard->GetYCenter(iMT));
645
646               //fYDigBox[iMT][iy]->Draw();
647
648             }
649
650             if (!fYDigBox[iMT][iy]->TestBit(kObjInCanvas))
651               fYDigBox[iMT][iy]->Draw();
652
653             fCanvas[iMT]->Modified();
654             fCanvas[iMT]->Update();
655
656             break;
657             
658           } 
659         }
660
661       }
662
663     }  // end button event
664
665   }  // end IsEditable
666
667 }
668
669 //__________________________________________________________________________
670 void AliMUONTriggerGUIbdmap::DoDigits()
671 {
672   /// set the board digits from GUI input (set/unset)
673
674   Int_t amp = 0;
675   Int_t number = fBoard->GetNumber();
676   Int_t pos, over;
677   pos  = fBoard->GetPosition();
678   over = fBoard->GetYOver();
679   AliMUONTriggerGUIboard *board;
680
681   for (Int_t imt = 0; imt < kNMT; imt++) {
682
683     for (Int_t ix = 0; ix < fNStripX; ix++) {
684       if (fXDigBox[imt][ix]->GetFillStyle() ==    0) {
685         amp = 0;
686       }
687       if (fXDigBox[imt][ix]->GetFillStyle() == 1001) {
688         amp = 1;
689       }
690       fBoard->SetDigitX(imt,ix,amp);
691     }
692
693     for (Int_t iy = 0; iy < fNStripY; iy++) {
694       if (fYDigBox[imt][iy]->GetFillStyle() ==    0) {
695         amp = 0;
696       }
697       if (fYDigBox[imt][iy]->GetFillStyle() == 1001) {
698         amp = 1;
699       }
700       fBoard->SetDigitY(imt,iy,amp);
701
702       // extended y-strips
703       for (Int_t io = 1; io <= over; io++) {
704         if (io == pos) continue;
705         board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
706         board->SetDigitY(imt,iy,amp);
707       }
708
709     }
710
711   }
712
713 }
714
715 //__________________________________________________________________________
716 void AliMUONTriggerGUIbdmap::ResetDigits()
717 {
718   /// set the board digits from GUI input (set/unset)
719
720   Int_t amp = 0;
721   Int_t number = fBoard->GetNumber();
722   AliMUONTriggerGUIboard *board;
723   Int_t pos, over;
724   pos  = fBoard->GetPosition();
725   over = fBoard->GetYOver();
726
727   for (Int_t imt = 0; imt < kNMT; imt++) {
728     for (Int_t ix = 0; ix < fNStripX; ix++) {
729       fXDigBox[imt][ix]->SetFillStyle(0);
730       fXDigBox[imt][ix]->SetX1(-fBoard->GetXCenter(imt));
731       fXDigBox[imt][ix]->SetY1(-fBoard->GetYCenter(imt));
732       fXDigBox[imt][ix]->SetX2(-fBoard->GetXCenter(imt));
733       fXDigBox[imt][ix]->SetY2(-fBoard->GetYCenter(imt));
734
735       fBoard->SetDigitX(imt,ix,amp);
736     }
737     for (Int_t iy = 0; iy < fNStripY; iy++) {
738       fYDigBox[imt][iy]->SetFillStyle(0);
739       fYDigBox[imt][iy]->SetX1(-fBoard->GetXCenter(imt));
740       fYDigBox[imt][iy]->SetY1(-fBoard->GetYCenter(imt));
741       fYDigBox[imt][iy]->SetX2(-fBoard->GetXCenter(imt));
742       fYDigBox[imt][iy]->SetY2(-fBoard->GetYCenter(imt));
743
744       fBoard->SetDigitY(imt,iy,amp);
745
746       // extended y-strips
747       for (Int_t io = 1; io <= over; io++) {
748         if (io == pos) continue;
749         board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
750
751         board->SetDigitY(imt,iy,amp);
752
753       }
754
755     }
756   }
757
758   fBoard->ClearXDigits();
759   fBoard->ClearYDigits();
760
761   // extended y-strips
762   for (Int_t io = 1; io <= over; io++) {
763     if (io == pos) continue;
764     board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
765     board->ClearYDigits();
766   }
767   
768   fXStrips->SetState(kButtonUp);
769   fYStrips->SetState(kButtonUp);
770   fEditStrips->SetState(kButtonUp);
771   fIsEditable = kFALSE;
772                       
773   DrawClear();
774   fXOn = kFALSE;
775   fYOn = kFALSE;
776
777 }
778
779 //__________________________________________________________________________
780 void AliMUONTriggerGUIbdmap::HandleButtons(Int_t id)
781 {
782   /// handle the check buttons
783
784   if (id == -1) {
785     TGButton *btn = (TGButton *) gTQSender;
786     id = btn->WidgetId();
787   }
788
789   // draw x and y 
790   if(fXStrips->GetState() == kButtonDown && 
791      fYStrips->GetState() == kButtonDown    ) {
792     
793     DrawClear();
794     DrawStrips(kTRUE,kTRUE);
795     DrawDigits(kTRUE,kTRUE);
796     fXOn = kTRUE;
797     fYOn = kTRUE;
798
799   }
800
801   // draw only x
802   if(fXStrips->GetState() == kButtonDown && 
803      fYStrips->GetState() == kButtonUp      ) {
804     
805     DrawClear();
806     DrawStrips(kTRUE,kFALSE);
807     DrawDigits(kTRUE,kFALSE);
808     fXOn = kTRUE;
809     fYOn = kFALSE;
810
811   }
812
813   // draw only y
814   if(fXStrips->GetState() == kButtonUp   && 
815      fYStrips->GetState() == kButtonDown    ) {
816     
817     DrawClear();
818     DrawStrips(kFALSE,kTRUE);
819     DrawDigits(kFALSE,kTRUE);
820     fXOn = kFALSE;
821     fYOn = kTRUE;
822
823   }
824
825   // clear
826   if(fXStrips->GetState() == kButtonUp   && 
827      fYStrips->GetState() == kButtonUp      ) {
828     
829     DrawClear();
830     fXOn = kFALSE;
831     fYOn = kFALSE;
832
833   }
834
835   HandleEditButton();
836
837 }
838
839 //__________________________________________________________________________
840 void AliMUONTriggerGUIbdmap::DrawClear()
841 {
842   /// draw the frame of the board image in the canvas
843   
844   for (Int_t i = 0; i < kNMT; i++) {
845
846     fCanvas[i]->cd();
847     fCanvas[i]->Clear();
848
849     fCanvas[i]->Modified();
850     fCanvas[i]->Update();
851
852   }
853
854 }
855
856 //__________________________________________________________________________
857 void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
858 {
859   /// draw the digits in "x" or/and "y"
860
861   AliRunLoader *runLoader = fLoader->GetRunLoader();
862   gAlice = runLoader->GetAliRun();
863   AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
864   const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
865   
866   AliMUONTriggerGUIboard *board;
867   Int_t over, pos, number;
868   const AliMpVSegmentation* seg;
869   AliMpPad pad;
870   Int_t cathode, detElemId, ix, iy, charge;
871   Int_t chamber, np = 5;
872   AliMpDEIterator it;
873   Float_t xpmin, xpmax, ypmin, ypmax;
874   Float_t xg1, xg2, yg1, yg2, zg1;
875   Float_t xdw, ydw, xcw, ycw;
876   Double_t xc1, xc2, yc1, yc2;
877   Char_t cln[2];
878   TBox *boxd;
879   Double_t xMin, xMax, yMin, yMax;
880   Double_t *px, *py;
881
882   number = fBoard->GetNumber();
883   pos    = fBoard->GetPosition();
884   over   = fBoard->GetYOver();
885
886   AliMUONVDigitStore *digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
887   
888   for (Int_t i = 0; i < kNMT; i++) {
889
890     fCanvas[i]->cd();
891     
892     fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
893     xcw = (Float_t)(0.5*(xc2-xc1));
894     ycw = (Float_t)(0.5*(yc2-yc1));
895
896     chamber = 11+i;
897
898     AliMpIntPair deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
899     TIter next(digitStore->CreateIterator(deRange.GetFirst(),deRange.GetSecond()));
900     AliMUONVDigit *mdig;
901
902     while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
903     {
904       cathode = mdig->Cathode()+1;
905       
906       ix = mdig->PadX();
907       iy = mdig->PadY();
908       detElemId = mdig->DetElemId(); 
909       charge = (Int_t)mdig->Charge();
910
911       Bool_t triggerBgn = kFALSE;
912       Int_t schg = (Int_t)(charge + 0.5);
913       // APPLY CONDITION ON SOFT BACKGROUND     
914       Int_t tchg = schg - (Int_t(schg/10))*10;  
915       if (schg<=10 || tchg>0) {
916         triggerBgn = kFALSE;
917       } else {
918         triggerBgn = kTRUE;
919       }
920
921       if (detElemId%100 != fBoard->GetDetElemId()) continue;
922       
923       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode-1));  
924       
925       pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
926       
927       //if (cathode == 1) printf("GUI x:  ix %d iy %d \n",ix,iy);
928       //if (cathode == 2) printf("GUI y:  ix %d iy %d \n",ix,iy);
929
930       // get the pad position and dimensions
931       Float_t xlocal1 = pad.Position().X();
932       Float_t ylocal1 = pad.Position().Y();
933       Float_t xlocal2 = pad.Dimensions().X();
934       Float_t ylocal2 = pad.Dimensions().Y();
935       
936       kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
937       // (no transformation for pad dimensions)
938       xg2 = xlocal2;
939       yg2 = ylocal2;
940       
941       // transform in the monitor coordinate system
942       //xpmin = -(xg1+xg2);
943       //xpmax = -(xg1-xg2);
944       //ypmin = -(yg2-yg1);
945       //ypmax = +(yg2+yg1);
946       // ALICE SC
947       xpmin = +(xg1-xg2);
948       xpmax = +(xg1+xg2);
949       ypmin = -(yg2-yg1);
950       ypmax = +(yg2+yg1);
951        
952       xpmin -= fXCenter[i];
953       xpmax -= fXCenter[i];
954       ypmin -= fYCenter[i];
955       ypmax -= fYCenter[i];
956
957       xdw = xpmax-xpmin;
958       ydw = ypmax-ypmin;
959
960       // x-strips
961       if ((xdw > ydw) && bx) {
962
963         //printf("X strips mdig->Cathode() = %1d \n",mdig->Cathode());
964
965         Int_t iX, iY1, iY2;
966         iX  = fBoard->GetXSix();
967         iY1 = fBoard->GetXSiy1();
968         iY2 = fBoard->GetXSiy2();
969         if (ix == iX && iy >= iY1 && iy <= iY2) {
970           //printf("Digit indices (x-strip) ix = %3d iy = %3d board = %s %d chamber = %2d \n",ix,iy,fBoard->GetBoardName(),fBoard->GetNumber(),chamber); 
971           /*
972           xpmin += 0.01*fXWidth[i];
973           xpmax -= 0.01*fXWidth[i];
974           ypmin += 0.1*ydw;
975           ypmax -= 0.1*ydw;
976           */
977           boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
978           boxd->SetFillStyle(1001);
979           if (triggerBgn) boxd->SetFillColor(6);
980           else boxd->SetFillColor(5);
981           boxd->SetBit(kCannotPick);
982           boxd->Draw();
983           
984           fXDigBox[i][iy-iY1]->SetFillStyle(1001);
985           fXDigBox[i][iy-iY1]->SetFillColor(2);
986           fXDigBox[i][iy-iY1]->SetX1(xpmin);
987           fXDigBox[i][iy-iY1]->SetY1(ypmin);
988           fXDigBox[i][iy-iY1]->SetX2(xpmax);
989           fXDigBox[i][iy-iY1]->SetY2(ypmax);
990           fXDigBox[i][iy-iY1]->Draw();
991
992           sprintf(cln,"%2d",(iy-iY1));
993           fXLabelL[i][iy-iY1]->Clear();
994           fXLabelL[i][iy-iY1]->AddText(cln);
995           fXLabelL[i][iy-iY1]->Draw();
996           fXLabelR[i][iy-iY1]->Clear();
997           fXLabelR[i][iy-iY1]->AddText(cln);
998           fXLabelR[i][iy-iY1]->Draw();
999
1000           fBoard->SetDigitX(i,iy-iY1,charge);
1001
1002         }
1003
1004       }
1005
1006       // y-strips
1007       if ((xdw < ydw) && by) {
1008
1009         //printf("Y strips mdig->Cathode() = %1d \n",mdig->Cathode());
1010
1011         Int_t iX1, iX2, iY;
1012         iX1 = fBoard->GetYSix1();
1013         iX2 = fBoard->GetYSix2();
1014         iY  = fBoard->GetYSiy();
1015         if (ix >= iX1 && ix <= iX2 && iy == iY) {
1016           //printf("Digit indices (y-strip) ix = %3d iy = %3d board = %s chamber = %2d \n",ix,iy,fBoard->GetBoardName(),chamber); 
1017           ypmin = -0.5*fYWidth[i];
1018           ypmax = +0.5*fYWidth[i];
1019           /*
1020           ypmin = -0.5*fYWidth[i];
1021           ypmax = +0.5*fYWidth[i];
1022           ypmin += 0.01*fYWidth[i];
1023           ypmax -= 0.01*fYWidth[i];       
1024           xpmin += 0.1*xdw;
1025           xpmax -= 0.1*xdw;
1026           */
1027           boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
1028           boxd->SetFillStyle(1001);
1029           if (triggerBgn) boxd->SetFillColor(6);
1030           else boxd->SetFillColor(5);
1031           boxd->SetBit(kCannotPick);
1032           boxd->Draw();
1033
1034           fYDigBox[i][ix-iX1]->SetFillStyle(1001);
1035           fYDigBox[i][ix-iX1]->SetFillColor(2);
1036           fYDigBox[i][ix-iX1]->SetX1(xpmin);
1037           fYDigBox[i][ix-iX1]->SetY1(ypmin);
1038           fYDigBox[i][ix-iX1]->SetX2(xpmax);
1039           fYDigBox[i][ix-iX1]->SetY2(ypmax);
1040           fYDigBox[i][ix-iX1]->Draw();
1041
1042           sprintf(cln,"%2d",(ix-iX1));
1043           fYLabelL[i][ix-iX1]->Clear();
1044           fYLabelL[i][ix-iX1]->AddText(cln);
1045           fYLabelL[i][ix-iX1]->Draw();
1046           fYLabelR[i][ix-iX1]->Clear();
1047           fYLabelR[i][ix-iX1]->AddText(cln);
1048           fYLabelR[i][ix-iX1]->Draw();
1049
1050           fBoard->SetDigitY(i,ix-iX1,charge);
1051
1052           // extended y-strips
1053           for (Int_t io = 1; io <= over; io++) {
1054             if (io == pos) continue;
1055             board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
1056             board->SetDigitY(i,ix-iX1,charge);
1057           }
1058
1059         }
1060       }
1061       
1062     }  // end digits loop
1063     
1064     // x-strips DSET
1065     if (bx) {
1066       
1067       for (ix = 0; ix < fNStripX; ix++) {
1068         //if (fBoard->GetXDig(i,ix) > 0) {
1069         if (fXDigBox[i][ix]->GetFillStyle() == 1001 || 
1070             fBoard->GetXDig(i,ix) > 0) {
1071           
1072           px = fXDigPL[i][ix]->GetX();
1073           py = fXDigPL[i][ix]->GetY();
1074           
1075           xMin = +9999.;
1076           xMax = -9999.;
1077           yMin = +9999.;
1078           yMax = -9999.;
1079           for (Int_t ip = 0; ip < np; ip++) {
1080             xMin = TMath::Min(xMin,px[ip]);
1081             xMax = TMath::Max(xMax,px[ip]);
1082             yMin = TMath::Min(yMin,py[ip]);
1083             yMax = TMath::Max(yMax,py[ip]);
1084           }
1085           
1086           if (fXDigBox[i][ix]->GetFillStyle() == 0) {
1087             fXDigBox[i][ix]->SetFillStyle(1001);
1088             fXDigBox[i][ix]->SetFillColor(2);
1089             fXDigBox[i][ix]->SetX1(xMin);
1090             fXDigBox[i][ix]->SetY1(yMin);
1091             fXDigBox[i][ix]->SetX2(xMax);
1092             fXDigBox[i][ix]->SetY2(yMax);
1093           }
1094           
1095           sprintf(cln,"%2d",ix);
1096           
1097           fXLabelL[i][ix]->Clear();
1098           fXLabelL[i][ix]->AddText(cln);
1099           fXLabelL[i][ix]->Draw();
1100           
1101           fXLabelR[i][ix]->Clear();
1102           fXLabelR[i][ix]->AddText(cln);
1103           fXLabelR[i][ix]->Draw();
1104           
1105           fXDigBox[i][ix]->Draw();
1106           
1107         }
1108         
1109       }
1110
1111     }
1112       
1113     // y-strips DSET
1114     if (by) {
1115       
1116       for (iy = 0; iy < fNStripY; iy++) {
1117         //if (fBoard->GetYDig(i,iy) > 0) {
1118         if (fYDigBox[i][iy]->GetFillStyle() == 1001 || 
1119             fBoard->GetYDig(i,iy) > 0) {
1120           
1121           px = fYDigPL[i][iy]->GetX();
1122           py = fYDigPL[i][iy]->GetY();
1123           
1124           xMin = +9999.;
1125           xMax = -9999.;
1126           yMin = +9999.;
1127           yMax = -9999.;
1128           for (Int_t ip = 0; ip < np; ip++) {
1129             xMin = TMath::Min(xMin,px[ip]);
1130             xMax = TMath::Max(xMax,px[ip]);
1131             yMin = TMath::Min(yMin,py[ip]);
1132             yMax = TMath::Max(yMax,py[ip]);
1133           }
1134           
1135           if (fYDigBox[i][iy]->GetFillStyle() == 0) {
1136             fYDigBox[i][iy]->SetFillStyle(1001);
1137             fYDigBox[i][iy]->SetFillColor(2);
1138             fYDigBox[i][iy]->SetX1(xMin);
1139             fYDigBox[i][iy]->SetY1(yMin);
1140             fYDigBox[i][iy]->SetX2(xMax);
1141             fYDigBox[i][iy]->SetY2(yMax);
1142           }
1143           
1144           sprintf(cln,"%2d",iy);
1145           
1146           fYLabelL[i][iy]->Clear();
1147           fYLabelL[i][iy]->AddText(cln);
1148           fYLabelL[i][iy]->Draw();
1149           
1150           fYLabelR[i][iy]->Clear();
1151           fYLabelR[i][iy]->AddText(cln);
1152           fYLabelR[i][iy]->Draw();
1153           
1154           
1155           fYDigBox[i][iy]->Draw();
1156           
1157         }
1158         
1159       }
1160
1161     }
1162       
1163     fCanvas[i]->Modified();
1164     fCanvas[i]->Update();
1165       
1166   }  // end canvas loop
1167
1168   fMain->MapWindow();
1169
1170 }
1171
1172 //__________________________________________________________________________
1173 void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
1174 {
1175   /// draw the "x" or/and "y" strips
1176
1177   AliRunLoader *runLoader = fLoader->GetRunLoader();
1178   gAlice = runLoader->GetAliRun();
1179   AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1180   const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
1181
1182   const AliMpVSegmentation* seg;
1183   AliMpPad pad;
1184   AliMpDEIterator it;
1185   Int_t chamber;
1186   Float_t xg1, xg2, yg1, yg2, zg1;
1187   Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1188   Int_t detElemId, ic, maxX, maxY;
1189   Float_t xdw, ydw, xpmin, xpmax, ypmin, ypmax;
1190   Float_t ptx1, ptx2, pty1, pty2;
1191   Char_t cln[2];
1192   Double_t xc1, xc2, yc1, yc2;
1193   Float_t xcw, ycw;
1194
1195   Bool_t makeLabelsX = kFALSE;
1196   Bool_t makeLabelsY = kFALSE;
1197
1198   if (bx && !fLabelX) {
1199     makeLabelsX = kTRUE;
1200     fLabelX = kTRUE;
1201   }
1202
1203   if (by && !fLabelY) {
1204     makeLabelsY = kTRUE;
1205     fLabelY = kTRUE;
1206   }
1207
1208   for (Int_t i = 0; i < kNMT; i++) {
1209
1210     fCanvas[i]->cd();
1211     
1212     fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
1213     xcw = (Float_t)(0.5*(xc2-xc1));
1214     ycw = (Float_t)(0.5*(yc2-yc1));
1215
1216     chamber = 11+i;
1217
1218     for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1219     
1220       detElemId = it.CurrentDEId();
1221     
1222       if (detElemId%100 != fBoard->GetDetElemId()) continue;
1223
1224       /*---------- y-pads ic = 2 ----------*/
1225       ic = 2;
1226       
1227       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));  
1228
1229       maxX = seg->MaxPadIndexX();
1230       maxY = seg->MaxPadIndexY();
1231       
1232       for (Int_t ix = 0; ix <= maxX; ix++) {
1233         for (Int_t iy = 0; iy <= maxY; iy++) {
1234           
1235           pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1236           
1237           if (!pad.IsValid()) continue;
1238           
1239           // get the pad position and dimensions
1240           xlocal1 = pad.Position().X();
1241           ylocal1 = pad.Position().Y();
1242           xlocal2 = pad.Dimensions().X();
1243           ylocal2 = pad.Dimensions().Y();
1244           
1245           kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1246           // (no transformation for pad dimensions)
1247           xg2 = xlocal2;
1248           yg2 = ylocal2;
1249           
1250           // transform in the monitor coordinate system
1251           //xpmin = -(xg1+xg2);
1252           //xpmax = -(xg1-xg2);
1253           //ypmin = -(yg2-yg1);
1254           //ypmax = +(yg2+yg1);
1255           // ALICE SC
1256           xpmin = +(xg1-xg2);
1257           xpmax = +(xg1+xg2);
1258           ypmin = -(yg2-yg1);
1259           ypmax = +(yg2+yg1);
1260           
1261           xpmin -= fXCenter[i];
1262           xpmax -= fXCenter[i];
1263           ypmin -= fYCenter[i];
1264           ypmax -= fYCenter[i];
1265           
1266           xdw = xpmax-xpmin;
1267           ydw = ypmax-ypmin;
1268           
1269           // y-strips
1270           if (by) {
1271             
1272             Int_t iX1, iX2, iY, ixDig;
1273             iX1 = fBoard->GetYSix1();
1274             iX2 = fBoard->GetYSix2();
1275             iY  = fBoard->GetYSiy();
1276             if (ix >= iX1 && ix <= iX2 && iy == iY) {
1277               
1278               ypmin = -0.5*fYWidth[i];
1279               ypmax = +0.5*fYWidth[i];
1280               /*
1281               ypmin += 0.01*fYWidth[i];
1282               ypmax -= 0.01*fYWidth[i];
1283               xpmin += 0.1*xdw;
1284               xpmax -= 0.1*xdw;
1285               */
1286               ixDig = ix - iX1;
1287               fYDigPL[i][ixDig]->SetPoint(0,xpmin,ypmin);
1288               fYDigPL[i][ixDig]->SetPoint(1,xpmax,ypmin);
1289               fYDigPL[i][ixDig]->SetPoint(2,xpmax,ypmax);
1290               fYDigPL[i][ixDig]->SetPoint(3,xpmin,ypmax);
1291               fYDigPL[i][ixDig]->SetPoint(4,xpmin,ypmin);
1292               fYDigPL[i][ixDig]->Draw();
1293               /*
1294               fYDigBox[i][ixDig]->SetFillStyle(1001);
1295               fYDigBox[i][ixDig]->SetFillColor(5);
1296               fYDigBox[i][ixDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1297               */
1298               if (makeLabelsY) {
1299                 sprintf(cln,"%2d",(ix-iX1));
1300                 ptx1 = xpmin;
1301                 ptx2 = xpmax;
1302                 
1303                 pty1 = 1.065*ypmin - 0.04*ycw;
1304                 pty2 = 1.065*ypmin + 0.04*ycw;
1305                 fYLabelL[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1306                 fYLabelL[i][ix-iX1]->SetBorderSize(0);
1307                 fYLabelL[i][ix-iX1]->SetBit(kCannotPick);
1308                 
1309                 pty1 = 1.065*ypmax - 0.04*ycw;
1310                 pty2 = 1.065*ypmax + 0.04*ycw;
1311                 fYLabelR[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1312                 fYLabelR[i][ix-iX1]->SetBorderSize(0);
1313                 fYLabelR[i][ix-iX1]->SetBit(kCannotPick);
1314               }
1315
1316             }
1317             
1318           }
1319           
1320         }  // end maxY
1321         
1322       }  // end maxX
1323       
1324       /*---------- x-pads ic = 1 ----------*/
1325       ic = 1;
1326       
1327       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1)); 
1328
1329       maxX = seg->MaxPadIndexX();
1330       maxY = seg->MaxPadIndexY();
1331       
1332       for (Int_t ix = 0; ix <= maxX; ix++) {
1333         for (Int_t iy = 0; iy <= maxY; iy++) {
1334           
1335           pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1336           
1337           if (!pad.IsValid()) continue;
1338           
1339           // get the pad position and dimensions
1340           xlocal1 = pad.Position().X();
1341           ylocal1 = pad.Position().Y();
1342           xlocal2 = pad.Dimensions().X();
1343           ylocal2 = pad.Dimensions().Y();
1344           
1345           kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1346           // (no transformation for pad dimensions)
1347           xg2 = xlocal2;
1348           yg2 = ylocal2;
1349           
1350           // transform in the monitor coordinate system
1351           //xpmin = -(xg1+xg2);
1352           //xpmax = -(xg1-xg2);
1353           //ypmin = -(yg2-yg1);
1354           //ypmax = +(yg2+yg1);
1355           // ALICE SC
1356           xpmin = +(xg1-xg2);
1357           xpmax = +(xg1+xg2);
1358           ypmin = -(yg2-yg1);
1359           ypmax = +(yg2+yg1);
1360           
1361           xpmin -= fXCenter[i];
1362           xpmax -= fXCenter[i];
1363           ypmin -= fYCenter[i];
1364           ypmax -= fYCenter[i];
1365           xdw = xpmax-xpmin;
1366           ydw = ypmax-ypmin;
1367           
1368           // x-strips
1369           if (bx) {
1370             
1371             Int_t iX, iY1, iY2, iyDig;
1372             iX  = fBoard->GetXSix();
1373             iY1 = fBoard->GetXSiy1();
1374             iY2 = fBoard->GetXSiy2();
1375             if (ix == iX && iy >= iY1 && iy <= iY2) {
1376               /*                  
1377               xpmin += 0.01*fXWidth[i];
1378               xpmax -= 0.01*fXWidth[i];
1379               ypmin += 0.1*ydw;
1380               ypmax -= 0.1*ydw;
1381               */
1382               iyDig = iy - iY1;
1383               fXDigPL[i][iyDig]->SetPoint(0,xpmin,ypmin);
1384               fXDigPL[i][iyDig]->SetPoint(1,xpmax,ypmin);
1385               fXDigPL[i][iyDig]->SetPoint(2,xpmax,ypmax);
1386               fXDigPL[i][iyDig]->SetPoint(3,xpmin,ypmax);
1387               fXDigPL[i][iyDig]->SetPoint(4,xpmin,ypmin);
1388               fXDigPL[i][iyDig]->Draw();
1389               /*              
1390               fXDigBox[i][iyDig]->SetFillStyle(1001);
1391               fXDigBox[i][iyDig]->SetFillColor(5);
1392               fXDigBox[i][iyDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1393               */
1394               if (makeLabelsX) {
1395                 sprintf(cln,"%2d",(iy-iY1));
1396                 pty1 = ypmin;
1397                 pty2 = ypmax;
1398                 
1399                 ptx1 = 1.065*xpmin - 0.04*xcw;
1400                 ptx2 = 1.065*xpmin + 0.04*xcw;
1401                 fXLabelL[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1402                 fXLabelL[i][iy-iY1]->SetBorderSize(0);
1403                 fXLabelL[i][iy-iY1]->SetBit(kCannotPick);
1404                 
1405                 ptx1 = 1.065*xpmax - 0.04*xcw;
1406                 ptx2 = 1.065*xpmax + 0.04*xcw;
1407                 fXLabelR[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1408                 fXLabelR[i][iy-iY1]->SetBorderSize(0);
1409                 fXLabelR[i][iy-iY1]->SetBit(kCannotPick);
1410               }
1411
1412             }
1413             
1414           }
1415           
1416         }  // end maxY
1417         
1418       }  // end maxX
1419       
1420     }  // end DEIterator
1421     
1422     fCanvas[i]->Modified();
1423     fCanvas[i]->Update();
1424
1425   }
1426
1427   fMain->MapWindow();
1428
1429 }
1430
1431 //__________________________________________________________________________
1432 void AliMUONTriggerGUIbdmap::CloseWindow()
1433 {
1434   /// close dialog in response to window manager close.
1435
1436   delete this;
1437
1438 }
1439
1440 //__________________________________________________________________________
1441 void AliMUONTriggerGUIbdmap::DoClose()
1442 {
1443   /// handle Close button.
1444
1445   fBoard->SetOpen(kFALSE);
1446   TTimer::SingleShot(150,"AliMUONTriggerGUIbdmap",this,"CloseWindow()");
1447
1448 }
1449
1450