CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/HcalDetId/src/HcalDcsDetId.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDetId/interface/HcalDcsDetId.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 #include <ostream>
00004 
00005 HcalDcsDetId::HcalDcsDetId() : HcalOtherDetId() {
00006 }
00007 
00008 HcalDcsDetId::HcalDcsDetId(uint32_t rawid) : HcalOtherDetId(rawid) {
00009 }
00010 
00011 HcalDcsDetId::HcalDcsDetId(DetId const& id) : HcalOtherDetId(id) {
00012   if ((subdet()!=HcalDcsBarrel) ||
00013       (subdet()!=HcalDcsEndcap) ||
00014       (subdet()!=HcalDcsOuter) ||
00015       (subdet()!=HcalDcsForward)) {
00016     throw cms::Exception("Invalid DetId") << "Cannot intialize HcalDcsDetId from "
00017                                           << std::hex << id_ << std::dec;
00018   }
00019 }
00020 
00021 HcalDcsDetId::HcalDcsDetId(HcalOtherSubdetector subd, int side_or_ring, 
00022                            unsigned int slc, DcsType ty, 
00023                            unsigned int subchan) : HcalOtherDetId(subd) {
00024   id_ |= ((side_or_ring > 0) ? ((1<<kSideOffset)|(side_or_ring<<kRingOffset)) : 
00025     ((-side_or_ring)<<kRingOffset));
00026   id_ |= (slc & 0x1F)<<kSliceOffset;
00027   id_ |= (ty & 0xF)<<kTypeOffset;
00028   id_ |= (subchan & 0xF)<<kSubChannelOffset;
00029 }
00030 
00031 HcalDcsDetId::DcsType HcalDcsDetId::DcsTypeFromString( const std::string& str) {
00032   int ty(HV);
00033   do {
00034     if (typeString(HcalDcsDetId::DcsType(ty))==str) 
00035       return HcalDcsDetId::DcsType(ty);
00036   } while (++ty != DCS_MAX);
00037   return DCSUNKNOWN;
00038 }
00039 
00040 std::string HcalDcsDetId::typeString (DcsType typ) {
00041   switch(typ) {
00042   case HV : return "HV";
00043   case BV : return "BV";
00044   case CATH : return "CATH";
00045   case DYN7 : return "DYN7";
00046   case DYN8 : return "DYN8";
00047   case RM_TEMP : return "RM_TEMP";
00048   case CCM_TEMP : return "CCM_TEMP";
00049   case CALIB_TEMP : return "CALIB_TEMP";
00050   case LVTTM_TEMP : return "LVTTM_TEMP";
00051   case TEMP : return "TEMP";
00052   case QPLL_LOCK : return "QPLL_LOCK";
00053   case STATUS : return "STATUS";
00054   default: return "DCSUNKNOWN";
00055   }
00056   return "Invalid";
00057 }
00058 
00059 std::ostream& operator<<(std::ostream& s,const HcalDcsDetId& id) {
00060   switch (id.subdet()) {
00061   case(HcalDcsBarrel) : return s << "(HB" << id.zside() << ' ' 
00062                                  << id.slice() << ' ' << id.typeString(id.type())
00063                                  << id.subchannel()
00064                                  << ')';
00065   case(HcalDcsEndcap) : return s << "(HE" << id.zside() << ' '
00066                                  << id.slice() << ' ' << id.typeString(id.type())
00067                                  << id.subchannel()
00068                                  << ')';
00069   case(HcalDcsOuter) : return s << "(HO" << id.ring() << " " 
00070                                 << id.slice() << ' ' << id.typeString(id.type())
00071                                 << id.subchannel()
00072                                 << ')';
00073   case(HcalDcsForward) : return s << "(HF" << id.zside() << ' '
00074                                   << ((id.type()<=HcalDcsDetId::DYN8)? "Q" : "")
00075                                   << id.slice() << ' ' << id.typeString(id.type())
00076                                   << id.subchannel()
00077                                   << ')';
00078   default : return s << id.rawId();
00079   }
00080 }