File indexing completed on 2024-04-06 12:04:17
0001 #include "DataFormats/HcalDetId/interface/HcalDcsDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004
0005 HcalDcsDetId::HcalDcsDetId() : HcalOtherDetId() {}
0006
0007 HcalDcsDetId::HcalDcsDetId(uint32_t rawid) : HcalOtherDetId(rawid) {}
0008
0009 HcalDcsDetId::HcalDcsDetId(DetId const& id) : HcalOtherDetId(id) {
0010 if ((subdet() != HcalDcsBarrel) || (subdet() != HcalDcsEndcap) || (subdet() != HcalDcsOuter) ||
0011 (subdet() != HcalDcsForward)) {
0012 throw cms::Exception("Invalid DetId") << "Cannot intialize HcalDcsDetId from " << std::hex << id_ << std::dec;
0013 }
0014 }
0015
0016 HcalDcsDetId::HcalDcsDetId(
0017 HcalOtherSubdetector subd, int side_or_ring, unsigned int slc, DcsType ty, unsigned int subchan)
0018 : HcalOtherDetId(subd) {
0019 id_ |= ((side_or_ring > 0) ? ((1 << kSideOffset) | (side_or_ring << kRingOffset)) : ((-side_or_ring) << kRingOffset));
0020 id_ |= (slc & 0x1F) << kSliceOffset;
0021 id_ |= (ty & 0xF) << kTypeOffset;
0022 id_ |= (subchan & 0xF) << kSubChannelOffset;
0023 }
0024
0025 HcalDcsDetId::DcsType HcalDcsDetId::DcsTypeFromString(const std::string& str) {
0026 int ty(HV);
0027 do {
0028 if (typeString(HcalDcsDetId::DcsType(ty)) == str)
0029 return HcalDcsDetId::DcsType(ty);
0030 } while (++ty != DCS_MAX);
0031 return DCSUNKNOWN;
0032 }
0033
0034 std::string HcalDcsDetId::typeString(DcsType typ) {
0035 switch (typ) {
0036 case HV:
0037 return "HV";
0038 case BV:
0039 return "BV";
0040 case CATH:
0041 return "CATH";
0042 case DYN7:
0043 return "DYN7";
0044 case DYN8:
0045 return "DYN8";
0046 case RM_TEMP:
0047 return "RM_TEMP";
0048 case CCM_TEMP:
0049 return "CCM_TEMP";
0050 case CALIB_TEMP:
0051 return "CALIB_TEMP";
0052 case LVTTM_TEMP:
0053 return "LVTTM_TEMP";
0054 case TEMP:
0055 return "TEMP";
0056 case QPLL_LOCK:
0057 return "QPLL_LOCK";
0058 case STATUS:
0059 return "STATUS";
0060 default:
0061 return "DCSUNKNOWN";
0062 }
0063 return "Invalid";
0064 }
0065
0066 std::ostream& operator<<(std::ostream& s, const HcalDcsDetId& id) {
0067 switch (id.subdet()) {
0068 case (HcalDcsBarrel):
0069 return s << "(HB" << id.zside() << ' ' << id.slice() << ' ' << id.typeString(id.type()) << id.subchannel() << ')';
0070 case (HcalDcsEndcap):
0071 return s << "(HE" << id.zside() << ' ' << id.slice() << ' ' << id.typeString(id.type()) << id.subchannel() << ')';
0072 case (HcalDcsOuter):
0073 return s << "(HO" << id.ring() << " " << id.slice() << ' ' << id.typeString(id.type()) << id.subchannel() << ')';
0074 case (HcalDcsForward):
0075 return s << "(HF" << id.zside() << ' ' << ((id.type() <= HcalDcsDetId::DYN8) ? "Q" : "") << id.slice() << ' '
0076 << id.typeString(id.type()) << id.subchannel() << ')';
0077 default:
0078 return s << id.rawId();
0079 }
0080 }