]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerCircuit.cxx
Modifications in AliESDMuonTrack:
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
index 9c23929b1df3f8044491a0492c91684657977396..10642c000131ba21de7327952a6f7de1ec02dde6 100644 (file)
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
 
 /* $Id$ */
 
-// ------------------
-// Class AliMUONTriggerCircuit
-// ------------------
-// description of the global position of the trigger boards strip positions
-// based on the "old" segmentation (to be replaced soon)
+//-----------------------------------------------------------------------------
+/// \class AliMUONTriggerCircuit
+/// Contains as data members the Y positions of the X declusturized strips and 
+/// the X positions of the (doubled or not) Y strips.
+/// This is used to associate the global positions to the fired strips of the 
+/// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
+///
+/// \author Philippe Crochet (LPCCFd)
+//-----------------------------------------------------------------------------
 
+#include "AliMUONTriggerCircuit.h"
 
-#include <TMath.h>
+#include "AliMpTriggerSegmentation.h"
+#include "AliMpTrigger.h"
+#include "AliMpSlat.h"
+#include "AliMpPCB.h"
+#include "AliMpSegmentation.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpCathodType.h"
+#include "AliMpDDLStore.h"
+#include "AliMpLocalBoard.h"
+#include "AliMpConstants.h"
 
-#include "AliMUONTriggerCircuit.h"
 #include "AliRun.h"
-#include "AliMUON.h"
-#include "AliMUONTriggerConstants.h"
-#include "AliMUONGeometrySegmentation.h"
-#include "AliMUONSegmentation.h"
-#include "AliMUONConstants.h"
 #include "AliLog.h"
 
+#include <TMath.h>
+#include <Riostream.h>
+
 /// \cond CLASSIMP
 ClassImp(AliMUONTriggerCircuit)
 /// \endcond
 
 //----------------------------------------------------------------------
-AliMUONTriggerCircuit::AliMUONTriggerCircuit()
-  : TObject(),
-    fIdCircuit(0),
-    fX2m(0),
-    fX2ud(0)
+AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
+    : TObject(),
+      fTransformer(transformer),
+      fCurrentSeg(0x0),
+      fCurrentDetElem(0x0),
+      fCurrentLocalBoard(0x0)
 {
 /// Constructor
+  
+    for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
+      fXpos11[i].Set(16); 
+      fYpos11[i].Set(31);
+      fYpos21[i].Set(63);
+    }
 
