Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0002 #include <iostream>
0003 
0004 //#define DebugLog
0005 
0006 HGCalDetId::HGCalDetId() : DetId() {}
0007 
0008 HGCalDetId::HGCalDetId(uint32_t rawid) : DetId(rawid) {}
0009 
0010 HGCalDetId::HGCalDetId(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell)
0011     : DetId(Forward, subdet) {
0012   if (wafertype < 0)
0013     wafertype = 0;
0014   if (cell > kHGCalCellMask || cell < 0 || wafer > kHGCalWaferMask || wafer < 0 || wafertype > kHGCalWaferTypeMask ||
0015       lay > kHGCalLayerMask || lay < 0) {
0016 #ifdef DebugLog
0017     std::cout << "[HGCalDetId] request for new id for"
0018               << " layer=" << lay << ":" << kHGCalLayerMask << " @ zp=" << zp << " wafer=" << wafer << ":"
0019               << kHGCalWaferMask << " waferType=" << wafertype << ":" << kHGCalWaferTypeMask << " cell=" << cell << ":"
0020               << kHGCalCellMask << " for subdet=" << subdet << " has one or more fields out of bounds and will be reset"
0021               << std::endl;
0022 #endif
0023     zp = lay = wafertype = wafer = cell = 0;
0024   }
0025   id_ |= ((cell & kHGCalCellMask) << kHGCalCellOffset);
0026   id_ |= ((wafer & kHGCalWaferMask) << kHGCalWaferOffset);
0027   id_ |= ((wafertype & kHGCalWaferTypeMask) << kHGCalWaferTypeOffset);
0028   id_ |= ((lay & kHGCalLayerMask) << kHGCalLayerOffset);
0029   if (zp > 0)
0030     id_ |= ((zp & kHGCalZsideMask) << kHGCalZsideOffset);
0031 }
0032 
0033 HGCalDetId::HGCalDetId(const DetId& gen) { id_ = gen.rawId(); }
0034 
0035 HGCalDetId& HGCalDetId::operator=(const DetId& gen) {
0036   id_ = gen.rawId();
0037   return (*this);
0038 }
0039 
0040 bool HGCalDetId::isValid(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell) {
0041   bool ok = ((subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB) && (cell >= 0 && cell <= kHGCalCellMask) &&
0042              (wafer >= 0 && wafer <= kHGCalWaferMask) && (wafertype <= kHGCalWaferTypeMask) &&
0043              (lay >= 0 && lay <= kHGCalLayerMask) && (zp == -1 || zp == 1));
0044 #ifdef DebugLog
0045   if (!ok)
0046     std::cout << "HGCalDetId: subdet " << subdet << ":" << (subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB)
0047               << " Cell " << cell << ":" << (cell >= 0 && cell <= kHGCalCellMask) << " Wafer " << wafer << ":"
0048               << (wafer >= 0 && wafer <= kHGCalWaferMask) << " WaferType " << wafertype << ":"
0049               << (wafertype <= kHGCalWaferTypeMask) << " Layer " << lay << ":" << (lay >= 0 && lay <= kHGCalLayerMask)
0050               << " zp " << zp << ":" << (zp == -1 || zp == 1) << std::endl;
0051 #endif
0052   return ok;
0053 }
0054 
0055 std::ostream& operator<<(std::ostream& s, const HGCalDetId& id) {
0056   return s << "HGCalDetId::isHGCal=" << id.isHGCal() << " subdet= " << id.subdetId() << " zpos=" << id.zside()
0057            << " layer=" << id.layer() << " wafer type=" << id.waferType() << " wafer=" << id.wafer()
0058            << " cell=" << id.cell();
0059 }