#include #include #include #include #include "../CentralHeaders/BitConstants.h" #include "../Logger/Logger.h" #include "../CentralHeaders/TpcException.h" #include #include using namespace std; #ifndef MAPPING_H #define MAPPING_H class Mapping{ public: Mapping(); ~Mapping(); void SetOffset(float offset); // [cm] void SetTimeBinLength(float tLength); // [microsec] void SetAngle(float newAngle) { fDR = fDZ * tan(newAngle * 3.14159265358979 / 180.); }; // [degree] void SetDriftVelocity(float dv) { fVelocity = dv; }; // [cm/mus] // Map pads to hardware address int32_t GetHWAddress(uint32_t padrow, uint32_t pad, uint32_t fRCU); int32_t DecodedHWAddressBranch(int32_t hwAddress); int32_t DecodedHWAddressFECaddr(int32_t hwAddress); int32_t DecodedHWAddressChipaddr(int32_t hwAddress); int32_t DecodedHWAddressChanneladdr(int32_t hwAddress); // Map hardware address to pads int16_t GetPadRow(int32_t hwAddress, uint32_t fRCU); int16_t GetPad(int32_t hwAddress, uint32_t fRCU); int16_t GetPadRow2(uint32_t Branch, uint32_t FEC, uint32_t chip, uint32_t channel, uint32_t fRCU); int16_t GetPad2(uint32_t Branch, uint32_t FEC, uint32_t chip, uint32_t channel, uint32_t fRCU); uint32_t GetNPads(uint32_t Row, uint32_t fRCU); uint32_t GetCenterPad(uint32_t Row, uint32_t fRCU); int16_t GetPadsPerRow(uint32_t Row, uint32_t fRCU); int32_t GetRocFromPatch(uint32_t side, uint32_t sector, uint32_t patch); int32_t GetDDLfromPatch(uint32_t side, uint32_t sector, uint32_t patch); // code/decode hardware adress uint32_t codeAddress(uint32_t Branch, uint32_t FEC, uint32_t chip, uint32_t channel); int32_t GetMaxHWAddress(uint32_t fRCU); // calculate relevant acceptance float GetRadialDistance(int32_t hwAddress, uint32_t fRCU); // [cm] float GetMaxRadialDistance(uint32_t Branch, uint32_t FEC, uint32_t chip, uint32_t fRCU); // [cm] float GetMinDriftTime(float RadDist); // in time bins uint32_t GetMinPadRow(uint32_t fRCU) { return fRCUs[fRCU].fMinPadRow; }; uint32_t GetMaxPadRow(uint32_t fRCU) { return fRCUs[fRCU].fMaxPadRow; }; float GetAngle() { return( atan(fDR/fDZ) * 180 / 3.14159265358979 ); }; // [degree] float GetOffset() { return fOffset; }; // [cm] float GetTimeBinLength() { return(fTimeBinLength); /* default is 0.1 microsec */ }; // [microsec] float GetDriftVelocity() { return fVelocity; }; // [cm/microsec] void setDebugLevel(int32_t dbl) { fLogger->setDebugLevel(dbl); }; int32_t getDebugLevel() { return fLogger->getDebugLevel(); }; private: // read one mapping file void ReadRCU(uint32_t fRCU); // create inverse mapping void CreateInvMapping(uint32_t fRCU); // set the number of pads per row void SetPadsPerRow(uint32_t Row, uint32_t fRCU, int16_t PadCount); struct RCUMapping { uint32_t fMaxHWAddress; // uint32_t fMinPadRow; // Minimum Index of pad-row uint32_t fMaxPadRow; // Maximum Index of pad-row uint32_t fMaxPad; // Maximum Index of pad inside row int16_t *fMapping; // The mapping int16_t *fInvMapping; // The inverse mapping }; uint32_t *fNPads[2]; // number of pads in row (for IROC/OROC) uint32_t *fCenterPad[2]; // First pad in branch B in this row (for IROC/OROC) uint32_t fRCUCount; // Number of RCUs (6) int16_t fPadsPerRow[240]; // Number of pads in a padrow RCUMapping *fRCUs; float fDZ; // max driftlength in z [cm] float fDR; // max radius to outermost padrow of OROC [cm] float fVelocity; // drift velocity [cm/microsec] float fOffset; // offset to add [cm] float fTimeBinLength; // length of a time bin [microsec] Logger *fLogger; // Logging class }; #endif // MAPPING_H