File indexing completed on 2024-04-06 12:14:50
0001 #include "DetectorDescription/Core/interface/DDFilter.h"
0002 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0003 #include "DetectorDescription/Core/interface/DDMaterial.h"
0004 #include "DetectorDescription/Core/interface/DDSplit.h"
0005 #include "DetectorDescription/Core/interface/DDValue.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "Geometry/HcalTestBeamData/interface/HcalTB02ParametersFromDD.h"
0009
0010 bool HcalTB02ParametersFromDD::build(const DDCompactView* cpv, HcalTB02Parameters& php, const std::string& name) {
0011 DDSpecificsMatchesValueFilter filter{DDValue("ReadOutName", name, 0)};
0012 DDFilteredView fv(*cpv, filter);
0013 bool dodet = fv.firstChild();
0014 while (dodet) {
0015 const DDSolid& sol = fv.logicalPart().solid();
0016 const std::vector<double>& paras = sol.parameters();
0017 std::string namx = static_cast<std::string>(sol.name().name());
0018 edm::LogVerbatim("HcalTBSim") << "HcalTB02ParametersFromDD (for " << name << "): Solid " << namx << " Shape "
0019 << sol.shape() << " Parameter 0 = " << paras[0];
0020 if (sol.shape() == DDSolidShape::ddtrap) {
0021 double dz = 2 * k_ScaleFromDDDToG4 * paras[0];
0022 php.lengthMap_.insert(std::pair<std::string, double>(namx, dz));
0023 }
0024 dodet = fv.next();
0025 }
0026 edm::LogVerbatim("HcalTBSim") << "HcalTB02ParametersFromDD: Length Table for ReadOutName = " << name << ":";
0027 std::map<std::string, double>::const_iterator it = php.lengthMap_.begin();
0028 int i = 0;
0029 for (; it != php.lengthMap_.end(); it++, i++) {
0030 edm::LogVerbatim("HcalTBSim") << " " << i << " " << it->first << " L = " << it->second;
0031 }
0032 return true;
0033 }
0034
0035 bool HcalTB02ParametersFromDD::build(const cms::DDCompactView* cpv, HcalTB02Parameters& php, const std::string& name) {
0036 const cms::DDFilter filter("ReadOutName", name);
0037 cms::DDFilteredView fv(*cpv, filter);
0038 while (fv.firstChild()) {
0039 std::string namx = static_cast<std::string>(dd4hep::dd::noNamespace(fv.name()));
0040 const std::vector<double>& paras = fv.parameters();
0041 edm::LogVerbatim("HcalTBSim") << "HcalTB02ParametersFromDD (for " << name << "): Solid " << namx << " Shape "
0042 << cms::dd::name(cms::DDSolidShapeMap, fv.shape()) << " Parameter 0 = " << paras[0];
0043 if (dd4hep::isA<dd4hep::Trap>(fv.solid())) {
0044 double dz = 2 * k_ScaleFromDD4hepToG4 * paras[0];
0045 php.lengthMap_.insert(std::pair<std::string, double>(namx, dz));
0046 }
0047 }
0048 edm::LogVerbatim("HcalTBSim") << "HcalTB02ParametersFromDD: Length Table for ReadOutName = " << name << ":";
0049 std::map<std::string, double>::const_iterator it = php.lengthMap_.begin();
0050 int i = 0;
0051 for (; it != php.lengthMap_.end(); it++, i++) {
0052 edm::LogVerbatim("HcalTBSim") << " " << i << " " << it->first << " L = " << it->second;
0053 }
0054 return true;
0055 }