Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:08

0001 #include "DataFormats/ForwardDetId/interface/HGCEEDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004 #include <iostream>
0005 
0006 const HGCEEDetId HGCEEDetId::Undefined(ForwardEmpty, 0, 0, 0, 0, 0);
0007 
0008 HGCEEDetId::HGCEEDetId() : DetId() {}
0009 
0010 HGCEEDetId::HGCEEDetId(uint32_t rawid) : DetId(rawid) {}
0011 
0012 HGCEEDetId::HGCEEDetId(ForwardSubdetector subdet, int zp, int lay, int sec, int subsec, int cell)
0013     : DetId(Forward, subdet) {
0014   id_ |= ((cell & kHGCEECellMask) << kHGCEECellOffset);
0015   id_ |= ((sec & kHGCEESectorMask) << kHGCEESectorOffset);
0016   if (subsec < 0)
0017     subsec = 0;
0018   id_ |= ((subsec & kHGCEESubSectorMask) << kHGCEESubSectorOffset);
0019   id_ |= ((lay & kHGCEELayerMask) << kHGCEELayerOffset);
0020   if (zp > 0)
0021     id_ |= ((zp & kHGCEEZsideMask) << kHGCEEZsideOffset);
0022 }
0023 
0024 HGCEEDetId::HGCEEDetId(const DetId& gen) {
0025   if (!gen.null()) {
0026     ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0027     if (gen.det() != Forward || (subdet != HGCEE)) {
0028       throw cms::Exception("Invalid DetId")
0029           << "Cannot initialize HGCEEDetId from " << std::hex << gen.rawId() << std::dec;
0030     }
0031   }
0032   id_ = gen.rawId();
0033 }
0034 
0035 HGCEEDetId& HGCEEDetId::operator=(const DetId& gen) {
0036   if (!gen.null()) {
0037     ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0038     if (gen.det() != Forward || (subdet != HGCEE)) {
0039       throw cms::Exception("Invalid DetId") << "Cannot assign HGCEEDetId from " << std::hex << gen.rawId() << std::dec;
0040     }
0041   }
0042   id_ = gen.rawId();
0043   return (*this);
0044 }
0045 
0046 std::ostream& operator<<(std::ostream& s, const HGCEEDetId& id) {
0047   switch (id.subdet()) {
0048     case (HGCEE):
0049       return s << "isEE=" << id.isEE() << " zpos=" << id.zside() << " layer=" << id.layer()
0050                << " phi subSector=" << id.subsector() << " sector=" << id.sector() << " cell=" << id.cell();
0051     default:
0052       return s << id.rawId();
0053   }
0054 }