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