-  fOrMud[0]=fOrMud[1]=0;
-  Int_t i;  
-  for (i=0; i<4; i++) {
-    for (Int_t j=0; j<32; j++) {      
-      fXcode[i][j]=0;
-      fYcode[i][j]=0;
+    for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) { // board begins at 1
+  
+    AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(i);
+
+    if (!localBoard)
+    {
+      AliError(Form("Did not get localboard %d",i));
+      continue;
     }
+
+    LoadXPos(localBoard);
+    LoadYPos(localBoard);
+
   }
-  for (i=0; i<16; i++) { fXpos11[i]=0.; }
-  for (i=0; i<31; i++) { fYpos11[i]=0.; }
-  for (i=0; i<63; i++) { fYpos21[i]=0.; }
+
 }
 
 //----------------------------------------------------------------------
 AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
 {
 /// Destructor
+   for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
+     fXpos11[i].Reset();
+     fYpos11[i].Reset();
+     fYpos21[i].Reset();
+    }
+
 } 
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::Init(Int_t iCircuit) {
-/// initialize circuit characteristics
-  fIdCircuit=AliMUONTriggerConstants::CircuitId(iCircuit);
-
-  LoadX2();
-  LoadXCode();
-  LoadYCode();
-
-  LoadXPos2();
-  LoadYPos2();
-  
-}
+AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
+    :  TObject(circuit),
+       fTransformer(circuit.fTransformer), // do not copy, just pointed to
+       fCurrentSeg(circuit.fCurrentSeg),
+       fCurrentDetElem(circuit.fCurrentDetElem),
+       fCurrentLocalBoard(circuit.fCurrentLocalBoard)
+{
+/// Copy constructor
 
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::CircuitNumber(Int_t idCircuit) const {
-/// returns circuit number iCircuit (0-234) corresponding to circuit idCircuit
-  Int_t iCircuit=0;
-  for (Int_t i=0; i<234; i++) {
-    if (AliMUONTriggerConstants::CircuitId(i)==idCircuit) {
-      iCircuit=i;
-      break;
+    for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
+      fXpos11[i] = circuit.fXpos11[i];
+      fYpos11[i] = circuit.fYpos11[i];
+      fYpos21[i] = circuit.fYpos21[i];
     }
-  }
-  return iCircuit;
+
 }
 //----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::ModuleNumber(Int_t idModule) const {
-/// returns module number imod (from 0 to 63) corresponding to module idmodule
-  Int_t absidModule=TMath::Abs(idModule);
-  Int_t iModule=0;
-  for (Int_t i=0; i<63; i++) {
-    if (AliMUONTriggerConstants::ModuleId(i)==absidModule) { 
-      iModule=i;
-      break;
-    }
+AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit) 
+{
+/// Assignment operator
+
+  if (this == &circuit) return *this;
+
+  fTransformer       = circuit.fTransformer;
+  fCurrentSeg        = circuit.fCurrentSeg;
+  fCurrentDetElem    = circuit.fCurrentDetElem;
+  fCurrentLocalBoard = circuit.fCurrentLocalBoard;
+
+  for (Int_t i = 1; i < AliMpConstants::NofLocalBoards()+1; ++i) {
+    fXpos11[i] = circuit.fXpos11[i];
+    fYpos11[i] = circuit.fYpos11[i];
+    fYpos21[i] = circuit.fYpos21[i];
   }
-  return iModule;
-}
 
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::Module(Int_t idCircuit) const {
-/// returns ModuleId where Circuit idCircuit is sitting
-  return Int_t(idCircuit/10);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::Position(Int_t idCircuit) const {
-/// returns position of idCircuit in correcponding Module
-  return TMath::Abs(idCircuit)-TMath::Abs(Module(idCircuit))*10;
+  return *this;
+
 }
 
-//----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadX2() {
-/// initialize fX2m, fX2ud and fOrMud
-  
-  Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
-// and its number of X strips
-  Int_t nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule)); 
-// and its number of Y strips
-  Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
-  Int_t iPosCircuit=Position(fIdCircuit); // position of circuit in module
-  
-// first step : look at lower part 
-  if (iPosCircuit==1) {               // need to scan lower module       
-    if(idModule<91&&TMath::Abs(idModule)!=41&&idModule>-91) { 
-      fOrMud[0]=1;
-      Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
-      Int_t nStrD=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleD));
-      
-      if (nStrY!=nStrD    
-         &&TMath::Abs(idModule)!=42&&TMath::Abs(idModule)!=52) {   
-       if (nStrY==8) fX2m=1; 
-       if (nStrD==8) fX2ud=1; 
-      }      
-    }      
-
-  } else {                         // lower strips within same module       
-    fOrMud[0]=0;
-  }    
+//---------------------------------------------------------------------
+void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
+{
+/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
   
-// second step : look at upper part
-  if ((iPosCircuit==1&&nStrX==16)||(iPosCircuit==2&&nStrX==32)|| 
-      (iPosCircuit==3&&nStrX==48)||(iPosCircuit==4&&nStrX==64)) {   
-    if ((idModule>17||idModule<-17)&&TMath::Abs(idModule)!=61) {  
-      fOrMud[1]=1;
-      Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
-      Int_t nStrU=AliMUONTriggerConstants::NstripY(ModuleNumber(idModuleU)); 
-
-      if (nStrY!=nStrU    
-         &&TMath::Abs(idModule)!=62&&TMath::Abs(idModule)!=52) {   
-       if (nStrY==8) fX2m=1; 
-       if (nStrU==8) fX2ud=1;
-      }      
-    }     
+  fCurrentLocalBoard = localBoard->GetId();
+  Int_t ichamber = 0;
+  Int_t icathode = 0;    
     
-  } else {                       // upper strips within same module       
-    fOrMud[1]=0;
-  }
-}  
+  Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
+  Int_t zeroUp   = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
+  Int_t iline = localBoard->GetPosition().GetFirst();
+  Int_t icol  = localBoard->GetPosition().GetSecond();
+  if ( iline == 5 ) --icol;
+
+  //--- first plane 
+  ichamber = 10;
+  fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
+
+  fCurrentSeg = AliMpSegmentation::Instance()
+        ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
+
+  Int_t iFirstStrip = FirstStrip(localBoard);
+  Int_t iLastStrip  = iFirstStrip + 16;    
+  Int_t iStripCircuit = 0;
+
+  FillXstrips(icol, iFirstStrip, iLastStrip, 
+             iStripCircuit, fYpos11[fCurrentLocalBoard]);
+  
+  //--- second plane 
+  ichamber = 12;
+  fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-//----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadXCode(){
-/// assign a Id. number to each X strip of current circuit 
-/// Id.=(corresponding module Id.)*100+(Id. strip of module)
-
-// first part : fill XMC11 XMC12 and strips 8 to 24 (middle) XMC21 XMC22
-  Int_t iStripCircMT1=0, iStripCircMT2=8;
-  Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
-// and its number of strips
-  Int_t nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule)); 
-  Int_t iPosCircuit=Position(fIdCircuit);   // position of circuit in module  
-  Int_t sign=TMath::Abs(idModule)/idModule; // left or right 
-  Int_t istrip;
-
-  for (istrip=(iPosCircuit-1)*16; 
-       istrip<(iPosCircuit-1)*16+16; istrip++) {
-        
-    fXcode[0][iStripCircMT1]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fXcode[1][iStripCircMT1]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip);     
-    iStripCircMT1++;
-    iStripCircMT2++;
-  }
+  fCurrentSeg = AliMpSegmentation::Instance()
+        ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
+
+  // second plane middle part
+  Int_t iFirstStripMiddle = FirstStrip(localBoard);
+  Int_t iLastStripMiddle  = iFirstStrip + 16;
+  iStripCircuit = 8;
 
