CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Numbers.cc
Go to the documentation of this file.
1 
8 #include <sstream>
9 #include <iomanip>
10 #include <set>
11 
14 
20 
27 
29 
30 //-------------------------------------------------------------------------
31 
35 
36 const unsigned Numbers::crystalsTCCArraySize_;
37 const unsigned Numbers::crystalsDCCArraySize_;
38 
39 std::vector<DetId> Numbers::crystalsTCC_[crystalsTCCArraySize_];
40 std::vector<DetId> Numbers::crystalsDCC_[crystalsDCCArraySize_];
41 
42 bool Numbers::init = false;
43 
44 //-------------------------------------------------------------------------
45 
46 void
48 {
49 
50  if( Numbers::init ) return;
51 
52  if ( verbose ) std::cout << "Initializing EcalElectronicsMapping ..." << std::endl;
53 
54  Numbers::init = true;
55 
57  setup.get<EcalMappingRcd>().get(handle);
58  Numbers::map = handle.product();
59 
61  setup.get<IdealGeometryRecord>().get(handleTT);
62  Numbers::mapTT = handleTT.product();
63 
64  edm::ESHandle<CaloGeometry> handleGeom;
65  setup.get<CaloGeometryRecord>().get(handleGeom);
66  Numbers::geometry = handleGeom.product();
67 
68  if ( verbose ) std::cout << "done." << std::endl;
69 
70 }
71 
72 //-------------------------------------------------------------------------
73 
74 int
75 Numbers::iEB( const unsigned ism )
76 {
77 
78  // EB-
79  if( ism >= 1 && ism <= 18 ) return( -ism );
80 
81  // EB+
82  if( ism >= 19 && ism <= 36 ) return( +ism - 18 );
83 
84  throw cms::Exception("InvalidParameter") << "Wrong SM id determination: iSM = " << ism;
85 
86 }
87 
88 //-------------------------------------------------------------------------
89 
91 Numbers::sEB( const unsigned ism )
92 {
93 
94  int ieb = Numbers::iEB( ism );
95 
96  std::ostringstream s;
97  s << "EB" << std::setw(3) << std::setfill('0')
98  << std::setiosflags( std::ios::showpos )
99  << std::setiosflags( std::ios::internal )
100  << ieb
101  << std::resetiosflags( std::ios::showpos )
102  << std::resetiosflags( std::ios::internal );
103  return( s.str() );
104 
105 }
106 
107 //-------------------------------------------------------------------------
108 
109 int
110 Numbers::iEE( const unsigned ism )
111 {
112 
113  // EE-
114  if( ism == 1 ) return( -7 );
115  if( ism == 2 ) return( -8 );
116  if( ism == 3 ) return( -9 );
117  if( ism == 4 ) return( -1 );
118  if( ism == 5 ) return( -2 );
119  if( ism == 6 ) return( -3 );
120  if( ism == 7 ) return( -4 );
121  if( ism == 8 ) return( -5 );
122  if( ism == 9 ) return( -6 );
123 
124  // EE+
125  if( ism == 10 ) return( +7 );
126  if( ism == 11 ) return( +8 );
127  if( ism == 12 ) return( +9 );
128  if( ism == 13 ) return( +1 );
129  if( ism == 14 ) return( +2 );
130  if( ism == 15 ) return( +3 );
131  if( ism == 16 ) return( +4 );
132  if( ism == 17 ) return( +5 );
133  if( ism == 18 ) return( +6 );
134 
135  throw cms::Exception("InvalidParameter") << "Wrong SM id determination: iSM = " << ism;
136 
137 }
138 
139 //-------------------------------------------------------------------------
140 
143 {
144 
145  return( id.subdet() );
146 
147 }
148 
149 //-------------------------------------------------------------------------
150 
153 {
154 
155  return( id.subdet() );
156 
157 }
158 
159 //-------------------------------------------------------------------------
160 
163 {
164 
165  return( id.subDet() );
166 
167 }
168 
169 //-------------------------------------------------------------------------
170 
173 {
174 
175  return( id.subdet() );
176 
177 }
178 
179 //-------------------------------------------------------------------------
180 
183 {
184 
185  return( id.subdet() );
186 
187 }
188 
189 //-------------------------------------------------------------------------
190 
193 {
194 
195  return( (EcalSubdetector) id.iEcalSubDetectorId() );
196 
197 }
198 
199 //-------------------------------------------------------------------------
200 
203 {
204 
205  int idcc = id.id();
206 
207  // EE-
208  if ( idcc >= 1 && idcc <= 9 ) return( EcalEndcap );
209 
210  // EB-/EB+
211  if ( idcc >= 10 && idcc <= 45 ) return( EcalBarrel);
212 
213  // EE+
214  if ( idcc >= 46 && idcc <= 54 ) return( EcalEndcap );
215 
216  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
217 
218 }
219 
220 //-------------------------------------------------------------------------
221 
223 Numbers::sEE( const unsigned ism )
224 {
225 
226  int iee = Numbers::iEE( ism );
227 
228  std::ostringstream s;
229  s << "EE" << std::setw(3) << std::setfill('0')
230  << std::setiosflags( std::ios::showpos )
231  << std::setiosflags( std::ios::internal )
232  << iee
233  << std::resetiosflags( std::ios::showpos )
234  << std::resetiosflags( std::ios::internal );
235  return( s.str() );
236 
237 }
238 
239 //-------------------------------------------------------------------------
240 
241 // for EB, converts between two schemes. Old scheme [1:9] for EB-, new scheme (used in EBDetId) [1:9] for EB+
242 unsigned
243 Numbers::iSM( const unsigned ism, const EcalSubdetector subdet )
244 {
245 
246  if( subdet == EcalBarrel ) {
247 
248  if( ism >= 1 && ism <= 18 ) return( ism+18 );
249 
250  if( ism >= 19 && ism <= 36 ) return( ism-18 );
251 
252  throw cms::Exception("InvalidParameter") << "Wrong SM id: iSM = " << ism;
253 
254  } else if( subdet == EcalEndcap ) {
255 
256  if( ism >= 1 && ism <= 9 ) return( ism+9 );
257 
258  if (ism >= 10 && ism <= 18 ) return( ism-9 );
259 
260  throw cms::Exception("InvalidParameter") << "Wrong SM id: iSM = " << ism;
261 
262  }
263 
264  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
265 
266 }
267 
268 //-------------------------------------------------------------------------
269 
270 unsigned
271 Numbers::iSM( const EBDetId& id )
272 {
273 
274  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
275 
276  const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
277  int idcc = eid.dccId();
278 
279  // EB-/EB+
280  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
281 
282  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
283 
284 }
285 
286 
287 //-------------------------------------------------------------------------
288 
289 unsigned
290 Numbers::iSM( const EEDetId& id )
291 {
292 
293  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
294 
295  const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
296  int idcc = eid.dccId();
297 
298  // EE-
299  if( idcc >= 1 && idcc <= 9 ) return( idcc );
300 
301  // EE+
302  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
303 
304  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
305 
306 }
307 
308 //-------------------------------------------------------------------------
309 
310 unsigned
312 {
313 
314  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
315 
316  EcalSubdetector subdet = Numbers::subDet( id );
317 
318  if( subdet == EcalBarrel ) {
319 
320  int idcc = Numbers::map->DCCid(id);
321 
322  // EB-/EB+
323  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
324 
325  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
326 
327  } else if( subdet == EcalEndcap) {
328 
329  int idcc = Numbers::map->DCCid(id);
330 
331  // EE-
332  if( idcc >= 1 && idcc <= 9 ) return( idcc );
333 
334  // EE+
335  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
336 
337  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
338 
339  }
340 
341  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
342 
343 }
344 
345 //-------------------------------------------------------------------------
346 
347 unsigned
349 {
350 
351  int idcc = id.dccId();
352 
353  // EE-
354  if( idcc >= 1 && idcc <= 9 ) return( idcc );
355 
356  // EB-/EB+
357  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
358 
359  // EE+
360  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
361 
362  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
363 
364 }
365 
366 //-------------------------------------------------------------------------
367 
368 unsigned
370 {
371 
372  int idcc = id.iDCCId();
373 
374  // EE-
375  if( idcc >= 1 && idcc <= 9 ) return( idcc );
376 
377  // EB-/EB+
378  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
379 
380  // EE+
381  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
382 
383  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
384 
385 }
386 
387 //-------------------------------------------------------------------------
388 
389 unsigned
391 {
392 
393  std::pair<int, int> dccsc = Numbers::map->getDCCandSC( id );
394 
395  int idcc = dccsc.first;
396 
397  // EE-
398  if( idcc >= 1 && idcc <= 9 ) return( idcc );
399 
400  // EB-/EB+
401  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
402 
403  // EE+
404  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
405 
406  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
407 
408 }
409 
410 //-------------------------------------------------------------------------
411 
412 unsigned
414 {
415 
416  int idcc = id.id();
417 
418  // EE-
419  if( idcc >= 1 && idcc <= 9 ) return( idcc );
420 
421  // EB-/EB+
422  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
423 
424  // EE+
425  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
426 
427  throw cms::Exception("InvalidParameter") << "Wrong DCC id: dcc = " << idcc;
428 
429 }
430 
431 //-------------------------------------------------------------------------
432 
433 unsigned
435 {
436 
437  std::pair<int, int> dccsc = Numbers::map->getDCCandSC( id );
438 
439  return static_cast<unsigned>(dccsc.second);
440 
441 }
442 
443 //-------------------------------------------------------------------------
444 
445 unsigned
446 Numbers::iSC( const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2 )
447 {
448 
449  if( subdet == EcalBarrel ) {
450 
451  int iet = 1 + ((i1-1)/5);
452  int ipt = 1 + ((i2-1)/5);
453 
454  return( (ipt-1) + 4*(iet-1) + 1 );
455 
456  } else if( subdet == EcalEndcap ) {
457 
458  if( !Numbers::map ) throw( std::runtime_error( "ECAL Geometry not available" ) );
459 
460  // use ism only for determination of +/-
461 
462  int iz = 0;
463 
464  if( ism >= 1 && ism <= 9 ) iz = -1;
465  if( ism >= 10 && ism <= 18 ) iz = +1;
466 
467  EEDetId id(i1, i2, iz, EEDetId::XYMODE); // throws an exception if invalid
468 
469  const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
470 
471  return( static_cast<unsigned>( eid.towerId() ));
472 
473  }
474 
475  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
476 
477 }
478 
479 //-------------------------------------------------------------------------
480 
481 unsigned
482 Numbers::iTT( const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2 )
483 {
484 
485  if( subdet == EcalBarrel ) {
486 
487  return( Numbers::iSC(ism, subdet, i1, i2) );
488 
489  } else if( subdet == EcalEndcap ) {
490 
491  if( !Numbers::mapTT ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
492 
493  // use ism only for determination of +/-
494 
495  int iz = 0;
496 
497  if( ism >= 1 && ism <= 9 ) iz = -1;
498  if( ism >= 10 && ism <= 18 ) iz = +1;
499 
500  EEDetId id(i1, i2, iz, EEDetId::XYMODE); // throws an exception if invalid
501 
502  const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
503 
504  return( static_cast<unsigned>( iTT(towid) ) );
505 
506  }
507 
508  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
509 
510 }
511 
512 //-------------------------------------------------------------------------
513 
514 unsigned
516 {
517 
518  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
519 
520  EcalSubdetector subdet = Numbers::subDet( id );
521 
522  if( subdet == EcalBarrel || subdet == EcalEndcap ) return( static_cast<unsigned>( Numbers::map->iTT(id) ) );
523 
524  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
525 
526 }
527 
528 //-------------------------------------------------------------------------
529 
530 unsigned
531 Numbers::iTCC( const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2 )
532 {
533 
534  if( !Numbers::mapTT ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
535 
536  if( subdet == EcalBarrel ) {
537 
538  EBDetId id(i1, i2, EBDetId::ETAPHIMODE);
539 
540  const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
541 
542  return( static_cast<unsigned>( Numbers::map->TCCid(towid) ) );
543 
544  } else if( subdet == EcalEndcap) {
545 
546  int iz = 0;
547 
548  if( ism >= 1 && ism <= 9 ) iz = -1;
549  if( ism >= 10 && ism <= 18 ) iz = +1;
550 
551  EEDetId id(i1, i2, iz, EEDetId::XYMODE);
552 
553  const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
554 
555  return( static_cast<unsigned>( Numbers::map->TCCid(towid) ) );
556 
557  }
558 
559  throw cms::Exception("InvalidSubdetector") << "subdet = " << subdet;
560 
561 }
562 
563 //-------------------------------------------------------------------------
564 
565 unsigned
567 {
568 
569  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
570 
571  EcalSubdetector subdet = Numbers::subDet( id );
572 
573  if( subdet == EcalBarrel || subdet == EcalEndcap ) return( static_cast<unsigned>( Numbers::map->TCCid(id) ) );
574 
575  throw cms::Exception("InvalidParameter") << "Invalid subdetector: subdet = " << subdet;
576 
577 }
578 
579 //-------------------------------------------------------------------------
580 
581 std::vector<DetId> *
583 {
584 
585  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
586 
587  int itcc = Numbers::map->TCCid(id);
588  int itt = Numbers::map->iTT(id);
589 
590  unsigned index = 100*(itcc-1) + (itt-1);
591 
592  if( index >= crystalsTCCArraySize_ ) throw cms::Exception("InvalidParameter") << "TCC index " << index;
593 
594  if ( Numbers::crystalsTCC_[index].size() == 0 ) {
595  Numbers::crystalsTCC_[index] = Numbers::map->ttConstituents( itcc, itt );
596  }
597 
598  return &(Numbers::crystalsTCC_[index]);
599 
600 }
601 
602 //-------------------------------------------------------------------------
603 
604 unsigned
606 {
607 
608  int ic = id.ic();
609  int ie = (ic-1)/20 + 1;
610  int ip = (ic-1)%20 + 1;
611 
612  if( ie > 5 && ip < 11 ) return 1;
613 
614  return 0;
615 
616 }
617 
618 //-------------------------------------------------------------------------
619 
620 unsigned
622 {
623 
624  int ix = id.ix();
625 
626  int ism = Numbers::iSM( id );
627 
628  // EE-05
629  if ( ism == 8 && ix > 50 ) return 1;
630 
631  // EE+05
632  if ( ism == 17 && ix > 50 ) return 1;
633 
634  return 0;
635 
636 }
637 
638 //-------------------------------------------------------------------------
639 
640 std::vector<DetId> *
642 {
643 
644  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
645 
646  int idcc = id.dccId();
647  int isc = id.towerId();
648 
649  return Numbers::crystals( idcc, isc );
650 
651 }
652 
653 //-------------------------------------------------------------------------
654 
655 std::vector<DetId> *
656 Numbers::crystals( unsigned idcc, unsigned isc )
657 {
658 
659  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
660 
661  unsigned index = 100*(idcc-1) + (isc-1);
662 
663  if( index > crystalsDCCArraySize_ ) throw cms::Exception("InvalidParameter") << "DCC index " << index;
664 
665  if ( Numbers::crystalsDCC_[index].size() == 0 ) {
666  Numbers::crystalsDCC_[index] = Numbers::map->dccTowerConstituents(idcc, isc);
667  }
668 
669  return &(Numbers::crystalsDCC_[index]);
670 
671 }
672 
673 //-------------------------------------------------------------------------
674 
675 const EcalScDetId
677 {
678 
679  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
680 
681  const EcalElectronicsId& eid = Numbers::map->getElectronicsId(id);
682 
683  int idcc = eid.dccId();
684  int isc = eid.towerId();
685 
686  const std::vector<EcalScDetId> ids = Numbers::map->getEcalScDetId( idcc, isc, true );
687 
688  return ids.size() > 0 ? ids[0] : EcalScDetId();
689 
690 }
691 
692 //-------------------------------------------------------------------------
693 
694 unsigned
695 Numbers::indexEB( const unsigned ism, const unsigned ie, const unsigned ip )
696 {
697 
698  unsigned ic = (ip-1) + 20*(ie-1) + 1;
699 
700  if( ic == 0 || ic > static_cast<unsigned>( EBDetId::kCrystalsPerSM ) ) throw cms::Exception("InvalidParameter") << "ism=" << ism << " ie=" << ie << " ip=" << ip;
701 
702  return ic;
703 
704 }
705 
706 //-------------------------------------------------------------------------
707 
708 unsigned
709 Numbers::indexEE( const unsigned ism, const unsigned ix, const unsigned iy )
710 {
711 
712  int iz = 0;
713 
714  if( ism >= 1 && ism <= 9 ) iz = -1;
715  if( ism >= 10 && ism <= 18 ) iz = +1;
716 
717  if( !EEDetId::validDetId(ix, iy, iz) ) throw cms::Exception("InvalidParameter") << "ism=" << ism << " ix=" << ix << " iy=" << iy;
718 
719  return( 1000*ix + iy );
720 
721 }
722 
723 //-------------------------------------------------------------------------
724 
725 unsigned
726 Numbers::icEB( const unsigned ism, const unsigned ie, const unsigned ip )
727 {
728 
729  return Numbers::indexEB( ism, ie, ip );
730 
731 }
732 
733 //-------------------------------------------------------------------------
734 
735 unsigned
736 Numbers::icEE( const unsigned ism, const unsigned ix, const unsigned iy )
737 {
738 
739  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
740 
741  int iz = 0;
742 
743  if( ism >= 1 && ism <= 9 ) iz = -1;
744  if( ism >= 10 && ism <= 18 ) iz = +1;
745 
746  EEDetId id(ix, iy, iz, EEDetId::XYMODE);
747 
748  const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
749 
750  int vfe = eid.towerId();
751  int strip = eid.stripId();
752  int channel = eid.xtalId();
753 
754  // EE-05 & EE+05
755  if( ism == 8 || ism == 17 ) {
756  if( vfe > 17 ) vfe = vfe - 7;
757  }
758 
759  unsigned ic = (vfe-1)*25 + (strip-1)*5 + channel;
760 
761  if( ic == 0 || ic > static_cast<unsigned>( EEDetId::kSizeForDenseIndexing ) ) throw cms::Exception("InvalidParameter") << "ic=" << ic;
762 
763  return ic;
764 
765 }
766 
767 //-------------------------------------------------------------------------
768 
769 int
770 Numbers::ix0EE( const unsigned ism )
771 {
772 
773  if( ism == 1 || ism == 15 ) return( - 5 );
774  if( ism == 2 || ism == 14 ) return( + 0 );
775  if( ism == 3 || ism == 13 ) return( + 10 );
776  if( ism == 4 || ism == 12 ) return( + 40 );
777  if( ism == 5 || ism == 11 ) return( + 50 );
778  if( ism == 6 || ism == 10 ) return( + 55 );
779  if( ism == 7 || ism == 18 ) return( + 50 );
780  if( ism == 8 || ism == 17 ) return( + 25 );
781  if( ism == 9 || ism == 16 ) return( + 0 );
782 
783  return( + 0 );
784 
785 }
786 
787 //-------------------------------------------------------------------------
788 
789 int
790 Numbers::ix0EEm( const unsigned ism )
791 {
792 
793  switch( ism ){
794  case 1: return -105;
795  case 2: return -100;
796  case 3: return -90;
797  case 4: return -60;
798  case 5: return -50;
799  case 6: return -45;
800  case 7: return -50;
801  case 8: return -75;
802  case 9: return -100;
803  }
804 
805  return ix0EE( ism );
806 }
807 
808 int
809 Numbers::iy0EE( const unsigned ism )
810 {
811 
812  if( ism == 1 || ism == 10 ) return( + 20 );
813  if( ism == 2 || ism == 11 ) return( + 45 );
814  if( ism == 3 || ism == 12 ) return( + 55 );
815  if( ism == 4 || ism == 13 ) return( + 55 );
816  if( ism == 5 || ism == 14 ) return( + 45 );
817  if( ism == 6 || ism == 15 ) return( + 20 );
818  if( ism == 7 || ism == 16 ) return( + 0 );
819  if( ism == 8 || ism == 17 ) return( - 5 );
820  if( ism == 9 || ism == 18 ) return( + 0 );
821 
822  return( + 0 );
823 
824 }
825 
826 //-------------------------------------------------------------------------
827 
828 bool
829 Numbers::validEE( const unsigned ism, const unsigned ix, const unsigned iy )
830 {
831 
832  int iz = 0;
833 
834  if( ism >= 1 && ism <= 9 ) iz = -1;
835  if( ism >= 10 && ism <= 18 ) iz = +1;
836 
837  if( EEDetId::validDetId(ix, iy, iz) ) {
838 
839  EEDetId id(ix, iy, iz, EEDetId::XYMODE);
840 
841  if( Numbers::iSM( id ) == ism ) return true;
842 
843  }
844 
845  return false;
846 
847 }
848 
849 //-------------------------------------------------------------------------
850 
851 bool
852 Numbers::validEESc( const unsigned ism, const unsigned ix, const unsigned iy )
853 {
854 
855  int iz = 0;
856 
857  if( ism >= 1 && ism <= 9 ) iz = -1;
858  if( ism >= 10 && ism <= 18 ) iz = +1;
859 
860  if( EcalScDetId::validDetId(ix, iy, iz) ) {
861 
862  EcalScDetId id(ix, iy, iz);
863 
864  if( Numbers::iSM( id ) == ism ) return true;
865 
866  }
867 
868  return false;
869 }
870 
871 unsigned
872 Numbers::nCCUs(const unsigned ism)
873 {
874  switch(ism){
875  case 8:
876  case 17:
877  return 41;
878  case 1:
879  case 6:
880  case 10:
881  case 15:
882  return 34;
883  case 3:
884  case 12:
885  case 4:
886  case 13:
887  case 7:
888  case 16:
889  case 9:
890  case 18:
891  return 33;
892  case 2:
893  case 11:
894  case 5:
895  case 14:
896  return 32;
897  default:
898  return 0;
899  }
900 }
901 
902 unsigned
903 Numbers::nTTs(const unsigned itcc)
904 {
905  using namespace std;
906  vector<DetId> crystals(map->tccConstituents(itcc));
907 
908  set<int> itts;
909  for(vector<DetId>::iterator cItr(crystals.begin()); cItr != crystals.end(); ++cItr)
910  itts.insert(map->iTT(mapTT->towerOf(*cItr)));
911 
912  return itts.size();
913 }
914 
917 {
918 
919  if( !Numbers::map ) throw cms::Exception("ObjectUnavailable") << "ECAL Geometry not available";
920 
921  return Numbers::map;
922 
923 }
924 
925 float
926 Numbers::eta( const DetId &id )
927 {
928  const GlobalPoint& pos = geometry->getPosition(id);
929  return pos.eta();
930 }
931 
932 float
933 Numbers::phi( const DetId &id )
934 {
935  const GlobalPoint& pos = geometry->getPosition(id);
936  return pos.phi();
937 }
938 
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:223
static const unsigned crystalsTCCArraySize_
Definition: Numbers.h:145
static bool validEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:829
int xtalId() const
get the channel id
static int iEE(const unsigned ism)
Definition: Numbers.cc:110
static int ix0EEm(const unsigned ism)
Definition: Numbers.cc:790
static unsigned icEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:736
static unsigned nCCUs(const unsigned ism)
Definition: Numbers.cc:872
int stripId() const
get the tower id
std::vector< DetId > tccConstituents(int tccId) const
Get the constituent detids for this dccId.
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
static bool validEESc(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:852
static const int XYMODE
Definition: EEDetId.h:339
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
static unsigned nTTs(const unsigned itcc)
Definition: Numbers.cc:903
int towerId() const
get the tower id
static int ix0EE(const unsigned ism)
Definition: Numbers.cc:770
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
static const int kCrystalsPerSM
Definition: EBDetId.h:151
static bool init
Definition: Numbers.h:136
static const EcalElectronicsMapping * getElectronicsMapping()
Definition: Numbers.cc:916
std::pair< int, int > getDCCandSC(EcalScDetId id) const
static unsigned icEB(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:726
static std::vector< DetId > crystalsDCC_[crystalsDCCArraySize_]
Definition: Numbers.h:149
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:809
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
static const EcalElectronicsMapping * map
Definition: Numbers.h:140
int TCCid(const EBDetId &id) const
returns the TCCid of an EBDetId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static std::vector< DetId > * crystals(const EcalTrigTowerDetId &id)
Definition: Numbers.cc:582
static unsigned iTCC(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
Definition: Numbers.cc:531
static unsigned iSC(const EcalScDetId &id)
Definition: Numbers.cc:434
tuple handle
Definition: patZpeak.py:22
static unsigned indexEB(const unsigned ism, const unsigned ie, const unsigned ip)
Definition: Numbers.cc:695
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
static const int ETAPHIMODE
Definition: EBDetId.h:166
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
std::vector< DetId > ttConstituents(int tccId, int tt) const
Get the constituent detids for this dccId.
Definition: DetId.h:18
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
static float eta(const DetId &id)
Definition: Numbers.cc:926
T eta() const
Definition: PV3DBase.h:76
static unsigned indexEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:709
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
static const EcalTrigTowerConstituentsMap * mapTT
Definition: Numbers.h:141
static std::vector< DetId > crystalsTCC_[crystalsTCCArraySize_]
Definition: Numbers.h:148
static const unsigned crystalsDCCArraySize_
Definition: Numbers.h:146
static unsigned RtHalf(const EBDetId &id)
Definition: Numbers.cc:605
tuple cout
Definition: gather_cfg.py:121
static const EcalScDetId getEcalScDetId(const EEDetId &id)
Definition: Numbers.cc:676
static int iEB(const unsigned ism)
Definition: Numbers.cc:75
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:142
EcalSubdetector
static const CaloGeometry * geometry
Definition: Numbers.h:143
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
static unsigned iTT(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
Definition: Numbers.cc:482
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.
static float phi(const DetId &id)
Definition: Numbers.cc:933