Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-04 01:50:46

0001 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004 #include <iostream>
0005 
0006 const HFNoseDetId HFNoseDetId::Undefined(0, 0, 0, 0, 0, 0, 0);
0007 
0008 HFNoseDetId::HFNoseDetId() : DetId() {}
0009 
0010 HFNoseDetId::HFNoseDetId(uint32_t rawid) : DetId(rawid) {}
0011 
0012 HFNoseDetId::HFNoseDetId(DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV)
0013     : DetId(det, HFNose) {
0014   int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
0015   int waferUsign = (waferU >= 0) ? 0 : 1;
0016   int waferVsign = (waferV >= 0) ? 0 : 1;
0017   int zside = (zp < 0) ? 1 : 0;
0018   int lay = std::max(layer - 1, 0);
0019   id_ |= (((cellU & kHFNoseCellUMask) << kHFNoseCellUOffset) | ((cellV & kHFNoseCellVMask) << kHFNoseCellVOffset) |
0020           ((waferUabs & kHFNoseWaferUMask) << kHFNoseWaferUOffset) |
0021           ((waferUsign & kHFNoseWaferUSignMask) << kHFNoseWaferUSignOffset) |
0022           ((waferVabs & kHFNoseWaferVMask) << kHFNoseWaferVOffset) |
0023           ((waferVsign & kHFNoseWaferVSignMask) << kHFNoseWaferVSignOffset) |
0024           ((lay & kHFNoseLayerMask) << kHFNoseLayerOffset) | ((zside & kHFNoseZsideMask) << kHFNoseZsideOffset) |
0025           ((type & kHFNoseTypeMask) << kHFNoseTypeOffset));
0026 }
0027 
0028 HFNoseDetId::HFNoseDetId(int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV)
0029     : HFNoseDetId(Forward, zp, type, layer, waferU, waferV, cellU, cellV) {}
0030 
0031 HFNoseDetId::HFNoseDetId(const DetId& gen) {
0032   if (!gen.null()) {
0033     if (!((gen.det() == Forward) && (gen.subdetId() == (int)(HFNose)))) {
0034       throw cms::Exception("Invalid DetId")
0035           << "Cannot initialize HFNoseDetId from " << std::hex << gen.rawId() << std::dec;
0036     }
0037   }
0038   id_ = gen.rawId();
0039 }
0040 
0041 HFNoseDetId& HFNoseDetId::operator=(const DetId& gen) {
0042   if (!gen.null()) {
0043     if (!((gen.det() == Forward) && (gen.subdetId() == (int)(HFNose)))) {
0044       throw cms::Exception("Invalid DetId") << "Cannot assign HFNoseDetId from " << std::hex << gen.rawId() << std::dec;
0045     }
0046   }
0047   id_ = gen.rawId();
0048   return (*this);
0049 }
0050 
0051 std::ostream& operator<<(std::ostream& s, const HFNoseDetId& id) {
0052   return s << " HFNoseDetId::EE:HE= " << id.isEE() << ":" << id.isHE() << " type= " << id.type() << " z= " << id.zside()
0053            << " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":"
0054            << id.waferX() << "," << id.waferY() << ")"
0055            << " cell(u,v:x,y)= (" << id.cellU() << "," << id.cellV() << ":" << id.cellX() << "," << id.cellY() << ")";
0056 }