CMS 3D CMS Logo

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