]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCmapper.cxx
Update TPCCEda to write output file in parts (to avoid too big files produced in...
[u/mrichter/AliRoot.git] / TPC / AliTPCmapper.cxx
index e56c9446cfc152fba8789dbf365bae7eb551f2d2..24d1dfd545af8b5ee91acff037d15999087aaa28 100644 (file)
  **************************************************************************/
 
 //-------------------------------------------------------------------------
-//           AliTPCmapper
-//  Origin: Jens Wiechula    (j.wiechula@gsi.de)
 //
-//  class to map (row,pad,sector) to (RCU, Branch, FEC, Altro, Altro channel)
-//  create Altro address 
-
+// AliTPCmapper
+// Authors: Christian.Lippmann@cern.ch, J.Wiechula@gsi.de
+// Class to map detector coordinates (row, pad, sector, ...) to
+// hardware coordinates (RCU, Branch, FEC, Altro, channel, Equipment ID, ...)
+// 
+// There are two different ways to number padrows:
+// 1) local padrow: for each ROC, 0 ... 62 for an IROC, 0 ... 95 for an OROC,
+// 2) global padrow: for each sector, from 0 ... 158.
+// If the global numbering is used, it is denoted by the variable name
+// globalpadrow in this class.
+//
+// There are two different ways to number sectors:
+// 1) Sectors contain one IROC and one OROC and are counted from 0 to 17 on
+//    each of the two sides (A=0 and C=1),
+// 2) ROCs are numbered from 0 to 71 where the ROCs 0 ... 35 are IROCS and
+//    ROCs 36 ... 71 are OROCs. A ROC is often named "sector" in aliroot,
+//    which can be very confusing!
+//
+//-------------------------------------------------------------------------
 
-#include <stdio.h>
 #include <TMath.h>
 #include <TSystem.h>
+#include <TString.h>
 
 #include "AliTPCmapper.h"
-
+#include "AliTPCAltroMapping.h"
+#include "AliTPCROC.h"
+#include "AliLog.h"
+#include "AliDAQ.h"
 
 ClassImp(AliTPCmapper)
-
+//______________________________________________________________
+AliTPCmapper::AliTPCmapper() :
+  fNside(0),
+  fNsector(0),
+  fNrcu(0),
+  fNbranch(0),
+  fNaltro(0),
+  fNchannel(0),
+  fNpadrow(0),
+  fNpadrowIROC(0),
+  fNpadrowOROC(0),
+  fTpcDdlOffset(0)
+{
+  //
+  // Constructor
+  //
+  for ( Int_t i = 0; i < 6; i++ )  fMapping[i]=0;
+}
 
 //______________________________________________________________
-AliTPCmapper::AliTPCmapper()
+AliTPCmapper::AliTPCmapper(const char * dirname) :
+  fNside(0),
+  fNsector(0),
+  fNrcu(0),
+  fNbranch(0),
+  fNaltro(0),
+  fNchannel(0),
+  fNpadrow(0),
+  fNpadrowIROC(0),
+  fNpadrowOROC(0),
+  fTpcDdlOffset(0)
 {
-    Init();
-    ReadMapping();
+  //
+  // Constructor
+  //
+  // dirname - specify the directory with the ascii Altro mapping files
+  //
+  Init(dirname);
 }
 
 //______________________________________________________________
-void AliTPCmapper::Init()
-{
-
-    //Initialize arrays
-    for (Int_t i=0; i<kNrcu; i++){
-       for (Int_t j=0; j<kNbranch; j++){
-           for (Int_t k=0; k<kNfecMax; k++){
-               for (Int_t l=0; l<kNaltro; l++){
-                   for (Int_t m=0; m<kNchannel; m++){
-                       fAddressToRow[i][j][k][l][m] = -1;
-                       fAddressToPad[i][j][k][l][m] = -1;
-                   }
-               }
-           }
-       }
-    }
+AliTPCmapper::~AliTPCmapper()
+{
+  // Destructor
 
-    for (Int_t i=0; i<kNpadrow; i++){
-       for (Int_t j=0; j<kNpadMax; j++){
-           fRowPadToRCU[i][j] = -1;
-           fRowPadToBranch[i][j] = -1;
-           fRowPadToFEC[i][j] = -1;
-           fRowPadToAltro[i][j] = -1;
-           fRowPadToChannel[i][j] = -1;
-            fRowPadToPadsec[i][j] = -1;
-       }
-    }
+  for ( Int_t i = 0; i < fNrcu; i++ ) {
+    delete fMapping[i];
+    fMapping[i] = 0;
+  }
+}
 
-    for (Int_t i=0; i<kNpadSector; i++){
-       fPadsecToRow[i]=-1;
-       fPadsecToPad[i]=-1;
-    }
 
-//    for (Int_t i=0; i<kNaddrSize; i++)
-//        fAddressArray[i] = 0;
+//_____________________________________________________________________________
+AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
+  TObject(mapper),
+  fNside(mapper.fNside),
+  fNsector(mapper.fNsector),
+  fNrcu(mapper.fNrcu),
+  fNbranch(mapper.fNbranch),
+  fNaltro(mapper.fNaltro),
+  fNchannel(mapper.fNchannel),
+  fNpadrow(mapper.fNpadrow),
+  fNpadrowIROC(mapper.fNpadrowIROC),
+  fNpadrowOROC(mapper.fNpadrowOROC),
+  fTpcDdlOffset(mapper.fTpcDdlOffset)
+{
+  // Copy Constructor
+  for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
+}
+
+//_____________________________________________________________________________
+AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
+{
+  // Assignment operator
+
+  if(&mapper == this) return *this;
+  ((TObject *)this)->operator=(mapper);
 
-    strcpy(fMapfileName,gSystem->ExpandPathName("$ALICE_ROOT/TPC/final_mapping.txt"));
+  for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
+
+  fNside = mapper.fNside;
+  fNsector = mapper.fNsector;
+  fNrcu = mapper.fNrcu;
+  fNbranch = mapper.fNbranch;
+  fNaltro = mapper.fNaltro;
+  fNchannel = mapper.fNchannel;
+  fNpadrow = mapper.fNpadrow;
+  fNpadrowIROC = mapper.fNpadrowIROC;
+  fNpadrowOROC = mapper.fNpadrowOROC;
+  fTpcDdlOffset = mapper.fTpcDdlOffset;
+
+  return *this;
 }
 
 //______________________________________________________________
-Int_t AliTPCmapper::ReadMapping()
+void AliTPCmapper::Init(const char *dirname)
 {
-    FILE *fin;
-    char line[255];
+  // Initialize all
+  fNside    = 2;
+  fNsector  = 18;
+  fNrcu     = 6;
+  fNbranch  = 2;
+  fNaltro   = 8;
+  fNchannel = 16;
 
-    int pad = -1, row = -1;
-    int rcu = -1, bra = -1, fec = -1, alt = -1, chn = -1;
-    int padsec = 0;
+  // Load and read mapping files. AliTPCAltroMapping contains the mapping for
+  // each patch (rcu).
+  TString path;
+  if (dirname==0){
+    path  =gSystem->Getenv("ALICE_ROOT");
+    path += "/TPC/mapping/Patch";
+  }else{
+    path  = dirname;
+    path +="Patch";
+  }
 
+  TString path2;
+  for(Int_t i = 0; i < fNrcu; i++) {
+    path2 = path;
+    path2 += i;
+    path2 += ".data";
+    fMapping[i] = new AliTPCAltroMapping(path2.Data());
+  }
 
-    fin = fopen(fMapfileName,"r");
-    if (!fin){
-       fprintf(stderr, "cannot open file '%s'!\n",fMapfileName);
-       return 1;
-    }
+  // Get instance of AliTPCROC object
+  AliTPCROC *fROC = AliTPCROC::Instance();
+  fNpadrowIROC = fROC->GetNRows(0);
+  fNpadrowOROC = fROC->GetNRows(36);
+  fNpadrow     = fNpadrowIROC+fNpadrowOROC;
 
-    fgets(line,256,fin);
-    while (sscanf(line,"%d %d %d %d %d %d %d %d",
-                 &padsec, &row, &pad,
-                 &rcu, &bra, &fec, &alt, &chn
-                )!=8){
-        fgets(line, 256, fin);
-       fprintf(stderr,"%s",line);
-    }
+  AliDAQ daq;
+  fTpcDdlOffset = daq.DdlIDOffset("TPC");
 
-    while (!feof(fin)){
-        sscanf(line,"%d %d %d %d %d %d %d %d",
-              &padsec, &row, &pad,
-              &rcu, &bra, &fec, &alt, &chn
-             );
-       fAddressToRow[rcu][bra][fec][alt][chn] = row;
-       fAddressToPad[rcu][bra][fec][alt][chn] = pad;
+}
 
-       fRowPadToRCU[row][pad]     = rcu;
-       fRowPadToBranch[row][pad]  = bra;
-       fRowPadToFEC[row][pad]     = fec;
-       fRowPadToAltro[row][pad]   = alt;
-       fRowPadToChannel[row][pad] = chn;
-       fRowPadToPadsec[row][pad]  = padsec;
 
-       fPadsecToRow[padsec]        = row;
-        fPadsecToPad[padsec]        = pad;
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the hardware address from pad coordinates for a given ROC
+  Int_t patch = GetPatch(roc, padrow, pad);
+  if ( (patch >= fNrcu) || (patch < 0) ) return -1;
+  return fMapping[patch]->GetHWAddress(padrow, pad, roc);
+}
 
 
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get the hardware address from pad coordinates
+  Int_t patch = 0;
+  if ( globalpadrow < fNpadrowIROC   ) {
+    patch = GetPatch(0,  globalpadrow, pad);
+    return fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
+  } else if ( globalpadrow < fNpadrow ) {
+    patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
+    return fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC,
+                                        pad, 36);
+  } else {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1;
+  }
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the patch (rcu) index from the pad coordinates. The Roc index is
+  // needed as well to determine if it is IROC or OROC. 
+  return GetPatch(roc, padrow, pad);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the patch (rcu) index from the pad coordinates. The Roc index is
+  // needed as well to determine if it is IROC or OROC. 
 
-       fgets(line, 256, fin);
+  if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
+    AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
+    return -1;
+  }
+
+  if ( roc < 36 ) {
+    // IROC (ROCs 0 ... 35)
+    Int_t padsInRow = GetNpads(padrow);
+    if ( (padsInRow < 0) || (pad >= padsInRow) ) {
+      AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
+      return -1;
+    }
+    if ( padrow < 30 ) {                  return 0;
+    } else if ( padrow == 30 ) {          // padrow 30 is shared between rcus 0 and 1
+      if ( (pad < 37) || (pad > 48) )     return 1;
+      else                                return 0;
+    } else if ( padrow < fNpadrowIROC ) { return 1;
+    } else {
+      AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
+      return -1;
+    }
+  } else if ( roc < 72 ) {
+    // OROC (ROCs 36 ... 71)
+    Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
+    if ( (padsInRow < 0) || (pad >= padsInRow) ) {
+      AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
+      return -1;
+    }
+    if ( padrow < 27 ) {                  return 2;
+    } else if ( padrow == 27 ) {          // padrow 27 is shared between rcus 2 and 3
+      if ( (pad >= 43) && (pad <= 46) )   return 3;
+      else                                return 2;
+    } else if ( padrow < 54 ) {           return 3;
+    } else if ( padrow < 76 ) {           return 4;
+    } else if ( padrow == 76) {           // padrow 76 is shared between rcus 4 and 5
+      if ( (pad >= 33) && (pad <= 88) )   return 5;
+      else                                return 4;
+    } else if ( padrow < fNpadrowOROC ) { return 5;
+    } else {
+      AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
+      return -1;
     }
+  }
+  return -1;
+}
 
