File indexing completed on 2024-04-06 12:05:14
0001
0002 #include "DataFormats/SiStripCommon/interface/SiStripKey.h"
0003 #include "DataFormats/SiStripCommon/interface/Constants.h"
0004 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0005 #include <iomanip>
0006
0007
0008
0009 SiStripKey::SiStripKey(const uint32_t& key)
0010 : key_(key), path_(sistrip::null_), granularity_(sistrip::UNDEFINED_GRAN), channel_(sistrip::invalid_) {
0011 ;
0012 }
0013
0014
0015
0016 SiStripKey::SiStripKey(const std::string& path)
0017 : key_(sistrip::invalid32_), path_(path), granularity_(sistrip::UNDEFINED_GRAN), channel_(sistrip::invalid_) {
0018 ;
0019 }
0020
0021
0022
0023 SiStripKey::SiStripKey(const SiStripKey& input)
0024 : key_(input.key()), path_(input.path()), granularity_(input.granularity()), channel_(input.channel()) {
0025 ;
0026 }
0027
0028
0029
0030 const SiStripKey& SiStripKey::operator=(const SiStripKey& rhs) {
0031 if (this == &rhs) {
0032 return *this;
0033 }
0034 key_ = rhs.key();
0035 path_ = rhs.path();
0036 granularity_ = rhs.granularity();
0037 channel_ = rhs.channel();
0038 return *this;
0039 }
0040
0041
0042
0043 SiStripKey::SiStripKey()
0044 : key_(sistrip::invalid32_),
0045 path_(sistrip::null_),
0046 granularity_(sistrip::UNDEFINED_GRAN),
0047 channel_(sistrip::invalid_) {
0048 ;
0049 }
0050
0051
0052
0053 bool SiStripKey::isEqual(const SiStripKey& input) const {
0054 if (key_ == input.key() && path_ == input.path() && granularity_ == input.granularity() &&
0055 channel_ == input.channel()) {
0056 return true;
0057 } else {
0058 return false;
0059 }
0060 }
0061
0062
0063
0064 bool SiStripKey::isConsistent(const SiStripKey& input) const { return isEqual(input); }
0065
0066
0067
0068 bool SiStripKey::isValid() const {
0069 return (key_ != sistrip::invalid32_ && path_ != sistrip::null_ && granularity_ != sistrip::UNDEFINED_GRAN &&
0070 channel_ != sistrip::invalid_);
0071 }
0072
0073
0074
0075 bool SiStripKey::isValid(const sistrip::Granularity& gran) const { return isValid(); }
0076
0077
0078
0079 bool SiStripKey::isInvalid() const {
0080 return (key_ == sistrip::invalid32_ || path_ == sistrip::null_ || granularity_ == sistrip::UNDEFINED_GRAN ||
0081 channel_ == sistrip::invalid_);
0082 }
0083
0084
0085
0086 bool SiStripKey::isInvalid(const sistrip::Granularity& gran) const { return isInvalid(); }
0087
0088
0089
0090 void SiStripKey::print(std::stringstream& ss) const {
0091 ss << " [SiStripKey::print]" << std::endl
0092 << std::hex << " 32-bit key : 0x" << std::setfill('0') << std::setw(8) << key() << std::endl
0093 << std::setfill(' ') << std::dec << " Directory : " << path() << std::endl
0094 << " Granularity : " << SiStripEnumsAndStrings::granularity(granularity()) << std::endl
0095 << " Channel : " << channel();
0096 }
0097
0098
0099
0100 std::ostream& operator<<(std::ostream& os, const SiStripKey& input) {
0101 std::stringstream ss;
0102 input.print(ss);
0103 os << ss.str();
0104 return os;
0105 }