Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:39

0001 #include "Geometry/CaloGeometry/interface/CaloGenericDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include <iostream>
0005 
0006 CaloGenericDetId::CaloGenericDetId(DetId::Detector iDet, int iSub, uint32_t iDin) : DetId(iDet, iSub) {
0007   if (isHcal()) {
0008     edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
0009     throw cms::Exception("No support");
0010   } else if (isCaloTower()) {
0011     edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
0012     throw cms::Exception("No support");
0013   } else {
0014     id_ =
0015         (isEB()
0016              ? EBDetId::detIdFromDenseIndex(iDin).rawId()
0017              : (isEE() ? EEDetId::detIdFromDenseIndex(iDin).rawId()
0018                        : (isES() ? ESDetId::detIdFromDenseIndex(iDin).rawId()
0019                                  : (isZDC() ? HcalZDCDetId::detIdFromDenseIndex(iDin).rawId()
0020                                             : (isCastor() ? HcalCastorDetId::detIdFromDenseIndex(iDin).rawId() : 0)))));
0021   }
0022 }
0023 
0024 uint32_t CaloGenericDetId::denseIndex() const {
0025   if (isHcal()) {
0026     edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
0027     throw cms::Exception("No support");
0028   } else if (isCaloTower()) {
0029     edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
0030     throw cms::Exception("No support");
0031   }
0032 
0033   return (isEB() ? EBDetId(rawId()).denseIndex()
0034                  : (isEE() ? EEDetId(rawId()).denseIndex()
0035                            : (isES() ? ESDetId(rawId()).denseIndex()
0036                                      : (isZDC() ? HcalZDCDetId(rawId()).denseIndex()
0037                                                 : (isCastor() ? HcalCastorDetId(rawId()).denseIndex() : ~0)))));
0038 }
0039 
0040 uint32_t CaloGenericDetId::sizeForDenseIndexing() const {
0041   if (isHcal()) {
0042     edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
0043     throw cms::Exception("No support");
0044   } else if (isCaloTower()) {
0045     edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
0046     throw cms::Exception("No support");
0047   }
0048 
0049   return (isEB() ? EBDetId::kSizeForDenseIndexing
0050                  : (isEE() ? EEDetId::kSizeForDenseIndexing
0051                            : (isES() ? ESDetId::kSizeForDenseIndexing
0052                                      : (isZDC() ? HcalZDCDetId::kSizeForDenseIndexing
0053                                                 : (isCastor() ? HcalCastorDetId::kSizeForDenseIndexing : 0)))));
0054 }
0055 
0056 bool CaloGenericDetId::validDetId() const {
0057   bool returnValue(false);
0058   if (isEB()) {
0059     const EBDetId ebid(rawId());
0060     returnValue = EBDetId::validDetId(ebid.ieta(), ebid.iphi());
0061   } else if (isEE()) {
0062     const EEDetId eeid(rawId());
0063     returnValue = EEDetId::validDetId(eeid.ix(), eeid.iy(), eeid.zside());
0064   } else if (isES()) {
0065     const ESDetId esid(rawId());
0066     returnValue = ESDetId::validDetId(esid.strip(), esid.six(), esid.siy(), esid.plane(), esid.zside());
0067   } else if (isHcal()) {
0068     edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
0069     throw cms::Exception("No support");
0070 
0071     returnValue = false;
0072   } else if (isZDC()) {
0073     const HcalZDCDetId zdid(rawId());
0074     returnValue = HcalZDCDetId::validDetId(zdid.section(), zdid.channel());
0075   } else if (isCastor()) {
0076     const HcalCastorDetId zdid(rawId());
0077     returnValue = HcalCastorDetId::validDetId(zdid.section(), zdid.zside() > 0, zdid.sector(), zdid.module());
0078   } else if (isCaloTower()) {
0079     edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
0080     throw cms::Exception("No support");
0081 
0082     returnValue = false;
0083   }
0084 
0085   return returnValue;
0086 }
0087 
0088 std::ostream& operator<<(std::ostream& s, const CaloGenericDetId& id) {
0089   if (id.isHcal()) {
0090     edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
0091     throw cms::Exception("No support");
0092   } else if (id.isCaloTower()) {
0093     edm::LogError("CaloGenericDetIdError") << "No support for CaloTower in CaloGenericDetId";
0094     throw cms::Exception("No support");
0095   }
0096 
0097   return (id.isEB()
0098               ? s << EBDetId(id)
0099               : (id.isEE() ? s << EEDetId(id)
0100                            : (id.isES() ? s << ESDetId(id)
0101                                         : (id.isZDC() ? s << HcalZDCDetId(id)
0102                                                       : s << "UnknownId=" << std::hex << id.rawId() << std::dec))));
0103 }