CMS 3D CMS Logo

CaloGenericDetId.cc
Go to the documentation of this file.
4 #include <iostream>
5 
6 CaloGenericDetId::CaloGenericDetId(DetId::Detector iDet, int iSub, uint32_t iDin) : DetId(iDet, iSub) {
7  if (isHcal()) {
8  edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
9  throw cms::Exception("No support");
10  } else if (isCaloTower()) {
11  edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
12  throw cms::Exception("No support");
13  } else {
14  id_ =
15  (isEB()
20  : (isCastor() ? HcalCastorDetId::detIdFromDenseIndex(iDin).rawId() : 0)))));
21  }
22 }
23 
24 uint32_t CaloGenericDetId::denseIndex() const {
25  if (isHcal()) {
26  edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
27  throw cms::Exception("No support");
28  } else if (isCaloTower()) {
29  edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
30  throw cms::Exception("No support");
31  }
32 
33  return (isEB() ? EBDetId(rawId()).denseIndex()
34  : (isEE() ? EEDetId(rawId()).denseIndex()
35  : (isES() ? ESDetId(rawId()).denseIndex()
37  : (isCastor() ? HcalCastorDetId(rawId()).denseIndex() : ~0)))));
38 }
39 
41  if (isHcal()) {
42  edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
43  throw cms::Exception("No support");
44  } else if (isCaloTower()) {
45  edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
46  throw cms::Exception("No support");
47  }
48 
54 }
55 
57  bool returnValue(false);
58  if (isEB()) {
59  const EBDetId ebid(rawId());
60  returnValue = EBDetId::validDetId(ebid.ieta(), ebid.iphi());
61  } else if (isEE()) {
62  const EEDetId eeid(rawId());
63  returnValue = EEDetId::validDetId(eeid.ix(), eeid.iy(), eeid.zside());
64  } else if (isES()) {
65  const ESDetId esid(rawId());
66  returnValue = ESDetId::validDetId(esid.strip(), esid.six(), esid.siy(), esid.plane(), esid.zside());
67  } else if (isHcal()) {
68  edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
69  throw cms::Exception("No support");
70  returnValue = false;
71  } else if (isCastor()) {
72  const HcalCastorDetId zdid(rawId());
73  returnValue = HcalCastorDetId::validDetId(zdid.section(), zdid.zside() > 0, zdid.sector(), zdid.module());
74  } else if (isCaloTower()) {
75  edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
76  throw cms::Exception("No support");
77 
78  returnValue = false;
79  }
80 
81  return returnValue;
82 }
83 
84 std::ostream& operator<<(std::ostream& s, const CaloGenericDetId& id) {
85  if (id.isHcal()) {
86  edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
87  throw cms::Exception("No support");
88  } else if (id.isCaloTower()) {
89  edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
90  throw cms::Exception("No support");
91  }
92 
93  return (id.isEB()
94  ? s << EBDetId(id)
95  : (id.isEE() ? s << EEDetId(id)
96  : (id.isES() ? s << ESDetId(id)
97  : (id.isZDC() ? s << HcalZDCDetId(id)
98  : s << "UnknownId=" << std::hex << id.rawId() << std::dec))));
99 }
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
static constexpr int kSizeForDenseIndexing
Definition: EEDetId.h:328
static bool validDetId(Section iSection, bool posEta, int iSector, int iMod)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
static constexpr HcalZDCDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalZDCDetId.h:145
int ix() const
Definition: EEDetId.h:77
uint32_t denseIndex() const
std::ostream & operator<<(std::ostream &s, const CaloGenericDetId &id)
int zside() const
Definition: ESDetId.h:39
Log< level::Error, false > LogError
static constexpr int kSizeForDenseIndexing
Definition: ESDetId.h:102
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:107
static HcalCastorDetId detIdFromDenseIndex(uint32_t di)
int plane() const
Definition: ESDetId.h:41
static constexpr int kSizeForDenseIndexing
Definition: EBDetId.h:155
int module() const
get the module (1-2 for EM, 1-12 for HAD)
int zside() const
get the z-side of the cell (1/-1)
bool isES() const
bool isHcal() const
bool validDetId() const
int sector() const
get the sector (1-16)
CaloGenericDetId(uint32_t rawid)
bool isCaloTower() const
static ESDetId detIdFromDenseIndex(uint32_t din)
Definition: ESDetId.h:55
Definition: DetId.h:17
static constexpr int32_t kSizeForDenseIndexing
Definition: HcalZDCDetId.h:203
int zside() const
Definition: EEDetId.h:71
bool isEB() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:69
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
Section section() const
get the section
int siy() const
Definition: ESDetId.h:45
static constexpr int kSizeForDenseIndexing
bool isEE() const
int six() const
Definition: ESDetId.h:43
int strip() const
Definition: ESDetId.h:47
uint32_t sizeForDenseIndexing() const
bool isCastor() const
bool isZDC() const
int iy() const
Definition: EEDetId.h:83