File indexing completed on 2024-04-06 12:04:08
0001 #include "DataFormats/ForwardDetId/interface/HGCTriggerDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004 #include <iostream>
0005
0006 const uint32_t HGCTriggerDetId::cell_shift;
0007 const uint32_t HGCTriggerDetId::cell_mask;
0008 const uint32_t HGCTriggerDetId::module_mask;
0009 const uint32_t HGCTriggerDetId::module_shift;
0010 const uint32_t HGCTriggerDetId::sector_shift;
0011 const uint32_t HGCTriggerDetId::sector_mask;
0012 const uint32_t HGCTriggerDetId::layer_shift;
0013 const uint32_t HGCTriggerDetId::layer_mask;
0014 const uint32_t HGCTriggerDetId::zside_shift;
0015 const uint32_t HGCTriggerDetId::zside_mask;
0016
0017 const HGCTriggerDetId HGCTriggerDetId::Undefined(ForwardEmpty, 0, 0, 0, 0, 0);
0018
0019 HGCTriggerDetId::HGCTriggerDetId() : DetId() {}
0020
0021 HGCTriggerDetId::HGCTriggerDetId(uint32_t rawid) : DetId(rawid) {}
0022
0023 HGCTriggerDetId::HGCTriggerDetId(ForwardSubdetector subdet, int zp, int lay, int sec, int mod, int cell)
0024 : DetId(Forward, subdet) {
0025 if (zp < 0)
0026 zp = 0;
0027
0028 setMaskedId(cell, cell_shift, cell_mask);
0029 setMaskedId(sec, sector_shift, sector_mask);
0030 setMaskedId(mod, module_shift, module_mask);
0031 setMaskedId(lay, layer_shift, layer_mask);
0032 setMaskedId(zp, zside_shift, zside_mask);
0033 }
0034
0035 HGCTriggerDetId::HGCTriggerDetId(const DetId& gen) {
0036 if (!gen.null()) {
0037 ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0038 if (gen.det() != Forward || (subdet != HGCTrigger)) {
0039 throw cms::Exception("Invalid DetId")
0040 << "Cannot initialize HGCTriggerDetId from " << std::hex << gen.rawId() << std::dec;
0041 }
0042 }
0043 id_ = gen.rawId();
0044 }
0045
0046 HGCTriggerDetId& HGCTriggerDetId::operator=(const DetId& gen) {
0047 if (!gen.null()) {
0048 ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0049 if (gen.det() != Forward || (subdet != HGCTrigger)) {
0050 throw cms::Exception("Invalid DetId")
0051 << "Cannot assign HGCTriggerDetId from " << std::hex << gen.rawId() << std::dec;
0052 }
0053 }
0054 id_ = gen.rawId();
0055 return (*this);
0056 }
0057
0058 std::ostream& operator<<(std::ostream& s, const HGCTriggerDetId& id) {
0059 switch (id.subdet()) {
0060 case (HGCTrigger):
0061 return s << "isEE=" << id.isEE() << " zpos=" << id.zside() << " layer=" << id.layer() << " module=" << id.module()
0062 << " sector=" << id.sector() << " cell=" << id.cell();
0063 default:
0064 return s << id.rawId();
0065 }
0066 }