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