-// second part 
-// XMC21 XMC22 strips 0 to 7 and 24 to 31 
-  Int_t idModuleD, idModuleU;
-  Int_t nStrD, nStrU;
-
-  idModule=Module(fIdCircuit); // corresponding module Id.
-// number of X strips
-  nStrX=AliMUONTriggerConstants::NstripX(ModuleNumber(idModule));  
-  sign=TMath::Abs(idModule)/idModule;
-
-// fill lower part (0 to 7)
-  if (iPosCircuit==1) {                 // need to scan lower module 
-    if(idModule<91&&TMath::Abs(idModule)!=41&&idModule>-91) { // non-existing
-      idModuleD=sign*(TMath::Abs(idModule)+10);  // lower module Id
-// and its number of strips
-      nStrD=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleD)); 
-      
-      iStripCircMT2=0;
-      for (istrip=nStrD-8; istrip<nStrD; istrip++) {  
-       fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModuleD)*100+istrip); 
-       fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModuleD)*100+istrip); 
-       iStripCircMT2++;
-      }
+  FillXstrips(icol, iFirstStripMiddle, iLastStripMiddle,
+             iStripCircuit, fYpos21[fCurrentLocalBoard]);
+  
+  // second plane upper part
+  if (zeroUp == 0) { // something up
+    Int_t iFirstStripUp;
+    Int_t iLastStripUp;
+    Int_t icolUp = icol;
+
+    // check if we need to move to another detElemId
+    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
+
+    if (pad.IsValid()) { // upper strips within same detElemId
+      iFirstStripUp = iLastStripMiddle;
+      iLastStripUp  = iFirstStripUp + 8;
+
+    } else {             // upper strips in another detElemId
+      fCurrentDetElem = AliMpDDLStore::Instance()->
+                  GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
+
+      fCurrentSeg = AliMpSegmentation::Instance()
+            ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
+
+      iFirstStripUp = 0;
+      iLastStripUp  = iFirstStripUp + 8;
+      if (iline == 4) icolUp = icol - 1; // special case
+      if (iline == 5) icolUp = icol + 1; // special case
     }
-     
-  } else {                       // lower strips within same module 
     
-    iStripCircMT2=0;
-    for (istrip=(iPosCircuit-1)*16-8; 
-        istrip<(iPosCircuit-1)*16; istrip++) {  
-      fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
-      fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
-      iStripCircMT2++;
-    }
-  }
+    iStripCircuit = 24;
+    FillXstrips(icolUp, iFirstStripUp, iLastStripUp,
+               iStripCircuit, fYpos21[fCurrentLocalBoard]);
+    
+    // fill strip between middle and upper part
+    fYpos21[fCurrentLocalBoard][47] = (fYpos21[fCurrentLocalBoard][46] + 
+                                      fYpos21[fCurrentLocalBoard][48])/2.;
+  } // end of something up
   
