ROOT logo
#ifndef AliTPCmapper_H
#define AliTPCmapper_H
/* Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

////////////////////////////////////////////////////////////////////////
//
// AliTPCmapper class
// Class for all mapping functions (hardware coordinates <-> pad coordinates)
// Author: Christian Lippmann
//       
/////////////////////////////////////////////////////////////////////////

#include <TObject.h>

class AliTPCAltroMapping;

class AliTPCmapper : public TObject{

public:

  AliTPCmapper();
  AliTPCmapper(const char * dirname);
  virtual ~AliTPCmapper();

  AliTPCmapper& operator = (const AliTPCmapper& mapper);
  AliTPCmapper(const AliTPCmapper& mapper);

  void Init(const char * dirname);
  //
  AliTPCAltroMapping **GetAltroMapping() { return fMapping; };

  // ALTRO mapping functions
  Int_t GetPad(Int_t patch, Int_t hwAddress) const;
  Int_t GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const;
  Int_t GetPadRow(Int_t patch, Int_t hwAddress) const;
  Int_t GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const;

  // ALTRO mapping functions on roc level (padrow = 0 ... kNpadrowIROC, kNpadrowOROC)
  Int_t GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetRcu(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetPatch(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetBranch(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetFEC(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetChip(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetChannel(Int_t roc, Int_t padrow, Int_t pad) const;

  // ALTRO mapping functions on sector level (globalpadrow = 0 ... kNpadrow)
  Int_t GetGlobalPadRow(Int_t patch, Int_t hwAddress) const;
  Int_t GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const;
  Int_t GetHWAddressSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetRcuSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetPatchSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetBranchSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetFEChwSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetFECSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetChipSector(Int_t globalpadrow, Int_t pad) const;
  Int_t GetChannelSector(Int_t globalpadrow, Int_t pad) const;

  // Coding and decoding of hardware addresses
  Int_t CodeHWAddress(Int_t branch,  Int_t fec,  Int_t chip, Int_t channel) const;
  Int_t DecodedHWAddressBranch(Int_t hwAddress) const;
  Int_t DecodedHWAddressFECaddr(Int_t hwAddress) const;
  Int_t DecodedHWAddressChipaddr(Int_t hwAddress) const;
  Int_t DecodedHWAddressChanneladdr(Int_t hwAddress) const;

  // Pad Geometry on sector level (padrow = 0 ... kNpadrow)
  Int_t    GetNpads(Int_t roc, Int_t padrow) const;
  Int_t    GetNpads(Int_t globalpadrow) const;
  Int_t    GetNpadrows(Int_t roc) const;
  /*
  Double_t GetPadXlocal(Int_t globalpadrow) const;
  Double_t GetPadYlocal(Int_t globalpadrow, Int_t pad) const;
  Double_t GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const;
  Double_t GetPadYglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const;
  Double_t GetPadWidth(Int_t globalpadrow) const;
  Double_t GetPadLength(Int_t globalpadrow) const;
  */

  // Conversion between hardware FEC numbering and official numbering
  Int_t HwToOffline(Int_t patch, Int_t branch, Int_t fec) const;
  Int_t OfflineToHwBranch(Int_t patch, Int_t fec) const;
  Int_t OfflineToHwFec(Int_t patch, Int_t fec) const;

  // More mapping functions
  Int_t GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const;
  Int_t GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const;
  Int_t GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const;
  Int_t GetSectorFromRoc(Int_t roc) const;
  Int_t GetSideFromRoc(Int_t roc) const;
  Int_t GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const;
  Int_t GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const;
  Int_t GetSideFromEquipmentID(Int_t equipmentID) const;
  Int_t GetSectorFromEquipmentID(Int_t equipmentID) const;
  Int_t GetRocFromEquipmentID(Int_t equipmentID) const;
  Int_t GetPatchFromEquipmentID(Int_t equipmentID) const;

  // Even more
  Int_t  GetNfec(Int_t patch, Int_t branch) const;
  Int_t  GetNfec(Int_t patch) const;
  Bool_t IsIROC(Int_t roc) const;
  Bool_t IsOROC(Int_t roc) const;
  
  Int_t  GetTpcDdlOffset() const {return fTpcDdlOffset;}
  Int_t  GetNumDdl() const {return fNside*fNsector*fNrcu; }

 private:

  Int_t fNside;        // TPC has 2 sides
  Int_t fNsector;      // TPC side has 18 sectors
  Int_t fNrcu;         // Sector has 6 RCUs (patches)
  Int_t fNbranch;      // RCU has 2 branches
  Int_t fNaltro;       // FEC has 8 ALTROs
  Int_t fNchannel;     // ALTRO has 16 channels
  Int_t fNpadrow;      // Sector has 159 padrows
  Int_t fNpadrowIROC;  // IROC has 63 padrows
  Int_t fNpadrowOROC;  // OROC has 96 padrows

  Int_t fTpcDdlOffset; // DDL offset for TPC

  AliTPCAltroMapping *fMapping[6];    // The ALTRO mapping for each patch (rcu)

  ClassDef(AliTPCmapper,2)

};