-    fclose(fin);
 
-    return 0;
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get the patch (rcu) index from the pad coordinates for a sector
+  return GetPatchSector(globalpadrow, pad);
 }
 
-//______________________________________________________________
-void AliTPCmapper::PrintRBFACinfo(Int_t row, Int_t pad)
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
 {
-    fprintf(stderr,"RCU: %d, Branch: %d, FEC: %2d, Altro: %d, Channel: %2d\n",
-           GetRCUs(row,pad), GetBranchS(row,pad),
-           GetFECs(row,pad), GetAltroS(row,pad),
-           GetChannelS(row,pad));
+  // Get the patch (rcu) index from the pad coordinates for a sector
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1;
+  }
+  if ( globalpadrow < fNpadrowIROC ) return GetPatch(0,  globalpadrow, pad);
+  else                               return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
+}
 
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
+{
+  // Get Pad Row (for a ROC) from the hardware address
+  if ( (patch >= fNrcu) || (patch < 0) ) {
+    AliWarning(Form("Patch index outside range (patch %d) !", patch));
+    return -1;
+  }
+  return fMapping[patch]->GetPadRow(hwAddress);
 }
 
-//______________________________________________________________
-Int_t AliTPCmapper::GetPadsInRowS(Int_t row) const{
-  //
-  //GetPadsInRowS
-  //
-    if ( row == 0 )
-       return 68;
 
-    if ( row < 63 )
-       return 2*(Int_t)(row/3.+33.67);
+//_____________________________________________________________________________
+  Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
+{
+  // Get Pad Row (for full sector) from the hardware address
+  if ( patch < 2 ) return GetPadRow(patch, hwAddress);
+  else             return GetPadRow(patch, hwAddress) + fNpadrowIROC;
+}
+
 
-    row -= 63;
-    Double_t k1=10./6.*tan(TMath::Pi()/18.);
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
+{
+  // Get Pad index from the hardware address
+  if ( (patch >= fNrcu) || (patch < 0) ) {
+    AliWarning(Form("Patch index outside range (patch %d) !", patch));
+    return -1;
+  }
+  return fMapping[patch]->GetPad(hwAddress);
+}
 
-    if ( row < 64 )
-       return 2*(Int_t)(k1 * row + 37.75);
 
-    Double_t k2=15./6.*tan(TMath::Pi()/18.);
-    return 2*(Int_t)(k2 * (row-64) + 56.66);
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
+                             Int_t channel) const
+{
+  // Get pad row (for a ROC) from hardware coordinates
+  if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
+       || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
+    AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
+                   patch, branch, fec, chip, channel));
+    return -1;
+  }
+  return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
 }
 
