CMS 3D CMS Logo

MESetBinningUtils.cc
Go to the documentation of this file.
2 
4 
8 
9 #include "TPRegexp.h"
10 
11 namespace ecaldqm {
12  namespace binning {
13  AxisSpecs getBinning(ObjectType _otype, BinningType _btype, bool _isMap, int _axis, unsigned _iME) {
14  if (_otype >= nObjType || _btype >= unsigned(nPresetBinnings))
15  return AxisSpecs(); // you are on your own
16 
17  switch (_otype) {
18  case kEB:
19  return getBinningEB_(_btype, _isMap, _axis);
20  case kEE:
21  return getBinningEE_(_btype, _isMap, 0, _axis);
22  case kEEm:
23  return getBinningEE_(_btype, _isMap, -1, _axis);
24  case kEEp:
25  return getBinningEE_(_btype, _isMap, 1, _axis);
26  case kSM:
27  return getBinningSM_(_btype, _isMap, _iME, _axis);
28  case kEBSM:
29  return getBinningSM_(_btype, _isMap, _iME + 9, _axis);
30  case kEESM:
31  if (_iME <= kEEmHigh)
32  return getBinningSM_(_btype, _isMap, _iME, _axis);
33  else
34  return getBinningSM_(_btype, _isMap, _iME + nEBDCC, _axis);
35  case kSMMEM:
36  return getBinningSMMEM_(_btype, _isMap, _iME, _axis);
37  case kEBSMMEM:
38  return getBinningSMMEM_(_btype, _isMap, _iME + nEEDCCMEM / 2, _axis);
39  case kEESMMEM:
40  if (_iME <= kEEmHigh)
41  return getBinningSMMEM_(_btype, _isMap, _iME, _axis);
42  else
43  return getBinningSMMEM_(_btype, _isMap, _iME + nEBDCC, _axis);
44  case kEcal:
45  return getBinningEcal_(_btype, _isMap, _axis);
46  case kMEM:
47  return getBinningMEM_(_btype, _isMap, -1, _axis);
48  case kEBMEM:
49  return getBinningMEM_(_btype, _isMap, EcalBarrel, _axis);
50  case kEEMEM:
51  return getBinningMEM_(_btype, _isMap, EcalEndcap, _axis);
52  default:
53  return AxisSpecs();
54  }
55  }
56 
57  int findBin1D(ObjectType _otype, BinningType _btype, const DetId &_id) {
58  switch (_otype) {
59  case kSM:
60  case kEBSM:
61  case kEESM:
62  if (_btype == kSuperCrystal)
63  return towerId(_id);
64  else if (_btype == kTriggerTower) {
65  unsigned tccid(tccId(_id));
66  if (tccid <= 36 || tccid >= 73) { // EE
67  unsigned bin(ttId(_id));
68  bool outer((tccid >= 19 && tccid <= 36) || (tccid >= 73 && tccid <= 90));
69  // For the following, the constants nTTInner and nTTOuter are defined in
70  // EcalDQMCommonUtils.h.
71  if (outer)
72  bin += 2 * nTTInner; // For outer TCCs, sets bin number to increment
73  // by twice the number of TTs in inner TCCs, because numbering of bins
74  // is in the order (inner1, inner2, outer1, outer2).
75  // ("inner"" := closer to the beam)
76  bin += (tccid % 2) * (outer ? nTTOuter : nTTInner); // Yields x-axis bin number
77  // in the format above; TTs in even-numbered TCCs are filled in inner1
78  // or outer1, and those in odd-numbered TCC are filled in inner2 and
79  // outer2.
80  return bin;
81  } else
82  return ttId(_id);
83  } else
84  break;
85  case kEcal:
86  if (_btype == kDCC)
87  return dccId(_id);
88  else if (_btype == kTCC)
89  return tccId(_id);
90  else
91  break;
92  case kEB:
93  if (_btype == kDCC)
94  return dccId(_id) - 9;
95  else if (_btype == kTCC)
96  return tccId(_id) - 36;
97  else
98  break;
99  case kEEm:
100  if (_btype == kDCC)
101  return dccId(_id);
102  else if (_btype == kTCC)
103  return tccId(_id);
104  else
105  break;
106  case kEEp:
107  if (_btype == kDCC)
108  return dccId(_id) - 45;
109  else if (_btype == kTCC)
110  return tccId(_id) - 72;
111  else
112  break;
113  case kEE:
114  if (_btype == kDCC) {
115  int bin(dccId(_id));
116  if (bin >= 46)
117  bin -= 36;
118  return bin;
119  } else if (_btype == kTCC) {
120  int bin(tccId(_id));
121  if (bin >= 72)
122  bin -= 36;
123  return bin;
124  } else
125  break;
126  case kSMMEM:
127  case kEBSMMEM:
128  case kEESMMEM:
129  if (_btype == kCrystal)
130  return EcalPnDiodeDetId(_id).iPnId();
131  else
132  break;
133  default:
134  break;
135  }
136 
137  return 0;
138  }
139 
140  int findBin1D(ObjectType _otype, BinningType _btype, const EcalElectronicsId &_id) {
141  switch (_otype) {
142  case kSM:
143  case kEBSM:
144  case kEESM:
145  if (_btype == kSuperCrystal)
146  return towerId(_id);
147  else if (_btype == kTriggerTower) {
148  unsigned tccid(tccId(_id));
149  if (tccid <= 36 || tccid >= 73) { // EE
150  unsigned bin(ttId(_id));
151  bool outer((tccid >= 19 && tccid <= 36) || (tccid >= 73 && tccid <= 90));
152  // For the following, the constants nTTInner and nTTOuter are defined in
153  // EcalDQMCommonUtils.h.
154  if (outer)
155  bin += 2 * nTTInner; // For outer TCCs, sets bin number to increment
156  // by twice the number of TTs in inner TCCs, because numbering of bins
157  // is in the order (inner1, inner2, outer1, outer2).
158  // ("inner"" := closer to the beam)
159  bin += (tccid % 2) * (outer ? nTTOuter : nTTInner); // Yields x-axis bin number
160  // in the format above; TTs in even-numbered TCCs are filled in inner1
161  // or outer1, and those in odd-numbered TCC are filled in inner2 and
162  // outer2.
163  return bin;
164  } else
165  return ttId(_id);
166  } else
167  break;
168  case kEcal:
169  if (_btype == kDCC)
170  return dccId(_id);
171  else if (_btype == kTCC)
172  return tccId(_id);
173  else
174  break;
175  case kEB:
176  if (_btype == kDCC)
177  return dccId(_id) - 9;
178  else if (_btype == kTCC)
179  return tccId(_id) - 36;
180  else
181  break;
182  case kEEm:
183  if (_btype == kDCC)
184  return dccId(_id);
185  else if (_btype == kTCC)
186  return tccId(_id);
187  else
188  break;
189  case kEEp:
190  if (_btype == kDCC)
191  return dccId(_id) - 45;
192  else if (_btype == kTCC)
193  return tccId(_id) - 72;
194  else
195  break;
196  case kEE:
197  if (_btype == kDCC) {
198  int bin(dccId(_id));
199  if (bin >= 46)
200  bin -= 36;
201  return bin;
202  } else if (_btype == kTCC) {
203  int bin(tccId(_id));
204  if (bin >= 72)
205  bin -= 36;
206  return bin;
207  } else
208  break;
209  default:
210  break;
211  }
212 
213  return 0;
214  }
215 
216  int findBin1D(ObjectType _otype, BinningType _btype, int _dcctccid) {
217  if (_otype == kEcal && _btype == kDCC)
218  return _dcctccid;
219  else if (_otype == kEcal && _btype == kTCC)
220  return _dcctccid;
221  if (_otype == kEB && _btype == kDCC)
222  return _dcctccid - 9;
223  else if (_otype == kEB && _btype == kTCC)
224  return _dcctccid - 36;
225  else if (_otype == kEEm && _btype == kDCC)
226  return _dcctccid;
227  else if (_otype == kEEm && _btype == kTCC)
228  return _dcctccid;
229  else if (_otype == kEEp && _btype == kDCC)
230  return _dcctccid - 45;
231  else if (_otype == kEEp && _btype == kTCC)
232  return _dcctccid - 72;
233  else if (_otype == kEE && _btype == kDCC)
234  return _dcctccid <= 9 ? _dcctccid : _dcctccid - 36;
235  else if (_otype == kEE && _btype == kTCC)
236  return _dcctccid <= 36 ? _dcctccid : _dcctccid - 36;
237 
238  return 0;
239  }
240 
241  int findBin2D(ObjectType _otype, BinningType _btype, const DetId &_id) {
242  if (_otype >= nObjType || _btype >= unsigned(nPresetBinnings))
243  return 0;
244 
245  switch (_btype) {
246  case kCrystal:
247  return findBinCrystal_(_otype, _id);
248  break;
249  case kTriggerTower:
250  return findBinTriggerTower_(_otype, _id);
251  break;
252  case kSuperCrystal:
253  return findBinSuperCrystal_(_otype, _id);
254  break;
255  case kPseudoStrip:
256  return findBinPseudoStrip_(_otype, _id);
257  break;
258  case kRCT:
259  return findBinRCT_(_otype, _id);
260  break;
261  default:
262  return 0;
263  }
264  }
265 
266  int findBin2D(ObjectType _otype, BinningType _btype, const EcalElectronicsId &_id) {
267  if (_otype >= nObjType || _btype >= unsigned(nPresetBinnings))
268  return 0;
269 
270  switch (_btype) {
271  case kCrystal:
272  return findBinCrystal_(_otype, _id);
273  break;
274  case kSuperCrystal:
275  return findBinSuperCrystal_(_otype, _id);
276  break;
277  default:
278  return 0;
279  }
280  }
281 
282  int findBin2D(ObjectType _otype, BinningType _btype, int _dccid) {
283  if (_otype != kEcal || _btype != kDCC)
284  return 0;
285 
286  int nbinsX(9);
287  unsigned iDCC(_dccid - 1);
288  int xbin(0);
289  if (iDCC <= kEEmHigh || iDCC >= kEEpLow)
290  xbin = (iDCC + 6) % nbinsX + 1;
291  else
292  xbin = iDCC % nbinsX + 1;
293  int ybin(6 - iDCC / nbinsX);
294 
295  return (nbinsX + 2) * ybin + xbin;
296  }
297 
298  unsigned findPlotIndex(ObjectType _otype, const DetId &_id) {
299  if (getNObjects(_otype) == 1)
300  return 0;
301 
302  switch (_otype) {
303  case kEcal3P:
304  if (_id.subdetId() == EcalBarrel)
305  return 1;
306  else if (_id.subdetId() == EcalEndcap && zside(_id) > 0)
307  return 2;
308  else if (_id.subdetId() == EcalTriggerTower) {
309  if (!isEndcapTTId(_id))
310  return 1;
311  else {
312  if (zside(_id) > 0)
313  return 2;
314  else
315  return 0;
316  }
317  } else
318  return 0;
319 
320  case kEcal2P:
321  if (_id.subdetId() == EcalBarrel)
322  return 1;
323  else if (_id.subdetId() == EcalTriggerTower && !isEndcapTTId(_id))
324  return 1;
325  else
326  return 0;
327 
328  case kEE2P:
329  if (zside(_id) > 0)
330  return 1;
331  else
332  return 0;
333 
334  case kMEM2P:
335  if (_id.subdetId() == EcalLaserPnDiode) {
336  unsigned iDCC(dccId(_id) - 1);
337  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
338  return 1;
339  else
340  return 0;
341  } else
342  return -1;
343 
344  default:
345  return findPlotIndex(_otype, dccId(_id));
346  }
347  }
348 
349  unsigned findPlotIndex(ObjectType _otype, const EcalElectronicsId &_id) {
350  if (getNObjects(_otype) == 1)
351  return 0;
352 
353  return findPlotIndex(_otype, _id.dccId());
354  }
355 
356  unsigned findPlotIndex(ObjectType _otype, int _dcctccid, BinningType _btype /* = kDCC*/) {
357  if (getNObjects(_otype) == 1)
358  return 0;
359 
360  int iSM(_dcctccid - 1);
361 
362  switch (_otype) {
363  case kSM:
364  if (_btype == kPseudoStrip) {
365  iSM = iSM <= kEEmTCCHigh ? (iSM + 1) % 18 / 2
366  : iSM >= kEEpTCCLow ? (iSM + 1 - 72) % 18 / 2 + 45 : (iSM + 1) - kEEmTCCHigh;
367  return iSM;
368  } else
369  return iSM;
370 
371  case kEBSM:
372  return iSM - 9;
373 
374  case kEESM:
375  if (iSM <= kEEmHigh)
376  return iSM;
377  else
378  return iSM - nEBDCC;
379 
380  case kSMMEM:
381  return memDCCIndex(_dcctccid);
382 
383  case kEBSMMEM:
384  return memDCCIndex(_dcctccid) - nEEDCCMEM / 2;
385 
386  case kEESMMEM:
387  if (iSM <= kEEmHigh)
388  return memDCCIndex(_dcctccid);
389  else
390  return memDCCIndex(_dcctccid) - nEBDCC;
391 
392  case kEcal2P:
393  if (_btype == kDCC) {
394  if (iSM <= kEEmHigh || iSM >= kEEpLow)
395  return 0;
396  else
397  return 1;
398  } else if (_btype == kTCC) {
399  if (iSM <= kEEmTCCHigh || iSM >= kEEpTCCLow)
400  return 0;
401  else
402  return 1;
403  } else {
404  if (iSM == EcalBarrel - 1)
405  return 1;
406  else
407  return 0;
408  }
409 
410  case kEcal3P:
411  if (_btype == kDCC) {
412  if (iSM <= kEEmHigh)
413  return 0;
414  else if (iSM <= kEBpHigh)
415  return 1;
416  else
417  return 2;
418  } else if (_btype == kTCC) {
419  if (iSM <= kEEmTCCHigh)
420  return 0;
421  else if (iSM <= kEBTCCHigh)
422  return 1;
423  else
424  return 2;
425  } else {
426  if (iSM == -EcalEndcap - 1)
427  return 0;
428  else if (iSM == EcalBarrel - 1)
429  return 1;
430  else
431  return 2;
432  }
433 
434  case kEE2P:
435  if (_btype == kDCC) {
436  if (iSM >= kEEpLow)
437  return 1;
438  else
439  return 0;
440  } else {
441  if (iSM >= kEEpTCCLow)
442  return 1;
443  else
444  return 0;
445  }
446 
447  case kMEM2P:
448  if (_btype == kDCC) {
449  if (iSM <= kEEmHigh || iSM >= kEEpLow)
450  return 0;
451  else
452  return 1;
453  } else if (_btype == kTCC)
454  return -1;
455  else {
456  if (iSM == kEB)
457  return 1;
458  else
459  return 0;
460  }
461  default:
462  return -1;
463  }
464  }
465 
466  ObjectType getObject(ObjectType _otype, unsigned _iObj) {
467  switch (_otype) {
468  case kEcal3P:
469  switch (_iObj) {
470  case 0:
471  return kEEm;
472  case 1:
473  return kEB;
474  case 2:
475  return kEEp;
476  default:
477  return nObjType;
478  }
479  case kEcal2P:
480  switch (_iObj) {
481  case 0:
482  return kEE;
483  case 1:
484  return kEB;
485  default:
486  return nObjType;
487  }
488  case kEE2P:
489  switch (_iObj) {
490  case 0:
491  return kEEm;
492  case 1:
493  return kEEp;
494  default:
495  return nObjType;
496  }
497  case kMEM2P:
498  switch (_iObj) {
499  case 0:
500  return kEEMEM;
501  case 1:
502  return kEBMEM;
503  default:
504  return nObjType;
505  }
506  default:
507  return _otype;
508  }
509  }
510 
511  unsigned getNObjects(ObjectType _otype) {
512  switch (_otype) {
513  case kSM:
514  return nDCC;
515  case kEBSM:
516  return nEBDCC;
517  case kEESM:
518  return nEEDCC;
519  case kSMMEM:
520  return nDCCMEM;
521  case kEBSMMEM:
522  return nEBDCC;
523  case kEESMMEM:
524  return nEEDCCMEM;
525  case kEcal2P:
526  return 2;
527  case kEcal3P:
528  return 3;
529  case kEE2P:
530  return 2;
531  case kMEM2P:
532  return 2;
533  default:
534  return 1;
535  }
536  }
537 
538  bool isValidIdBin(ObjectType _otype, BinningType _btype, unsigned _iME, int _bin) {
539  if (_otype == kEEm || _otype == kEEp) {
540  if (_btype == kCrystal || _btype == kTriggerTower)
541  return EEDetId::validDetId(_bin % 102, _bin / 102, 1);
542  else if (_btype == kSuperCrystal)
543  return EcalScDetId::validDetId(_bin % 22, _bin / 22, 1);
544  } else if (_otype == kEE) {
545  if (_btype == kCrystal || _btype == kTriggerTower) {
546  int ix(_bin % 202);
547  if (ix > 100)
548  ix = (ix - 100) % 101;
549  return EEDetId::validDetId(ix, _bin / 202, 1);
550  } else if (_btype == kSuperCrystal) {
551  int ix(_bin % 42);
552  if (ix > 20)
553  ix = (ix - 20) % 21;
554  return EcalScDetId::validDetId(ix, _bin / 42, 1);
555  }
556  } else if (_otype == kSM || _otype == kEESM) {
557  unsigned iSM(_iME);
558  if (_otype == kEESM && iSM > kEEmHigh)
559  iSM += nEBDCC;
560 
561  if (iSM >= kEBmLow && iSM <= kEBpHigh)
562  return true;
563 
564  if (_btype == kCrystal || _btype == kTriggerTower) {
565  int nX(nEESMX);
566  if (iSM == kEEm02 || iSM == kEEm08 || iSM == kEEp02 || iSM == kEEp08)
567  nX = nEESMXExt;
568  if (iSM == kEEm01 || iSM == kEEm05 || iSM == kEEm09 || iSM == kEEp01 || iSM == kEEp05 || iSM == kEEp09)
569  nX = nEESMXRed;
570  int ix(_bin % (nX + 2) + xlow_(iSM));
571  int iy(_bin / (nX + 2) + ylow_(iSM));
572  int z(iSM <= kEEmHigh ? -1 : 1);
573  return EEDetId::validDetId(ix, iy, 1) && iSM == dccId(EEDetId(ix, iy, z)) - 1;
574  } else if (_btype == kSuperCrystal) {
575  int nX(nEESMX / 5);
576  if (iSM == kEEm02 || iSM == kEEm08 || iSM == kEEp02 || iSM == kEEp08)
577  nX = nEESMXExt / 5;
578  if (iSM == kEEm01 || iSM == kEEm05 || iSM == kEEm09 || iSM == kEEp01 || iSM == kEEp05 || iSM == kEEp09)
579  nX = nEESMXRed / 5;
580  int ix(_bin % (nX + 2) + xlow_(iSM) / 5);
581  int iy(_bin / (nX + 2) + ylow_(iSM) / 5);
582  int z(iSM <= kEEmHigh ? -1 : 1);
583  return EcalScDetId::validDetId(ix, iy, z) && iSM == dccId(EcalScDetId(ix, iy, z)) - 1;
584  }
585  }
586 
587  return true;
588  }
589 
590  std::string channelName(uint32_t _rawId, BinningType _btype /* = kDCC*/) {
591  // assume the following IDs for respective binning types:
592  // Crystal: EcalElectronicsId
593  // TriggerTower: EcalTriggerElectronicsId (pstrip and channel ignored)
594  // SuperCrystal: EcalElectronicsId (strip and crystal ignored)
595  // TCC: TCC ID
596  // DCC: DCC ID
597 
598  std::stringstream ss;
599 
600  switch (_btype) {
601  case kCrystal: {
602  // EB-03 DCC 12 CCU 12 strip 3 xtal 1 (EB ieta -13 iphi 60) (TCC 39 TT 12
603  // pstrip 3 chan 1)
604  EcalElectronicsId eid(_rawId);
605  if (eid.towerId() >= 69)
606  ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " CCU " << eid.towerId() << " PN " << eid.xtalId();
607  else {
608  ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " CCU " << eid.towerId() << " strip "
609  << eid.stripId() << " xtal " << eid.xtalId();
610 
611  if (eid.dccId() >= kEBmLow + 1 && eid.dccId() <= kEBpHigh + 1) {
612  EBDetId ebid(getElectronicsMap()->getDetId(eid));
613  ss << " (EB ieta " << std::showpos << ebid.ieta() << std::noshowpos << " iphi " << ebid.iphi() << ")";
614  } else {
615  EEDetId eeid(getElectronicsMap()->getDetId(eid));
616  ss << " (EE ix " << eeid.ix() << " iy " << eeid.iy() << ")";
617  }
618  EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(eid));
619  ss << " (TCC " << teid.tccId() << " TT " << teid.ttId() << " pstrip " << teid.pseudoStripId() << " chan "
620  << teid.channelId() << ")";
621  break;
622  }
623  }
624  case kTriggerTower: {
625  // EB-03 DCC 12 TCC 18 TT 3
626  EcalTriggerElectronicsId teid(_rawId);
627  EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(teid));
628  ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " TCC " << teid.tccId() << " TT " << teid.ttId();
629  break;
630  }
631  case kSuperCrystal: {
632  // EB-03 DCC 12 CCU 18 (EBTT ieta -13 iphi 60)
633  EcalElectronicsId eid(_rawId);
634  ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " CCU " << eid.towerId();
635  if (eid.dccId() >= kEBmLow + 1 && eid.dccId() <= kEBpHigh + 1) {
636  EcalTrigTowerDetId ttid(EBDetId(getElectronicsMap()->getDetId(eid)).tower());
637  ss << " (EBTT ieta " << std::showpos << ttid.ieta() << std::noshowpos << " iphi " << ttid.iphi() << ")";
638  } else {
639  EcalScDetId scid(EEDetId(getElectronicsMap()->getDetId(eid)).sc());
640  ss << " (EESC ix " << scid.ix() << " iy " << scid.iy() << ")";
641  }
642  break;
643  }
644  case kTCC: {
645  // EB-03 TCC 12
646  int tccid(_rawId - nDCC);
647  int dccid(getElectronicsMap()->DCCid(getElectronicsMap()->getTrigTowerDetId(tccid, 1)));
648  ss << smName(dccid) << " TCC " << (_rawId - nDCC);
649  break;
650  }
651  case kDCC:
652  ss << smName(_rawId);
653  break;
654  default:
655  break;
656  }
657 
658  return ss.str();
659  }
660 
661  uint32_t idFromName(std::string const &_name) {
662  TString name(_name);
663  TPRegexp re(
664  "(EB|EE)([+-][0-9][0-9])(?: TCC ([0-9]+)| DCC ([0-9]+) (CCU|TCC) "
665  "([0-9]+)(?: (TT|strip|PN) ([0-9]+)(?: xtal ([0-9]+)|)|)|)");
666  // 1 2 3 4 5 6 7 8 9
667  uint32_t rawId(0);
668 
669  TObjArray *matches(re.MatchS(name));
670  matches->SetOwner(true);
671  if (matches->GetEntries() == 0)
672  return 0;
673  else if (matches->GetEntries() == 3) {
674  TString subdet(static_cast<TObjString *>(matches->At(1))->GetString());
675  if (subdet == "EB") {
676  int dccid(static_cast<TObjString *>(matches->At(2))->GetString().Atoi());
677  unsigned offset(0);
678  if (dccid < 0) {
679  dccid *= -1;
680  offset = kEEmLow;
681  } else
682  offset = kEEpLow;
683  rawId = (dccid + 2) % 9 + 1 + offset;
684  } else {
685  int dccid(static_cast<TObjString *>(matches->At(2))->GetString().Atoi());
686  if (dccid < 0)
687  dccid *= -1;
688  else
689  dccid += 18;
690  rawId = kEBmLow + dccid;
691  }
692  } else if (matches->GetEntries() == 4)
693  rawId = static_cast<TObjString *>(matches->At(3))->GetString().Atoi() + nDCC;
694  else {
695  TString subtype(static_cast<TObjString *>(matches->At(5))->GetString());
696  if (subtype == "TCC") {
697  int tccid(static_cast<TObjString *>(matches->At(6))->GetString().Atoi());
698  int ttid(static_cast<TObjString *>(matches->At(8))->GetString().Atoi());
699  rawId = EcalTriggerElectronicsId(tccid, ttid, 1, 1).rawId();
700  } else {
701  int dccid(static_cast<TObjString *>(matches->At(4))->GetString().Atoi());
702  int towerid(static_cast<TObjString *>(matches->At(6))->GetString().Atoi());
703  if (matches->GetEntries() == 7)
704  rawId = EcalElectronicsId(dccid, towerid, 1, 1).rawId();
705  else {
706  TString chType(static_cast<TObjString *>(matches->At(7))->GetString());
707  int stripOrPNid(static_cast<TObjString *>(matches->At(8))->GetString().Atoi());
708  if (chType == "PN")
709  rawId = EcalElectronicsId(dccid, towerid, 1, stripOrPNid).rawId();
710  else if (chType == "strip") {
711  int xtalid(static_cast<TObjString *>(matches->At(9))->GetString().Atoi());
712  rawId = EcalElectronicsId(dccid, towerid, stripOrPNid, xtalid).rawId();
713  }
714  // case "TT" is already taken care of
715  }
716  }
717  }
718 
719  delete matches;
720 
721  return rawId;
722  }
723 
724  uint32_t idFromBin(ObjectType _otype, BinningType _btype, unsigned _iME, int _bin) {
725  if (_otype == kEB) {
726  if (_btype == kCrystal) {
727  int ieta(_bin / 362 - 86);
728  if (ieta >= 0)
729  ++ieta;
730  return EBDetId(ieta, _bin % 362);
731  } else if (_btype == kTriggerTower || _btype == kSuperCrystal) {
732  int ieta(_bin / 74 - 17);
733  int z(1);
734  if (ieta <= 0) {
735  z = -1;
736  ieta = -ieta + 1;
737  }
738  return EcalTrigTowerDetId(z, EcalBarrel, ieta, (_bin % 74 + 69) % 72 + 1);
739  }
740  } else if (_otype == kEEm || _otype == kEEp) {
741  int z(_otype == kEEm ? -1 : 1);
742  if (_btype == kCrystal || _btype == kTriggerTower)
743  return EEDetId(_bin % 102, _bin / 102, z).rawId();
744  else if (_btype == kSuperCrystal)
745  return EcalScDetId(_bin % 22, _bin / 22, z).rawId();
746  } else if (_otype == kEE) {
747  if (_btype == kCrystal || _btype == kTriggerTower) {
748  int ix(_bin % 202);
749  int z(ix > 100 ? 1 : -1);
750  if (z > 0)
751  ix = (ix - 100) % 101;
752  return EEDetId(ix, _bin / 202, z).rawId();
753  } else if (_btype == kSuperCrystal) {
754  int ix(_bin % 42);
755  int z(ix > 20 ? 1 : -1);
756  if (z > 0)
757  ix = (ix - 20) % 21;
758  return EcalScDetId(ix, _bin / 42, z).rawId();
759  }
760  } else if (_otype == kSM || _otype == kEBSM || _otype == kEESM) {
761  unsigned iSM(_iME);
762  if (_otype == kEBSM)
763  iSM += 9;
764  else if (_otype == kEESM && iSM > kEEmHigh)
765  iSM += nEBDCC;
766 
767  int z(iSM <= kEBmHigh ? -1 : 1);
768 
769  if ((iSM >= kEBmLow && iSM <= kEBmHigh) || (iSM >= kEBpLow && iSM <= kEBpHigh)) {
770  if (_btype == kCrystal) {
771  int iphi(((iSM - 9) % 18) * 20 + (z < 0 ? _bin / 87 : 21 - _bin / 87));
772  int ieta((_bin % 87) * z);
773  return EBDetId(ieta, iphi).rawId();
774  } else if (_btype == kTriggerTower || _btype == kSuperCrystal) {
775  int iphi((((iSM - 9) % 18) * 4 + (z < 0 ? _bin / 19 : 5 - _bin / 19) + 69) % 72 + 1);
776  int ieta(_bin % 19);
777  return EcalTrigTowerDetId(z, EcalBarrel, ieta, iphi).rawId();
778  }
779  } else {
780  if (_btype == kCrystal || _btype == kTriggerTower) {
781  int nX(nEESMX);
782  if (iSM == kEEm02 || iSM == kEEm08 || iSM == kEEp02 || iSM == kEEp08)
783  nX = nEESMXExt;
784  if (iSM == kEEm01 || iSM == kEEm05 || iSM == kEEm09 || iSM == kEEp01 || iSM == kEEp05 || iSM == kEEp09)
785  nX = nEESMXRed;
786  return EEDetId(_bin % (nX + 2) + xlow_(iSM), _bin / (nX + 2) + ylow_(iSM), z).rawId();
787  } else if (_btype == kSuperCrystal) {
788  int nX(nEESMX / 5);
789  if (iSM == kEEm02 || iSM == kEEm08 || iSM == kEEp02 || iSM == kEEp08)
790  nX = nEESMXExt / 5;
791  if (iSM == kEEm01 || iSM == kEEm05 || iSM == kEEm09 || iSM == kEEp01 || iSM == kEEp05 || iSM == kEEp09)
792  nX = nEESMXRed / 5;
793  return EcalScDetId(_bin % (nX + 2) + xlow_(iSM) / 5, _bin / (nX + 2) + ylow_(iSM) / 5, z).rawId();
794  }
795  }
796  }
797 
798  return 0;
799  }
800 
801  AxisSpecs formAxis(edm::ParameterSet const &_axisParams) {
802  AxisSpecs axis;
803 
804  if (_axisParams.existsAs<std::vector<double>>("edges", false)) {
805  std::vector<double> const &vEdges(_axisParams.getUntrackedParameter<std::vector<double>>("edges"));
806  axis.nbins = vEdges.size() - 1;
807  axis.edges = new float[vEdges.size()];
808  std::copy(vEdges.begin(), vEdges.end(), axis.edges);
809  } else {
810  axis.nbins = _axisParams.getUntrackedParameter<int>("nbins");
811  axis.low = _axisParams.getUntrackedParameter<double>("low");
812  bool highSet(_axisParams.existsAs<double>("high", false));
813  bool perBinSet(_axisParams.existsAs<double>("unitsPerBin", false));
814  if (highSet) {
815  if (perBinSet)
816  edm::LogWarning("EcalDQM") << "Maximum and bin width both set in an axis; using the former";
817  axis.high = _axisParams.getUntrackedParameter<double>("high");
818  } else if (perBinSet)
819  axis.high = axis.low + _axisParams.getUntrackedParameter<double>("unitsPerBin") * axis.nbins;
820  else
821  axis.high = 0.;
822  }
823 
824  if (_axisParams.existsAs<std::vector<std::string>>("labels", false)) {
825  std::vector<std::string> const &labels(_axisParams.getUntrackedParameter<std::vector<std::string>>("labels"));
826  if (int(labels.size()) == axis.nbins) {
827  axis.labels = new std::string[axis.nbins];
828  for (int iB(0); iB != axis.nbins; ++iB)
829  axis.labels[iB] = labels[iB];
830  }
831  }
832 
833  axis.title = _axisParams.getUntrackedParameter<std::string>("title");
834 
835  return axis;
836  }
837 
839  _desc.addUntracked<std::string>("title", "");
840  _desc.addUntracked<int>("nbins", 0);
841  _desc.addUntracked<double>("low", 0.);
842  _desc.addOptionalNode(edm::ParameterDescription<double>("high", 0., false) ^
843  edm::ParameterDescription<double>("unitsPerBin", 0., false),
844  false);
845  _desc.addOptionalUntracked<std::vector<double>>("edges");
846  _desc.addOptionalUntracked<std::vector<std::string>>("labels");
847  }
848 
850  if (_otypeName == "EB")
851  return kEB;
852  else if (_otypeName == "EE")
853  return kEE;
854  else if (_otypeName == "EEm")
855  return kEEm;
856  else if (_otypeName == "EEp")
857  return kEEp;
858  else if (_otypeName == "SM")
859  return kSM;
860  else if (_otypeName == "EBSM")
861  return kEBSM;
862  else if (_otypeName == "EESM")
863  return kEESM;
864  else if (_otypeName == "SMMEM")
865  return kSMMEM;
866  else if (_otypeName == "EBSMMEM")
867  return kEBSMMEM;
868  else if (_otypeName == "EESMMEM")
869  return kEESMMEM;
870  else if (_otypeName == "Ecal")
871  return kEcal;
872  else if (_otypeName == "MEM")
873  return kMEM;
874  else if (_otypeName == "EBMEM")
875  return kEBMEM;
876  else if (_otypeName == "EEMEM")
877  return kEEMEM;
878  else if (_otypeName == "Ecal2P")
879  return kEcal2P;
880  else if (_otypeName == "Ecal3P")
881  return kEcal3P;
882  else if (_otypeName == "EE2P")
883  return kEE2P;
884  else if (_otypeName == "MEM2P")
885  return kMEM2P;
886  else if (_otypeName == "Channel")
887  return kChannel;
888  else if (_otypeName == "None")
889  return nObjType;
890 
891  throw cms::Exception("InvalidConfiguration") << "No object type " << _otypeName << " defined";
892  }
893 
895  if (_btypeName == "Crystal")
896  return kCrystal;
897  else if (_btypeName == "TriggerTower")
898  return kTriggerTower;
899  else if (_btypeName == "SuperCrystal")
900  return kSuperCrystal;
901  else if (_btypeName == "PseudoStrip")
902  return kPseudoStrip;
903  else if (_btypeName == "TCC")
904  return kTCC;
905  else if (_btypeName == "DCC")
906  return kDCC;
907  else if (_btypeName == "ProjEta")
908  return kProjEta;
909  else if (_btypeName == "ProjPhi")
910  return kProjPhi;
911  else if (_btypeName == "RCT")
912  return kRCT;
913  else if (_btypeName == "User")
914  return kUser;
915  else if (_btypeName == "Report")
916  return kReport;
917  else if (_btypeName == "Trend")
918  return kTrend;
919 
920  throw cms::Exception("InvalidConfiguration") << "No binning type " << _btypeName << " defined";
921  }
922 
924  if (_kindName == "REAL")
926  else if (_kindName == "TH1F")
928  else if (_kindName == "TProfile")
930  else if (_kindName == "TH2F")
932  else if (_kindName == "TProfile2D")
934  else
936  }
937  } // namespace binning
938 } // namespace ecaldqm
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
int findBinCrystal_(ObjectType, DetId const &, int=-1)
unsigned memDCCIndex(unsigned)
T getUntrackedParameter(std::string const &, T const &) const
int findBinRCT_(ObjectType, DetId const &)
int findBinTriggerTower_(ObjectType, DetId const &)
int ix() const
Definition: EEDetId.h:77
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
int tccId() const
get the DCC (Ecal Local DCC value not global one) id
int xtalId() const
get the channel id
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
def copy(args, dbName)
int stripId() const
get the tower id
bool isValidIdBin(ObjectType, BinningType, unsigned, int)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
unsigned getNObjects(ObjectType)
EcalElectronicsMapping const * getElectronicsMap()
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
unsigned tccId(DetId const &)
int towerId() const
get the tower id
int zside(DetId const &)
ObjectType getObject(ObjectType, unsigned)
unsigned ttId(DetId const &)
int channelId() const
get the channel id
int ieta() const
get the tower ieta
ObjectType translateObjectType(std::string const &)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
AxisSpecs getBinning(ObjectType, BinningType, bool, int, unsigned)
bool isEndcapTTId(DetId const &)
int iPnId() const
get the PnId
int findBinSuperCrystal_(ObjectType, DetId const &, int=-1)
int ix() const
Definition: EcalScDetId.h:70
int ttId() const
get the tower id
AxisSpecs getBinningSMMEM_(BinningType, bool, unsigned, int)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
AxisSpecs getBinningEB_(BinningType, bool, int)
int iy() const
Definition: EEDetId.h:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
uint32_t idFromName(std::string const &)
int pseudoStripId() const
get the tower id
AxisSpecs getBinningSM_(BinningType, bool, unsigned, int)
int findBin1D(ObjectType, BinningType, DetId const &)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
unsigned towerId(DetId const &)
int iy() const
Definition: EcalScDetId.h:76
std::string channelName(uint32_t, BinningType _btype=kDCC)
uint32_t rawId() const
bin
set the eta bin as selection string.
Definition: DetId.h:18
int iphi() const
get the tower iphi
std::string smName(unsigned)
int findBin2D(ObjectType, BinningType, DetId const &)
unsigned findPlotIndex(ObjectType, DetId const &)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
AxisSpecs getBinningEE_(BinningType, bool, int, int)
void fillAxisDescriptions(edm::ParameterSetDescription &)
MonitorElement::Kind translateKind(std::string const &)
int findBinPseudoStrip_(ObjectType, DetId const &)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
BinningType translateBinningType(std::string const &)
AxisSpecs formAxis(edm::ParameterSet const &)
AxisSpecs getBinningMEM_(BinningType, bool, int, int)
unsigned dccId(DetId const &)
AxisSpecs getBinningEcal_(BinningType, bool, int)
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
uint32_t idFromBin(ObjectType, BinningType, unsigned, int)