diff --git a/Geometry/HcalCommonData/interface/HcalGeomParameters.h b/Geometry/HcalCommonData/interface/HcalGeomParameters.h index 9796a5abda323..3e99a20357ca5 100644 --- a/Geometry/HcalCommonData/interface/HcalGeomParameters.h +++ b/Geometry/HcalCommonData/interface/HcalGeomParameters.h @@ -15,12 +15,11 @@ #include #include -#include "DetectorDescription/Core/interface/DDsvalues.h" +#include "DetectorDescription/Core/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "Geometry/HcalCommonData/interface/HcalCellType.h" #include "DataFormats/HcalDetId/interface/HcalSubdetector.h" -class DDCompactView; -class DDFilteredView; class HcalParameters; class HcalGeomParameters { @@ -28,21 +27,29 @@ class HcalGeomParameters { HcalGeomParameters(); ~HcalGeomParameters(); - double getConstDzHF() const { return dzVcal; } + double getConstDzHF() const { return dzVcal_; } void getConstRHO(std::vector&) const; std::vector getModHalfHBHE(const int type) const; void loadGeometry(const DDFilteredView& _fv, HcalParameters& php); + void loadGeometry(cms::DDFilteredView& fv, HcalParameters& php); private: unsigned find(int element, std::vector& array) const; double getEta(double r, double z) const; - - int nzHB, nmodHB; // Number of halves and modules in HB - int nzHE, nmodHE; // Number of halves and modules in HE - double etaHO[4], rminHO; // eta in HO ring boundaries - double zVcal; // Z-position of the front of HF - double dzVcal; // Half length of the HF - double dlShort; // Diference of length between long and short + void clear(HcalParameters& php); + void loadfinal(HcalParameters& php); + + int nzHB_, nmodHB_; // Number of halves and modules in HB + int nzHE_, nmodHE_; // Number of halves and modules in HE + double etaHO_[4], rminHO_; // eta in HO ring boundaries + double zVcal_; // Z-position of the front of HF + double dzVcal_; // Half length of the HF + double dlShort_; // Diference of length between long and short + static const int maxLayer_ = 20; + static const int kHELayer1_ = 21, kHELayer2_ = 71; + std::vector rb_, ze_, thkb_, thke_; + std::vector ib_, ie_, izb_, phib_, ize_, phie_; + std::vector rxb_, rminHE_, rmaxHE_; }; #endif diff --git a/Geometry/HcalCommonData/interface/HcalParametersFromDD.h b/Geometry/HcalCommonData/interface/HcalParametersFromDD.h index 4a1664ea74281..605f1075dc9b0 100644 --- a/Geometry/HcalCommonData/interface/HcalParametersFromDD.h +++ b/Geometry/HcalCommonData/interface/HcalParametersFromDD.h @@ -11,7 +11,7 @@ class HcalParametersFromDD { HcalParametersFromDD() = default; bool build(const DDCompactView*, HcalParameters&); - bool build(const cms::DDCompactView*, HcalParameters&) { return true; } + bool build(const cms::DDCompactView*, HcalParameters&); private: bool build(const HcalParameters&); diff --git a/Geometry/HcalCommonData/src/HcalGeomParameters.cc b/Geometry/HcalCommonData/src/HcalGeomParameters.cc index 75586449b6174..61f957a9e490b 100644 --- a/Geometry/HcalCommonData/src/HcalGeomParameters.cc +++ b/Geometry/HcalCommonData/src/HcalGeomParameters.cc @@ -3,23 +3,24 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDValue.h" #include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDConstant.h" #include "DetectorDescription/Core/interface/DDVectorGetter.h" -#include "DetectorDescription/Core/interface/DDFilteredView.h" #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h" #include "CondFormats/GeometryObjects/interface/HcalParameters.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; + +static const double tan10deg = std::tan(10._deg); HcalGeomParameters::HcalGeomParameters() { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::HcalGeomParameters ( const DDCompactView& cpv ) constructor"; + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::HcalGeomParameters (void) constructor"; #endif } @@ -30,81 +31,40 @@ HcalGeomParameters::~HcalGeomParameters() { } void HcalGeomParameters::getConstRHO(std::vector& rHO) const { - rHO.emplace_back(rminHO); - for (double i : etaHO) + rHO.emplace_back(rminHO_); + for (double i : etaHO_) rHO.emplace_back(i); } std::vector HcalGeomParameters::getModHalfHBHE(const int type) const { std::vector modHalf; if (type == 0) { - modHalf.emplace_back(nmodHB); - modHalf.emplace_back(nzHB); + modHalf.emplace_back(nmodHB_); + modHalf.emplace_back(nzHB_); } else { - modHalf.emplace_back(nmodHE); - modHalf.emplace_back(nzHE); + modHalf.emplace_back(nmodHE_); + modHalf.emplace_back(nzHE_); } return modHalf; } -unsigned int HcalGeomParameters::find(int element, std::vector& array) const { - unsigned int id = array.size(); - for (unsigned int i = 0; i < array.size(); i++) { - if (element == array[i]) { - id = i; - break; - } - } - return id; -} - -double HcalGeomParameters::getEta(double r, double z) const { - double tmp = 0; - if (z != 0) - tmp = -log(tan(0.5 * atan(r / z))); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::getEta " << r << " " << z << " ==> " << tmp; -#endif - return tmp; -} - void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& php) { DDFilteredView fv = _fv; bool dodet = true, hf = false; - std::vector rb(20, 0.0), ze(20, 0.0), thkb(20, -1.0), thke(20, -1.0); - std::vector ib(20, 0), ie(20, 0); - std::vector izb, phib, ize, phie; - std::vector rxb; -#ifdef EDM_ML_DEBUG - std::vector rminHE(20, 0.0), rmaxHE(20, 0.0); -#endif - php.rhoxHB.clear(); - php.zxHB.clear(); - php.dyHB.clear(); - php.dxHB.clear(); - php.layHB.clear(); - php.layHE.clear(); - php.zxHE.clear(); - php.rhoxHE.clear(); - php.dyHE.clear(); - php.dx1HE.clear(); - php.dx2HE.clear(); - dzVcal = -1.; + clear(php); while (dodet) { DDTranslation t = fv.translation(); std::vector copy = fv.copyNumbers(); const DDSolid& sol = fv.logicalPart().solid(); int idet = 0, lay = -1; - int nsiz = (int)(copy.size()); + int nsiz = static_cast(copy.size()); if (nsiz > 0) lay = copy[nsiz - 1] / 10; if (nsiz > 1) idet = copy[nsiz - 2] / 1000; double dx = 0, dy = 0, dz = 0, dx1 = 0, dx2 = 0; -#ifdef EDM_ML_DEBUG double alp(0); -#endif if (sol.shape() == DDSolidShape::ddbox) { const DDBox& box = static_cast(fv.logicalPart().solid()); dx = box.halfX(); @@ -117,9 +77,7 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& dx = 0.25 * (trp.x1() + trp.x2() + trp.x3() + trp.x4()); dy = 0.5 * (trp.y1() + trp.y2()); dz = trp.halfZ(); -#ifdef EDM_ML_DEBUG alp = 0.5 * (trp.alpha1() + trp.alpha2()); -#endif } else if (sol.shape() == DDSolidShape::ddtubs) { const DDTubs& tub = static_cast(fv.logicalPart().solid()); dx = tub.rIn(); @@ -132,25 +90,25 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& edm::LogVerbatim("HCalGeom") << "HB " << sol.name() << " Shape " << sol.shape() << " Layer " << lay << " R " << t.Rho(); #endif - if (lay >= 0 && lay < 20) { - ib[lay]++; - rb[lay] += t.Rho(); - if (thkb[lay] <= 0) { + if (lay >= 0 && lay < maxLayer_) { + ib_[lay]++; + rb_[lay] += t.Rho(); + if (thkb_[lay] <= 0) { if (lay < 17) - thkb[lay] = dx; + thkb_[lay] = dx; else - thkb[lay] = std::min(dx, dy); + thkb_[lay] = std::min(dx, dy); } if (lay < 17) { bool found = false; - for (double k : rxb) { + for (double k : rxb_) { if (std::abs(k - t.Rho()) < 0.01) { found = true; break; } } if (!found) { - rxb.emplace_back(t.Rho()); + rxb_.emplace_back(t.Rho()); php.rhoxHB.emplace_back(t.Rho() * std::cos(t.phi())); php.zxHB.emplace_back(std::abs(t.z())); php.dyHB.emplace_back(2. * dy); @@ -162,12 +120,12 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& if (lay == 2) { int iz = copy[nsiz - 5]; int fi = copy[nsiz - 4]; - unsigned int it1 = find(iz, izb); - if (it1 == izb.size()) - izb.emplace_back(iz); - unsigned int it2 = find(fi, phib); - if (it2 == phib.size()) - phib.emplace_back(fi); + unsigned int it1 = find(iz, izb_); + if (it1 == izb_.size()) + izb_.emplace_back(iz); + unsigned int it2 = find(fi, phib_); + if (it2 == phib_.size()) + phib_.emplace_back(fi); } if (lay == 18) { int ifi = -1, ich = -1; @@ -218,17 +176,15 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& edm::LogVerbatim("HCalGeom") << "HE " << sol.name() << " Shape " << sol.shape() << " Layer " << lay << " Z " << t.z(); #endif - if (lay >= 0 && lay < 20) { - ie[lay]++; - ze[lay] += std::abs(t.z()); - if (thke[lay] <= 0) - thke[lay] = dz; -#ifdef EDM_ML_DEBUG + if (lay >= 0 && lay < maxLayer_) { + ie_[lay]++; + ze_[lay] += std::abs(t.z()); + if (thke_[lay] <= 0) + thke_[lay] = dz; double rinHE = t.Rho() * cos(alp) - dy; double routHE = t.Rho() * cos(alp) + dy; - rminHE[lay] += rinHE; - rmaxHE[lay] += routHE; -#endif + rminHE_[lay] += rinHE; + rmaxHE_[lay] += routHE; bool found = false; for (double k : php.zxHE) { if (std::abs(k - std::abs(t.z())) < 0.01) { @@ -240,22 +196,22 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& php.zxHE.emplace_back(std::abs(t.z())); php.rhoxHE.emplace_back(t.Rho() * std::cos(t.phi())); php.dyHE.emplace_back(dy * std::cos(t.phi())); - dx1 -= 0.5 * (t.rho() - dy) * std::cos(t.phi()) * std::tan(10 * CLHEP::deg); - dx2 -= 0.5 * (t.rho() + dy) * std::cos(t.phi()) * std::tan(10 * CLHEP::deg); + dx1 -= 0.5 * (t.rho() - dy) * std::cos(t.phi()) * tan10deg; + dx2 -= 0.5 * (t.rho() + dy) * std::cos(t.phi()) * tan10deg; php.dx1HE.emplace_back(-dx1); php.dx2HE.emplace_back(-dx2); php.layHE.emplace_back(lay); } } - if (copy[nsiz - 1] == 21 || copy[nsiz - 1] == 71) { + if (copy[nsiz - 1] == kHELayer1_ || copy[nsiz - 1] == kHELayer2_) { int iz = copy[nsiz - 7]; int fi = copy[nsiz - 5]; - unsigned int it1 = find(iz, ize); - if (it1 == ize.size()) - ize.emplace_back(iz); - unsigned int it2 = find(fi, phie); - if (it2 == phie.size()) - phie.emplace_back(fi); + unsigned int it1 = find(iz, ize_); + if (it1 == ize_.size()) + ize_.emplace_back(iz); + unsigned int it2 = find(fi, phie_); + if (it2 == phie_.size()) + phie_.emplace_back(fi); } } else if (idet == 5) { // HF @@ -269,10 +225,10 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& #endif if (sol.shape() == DDSolidShape::ddpolycone_rrz) { int nz = (int)(paras.size()) - 3; - dzVcal = 0.5 * (paras[nz] - paras[3]); + dzVcal_ = 0.5 * (paras[nz] - paras[3]); hf = true; } else if (sol.shape() == DDSolidShape::ddtubs || sol.shape() == DDSolidShape::ddcons) { - dzVcal = paras[0]; + dzVcal_ = paras[0]; hf = true; } } @@ -285,58 +241,303 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& dodet = fv.next(); } + loadfinal(php); +} + +void HcalGeomParameters::loadGeometry(cms::DDFilteredView& fv, HcalParameters& php) { + clear(php); + bool dodet = fv.firstChild(); + bool hf(false); + while (dodet) { + auto t = fv.translation(); + std::vector paras = fv.parameters(); + std::vector copy = fv.history().copyNos; + int idet = 0, lay = -1; + int nsiz = static_cast(copy.size()); + if (nsiz > 0) + lay = copy[nsiz - 1] / 10; + if (nsiz > 1) + idet = copy[nsiz - 2] / 1000; + double dx = 0, dy = 0, dz = 0, dx1 = 0, dx2 = 0; + double alp(0); + if (fv.isA()) { + dx = paras[0]; + dy = paras[1]; + dz = paras[2]; + } else if (fv.isA()) { + dx1 = paras[4]; + dx2 = paras[5]; + dx = 0.25 * (paras[4] + paras[5] + paras[8] + paras[9]); + dy = 0.5 * (paras[3] + paras[7]); + dz = paras[0]; + alp = 0.5 * (paras[6] + paras[10]); + } else if (fv.isA()) { + dx = paras[0]; + dy = paras[1]; + dz = paras[2]; + } + if (idet == 3) { + // HB +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "HB " << fv.name() << " Shape " //<< fv.shape() + << " Layer " << lay << " R " << t.Rho(); +#endif + if (lay >= 0 && lay < maxLayer_) { + ib_[lay]++; + rb_[lay] += t.Rho(); + if (thkb_[lay] <= 0) { + if (lay < 17) + thkb_[lay] = dx; + else + thkb_[lay] = std::min(dx, dy); + } + if (lay < 17) { + bool found = false; + for (double k : rxb_) { + if (std::abs(k - t.Rho()) < 0.01) { + found = true; + break; + } + } + if (!found) { + rxb_.emplace_back(t.Rho()); + php.rhoxHB.emplace_back(t.Rho() * std::cos(t.phi())); + php.zxHB.emplace_back(std::abs(t.z())); + php.dyHB.emplace_back(2. * dy); + php.dxHB.emplace_back(2. * dz); + php.layHB.emplace_back(lay); + } + } + } + if (lay == 2) { + int iz = copy[nsiz - 5]; + int fi = copy[nsiz - 4]; + unsigned int it1 = find(iz, izb_); + if (it1 == izb_.size()) + izb_.emplace_back(iz); + unsigned int it2 = find(fi, phib_); + if (it2 == phib_.size()) + phib_.emplace_back(fi); + } + if (lay == 18) { + int ifi = -1, ich = -1; + if (nsiz > 2) + ifi = copy[nsiz - 3]; + if (nsiz > 3) + ich = copy[nsiz - 4]; + double z1 = std::abs((t.z()) + dz); + double z2 = std::abs((t.z()) - dz); + if (std::abs(z1 - z2) < 0.01) + z1 = 0; + if (ifi == 1 && ich == 4) { + if (z1 > z2) { + double tmp = z1; + z1 = z2; + z2 = tmp; + } + bool sok = true; + for (unsigned int kk = 0; kk < php.zHO.size(); kk++) { + if (std::abs(z2 - php.zHO[kk]) < 0.01) { + sok = false; + break; + } else if (z2 < php.zHO[kk]) { + php.zHO.resize(php.zHO.size() + 2); + for (unsigned int kz = php.zHO.size() - 1; kz > kk + 1; kz = kz - 2) { + php.zHO[kz] = php.zHO[kz - 2]; + php.zHO[kz - 1] = php.zHO[kz - 3]; + } + php.zHO[kk + 1] = z2; + php.zHO[kk] = z1; + sok = false; + break; + } + } + if (sok) { + php.zHO.emplace_back(z1); + php.zHO.emplace_back(z2); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "Detector " << idet << " Lay " << lay << " fi " << ifi << " " << ich << " z " + << z1 << " " << z2; +#endif + } + } + } else if (idet == 4) { + // HE +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "HE " << fv.name() << " Shape " //<< fv.shape() + << " Layer " << lay << " Z " << t.z(); +#endif + if (lay >= 0 && lay < maxLayer_) { + ie_[lay]++; + ze_[lay] += std::abs(t.z()); + if (thke_[lay] <= 0) + thke_[lay] = dz; + double rinHE = t.Rho() * cos(alp) - dy; + double routHE = t.Rho() * cos(alp) + dy; + rminHE_[lay] += rinHE; + rmaxHE_[lay] += routHE; + bool found = false; + for (double k : php.zxHE) { + if (std::abs(k - std::abs(t.z())) < 0.01) { + found = true; + break; + } + } + if (!found) { + php.zxHE.emplace_back(std::abs(t.z())); + php.rhoxHE.emplace_back(t.Rho() * std::cos(t.phi())); + php.dyHE.emplace_back(dy * std::cos(t.phi())); + dx1 -= 0.5 * (t.Rho() - dy) * std::cos(t.phi()) * tan10deg; + dx2 -= 0.5 * (t.Rho() + dy) * std::cos(t.phi()) * tan10deg; + php.dx1HE.emplace_back(-dx1); + php.dx2HE.emplace_back(-dx2); + php.layHE.emplace_back(lay); + } + } + if (copy[nsiz - 1] == kHELayer1_ || copy[nsiz - 1] == kHELayer2_) { + int iz = copy[nsiz - 7]; + int fi = copy[nsiz - 5]; + unsigned int it1 = find(iz, ize_); + if (it1 == ize_.size()) + ize_.emplace_back(iz); + unsigned int it2 = find(fi, phie_); + if (it2 == phie_.size()) + phie_.emplace_back(fi); + } + } else if (idet == 5) { + // HF + if (!hf) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "HF " << fv.name() << " Shape " //<< fv.shape() + << " Z " << t.z() << " with " << paras.size() << " Parameters"; + for (unsigned j = 0; j < paras.size(); j++) + edm::LogVerbatim("HCalGeom") << "HF Parameter[" << j << "] = " << paras[j]; +#endif + if (fv.isA()) { + int nz = (int)(paras.size()) - 3; + dzVcal_ = 0.5 * (paras[nz] - paras[3]); + hf = true; + } else if (fv.isATubeSeg() || fv.isAConeSeg()) { + dzVcal_ = paras[0]; + hf = true; + } + } +#ifdef EDM_ML_DEBUG + } else { + edm::LogVerbatim("HCalGeom") << "Unknown Detector " << idet << " for " << fv.name() << " Shape " //<< fv.shape() + << " R " << t.Rho() << " Z " << t.z(); +#endif + } + dodet = fv.nextSibling(); + } + loadfinal(php); +} + +unsigned int HcalGeomParameters::find(int element, std::vector& array) const { + unsigned int id = array.size(); + for (unsigned int i = 0; i < array.size(); i++) { + if (element == array[i]) { + id = i; + break; + } + } + return id; +} + +double HcalGeomParameters::getEta(double r, double z) const { + double tmp = 0; + if (z != 0) + tmp = -log(tan(0.5 * atan(r / z))); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::getEta " << r << " " << z << " ==> " << tmp; +#endif + return tmp; +} + +void HcalGeomParameters::clear(HcalParameters& php) { + php.rhoxHB.clear(); + php.zxHB.clear(); + php.dyHB.clear(); + php.dxHB.clear(); + php.layHB.clear(); + php.layHE.clear(); + php.zxHE.clear(); + php.rhoxHE.clear(); + php.dyHE.clear(); + php.dx1HE.clear(); + php.dx2HE.clear(); + + // Initialize all variables + nzHB_ = nmodHB_ = 0; + nzHE_ = nmodHE_ = 0; + for (int i = 0; i < 4; ++i) + etaHO_[i] = 0; + zVcal_ = dzVcal_ = dlShort_ = 0; + rminHO_ = dzVcal_ = -1.; + for (int i = 0; i < maxLayer_; ++i) { + rb_.emplace_back(0.0); + ze_.emplace_back(0.0); + thkb_.emplace_back(-1.0); + thke_.emplace_back(-1.0); + ib_.emplace_back(0); + ie_.emplace_back(0); + rminHE_.emplace_back(0.0); + rmaxHE_.emplace_back(0.0); + } +} + +void HcalGeomParameters::loadfinal(HcalParameters& php) { int ibmx = 0, iemx = 0; - for (int i = 0; i < 20; i++) { - if (ib[i] > 0) { - rb[i] /= (double)(ib[i]); + for (int i = 0; i < maxLayer_; i++) { + if (ib_[i] > 0) { + rb_[i] /= static_cast(ib_[i]); ibmx = i + 1; } - if (ie[i] > 0) { - ze[i] /= (double)(ie[i]); + if (ie_[i] > 0) { + ze_[i] /= static_cast(ie_[i]); + rminHE_[i] /= static_cast(ie_[i]); + rmaxHE_[i] /= static_cast(ie_[i]); iemx = i + 1; } #ifdef EDM_ML_DEBUG - if (ie[i] > 0) { - rminHE[i] /= (double)(ie[i]); - rmaxHE[i] /= (double)(ie[i]); - } - edm::LogVerbatim("HCalGeom") << "Index " << i << " Barrel " << ib[i] << " " << rb[i] << " Endcap " << ie[i] << " " - << ze[i] << ":" << rminHE[i] << ":" << rmaxHE[i]; + edm::LogVerbatim("HCalGeom") << "Index " << i << " Barrel " << ib_[i] << " " << rb_[i] << " Endcap " << ie_[i] + << " " << ze_[i] << ":" << rminHE_[i] << ":" << rmaxHE_[i]; #endif } for (int i = 4; i >= 0; i--) { - if (ib[i] == 0) { - rb[i] = rb[i + 1]; - thkb[i] = thkb[i + 1]; + if (ib_[i] == 0) { + rb_[i] = rb_[i + 1]; + thkb_[i] = thkb_[i + 1]; } - if (ie[i] == 0) { - ze[i] = ze[i + 1]; - thke[i] = thke[i + 1]; + if (ie_[i] == 0) { + ze_[i] = ze_[i + 1]; + thke_[i] = thke_[i + 1]; } #ifdef EDM_ML_DEBUG - if (ib[i] == 0 || ie[i] == 0) - edm::LogVerbatim("HCalGeom") << "Index " << i << " Barrel " << ib[i] << " " << rb[i] << " Endcap " << ie[i] << " " - << ze[i]; + if (ib_[i] == 0 || ie_[i] == 0) + edm::LogVerbatim("HCalGeom") << "Index " << i << " Barrel " << ib_[i] << " " << rb_[i] << " Endcap " << ie_[i] + << " " << ze_[i]; #endif } #ifdef EDM_ML_DEBUG for (unsigned int k = 0; k < php.layHB.size(); ++k) - edm::LogVerbatim("HCalGeom") << "HB: " << php.layHB[k] << " R " << rxb[k] << " " << php.rhoxHB[k] << " Z " + edm::LogVerbatim("HCalGeom") << "HB: " << php.layHB[k] << " R " << rxb_[k] << " " << php.rhoxHB[k] << " Z " << php.zxHB[k] << " DY " << php.dyHB[k] << " DZ " << php.dxHB[k]; for (unsigned int k = 0; k < php.layHE.size(); ++k) edm::LogVerbatim("HCalGeom") << "HE: " << php.layHE[k] << " R " << php.rhoxHE[k] << " Z " << php.zxHE[k] << " X1|X2 " << php.dx1HE[k] << "|" << php.dx2HE[k] << " DY " << php.dyHE[k]; edm::LogVerbatim("HCalGeom") << "HcalGeomParameters: Maximum Layer for HB " << ibmx << " for HE " << iemx - << " extent " << dzVcal; + << " extent " << dzVcal_; #endif if (ibmx > 0) { php.rHB.resize(ibmx); php.drHB.resize(ibmx); for (int i = 0; i < ibmx; i++) { - php.rHB[i] = rb[i]; - php.drHB[i] = thkb[i]; + php.rHB[i] = rb_[i]; + php.drHB[i] = thkb_[i]; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "HcalGeomParameters: php.rHB[" << i << "] = " << php.rHB[i] << " php.drHB[" << i << "] = " << php.drHB[i]; @@ -347,8 +548,8 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& php.zHE.resize(iemx); php.dzHE.resize(iemx); for (int i = 0; i < iemx; i++) { - php.zHE[i] = ze[i]; - php.dzHE[i] = thke[i]; + php.zHE[i] = ze_[i]; + php.dzHE[i] = thke_[i]; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "HcalGeomParameters: php.zHE[" << i << "] = " << php.zHE[i] << " php.dzHE[" << i << "] = " << php.dzHE[i]; @@ -356,26 +557,26 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& } } - nzHB = (int)(izb.size()); - nmodHB = (int)(phib.size()); + nzHB_ = static_cast(izb_.size()); + nmodHB_ = static_cast(phib_.size()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nzHB << " barrel half-sectors"; - for (int i = 0; i < nzHB; i++) - edm::LogVerbatim("HCalGeom") << "Section " << i << " Copy number " << izb[i]; - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nmodHB << " barrel modules"; - for (int i = 0; i < nmodHB; i++) - edm::LogVerbatim("HCalGeom") << "Module " << i << " Copy number " << phib[i]; + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nzHB_ << " barrel half-sectors"; + for (int i = 0; i < nzHB_; i++) + edm::LogVerbatim("HCalGeom") << "Section " << i << " Copy number " << izb_[i]; + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nmodHB_ << " barrel modules"; + for (int i = 0; i < nmodHB_; i++) + edm::LogVerbatim("HCalGeom") << "Module " << i << " Copy number " << phib_[i]; #endif - nzHE = (int)(ize.size()); - nmodHE = (int)(phie.size()); + nzHE_ = static_cast(ize_.size()); + nmodHE_ = static_cast(phie_.size()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nzHE << " endcap half-sectors"; - for (int i = 0; i < nzHE; i++) - edm::LogVerbatim("HCalGeom") << "Section " << i << " Copy number " << ize[i]; - edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nmodHE << " endcap modules"; - for (int i = 0; i < nmodHE; i++) - edm::LogVerbatim("HCalGeom") << "Module " << i << " Copy number " << phie[i]; + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nzHE_ << " endcap half-sectors"; + for (int i = 0; i < nzHE_; i++) + edm::LogVerbatim("HCalGeom") << "Section " << i << " Copy number " << ize_[i]; + edm::LogVerbatim("HCalGeom") << "HcalGeomParameters::loadGeometry: " << nmodHE_ << " endcap modules"; + for (int i = 0; i < nmodHE_; i++) + edm::LogVerbatim("HCalGeom") << "Module " << i << " Copy number " << phie_[i]; #endif #ifdef EDM_ML_DEBUG @@ -384,19 +585,16 @@ void HcalGeomParameters::loadGeometry(const DDFilteredView& _fv, HcalParameters& edm::LogVerbatim("HCalGeom") << "ZHO[" << kk << "] = " << php.zHO[kk]; #endif if (ibmx > 17 && php.zHO.size() > 4) { - rminHO = php.rHB[17] - 100.0; - etaHO[0] = getEta(0.5 * (php.rHB[17] + php.rHB[18]), php.zHO[1]); - etaHO[1] = getEta(php.rHB[18] + php.drHB[18], php.zHO[2]); - etaHO[2] = getEta(php.rHB[18] - php.drHB[18], php.zHO[3]); - etaHO[3] = getEta(php.rHB[18] + php.drHB[18], php.zHO[4]); - } else { - rminHO = -1.0; - etaHO[0] = etaHO[1] = etaHO[2] = etaHO[3] = 0; + rminHO_ = php.rHB[17] - 100.0; + etaHO_[0] = getEta(0.5 * (php.rHB[17] + php.rHB[18]), php.zHO[1]); + etaHO_[1] = getEta(php.rHB[18] + php.drHB[18], php.zHO[2]); + etaHO_[2] = getEta(php.rHB[18] - php.drHB[18], php.zHO[3]); + etaHO_[3] = getEta(php.rHB[18] + php.drHB[18], php.zHO[4]); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HCalGeom") << "HO Eta boundaries " << etaHO[0] << " " << etaHO[1] << " " << etaHO[2] << " " - << etaHO[3]; - edm::LogVerbatim("HCalGeom") << "HO Parameters " << rminHO << " " << php.zHO.size(); + edm::LogVerbatim("HCalGeom") << "HO Eta boundaries " << etaHO_[0] << " " << etaHO_[1] << " " << etaHO_[2] << " " + << etaHO_[3]; + edm::LogVerbatim("HCalGeom") << "HO Parameters " << rminHO_ << " " << php.zHO.size(); for (unsigned int i = 0; i < php.zHO.size(); ++i) edm::LogVerbatim("HCalGeom") << " zho[" << i << "] = " << php.zHO[i]; #endif diff --git a/Geometry/HcalCommonData/src/HcalParametersFromDD.cc b/Geometry/HcalCommonData/src/HcalParametersFromDD.cc index fa66dc34e7aaa..d613cd11efd2b 100644 --- a/Geometry/HcalCommonData/src/HcalParametersFromDD.cc +++ b/Geometry/HcalCommonData/src/HcalParametersFromDD.cc @@ -8,11 +8,10 @@ #include "DetectorDescription/Core/interface/DDutils.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include #include -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG using namespace geant_units::operators; namespace { @@ -39,9 +38,26 @@ namespace { throw cms::Exception("HcalParametersFromDD") << "Failed to get " << s << " tag."; } } + + int getTopologyMode(const std::string& s, bool type) { + int result(-1); + if (type) { + StringToEnumParser eparser; + HcalTopologyMode::Mode mode = (HcalTopologyMode::Mode)eparser.parseString(s); + result = static_cast(mode); + } else { + StringToEnumParser eparser; + HcalTopologyMode::TriggerMode mode = (HcalTopologyMode::TriggerMode)eparser.parseString(s); + result = static_cast(mode); + } + return result; + } } // namespace bool HcalParametersFromDD::build(const DDCompactView* cpv, HcalParameters& php) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::build(const DDCompactView*, HcalParameters&) is called"; +#endif //Special parameters at simulation level std::string attribute = "OnlyForHcalSimNumbering"; DDSpecificsHasNamedValueFilter filter1{attribute}; @@ -128,134 +144,278 @@ bool HcalParametersFromDD::build(const DDCompactView* cpv, HcalParameters& php) return build(php); } -bool HcalParametersFromDD::build(const HcalParameters& php) { +bool HcalParametersFromDD::build(const cms::DDCompactView* cpv, HcalParameters& php) { #ifdef EDM_ML_DEBUG - int i(0); - std::stringstream ss0; - for (unsigned int it = 0; it < php.maxDepth.size(); it++) { - if (it / 10 * 10 == it) { - ss0 << "\n"; + edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::build(const cms::DDCompactView*, HcalParameters&) is called"; +#endif + //Special parameters at simulation level + cms::DDFilteredView fv1(cpv->detector(), cpv->detector()->worldVolume()); + cms::DDVectorsMap vmap = cpv->detector()->vectors(); + std::string attribute = "OnlyForHcalSimNumbering"; + cms::DDSpecParRefs ref1; + const cms::DDSpecParRegistry& mypar1 = cpv->specpars(); + mypar1.filter(ref1, attribute, "HCAL"); + fv1.mergedSpecifics(ref1); + + const int nEtaMax = 100; + + if (fv1.firstChild()) { + std::unique_ptr geom = std::make_unique(); + geom->loadGeometry(fv1, php); + php.modHB = geom->getModHalfHBHE(0); + php.modHE = geom->getModHalfHBHE(1); + php.dzVcal = geom->getConstDzHF(); + geom->getConstRHO(php.rHO); + + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "phioff")) { + for (const auto& i : it.second) + php.phioff.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "etaTable")) { + for (const auto& i : it.second) + php.etaTable.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "rTable")) { + for (const auto& i : it.second) + php.rTable.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "phibin")) { + for (const auto& i : it.second) + php.phibin.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "phitable")) { + for (const auto& i : it.second) + php.phitable.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "etaMin")) { + for (const auto& i : it.second) + php.etaMin.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "etaMax")) { + for (const auto& i : it.second) + php.etaMax.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "etaRange")) { + for (const auto& i : it.second) + php.etaRange.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "gparHF")) { + for (const auto& i : it.second) + php.gparHF.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "noff")) { + for (const auto& i : it.second) + php.noff.emplace_back(std::round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "Layer0Wt")) { + for (const auto& i : it.second) + php.Layer0Wt.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HBGains")) { + for (const auto& i : it.second) + php.HBGains.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HBShift")) { + for (const auto& i : it.second) + php.HBShift.emplace_back(round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HEBGains")) { + for (const auto& i : it.second) + php.HEGains.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HEShift")) { + for (const auto& i : it.second) + php.HEShift.emplace_back(round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HFGains")) { + for (const auto& i : it.second) + php.HFGains.emplace_back(i); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "HFShift")) { + for (const auto& i : it.second) + php.HFShift.emplace_back(round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "maxDepth")) { + for (const auto& i : it.second) + php.maxDepth.emplace_back(round(i)); + } } - ss0 << " [" << it << "] " << php.maxDepth[it]; - } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::maxDepth: " << php.maxDepth.size() << ": " << ss0.str(); - std::stringstream ss1; - for (unsigned int it = 0; it < php.modHB.size(); it++) { - if (it / 10 * 10 == it) { - ss1 << "\n"; + for (unsigned int i = 1; i <= nEtaMax; ++i) { + std::stringstream sstm; + sstm << "layerGroupSimEta" << i; + std::string tempName = sstm.str(); + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), tempName)) { + HcalParameters::LayerItem layerGroupEta; + layerGroupEta.layer = i; + for (const auto& i : it.second) + layerGroupEta.layerGroup.emplace_back(round(i)); + php.layerGroupEtaSim.emplace_back(layerGroupEta); + break; + } + } + php.etaMin[0] = 1; + if (php.etaMax[1] >= php.etaMin[1]) + php.etaMax[1] = static_cast(php.etaTable.size()) - 1; + php.etaMax[2] = php.etaMin[2] + static_cast(php.rTable.size()) - 2; } - ss1 << " [" << it << "] " << php.modHB[it]; + } else { + throw cms::Exception("HcalParametersFromDD") << "Not found " << attribute.c_str() << " but needed."; } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::modHB: " << php.modHB.size() << ": " << ss1.str(); - std::stringstream ss2; - for (unsigned int it = 0; it < php.modHE.size(); it++) { - if (it / 10 * 10 == it) { - ss2 << "\n"; - } - ss2 << " [" << it << "] " << php.modHE[it]; + for (unsigned int i = 0; i < php.rTable.size(); ++i) { + unsigned int k = php.rTable.size() - i - 1; + php.etaTableHF.emplace_back(-log(tan(0.5 * atan(php.rTable[k] / php.gparHF[4])))); } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::modHE: " << php.modHE.size() << ": " << ss2.str(); - std::stringstream ss3; - for (unsigned int it = 0; it < php.phioff.size(); it++) { - if (it / 10 * 10 == it) { - ss3 << "\n"; + + //Special parameters at reconstruction level + cms::DDFilteredView fv2(cpv->detector(), cpv->detector()->worldVolume()); + attribute = "OnlyForHcalRecNumbering"; + cms::DDSpecParRefs ref2; + const cms::DDSpecParRegistry& mypar2 = cpv->specpars(); + mypar2.filter(ref2, attribute, "HCAL"); + fv2.mergedSpecifics(ref2); + if (fv2.firstChild()) { + std::vector tempS = fv2.get >("hcal", "TopologyMode"); + std::string sv = (!tempS.empty()) ? tempS[0] : "HcalTopologyMode::SLHC"; + int topoMode = getTopologyMode(sv, true); + tempS = fv2.get >("hcal", "TriggerMode"); + sv = (!tempS.empty()) ? tempS[0] : "HcalTopologyMode::TriggerMode_2021"; + int trigMode = getTopologyMode(sv, false); + php.topologyMode = ((trigMode & 0xFF) << 8) | (topoMode & 0xFF); + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "etagroup")) { + for (const auto& i : it.second) + php.etagroup.emplace_back(round(i)); + } else if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), "phigroup")) { + for (const auto& i : it.second) + php.phigroup.emplace_back(round(i)); + } } - ss3 << " [" << it << "] " << convertRadToDeg(php.phioff[it]); - } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::phiOff: " << php.phioff.size() << ": " << ss3.str(); - std::stringstream ss4; - for (unsigned int it = 0; it < php.etaTable.size(); it++) { - if (it / 10 * 10 == it) { - ss4 << "\n"; + for (unsigned int i = 1; i <= nEtaMax; ++i) { + std::stringstream sstm; + sstm << "layerGroupRecEta" << i; + std::string tempName = sstm.str(); + for (auto const& it : vmap) { + if (cms::dd::compareEqual(cms::dd::noNamespace(it.first), tempName)) { + HcalParameters::LayerItem layerGroupEta; + layerGroupEta.layer = i; + for (const auto& i : it.second) + layerGroupEta.layerGroup.emplace_back(round(i)); + php.layerGroupEtaRec.emplace_back(layerGroupEta); + break; + } + } } - ss4 << " [" << it << "] " << php.etaTable[it]; + } else { + throw cms::Exception("HcalParametersFromDD") << "Not found " << attribute.c_str() << " but needed."; } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::etaTable: " << php.etaTable.size() << ": " << ss4.str(); + + return build(php); +} + +bool HcalParametersFromDD::build(const HcalParameters& php) { +#ifdef EDM_ML_DEBUG + int i(0); + std::stringstream ss0; + ss0 << "HcalParametersFromDD: MaxDepth[" << php.maxDepth.size() << "]: "; + for (const auto& it : php.maxDepth) + ss0 << it << ", "; + edm::LogVerbatim("HCalGeom") << ss0.str(); + std::stringstream ss1; + ss1 << "HcalParametersFromDD: ModHB [" << php.modHB.size() << "]: "; + for (const auto& it : php.modHB) + ss1 << it << ", "; + edm::LogVerbatim("HCalGeom") << ss1.str(); + std::stringstream ss2; + ss2 << "HcalParametersFromDD: ModHE [" << php.modHE.size() << "]: "; + for (const auto& it : php.modHE) + ss2 << it << ", "; + edm::LogVerbatim("HCalGeom") << ss2.str(); + std::stringstream ss3; + ss3 << "HcalParametersFromDD: " << php.phioff.size() << " phioff values:"; + std::vector::const_iterator it; + for (it = php.phioff.begin(), i = 0; it != php.phioff.end(); ++it) + ss3 << " [" << ++i << "] = " << convertRadToDeg(*it); + edm::LogVerbatim("HCalGeom") << ss3.str(); + std::stringstream ss4; + ss4 << "HcalParametersFromDD: " << php.etaTable.size() << " entries for etaTable:"; + for (it = php.etaTable.begin(), i = 0; it != php.etaTable.end(); ++it) + ss4 << " [" << ++i << "] = " << (*it); + edm::LogVerbatim("HCalGeom") << ss4.str(); std::stringstream ss5; - for (unsigned int it = 0; it < php.rTable.size(); it++) { - if (it / 10 * 10 == it) { - ss5 << "\n"; - } - ss5 << " [" << it << "] " << convertMmToCm(php.rTable[it]); - } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD::rTable: " << php.rTable.size() << ": " << ss5.str(); + ss5 << "HcalParametersFromDD: " << php.rTable.size() << " entries for rTable:"; + for (it = php.rTable.begin(), i = 0; it != php.rTable.end(); ++it) + ss5 << " [" << ++i << "] = " << convertMmToCm(*it); + edm::LogVerbatim("HCalGeom") << ss5.str(); std::stringstream ss6; - for (unsigned int it = 0; it < php.phibin.size(); it++) { - if (it / 10 * 10 == it) { - ss6 << "\n"; - } - ss6 << " [" << it << "] " << convertRadToDeg(php.phibin[it]); - } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD:phibin: " << php.phibin.size() << ": " << ss6.str(); + ss6 << "HcalParametersFromDD: " << php.phibin.size() << " phibin values:"; + for (it = php.phibin.begin(), i = 0; it != php.phibin.end(); ++it) + ss6 << " [" << ++i << "] = " << convertRadToDeg(*it); + edm::LogVerbatim("HCalGeom") << ss6.str(); std::stringstream ss7; - for (unsigned int it = 0; it < php.phitable.size(); it++) { - if (it / 10 * 10 == it) { - ss7 << "\n"; - } - ss7 << " [" << it << "] " << convertRadToDeg(php.phitable[it]); - } - edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD:phitable: " << php.phitable.size() << ": " << ss7.str(); - std::cout << "HcalParametersFromDD: " << php.layerGroupEtaSim.size() << " layerGroupEtaSim blocks" << std::endl; + ss7 << "HcalParametersFromDD: " << php.phitable.size() << " phitable values:"; + for (it = php.phitable.begin(), i = 0; it != php.phitable.end(); ++it) + ss7 << " [" << ++i << "] = " << convertRadToDeg(*it); + edm::LogVerbatim("HCalGeom") << ss7.str(); + edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD: " << php.layerGroupEtaSim.size() << " layerGroupEtaSim blocks" + << std::endl; std::vector::const_iterator kt; - std::vector::const_iterator it; for (unsigned int k = 0; k < php.layerGroupEtaSim.size(); ++k) { - std::cout << "layerGroupEtaSim[" << k << "] Layer " << php.layerGroupEtaSim[k].layer; + std::stringstream ss8; + ss8 << "layerGroupEtaSim[" << k << "] Layer " << php.layerGroupEtaSim[k].layer; for (kt = php.layerGroupEtaSim[k].layerGroup.begin(), i = 0; kt != php.layerGroupEtaSim[k].layerGroup.end(); ++kt) - std::cout << " " << ++i << ":" << (*kt); - std::cout << std::endl; + ss8 << " " << ++i << ":" << (*kt); + edm::LogVerbatim("HCalGeom") << ss8.str(); } - std::cout << "HcalParametersFromDD: " << php.etaMin.size() << " etaMin values"; + std::stringstream ss8; + ss8 << "HcalParametersFromDD: " << php.etaMin.size() << " etaMin values:"; for (kt = php.etaMin.begin(), i = 0; kt != php.etaMin.end(); ++kt) - std::cout << " [" << ++i << "] = " << (*kt); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.etaMax.size() << " etaMax values"; + ss8 << " [" << ++i << "] = " << (*kt); + edm::LogVerbatim("HCalGeom") << ss8.str(); + std::stringstream ss9; + ss9 << "HcalParametersFromDD: " << php.etaMax.size() << " etaMax values:"; for (kt = php.etaMax.begin(), i = 0; kt != php.etaMax.end(); ++kt) - std::cout << " [" << ++i << "] = " << (*kt); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.etaRange.size() << " etaRange values"; + ss9 << " [" << ++i << "] = " << (*kt); + edm::LogVerbatim("HCalGeom") << ss9.str(); + std::stringstream ss10; + ss10 << "HcalParametersFromDD: " << php.etaRange.size() << " etaRange values:"; for (it = php.etaRange.begin(), i = 0; it != php.etaRange.end(); ++it) - std::cout << " [" << ++i << "] = " << (*it); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.gparHF.size() << " gparHF values"; + ss10 << " [" << ++i << "] = " << (*it); + edm::LogVerbatim("HCalGeom") << ss10.str(); + std::stringstream ss11; + ss11 << "HcalParametersFromDD: " << php.gparHF.size() << " gparHF values:"; for (it = php.gparHF.begin(), i = 0; it != php.gparHF.end(); ++it) - std::cout << " [" << ++i << "] = " << (*it) / CLHEP::cm; - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.noff.size() << " noff values"; + ss11 << " [" << ++i << "] = " << convertMmToCm(*it); + edm::LogVerbatim("HCalGeom") << ss11.str(); + std::stringstream ss12; + ss12 << "HcalParametersFromDD: " << php.noff.size() << " noff values:"; for (kt = php.noff.begin(), i = 0; kt != php.noff.end(); ++kt) - std::cout << " [" << ++i << "] = " << (*kt); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.Layer0Wt.size() << " Layer0Wt values"; + ss12 << " [" << ++i << "] = " << (*kt); + edm::LogVerbatim("HCalGeom") << ss12.str(); + std::stringstream ss13; + ss13 << "HcalParametersFromDD: " << php.Layer0Wt.size() << " Layer0Wt values:"; for (it = php.Layer0Wt.begin(), i = 0; it != php.Layer0Wt.end(); ++it) - std::cout << " [" << ++i << "] = " << (*it); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.HBGains.size() << " Shift/Gains values for HB"; + ss13 << " [" << ++i << "] = " << (*it); + edm::LogVerbatim("HCalGeom") << ss13.str(); + std::stringstream ss14; + ss14 << "HcalParametersFromDD: " << php.HBGains.size() << " Shift/Gains values for HB:"; for (unsigned k = 0; k < php.HBGains.size(); ++k) - std::cout << " [" << k << "] = " << php.HBShift[k] << ":" << php.HBGains[k]; - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.HEGains.size() << " Shift/Gains values for HE"; + ss14 << " [" << k << "] = " << php.HBShift[k] << ":" << php.HBGains[k]; + edm::LogVerbatim("HCalGeom") << ss14.str(); + std::stringstream ss15; + ss15 << "HcalParametersFromDD: " << php.HEGains.size() << " Shift/Gains values for HE:"; for (unsigned k = 0; k < php.HEGains.size(); ++k) - std::cout << " [" << k << "] = " << php.HEShift[k] << ":" << php.HEGains[k]; - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.HFGains.size() << " Shift/Gains values for HF"; + ss15 << " [" << k << "] = " << php.HEShift[k] << ":" << php.HEGains[k]; + edm::LogVerbatim("HCalGeom") << ss15.str(); + std::stringstream ss16; + ss16 << "HcalParametersFromDD: " << php.HFGains.size() << " Shift/Gains values for HF:"; for (unsigned k = 0; k < php.HFGains.size(); ++k) - std::cout << " [" << k << "] = " << php.HFShift[k] << ":" << php.HFGains[k]; - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.etagroup.size() << " etagroup values"; + ss16 << " [" << k << "] = " << php.HFShift[k] << ":" << php.HFGains[k]; + edm::LogVerbatim("HCalGeom") << ss16.str(); + std::stringstream ss17; + ss17 << "HcalParametersFromDD: " << php.etagroup.size() << " etagroup values:"; for (kt = php.etagroup.begin(), i = 0; kt != php.etagroup.end(); ++kt) - std::cout << " [" << ++i << "] = " << (*kt); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.phigroup.size() << " phigroup values"; + ss17 << " [" << ++i << "] = " << (*kt); + edm::LogVerbatim("HCalGeom") << ss17.str(); + std::stringstream ss18; + ss18 << "HcalParametersFromDD: " << php.phigroup.size() << " phigroup values:"; for (kt = php.phigroup.begin(), i = 0; kt != php.phigroup.end(); ++kt) - std::cout << " [" << ++i << "] = " << (*kt); - std::cout << std::endl; - std::cout << "HcalParametersFromDD: " << php.layerGroupEtaRec.size() << " layerGroupEtaRec blocks" << std::endl; + ss18 << " [" << ++i << "] = " << (*kt); + edm::LogVerbatim("HCalGeom") << ss18.str(); + edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD: " << php.layerGroupEtaRec.size() << " layerGroupEtaRec blocks"; for (unsigned int k = 0; k < php.layerGroupEtaRec.size(); ++k) { - std::cout << "layerGroupEtaRec[" << k << "] Layer " << php.layerGroupEtaRec[k].layer; + std::stringstream ss19; + ss19 << "layerGroupEtaRec[" << k << "] Layer " << php.layerGroupEtaRec[k].layer; for (kt = php.layerGroupEtaRec[k].layerGroup.begin(), i = 0; kt != php.layerGroupEtaRec[k].layerGroup.end(); ++kt) - std::cout << " " << ++i << ":" << (*kt); - std::cout << std::endl; + ss19 << " " << ++i << ":" << (*kt); + edm::LogVerbatim("HCalGeom") << ss19.str(); } - std::cout << "HcalParametersFromDD: (topology|trigger)Mode " << std::hex << php.topologyMode << std::dec << std::endl; + edm::LogVerbatim("HCalGeom") << "HcalParametersFromDD: (topology|trigger)Mode " << std::hex << php.topologyMode + << std::dec; #endif return true; diff --git a/Geometry/HcalCommonData/test/python/runHcalParametersFromDD4HepAnalyzer_cfg.py b/Geometry/HcalCommonData/test/python/runHcalParametersFromDD4HepAnalyzer_cfg.py new file mode 100644 index 0000000000000..9c2fd7b36a95e --- /dev/null +++ b/Geometry/HcalCommonData/test/python/runHcalParametersFromDD4HepAnalyzer_cfg.py @@ -0,0 +1,31 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("HcalParametersTest") + +process.load('Geometry.HcalCommonData.hcalParameters_cff') +process.load('Geometry.HcalCommonData.hcalSimulationParameters_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') + +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('Geometry/HcalAlgo/data/cms-test-ddhcalPhase2-algorithm.xml'), + appendToDataLabel = cms.string('') + ) + +process.DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer", + appendToDataLabel = cms.string('') +) + +process.hpa = cms.EDAnalyzer("HcalParametersAnalyzer") +process.hcalParameters.fromDD4Hep = cms.bool(True) + +process.Timing = cms.Service("Timing") +process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck") + +process.p1 = cms.Path(process.hpa)