diff --git a/Alignment/CocoaApplication/interface/CocoaAnalyzer.h b/Alignment/CocoaApplication/interface/CocoaAnalyzer.h deleted file mode 100644 index 3438b652fa2cc..0000000000000 --- a/Alignment/CocoaApplication/interface/CocoaAnalyzer.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef ALIGNMENT_COCOA_APPLICATION_COCOA_ANALYZER_H -#define ALIGNMENT_COCOA_APPLICATION_COCOA_ANALYZER_H - -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "CondFormats/OptAlignObjects/interface/OpticalAlignments.h" -#include "CondFormats/OptAlignObjects/interface/OpticalAlignMeasurements.h" - -class CocoaAnalyzer : public edm::one::EDAnalyzer { -public: - explicit CocoaAnalyzer(edm::ParameterSet const& p); - explicit CocoaAnalyzer(int i) {} - ~CocoaAnalyzer() override {} - - void beginJob() override; - void analyze(const edm::Event& e, const edm::EventSetup& c) override; - -private: - void readXMLFile(const edm::EventSetup& evts); - - std::vector readCalibrationDB(const edm::EventSetup& evts); - void correctAllOpticalAlignments(std::vector& allDBOpticalAlignments); - void correctOpticalAlignmentParameter(OpticalAlignParam& myXMLParam, const OpticalAlignParam& myDBParam); - - void runCocoa(); - - template - std::vector getAllParameterValuesFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, - const std::string& nodePath, - const std::string& parameterName); - template - T getParameterValueFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, - const std::string& nodePath, - const std::string& parameterName, - const unsigned int parameterValueIndex); - -private: - OpticalAlignments oaList_; - OpticalAlignMeasurements measList_; - std::string theCocoaDaqRootFileName_; -}; - -#endif diff --git a/Alignment/CocoaApplication/src/CocoaAnalyzer.cc b/Alignment/CocoaApplication/src/CocoaAnalyzer.cc index f9aab2322b4ce..466aefcfc9d9e 100644 --- a/Alignment/CocoaApplication/src/CocoaAnalyzer.cc +++ b/Alignment/CocoaApplication/src/CocoaAnalyzer.cc @@ -10,9 +10,9 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "Alignment/CocoaApplication/interface/CocoaAnalyzer.h" #include "Alignment/CocoaUtilities/interface/ALIUtils.h" #include "Alignment/CocoaModel/interface/Model.h" #include "Alignment/CocoaFit/interface/Fit.h" @@ -22,6 +22,34 @@ #include "Alignment/CocoaModel/interface/OpticalObject.h" #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h" #include "Alignment/CocoaFit/interface/CocoaDBMgr.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" +#include "CondFormats/OptAlignObjects/interface/OpticalAlignments.h" +#include "CondFormats/OptAlignObjects/interface/OpticalAlignMeasurements.h" + +class CocoaAnalyzer : public edm::one::EDAnalyzer { +public: + explicit CocoaAnalyzer(edm::ParameterSet const& p); + explicit CocoaAnalyzer(int i) {} + ~CocoaAnalyzer() override {} + + void beginJob() override; + void analyze(const edm::Event& e, const edm::EventSetup& c) override; + +private: + void readXMLFile(const edm::EventSetup& evts); + + std::vector readCalibrationDB(const edm::EventSetup& evts); + void correctAllOpticalAlignments(std::vector& allDBOpticalAlignments); + void correctOpticalAlignmentParameter(OpticalAlignParam& myXMLParam, const OpticalAlignParam& myDBParam); + + void runCocoa(); + +private: + OpticalAlignments oaList_; + OpticalAlignMeasurements measList_; + std::string theCocoaDaqRootFileName_; +}; using namespace cms_units::operators; @@ -160,35 +188,35 @@ void CocoaAnalyzer::readXMLFile(const edm::EventSetup& evts) { oaInfo.x_.name_ = "X"; oaInfo.x_.dim_type_ = "centre"; oaInfo.x_.value_ = transl.x() / (1._m); // COCOA units are m - oaInfo.x_.error_ = getParameterValueFromSpecParSections(allSpecParSections, - nodePath, - "centre_X_sigma", - 0) / + oaInfo.x_.error_ = cms::getParameterValueFromSpecParSections(allSpecParSections, + nodePath, + "centre_X_sigma", + 0) / (1._m); // COCOA units are m oaInfo.x_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_X_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_X_quality", 0)); // Y oaInfo.y_.name_ = "Y"; oaInfo.y_.dim_type_ = "centre"; oaInfo.y_.value_ = transl.y() / (1._m); // COCOA units are m - oaInfo.y_.error_ = getParameterValueFromSpecParSections(allSpecParSections, - nodePath, - "centre_Y_sigma", - 0) / + oaInfo.y_.error_ = cms::getParameterValueFromSpecParSections(allSpecParSections, + nodePath, + "centre_Y_sigma", + 0) / (1._m); // COCOA units are m oaInfo.y_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_Y_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_Y_quality", 0)); // Z oaInfo.z_.name_ = "Z"; oaInfo.z_.dim_type_ = "centre"; oaInfo.z_.value_ = transl.z() / (1._m); // COCOA units are m - oaInfo.z_.error_ = getParameterValueFromSpecParSections(allSpecParSections, - nodePath, - "centre_Z_sigma", - 0) / + oaInfo.z_.error_ = cms::getParameterValueFromSpecParSections(allSpecParSections, + nodePath, + "centre_Z_sigma", + 0) / (1._m); // COCOA units are m oaInfo.z_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_Z_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "centre_Z_quality", 0)); // ROTATIONS @@ -234,34 +262,35 @@ void CocoaAnalyzer::readXMLFile(const edm::EventSetup& evts) { oaInfo.angx_.name_ = "X"; oaInfo.angx_.dim_type_ = "angles"; oaInfo.angx_.value_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_value", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_value", 0); oaInfo.angx_.error_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_sigma", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_sigma", 0); oaInfo.angx_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_X_quality", 0)); // Y oaInfo.angy_.name_ = "Y"; oaInfo.angy_.dim_type_ = "angles"; oaInfo.angy_.value_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_value", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_value", 0); oaInfo.angy_.error_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_sigma", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_sigma", 0); oaInfo.angy_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Y_quality", 0)); // Z oaInfo.angz_.name_ = "Z"; oaInfo.angz_.dim_type_ = "angles"; oaInfo.angz_.value_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_value", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_value", 0); oaInfo.angz_.error_ = - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_sigma", 0); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_sigma", 0); oaInfo.angz_.quality_ = static_cast( - getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_quality", 0)); + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "angles_Z_quality", 0)); - oaInfo.type_ = getParameterValueFromSpecParSections(allSpecParSections, nodePath, "cocoa_type", 0); + oaInfo.type_ = + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "cocoa_type", 0); - oaInfo.ID_ = - static_cast(getParameterValueFromSpecParSections(allSpecParSections, nodePath, "cmssw_ID", 0)); + oaInfo.ID_ = static_cast( + cms::getParameterValueFromSpecParSections(allSpecParSections, nodePath, "cmssw_ID", 0)); if (ALIUtils::debug >= 4) { edm::LogInfo("Alignment") << "CocoaAnalyzer::ReadXML OBJECT " << oaInfo.name_ << " pos/angles read "; @@ -279,15 +308,15 @@ void CocoaAnalyzer::readXMLFile(const edm::EventSetup& evts) { // EXTRA PARAM ENTRIES (FROM XMLS) // Here initial code to define the containers was fully removed, this is much more compact. const std::vector& names = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "extra_entry"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "extra_entry"); const std::vector& dims = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "dimType"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "dimType"); const std::vector& values = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "value"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "value"); const std::vector& errors = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "sigma"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "sigma"); const std::vector& quality = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "quality"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "quality"); if (ALIUtils::debug >= 4) { edm::LogInfo("Alignment") << " CocoaAnalyzer::ReadXML: Fill extra entries with read parameters "; @@ -320,9 +349,9 @@ void CocoaAnalyzer::readXMLFile(const edm::EventSetup& evts) { // MEASUREMENTS (FROM XMLS) const std::vector& measNames = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_name"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_name"); const std::vector& measTypes = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_type"); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_type"); std::map> measObjectNames; std::map> measParamNames; @@ -330,15 +359,15 @@ void CocoaAnalyzer::readXMLFile(const edm::EventSetup& evts) { std::map> measParamSigmas; std::map> measIsSimulatedValue; for (const auto& name : measNames) { - measObjectNames[name] = getAllParameterValuesFromSpecParSections( + measObjectNames[name] = cms::getAllParameterValuesFromSpecParSections( allSpecParSections, nodePath, "meas_object_name_" + name); - measParamNames[name] = getAllParameterValuesFromSpecParSections( + measParamNames[name] = cms::getAllParameterValuesFromSpecParSections( allSpecParSections, nodePath, "meas_value_name_" + name); measParamValues[name] = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_value_" + name); + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_value_" + name); measParamSigmas[name] = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_sigma_" + name); - measIsSimulatedValue[name] = getAllParameterValuesFromSpecParSections( + cms::getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, "meas_sigma_" + name); + measIsSimulatedValue[name] = cms::getAllParameterValuesFromSpecParSections( allSpecParSections, nodePath, "meas_is_simulated_value_" + name); } @@ -568,39 +597,4 @@ void CocoaAnalyzer::runCocoa() { } } -/* Helper: For a given node, get the values associated to a given parameter, from the XMLs SpecPar sections. - * NB: The same parameter can appear several times WITHIN the same SpecPar section (hence, we have a std::vector). - * WARNING: This stops at the first relevant SpecPar section encountered. - * Hence, if A GIVEN NODE HAS SEVERAL SPECPAR XML SECTIONS RE-DEFINING THE SAME PARAMETER, - * only the first XML SpecPar block will be considered. - */ -template -std::vector CocoaAnalyzer::getAllParameterValuesFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, - const std::string& nodePath, - const std::string& parameterName) { - cms::DDSpecParRefs filteredSpecParSections; - allSpecParSections.filter(filteredSpecParSections, parameterName); - for (const auto& mySpecParSection : filteredSpecParSections) { - if (mySpecParSection->hasPath(nodePath)) { - return mySpecParSection->value>(parameterName); - } - } - - return std::vector(); -} - -/* Helper: For a given node, get the value associated to a given parameter, from the XMLs SpecPar sections. - * This is the parameterValueIndex-th value (within a XML SpecPar block.) of the desired parameter. - */ -template -T CocoaAnalyzer::getParameterValueFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, - const std::string& nodePath, - const std::string& parameterName, - const unsigned int parameterValueIndex) { - const std::vector& allParameterValues = - getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, parameterName); - if (parameterValueIndex < allParameterValues.size()) { - return allParameterValues.at(parameterValueIndex); - } - return T(); -} +DEFINE_FWK_MODULE(CocoaAnalyzer); diff --git a/Alignment/CocoaApplication/src/SealModule.cc b/Alignment/CocoaApplication/src/SealModule.cc deleted file mode 100644 index 6fabe6d7c6341..0000000000000 --- a/Alignment/CocoaApplication/src/SealModule.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "FWCore/Framework/interface/MakerMacros.h" -#include "Alignment/CocoaApplication/interface/CocoaAnalyzer.h" - -DEFINE_FWK_MODULE(CocoaAnalyzer); diff --git a/DetectorDescription/DDCMS/interface/DDCompactView.h b/DetectorDescription/DDCMS/interface/DDCompactView.h index 1c19a9a0f58b4..652ed53385025 100644 --- a/DetectorDescription/DDCMS/interface/DDCompactView.h +++ b/DetectorDescription/DDCMS/interface/DDCompactView.h @@ -26,6 +26,7 @@ namespace cms { using DDSpecParRegistry = dd4hep::SpecParRegistry; + using DDSpecParRefs = dd4hep::SpecParRefs; class DDCompactView { public: @@ -43,6 +44,44 @@ namespace cms { private: const cms::DDDetector& m_det; }; + + /* Helper: For a given node, get the values associated to a given parameter, from the XMLs SpecPar sections. + * NB: The same parameter can appear several times WITHIN the same SpecPar section (hence, we have a std::vector). + * WARNING: This stops at the first relevant SpecPar section encountered. + * Hence, if A GIVEN NODE HAS SEVERAL SPECPAR XML SECTIONS RE-DEFINING THE SAME PARAMETER, + * only the first XML SpecPar block will be considered. + */ + template + std::vector getAllParameterValuesFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, + const std::string& nodePath, + const std::string& parameterName) { + cms::DDSpecParRefs filteredSpecParSections; + allSpecParSections.filter(filteredSpecParSections, parameterName); + for (const auto& mySpecParSection : filteredSpecParSections) { + if (mySpecParSection.second->hasPath(nodePath)) { + return mySpecParSection.second->value>(parameterName); + } + } + + return std::vector(); + } + + /* Helper: For a given node, get the value associated to a given parameter, from the XMLs SpecPar sections. + * This is the parameterValueIndex-th value (within a XML SpecPar block.) of the desired parameter. + */ + template + T getParameterValueFromSpecParSections(const cms::DDSpecParRegistry& allSpecParSections, + const std::string& nodePath, + const std::string& parameterName, + const unsigned int parameterValueIndex) { + const std::vector& allParameterValues = + getAllParameterValuesFromSpecParSections(allSpecParSections, nodePath, parameterName); + if (parameterValueIndex < allParameterValues.size()) { + return allParameterValues.at(parameterValueIndex); + } + return T(); + } + } // namespace cms #endif diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index f1fe2729262f1..38fc916db11be 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -172,7 +172,7 @@ namespace cms { std::string path = this->path(); for (const auto& specPar : refs) { - for (const auto& part : specPar->paths) { + for (const auto& part : specPar.second->paths) { bool flag(true); std::size_t from = 0; for (auto name : dd4hep::dd::split(part, "/")) { @@ -185,7 +185,7 @@ namespace cms { } } if (flag) { - return specPar->value>(key); + return specPar.second->value>(key); } } } diff --git a/DetectorDescription/DDCMS/interface/DDParsingContext.h b/DetectorDescription/DDCMS/interface/DDParsingContext.h index 86a9fff85513d..d885a9efe36cd 100644 --- a/DetectorDescription/DDCMS/interface/DDParsingContext.h +++ b/DetectorDescription/DDCMS/interface/DDParsingContext.h @@ -66,6 +66,7 @@ namespace cms { bool debug_specpars = false; dd4hep::Detector& description; + std::unordered_map assemblies; std::unordered_map rotations; std::unordered_map shapes; diff --git a/DetectorDescription/DDCMS/interface/DDSpecParRegistry.h b/DetectorDescription/DDCMS/interface/DDSpecParRegistry.h index 8c03a5fd3a5f6..297e00a29d89f 100644 --- a/DetectorDescription/DDCMS/interface/DDSpecParRegistry.h +++ b/DetectorDescription/DDCMS/interface/DDSpecParRegistry.h @@ -7,6 +7,7 @@ namespace cms { using DDSpecParRegistry = dd4hep::SpecParRegistry; using DDSpecPar = dd4hep::SpecPar; + using DDSpecParRefs = dd4hep::SpecParRefs; } // namespace cms diff --git a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc index 8599cb0f3e6a8..576b4e8353f23 100644 --- a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc +++ b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc @@ -29,6 +29,8 @@ #include #include +#define EDM_ML_DEBUG + using namespace std; using namespace dd4hep; using namespace cms; @@ -415,6 +417,8 @@ void Converter::operator()(xml_h element) const { ns.addConstant(nam, val, typ); res->originalConst[real] = val; } catch (const exception& e) { +#ifdef EDM_ML_DEBUG + printout(INFO, "DD4CMS", "++ Unresolved constant: %s = %s [%s]. Try to resolve later. [%s]", @@ -422,6 +426,7 @@ void Converter::operator()(xml_h element) const { val.c_str(), typ.c_str(), e.what()); +#endif } return; } @@ -436,8 +441,14 @@ void Converter::operator()(xml_h element) const { val[idp] = NAMESPACE_SEP; idx = val.find('[', idx); } + +#ifdef EDM_ML_DEBUG + printout( ns.context()->debug_constants ? ALWAYS : DEBUG, "Constant", "Unresolved: %s -> %s", real.c_str(), val.c_str()); + +#endif + res->originalConst[real] = val; res->unresolvedConst[real] = val; } @@ -457,8 +468,13 @@ void Converter::operator()(xml_h element) const { double atomicWeight = xmat.attr(DD_CMU(atomicWeight)) / (dd4hep::g / dd4hep::mole); TGeoElementTable* tab = mgr.GetElementTable(); int nElem = tab->GetNelements(); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", "+++ Element table size = %d", nElem); +#endif + if (nElem <= 1) { // Restore the element table DD4hep destroyed. tab->TGeoElementTable::~TGeoElementTable(); new (tab) TGeoElementTable(); @@ -466,6 +482,9 @@ void Converter::operator()(xml_h element) const { } TGeoMixture* mix = new TGeoMixture(nam.c_str(), 1, density); TGeoElement* elt = tab->FindElement(xmat.nameStr().c_str()); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", "+++ Searching for material %-48s elt_ptr = %ld", @@ -482,10 +501,15 @@ void Converter::operator()(xml_h element) const { density, mix->GetDensity()); +#endif + bool newMatDef = false; if (elt) { // A is Mass of a mole in Geant4 units for atoms with atomic shell + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", " ROOT definition of %-50s Atomic weight %g, Atomic number %u, Number of nucleons %u", @@ -498,6 +522,8 @@ void Converter::operator()(xml_h element) const { "+++ Compared to XML values: Atomic weight %g, Atomic number %u", atomicWeight, atomicNumber); +#endif + static constexpr double const weightTolerance = 1.0e-6; if (atomicNumber != elt->Z() || (std::abs(atomicWeight - elt->A()) > (weightTolerance * (atomicWeight + elt->A())))) @@ -505,17 +531,27 @@ void Converter::operator()(xml_h element) const { } if (!elt || newMatDef) { - if (newMatDef) + if (newMatDef) { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS Warning", "+++ Converter Different definition of a default element with name:%s [CREATE NEW " "MATERIAL]", matname); - else + +#endif + + } else { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS Warning", "+++ Converter No default element present with name:%s [CREATE NEW MATERIAL]", matname); + +#endif + } elt = new TGeoElement(xmat.nameStr().c_str(), "CMS element", atomicNumber, atomicWeight); } @@ -547,6 +583,8 @@ void Converter::operator()(xml_h element) const { xml_coll_t composites(xmat, DD_CMU(MaterialFraction)); TGeoMixture* mix = new TGeoMixture(nam.c_str(), composites.size(), density); +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", "++ Converting material %-48s Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]", @@ -554,6 +592,8 @@ void Converter::operator()(xml_h element) const { density, mix->GetDensity()); +#endif + for (composites.reset(); composites; ++composites) { xml_dim_t xfrac(composites); xml_dim_t xfrac_mat(xfrac.child(DD_CMU(rMaterial))); @@ -568,11 +608,16 @@ void Converter::operator()(xml_h element) const { continue; } +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS Warning", "+++ Composite material \"%s\" [nor \"%s\"] not present! [delay resolution]", fracname.c_str(), ns.prepend(fracname).c_str()); + +#endif + ns.context()->unresolvedMaterials[nam].emplace_back( cms::DDParsingContext::CompositeMaterial(ns.prepend(fracname), fraction)); } @@ -602,6 +647,9 @@ void Converter::operator()(xml_h element) const { double thetaZ = xrot.hasAttr(DD_CMU(thetaZ)) ? ns.attr(xrot, DD_CMU(thetaZ)) : 0e0; double phiZ = xrot.hasAttr(DD_CMU(phiZ)) ? ns.attr(xrot, DD_CMU(phiZ)) : 0e0; Rotation3D rot = makeRotation3D(thetaX, phiX, thetaY, phiY, thetaZ, phiZ); + +#ifdef EDM_ML_DEBUG + printout(context->debug_rotations ? ALWAYS : DEBUG, "DD4CMS", "+++ Adding rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f", @@ -612,6 +660,9 @@ void Converter::operator()(xml_h element) const { phiY, thetaZ, phiZ); + +#endif + ns.addRotation(nam, rot); } @@ -628,6 +679,9 @@ void Converter::operator()(xml_h element) const { double phiY = xrot.hasAttr(DD_CMU(phiY)) ? ns.attr(xrot, DD_CMU(phiY)) : 0e0; double thetaZ = xrot.hasAttr(DD_CMU(thetaZ)) ? ns.attr(xrot, DD_CMU(thetaZ)) : 0e0; double phiZ = xrot.hasAttr(DD_CMU(phiZ)) ? ns.attr(xrot, DD_CMU(phiZ)) : 0e0; + +#ifdef EDM_ML_DEBUG + printout(context->debug_rotations ? ALWAYS : DEBUG, "DD4CMS", "+++ Adding reflection rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f", @@ -638,6 +692,9 @@ void Converter::operator()(xml_h element) const { phiY, thetaZ, phiZ); + +#endif + Rotation3D rot = makeRotReflect(thetaX, phiX, thetaY, phiY, thetaZ, phiZ); ns.addRotation(name, rot); } @@ -655,17 +712,25 @@ void Converter::operator()(xml_h element) const { string axis = ns.attr(rotations, DD_CMU(axis)); double angle = ns.attr(rotations, _U(angle)); rot = makeRotation3D(rot, axis, angle); + +#ifdef EDM_ML_DEBUG + printout(context->debug_rotations ? ALWAYS : DEBUG, "DD4CMS", "+ Adding rotation to: %-29s: (axis/angle)[rad] Axis: %s Angle: %6.3f", nam.c_str(), axis.c_str(), angle); + +#endif } double xx, xy, xz; double yx, yy, yz; double zx, zy, zz; rot.GetComponents(xx, xy, xz, yx, yy, yz, zx, zy, zz); + +#ifdef EDM_ML_DEBUG + printout(context->debug_rotations ? ALWAYS : DEBUG, "DD4CMS", "+++ Adding rotation sequence: %-23s: %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f", @@ -679,6 +744,9 @@ void Converter::operator()(xml_h element) const { zx, zy, zz); + +#endif + ns.addRotation(nam, rot); } @@ -695,12 +763,18 @@ void Converter::operator()(xml_h element) const { double angle = ns.attr(xrot, _U(angle)); Rotation3D rot; rot = makeRotation3D(rot, axis, angle); + +#ifdef EDM_ML_DEBUG + printout(context->debug_rotations ? ALWAYS : DEBUG, "DD4CMS", "+++ Adding rotation: %-32s: (axis/angle)[rad] Axis: %s Angle: %6.3f", ns.prepend(nam).c_str(), axis.c_str(), angle); + +#endif + ns.addRotation(nam, rot); } } @@ -715,7 +789,15 @@ void Converter::operator()(xml_h element) const { string volName = e.attr(_U(name)); Solid solid = ns.solid(sol); Material material = ns.material(mat); - Volume volume = ns.addVolume(Volume(volName, solid, material)); + +#ifdef EDM_ML_DEBUG + Volume volume = +#endif + + ns.addVolume(Volume(volName, solid, material)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_volumes ? ALWAYS : DEBUG, "DD4CMS", "+++ %s Volume: %-24s [%s] Shape: %-32s [%s] Material: %-40s [%s]", @@ -726,6 +808,8 @@ void Converter::operator()(xml_h element) const { solid.isValid() ? "VALID" : "INVALID", mat.c_str(), material.isValid() ? "VALID" : "INVALID"); + +#endif } /// Helper converter @@ -772,6 +856,9 @@ void Converter::operator()(xml_h element) const { string childName = ns.attr(e.child(DD_CMU(rChild)), _U(name)); Volume parent = ns.volume(parentName, false); Volume child = ns.volume(childName, false); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d", @@ -782,6 +869,8 @@ void Converter::operator()(xml_h element) const { child.isValid() ? "VALID" : "INVALID", copy); +#endif + if (!parent.isValid() && strchr(parentName.c_str(), NAMESPACE_SEP) == nullptr) parentName = ns.prepend(parentName); parent = ns.volume(parentName); @@ -790,6 +879,8 @@ void Converter::operator()(xml_h element) const { childName = ns.prepend(childName); child = ns.volume(childName, false); +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d", @@ -800,6 +891,8 @@ void Converter::operator()(xml_h element) const { child.isValid() ? "VALID" : "INVALID", copy); +#endif + PlacedVolume pv; if (child.isValid()) { Transform3D transform; @@ -863,12 +956,17 @@ void Converter::operator()(xml_h element) const { xml_dim_t specPar = e.parent(); string specParName = specPar.attr(_U(name)); string path = e.attr(DD_CMU(path)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_specpars ? ALWAYS : DEBUG, "DD4CMS", "+++ PartSelector for %s path: %s", specParName.c_str(), path.c_str()); +#endif + size_t pos = std::string::npos; if ((pos = path.find("//.*:")) != std::string::npos) { path.erase(pos + 2, 3); @@ -892,6 +990,8 @@ void Converter::operator()(xml_h element) const { : (specParSect.hasAttr(_U(eval)) ? specParSect.attr(_U(eval)) : false); string type = eval ? "number" : "string"; +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_specpars ? ALWAYS : DEBUG, "DD4CMS", "+++ Parameter for %s: %s value %s is a %s", @@ -900,6 +1000,8 @@ void Converter::operator()(xml_h element) const { value.c_str(), type.c_str()); +#endif + size_t idx = value.find('['); if (idx == string::npos || type == "string") { registry.specpars[specParName].spars[name].emplace_back(std::move(value)); @@ -929,7 +1031,7 @@ void Converter::operator()(xml_h element) const { v.replace(idx, idq - idx + 1, rep); } } - registry.specpars[specParName].numpars[name].emplace_back(_toDouble(value)); + registry.specpars[specParName].numpars[name].emplace_back(dd4hep::_toDouble(value)); } template @@ -958,6 +1060,8 @@ static void convert_boolean(cms::DDParsingContext* context, xml_h element) { except("DD4CMS", "+++ Failed to create boolean solid %s. Found only %d parts.", nam.c_str(), cnt); } +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ BooleanSolid: %s Left: %-32s Right: %-32s", @@ -965,6 +1069,8 @@ static void convert_boolean(cms::DDParsingContext* context, xml_h element) { ((solids[0].ptr() == nullptr) ? solidName[0].c_str() : solids[0]->GetName()), ((solids[1].ptr() == nullptr) ? solidName[1].c_str() : solids[1]->GetName())); +#endif + if (solids[0].isValid() && solids[1].isValid()) { Transform3D trafo; Converter(context->description, context, &trafo)(element); @@ -1021,14 +1127,22 @@ void Converter::operator()(xml_h element) const { rmax.emplace_back(ns.attr(zplane, DD_CMU(rMax))); z.emplace_back(ns.attr(zplane, _U(z))); } + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes", startPhi, deltaPhi, z.size()); + +#endif + ns.addSolid(nam, Polycone(startPhi, deltaPhi, rmin, rmax, z)); } else { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes and %4ld radii", @@ -1036,6 +1150,9 @@ void Converter::operator()(xml_h element) const { deltaPhi, z.size(), r.size()); + +#endif + ns.addSolid(nam, Polycone(startPhi, deltaPhi, r, z)); } } @@ -1058,11 +1175,17 @@ void Converter::operator()(xml_h element) const { pt_x.emplace_back(ns.attr(pt, _U(x))); pt_y.emplace_back(ns.attr(pt, _U(y))); } + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ ExtrudedPolygon: %4ld points %4ld zxy sections", pt_x.size(), sec_z.size()); + +#endif + ns.addSolid(nam, ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale)); } @@ -1087,6 +1210,9 @@ void Converter::operator()(xml_h element) const { rmax.emplace_back(ns.attr(zplane, DD_CMU(rMax))); z.emplace_back(ns.attr(zplane, _U(z))); } + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Polyhedra:startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] %4d sides %4ld z-planes", @@ -1094,6 +1220,9 @@ void Converter::operator()(xml_h element) const { deltaPhi, numSide, z.size()); + +#endif + ns.addSolid(nam, Polyhedra(numSide, startPhi, deltaPhi, z, rmin, rmax)); } @@ -1109,6 +1238,9 @@ void Converter::operator()(xml_h element) const { double deltaPhi = ns.attr(e, DD_CMU(deltaPhi)); double startTheta = ns.attr(e, DD_CMU(startTheta)); double deltaTheta = ns.attr(e, DD_CMU(deltaTheta)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Sphere: r_inner=%8.3f [cm] r_outer=%8.3f [cm]" @@ -1119,6 +1251,9 @@ void Converter::operator()(xml_h element) const { deltaPhi, startTheta, deltaTheta); + +#endif + ns.addSolid(nam, Sphere(rinner, router, startTheta, deltaTheta, startPhi, deltaPhi)); } @@ -1133,6 +1268,9 @@ void Converter::operator()(xml_h element) const { double router = ns.attr(e, DD_CMU(outerRadius)); double startPhi = ns.attr(e, DD_CMU(startPhi)); double deltaPhi = ns.attr(e, DD_CMU(deltaPhi)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Torus: r=%10.3f [cm] r_inner=%10.3f [cm] r_outer=%10.3f [cm]" @@ -1142,6 +1280,9 @@ void Converter::operator()(xml_h element) const { router, startPhi, deltaPhi); + +#endif + ns.addSolid(nam, Torus(r, rinner, router, startPhi, deltaPhi)); } @@ -1158,6 +1299,9 @@ void Converter::operator()(xml_h element) const { double dz = ns.attr(e, _U(dz)); double r = ns.attr(e, _U(radius)); bool atMinusZ = ns.attr(e, DD_CMU(atMinusZ)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Pseudotrap: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2=%.3f dy2=%.3f radius:%.3f atMinusZ:%s", @@ -1168,6 +1312,9 @@ void Converter::operator()(xml_h element) const { dy2, r, yes_no(atMinusZ)); + +#endif + ns.addSolid(nam, PseudoTrap(dx1, dx2, dy1, dy2, dz, r, atMinusZ)); } @@ -1189,6 +1336,8 @@ void Converter::operator()(xml_h element) const { double phi = ns.attr(e, _U(phi), 0.0); double theta = ns.attr(e, _U(theta), 0.0); +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Trapezoid: dz=%10.3f [cm] alp1:%.3f bl1=%.3f tl1=%.3f alp2=%.3f bl2=%.3f tl2=%.3f h2=%.3f phi=%.3f " @@ -1204,6 +1353,9 @@ void Converter::operator()(xml_h element) const { h2, phi, theta); + +#endif + ns.addSolid(nam, Trap(dz, theta, phi, h1, bl1, tl1, alp1, h2, bl2, tl2, alp2)); } @@ -1219,6 +1371,8 @@ void Converter::operator()(xml_h element) const { double dy2 = ns.attr(e, DD_CMU(dy2), dy1); double dz = ns.attr(e, DD_CMU(dz)); if (dy1 == dy2) { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f", @@ -1227,8 +1381,13 @@ void Converter::operator()(xml_h element) const { dy1, dx2, dy2); + +#endif + ns.addSolid(nam, Trd1(dx1, dx2, dy1, dz)); } else { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Trd1(which is actually Trd2): dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f", @@ -1237,6 +1396,9 @@ void Converter::operator()(xml_h element) const { dy1, dx2, dy2); + +#endif + ns.addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz)); } } @@ -1252,6 +1414,9 @@ void Converter::operator()(xml_h element) const { double dx2 = ns.attr(e, DD_CMU(dx2), 0.0); double dy2 = ns.attr(e, DD_CMU(dy2), dy1); double dz = ns.attr(e, DD_CMU(dz)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f", @@ -1260,6 +1425,9 @@ void Converter::operator()(xml_h element) const { dy1, dx2, dy2); + +#endif + ns.addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz)); } @@ -1274,6 +1442,9 @@ void Converter::operator()(xml_h element) const { double rmax = ns.attr(e, DD_CMU(rMax)); double startPhi = ns.attr(e, DD_CMU(startPhi), 0.0); double deltaPhi = ns.attr(e, DD_CMU(deltaPhi), 2 * M_PI); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Tubs: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" @@ -1283,6 +1454,9 @@ void Converter::operator()(xml_h element) const { rmax, startPhi, deltaPhi); + +#endif + ns.addSolid(nam, Tube(rmin, rmax, dz, startPhi, startPhi + deltaPhi)); } @@ -1303,6 +1477,9 @@ void Converter::operator()(xml_h element) const { double tx = ns.attr(e, DD_CMU(tx)); double ty = ns.attr(e, DD_CMU(ty)); double tz = ns.attr(e, DD_CMU(tz)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ CutTube: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" @@ -1312,6 +1489,9 @@ void Converter::operator()(xml_h element) const { rmax, startPhi, deltaPhi); + +#endif + ns.addSolid(nam, CutTube(rmin, rmax, dz, startPhi, startPhi + deltaPhi, lx, ly, lz, tx, ty, tz)); } @@ -1329,6 +1509,9 @@ void Converter::operator()(xml_h element) const { double cutAtStart = ns.attr(e, DD_CMU(cutAtStart)); double cutAtDelta = ns.attr(e, DD_CMU(cutAtDelta)); bool cutInside = ns.attr(e, DD_CMU(cutInside)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ TruncTube:zHalf=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" @@ -1341,6 +1524,9 @@ void Converter::operator()(xml_h element) const { cutAtStart, cutAtDelta, yes_no(cutInside)); + +#endif + ns.addSolid(nam, TruncatedTube(zhalf, rmin, rmax, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside)); } @@ -1353,12 +1539,18 @@ void Converter::operator()(xml_h element) const { double dx = ns.attr(e, DD_CMU(xSemiAxis)); double dy = ns.attr(e, DD_CMU(ySemiAxis)); double dz = ns.attr(e, DD_CMU(zHeight)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ EllipticalTube xSemiAxis=%8.3f [cm] ySemiAxis=%8.3f [cm] zHeight=%8.3f [cm]", dx, dy, dz); + +#endif + ns.addSolid(nam, EllipticalTube(dx, dy, dz)); } @@ -1376,6 +1568,9 @@ void Converter::operator()(xml_h element) const { double startPhi = ns.attr(e, DD_CMU(startPhi)); double deltaPhi = ns.attr(e, DD_CMU(deltaPhi)); double phi2 = startPhi + deltaPhi; + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Cone: dz=%8.3f [cm]" @@ -1389,6 +1584,9 @@ void Converter::operator()(xml_h element) const { rmax2, startPhi, deltaPhi); + +#endif + ns.addSolid(nam, ConeSegment(dz, rmin1, rmax1, rmin2, rmax2, startPhi, phi2)); } @@ -1398,10 +1596,16 @@ void Converter::operator()(xml_h element) const { cms::DDNamespace ns(_param()); xml_dim_t e(element); string nam = e.nameStr(); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Shapeless: THIS ONE CAN ONLY BE USED AT THE VOLUME LEVEL -> Assembly%s", nam.c_str()); + +#endif + ns.addSolid(nam, Box(1, 1, 1)); } @@ -1414,12 +1618,18 @@ void Converter::operator()(xml_h element) const { double dx = ns.attr(e, DD_CMU(dx)); double dy = ns.attr(e, DD_CMU(dy)); double dz = ns.attr(e, DD_CMU(dz)); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Box: dx=%10.3f [cm] dy=%10.3f [cm] dz=%10.3f [cm]", dx, dy, dz); + +#endif + ns.addSolid(nam, Box(dx, dy, dz)); } @@ -1430,10 +1640,16 @@ void Converter::operator()(xml_h element) const { edm::FileInPath fp(fname); xml::Document doc; doc = xml::DocumentHandler().load(fp.fullPath()); + +#ifdef EDM_ML_DEBUG + printout(_param()->debug_includes ? ALWAYS : DEBUG, "DD4CMS", "+++ Processing the CMS detector description %s", fname.c_str()); + +#endif + _option()->includes.emplace_back(doc); } @@ -1442,10 +1658,14 @@ template <> void Converter::operator()(xml_h element) const { string fname = xml::DocumentHandler::system_path(element); xml::DocumentHolder(xml_elt_t(element).document()).assign(nullptr); + +#ifdef EDM_ML_DEBUG + printout(_param()->debug_includes ? ALWAYS : DEBUG, "DD4CMS", "+++ Finished processing %s", fname.c_str()); +#endif } /// DD4hep specific Converter for tags: process only the constants @@ -1491,6 +1711,8 @@ void Converter::operator()(xml_h element) const { double width = e.hasAttr(DD_CMU(width)) ? ns.attr(e, DD_CMU(width)) : 0e0; int nReplicas = e.hasAttr(DD_CMU(nReplicas)) ? ns.attr(e, DD_CMU(nReplicas)) : 0; +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ Start executing Division of %s along %s (%d) with offset %6.3f and %6.3f to produce %s....", @@ -1501,6 +1723,8 @@ void Converter::operator()(xml_h element) const { width, childName.c_str()); +#endif + Volume parent = ns.volume(parentName); const TGeoShape* shape = parent.solid(); @@ -1510,6 +1734,9 @@ void Converter::operator()(xml_h element) const { double widthInDeg = convertRadToDeg(width); double startInDeg = convertRadToDeg(offset); int numCopies = (int)((sh->GetPhi2() - sh->GetPhi1()) / widthInDeg); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ ...divide %s along %s (%d) with offset %6.3f deg and %6.3f deg to produce %d copies", @@ -1519,10 +1746,15 @@ void Converter::operator()(xml_h element) const { startInDeg, widthInDeg, numCopies); + +#endif + Volume child = parent.divide(childName, static_cast(axesmap.at(axis)), numCopies, startInDeg, widthInDeg); ns.context()->volumes[childName] = child; +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]", @@ -1532,9 +1764,13 @@ void Converter::operator()(xml_h element) const { child.name(), child.isValid() ? "VALID" : "INVALID", child->IsVolumeMulti() ? "YES" : "NO"); +#endif } else if (cl == TGeoTrd1::Class()) { double dy = static_cast(shape)->GetDy(); + +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ ...divide %s along %s (%d) with offset %6.3f cm and %6.3f cm to produce %d copies in %6.3f", @@ -1545,10 +1781,15 @@ void Converter::operator()(xml_h element) const { width, nReplicas, dy); + +#endif + Volume child = parent.divide(childName, static_cast(axesmap.at(axis)), nReplicas, -dy + offset + width, width); ns.context()->volumes[childName] = child; +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS", "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]", @@ -1558,6 +1799,9 @@ void Converter::operator()(xml_h element) const { child.name(), child.isValid() ? "VALID" : "INVALID", child->IsVolumeMulti() ? "YES" : "NO"); + +#endif + } else { printout(ERROR, "DD4CMS", "++ FAILED Division of a %s is not implemented yet!", parent.solid().type()); } @@ -1574,16 +1818,25 @@ void Converter::operator()(xml_h element) const { while ((idx = type.find(NAMESPACE_SEP)) != string::npos) type[idx] = '_'; +#ifdef EDM_ML_DEBUG + printout( ns.context()->debug_algorithms ? ALWAYS : DEBUG, "DD4CMS", "+++ Start executing algorithm %s....", type.c_str()); +#endif + long ret = PluginService::Create(type, &description, ns.context(), &element); if (ret == s_executed) { +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_algorithms ? ALWAYS : DEBUG, + "DD4CMS", "+++ Executed algorithm: %08lX = %s", ret, name.c_str()); + +#endif return; } printout(ERROR, "DD4CMS", "++ FAILED NOT ADDING SUBDETECTOR %08lX = %s", ret, name.c_str()); @@ -1647,6 +1900,8 @@ void Converter::operator()(xml_h element) const { string val = e.text(); val.erase(remove_if(val.begin(), val.end(), [](unsigned char x) { return isspace(x); }), val.end()); +#ifdef EDM_ML_DEBUG + printout(ns.context()->debug_constants ? ALWAYS : DEBUG, "DD4CMS", "+++ Vector<%s>: %s[%s]: %s", @@ -1654,12 +1909,17 @@ void Converter::operator()(xml_h element) const { name.c_str(), nEntries.c_str(), val.c_str()); + +#endif + try { std::vector results = splitNumeric(val); registry->insert( {name, results}); //tbb::concurrent_vector>(results.begin(), results.end())}); } catch (const exception& e) { +#ifdef EDM_ML_DEBUG + printout(INFO, "DD4CMS", "++ Unresolved Vector<%s>: %s[%s]: %s. Try to resolve later. [%s]", @@ -1669,6 +1929,8 @@ void Converter::operator()(xml_h element) const { val.c_str(), e.what()); +#endif + std::vector results = splitString(val); context->unresolvedVectors.insert({name, results}); } @@ -1706,11 +1968,14 @@ void Converter::operator()(xml_h /* element */) const { cms::DDNamespace ns(context); int count = 0; +#ifdef EDM_ML_DEBUG + printout(context->debug_constants ? ALWAYS : DEBUG, "DD4CMS", "+++ RESOLVING %ld unknown constants..... (out of %ld)", res->unresolvedConst.size(), res->originalConst.size()); +#endif while (!res->unresolvedConst.empty()) { for (auto& i : res->unresolvedConst) { @@ -1734,12 +1999,18 @@ void Converter::operator()(xml_h /* element */) const { while ((idx = v.find("+-")) != string::npos) v.replace(idx, 2, "-"); } + +#ifdef EDM_ML_DEBUG + printout(context->debug_constants ? ALWAYS : DEBUG, "DD4CMS", "+++ [%06ld] ---------- %-40s = %s", res->unresolvedConst.size() - 1, n.c_str(), res->originalConst[n].c_str()); + +#endif + ns.addConstantNS(n, v, "number"); res->unresolvedConst.erase(n); break; @@ -1760,10 +2031,15 @@ void Converter::operator()(xml_h /* element */) const { template <> void Converter::operator()(xml_h element) const { string fname = xml::DocumentHandler::system_path(element); + +#ifdef EDM_ML_DEBUG + printout(_param()->debug_includes ? ALWAYS : DEBUG, "DD4CMS", "+++ Processing data from: %s", fname.c_str()); + +#endif } /// Converter for tags diff --git a/DetectorDescription/DDCMS/plugins/test/DDTestSpecPars.cc b/DetectorDescription/DDCMS/plugins/test/DDTestSpecPars.cc index 30610a900f5ef..3ed77010eb060 100644 --- a/DetectorDescription/DDCMS/plugins/test/DDTestSpecPars.cc +++ b/DetectorDescription/DDCMS/plugins/test/DDTestSpecPars.cc @@ -32,7 +32,7 @@ void DDTestSpecPars::analyze(const Event&, const EventSetup& iEventSetup) { LogVerbatim("Geometry").log([®istry](auto& log) { log << "DD SpecPar Registry size: " << registry->specpars.size(); for (const auto& i : registry->specpars) { - log << " " << i.first << " == " << std::string({i.second.name.data(), i.second.name.size()}) << " =>"; + log << " " << i.first << " =>"; log << "\npaths:\n"; for (const auto& k : i.second.paths) log << k << ", "; diff --git a/DetectorDescription/DDCMS/plugins/test/DDTestSpecParsFilter.cc b/DetectorDescription/DDCMS/plugins/test/DDTestSpecParsFilter.cc index 7ca45d554f9e2..3f96052842367 100644 --- a/DetectorDescription/DDCMS/plugins/test/DDTestSpecParsFilter.cc +++ b/DetectorDescription/DDCMS/plugins/test/DDTestSpecParsFilter.cc @@ -52,10 +52,10 @@ void DDTestSpecParsFilter::analyze(const Event&, const EventSetup& iEventSetup) log << "Filtered DD SpecPar Registry size: " << myReg.size() << "\n"; for (const auto& t : myReg) { log << "\nRegExps { "; - for (const auto& ki : t->paths) + for (const auto& ki : t.second->paths) log << ki << " "; log << "};\n "; - for (const auto& kl : t->spars) { + for (const auto& kl : t.second->spars) { log << kl.first << " = "; for (const auto& kil : kl.second) { log << kil << " "; @@ -65,9 +65,9 @@ void DDTestSpecParsFilter::analyze(const Event&, const EventSetup& iEventSetup) } }); std::cout << "*** Check names in a path after filtering:\n"; - for (auto it : myReg) { - if (it->hasPath("//ME11AlumFrame")) { - std::cout << it->name << "\n"; + for (const auto& it : myReg) { + if (it.second->hasPath("//ME11AlumFrame")) { + std::cout << it.first << "\n"; } } } diff --git a/DetectorDescription/DDCMS/src/DDCompactView.cc b/DetectorDescription/DDCMS/src/DDCompactView.cc index b434b15e912fc..31c99522e8b64 100644 --- a/DetectorDescription/DDCMS/src/DDCompactView.cc +++ b/DetectorDescription/DDCMS/src/DDCompactView.cc @@ -3,7 +3,7 @@ #include #include -#include "tbb/concurrent_vector.h" +#include template <> std::vector cms::DDCompactView::getVector(const std::string& key) const { @@ -42,8 +42,8 @@ std::vector const& cms::DDCompactView::get>(const st } template <> -tbb::concurrent_vector const& cms::DDCompactView::get>( - const std::string& name, const std::string& key) const { +std::vector const& cms::DDCompactView::get>(const std::string& name, + const std::string& key) const { const auto& spec = specpars().specPar(name); if (spec != nullptr) { auto const& nitem = spec->numpars.find(key); diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index c922a9e8c394e..04febf2136a10 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -50,11 +50,11 @@ DDFilteredView::DDFilteredView(const DDCompactView& cpv, const cms::DDFilter& fi log << "Filtered by an attribute " << filter.attribute() << "==" << filter.value() << " DD SpecPar Registry size: " << refs_.size() << "\n"; for (const auto& t : refs_) { - log << "\nRegExps { "; - for (const auto& ki : t->paths) + log << "\nSpecPar " << std::string(t.first.data(), t.first.size()) << "\nRegExps { "; + for (const auto& ki : t.second->paths) log << ki << " "; log << "};\n "; - for (const auto& kl : t->spars) { + for (const auto& kl : t.second->spars) { log << kl.first << " = "; for (const auto& kil : kl.second) { log << kil << " "; @@ -156,65 +156,112 @@ void DDFilteredView::rot(dd4hep::Rotation3D& matrixOut) const { rotation[8]); } -void DDFilteredView::mergedSpecifics(DDSpecParRefs const& specs) { +void DDFilteredView::mergedSpecifics(DDSpecParRefs const& specPars) { currentSpecPar_ = nullptr; - if (!filters_.empty()) { filters_.clear(); filters_.shrink_to_fit(); } - for (const auto& i : specs) { - for (const auto& j : i->paths) { - auto const& firstTok = front(j); - auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) { - auto const& k = find_if(begin(f->skeys), end(f->skeys), [&](auto const& p) { return firstTok == p; }); - if (k != end(f->skeys)) { - currentFilter_ = f.get(); + + for (const auto& section : specPars) { + for (const auto& partSelector : section.second->paths) { + auto const& firstPartName = front(partSelector); + auto const& filterMatch = find_if(begin(filters_), end(filters_), [&](auto const& it) { + auto const& key = + find_if(begin(it->skeys), end(it->skeys), [&](auto const& partName) { return firstPartName == partName; }); + if (key != end(it->skeys)) { + currentFilter_ = it.get(); return true; } return false; }); - if (filter == end(filters_)) { - filters_.emplace_back(unique_ptr( - new Filter{{firstTok}, - {std::regex(std::string("^").append({firstTok.data(), firstTok.size()}).append("$"))}, - nullptr, - nullptr, - i})); + if (filterMatch == end(filters_)) { + filters_.emplace_back(make_unique()); + filters_.back()->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(firstPartName)); + if (dd4hep::dd::isRegex(firstPartName)) { + filters_.back()->isRegex.emplace_back(true); + filters_.back()->index.emplace_back(filters_.back()->keys.size()); + filters_.back()->keys.emplace_back(std::regex(std::begin(firstPartName), std::end(firstPartName))); + } else { + filters_.back()->isRegex.emplace_back(false); + filters_.back()->index.emplace_back(filters_.back()->skeys.size()); + } + filters_.back()->skeys.emplace_back(firstPartName); + filters_.back()->up = nullptr; + filters_.back()->next = nullptr; + filters_.back()->spec = section.second; // initialize current filter if it's empty if (currentFilter_ == nullptr) { currentFilter_ = filters_.back().get(); } } // all next levels - vector toks = split(j, "/"); + vector toks = split(partSelector, "/"); for (size_t pos = 1; pos < toks.size(); ++pos) { if (currentFilter_->next != nullptr) { currentFilter_ = currentFilter_->next.get(); - auto const& l = find_if(begin(currentFilter_->skeys), end(currentFilter_->skeys), [&](auto const& p) { + auto const& key = find_if(begin(currentFilter_->skeys), end(currentFilter_->skeys), [&](auto const& p) { return toks.front() == p; }); - if (l == end(currentFilter_->skeys)) { + if (key == end(currentFilter_->skeys)) { + currentFilter_->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(toks[pos])); + if (dd4hep::dd::isRegex(toks[pos])) { + currentFilter_->isRegex.emplace_back(true); + currentFilter_->index.emplace_back(currentFilter_->keys.size()); + currentFilter_->keys.emplace_back(std::regex(std::begin(toks[pos]), std::end(toks[pos]))); + } else { + currentFilter_->isRegex.emplace_back(false); + currentFilter_->index.emplace_back(currentFilter_->skeys.size()); + } currentFilter_->skeys.emplace_back(toks[pos]); - currentFilter_->keys.emplace_back( - std::regex(std::string("^").append({toks[pos].data(), toks[pos].size()}).append("$"))); } } else { - currentFilter_->next.reset( - new Filter{{toks[pos]}, - {std::regex(std::string("^").append({toks[pos].data(), toks[pos].size()}).append("$"))}, - nullptr, - currentFilter_, - i}); + auto nextLevelFilter = std::make_unique(); + bool isRegex = dd4hep::dd::isRegex(toks[pos]); + nextLevelFilter->isRegex.emplace_back(isRegex); + nextLevelFilter->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(toks[pos])); + if (isRegex) { + nextLevelFilter->index.emplace_back(filters_.back()->keys.size()); + nextLevelFilter->keys.emplace_back(std::regex(toks[pos].begin(), toks[pos].end())); + } else { + nextLevelFilter->index.emplace_back(filters_.back()->skeys.size()); + } + nextLevelFilter->skeys.emplace_back(toks[pos]); + nextLevelFilter->next = nullptr; + nextLevelFilter->up = currentFilter_; + nextLevelFilter->spec = section.second; + + currentFilter_->next = std::move(nextLevelFilter); } } } } } +void print(const Filter* filter) { + edm::LogVerbatim("Geometry").log([&](auto& log) { + for (const auto& it : filter->skeys) { + log << it << ", "; + } + }); +} + void DDFilteredView::printFilter() const { for (const auto& f : filters_) { - f->print(); + edm::LogVerbatim("Geometry").log([&](auto& log) { + log << "\nFilter: "; + for (const auto& it : f->skeys) { + log << it << ", "; + } + if (f->next) { + log << "\nNext: "; + print(&*f->next); + } + if (f->up) { + log << "Up: "; + print(f->up); + } + }); } } @@ -368,7 +415,7 @@ bool DDFilteredView::firstSibling() { else return false; do { - if (accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + if (dd4hep::dd::accepted(currentFilter_, noNamespace(node->GetVolume()->GetName()))) { node_ = node; return true; } @@ -390,7 +437,7 @@ bool DDFilteredView::nextSibling() { it_.back().SetType(1); Node* node = node_; do { - if (accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + if (dd4hep::dd::accepted(currentFilter_, noNamespace(node->GetVolume()->GetName()))) { node_ = node; return true; } @@ -408,7 +455,7 @@ bool DDFilteredView::sibling() { it_.back().SetType(1); Node* node = nullptr; while ((node = it_.back().Next())) { - if (accepted(currentFilter_->keys, node->GetVolume()->GetName())) { + if (dd4hep::dd::accepted(currentFilter_, node->GetVolume()->GetName())) { node_ = node; return true; } @@ -424,7 +471,7 @@ bool DDFilteredView::checkChild() { it_.back().SetType(1); Node* node = nullptr; while ((node = it_.back().Next())) { - if (accepted(currentFilter_->keys, node->GetVolume()->GetName())) { + if (dd4hep::dd::accepted(currentFilter_, node->GetVolume()->GetName())) { return true; } } @@ -478,14 +525,12 @@ void DDFilteredView::up() { } bool DDFilteredView::accept(std::string_view name) { - bool result = false; for (const auto& it : filters_) { currentFilter_ = it.get(); - result = accepted(currentFilter_->keys, name); - if (result) - return result; + if (dd4hep::dd::accepted(currentFilter_, name)) + return true; } - return result; + return false; } const std::vector DDFilteredView::parameters() const { @@ -664,10 +709,11 @@ const DDSpecPar* DDFilteredView::find(const std::string& key) const { filter(specParRefs, key); for (auto const& specPar : specParRefs) { - auto pos = find_if( - begin(specPar->paths), end(specPar->paths), [&](auto const& partSelector) { return matchPath(partSelector); }); - if (pos != end(specPar->paths)) { - return specPar; + auto pos = find_if(begin(specPar.second->paths), end(specPar.second->paths), [&](auto const& partSelector) { + return matchPath(partSelector); + }); + if (pos != end(specPar.second->paths)) { + return specPar.second; } } @@ -677,7 +723,7 @@ const DDSpecPar* DDFilteredView::find(const std::string& key) const { void DDFilteredView::filter(DDSpecParRefs& refs, const std::string& key) const { for (auto const& it : registry_->specpars) { if (it.second.hasValue(key) || (it.second.spars.find(key) != end(it.second.spars))) { - refs.emplace_back(&it.second); + refs.emplace_back(it.first, &it.second); } } } @@ -809,7 +855,9 @@ double DDFilteredView::getNextValue(const std::string& key) const { return result; } -std::string_view DDFilteredView::name() const { return (volume().volume().name()); } +std::string_view DDFilteredView::name() const { + return (node_ == nullptr ? std::string_view() : (volume().volume().name())); +} dd4hep::Solid DDFilteredView::solid() const { return (volume().volume().solid()); } diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc index 4e5b453e7adfb..3c2ccf0736375 100644 --- a/DetectorDescription/DDCMS/src/DDNamespace.cc +++ b/DetectorDescription/DDCMS/src/DDNamespace.cc @@ -109,6 +109,7 @@ void DDNamespace::addConstantNS(const string& name, const string& val, const str type.c_str()); dd4hep::_toDictionary(n, v, type); dd4hep::Constant c(n, v, type); + m_context->description.addConstant(c); } diff --git a/DetectorDescription/DDCMS/test/BuildFile.xml b/DetectorDescription/DDCMS/test/BuildFile.xml index 3a55304f92426..9e6f6b904bd6b 100644 --- a/DetectorDescription/DDCMS/test/BuildFile.xml +++ b/DetectorDescription/DDCMS/test/BuildFile.xml @@ -2,36 +2,43 @@ + + + + + + + @@ -48,6 +55,7 @@ + diff --git a/DetectorDescription/DDCMS/test/Filter.cppunit.cc b/DetectorDescription/DDCMS/test/Filter.cppunit.cc index 982d30390999d..c82f6f698220f 100644 --- a/DetectorDescription/DDCMS/test/Filter.cppunit.cc +++ b/DetectorDescription/DDCMS/test/Filter.cppunit.cc @@ -41,7 +41,6 @@ void testFilter::setUp() { for (const auto& i : selections) { vector toks = split(i, "/"); - unique_ptr f = nullptr; auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) { auto const& k = find_if(begin(f->skeys), end(f->skeys), [&](auto const& p) { return toks.front() == p; }); if (k != end(f->skeys)) { @@ -51,8 +50,19 @@ void testFilter::setUp() { return false; }); if (filter == end(filters_)) { - filters_.emplace_back(unique_ptr(new Filter{ - {toks.front()}, {std::regex(std::string(toks.front().data(), toks.front().size()))}, nullptr, nullptr})); + bool isRegex = dd4hep::dd::isRegex(toks.front()); + filters_.emplace_back(make_unique()); + filters_.back()->isRegex.emplace_back(isRegex); + filters_.back()->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(toks.front())); + if (isRegex) { + filters_.back()->index.emplace_back(filters_.back()->keys.size()); + filters_.back()->keys.emplace_back(std::regex(std::begin(toks.front()), std::end(toks.front()))); + } else { + filters_.back()->index.emplace_back(filters_.back()->skeys.size()); + } + filters_.back()->skeys.emplace_back(toks.front()); + filters_.back()->up = nullptr; + filters_.back()->spec = nullptr; currentFilter = filters_.back().get(); } // all next levels @@ -62,12 +72,33 @@ void testFilter::setUp() { auto const& l = find_if( begin(currentFilter->skeys), end(currentFilter->skeys), [&](auto const& p) { return toks[pos] == p; }); if (l == end(currentFilter->skeys)) { - currentFilter->skeys.emplace_back(toks.front()); - currentFilter->keys.emplace_back(std::regex(std::string(toks.front().data(), toks.front().size()))); + bool isRegex = dd4hep::dd::isRegex(toks[pos]); + currentFilter->isRegex.emplace_back(isRegex); + currentFilter->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(toks[pos])); + if (isRegex) { + currentFilter->index.emplace_back(currentFilter->keys.size()); + currentFilter->keys.emplace_back(std::regex(std::begin(toks[pos]), std::end(toks[pos]))); + } else { + currentFilter->index.emplace_back(currentFilter->skeys.size()); + } + currentFilter->skeys.emplace_back(toks[pos]); } } else { - currentFilter->next.reset(new Filter{ - {toks[pos]}, {std::regex(std::string({toks[pos].data(), toks[pos].size()}))}, nullptr, currentFilter}); + auto filter = std::make_unique(); + bool isRegex = dd4hep::dd::isRegex(toks[pos]); + filter->isRegex.emplace_back(isRegex); + filter->hasNamespace.emplace_back(dd4hep::dd::hasNamespace(toks[pos])); + if (isRegex) { + filter->index.emplace_back(filters_.back()->keys.size()); + filter->keys.emplace_back(std::regex(toks[pos].begin(), toks[pos].end())); + } else { + filter->index.emplace_back(filters_.back()->skeys.size()); + } + filter->skeys.emplace_back(toks[pos]); + filter->next = nullptr; + filter->up = currentFilter; + + currentFilter->next = std::move(filter); } } } @@ -75,7 +106,7 @@ void testFilter::setUp() { void testFilter::checkFilter() { string_view name = "MB2P.*"sv; - CPPUNIT_ASSERT(std::regex_match(std::string({name.data(), name.size()}), filters_.front()->keys.front()) == 1); + CPPUNIT_ASSERT(std::regex_match(name.begin(), name.end(), filters_.front()->keys.front()) == 1); CPPUNIT_ASSERT(filters_.front()->up == nullptr); CPPUNIT_ASSERT(filters_.front()->next != nullptr); CPPUNIT_ASSERT(filters_.size() == 1); @@ -84,6 +115,10 @@ void testFilter::checkFilter() { for (auto const& i : filters_) { current = i.get(); do { + for (auto const& i : current->skeys) { + std::cout << i << ", "; + } + std::cout << "\n"; current = current->next.get(); } while (current != nullptr); } diff --git a/Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml b/Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml index 521f45c29cc66..ade5ecbed2f23 100644 --- a/Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml +++ b/Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml @@ -1,7 +1,7 @@ - + diff --git a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc index 8cb2e58e43d96..8fac42a0d9199 100644 --- a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc +++ b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc @@ -121,11 +121,11 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E edm::LogVerbatim("Geometry").log([&specs](auto& log) { log << "Filtered DD SpecPar Registry size: " << specs.size() << "\n"; for (const auto& t : specs) { - log << "\nRegExps { "; - for (const auto& ki : t->paths) + log << "\nSpecPar " << t.first << ":\nRegExps { "; + for (const auto& ki : t.second->paths) log << ki << " "; log << "};\n "; - for (const auto& kl : t->spars) { + for (const auto& kl : t.second->spars) { log << kl.first << " = "; for (const auto& kil : kl.second) { log << kil << " "; @@ -193,7 +193,7 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E bool isSens = false; for (auto const& t : specs) { - for (auto const& it : t->paths) { + for (auto const& it : t.second->paths) { if (dd4hep::dd::compareEqual(fv.name(), dd4hep::dd::realTopName(it))) { isSens = true; break; diff --git a/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc b/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc index 9514140f1a17d..d16aac25d1390 100644 --- a/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc +++ b/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc @@ -112,10 +112,10 @@ void DD4hep_MTDTopologyAnalyzer::analyze(const edm::Event& iEvent, const edm::Ev log << "Filtered DD SpecPar Registry size: " << specs.size() << "\n"; for (const auto& t : specs) { log << "\nRegExps { "; - for (const auto& ki : t->paths) + for (const auto& ki : t.second->paths) log << ki << " "; log << "};\n "; - for (const auto& kl : t->spars) { + for (const auto& kl : t.second->spars) { log << kl.first << " = "; for (const auto& kil : kl.second) { log << kil << " "; @@ -178,7 +178,7 @@ void DD4hep_MTDTopologyAnalyzer::analyze(const edm::Event& iEvent, const edm::Ev bool isSens = false; for (auto const& t : specs) { - for (auto const& it : t->paths) { + for (auto const& it : t.second->paths) { if (dd4hep::dd::compareEqual(fv.name(), dd4hep::dd::realTopName(it))) { isSens = true; break; diff --git a/SimG4Core/DD4hepGeometry/test/plugins/DD4hepTestDDDWorld.cc b/SimG4Core/DD4hepGeometry/test/plugins/DD4hepTestDDDWorld.cc index 4a8faa9e74551..3ab1eeaf56d4a 100644 --- a/SimG4Core/DD4hepGeometry/test/plugins/DD4hepTestDDDWorld.cc +++ b/SimG4Core/DD4hepGeometry/test/plugins/DD4hepTestDDDWorld.cc @@ -106,14 +106,14 @@ void DD4hepTestDDDWorld::initialize(const dd4hep::sim::Geant4GeometryMaps::Volum LogVerbatim("Geometry").log([&](auto& log) { for (auto const& it : vmap) { for (auto const& fit : specs_) { - for (auto const& sit : fit->spars) { + for (auto const& sit : fit.second->spars) { log << sit.first << " = " << sit.second[0] << "\n"; } - for (auto const& pit : fit->paths) { + for (auto const& pit : fit.second->paths) { log << dd4hep::dd::realTopName(pit) << "\n"; log << " compare equal to " << dd4hep::dd::noNamespace(it.first.name()) << " ... "; if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first.name()), dd4hep::dd::realTopName(pit))) { - vec_.emplace_back(std::make_pair(&*it.second, &*fit)); + vec_.emplace_back(std::make_pair(&*it.second, &*fit.second)); log << " are equal!\n"; } else log << " nope.\n"; diff --git a/SimG4Core/Geometry/src/DD4hep_DDG4Builder.cc b/SimG4Core/Geometry/src/DD4hep_DDG4Builder.cc index 41a8aff41385a..0ffb65513965f 100644 --- a/SimG4Core/Geometry/src/DD4hep_DDG4Builder.cc +++ b/SimG4Core/Geometry/src/DD4hep_DDG4Builder.cc @@ -41,9 +41,9 @@ G4VPhysicalVolume *DDG4Builder::BuildGeometry(SensitiveDetectorCatalog &catalog) specPars.filter(specs, "SensitiveDetector"); for (auto const &it : map_) { for (auto const &fit : specs) { - for (auto const &pit : fit->paths) { - if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first.name()), dd4hep::dd::realTopName(pit))) { - dd4hepVec.emplace_back(&*it.second, &*fit); + for (auto const &pit : fit.second->paths) { + if (dd4hep::dd::compareEqualName(dd4hep::dd::realTopName(pit), dd4hep::dd::noNamespace(it.first.name()))) { + dd4hepVec.emplace_back(&*it.second, &*fit.second); } } } diff --git a/SimG4Core/Geometry/src/DDG4ProductionCuts.cc b/SimG4Core/Geometry/src/DDG4ProductionCuts.cc index a50c3530b541a..23f66e0c14f67 100644 --- a/SimG4Core/Geometry/src/DDG4ProductionCuts.cc +++ b/SimG4Core/Geometry/src/DDG4ProductionCuts.cc @@ -113,9 +113,9 @@ void DDG4ProductionCuts::dd4hepInitialize() { for (auto const& it : *dd4hepMap_) { for (auto const& fit : specs) { - for (auto const& pit : fit->paths) { + for (auto const& pit : fit.second->paths) { if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first.name()), dd4hep::dd::realTopName(pit))) { - dd4hepVec_.emplace_back(std::make_pair(&*it.second, &*fit)); + dd4hepVec_.emplace_back(std::make_pair(&*it.second, &*fit.second)); } } } diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListGroups.cc b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListGroups.cc index 306e61d48c51b..35335a64c2b7b 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListGroups.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListGroups.cc @@ -367,7 +367,7 @@ void DD4hep_ListGroups::analyze(const edm::Event &evt, const edm::EventSetup &se cms::DDFilteredView fv(*cpv, filter); for (const auto &t : fv.specpars()) { - m_group_names.insert(t->strValue("TrackingMaterialGroup")); + m_group_names.insert(t.second->strValue("TrackingMaterialGroup")); } for (const auto &i : m_group_names) { @@ -375,8 +375,8 @@ void DD4hep_ListGroups::analyze(const edm::Event &evt, const edm::EventSetup &se cms::DDFilteredView fv1(*cpv, filter1); bool firstChild = fv1.firstChild(); - for (const auto j : fv1.specpars()) { - for (const auto &k : j->paths) { + for (const auto &j : fv1.specpars()) { + for (const auto &k : j.second->paths) { if (firstChild) { std::vector> children = fv1.children(k); for (auto const &path : children) { diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListIds.cc b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListIds.cc index b5a29926e1086..d829b23665cc3 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListIds.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_ListIds.cc @@ -51,7 +51,7 @@ void DD4hep_ListIds::analyze(const edm::Event &evt, const edm::EventSetup &setup std::set tkdss; for (const auto &t : fv.specpars()) { - tkdss.insert(t->strValue(attribute)); + tkdss.insert(t.second->strValue(attribute)); } for (const auto &i : tkdss) { diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_MaterialAccountingGroup.cc b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_MaterialAccountingGroup.cc index 8dc741b90338b..896eac59774e5 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_MaterialAccountingGroup.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/dd4hep/DD4hep_MaterialAccountingGroup.cc @@ -34,8 +34,8 @@ DD4hep_MaterialAccountingGroup::DD4hep_MaterialAccountingGroup(const std::string edm::LogVerbatim("TrackingMaterialAnalysis") << "Elements within: " << name; - for (const auto j : fv.specpars()) { - for (const auto& k : j->paths) { + for (const auto& j : fv.specpars()) { + for (const auto& k : j.second->paths) { if (firstChild) { std::vector> children = fv.children(k); for (auto const& path : children) {