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