Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include "CondFormats/L1TObjects/interface/L1RPCHsbConfig.h"
#include "FWCore/Utilities/interface/Exception.h"

L1RPCHsbConfig::L1RPCHsbConfig() {}

L1RPCHsbConfig::~L1RPCHsbConfig() {}

void L1RPCHsbConfig::setHsbMask(int hsb, const std::vector<int>& mask) {
  if (getMaskSize() != int(mask.size())) {
    throw cms::Exception("L1RPCHsbConfig::setHsbMask")
        << "Wrong size of hsb mask " << mask.size() << " " << getMaskSize() << "\n";
  }

  if (hsb != 0 && hsb != 1) {
    throw cms::Exception("L1RPCHsbConfig::getHsbMask") << "Wrong hsb index: " << hsb << "\n";
  }
  if (hsb == 0) {
    for (int i = 0; i < getMaskSize(); ++i) {
      m_hsb0[i] = mask[i];
    }
  }

  if (hsb == 1) {
    for (int i = 0; i < getMaskSize(); ++i) {
      m_hsb1[i] = mask[i];
    }
  }
}

int L1RPCHsbConfig::getHsbMask(int hsb, int input) const {
  if (input < 0 || input >= int(sizeof(m_hsb0) / (sizeof(m_hsb0[0])))) {
    throw cms::Exception("L1RPCHsbConfig::getHsbMask") << "Wrong hsb input index: " << input << "\n";
  }
  if (hsb == 0) {
    return m_hsb0[input];
  } else if (hsb == 1) {
    return m_hsb1[input];
  } else {
    throw cms::Exception("L1RPCHsbConfig::getHsbMask") << "Wrong hsb index: " << hsb << "\n";
  }

  return -1;
}