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 sec, int subsec, int cell) : DetId(Forward,subdet) {
13 
14  if (cell > kHGCalCellMask || sec>kHGCalSectorMask ||
15  subsec > kHGCalSubSectorMask || lay>kHGCalLayerMask ) {
16 #ifdef DebugLog
17  std::cout << "[HGCalDetId] request for new id for layer=" << lay
18  << " @ zp=" << zp
19  << " sector=" << sec
20  << " subsec=" << subsec
21  << " cell=" << cell
22  << " for subdet=" << subdet
23  << " has one or more fields out of bounds and will be reset"
24  << std::endl;
25 #endif
26  cell=0; sec=0; subsec=0; lay=0;
27  }
28  uint32_t rawid=0;
29  rawid |= ((cell & kHGCalCellMask) << kHGCalCellOffset);
30  rawid |= ((sec & kHGCalSectorMask) << kHGCalSectorOffset);
31  if (subsec<0) subsec=0;
32  rawid |= ((subsec & kHGCalSubSectorMask) << kHGCalSubSectorOffset);
33  rawid |= ((lay & kHGCalLayerMask) << kHGCalLayerOffset);
34  if (zp>0) rawid |= ((zp & kHGCalZsideMask) << kHGCalZsideOffset);
35  id_ = rawid;
36 }
37 
39  id_ = gen.rawId();
40 }
41 
43  id_ = gen.rawId();
44  return (*this);
45 }
46 
47 bool HGCalDetId::isValid(ForwardSubdetector subdet, int zp, int lay,
48  int mod, int subsec, int cell) {
49  bool ok = ((subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB) &&
50  (cell >= 0 && cell <= kHGCalCellMask) &&
51  (mod >= 1 && mod <= kHGCalSectorMask) &&
52  (subsec == 0 || subsec == 1) &&
53  (lay >= 0 && lay <= kHGCalLayerMask) &&
54  (zp == -1 || zp == 1));
55 #ifdef DebugLog
56  if (!ok)
57  std::cout << "HGCalDetId: subdet " << subdet << ":"
58  << (subdet == HGCEE || subdet == HGCHEF || subdet == HGCHEB)
59  << " Cell " << cell << ":" << (cell >= 0 && cell <= 0xffff)
60  << " Module " << mod << ":" << (mod >= 1 && mod <= 0x7f)
61  << " SubSector " << subsec << ":" << (subsec == 0 || subsec == 1)
62  << " Layer " << lay << ":" << (lay >= 0 && lay <= 0x7f)
63  << " zp " << zp << ":" << (zp == -1 || zp == 1) << std::endl;
64 #endif
65  return ok;
66 }
67 
68 std::ostream& operator<<(std::ostream& s,const HGCalDetId& id) {
69  return s << "isHGCal=" << id.isHGCal() << " zpos=" << id.zside()
70  << " layer=" << id.layer() << " phi subSector=" << id.subsector()
71  << " sector=" << id.sector() << " cell=" << id.cell();
72 }
static const int kHGCalLayerOffset
Definition: HGCalDetId.h:18
static const int kHGCalLayerMask
Definition: HGCalDetId.h:19
static const int kHGCalSubSectorMask
Definition: HGCalDetId.h:17
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
ForwardSubdetector
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 kHGCalSectorOffset
Definition: HGCalDetId.h:14
Definition: DetId.h:18
HGCalDetId & operator=(const DetId &id)
Definition: HGCalDetId.cc:42
static const int kHGCalZsideMask
Definition: HGCalDetId.h:21
static bool isValid(ForwardSubdetector subdet, int zp, int lay, int mod, int subsec, int cell)
Definition: HGCalDetId.cc:47
uint32_t id_
Definition: DetId.h:55
tuple cout
Definition: gather_cfg.py:121
static const int kHGCalZsideOffset
Definition: HGCalDetId.h:20
static const int kHGCalSubSectorOffset
Definition: HGCalDetId.h:16
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
static const int kHGCalSectorMask
Definition: HGCalDetId.h:15