File indexing completed on 2024-04-06 12:05:08
0001 #include "DataFormats/RPCDigi/interface/RPCDigiL1Link.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003
0004 RPCDigiL1Link::RPCDigiL1Link() {
0005 for (unsigned int i = 0; i < 7; i++) {
0006 std::pair<unsigned int, int> c(0, 0);
0007 _link.push_back(c);
0008 }
0009 }
0010
0011 RPCDigiL1Link::~RPCDigiL1Link() {}
0012
0013 bool RPCDigiL1Link::empty() const {
0014 bool e = true;
0015 for (unsigned int l = 1; l <= 6; l++) {
0016 if (!this->empty(l))
0017 e = false;
0018 }
0019 return e;
0020 }
0021
0022 bool RPCDigiL1Link::empty(unsigned int layer) const {
0023 this->checklayer(layer);
0024 return this->rawdetId(layer) == 0;
0025 }
0026
0027 unsigned int RPCDigiL1Link::rawdetId(unsigned int layer) const {
0028 this->checklayer(layer);
0029 return _link[layer - 1].first;
0030 }
0031
0032 int RPCDigiL1Link::strip(unsigned int layer) const {
0033 this->checklayer(layer);
0034 return abs(_link[layer - 1].second) % 1000;
0035 }
0036
0037 int RPCDigiL1Link::bx(unsigned int layer) const {
0038 this->checklayer(layer);
0039 return _link[layer - 1].second / 1000;
0040 }
0041
0042 unsigned int RPCDigiL1Link::nlayer() const { return _link.size() - 1; }
0043
0044 void RPCDigiL1Link::setLink(unsigned int layer, unsigned int rpcdetId, int strip, int bx) {
0045 this->checklayer(layer);
0046 int pdigi = abs(bx) * 1000 + strip;
0047 if (bx < 0)
0048 pdigi *= -1;
0049 std::pair<unsigned int, int> digi(rpcdetId, pdigi);
0050 _link[layer - 1] = digi;
0051 }
0052
0053 void RPCDigiL1Link::checklayer(unsigned int layer) const {
0054 if (layer == 0 || layer > 6)
0055 throw cms::Exception("RPCException") << "RPCDigiL1Link: layer must be in the range from 1 to 6" << std::endl;
0056 }