CMS 3D CMS Logo

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