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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

#include "DataFormats/SiStripCommon/interface/SiStripKey.h"
#include "DataFormats/SiStripCommon/interface/Constants.h"
#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
#include <iomanip>

// -----------------------------------------------------------------------------
//
SiStripKey::SiStripKey(const uint32_t& key)
    : key_(key), path_(sistrip::null_), granularity_(sistrip::UNDEFINED_GRAN), channel_(sistrip::invalid_) {
  ;
}

// -----------------------------------------------------------------------------
//
SiStripKey::SiStripKey(const std::string& path)
    : key_(sistrip::invalid32_), path_(path), granularity_(sistrip::UNDEFINED_GRAN), channel_(sistrip::invalid_) {
  ;
}

// -----------------------------------------------------------------------------
//
SiStripKey::SiStripKey(const SiStripKey& input)
    : key_(input.key()), path_(input.path()), granularity_(input.granularity()), channel_(input.channel()) {
  ;
}

// -----------------------------------------------------------------------------
//
const SiStripKey& SiStripKey::operator=(const SiStripKey& rhs) {
  if (this == &rhs) {
    return *this;
  }
  key_ = rhs.key();
  path_ = rhs.path();
  granularity_ = rhs.granularity();
  channel_ = rhs.channel();
  return *this;
}

// -----------------------------------------------------------------------------
//
SiStripKey::SiStripKey()
    : key_(sistrip::invalid32_),
      path_(sistrip::null_),
      granularity_(sistrip::UNDEFINED_GRAN),
      channel_(sistrip::invalid_) {
  ;
}

// -----------------------------------------------------------------------------
//
bool SiStripKey::isEqual(const SiStripKey& input) const {
  if (key_ == input.key() && path_ == input.path() && granularity_ == input.granularity() &&
      channel_ == input.channel()) {
    return true;
  } else {
    return false;
  }
}

// -----------------------------------------------------------------------------
//
bool SiStripKey::isConsistent(const SiStripKey& input) const { return isEqual(input); }

// -----------------------------------------------------------------------------
//
bool SiStripKey::isValid() const {
  return (key_ != sistrip::invalid32_ && path_ != sistrip::null_ && granularity_ != sistrip::UNDEFINED_GRAN &&
          channel_ != sistrip::invalid_);
}

// -----------------------------------------------------------------------------
//
bool SiStripKey::isValid(const sistrip::Granularity& gran) const { return isValid(); }

// -----------------------------------------------------------------------------
//
bool SiStripKey::isInvalid() const {
  return (key_ == sistrip::invalid32_ || path_ == sistrip::null_ || granularity_ == sistrip::UNDEFINED_GRAN ||
          channel_ == sistrip::invalid_);
}

// -----------------------------------------------------------------------------
//
bool SiStripKey::isInvalid(const sistrip::Granularity& gran) const { return isInvalid(); }

// -----------------------------------------------------------------------------
//
void SiStripKey::print(std::stringstream& ss) const {
  ss << " [SiStripKey::print]" << std::endl
     << std::hex << " 32-bit key  : 0x" << std::setfill('0') << std::setw(8) << key() << std::endl
     << std::setfill(' ') << std::dec << " Directory   : " << path() << std::endl
     << " Granularity : " << SiStripEnumsAndStrings::granularity(granularity()) << std::endl
     << " Channel     : " << channel();
}

// -----------------------------------------------------------------------------
//
std::ostream& operator<<(std::ostream& os, const SiStripKey& input) {
  std::stringstream ss;
  input.print(ss);
  os << ss.str();
  return os;
}