-// fill upper part (24 to 31)
-  if ((iPosCircuit==1&&nStrX==16)||(iPosCircuit==2&&nStrX==32)|| 
-      (iPosCircuit==3&&nStrX==48)||(iPosCircuit==4&&nStrX==64)) {   
-    if ((idModule>17||idModule<-17)&&TMath::Abs(idModule)!=61) {  
-      idModuleU=sign*(TMath::Abs(idModule)-10);  // upper module Id
-// and its number of strips
-      nStrU=AliMUONTriggerConstants::NstripX(ModuleNumber(idModuleU)); 
-      
-      iStripCircMT2=24;
-      for (istrip=0; istrip<8; istrip++) {       
-       fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModuleU)*100+istrip); 
-       fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModuleU)*100+istrip); 
-       iStripCircMT2++;
-      }
-    }
+  // restore current detElemId & segmentation
+  fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
+  fCurrentSeg = AliMpSegmentation::Instance()
+      ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
+
+  // second plane lower part
+  if (zeroDown == 0) { // something down
+    Int_t iFirstStripDo;
+    Int_t iLastStripDo;
+    Int_t icolDo = icol;
     
-  } else if ((iPosCircuit==1&&nStrX>16)||(iPosCircuit==2&&nStrX>32)|| 
-            (iPosCircuit==3&&nStrX>48)) { // upper strips within same mod. 
+    // check if we need to move to another detElemId      
+    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
+    if (pad.IsValid()) { // lower strips within same detElemId
+      iFirstStripDo = iFirstStripMiddle - 8;
+      iLastStripDo  = iFirstStripDo + 8;             
+
+    } else {             // lower strips in another detElemId 
+      fCurrentDetElem = AliMpDDLStore::Instance()
+         ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
+
+      fCurrentSeg = AliMpSegmentation::Instance()
+         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
+
+      // get iFirstStrip in this module 
+      const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
+      const AliMpTrigger* t = trig->Slat();
+      const AliMpSlat* slat = t->GetLayer(0);
+
+      if (iline == 5) icolDo = icol + 1; // special case
+      if (iline == 6) icolDo = icol - 1; // special case
+           
+      const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
+      iFirstStripDo = (pcb->Iymax() + 1) - 8;
+      iLastStripDo =  iFirstStripDo + 8;
+    }  
     
-    iStripCircMT2=24;
-    for (istrip=(iPosCircuit-1)*16+16; 
-        istrip<(iPosCircuit-1)*16+24; istrip++) {  
-      fXcode[2][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
-      fXcode[3][iStripCircMT2]=sign*(TMath::Abs(idModule)*100+istrip); 
-      iStripCircMT2++;
-    }  
-  }
+    iStripCircuit = 0;
+    FillXstrips(icolDo, iFirstStripDo, iLastStripDo,
+               iStripCircuit, fYpos21[fCurrentLocalBoard]);
+    
+    // fill strip between middle and upper part
+    fYpos21[fCurrentLocalBoard][15] = (fYpos21[fCurrentLocalBoard][14] + 
+                                      fYpos21[fCurrentLocalBoard][16])/2.;
+  } // end of something down
+  
 }
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadYCode(){
-/// assign a Id. number to each Y strip of current circuit 
-/// Id.=(corresponding module Id.)*100+(Id. strip of module)
-/// note : for Y plane fill only "central part" of circuit
-/// (upper and lower parts are filled in PreHandlingY of AliMUONTriggerDecision)
+void AliMUONTriggerCircuit::FillXstrips(const Int_t icol, 
+                                       const Int_t iFirstStrip, const Int_t iLastStrip, 
+                                       Int_t liStripCircuit, TArrayF& ypos)
+{    
+/// fill 
+  Double_t xyGlobal[2] = {0.};
+  for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
+
+    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
+    if ( !pad.IsValid() ) {
+      StdoutToAliError(cout << "Pad not found in seg " << endl;
+                       fCurrentSeg->Print();
+                       cout << " ix,iy=" << icol-1 << "," << istrip << endl;
+                       );
+    }
+    Float_t yDim = pad.Dimensions().Y(); // half size! 
+
+    XYGlobal(pad,xyGlobal);
     
-  Int_t idModule=Module(fIdCircuit);        // corresponding module Id.
-// and its number of Y strips
-  Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
-  Int_t sign=TMath::Abs(idModule)/idModule; // left or right 
-
-  for (Int_t istrip=0; istrip<nStrY; istrip++) {
-    fYcode[0][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fYcode[1][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fYcode[2][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
-    fYcode[3][istrip]=sign*(TMath::Abs(idModule)*100+istrip); 
-  }
+    ypos[2*liStripCircuit] = xyGlobal[1];
+    if (istrip != (iLastStrip - 1)) ypos[2*liStripCircuit+1] = xyGlobal[1] + yDim;
+    liStripCircuit++;
+  }    
 }
 
+
 //----------------------------------------------------------------------
-Float_t AliMUONTriggerCircuit::PtCal(Int_t istripX, Int_t idev, Int_t istripY){
-/// returns calculated pt for circuit/istripX/idev/istripY according 
-/// to the formula of the TRD. Note : idev (input) is in [0+30]
+void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
+{
+/// fill fXpos11 -> x position of Y strips for the first plane only
+/// fXpos11 contains the x position of Y strip for the current circuit
+/// taking into account whether or nor not part(s) of the circuit
+/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
 
-  //  Int_t jdev = idev - 15;        // jdev in [-15+15]
-  Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
+  fCurrentLocalBoard = localBoard->GetId();
 
-  Float_t yPosX1=fYpos11[istripX];
-  Float_t yPosX2=fYpos21[istripX2];
-  Float_t xPosY1=fXpos11[istripY];
+  Int_t ichamber = 10;
+  Int_t icathode = 1;
   
-  Float_t zf=975.;
-  Float_t z1=AliMUONConstants::DefaultChamberZ(10);
-  Float_t z2=AliMUONConstants::DefaultChamberZ(12);
-  Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
-  Float_t xf=xPosY1*zf/z1; 
-  Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
-  return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
-}
-//---------------------------------------------------------------------
-//----------------------- New Segmentation ----------------------------
-//---------------------------------------------------------------------
+  Int_t x2u = localBoard->GetSwitch(AliMpLocalBoard::kX2u);
+  Int_t x2m = localBoard->GetSwitch(AliMpLocalBoard::kX2m);
+  Int_t x2d = localBoard->GetSwitch(AliMpLocalBoard::kX2d);
+  Int_t zeroAllYLSB = localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB);
+
+  Int_t  iStripCircuit = 0;
+  Int_t  iFirstStrip   = 0;
+  Int_t  iLastStrip    = 0;
+  Bool_t doubling      = kFALSE;
+  
+  Int_t iline  = localBoard->GetPosition().GetFirst();
+  Int_t icol   = localBoard->GetPosition().GetSecond();
+  if ( iline == 5 ) --icol;
 
-//---------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadYPos2(){
-/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
+  fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-  Int_t chamber, cathode;
-  Int_t code, idModule, idStrip, idSector;
-  Float_t x, y, z, width;
-  Int_t istrip, idDE;
+  fCurrentSeg = AliMpSegmentation::Instance()
+        ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
-  AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
-  AliMUONGeometrySegmentation* segmentation;    
+  // check if one needs a strip doubling or not
+  if ( (x2u || x2m || x2d ) && x2m ) doubling = kTRUE;
   
-// first plane (11)
-  chamber=11;
-  cathode=1;
-  segmentation
-    = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
+
+  // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
+  if (zeroAllYLSB) iStripCircuit = 8;
   
-  if (!segmentation) {
-    AliWarning("Segmentation not defined.");
-    return;
-  }  
-
-  for (istrip=0; istrip<16; istrip++) {
-    code=fXcode[0][istrip];           // decode current strip
-    idModule=Int_t(code/100);           // corresponding module Id.
-    idDE = DetElemId(chamber, idModule);
-    idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
-    idSector=segmentation->Sector(idDE, idModule, idStrip); // corresponding sector
-    width=segmentation->Dpy(idDE, idSector);      // corresponding strip width
-    segmentation->GetPadC(idDE, idModule,idStrip,x,y,z); // get strip real position
-    
-    fYpos11[2*istrip]=y;
-    if (istrip!=15) fYpos11[2*istrip+1]=y+width/2.;
-  }   
-   
-// second plane (21)
-  chamber=13;
-  cathode=1;
-  segmentation
-    = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
+  // get iFirstStrip in this module 
+  const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
+  const AliMpTrigger* t = trig->Slat();
+  const AliMpSlat* slat = t->GetLayer(0);
+  
+  const AliMpPCB* pcb = slat->GetPCB(icol-1);
+  iFirstStrip = pcb->Ixmin();
+  
+
+  if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
+  else iLastStrip = iFirstStrip + 16;
   
-  for (istrip=0; istrip<32; istrip++) {
-    code=fXcode[2][istrip];    // decode current strip
-    idModule=Int_t(code/100);           // corresponding module Id.
-    idDE = DetElemId(chamber, idModule);
-    if (idModule == 0) continue;
-    idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
-    idSector=segmentation->Sector(idDE, idModule, idStrip); // corresponding sector
-    width=segmentation->Dpy(idDE, idSector);      // corresponding strip width
-    segmentation->GetPadC(idDE, idModule,idStrip,x,y,z); // get strip real position
+  FillYstrips(iFirstStrip, iLastStrip, iStripCircuit, doubling);  
+}
+
+//----------------------------------------------------------------------
+void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLastStrip, 
+                                       Int_t liStripCircuit,
+                                       const Bool_t doubling)
+{    
+/// fill
+  Double_t xyGlobal[2] = {0.};
+
+  for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
+
+    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
+
+    if ( !pad.IsValid() )
+    {
+       StdoutToAliError(cout << "Pad not found in seg " << endl;
+                        fCurrentSeg->Print();
+                        cout << " ix,iy=" << istrip << "," << 0 << endl;
+                        );
+    }
+    Float_t xDim = pad.Dimensions().X(); // half size!
+
+    XYGlobal(pad,xyGlobal);
     
-// using idModule!=0 prevents to fill garbage in case of circuits 
-// in the first and last rows 
-    if (idModule!=0) { 
-      fYpos21[2*istrip]=y;
-      if (istrip!=31) fYpos21[2*istrip+1]=y+width/2.;
+    if (!doubling) {   
+      fXpos11[fCurrentLocalBoard].AddAt(xyGlobal[0], liStripCircuit);
+    } else if (doubling) {
+
+      fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) * 
+                                 (TMath::Abs(xyGlobal[0]) - xDim/2.), 2*liStripCircuit);
+
+      fXpos11[fCurrentLocalBoard].AddAt(TMath::Sign(1.,xyGlobal[0]) *
+                                 (TMath::Abs(fXpos11[fCurrentLocalBoard][2*liStripCircuit]) + xDim),
+                                       2*liStripCircuit + 1); 
     }
-  }   
+
+    liStripCircuit++;
+  }    
 }
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadXPos2(){
-/// fill fXpos11 -> x position of Y strips for the first plane only
-/// fXpos11 contains the x position of Y strip for the current circuit
-/// taking into account whether or nor not part(s) of the circuit
-/// (middle, up or down) has(have) 16 strips
+void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
+                                    Double_t* xyGlobal)
+{
+/// returns pad x & y positions and x & y pad dimensions in global coordinates
+/// note: no need for transformation for pad dimensions
   
-  Float_t x, y, z;
-  Int_t istrip, idDE;  
-
-  Int_t chamber=11;
-  Int_t cathode=2;
-  AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
-  AliMUONGeometrySegmentation*  segmentation; 
-  segmentation
-    = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
-
-  if (!segmentation) {
-    AliWarning("Segmentation not defined.");
-    return;
-  }  
+  // get the pad position and dimensions
+  Double_t xl1 = pad.Position().X();
+  Double_t yl1 = pad.Position().Y();
+  Double_t zg1 = 0;
   
-  Int_t idModule=Module(fIdCircuit);        // corresponding module Id.  
-// number of Y strips
-  idDE = DetElemId(chamber, idModule);
-
-  Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
-  Int_t idSector=segmentation->Sector(idDE, idModule,0); // corresp. sector
-  Float_t width=segmentation->Dpx(idDE, idSector);      // corresponding strip width
-
-// first case : up middle and down parts have all 8 or 16 strip 
-  if ((nStrY==16)||(nStrY==8&&fX2m==0&&fX2ud==0)) { 
-    for (istrip=0; istrip<nStrY; istrip++) {
-      segmentation->GetPadC(idDE, idModule,istrip,x,y,z); 
-      AliDebug(1,Form("idDE %d idModule %d istrip %d x,y,z=%e,%e,%e\n",
-                      idDE,idModule,istrip,x,y,z));
-      fXpos11[istrip]=x;
-    }
-// second case : mixing 8 and 16 strips within same circuit      
-  } else {
-    for (istrip=0; istrip<nStrY; istrip++) {
-      if (nStrY!=8) { printf(" bug in LoadXpos \n");}
-      segmentation->GetPadC(idDE, idModule, istrip, x, y, z); 
-      fXpos11[2*istrip]=x-width/4.;
-      fXpos11[2*istrip+1]=fXpos11[2*istrip]+width/2.;
-    }
-  }   
+  // positions from local to global 
+  fTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0, 
+                                 xyGlobal[0], xyGlobal[1], zg1);
 }
 
