CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalDetId.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 //#define DebugLog
5 
7 
8 HGCalDetId::HGCalDetId(uint32_t rawid) : DetId(rawid) {}
9 
10 HGCalDetId::HGCalDetId(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell)
11  : DetId(Forward, subdet) {
12  if (wafertype < 0)
13  wafertype = 0;
14  if (cell > kHGCalCellMask || cell < 0 || wafer > kHGCalWaferMask || wafer < 0 || wafertype > kHGCalWaferTypeMask ||
15  lay > kHGCalLayerMask || lay < 0) {
16 #ifdef DebugLog
17  std::cout << "[HGCalDetId] request for new id for"
18  << " layer=" << lay << ":" << kHGCalLayerMask << " @ zp=" << zp << " wafer=" << wafer << ":"
19  << kHGCalWaferMask << " waferType=" << wafertype << ":" << kHGCalWaferTypeMask << " cell=" << cell << ":"
20  << kHGCalCellMask << " for subdet=" << subdet << " has one or more fields out of bounds and will be reset"
21  << std::endl;
22 #endif
23  zp = lay = wafertype = wafer = cell = 0;
24  }
25  id_ |= ((cell & kHGCalCellMask) << kHGCalCellOffset);
26  id_ |= ((wafer & kHGCalWaferMask) << kHGCalWaferOffset);
27  id_ |= ((wafertype & kHGCalWaferTypeMask) << kHGCalWaferTypeOffset);
28  id_ |= ((lay & kHGCalLayerMask) << kHGCalLayerOffset);
29  if (zp > 0)
30  id_ |= ((zp & kHGCalZsideMask) << kHGCalZsideOffset);
31 }
32 
34 
36  id_ = gen.rawId();
37  return (*this);
38 }
39 
40 bool HGCalDetId::isValid(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell) {
41  bool ok = ((subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB) && (cell >= 0 && cell <= kHGCalCellMask) &&
42  (wafer >= 0 && wafer <= kHGCalWaferMask) && (wafertype <= kHGCalWaferTypeMask) &&
43  (lay >= 0 && lay <= kHGCalLayerMask) && (zp == -1 || zp == 1));
44 #ifdef DebugLog
45  if (!ok)
46  std::cout << "HGCalDetId: subdet " << subdet << ":" << (subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB)
47  << " Cell " << cell << ":" << (cell >= 0 && cell <= kHGCalCellMask) << " Wafer " << wafer << ":"
48  << (wafer >= 0 && wafer <= kHGCalWaferMask) << " WaferType " << wafertype << ":"
49  << (wafertype <= kHGCalWaferTypeMask) << " Layer " << lay << ":" << (lay >= 0 && lay <= kHGCalLayerMask)
50  << " zp " << zp << ":" << (zp == -1 || zp == 1) << std::endl;
51 #endif
52  return ok;
53 }
54 
55 std::ostream& operator<<(std::ostream& s, const HGCalDetId& id) {
56  return s << "HGCalDetId::isHGCal=" << id.isHGCal() << " subdet= " << id.subdetId() << " zpos=" << id.zside()
57  << " layer=" << id.layer() << " wafer type=" << id.waferType() << " wafer=" << id.wafer()
58  << " cell=" << id.cell();
59 }
static const int kHGCalLayerOffset
Definition: HGCalDetId.h:16
static const int kHGCalLayerMask
Definition: HGCalDetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static const int kHGCalWaferTypeOffset
Definition: HGCalDetId.h:14
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
ForwardSubdetector
static const int kHGCalCellOffset
Definition: HGCalDetId.h:10
static const int kHGCalCellMask
Definition: HGCalDetId.h:11
static const int kHGCalWaferTypeMask
Definition: HGCalDetId.h:15
Definition: DetId.h:17
HGCalDetId & operator=(const DetId &id)
Definition: HGCalDetId.cc:35
static const int kHGCalZsideMask
Definition: HGCalDetId.h:19
uint32_t id_
Definition: DetId.h:69
static const int kHGCalWaferOffset
Definition: HGCalDetId.h:12
static bool isValid(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell)
Definition: HGCalDetId.cc:40
tuple cout
Definition: gather_cfg.py:144
static const int kHGCalZsideOffset
Definition: HGCalDetId.h:18
static const int kHGCalWaferMask
Definition: HGCalDetId.h:13