CMS 3D CMS Logo

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