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