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