]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerGUIbdmap.cxx
Bring PIPEupgrade naming conventions in acc. with ITSU expectations
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGUIbdmap.cxx
index 0ba12240bdff2bab1504f40b49ce587b3e52432a..cf2cd868b2f408adf567d7cbd00499ec9de4c353 100644 (file)
 
 // $Id$
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONTriggerGUIbdmap
 ///
 /// The gui map of a single board object, strips/digits
 ///
 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
+//-----------------------------------------------------------------------------
 
 #include <TPolyLine.h>
 #include <TStyle.h>
 #include <TObjArray.h>
 #include <TCanvas.h>
 
-#include "AliRun.h"
-#include "AliMUON.h"
+#include "AliLoader.h"
+#include "AliRunLoader.h"
 #include "AliMUONVDigit.h"
-#include "AliMpVSegmentation.h"
-#include "AliMpSegmentation.h"
 #include "AliMUONGeometryTransformer.h"
-#include "AliMpDEIterator.h"
 #include "AliMUONLocalTrigger.h"
 #include "AliMUONLocalTriggerBoard.h"
 #include "AliMUONTriggerCrateStore.h"
-
+#include "AliMUONMCDataInterface.h"
+#include "AliMUONTriggerStoreV1.h"
+#include "AliMUONDigitStoreV1.h"
 #include "AliMUONTriggerGUIboard.h"
 #include "AliMUONTriggerGUIbdmap.h"
 
-#include "AliMUONVTriggerStore.h"
-#include "AliMUONVDigitStore.h"
-
 #include "AliMpDEManager.h"
+#include "AliMpDEIterator.h"
+#include "AliMpEncodePair.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpSegmentation.h"
+
+#include <cstdio>
+
 
 /// \cond CLASSIMP
 ClassImp(AliMUONTriggerGUIbdmap)
 /// \endcond
 
 //__________________________________________________________________________
-AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
+AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow *mainWindow, UInt_t w, UInt_t h)
   : TGFrame(0),
     fMain(0),
     fLocTrigE(0),
     fBoard(0),
     fLoader(0),
+    fMCDataInterface(0),
+    fRawDigitStore(0),
+    fRawTriggerStore(0),
     fXStrips(0),
     fYStrips(0),
     fEditStrips(0),
@@ -74,7 +82,9 @@ AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow
     fCanvasSize(0),
     fNStripX(0),
     fNStripY(0),