-//______________________________________________________________
-Double_t AliTPCmapper::GetPadXlocalS(Int_t row, Int_t pad) const {
-  //
-  //GetPadXlocalS
-  //
-    if ( row < 63 ) //IROC
-       return (852.25 + 7.5 * (Double_t)row)*1.e-1; //divide by 10 to get cm
 
-    row -= 63;
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
+                                   Int_t channel) const
+{
+  // Get Pad Row (for full sector) from the hardware address
+  if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
+       || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
+    AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
+                   patch, branch, fec, chip, channel));
+    return -1;
+  }
+  if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
+  else             return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
+}
 
-    if ( row < 64 ) //OROC inner part
-       return (10.* row + 1351.)*1.e-1;  //divide by 10 to get cm
+
+//_____________________________________________________________________________
+  Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
+{
+  // Get pad from hardware coordinates
+  if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
+       || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
+    AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
+                   patch, branch, fec, chip, channel));
+    return -1;
+  }
+  return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
+}
 
 
-    //OROC outer part
-    return (15.*(row - 64) + 1993.5)*1.e-1;  //divide by 10 to get cm
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the branch to which this pad is connected. The FECs connected to
+  // one RCU are divided into two branches: A(=0) and B(=1). This information
+  // can be extracted from the hardware address.
+  return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
 }
 
