#include "Geometry/HGCalCommonData/interface/HGCalProperty.h"

int32_t HGCalProperty::waferProperty(const int32_t thick,
                                     const int32_t part,
                                     const int32_t orient,
                                     const int32_t cassette) {
  return (((thick % HGCalProperty::kHGCalFactor) * HGCalProperty::kHGCalOffsetThick) +
          ((part % HGCalProperty::kHGCalFactorPartial) * HGCalProperty::kHGCalOffsetPartial) +
          ((orient % HGCalProperty::kHGCalFactor) * HGCalProperty::kHGCalOffsetOrient) +
          ((cassette % HGCalProperty::kHGCalFactorCassette) * HGCalProperty::kHGCalOffsetCassette));
}

int32_t HGCalProperty::waferThick(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetThick) % HGCalProperty::kHGCalFactor);
}

int32_t HGCalProperty::waferPartial(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetPartial) % HGCalProperty::kHGCalFactorPartial);
}

int32_t HGCalProperty::waferOrient(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetOrient) % HGCalProperty::kHGCalFactor);
}

int32_t HGCalProperty::waferCassette(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetCassette) % HGCalProperty::kHGCalFactorCassette);
}

int32_t HGCalProperty::tileProperty(const int32_t type, const int32_t sipm) {
  return (((type % HGCalProperty::kHGCalFactor) * HGCalProperty::kHGCalOffsetType) +
          ((sipm % HGCalProperty::kHGCalFactor) * HGCalProperty::kHGCalOffsetSiPM));
}

int32_t HGCalProperty::tileType(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetType) % HGCalProperty::kHGCalFactor);
}

int32_t HGCalProperty::tileSiPM(const int32_t property) {
  return ((property / HGCalProperty::kHGCalOffsetSiPM) % HGCalProperty::kHGCalFactor);
}
