Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:22

0001 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004 #include <iostream>
0005 
0006 const HGCSiliconDetId HGCSiliconDetId::Undefined(HGCalEE, 0, 0, 0, 0, 0, 0, 0);
0007 
0008 HGCSiliconDetId::HGCSiliconDetId() : DetId() {}
0009 
0010 HGCSiliconDetId::HGCSiliconDetId(uint32_t rawid) : DetId(rawid) {}
0011 
0012 HGCSiliconDetId::HGCSiliconDetId(
0013     DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV)
0014     : DetId(det, ForwardEmpty) {
0015   int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
0016   int waferUsign = (waferU >= 0) ? 0 : 1;
0017   int waferVsign = (waferV >= 0) ? 0 : 1;
0018   int zside = (zp < 0) ? 1 : 0;
0019   id_ |= (((cellU & kHGCalCellUMask) << kHGCalCellUOffset) | ((cellV & kHGCalCellVMask) << kHGCalCellVOffset) |
0020           ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) |
0021           ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) |
0022           ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) |
0023           ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) |
0024           ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
0025           ((type & kHGCalTypeMask) << kHGCalTypeOffset));
0026 }
0027 
0028 HGCSiliconDetId::HGCSiliconDetId(const DetId& gen) {
0029   if (!gen.null()) {
0030     if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) {
0031       throw cms::Exception("Invalid DetId")
0032           << "Cannot initialize HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec;
0033     }
0034   }
0035   id_ = gen.rawId();
0036 }
0037 
0038 HGCSiliconDetId& HGCSiliconDetId::operator=(const DetId& gen) {
0039   if (!gen.null()) {
0040     if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) {
0041       throw cms::Exception("Invalid DetId")
0042           << "Cannot assign HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec;
0043     }
0044   }
0045   id_ = gen.rawId();
0046   return (*this);
0047 }
0048 
0049 std::ostream& operator<<(std::ostream& s, const HGCSiliconDetId& id) {
0050   return s << " HGCSiliconDetId::EE:HE= " << id.isEE() << ":" << id.isHE() << " type= " << id.type()
0051            << " z= " << id.zside() << " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << ","
0052            << id.waferV() << ":" << id.waferX() << "," << id.waferY() << ")"
0053            << " cell(u,v:x,y)= (" << id.cellU() << "," << id.cellV() << ":" << id.cellX() << "," << id.cellY() << ")";
0054 }