00001 #ifndef DATAFORMATS_HCALDETID_CASTORELECTRONICSID_H 00002 #define DATAFORMATS_HCALDETID_CASTORELECTRONICSID_H 1 00003 00004 #include <string> 00005 #include <ostream> 00006 00019 class CastorElectronicsId { 00020 public: 00022 CastorElectronicsId(); 00023 CastorElectronicsId(uint32_t); 00024 CastorElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid); 00025 CastorElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb); 00026 uint32_t operator()() { return castorElectronicsId_; } 00027 00028 uint32_t rawId() const { return castorElectronicsId_; } 00029 00030 bool isTriggerChainId() const { return (castorElectronicsId_&0x02000000)!=0; } 00031 00032 void setHTR(int crate, int slot, int tb); 00033 int fiberChanId() const { return castorElectronicsId_&0x3; } 00034 int fiberIndex() const { return ((castorElectronicsId_>>2)&0x7)+1; } 00035 int slbChannelIndex() const { return castorElectronicsId_&0x3; } 00036 int slbSiteNumber() const { return ((castorElectronicsId_>>2)&0x7)+1; } 00037 00038 std::string slbChannelCode() const; 00039 00040 int htrChanId() const { return (fiberChanId()+1)+((fiberIndex()-1)*3); } 00041 int spigot() const { return (castorElectronicsId_>>5)&0xF; } 00042 int dccid() const { return (castorElectronicsId_>>9)&0x1F; } 00043 int htrSlot() const { return (castorElectronicsId_>>14)&0x1F; } 00044 int htrTopBottom() const { return (castorElectronicsId_>>19)&0x1; } 00045 int readoutVMECrateId() const { return (castorElectronicsId_>>20)&0x1F; } 00046 int linearIndex() const { return (castorElectronicsId_)&0x3FFF; } 00047 00048 static const int maxLinearIndex = 0x3FFF; 00049 static const int maxDCCId = 31; 00050 00052 int operator==(const CastorElectronicsId& id) const { return id.castorElectronicsId_==castorElectronicsId_; } 00053 int operator!=(const CastorElectronicsId& id) const { return id.castorElectronicsId_!=castorElectronicsId_; } 00055 int operator<(const CastorElectronicsId& id) const { return castorElectronicsId_<id.castorElectronicsId_; } 00056 00057 private: 00058 uint32_t castorElectronicsId_; 00059 }; 00060 00061 std::ostream& operator<<(std::ostream&,const CastorElectronicsId&); 00062 00063 00064 #endif