test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZdcTopology.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <iostream>
4 #include <algorithm>
5 
6 static const int ICH_EM_MAX = 5;
7 static const int ICH_HAD_MAX = 4;
8 static const int ICH_LUM_MAX = 2;
9 
11  excludeEM_(false),
12  excludeHAD_(false),
13  excludeLUM_(false),
14  excludeZP_(false),
15  excludeZN_(false),
16  firstEMModule_(1),
17  lastEMModule_(5),
18  firstHADModule_(1),
19  lastHADModule_(4),
20  firstLUMModule_(1),
21  lastLUMModule_(2)
22 {
23 }
24 
25 bool ZdcTopology::valid(const HcalZDCDetId& id) const {
26  // check the raw rules
27  bool ok=validRaw(id);
28  ok=ok && !isExcluded(id);
29  return ok;
30 }
31 
32 bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const {
33  bool exed=false;
34 
35  // check for section exclutions
36  switch (id.section()) {
37  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
38  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
39  case(HcalZDCDetId::LUM) : exed = excludeLUM_; break;
40  default: exed = false;
41  }
42 
43  // check the entire list
44  if (!exed && !exclusionList_.empty()) {
45  std::vector<HcalZDCDetId>::const_iterator
46  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
47  if (i!=exclusionList_.end() && *i==id) exed=true;
48  }
49  return exed;
50 }
51 
53  std::vector<HcalZDCDetId>::iterator
54  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
55  if (i==exclusionList_.end() || *i!=id) {
56  exclusionList_.insert(i,id);
57  }
58 }
59 
61  switch(zside){
62  case( 1): excludeZP_ = true; break;
63  case(-1): excludeZN_ = true; break;
64  default: break;
65  }
66 }
67 
69  switch(zside){
70  case( 1): excludeZP_ = true; break;
71  case(-1): excludeZN_ = true; break;
72  default: break;
73  }
74  switch (section) {
75  case(HcalZDCDetId::EM) : excludeEM_ = true; break;
76  case(HcalZDCDetId::HAD) : excludeHAD_ = true; break;
77  case(HcalZDCDetId::LUM) : excludeLUM_ = true; break;
78  default: break;
79  }
80 }
81 
82 int ZdcTopology::exclude(int zside, HcalZDCDetId::Section section, int ich1, int ich2) {
83  bool exed = false;
84  switch(zside){
85  case( 1): exed = excludeZP_; break;
86  case(-1): exed = excludeZN_; break;
87  default: exed = false;
88  }
89  if (exed) return 0;
90 
91  switch (section) {
92  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
93  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
94  case(HcalZDCDetId::LUM) : exed = excludeLUM_; break;
95  default: exed = false;
96  }
97  if (exed) return 0;
98 
99  bool isPositive = false;
100  if(zside == 1)isPositive = true;
101 
102  int n = 0;
103  for (int ich = ich1; ich < ich2; ich++){
104  HcalZDCDetId id(section, isPositive, ich);
105  if(validRaw(id))exclude(id);
106  n++;
107  }
108  return n;
109 }
110 
111 bool ZdcTopology::validRaw(const HcalZDCDetId& id) const{
112  bool ok = true;
113  if(abs(id.zside())!=1)return false;
114  if(id.channel() <= 0)return false;
115  if(!(id.section()== HcalZDCDetId::EM ||
116  id.section()== HcalZDCDetId::HAD ||
117  id.section()== HcalZDCDetId::LUM)) return false;
118  if(id.section()== HcalZDCDetId::EM && id.channel() > ICH_EM_MAX)
119  return false;
120  if(id.section()== HcalZDCDetId::HAD && id.channel() > ICH_HAD_MAX)
121  return false;
122  if(id.section()== HcalZDCDetId::LUM && id.channel() > ICH_LUM_MAX)
123  return false;
124  return ok;
125 }
126 
127 std::vector<DetId> ZdcTopology::transverse(const DetId& id) const{
128  std::vector<DetId> vNeighborsDetId;
129  HcalZDCDetId zdcId = HcalZDCDetId(id);
130  HcalZDCDetId zdcDetId;
131  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::EM){
132  bool isPositive = false;
133  if(zdcId.zside()==1)isPositive = true;
134  if(zdcId.channel()==1){
135  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
136  vNeighborsDetId.push_back(zdcDetId.rawId());
137  return vNeighborsDetId;
138  }
139  if(zdcId.channel()== ICH_EM_MAX){
140  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
141  vNeighborsDetId.push_back(zdcDetId.rawId());
142  return vNeighborsDetId;
143  }
144  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
145  vNeighborsDetId.push_back(zdcDetId.rawId());
146  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
147  vNeighborsDetId.push_back(zdcDetId.rawId());
148  }
149  return vNeighborsDetId;
150 }
151 
152 std::vector<DetId> ZdcTopology::longitudinal(const DetId& id) const{
153  std::vector<DetId> vNeighborsDetId;
154  HcalZDCDetId zdcId = HcalZDCDetId(id);
155  HcalZDCDetId zdcDetId;
156  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::HAD){
157  bool isPositive = false;
158  if(zdcId.zside()==1)isPositive = true;
159  if(zdcId.channel()==1){
160  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
161  vNeighborsDetId.push_back(zdcDetId.rawId());
162  return vNeighborsDetId;
163  }
164  if(zdcId.channel()== ICH_HAD_MAX){
165  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
166  vNeighborsDetId.push_back(zdcDetId.rawId());
167  return vNeighborsDetId;
168  }
169  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
170  vNeighborsDetId.push_back(zdcDetId.rawId());
171  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
172  vNeighborsDetId.push_back(zdcDetId.rawId());
173  }
174  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::LUM){
175  bool isPositive = false;
176  if(zdcId.zside()==1)isPositive = true;
177  if(zdcId.channel()==1){
178  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
179  vNeighborsDetId.push_back(zdcDetId.rawId());
180  return vNeighborsDetId;
181  }
182  if(zdcId.channel()== ICH_LUM_MAX){
183  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
184  vNeighborsDetId.push_back(zdcDetId.rawId());
185  return vNeighborsDetId;
186  }
187  }
188  return vNeighborsDetId;
189 }
190 
191 std::vector<DetId> ZdcTopology::east(const DetId& /*id*/) const
192 {
193  std::cout << "ZdcTopology::east() not yet implemented" << std::endl;
194  std::vector<DetId> vNeighborsDetId;
195  return vNeighborsDetId;
196 }
197 
198 std::vector<DetId> ZdcTopology::west(const DetId& /*id*/) const
199 {
200  std::cout << "ZdcTopology::west() not yet implemented" << std::endl;
201  std::vector<DetId> vNeighborsDetId;
202  return vNeighborsDetId;
203 }
204 
205 std::vector<DetId> ZdcTopology::north(const DetId& /*id*/) const
206 {
207  std::cout << "ZdcTopology::north() not yet implemented" << std::endl;
208  std::vector<DetId> vNeighborsDetId;
209  return vNeighborsDetId;
210 }
211 std::vector<DetId> ZdcTopology::south(const DetId& /*id*/) const
212 {
213  std::cout << "ZdcTopology::south() not yet implemented" << std::endl;
214  std::vector<DetId> vNeighborsDetId;
215  return vNeighborsDetId;
216 }
217 std::vector<DetId> ZdcTopology::up(const DetId& /*id*/) const
218 {
219  std::cout << "ZdcTopology::up() not yet implemented" << std::endl;
220  std::vector<DetId> vNeighborsDetId;
221  return vNeighborsDetId;
222 }
223 std::vector<DetId> ZdcTopology::down(const DetId& /*id*/) const
224 {
225  std::cout << "ZdcTopology::down() not yet implemented" << std::endl;
226  std::vector<DetId> vNeighborsDetId;
227  return vNeighborsDetId;
228 }
229 
231  int ncells = 0;
232  switch (section) {
233  case(HcalZDCDetId::EM) : ncells = ICH_EM_MAX; break;
234  case(HcalZDCDetId::HAD) : ncells = ICH_HAD_MAX; break;
235  case(HcalZDCDetId::LUM) : ncells = ICH_LUM_MAX; break;
236  case(HcalZDCDetId::Unknown) : ncells =0; break;
237  }
238  return ncells;
239 }
240 
242  int firstCell = 0;
243  switch (section) {
244  case(HcalZDCDetId::EM) : firstCell = firstEMModule_ ; break;
245  case(HcalZDCDetId::HAD) : firstCell = firstHADModule_; break;
246  case(HcalZDCDetId::LUM) : firstCell = firstLUMModule_; break;
247  case(HcalZDCDetId::Unknown) : firstCell = 0; break;
248  }
249  return firstCell;
250 }
251 
253  int lastCell = 0;
254  switch (section) {
255  case(HcalZDCDetId::EM) : lastCell = lastEMModule_; break;
256  case(HcalZDCDetId::HAD) : lastCell = lastHADModule_; break;
257  case(HcalZDCDetId::LUM) : lastCell = lastLUMModule_; break;
258  case(HcalZDCDetId::Unknown) : lastCell = 0; break;
259  }
260  return lastCell;
261 }
262 
263 
264 
265 
266 
int firstEMModule_
Definition: ZdcTopology.h:60
static const int ICH_LUM_MAX
Definition: ZdcTopology.cc:8
static const int ICH_EM_MAX
Definition: ZdcTopology.cc:6
int i
Definition: DBlmapReader.cc:9
bool excludeEM_
Definition: ZdcTopology.h:58
void exclude(const HcalZDCDetId &id)
Definition: ZdcTopology.cc:52
virtual std::vector< DetId > transverse(const DetId &id) const
Definition: ZdcTopology.cc:127
int lastLUMModule_
Definition: ZdcTopology.h:60
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:34
bool excludeHAD_
Definition: ZdcTopology.h:58
virtual std::vector< DetId > down(const DetId &id) const
Definition: ZdcTopology.cc:223
int zside(DetId const &)
bool validRaw(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:111
virtual std::vector< DetId > up(const DetId &id) const
Definition: ZdcTopology.cc:217
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual std::vector< DetId > south(const DetId &id) const
Definition: ZdcTopology.cc:211
virtual std::vector< DetId > west(const DetId &id) const
Definition: ZdcTopology.cc:198
virtual bool valid(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:25
int lastCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:252
bool excludeZN_
Definition: ZdcTopology.h:58
virtual std::vector< DetId > north(const DetId &id) const
Definition: ZdcTopology.cc:205
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
int firstHADModule_
Definition: ZdcTopology.h:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< HcalZDCDetId > exclusionList_
Definition: ZdcTopology.h:56
bool excludeLUM_
Definition: ZdcTopology.h:58
Section section() const
get the section
Definition: HcalZDCDetId.h:36
Definition: DetId.h:18
int channel() const
get the channel
Definition: HcalZDCDetId.h:40
bool isExcluded(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:32
bool excludeZP_
Definition: ZdcTopology.h:58
int firstCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:241
int lastEMModule_
Definition: ZdcTopology.h:60
tuple cout
Definition: gather_cfg.py:121
int firstLUMModule_
Definition: ZdcTopology.h:60
virtual std::vector< DetId > east(const DetId &id) const
Definition: ZdcTopology.cc:191
volatile std::atomic< bool > shutdown_flag false
static const int ICH_HAD_MAX
Definition: ZdcTopology.cc:7
virtual std::vector< DetId > longitudinal(const DetId &id) const
Definition: ZdcTopology.cc:152
int lastHADModule_
Definition: ZdcTopology.h:60