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