-    fBoards(0)
+    fBoards(0),
+    fCalibrationData(0x0),
+    fCrateManager(0)
 {
   /// frame constructor
 
@@ -83,7 +93,7 @@ AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow
   gStyle->SetPadTopMargin(0.05);
   gStyle->SetPadBottomMargin(0.05);
 
-  fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
+  fMain = new TGTransientFrame(p, mainWindow, w, h, kVerticalFrame);
   fMain->Connect("CloseWindow()", "AliMUONTriggerGUIbdmap", this, "CloseWindow()");
   fMain->DontCallClose(); // to avoid double deletions.
   
@@ -97,10 +107,10 @@ AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow
   fCanvasSize = 200;
 
   TRootEmbeddedCanvas *recanvas[4];
-  Char_t ecname[1];
+  Char_t ecname[2];
   for (Int_t i = 0; i < kNMT; i++) {
 
-    sprintf(ecname,"%1d",i+1);
+    snprintf(ecname,2,"%1d",i+1);
     recanvas[i] = new TRootEmbeddedCanvas(ecname,fMain,fCanvasSize,fCanvasSize);
     
     fCanvas[i] = recanvas[i]->GetCanvas();
@@ -271,25 +281,27 @@ void AliMUONTriggerGUIbdmap::Show()
 void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
 {
   /// print the local trigger
-  
-  AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
-  crateManager->ReadFromFile();
 
   TGText txt;
   Char_t buffer[20];
 
-  sprintf(buffer,"Local trigger info\n");
+  snprintf(buffer,20,"Local trigger info\n");
   fLocTrigE->LoadBuffer(buffer);
 
-  AliRunLoader *runLoader = fLoader->GetRunLoader();
-  gAlice = runLoader->GetAliRun();
+  AliMUONVTriggerStore *triggerStore;
+
+  if (fLoader != 0x0) {
+    AliRunLoader *runLoader = fLoader->GetRunLoader();
+    triggerStore = fMCDataInterface->TriggerStore(runLoader->GetEventNumber());
+  } else if (fRawTriggerStore != 0x0) {
+    triggerStore = static_cast<AliMUONVTriggerStore*>(fRawTriggerStore);
+  } else {
+    snprintf(buffer,20,"No data loaded yet...\n");
+    txt.LoadBuffer(buffer);
+    fLocTrigE->AddText(&txt);
+    return;
+  }
 
-  fLoader->LoadDigits("READ");
-  
-  TTree* treeD = fLoader->TreeD();
-  
-  AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
-  
   Int_t circuitNumber = fBoard->GetIdCircuit();
 
   UShort_t x2m, x2u, x2d;
@@ -305,7 +317,7 @@ void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
 
     if (loCircuit == circuitNumber) {
 
-      AliMUONLocalTriggerBoard* ltb = crateManager->LocalBoard(loCircuit);
+      AliMUONLocalTriggerBoard* ltb = fCrateManager->LocalBoard(loCircuit);
       x2d = ltb->GetSwitch(0);
       x2m = ltb->GetSwitch(1);
       x2u = ltb->GetSwitch(2);
@@ -323,43 +335,43 @@ void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
        iStripY = loStripY;
       }
 
-      sprintf(buffer,"Circuit = %03d",loCircuit);
+      snprintf(buffer,20,"Circuit = %03d",loCircuit);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"LoStripX = %2d",loStripX);
+      snprintf(buffer,20,"LoStripX = %2d",loStripX);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"LoStripY = %2d",loStripY);
+      snprintf(buffer,20,"LoStripY = %2d",loStripY);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"LoDev = %2d",loDev);
+      snprintf(buffer,20,"LoDev = %2d",loDev);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"--------------------");
+      snprintf(buffer,20,"--------------------");
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"X-strip = %2d ( %2d )",iStripX,(loStripX+loDev+1)/2);
+      snprintf(buffer,20,"X-strip = %2d ( %2d )",iStripX,(loStripX+loDev+1)/2);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"Y-strip = %2d",iStripY);
+      snprintf(buffer,20,"Y-strip = %2d",iStripY);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"--------------------");
+      snprintf(buffer,20,"--------------------");
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"LoLpt = %2d",loLpt);
+      snprintf(buffer,20,"LoLpt = %2d",loLpt);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
-      sprintf(buffer,"LoHpt = %2d",loHpt);
+      snprintf(buffer,20,"LoHpt = %2d",loHpt);
       txt.LoadBuffer(buffer);
       fLocTrigE->AddText(&txt);
 
@@ -369,7 +381,6 @@ void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
 
   }
   
-  delete triggerStore;
 }
 
 //__________________________________________________________________________