-//______________________________________________________________
-Double_t AliTPCmapper::GetPadXlocalS(Int_t padsector) const{
-  //
-  //GetPadXlocalS
-  //
-    Int_t row=GetRowFromPadSector(padsector);
-    Int_t pad=GetPadFromPadSector(padsector);
-    return GetPadXlocalS(row,pad);
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get Branch from pad coordinates, where globalpadrow is counted
+  // for a full sector (0 ... 158)
+  return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
 }
 
-//______________________________________________________________
-Double_t AliTPCmapper::GetPadYlocalS(Int_t row, Int_t pad) const{
-  //
-  //:GetPadYlocalS
-  //
-    Int_t padsInRow = GetPadsInRowS(row);
 
-    if ( row < 63 ) //IROC
-       return (2.* padsInRow - 4.*pad - 2.)*1.e-1;  //divide by 10 to get cm
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
+  // center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
+  // (partition 1, branch A) or 12 (partition 1, branch B). This information
+  // can be extracted from the hardware address.
+  return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
+}
+
 
-    //OROC
-        return (3.* padsInRow -6.*pad - 3.)*1.e-1;  //divide by 10 to get cm
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get the FEC number in hardware numbering from pad coordinates, where 
+  // globalpadrow is counted for a full sector (0 ... 158)
+  return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
 }
 
