CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CoordinateAxis.cc
Go to the documentation of this file.
1 
3 
4 namespace hcaldqm
5 {
6  namespace axis
7  {
9  Axis(), _ctype(fSubDet)
10  {}
11 
13  int n, double min, double max, std::string title, bool log):
14  Axis(title, type, fCoordinate, n, min, max, log), _ctype(ctype)
15  {
16  this->_setup();
17  }
18 
20  bool log):
21  Axis(ctitle[ctype], type, fCoordinate, cnbins[ctype],
22  cmin[ctype], cmax[ctype], log), _ctype(ctype)
23  {
24  this->_setup();
25  }
26 
27  /* virtual */ int CoordinateAxis::get(HcalDetId const& did)
28  {
29  int x;
30  switch(_ctype)
31  {
32  case fSubDet:
33  x = did.subdet();
34  break;
35  case fSubDetPM:
36  x = did.ieta()<0 ? 2*(did.subdet()-1) :
37  2*(did.subdet()-1)+1;
38  break;
39  case fiphi:
40  x = did.iphi();
41  break;
42  case fieta:
43  x = did.ieta();
44  if (x<0)
45  x = did.subdet()==HcalForward ? x+41 : x+42;
46  else
47  x = did.subdet()==HcalForward ? x+42 : x+41;
48  break;
49  case fdepth:
50  x = did.depth();
51  break;
52  default:
53  x = -100;
54  break;
55  }
56  return x;
57  }
58 
59  /* virtual */ int CoordinateAxis::get(HcalTrigTowerDetId const& tid)
60  {
61  int x;
62  switch(_ctype)
63  {
64  case fiphi:
65  x = tid.iphi();
66  break;
67  case fTPieta:
68  x = tid.ieta()<0 ? tid.ieta()+32 : tid.ieta()+31;
69  break;
70  case fTPSubDet:
71  x = tid.ietaAbs()<29 ? 0 : 1;
72  break;
73  case fTPSubDetPM:
74  {
75  int ieta = tid.ieta();
76  if (ieta<0 && ieta>-29)
77  x = 0;
78  else if (ieta>0 && ieta<29)
79  x = 1;
80  else if (ieta<0 && ieta<=-29)
81  x = 2;
82  else
83  x = 3;
84  break;
85  }
86  default:
87  x = -100;
88  break;
89  }
90  return x;
91  }
92 
93  /* virtual */ int CoordinateAxis::get(HcalElectronicsId const& eid)
94  {
95  int x;
96  switch(_ctype)
97  {
98  case fCrateVME:
99  x = eid.crateId();
100  if (x<=CRATE_VME_MAX)
101  x = x-CRATE_VME_MIN;
102  else
103  x = 100;
104  break;
105  case fCrateuTCA:
106  x = eid.crateId();
107  if (x>CRATE_VME_MAX && x<=CRATE_uTCA_MAX)
108  x = x-CRATE_uTCA_MIN;
109  else
110  x = 100;
111  break;
112  case fCrateComb:
113  x = eid.crateId();
114  if (x<=CRATE_VME_MAX)
115  x = x-CRATE_VME_MIN;
116  else if (x<=CRATE_uTCA_MAX)
118  else
119  x = 100;
120  break;
121  case fSlotVME:
122  x = eid.slot();
123  if (x<=SLOT_VME_MIN1)
124  x = x-SLOT_VME_MIN;
125  else if (x>=SLOT_VME_MIN2 && x<=SLOT_VME_MAX)
127  else
128  x = 100;
129  break;
130  case fSlotuTCA:
131  x = eid.slot();
132  if (x<=SLOT_uTCA_MAX)
133  x = x-SLOT_uTCA_MIN;
134  else
135  x = 100;
136  break;
137  case fSlotComb:
138  x = eid.slot();
139  if (eid.isVMEid()) // VME
140  {
141  if (x<=SLOT_VME_MIN1)
142  x = x-SLOT_VME_MIN;
143  else if (x>=SLOT_VME_MIN2 && x<=SLOT_VME_MAX)
145  else x = 100;
146  }
147  else // uTCA
148  {
149  if (x<=SLOT_uTCA_MAX)
150  x = x-SLOT_uTCA_MIN;
151  else
152  x = 100;
153  }
154  break;
155  case fSpigot:
156  x = eid.spigot();
157  break;
158  case fFiberVME:
159  {
160  x = eid.fiberIndex();
161  int tb = eid.htrTopBottom(); //1 for t
162  x = tb*FIBER_VME_NUM + (x-FIBER_VME_MIN);
163  }
164  break;
165  case fFiberuTCA:
166  x = eid.fiberIndex()-FIBER_uTCA_MIN;
167  break;
168  case fFiberComb:
169  x = eid.fiberIndex();
170  if (eid.isVMEid())
171  {
172  int tb = eid.htrTopBottom();
173  x = tb*FIBER_VME_NUM+(x-FIBER_VME_MIN);
174  }
175  else
176  x = x-FIBER_uTCA_MIN;
177  break;
178  case fFiberCh:
179  x = eid.fiberChanId();
180  break;
181  default :
182  x = -100;
183  break;
184  }
185  return x;
186  }
187 
188  /* virtual */ int CoordinateAxis::get(int i)
189  {
190  int x = 0;
191  switch(_ctype)
192  {
193  case fFEDVME:
194  x = i-FED_VME_MIN;
195  break;
196  case fFEDuTCA:
198  break;
199  case fFEDComb:
200  if (i<=FED_VME_MAX)
201  x = i-FED_VME_MIN;
202  else
204  break;
205  case fCrateVME:
206  x = i-CRATE_VME_MIN;
207  break;
208  case fCrateuTCA:
209  x = i-CRATE_uTCA_MIN;
210  break;
211  case fCrateComb:
212  if (i<CRATE_VME_MAX)
213  x = i-CRATE_VME_MIN;
214  else
216  break;
217  default :
218  break;
219  }
220  return x;
221  }
222 
223  /* virtual */ int CoordinateAxis::getBin(HcalDetId const&)
224  {
225  return 1;
226  }
227 
228  /* virtual */ int CoordinateAxis::getBin(HcalElectronicsId const&)
229  {
230  return 1;
231  }
232 
233  /* virtual */ int CoordinateAxis::getBin(HcalTrigTowerDetId const&)
234  {
235  return 1;
236  }
237 
238  /* virtual */ int CoordinateAxis::getBin(int value)
239  {
240  int r = 1;
241  switch (_ctype)
242  {
243  case fSubDet:
244  r = value+1;
245  break;
246  case fTPSubDet:
247  r = value+1;
248  break;
249  case fiphi:
250  r = value;
251  break;
252  case fFEDComb:
253  r = 1+value;
254  break;
255  default:
256  r = 1;
257  break;
258  }
259 
260  return r;
261  }
262 
263  /* virtual */ void CoordinateAxis::_setup()
264  {
265  char name[20];
266  switch (_ctype)
267  {
268  case fSubDet:
269  for (int i=HB; i<=HF; i++)
270  _labels.push_back(SUBDET_NAME[i-1]);
271  break;
272  case fSubDetPM:
273  for (int i=0; i<2*SUBDET_NUM; i++)
274  _labels.push_back(SUBDETPM_NAME[i]);
275  break;
276  case fTPSubDetPM:
277  for (int i=0; i<2*TPSUBDET_NUM; i++)
278  _labels.push_back(TPSUBDETPM_NAME[i]);
279  break;
280  case fieta:
281  for (int ieta=-41; ieta<=41; ieta++)
282  {
283  if (ieta==0)
284  continue;
285  sprintf(name, "%d", ieta);
286  if (ieta==-29 || ieta==29)
287  _labels.push_back(std::string(name));
288  _labels.push_back(std::string(name));
289  }
290  break;
291  case fFEDVME:
292  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
293  {
294  sprintf(name, "%d", i);
295  _labels.push_back(std::string(name));
296  }
297  break;
298  case fFEDuTCA:
299  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i+=2)
300  {
301  sprintf(name, "%d", i);
302  _labels.push_back(std::string(name));
303  }
304  break;
305  case fFEDComb: // uTCA and VME combined
306  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
307  {
308  sprintf(name, "%d", i);
309  _labels.push_back(std::string(name));
310  }
311  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i+=2)
312  {
313  sprintf(name, "%d", i);
314  _labels.push_back(std::string(name));
315  }
316  break;
317  case fCrateVME:
318  for (int i=CRATE_VME_MIN; i<=CRATE_VME_MAX; i++)
319  {
320  sprintf(name, "%d", i);
321  _labels.push_back(std::string(name));
322  }
323  break;
324  case fCrateuTCA:
325  for (int i=CRATE_uTCA_MIN; i<=CRATE_uTCA_MAX; i++)
326  {
327  sprintf(name, "%d", i);
328  _labels.push_back(std::string(name));
329  }
330  break;
331  case fCrateComb:
332  for (int i=CRATE_VME_MIN; i<=CRATE_VME_MAX; i++)
333  {
334  sprintf(name, "%d", i);
335  _labels.push_back(std::string(name));
336  }
337  for (int i=CRATE_uTCA_MIN; i<=CRATE_uTCA_MAX; i++)
338  {
339  sprintf(name, "%d", i);
340  _labels.push_back(std::string(name));
341  }
342  break;
343  case fSlotVME:
344  for (int i=SLOT_VME_MIN; i<=SLOT_VME_MIN1; i++)
345  {
346  sprintf(name, "%d", i);
347  _labels.push_back(std::string(name));
348  }
349  for (int i=SLOT_VME_MIN2; i<=SLOT_VME_MAX; i++)
350  {
351  sprintf(name, "%d", i);
352  _labels.push_back(std::string(name));
353  }
354  break;
355  case fSlotuTCA:
356  for (int i=SLOT_uTCA_MIN; i<=SLOT_uTCA_MAX; i++)
357  {
358  sprintf(name, "%d", i);
359  _labels.push_back(std::string(name));
360  }
361  break;
362  case fSlotComb:
363  {
364  int j = SLOT_uTCA_MIN;
365  for (int i=SLOT_VME_MIN; i<=SLOT_VME_MIN1; i++)
366  {
367  sprintf(name, "%d (%d)", i, j);
368  _labels.push_back(std::string(name));
369  j++;
370  }
371  for (int i=SLOT_VME_MIN2; i<=SLOT_VME_MAX; i++)
372  {
373  sprintf(name, "%d (%d)", i, j);
374  _labels.push_back(std::string(name));
375  j++;
376  }
377  }
378  break;
379  case fFiberVME:
380  for (int i=FIBER_VME_MIN; i<=FIBER_VME_MAX; i++)
381  {
382  sprintf(name, "%d-b", i);
383  _labels.push_back(std::string(name));
384  }
385  for (int i=FIBER_VME_MIN; i<=FIBER_VME_MAX; i++)
386  {
387  sprintf(name, "%d-t", i);
388  _labels.push_back(std::string(name));
389  }
390  break;
391  case fFiberuTCA:
392  for (int i=FIBER_uTCA_MIN; i<=FIBER_uTCA_MAX; i++)
393  {
394  sprintf(name, "%d", i);
395  _labels.push_back(std::string(name));
396  }
397  break;
398  case fFiberComb:
399  {
400  int j = FIBER_uTCA_MIN;
401  for (int i=FIBER_VME_MIN; i<=FIBER_VME_MAX; i++)
402  {
403  sprintf(name, "%d-b (%d)", i, j);
404  _labels.push_back(std::string(name));
405  j++;
406  }
407  for (int i=FIBER_VME_MIN; i<=FIBER_VME_MAX; i++)
408  {
409  sprintf(name, "%d-t (%d)", i, j);
410  _labels.push_back(std::string(name));
411  j++;
412  }
413  for (int k=j; k<+FIBER_uTCA_MAX; k++)
414  {
415  sprintf(name, "%d", k);
416  _labels.push_back(std::string(name));
417  }
418  }
419  break;
420  case fTPSubDet:
421  _labels.push_back(std::string("HBHE"));
422  _labels.push_back(std::string("HF"));
423  break;
424  case fTPieta:
425  for (int ieta=-32; ieta<=32; ieta++)
426  {
427  if (ieta==0)
428  continue;
429  sprintf(name, "%d", ieta);
430  _labels.push_back(std::string(name));
431  }
432  default:
433  break;
434  }
435  }
436  }
437 }
438 
439 
440 
441 
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
int const CRATE_VME_MIN
Definition: Constants.h:38
int const SUBDET_NUM
Definition: Constants.h:87
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
std::string const TPSUBDETPM_NAME[2 *TPSUBDET_NUM]
Definition: Constants.h:94
virtual int get(HcalDetId const &)
double const cmin[nCoordinateType]
int const CRATE_uTCA_MAX
Definition: Constants.h:44
int const SLOT_VME_MAX
Definition: Constants.h:57
int const FIBER_VME_MAX
Definition: Constants.h:68
int const FIBER_uTCA_MIN
Definition: Constants.h:70
int const FIBER_VME_MIN
Definition: Constants.h:67
int ieta() const
get the tower ieta
int crateId() const
get the readout VME crate number
int const FED_uTCA_MIN
Definition: Constants.h:31
int const SLOT_VME_MIN1
Definition: Constants.h:55
int const SLOT_VME_MIN2
Definition: Constants.h:56
int const HF
Definition: Constants.h:86
T x() const
Cartesian x coordinate.
int const FED_uTCA_MAX
Definition: Constants.h:32
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
std::string const SUBDET_NAME[SUBDET_NUM]
Definition: Constants.h:89
std::string const ctitle[nCoordinateType]
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
int const FED_VME_MIN
Definition: Constants.h:26
virtual int getBin(HcalDetId const &)
int const FED_uTCA_DELTA
Definition: Constants.h:34
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
std::string const SUBDETPM_NAME[2 *SUBDET_NUM]
Definition: Constants.h:90
int j
Definition: DBlmapReader.cc:9
int const cnbins[nCoordinateType]
int const SLOT_VME_MIN
Definition: Constants.h:54
T min(T a, T b)
Definition: MathUtil.h:58
double const cmax[nCoordinateType]
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
int const FIBER_VME_NUM
Definition: Constants.h:69
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
std::vector< std::string > _labels
Definition: Axis.h:109
int const CRATE_uTCA_MIN
Definition: Constants.h:43
int const SLOT_VME_NUM1
Definition: Constants.h:58
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
bool isVMEid() const
int slot() const
get the htr or uHTR slot
int const FED_VME_NUM
Definition: Constants.h:29
int const CRATE_VME_NUM
Definition: Constants.h:41
int const SLOT_uTCA_MAX
Definition: Constants.h:50
int const TPSUBDET_NUM
Definition: Constants.h:88
int const FIBER_uTCA_MAX
Definition: Constants.h:71
int const FED_VME_MAX
Definition: Constants.h:27
Readout chain identification for Hcal.
int const CRATE_VME_MAX
Definition: Constants.h:39
int ietaAbs() const
get the absolute value of the tower ieta
int iphi() const
get the tower iphi
int const SLOT_uTCA_MIN
Definition: Constants.h:49