@@ -377,52 +388,13 @@ void AliMUONTriggerGUIbdmap::Init()
 {
   /// initialize the boards in the four MT
 
-  TString mapspath = gSystem->Getenv("ALICE_ROOT");
-  mapspath.Append("/MUON/data");
-
-  TString mapName[kNMT];
-  mapName[0] = TString(mapspath.Data());
-  mapName[1] = TString(mapspath.Data());
-  mapName[2] = TString(mapspath.Data());
-  mapName[3] = TString(mapspath.Data());
-  mapName[0].Append("/guimapp11.txt");
-  mapName[1].Append("/guimapp12.txt");
-  mapName[2].Append("/guimapp13.txt");
-  mapName[3].Append("/guimapp14.txt");
-
-  Int_t side, col, line, nbx;
-  Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
-  Char_t name[8];
-
-  FILE *fmap;
   for (Int_t i = 0; i < kNMT; i++) {
 
-    fmap = fopen(mapName[i].Data(),"r");
-
-    for (Int_t ib = 0; ib < kNBoards; ib++) {
-
-      fscanf(fmap,"%d   %d   %d   %d   %f   %f   %f   %f   %f   %s   \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
-
-      if (side == 0) {
-       sprintf(name,"LC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
-      }
-      if (side == 1) {
-       sprintf(name,"RC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
-      }
-
-      if (strncmp(name,fBoard->GetBoardName(),7) == 0) {
-       fXWidth[i]  = xWidth;
-       fYWidth[i]  = yWidth; 
-       fXCenter[i] = xCenter;
-       fYCenter[i] = yCenter; 
-
-       fclose(fmap);
-
-       break;
-      }
-
-    }
-
+    fXWidth[i]  = fBoard->GetXWidth(i);
+    fYWidth[i]  = fBoard->GetYWidth(i); 
+    fXCenter[i] = fBoard->GetXCenter(i);
+    fYCenter[i] = fBoard->GetYCenter(i); 
+    
   }
 
   Float_t xw, yw;
@@ -491,7 +463,7 @@ void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *
   Int_t np = 5;
   Double_t xMin, xMax, yMin, yMax;
   Float_t xd, yd, fxDim, fyDim, cDim;
-  Char_t cln[2];
+  Char_t cln[3];
 
   cDim = (Float_t)fCanvasSize;
   
@@ -542,7 +514,7 @@ void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *
              fXDigBox[iMT][ix]->SetFillStyle(1001);
              fXDigBox[iMT][ix]->SetFillColor(2);
 
-             sprintf(cln,"%2d",ix);
+             snprintf(cln,3,"%2d",ix);
 
              fXLabelL[iMT][ix]->Clear();
              fXLabelL[iMT][ix]->AddText(cln);
@@ -616,7 +588,7 @@ void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *
              fYDigBox[iMT][iy]->SetFillStyle(1001);
              fYDigBox[iMT][iy]->SetFillColor(2);
 
-             sprintf(cln,"%2d",iy);
+             snprintf(cln,3,"%2d",iy);
 
              fYLabelL[iMT][iy]->Clear();
              fYLabelL[iMT][iy]->AddText(cln);
@@ -631,7 +603,7 @@ void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *
              fYDigBox[iMT][iy]->SetX2(xMax);
              fYDigBox[iMT][iy]->SetY2(yMax);
              
-             //fYDigBox[iMT][iy]->Draw();
+             fYDigBox[iMT][iy]->Draw();
 
            } else if (fYDigBox[iMT][iy]->GetFillStyle() == 1001) {
 
@@ -648,7 +620,7 @@ void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *
              fYDigBox[iMT][iy]->SetX2(-fBoard->GetXCenter(iMT));
              fYDigBox[iMT][iy]->SetY2(-fBoard->GetYCenter(iMT));
 
-             //fYDigBox[iMT][iy]->Draw();
+             fYDigBox[iMT][iy]->Draw();
 
            }
 
@@ -863,10 +835,14 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
 {
   /// draw the digits in "x" or/and "y"
 
-  AliRunLoader *runLoader = fLoader->GetRunLoader();
-  gAlice = runLoader->GetAliRun();
-  AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
-  const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
+  Bool_t drawDigits = kTRUE;
+  Bool_t drawDigitsRaw = kTRUE;
+  if (fLoader == 0x0) {
+    drawDigits = kFALSE;
+  }
+  if (fRawDigitStore == 0x0) {
+    drawDigitsRaw = kFALSE;
+  }
   
   AliMUONTriggerGUIboard *board;
   Int_t over, pos, number;
@@ -879,199 +855,218 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
   Float_t xg1, xg2, yg1, yg2, zg1;
   Float_t xdw, ydw, xcw, ycw;
   Double_t xc1, xc2, yc1, yc2;
-  Char_t cln[2];
+  Char_t cln[3];
   TBox *boxd;
   Double_t xMin, xMax, yMin, yMax;
   Double_t *px, *py;
-
+    
   number = fBoard->GetNumber();
   pos    = fBoard->GetPosition();
   over   = fBoard->GetYOver();
-
-  fLoader->LoadDigits("READ");
-  TTree* treeD = fLoader->TreeD();
-  AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
   
-  for (Int_t i = 0; i < kNMT; i++) {
+  if (drawDigits || drawDigitsRaw) {
 
+  for (Int_t i = 0; i < kNMT; i++) {
+    
     fCanvas[i]->cd();
     
     fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
     xcw = (Float_t)(0.5*(xc2-xc1));
     ycw = (Float_t)(0.5*(yc2-yc1));
 
-    chamber = 11+i;
+    AliMUONVDigitStore *digitStore = 0x0;
+    AliMUONGeometryTransformer transformer;
+    transformer.LoadGeometryData("transform.dat");
 
-    AliMpIntPair deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
-    TIter next(digitStore->CreateIterator(deRange.GetFirst(),deRange.GetSecond()));
-    AliMUONVDigit *mdig;
+    if (drawDigits) {
+      AliRunLoader *runLoader = fLoader->GetRunLoader();
+      digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
+    }
+    if (drawDigitsRaw) {
+      digitStore = static_cast<AliMUONVDigitStore*>(fRawDigitStore);
+    }
 
+    chamber = 11+i;
+    
+    MpPair_t deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
+    TIter next(digitStore->CreateIterator(AliMp::PairFirst(deRange),AliMp::PairSecond(deRange)));
+    AliMUONVDigit *mdig;
+    
     while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
-    {
-      cathode = mdig->Cathode()+1;
-      
-      ix = mdig->PadX();
-      iy = mdig->PadY();
-      detElemId = mdig->DetElemId(); 
-      charge = (Int_t)mdig->Charge();
-
-      Bool_t triggerBgn = kFALSE;
-      Int_t schg = (Int_t)(charge + 0.5);
-      // APPLY CONDITION ON SOFT BACKGROUND    
-      Int_t tchg = schg - (Int_t(schg/10))*10; 
-      if (schg<=10 || tchg>0) {
-       triggerBgn = kFALSE;
-      } else {
-       triggerBgn = kTRUE;
-      }
-
-      if (detElemId%100 != fBoard->GetDetElemId()) continue;
-      
-      seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode-1));  
-      
-      pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
-      
-      //if (cathode == 1) printf("GUI x:  ix %d iy %d \n",ix,iy);
-      //if (cathode == 2) printf("GUI y:  ix %d iy %d \n",ix,iy);
-
-      // get the pad position and dimensions
-      Float_t xlocal1 = pad.Position().X();
-      Float_t ylocal1 = pad.Position().Y();
-      Float_t xlocal2 = pad.Dimensions().X();
-      Float_t ylocal2 = pad.Dimensions().Y();
-      
-      kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
-      // (no transformation for pad dimensions)
-      xg2 = xlocal2;
-      yg2 = ylocal2;
-      
-      // transform in the monitor coordinate system
-      //xpmin = -(xg1+xg2);
-      //xpmax = -(xg1-xg2);
-      //ypmin = -(yg2-yg1);
-      //ypmax = +(yg2+yg1);
-      // ALICE SC
-      xpmin = +(xg1-xg2);
-      xpmax = +(xg1+xg2);
-      ypmin = -(yg2-yg1);
-      ypmax = +(yg2+yg1);
-       
-      xpmin -= fXCenter[i];
-      xpmax -= fXCenter[i];
-      ypmin -= fYCenter[i];
-      ypmax -= fYCenter[i];
-
-      xdw = xpmax-xpmin;
-      ydw = ypmax-ypmin;
-
-      // x-strips
-      if ((xdw > ydw) && bx) {
-
-       //printf("X strips mdig->Cathode() = %1d \n",mdig->Cathode());
-
-       Int_t iX, iY1, iY2;
-       iX  = fBoard->GetXSix();
-       iY1 = fBoard->GetXSiy1();
-       iY2 = fBoard->GetXSiy2();
-       if (ix == iX && iy >= iY1 && iy <= iY2) {
-         //printf("Digit indices (x-strip) ix = %3d iy = %3d board = %s %d chamber = %2d \n",ix,iy,fBoard->GetBoardName(),fBoard->GetNumber(),chamber); 
-         /*
-         xpmin += 0.01*fXWidth[i];
-         xpmax -= 0.01*fXWidth[i];
-         ypmin += 0.1*ydw;
-         ypmax -= 0.1*ydw;
-         */
-         boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
-         boxd->SetFillStyle(1001);
-         if (triggerBgn) boxd->SetFillColor(6);
-         else boxd->SetFillColor(5);
-         boxd->SetBit(kCannotPick);
-         boxd->Draw();
+      {
+       cathode = mdig->Cathode();
+       
+       ix = mdig->PadX();
+       iy = mdig->PadY();
+       detElemId = mdig->DetElemId(); 
+       charge = (Int_t)mdig->Charge();
+       
+       Bool_t triggerBgn = kFALSE;
+       Int_t schg = (Int_t)(charge + 0.5);
+       // APPLY CONDITION ON SOFT BACKGROUND   
+       Int_t tchg = schg - (Int_t(schg/10))*10;        
+       if (schg<=10 || tchg>0) {
+         triggerBgn = kFALSE;
+       } else {
+         triggerBgn = kTRUE;
+       }
+       
+       if (detElemId%100 != fBoard->GetDetElemId()) continue;
+       
+       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));  
+       
+       pad = seg->PadByIndices(ix,iy,kTRUE);
+       
+       //if (cathode == 0) printf("GUI x:  ix %d iy %d \n",ix,iy);
+       //if (cathode == 1) printf("GUI y:  ix %d iy %d \n",ix,iy);
+       
+       // get the pad position and dimensions
+       Float_t xlocal1 = pad.GetPositionX();
+       Float_t ylocal1 = pad.GetPositionY();
+       Float_t xlocal2 = pad.GetDimensionX();
+       Float_t ylocal2 = pad.GetDimensionY();
+       
+       transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+       // (no transformation for pad dimensions)
+       xg2 = xlocal2;
+       yg2 = ylocal2;
+       
+       // transform in the monitor coordinate system
+       // ALICE SC
+       xpmin = +(xg1-xg2);
+       xpmax = +(xg1+xg2);
+       ypmin = -(yg2-yg1);
+       ypmax = +(yg2+yg1);
+       
+       xpmin -= fXCenter[i];
+       xpmax -= fXCenter[i];
+       ypmin -= fYCenter[i];
+       ypmax -= fYCenter[i];
+       
+       xdw = xpmax-xpmin;
+       ydw = ypmax-ypmin;
+       
+       // x-strips
+       if ((xdw > ydw) && bx) {
          
-         fXDigBox[i][iy-iY1]->SetFillStyle(1001);
-         fXDigBox[i][iy-iY1]->SetFillColor(2);
-         fXDigBox[i][iy-iY1]->SetX1(xpmin);
-         fXDigBox[i][iy-iY1]->SetY1(ypmin);
-         fXDigBox[i][iy-iY1]->SetX2(xpmax);
-         fXDigBox[i][iy-iY1]->SetY2(ypmax);
-         fXDigBox[i][iy-iY1]->Draw();
-
-         sprintf(cln,"%2d",(iy-iY1));
-         fXLabelL[i][iy-iY1]->Clear();
-         fXLabelL[i][iy-iY1]->AddText(cln);
-         fXLabelL[i][iy-iY1]->Draw();
-         fXLabelR[i][iy-iY1]->Clear();
-         fXLabelR[i][iy-iY1]->AddText(cln);
-         fXLabelR[i][iy-iY1]->Draw();
-
-         fBoard->SetDigitX(i,iy-iY1,charge);
-
+         //printf("X strips mdig->Cathode() = %1d \n",mdig->Cathode());
+         
+         Int_t iX, iY1, iY2;
+         iX  = fBoard->GetXSix();
+         iY1 = fBoard->GetXSiy1();
+         iY2 = fBoard->GetXSiy2();
+         if (ix == iX && iy >= iY1 && iy <= iY2) {
+           //printf("Digit indices (x-strip) ix = %3d iy = %3d board = %s %d chamber = %2d \n",ix,iy,fBoard->GetBoardName(),fBoard->GetNumber(),chamber); 
+           /*
+             xpmin += 0.01*fXWidth[i];
+             xpmax -= 0.01*fXWidth[i];
+             ypmin += 0.1*ydw;
+             ypmax -= 0.1*ydw;
+           */
+           boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
+           boxd->SetFillStyle(1001);
+           if (triggerBgn) boxd->SetFillColor(6);
+           else boxd->SetFillColor(5);
+           boxd->SetBit(kCannotPick);
+           boxd->Draw();
+           
+           fXDigBox[i][iy-iY1]->SetFillStyle(1001);
+           fXDigBox[i][iy-iY1]->SetFillColor(2);
+           fXDigBox[i][iy-iY1]->SetX1(xpmin);
+           fXDigBox[i][iy-iY1]->SetY1(ypmin);
+           fXDigBox[i][iy-iY1]->SetX2(xpmax);
+           fXDigBox[i][iy-iY1]->SetY2(ypmax);
+           fXDigBox[i][iy-iY1]->Draw();
+           
+           snprintf(cln,3,"%2d",(iy-iY1));
+           fXLabelL[i][iy-iY1]->Clear();
+           fXLabelL[i][iy-iY1]->AddText(cln);
+           fXLabelL[i][iy-iY1]->Draw();
+           fXLabelR[i][iy-iY1]->Clear();
+           fXLabelR[i][iy-iY1]->AddText(cln);
+           fXLabelR[i][iy-iY1]->Draw();
+           
+           fBoard->SetDigitX(i,iy-iY1,charge);
+           
+         }
+         
+       }
+       
+       // y-strips
+       if ((xdw < ydw) && by) {
+         
+         //printf("Y strips mdig->Cathode() = %1d \n",mdig->Cathode());
+         
+         Int_t iX1, iX2, iY;
+         iX1 = fBoard->GetYSix1();
+         iX2 = fBoard->GetYSix2();
+         iY  = fBoard->GetYSiy();
+         if (ix >= iX1 && ix <= iX2 && iy == iY) {
+           //printf("Digit indices (y-strip) ix = %3d iy = %3d board = %s chamber = %2d \n",ix,iy,fBoard->GetBoardName(),chamber); 
+           ypmin = -0.5*fYWidth[i];
+           ypmax = +0.5*fYWidth[i];
+           /*
+             ypmin = -0.5*fYWidth[i];
+             ypmax = +0.5*fYWidth[i];
+             ypmin += 0.01*fYWidth[i];
+             ypmax -= 0.01*fYWidth[i];   
+             xpmin += 0.1*xdw;
+             xpmax -= 0.1*xdw;
+           */
+           boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
+           boxd->SetFillStyle(1001);
+           if (triggerBgn) boxd->SetFillColor(6);
+           else boxd->SetFillColor(5);
+           boxd->SetBit(kCannotPick);
+           boxd->Draw();
+           
+           fYDigBox[i][ix-iX1]->SetFillStyle(1001);
+           fYDigBox[i][ix-iX1]->SetFillColor(2);
+           fYDigBox[i][ix-iX1]->SetX1(xpmin);
+           fYDigBox[i][ix-iX1]->SetY1(ypmin);
+           fYDigBox[i][ix-iX1]->SetX2(xpmax);
+           fYDigBox[i][ix-iX1]->SetY2(ypmax);
+           fYDigBox[i][ix-iX1]->Draw();
+           
+           snprintf(cln,3,"%2d",(ix-iX1));
+           fYLabelL[i][ix-iX1]->Clear();
+           fYLabelL[i][ix-iX1]->AddText(cln);
+           fYLabelL[i][ix-iX1]->Draw();
+           fYLabelR[i][ix-iX1]->Clear();
+           fYLabelR[i][ix-iX1]->AddText(cln);
+           fYLabelR[i][ix-iX1]->Draw();
+           
+           fBoard->SetDigitY(i,ix-iX1,charge);
+           
+           // extended y-strips
+           for (Int_t io = 1; io <= over; io++) {
+             if (io == pos) continue;
+             board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
+             board->SetDigitY(i,ix-iX1,charge);
+           }
+           
+         }
        }
+       
+      }  // end digits loop
 
-      }
+  }  // end chamber loop
 
-      // y-strips
-      if ((xdw < ydw) && by) {
-
-       //printf("Y strips mdig->Cathode() = %1d \n",mdig->Cathode());
-
-       Int_t iX1, iX2, iY;
-       iX1 = fBoard->GetYSix1();
-       iX2 = fBoard->GetYSix2();
-       iY  = fBoard->GetYSiy();
-       if (ix >= iX1 && ix <= iX2 && iy == iY) {
-         //printf("Digit indices (y-strip) ix = %3d iy = %3d board = %s chamber = %2d \n",ix,iy,fBoard->GetBoardName(),chamber); 
-         ypmin = -0.5*fYWidth[i];
-         ypmax = +0.5*fYWidth[i];
-         /*
-         ypmin = -0.5*fYWidth[i];
-         ypmax = +0.5*fYWidth[i];
-         ypmin += 0.01*fYWidth[i];
-         ypmax -= 0.01*fYWidth[i];       
-         xpmin += 0.1*xdw;
-         xpmax -= 0.1*xdw;
-         */
-         boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
-         boxd->SetFillStyle(1001);
-         if (triggerBgn) boxd->SetFillColor(6);
-         else boxd->SetFillColor(5);
-         boxd->SetBit(kCannotPick);
-         boxd->Draw();
-
-         fYDigBox[i][ix-iX1]->SetFillStyle(1001);
-         fYDigBox[i][ix-iX1]->SetFillColor(2);
-         fYDigBox[i][ix-iX1]->SetX1(xpmin);
-         fYDigBox[i][ix-iX1]->SetY1(ypmin);
-         fYDigBox[i][ix-iX1]->SetX2(xpmax);
-         fYDigBox[i][ix-iX1]->SetY2(ypmax);
-         fYDigBox[i][ix-iX1]->Draw();
-
-         sprintf(cln,"%2d",(ix-iX1));
-         fYLabelL[i][ix-iX1]->Clear();
-         fYLabelL[i][ix-iX1]->AddText(cln);
-         fYLabelL[i][ix-iX1]->Draw();
-         fYLabelR[i][ix-iX1]->Clear();
-         fYLabelR[i][ix-iX1]->AddText(cln);
-         fYLabelR[i][ix-iX1]->Draw();
-
-         fBoard->SetDigitY(i,ix-iX1,charge);
-
-         // extended y-strips
-         for (Int_t io = 1; io <= over; io++) {
-           if (io == pos) continue;
-           board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
-           board->SetDigitY(i,ix-iX1,charge);
-         }
+  }  // end drawDigits
 
-       }
-      }
-      
-    }  // end digits loop
+  // DSET digits
+  for (Int_t i = 0; i < kNMT; i++) {
+    
+    fCanvas[i]->cd();
+    
+    fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
+    xcw = (Float_t)(0.5*(xc2-xc1));
+    ycw = (Float_t)(0.5*(yc2-yc1));
     
     // x-strips DSET
     if (bx) {
       
-      for (Int_t ix = 0; ix < fNStripX; ix++) {
+      for (ix = 0; ix < fNStripX; ix++) {
        //if (fBoard->GetXDig(i,ix) > 0) {
        if (fXDigBox[i][ix]->GetFillStyle() == 1001 || 
            fBoard->GetXDig(i,ix) > 0) {
@@ -1099,7 +1094,7 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
            fXDigBox[i][ix]->SetY2(yMax);
          }
          
-         sprintf(cln,"%2d",ix);
+         snprintf(cln,3,"%2d",ix);
          
          fXLabelL[i][ix]->Clear();
          fXLabelL[i][ix]->AddText(cln);
@@ -1120,7 +1115,7 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
     // y-strips DSET
     if (by) {
       
-      for (Int_t iy = 0; iy < fNStripY; iy++) {
+      for (iy = 0; iy < fNStripY; iy++) {
        //if (fBoard->GetYDig(i,iy) > 0) {
        if (fYDigBox[i][iy]->GetFillStyle() == 1001 || 
            fBoard->GetYDig(i,iy) > 0) {
@@ -1148,7 +1143,7 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
            fYDigBox[i][iy]->SetY2(yMax);
          }
          
-         sprintf(cln,"%2d",iy);
+         snprintf(cln,3,"%2d",iy);
          
          fYLabelL[i][iy]->Clear();
          fYLabelL[i][iy]->AddText(cln);
@@ -1158,7 +1153,6 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
          fYLabelR[i][iy]->AddText(cln);
          fYLabelR[i][iy]->Draw();
          
-         
          fYDigBox[i][iy]->Draw();
          
        }
@@ -1170,9 +1164,8 @@ void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
     fCanvas[i]->Modified();
     fCanvas[i]->Update();
       
-  }  // end canvas loop
+  }  // end canvas (chamber) loop
 
-  delete digitStore;
   fMain->MapWindow();
 
 }
@@ -1182,10 +1175,8 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
 {
   /// draw the "x" or/and "y" strips
 
-  AliRunLoader *runLoader = fLoader->GetRunLoader();
-  gAlice = runLoader->GetAliRun();
-  AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
-  const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
+  AliMUONGeometryTransformer transformer;
+  transformer.LoadGeometryData("transform.dat");
 
   const AliMpVSegmentation* seg;
   AliMpPad pad;
@@ -1193,10 +1184,10 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
   Int_t chamber;
   Float_t xg1, xg2, yg1, yg2, zg1;
   Float_t xlocal1, xlocal2, ylocal1, ylocal2;
-  Int_t detElemId, ic, maxX, maxY;
+  Int_t detElemId, maxX, maxY;
   Float_t xdw, ydw, xpmin, xpmax, ypmin, ypmax;
   Float_t ptx1, ptx2, pty1, pty2;
-  Char_t cln[2];
+  Char_t cln[3];
   Double_t xc1, xc2, yc1, yc2;
   Float_t xcw, ycw;
 
@@ -1229,10 +1220,9 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
     
       if (detElemId%100 != fBoard->GetDetElemId()) continue;
 
-      /*---------- y-pads ic = 2 ----------*/
-      ic = 2;
+      /*---------- y-pads ic = 1 ----------*/
       
-      seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));  
+      seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath1);  
 
       maxX = seg->MaxPadIndexX();
       maxY = seg->MaxPadIndexY();
@@ -1240,26 +1230,22 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
       for (Int_t ix = 0; ix <= maxX; ix++) {
        for (Int_t iy = 0; iy <= maxY; iy++) {
          
-         pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
+         pad = seg->PadByIndices(ix,iy,kFALSE);
          
          if (!pad.IsValid()) continue;
          
          // get the pad position and dimensions
-         xlocal1 = pad.Position().X();
-         ylocal1 = pad.Position().Y();
-         xlocal2 = pad.Dimensions().X();
-         ylocal2 = pad.Dimensions().Y();
+         xlocal1 = pad.GetPositionX();
+         ylocal1 = pad.GetPositionY();
+         xlocal2 = pad.GetDimensionX();
+         ylocal2 = pad.GetDimensionY();
          
-         kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+         transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
          // (no transformation for pad dimensions)
          xg2 = xlocal2;
          yg2 = ylocal2;
          
          // transform in the monitor coordinate system
-         //xpmin = -(xg1+xg2);
-         //xpmax = -(xg1-xg2);
-         //ypmin = -(yg2-yg1);
-         //ypmax = +(yg2+yg1);
          // ALICE SC
          xpmin = +(xg1-xg2);
          xpmax = +(xg1+xg2);
@@ -1304,7 +1290,7 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
              fYDigBox[i][ixDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
              */
              if (makeLabelsY) {
-               sprintf(cln,"%2d",(ix-iX1));
+               snprintf(cln,3,"%2d",(ix-iX1));
                ptx1 = xpmin;
                ptx2 = xpmax;
                
@@ -1329,10 +1315,9 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
        
       }  // end maxX
       
-      /*---------- x-pads ic = 1 ----------*/
-      ic = 1;
+      /*---------- x-pads ic = 0 ----------*/
       
-      seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1)); 
+      seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath0); 
 
       maxX = seg->MaxPadIndexX();
       maxY = seg->MaxPadIndexY();
@@ -1340,26 +1325,22 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
       for (Int_t ix = 0; ix <= maxX; ix++) {
        for (Int_t iy = 0; iy <= maxY; iy++) {
          
-         pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
+         pad = seg->PadByIndices(ix,iy,kFALSE);
          
          if (!pad.IsValid()) continue;
          
          // get the pad position and dimensions
-         xlocal1 = pad.Position().X();
-         ylocal1 = pad.Position().Y();
-         xlocal2 = pad.Dimensions().X();
-         ylocal2 = pad.Dimensions().Y();
+         xlocal1 = pad.GetPositionX();
+         ylocal1 = pad.GetPositionY();
+         xlocal2 = pad.GetDimensionX();
+         ylocal2 = pad.GetDimensionY();
          
-         kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+         transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
          // (no transformation for pad dimensions)
          xg2 = xlocal2;
          yg2 = ylocal2;
          
          // transform in the monitor coordinate system
-         //xpmin = -(xg1+xg2);
-         //xpmax = -(xg1-xg2);
-         //ypmin = -(yg2-yg1);
-         //ypmax = +(yg2+yg1);
          // ALICE SC
          xpmin = +(xg1-xg2);
          xpmax = +(xg1+xg2);
@@ -1400,7 +1381,7 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
              fXDigBox[i][iyDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
              */
              if (makeLabelsX) {
-               sprintf(cln,"%2d",(iy-iY1));
+               snprintf(cln,3,"%2d",(iy-iY1));
                pty1 = ypmin;
                pty2 = ypmax;
                
@@ -1437,7 +1418,7 @@ void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
 }
 
 //__________________________________________________________________________
-void AliMUONTriggerGUIbdmap::CloseWindow()
+void AliMUONTriggerGUIbdmap::CloseWindow() const
 {
   /// close dialog in response to window manager close.