ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InttDeadMap.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InttDeadMap.cc
1 #include "InttDeadMap.h"
2 
4 
5 #include <cassert>
6 #include <iostream>
7 #include <limits>
8 
9 using namespace std;
10 
12 
13 const InttDeadMap::Map&
15 {
16  static Map tmp_map;
17  return tmp_map;
18 }
19 
22 {
23  static Map tmp_map;
24  return tmp_map;
25 }
26 
28  const int ladder_phi, const int ladder_z,
29  const int strip_z, const int strip_phi)
30 {
31  addDeadChannel(getInttKey(layer,
32  ladder_phi, ladder_z,
33  strip_z, strip_phi));
34 }
35 
37  const int ladder_phi, const int ladder_z,
38  const int strip_z, const int strip_phi) const
39 {
40  if (isDeadChannel(getInttKey(layer,
41  ladder_phi, ladder_z,
42  strip_z, strip_phi)))
43  return true;
44  else if (isDeadChannel(getInttKey(layer,
45  ladder_phi, ladder_z,
46  strip_z, s_wildCardID)))
47  return true;
48  else if (isDeadChannel(getInttKey(layer,
49  ladder_phi, ladder_z,
50  s_wildCardID, s_wildCardID)))
51  return true;
52  else if (isDeadChannel(getInttKey(layer,
53  ladder_phi, s_wildCardID,
54  s_wildCardID, s_wildCardID)))
55  return true;
56  else if (isDeadChannel(getInttKey(layer,
57  s_wildCardID, s_wildCardID,
58  s_wildCardID, s_wildCardID)))
59  return true;
60  else
61  return false;
62 }
63 
65 {
66  return size() > 0;
67 }
68 
69 void InttDeadMap::identify(std::ostream& os) const
70 {
71  os << "InttDeadMap base class" << std::endl;
72 }
73 
75  int ladder_phi, int ladder_z,
76  int strip_z, int strip_phi)
77 {
78  static const int layer_bit = 8;
79  static const int ladder_phi_bit = 16;
80  static const int ladder_z_bit = 8;
81  static const int strip_z_bit = 16;
82  static const int strip_phi_bit = 16;
83 
84  bool wildcard = false;
85 
86  if (layer == s_wildCardID) wildcard = true;
87  if (wildcard) layer = (1 << layer_bit) - 1;
88 
89  if (ladder_phi == s_wildCardID) wildcard = true;
90  if (wildcard) ladder_phi = (1 << ladder_phi_bit) - 1;
91 
92  if (ladder_z == s_wildCardID) wildcard = true;
93  if (wildcard) ladder_z = (1 << ladder_z_bit) - 1;
94 
95  if (strip_z == s_wildCardID) wildcard = true;
96  if (wildcard) strip_z = (1 << strip_z_bit) - 1;
97 
98  if (strip_phi == s_wildCardID) wildcard = true;
99  if (wildcard) strip_phi = (1 << strip_phi_bit) - 1;
100 
101  // bit sum check
102  assert(layer_bit + ladder_phi_bit + ladder_z_bit + strip_z_bit + strip_phi_bit == numeric_limits<PHG4CellDefs::keytype>::digits);
103 
104  //max range check
105  assert(layer < (1 << layer_bit));
106  assert(ladder_phi < (1 << ladder_phi_bit));
107  assert(ladder_z < (1 << ladder_z_bit));
108  assert(strip_z < (1 << strip_z_bit));
109  assert(strip_phi < (1 << strip_phi_bit));
110 
111  //min range check
112  assert(layer >= 0);
113  assert(ladder_phi >= 0);
114  assert(ladder_z >= 0);
115  assert(strip_z >= 0);
116  assert(strip_phi >= 0);
117 
118  PHG4CellDefs::keytype key = 0;
119 
120  key += layer;
121 
122  key <<= ladder_phi_bit;
123  key += ladder_phi;
124 
125  key <<= ladder_z_bit;
126  key += ladder_z;
127 
128  key <<= strip_z_bit;
129  key += strip_z;
130 
131  key <<= strip_phi_bit;
132  key += strip_phi;
133 
134  return key;
135 }