#endif
 AliTPCmapper.h:1
 AliTPCmapper.h:2
 AliTPCmapper.h:3
 AliTPCmapper.h:4
 AliTPCmapper.h:5
 AliTPCmapper.h:6
 AliTPCmapper.h:7
 AliTPCmapper.h:8
 AliTPCmapper.h:9
 AliTPCmapper.h:10
 AliTPCmapper.h:11
 AliTPCmapper.h:12
 AliTPCmapper.h:13
 AliTPCmapper.h:14
 AliTPCmapper.h:15
 AliTPCmapper.h:16
 AliTPCmapper.h:17
 AliTPCmapper.h:18
 AliTPCmapper.h:19
 AliTPCmapper.h:20
 AliTPCmapper.h:21
 AliTPCmapper.h:22
 AliTPCmapper.h:23
 AliTPCmapper.h:24
 AliTPCmapper.h:25
 AliTPCmapper.h:26
 AliTPCmapper.h:27
 AliTPCmapper.h:28
 AliTPCmapper.h:29
 AliTPCmapper.h:30
 AliTPCmapper.h:31
 AliTPCmapper.h:32
 AliTPCmapper.h:33
 AliTPCmapper.h:34
 AliTPCmapper.h:35
 AliTPCmapper.h:36
 AliTPCmapper.h:37
 AliTPCmapper.h:38
 AliTPCmapper.h:39
 AliTPCmapper.h:40
 AliTPCmapper.h:41
 AliTPCmapper.h:42
 AliTPCmapper.h:43
 AliTPCmapper.h:44
 AliTPCmapper.h:45
 AliTPCmapper.h:46
 AliTPCmapper.h:47
 AliTPCmapper.h:48
 AliTPCmapper.h:49
 AliTPCmapper.h:50
 AliTPCmapper.h:51
 AliTPCmapper.h:52
 AliTPCmapper.h:53
 AliTPCmapper.h:54
 AliTPCmapper.h:55
 AliTPCmapper.h:56
 AliTPCmapper.h:57
 AliTPCmapper.h:58
 AliTPCmapper.h:59
 AliTPCmapper.h:60
 AliTPCmapper.h:61
 AliTPCmapper.h:62
 AliTPCmapper.h:63
 AliTPCmapper.h:64
 AliTPCmapper.h:65
 AliTPCmapper.h:66
 AliTPCmapper.h:67
 AliTPCmapper.h:68
 AliTPCmapper.h:69
 AliTPCmapper.h:70
 AliTPCmapper.h:71
 AliTPCmapper.h:72
 AliTPCmapper.h:73
 AliTPCmapper.h:74
 AliTPCmapper.h:75
 AliTPCmapper.h:76
 AliTPCmapper.h:77
 AliTPCmapper.h:78
 AliTPCmapper.h:79
 AliTPCmapper.h:80
 AliTPCmapper.h:81
 AliTPCmapper.h:82
 AliTPCmapper.h:83
 AliTPCmapper.h:84
 AliTPCmapper.h:85
 AliTPCmapper.h:86
 AliTPCmapper.h:87
 AliTPCmapper.h:88
 AliTPCmapper.h:89
 AliTPCmapper.h:90
 AliTPCmapper.h:91
 AliTPCmapper.h:92
 AliTPCmapper.h:93
 AliTPCmapper.h:94
 AliTPCmapper.h:95
 AliTPCmapper.h:96
 AliTPCmapper.h:97
 AliTPCmapper.h:98
 AliTPCmapper.h:99
 AliTPCmapper.h:100
 AliTPCmapper.h:101
 AliTPCmapper.h:102
 AliTPCmapper.h:103
 AliTPCmapper.h:104
 AliTPCmapper.h:105
 AliTPCmapper.h:106
 AliTPCmapper.h:107
 AliTPCmapper.h:108
 AliTPCmapper.h:109
 AliTPCmapper.h:110
 AliTPCmapper.h:111
 AliTPCmapper.h:112
 AliTPCmapper.h:113
 AliTPCmapper.h:114
 AliTPCmapper.h:115
 AliTPCmapper.h:116
 AliTPCmapper.h:117
 AliTPCmapper.h:118
 AliTPCmapper.h:119
 AliTPCmapper.h:120
 AliTPCmapper.h:121
 AliTPCmapper.h:122
 AliTPCmapper.h:123
 AliTPCmapper.h:124
 AliTPCmapper.h:125
 AliTPCmapper.h:126
 AliTPCmapper.h:127
 AliTPCmapper.h:128