-//______________________________________________________________
-Double_t AliTPCmapper::GetPadYlocalS(Int_t padsector) const{
-  //
-  //:GetPadYlocalS
-  //
-    Int_t row = GetRowFromPadSector(padsector);
-    Int_t pad = GetPadFromPadSector(padsector);
-    return GetPadYlocalS(row,pad);
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
+  // 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
+  Int_t patch  = GetPatch(roc, padrow, pad);
+  Int_t fec    = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
+  Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
+  if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
+  return HwToOffline(patch, branch, fec);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get the FEC number in offline-oriented numbering. globalpadrow is
+  // counted for a full sector (0 ... 158)
+  Int_t patch  = GetPatchSector(globalpadrow, pad);
+  Int_t fec    = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
+  Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
+  if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
+  return HwToOffline(patch, branch, fec);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get Chip (ALTRO) index (0 ... 7) from pad coordinates
+  return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where 
+  // globalpadrow is counted for a full sector (0 ... 158)
+  return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get Channel index (0 ... 15) from pad coordinates
+  return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
+{
+  // Get Channel index (0 ... 15) from pad coordinates, where 
+  // globalpadrow is counted for a full sector (0 ... 158)
+  return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
+{
+  // Get Hardware address from channel, altro, fec and branch coordinates
+  return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
+{
+  // Get branch index (0, 1) from hardware address
+  if ( hwAddress < 0 ) return -1;
+  return ((hwAddress>>11)&1);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
+{
+  // Get FEC index (0 ... 12) from hardware address
+  if ( hwAddress < 0 ) return -1;
+  return ((hwAddress>>7)&0xf);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
+{
+  // Get ALTRO index (0 ... 7) from hardware address
+  if ( hwAddress < 0 ) return -1;
+  return ((hwAddress>>4)&0x7);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
+{
+  // Get channel index (0 ... 15) from hardware address
+  if ( hwAddress < 0 ) return -1;
+  return ((hwAddress&0xf));
 }
 
+
 //______________________________________________________________
-Double_t AliTPCmapper::GetPadXglobalS(Int_t row, Int_t pad,Int_t sector) const{
-  //
-  // GetPadXglobalS
-  //
-    Double_t angle = (Double_t)(( sector * 20. ) +10. ) * TMath::DegToRad();
-    return GetPadXlocalS(row,pad)*TMath::Cos(angle) -
-       GetPadYlocalS(row,pad)*TMath::Sin(angle);
+Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
+  // Get number of pads in padrow for this ROC.
+  AliTPCROC *fROC = AliTPCROC::Instance();
+  Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
+  return retval;
 }
 
+
 //______________________________________________________________
-Double_t AliTPCmapper::GetPadYglobalS(Int_t row, Int_t pad,Int_t sector) const{
-  //
-  // GetPadYglobalS
-  //
-    Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
-    return GetPadXlocalS(row,pad)*TMath::Sin(angle) +
-       GetPadYlocalS(row,pad)*TMath::Cos(angle);
+Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
+  // Get number of pads in padrow, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1;
+  }
+  if ( globalpadrow < fNpadrowIROC ) return GetNpads(0,  globalpadrow);  // IROC
+  else  return GetNpads(36, globalpadrow - fNpadrowIROC);                // OROC
+
+  return -1;
 }
 
+
 //______________________________________________________________
-Double_t AliTPCmapper::GetPadWidthS(Int_t row) const
+Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
 {
-  //
-  // :GetPadWidthS
-  //
-    if (row < 63 ) return .4;
-    return .6;
+  // Get number of padrows
+  if      (roc < 36) return fNpadrowIROC;
+  else if (roc < 72) return fNpadrowOROC;
+  return -1;
 }
 
+
 //______________________________________________________________
-Double_t AliTPCmapper::GetPadLengthS(Int_t row) const
+/*
+Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
 {
-  //
-  // GetPadLengthS
-  //
+  // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
+
+  //IROC
+  if ( globalpadrow < fNpadrowIROC )
+    return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
+
+  globalpadrow -= fNpadrowIROC;
 
-    if ( row < 63  ) return  .75;
-    if ( row < 127 ) return 1.;
-    return 1.5;
+  if ( globalpadrow < 64 ) //OROC inner part
+    return (10.* globalpadrow + 1351.)/10.;         //divide by 10 to get cm
+
+  //OROC outer part
+  return (15.*(globalpadrow - 64) + 1993.5)/10.;    //divide by 10 to get cm
 }
+*/
 
 //______________________________________________________________
-Int_t AliTPCmapper::GetAltroAddrwPatch(const Int_t row,const Int_t pad) const
+/*
+Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
 {
-  //
-  // :GetAltroAddrwPatch
-  //
-    return GetChannelS(row,pad)+
-       (GetAltroS (row,pad) <<4)+
-       (GetFECs   (row,pad) <<7)+
-       (GetBranchS(row,pad) <<11)+
-        (GetRCUs   (row,pad) <<12);
+  // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
+
+  Int_t padsInRow = GetNpads(globalpadrow);
+  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
+    AliWarning(Form("Pad index outside range (pad %d) !", pad));
+    return -1.0;
+  }
+
+  //IROC
+  if ( globalpadrow < fNpadrowIROC )
+    return (2.* padsInRow - 4.*pad - 2.)*1.e-1;  //divide by 10 to get cm
+
+  //OROC
+  return (3.* padsInRow -6.*pad - 3.)*1.e-1;  //divide by 10 to get cm
 }
+*/
 
 //______________________________________________________________
-Int_t AliTPCmapper::GetAltroAddrwPatch(const Int_t padsector) const
+/*
+Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
 {
-  //
-  // GetAltroAddrwPatch
-  //
-    return GetAltroAddrwPatch(GetRowFromPadSector(padsector),GetPadFromPadSector(padsector));
+  // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
+
+  Int_t padsInRow = GetNpads(globalpadrow);
+  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
+    AliWarning(Form("Pad index outside range (pad %d) !", pad));
+    return -1.0;
+  }
+
+  Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
+  return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
+    GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
 }
+*/
 
 //______________________________________________________________
-Int_t AliTPCmapper::GetRow(Int_t altroaddr) const
+/*
+Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
 {
-  //
-  // GetRow
-  //
-    Int_t rcu = (altroaddr>>12)&0x07;
-    Int_t bra = (altroaddr>>11)&0x01;
-    Int_t fec = (altroaddr>>7)&0x0F;
-    Int_t alt = (altroaddr>>4)&0x07;
-    Int_t chn = (altroaddr)&0x0F;
-    return GetRow(rcu,bra,fec,alt,chn);
+  // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
+
+  Int_t padsInRow = GetNpads(globalpadrow);
+  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
+    AliWarning(Form("Pad index outside range (pad %d) !", pad));
+    return -1.0;
+  }
+
+  Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
+  return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
+    GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
 }
+*/
 
 //______________________________________________________________
-Int_t AliTPCmapper::GetPad(Int_t altroaddr) const
+/*
+Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
 {
-  //
-  // GetPad
-  //
-    Int_t rcu = (altroaddr>>12)&0x07;
-    Int_t bra = (altroaddr>>11)&0x01;
-    Int_t fec = (altroaddr>>7)&0x0F;
-    Int_t alt = (altroaddr>>4)&0x07;
-    Int_t chn = (altroaddr)&0x0F;
-    return GetPad(rcu,bra,fec,alt,chn);
+  //  Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
+
+  if (globalpadrow < fNpadrowIROC ) // IROC
+    return 0.4;
+  return 0.6;
 }
+*/
 
 //______________________________________________________________
-void AliTPCmapper::PrintAddressArray(Int_t row, Int_t pad)
+/*
+Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
 {
-  //
-  // PrintAddressArray
-  //
-    Bool_t a[kNaddrSize];
+  // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
+
+  if ( globalpadrow >= fNpadrow ) {
+    AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
+    return -1.0;
+  }
 
-    Int_t addr = GetAltroAddrwPatch(row,pad);
-    for (Int_t i=0; i<kNaddrSize; i++)
-       a[i] = addr&(Int_t)TMath::Power(2,i);
+  if ( globalpadrow < fNpadrowIROC ) return  0.75;
+  if ( globalpadrow < 127 )          return 1.0;
+  return 1.5;
+}
+*/
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetNfec(Int_t patch) const
+{
+  // Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
+  Int_t retval = 0;
+  switch(patch){
+  case(0):
+    retval = 18;
+    break;
+  case(1):
+    retval = 25;
+    break;
+  case(2):
+    retval = 18;
+    break;
+  case(3):
+    retval = 20;
+    break;
+  case(4):
+    retval = 20;
+    break;
+  case(5):
+    retval = 20;
+    break;
+  };
+  return retval;
+}
 
-    fprintf(stderr,"Par|Bro|BC/|Bra|   FEC HW   |  Altro  |Altro Chann.|  Instruction  \n");
-    fprintf(stderr,"ity|adc|AL |nch|  Address   |Chip Addr|   Address  |      Code     \n");
-    fprintf(stderr,"-------------------------------------------------------------------\n");
-    fprintf(stderr," %d | %d | %d | %d | %d  %d  %d  %d | %d  %d  %d | %d  %d  %d  %d | %d  %d  %d  %d  %d\n",
-           a[19],a[18],a[17],a[16],a[15],a[14],a[13],a[12],a[11],
-           a[10],a[9],a[8],a[7],a[6],a[5],a[4],a[3],a[2],a[1],a[0]);
 
-    fprintf(stderr,"-------------------------------------------------------------------\n");
-    fprintf(stderr,"19 |18 |17 |16 |15 14 13 12 |11 10  9 | 8  7  6  5 | 4  3  2  1  0\n\n");
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
+{
+  // Get size of readout partition (number of FECs) for this branch
+  Int_t retval = 0;
+  switch(patch){
+  case(0):
+    retval = 9;
+    break;
+  case(1):
+    retval = 13;
+    break;
+  case(2):
+    retval = 9;
+    break;
+  case(3):
+    retval = 10;
+    break;
+  case(4):
+    retval = 10;
+    break;
+  case(5):
+    retval = 10;
+    break;
+  };
+  
+  if( (branch == 1) && (patch == 1) ){
+    retval = 12;
+  }
 
+  return retval;
 }
 
-//______________________________________________________________
-AliTPCmapper::~AliTPCmapper()
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
+{
+  // Convert FEC position in offline-like numbering to hardware numbering (fec).
+
+  if ( (patch < 0) || (fec < 0) ) {
+    AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
+    return -1;
+  }
+  if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
+    AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
+    return -1;
+  }
+
+  Int_t fecsInBranchA = GetNfec(patch, 0);
+  if ( fec < fecsInBranchA ) // branch A
+    return (fecsInBranchA - 1 - fec);
+  else                       // branch B
+    return (fec - fecsInBranchA);
+
+  return -1;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
+{
+  // Convert fec position in offline-like numbering to hardware numbering (branch).
+
+  if ( (patch < 0) || (fec < 0) ) {
+    AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
+    return -1;
+  }
+  if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
+    AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
+    return -1;
+  }
+  if ( fec < GetNfec(patch, 0) ) return 0; // branch A
+  else                                         return 1; // branch B
+
+  return -1;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
+{
+  // Convert hardware FEC position (branch, fec) to the offline-oriented numbering
+
+  if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
+    AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
+    return -1;
+  }
+  if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
+    AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
+    return -1;
+  }
+  Int_t fecsInBranchA = GetNfec(patch, 0);
+  if ( branch == 0 )  // branch A
+    return (fecsInBranchA - 1 - fec);
+  else                // branch B
+    return (fec + fecsInBranchA);
+
+  return -1;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
+{
+  // Get EqID from pad coordinate. The Roc index is
+  // needed as well to determine if it is IROC or OROC. 
+
+  Int_t side = GetSideFromRoc(roc);
+  if ( side < 0 ) return -1;
+  Int_t sector = GetSectorFromRoc(roc);
+  if ( sector < 0 ) return -1;
+  Int_t patch = GetPatch(roc, padrow, pad);
+  if ( patch < 0 ) return -1;
+  return GetEquipmentIDfromPatch(side, sector, patch);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
+{
+  // Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
+  Int_t patch = GetPatchSector(globalpadrow, pad);
+  if ( patch < 0 ) return -1;
+  Int_t roc = GetRocFromPatch(side, sector, patch);
+  if ( roc < 0 ) return -1;
+
+  if ( globalpadrow < fNpadrowIROC )
+    return GetEquipmentID(roc, globalpadrow, pad);
+  else
+    return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
+{
+  // Get EqID from patch (rcu).
+
+  Int_t roc = GetRocFromPatch(side, sector, patch);
+  Int_t ddl = 0;
+  if (patch < 2)  // IROC
+    ddl = roc*2 + patch;
+  else            // OROC
+    ddl = (roc-36)*4 + 36*2 + (patch-2);
+  // Add offset. TPC has detectorID = 3
+  return ddl+fTpcDdlOffset;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
+{
+  // Get rcu (patch) index (0 ... 5) from equipment ID
+  Int_t retval = 0;
+
+  if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
+    AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
+    return -1;
+  }
+  if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
+  else                                 retval = (equipmentID-840)%4 + 2;
+  return retval;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
+{
+  // Get side from Eq ID
+  if ( equipmentID < fTpcDdlOffset ) {
+    AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
+    return -1;
+  }
+  if      ( equipmentID < 804 ) return 0;
+  else if ( equipmentID < 840 ) return 1;
+  else if ( equipmentID < 912 ) return 0;
+  else if ( equipmentID < 984 ) return 1;
+  else {
+    AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
+    return -1;
+  }
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
+{
+  // Get sector index (0 ... 17) from equipment ID
+  Int_t retval = 0;
+  if ( (equipmentID < fTpcDdlOffset) || (equipmentID >= fTpcDdlOffset+216) ) {
+    AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
+    return -1;
+  }
+  Int_t side   = GetSideFromEquipmentID(equipmentID);
+  if ( side < 0 ) return -1;
+
+  if ( (equipmentID - 840) < 0 ) { // IROC
+    if ( side == 0 ) retval = (equipmentID-fTpcDdlOffset)/2;
+    else             retval = (equipmentID-fTpcDdlOffset-18*2)/2;
+  } else {                         // OROC
+    if ( side == 0 ) retval = (equipmentID-840)/4;
+    else             retval = (equipmentID-840-18*4)/4;
+  }
+  return retval;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
 {
-//    delete fAddressArray;
+  // Get ROC index (0 ... 71) from equipment ID
+  Int_t side   = GetSideFromEquipmentID(equipmentID);
+  if ( side < 0 ) return -1;
+  Int_t sector = GetSectorFromEquipmentID(equipmentID);
+  if ( sector < 0 ) return -1;
+  Int_t patch  = GetPatchFromEquipmentID(equipmentID);
+  if ( patch < 0 ) return -1;
 
+  return GetRocFromPatch(side, sector, patch);
 }
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
+{
+  // get the sector number (0 ... 17) from the roc number (0 ... 71)
+
+  if ( roc < 0 ) {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  } else if ( roc < 18 ) {   // inner sector, A side
+    return roc;
+  } else if ( roc < 36 ) {   // inner sector, C side
+    return (roc-18);
+  } else if ( roc < 54 ) {   // outer sector, A side
+    return (roc-36);
+  } else if ( roc < 72 ) {   // outer sector, C side
+    return (roc-54);
+  } else {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  }
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
+{
+  // get the side (0, 1) from the roc number (0 ... 71)
+
+  if ( roc < 0 ) {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  } else if ( roc < 18 ) {   // inner sector, A side
+    return 0;
+  } else if ( roc < 36 ) {   // inner sector, C side
+    return 1;
+  } else if ( roc < 54 ) {   // outer sector, A side
+    return 0;
+  } else if ( roc < 72 ) {   // outer sector, C side
+    return 1;
+  } else { 
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  } 
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
+{
+  // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
+
+  if ( (side < 0) || (side >= fNside) ) {
+    AliWarning(Form("Side outside range (side %d) !", side));
+    return -1;
+  }
+  if ( (sector < 0) || (sector >= fNsector) ) {
+    AliWarning(Form("Sector outside range (sector %d) !", sector));
+    return -1;
+  }
+  if ( (patch < 0) || (patch >= fNrcu) ) {
+    AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
+    return -1;
+  }
+
+  if ( side == 0 ) { // A side
+    if ( patch < 2 ) return sector;         // IROC
+    else             return 36+sector;      // OROC
+  } else {           // C side
+    if ( patch < 2 ) return 18+sector;      // IROC
+    else             return 54+sector;      // OROC
+  }
+}
+
+
+//_____________________________________________________________________________
+Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
+{
+  // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
+
+  Int_t patch = GetPatchSector(globalpadrow, pad);
+  if ( patch < 0 ) return -1;
+  return GetRocFromPatch(side, sector, patch);
+}
+
+
+//_____________________________________________________________________________
+  Bool_t AliTPCmapper::IsIROC(Int_t roc) const
+{
+  // Is this ROC an IROC?
+  if ( roc < 0 ) {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  } else if ( roc < 36 ) {   // inner sector
+    return true;
+  } else if ( roc < 72 ) {   // outer sector, C side
+    return false;
+  } else {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  }
+}
+
+
+//_____________________________________________________________________________
+  Bool_t AliTPCmapper::IsOROC(Int_t roc) const
+{
+  // Is this ROC an OROC?
+  if ( roc < 0 ) {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  } else if ( roc < 36 ) {   // inner sector
+    return false;
+  } else if ( roc < 72 ) {   // outer sector, C side
+    return true;
+  } else {
+    AliWarning(Form("Roc outside range (roc %d) !", roc));
+    return -1;
+  }
+}
+
+// EOF