CMS 3D CMS Logo

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  }
27  id_ |= ((wafertype & kHGCalWaferTypeMask) << kHGCalWaferTypeOffset);
28  id_ |= ((lay & kHGCalLayerMask) << kHGCalLayerOffset);
29  if (zp > 0)
30  id_ |= ((zp & kHGCalZsideMask) << kHGCalZsideOffset);
31 }
32 
33 HGCalDetId::HGCalDetId(const DetId& gen) { id_ = gen.rawId(); }
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 }
HGCalDetId::kHGCalWaferTypeMask
static const int kHGCalWaferTypeMask
Definition: HGCalDetId.h:15
HGCalDetId::operator=
HGCalDetId & operator=(const DetId &id)
Definition: HGCalDetId.cc:35
HGCalDetId::kHGCalWaferOffset
static const int kHGCalWaferOffset
Definition: HGCalDetId.h:12
HGCalDetId::HGCalDetId
HGCalDetId()
Definition: HGCalDetId.cc:6
ForwardSubdetector
ForwardSubdetector
Definition: ForwardSubdetector.h:4
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HGCalDetId::kHGCalZsideMask
static const int kHGCalZsideMask
Definition: HGCalDetId.h:19
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
HGCalDetId::isValid
static bool isValid(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell)
Definition: HGCalDetId.cc:40
HGCalDetId::kHGCalZsideOffset
static const int kHGCalZsideOffset
Definition: HGCalDetId.h:18
HGCalDetId::kHGCalWaferMask
static const int kHGCalWaferMask
Definition: HGCalDetId.h:13
DetId
Definition: DetId.h:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
gen
Definition: PythiaDecays.h:13
HGCEE
Definition: ForwardSubdetector.h:8
HGCalDetId::kHGCalLayerOffset
static const int kHGCalLayerOffset
Definition: HGCalDetId.h:16
DetId::id_
uint32_t id_
Definition: DetId.h:69
HGCalDetId::kHGCalWaferTypeOffset
static const int kHGCalWaferTypeOffset
Definition: HGCalDetId.h:14
HGCalDetId::wafer
int wafer() const
get the wafer #
Definition: HGCalDetId.h:40
HGCalDetId
Definition: HGCalDetId.h:8
HGCalDetId::kHGCalCellMask
static const int kHGCalCellMask
Definition: HGCalDetId.h:11
HGCalDetId.h
HGCalDetId::kHGCalLayerMask
static const int kHGCalLayerMask
Definition: HGCalDetId.h:17
HGCalDetId::kHGCalCellOffset
static const int kHGCalCellOffset
Definition: HGCalDetId.h:10
HGCHEF
Definition: ForwardSubdetector.h:9
operator<<
std::ostream & operator<<(std::ostream &s, const HGCalDetId &id)
Definition: HGCalDetId.cc:55
HGCalDetId::cell
int cell() const
get the absolute value of the cell #'s in x and y
Definition: HGCalDetId.h:37
HGCHEB
Definition: ForwardSubdetector.h:10