+
 //----------------------------------------------------------------------
 //--- methods which return member data related info
 //----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetIdCircuit() const { 
-/// returns circuit Id
-  return fIdCircuit;
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetIdModule() const { 
-/// returns module Id
-  return Module(fIdCircuit);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetNstripX() const { 
-/// returns the number of X strips in the module where the circuit is sitting
-  return AliMUONTriggerConstants::NstripX(ModuleNumber(Module(fIdCircuit)));
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetNstripY() const { 
-/// returns the number of Y strips in the module where the circuit is sitting
-  return AliMUONTriggerConstants::NstripY(ModuleNumber(Module(fIdCircuit)));
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetPosCircuit() const { 
-/// returns the position of the circuit in its module
-  return Position(fIdCircuit);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetIdCircuitD() const {
-/// returns the Id of the circuit down 
-  Int_t idModule=Module(fIdCircuit);
-  Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
-  return (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetICircuitD() const {
-/// returns the number of the circuit down 
-  Int_t idModule=Module(fIdCircuit);
-  Int_t idModuleD=(TMath::Abs(idModule)+10)*(TMath::Abs(idModule)/idModule); 
-  Int_t idCircuitD=
-    (TMath::Abs(idModuleD)*10+1)*(TMath::Abs(idModule)/idModule);
-  return CircuitNumber(idCircuitD);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetIdCircuitU() const {
-/// returns the Id of the circuit up 
-  Int_t idModule=Module(fIdCircuit);
-  Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
-  return (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetICircuitU() const {
-/// returns the number of the circuit up 
-  Int_t idModule=Module(fIdCircuit);
-  Int_t idModuleU=(TMath::Abs(idModule)-10)*(TMath::Abs(idModule)/idModule); 
-  Int_t idCircuitU=
-    (TMath::Abs(idModuleU)*10+1)*(TMath::Abs(idModule)/idModule);
-  return CircuitNumber(idCircuitU);
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetX2m() const { 
-/// returns fX2m
-  return fX2m;
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetX2ud() const { 
-/// returns fX2ud
-  return fX2ud;
-}
-//----------------------------------------------------------------------
-void AliMUONTriggerCircuit::GetOrMud(Int_t orMud[2]) const {
-/// returns fOrMud 
-  orMud[0]=fOrMud[0];
-  orMud[1]=fOrMud[1];
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetXcode(Int_t chamber, Int_t istrip) const {
-/// returns X code of circuit/chamber/istrip (warning : chamber in [0,3])
-  return fXcode[chamber][istrip];
-}
-//----------------------------------------------------------------------
-Int_t AliMUONTriggerCircuit::GetYcode(Int_t chamber, Int_t istrip) const {
-/// returns Y code of circuit/chamber/istrip (warning : chamber in [0,3])
-  return fYcode[chamber][istrip];
-}
-//----------------------------------------------------------------------
-Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t istrip) const {
+Float_t AliMUONTriggerCircuit::GetY11Pos(Int_t localBoardId, Int_t istrip) const 
+{
 /// returns Y position of X strip istrip in MC11
-  return fYpos11[istrip];
+  return fYpos11[localBoardId][istrip];
 }
 //----------------------------------------------------------------------
-Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t istrip) const {
+Float_t AliMUONTriggerCircuit::GetY21Pos(Int_t localBoardId, Int_t istrip) const 
+{
 /// returns Y position of X strip istrip in MC21
-  return fYpos21[istrip];
+  return fYpos21[localBoardId][istrip];
 }
 //----------------------------------------------------------------------
-Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
-// returns X position of Y strip istrip in MC11
-  return fXpos11[istrip];
-}
-//----------------------------------------------------------------------
-//--- end of methods which return member data related info
-//----------------------------------------------------------------------
-
-void dump(const char* what, const Float_t* array, Int_t size)
+Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t localBoardId, Int_t istrip) const 
 {
-  cout << what << " " << endl;
-  for ( Int_t i = 0; i < size; ++i )
-  {
-    cout << array[i] << " , ";
-  }
-  cout << endl;
+/// returns X position of Y strip istrip in MC11
+  return fXpos11[localBoardId][istrip];
 }
 
-void dump(const char* what, const Int_t* array, Int_t size)
+//----------------------------------------------------------------------
+Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
 {
-  cout << what << " " << endl;
-  for ( Int_t i = 0; i < size; ++i )
-  {
-    cout << array[i] << " , ";
-  }
-  cout << endl;
-}
+/// returns the first strip from mapping for board boardName
+/// take care of special case for boards RC1L6B12 & LC1L6B12
+  Int_t iFirstStrip = -1;
+  Int_t boardNumber = atoi(localBoard->GetName()+6);
 
-//_____________________________________________________________________________
-void
-AliMUONTriggerCircuit::Print(Option_t* ) const
-{
-/// prints-out data member
-  cout << "IdCircuit " << fIdCircuit << " X2m,X2ud=" << fX2m << ","
-  << fX2ud;
-  for ( Int_t i = 0; i < 2; ++i )
-  {
-    cout << " OrMud[" << i << "]=" << fOrMud[i];
-  }
-  cout << endl;
-  dump("Xpos11",fXpos11,16);
-  dump("Ypos11",fYpos11,31);
-  dump("Ypos21",fYpos21,63);
-  for ( Int_t i = 0; i < 4; ++i )
+  Int_t iline = localBoard->GetPosition().GetFirst();
+  Int_t icol  = localBoard->GetPosition().GetSecond();
+  if ( iline == 5 ) --icol;
+
+  switch (boardNumber)
   {
-    char s[80];
-    sprintf(s,"Xcode[%d]",i);
-    dump(s,fXcode[i],32);
-    sprintf(s,"Ycode[%d]",i);
-    dump(s,fYcode[i],32);
+    case 12:
+      iFirstStrip = 0;
+      break;           
+    case 34:
+      iFirstStrip = 16;
+      break;           
+    case 56:
+      iFirstStrip = 32;
+      break;           
+    case 78:
+      iFirstStrip = 48;
+      break;           
   }
-//  Int_t fIdCircuit;            // circuit Id number
-//  Int_t fX2m;                  // internal info needed by TriggerDecision
-//  Int_t fX2ud;                 // internal info needed by TriggerDecision
-//  Int_t fOrMud[2];             // internal info needed by TriggerDecision
-//  Int_t fXcode[4][32];         // code of X strips
-//  Int_t fYcode[4][32];         // code of Y strips 
-//  Float_t fXpos11[16];         // X position of Y strips in MC11
-//  Float_t fYpos11[31];         // Y position of X strips in MC11
-//  Float_t fYpos21[63];         // Y position of X strips in MC21
-  
+  if (icol == 1 && iline == 6) iFirstStrip += 16; // special case
+  return iFirstStrip;
 }
 
-Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, Int_t idModule)
-{
-/// adpated to official numbering (09/20/05)
-/// returns the detection element Id for given chamber and module
-/// ichamber (from 11 to 14), idModule (from -97 to 97)
-//    
-    Int_t itmp=0;    
-    Int_t linenumber=Int_t(idModule/10);    
-    switch (linenumber) // (from 1 to 9, from top to bottom)
-    {
-    case 1:
-       itmp = 4;
-       break;  
-    case 2:
-       itmp = 3;
-       break;          
-    case 3:
-       itmp = 2;
-       break;
-    case 4:
-       itmp = 1;
-       break;      
-    case 5:
-       itmp = 0;
-       break;          
-    case 6:
-       itmp = 17;
-       break;          
-    case 7:
-       itmp = 16;
-       break;          
-    case 8:
-       itmp = 15;
-       break;          
-    case 9:
-       itmp = 14;
-       break;          
-// left
-    case -1:
-       itmp = 5;
-       break;          
-    case -2:
-       itmp = 6;
-       break;          
-    case -3:
-       itmp = 7;
-       break;          
-    case -4:
-       itmp = 8;
-       break;          
-    case -5:
-       itmp = 9;
-       break;          
-    case -6:
-       itmp = 10;
-       break;          
-    case -7:
-       itmp = 11;
-       break;          
-    case -8:
-       itmp = 12;
-       break;
-    case -9:
-       itmp = 13;
-       break;          
-    }
-    return (ichamber*100)+itmp;    
-}
-
-
-
-