diff --git a/CondTools/Geometry/plugins/BuildFile.xml b/CondTools/Geometry/plugins/BuildFile.xml
index 826ab89bacd32..d47dbefafb61d 100644
--- a/CondTools/Geometry/plugins/BuildFile.xml
+++ b/CondTools/Geometry/plugins/BuildFile.xml
@@ -2,6 +2,7 @@
+
diff --git a/CondTools/Geometry/plugins/PGeometricDetBuilder.cc b/CondTools/Geometry/plugins/PGeometricDetBuilder.cc
index 57b8f4adad759..2e9fae089ae4c 100644
--- a/CondTools/Geometry/plugins/PGeometricDetBuilder.cc
+++ b/CondTools/Geometry/plugins/PGeometricDetBuilder.cc
@@ -8,6 +8,7 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "CondFormats/GeometryObjects/interface/PGeometricDet.h"
+#include "DataFormats/Math/interface/Rounding.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
@@ -136,20 +137,24 @@ void PGeometricDetBuilder::putOne(const GeometricDet* gd, PGeometricDet* pgd, in
item._name = gd->name();
item._ns = std::string();
item._level = lev;
- item._x = tran.X();
- item._y = tran.Y();
- item._z = tran.Z();
+ using cms_rounding::roundIfNear0;
+ const double tol = 1.e-10;
+ // Round very small calculated values to 0 to avoid discrepancies
+ // between +0 and -0 in comparisons.
+ item._x = roundIfNear0(tran.X(), tol);
+ item._y = roundIfNear0(tran.Y(), tol);
+ item._z = roundIfNear0(tran.Z(), tol);
item._phi = gd->phi();
item._rho = gd->rho();
- item._a11 = x.X();
- item._a12 = y.X();
- item._a13 = z.X();
- item._a21 = x.Y();
- item._a22 = y.Y();
- item._a23 = z.Y();
- item._a31 = x.Z();
- item._a32 = y.Z();
- item._a33 = z.Z();
+ item._a11 = roundIfNear0(x.X(), tol);
+ item._a12 = roundIfNear0(y.X(), tol);
+ item._a13 = roundIfNear0(z.X(), tol);
+ item._a21 = roundIfNear0(x.Y(), tol);
+ item._a22 = roundIfNear0(y.Y(), tol);
+ item._a23 = roundIfNear0(z.Y(), tol);
+ item._a31 = roundIfNear0(x.Z(), tol);
+ item._a32 = roundIfNear0(y.Z(), tol);
+ item._a33 = roundIfNear0(z.Z(), tol);
item._shape = static_cast(gd->shape_dd4hep());
item._type = gd->type();
if (gd->shape_dd4hep() == cms::DDSolidShape::ddbox) {
diff --git a/CondTools/Geometry/test/writehelpers/createExtended2021DD4hepPayloads.sh b/CondTools/Geometry/test/writehelpers/createExtended2021DD4hepPayloads.sh
new file mode 100755
index 0000000000000..18a02b05a2da5
--- /dev/null
+++ b/CondTools/Geometry/test/writehelpers/createExtended2021DD4hepPayloads.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+
+if [ $# -ne 1 ]
+then
+ echo Error: createExtended2021Payloads.sh requires exactly one argument which is the tag
+ exit 1
+fi
+mytag=$1
+echo ${mytag}
+
+# Set the tag in all the scripts and the metadata text files
+sed -i {s/TagXX/${mytag}/g} *.py
+compgen -G "*.txt" > /dev/null && sed -i {s/TagXX/${mytag}/g} *.txt
+sed -i {s/TagXX/${mytag}/g} splitExtended2021Database.sh
+
+# First read in the little XML files and create the
+# large XML file for the Phase1_R30F12_HCal Ideal scenario.
+# Input cff Output file
+# GeometryExtended2021_cff geSingleBigFile.xml
+cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# Now convert the content of the large XML file into
+# a "blob" and write it to the database.
+# Also reads in the little XML files again and fills
+# the DDCompactView. From the DDCompactView the
+# reco parts of the database are also filled.
+cmsRun geometryExtended2021DD4hep_writer.py
+
+# Now put the other scenarios into the database.
+# Input the many XML files referenced by the cff file and
+# output a single big XML file.
+# This is repeated several times below. The sed commands
+# serve to give the following sequence of input and output
+# files
+#
+# Input cff Output file
+# GeometryIdeal_cff giSingleBigFile.xml
+#
+# sed -i '{s/Extended2021/Extended2021ZeroMaterial/g}' geometryExtended2021DD4hep_xmlwriter.py
+# sed -i '{s/\/ge/\/gez/g}' geometryExtended2021DD4hep_xmlwriter.py
+# cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# sed -i '{s/Extended2021ZeroMaterial/Extended2021FlatMinus05Percent/g}' geometryExtended2021DD4hep_xmlwriter.py
+# sed -i '{s/\/gez/\/geFM05/g}' geometryExtended2021DD4hep_xmlwriter.py
+# cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# sed -i '{s/Extended2021FlatMinus05Percent/Extended2021FlatMinus10Percent/g}' geometryExtended2021DD4hep_xmlwriter.py
+# sed -i '{s/\/geFM05/\/geFM10/g}' geometryExtended2021DD4hep_xmlwriter.py
+# cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# sed -i '{s/Extended2021FlatMinus10Percent/Extended2021FlatPlus05Percent/g}' geometryExtended2021DD4hep_xmlwriter.py
+# sed -i '{s/\/geFM10/\/geFP05/g}' geometryExtended2021DD4hep_xmlwriter.py
+# cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# sed -i '{s/Extended2021FlatPlus05Percent/Extended2021FlatPlus10Percent/g}' geometryExtended2021DD4hep_xmlwriter.py
+# sed -i '{s/\/geFP05/\/geFP10/g}' geometryExtended2021DD4hep_xmlwriter.py
+# cmsRun geometryExtended2021DD4hep_xmlwriter.py
+
+# Read the one big XML file and output a record to the
+# database with the an identifying tag
+# This is repeated several times below. The sed commands
+# serve to give the following sequence of input file and output
+# tag
+#
+# Input file Output tag
+# gezSingleBigFile.xml XMLFILE_Geometry_${mytag}_Extended2021ZeroMaterial_mc
+#
+# sed -i '{s/Extended/Extended2021ZeroMaterial/g}' xmlgeometrywriter.py
+# sed -i '{s/\/ge/\/gez/g}' xmlgeometrywriter.py
+# cmsRun xmlgeometrywriter.py
+
+# sed -i '{s/Extended2021ZeroMaterial/Extended2021FlatMinus05Percent/g}' xmlgeometrywriter.py
+# sed -i '{s/\/gez/\/geFM05/g}' xmlgeometrywriter.py
+# cmsRun xmlgeometrywriter.py
+
+# sed -i '{s/Extended2021FlatMinus05Percent/Extended2021FlatMinus10Percent/g}' xmlgeometrywriter.py
+# sed -i '{s/\/geFM05/\/geFM10/g}' xmlgeometrywriter.py
+# cmsRun xmlgeometrywriter.py
+
+# sed -i '{s/Extended2021FlatMinus10Percent/Extended2021FlatPlus05Percent/g}' xmlgeometrywriter.py
+# sed -i '{s/\/geFM10/\/geFP05/g}' xmlgeometrywriter.py
+# cmsRun xmlgeometrywriter.py
+
+# sed -i '{s/Extended2021FlatPlus05Percent/Extended2021FlatPlus10Percent/g}' xmlgeometrywriter.py
+# sed -i '{s/\/geFP05/\/geFP10/g}' xmlgeometrywriter.py
+# cmsRun xmlgeometrywriter.py
+
+# All the database objects were written into one database
+# (myfile.db) in the steps above. Extract the different
+# pieces into separate database files. These are the payloads
+# that get uploaded to the dropbox. There is one for each tag
+./splitExtended2021Database.sh
diff --git a/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_writer.py b/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_writer.py
new file mode 100644
index 0000000000000..554423ee90704
--- /dev/null
+++ b/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_writer.py
@@ -0,0 +1,80 @@
+import FWCore.ParameterSet.Config as cms
+from Configuration.Eras.Era_Run3_dd4hep_cff import Run3_dd4hep
+
+process = cms.Process("GeometryWriter", Run3_dd4hep)
+
+from Configuration.ProcessModifiers.dd4hep_cff import dd4hep
+
+process.load('CondCore.CondDB.CondDB_cfi')
+
+process.load('Configuration.Geometry.GeometryDD4hepExtended2021_cff')
+process.load('Geometry.CaloEventSetup.CaloGeometryDBWriter_cfi')
+process.load('CondTools.Geometry.HcalParametersWriter_cff')
+process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
+
+process.CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder",
+ SelectedCalos = cms.vstring(
+ 'HCAL',
+ 'ZDC',
+ 'EcalBarrel',
+ 'EcalEndcap',
+ 'EcalPreshower',
+ 'TOWER'
+ )
+)
+
+process.source = cms.Source("EmptyIOVSource",
+ lastValue = cms.uint64(1),
+ timetype = cms.string('runnumber'),
+ firstValue = cms.uint64(1),
+ interval = cms.uint64(1)
+ )
+
+# This reads the big XML file and the only way to fill the
+# nonreco part of the database is to read this file.
+process.XMLGeometryWriter = cms.EDAnalyzer("XMLGeometryBuilder",
+ XMLFileName = cms.untracked.string("./geSingleBigFile.xml"),
+ ZIP = cms.untracked.bool(True)
+ )
+
+process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool(True))
+process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool(True))
+
+process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder",fromDD4Hep = cms.untracked.bool(True))
+
+process.CSCGeometryWriter = cms.EDAnalyzer("CSCRecoIdealDBLoader",fromDD4Hep = cms.untracked.bool(True))
+
+process.DTGeometryWriter = cms.EDAnalyzer("DTRecoIdealDBLoader",fromDD4Hep = cms.untracked.bool(True))
+
+process.RPCGeometryWriter = cms.EDAnalyzer("RPCRecoIdealDBLoader",fromDD4Hep = cms.untracked.bool(True))
+
+process.GEMGeometryWriter = cms.EDAnalyzer("GEMRecoIdealDBLoader",fromDD4Hep = cms.untracked.bool(True))
+
+process.CondDB.timetype = cms.untracked.string('runnumber')
+process.CondDB.connect = cms.string('sqlite_file:myfile.db')
+process.PoolDBOutputService = cms.Service("PoolDBOutputService",
+ process.CondDB,
+ toPut = cms.VPSet(cms.PSet(record = cms.string('GeometryFileRcd'),tag = cms.string('XMLFILE_Geometry_TagXX_Extended2021_mc')),
+ cms.PSet(record = cms.string('IdealGeometryRecord'),tag = cms.string('TKRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PTrackerParametersRcd'),tag = cms.string('TKParameters_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PEcalBarrelRcd'), tag = cms.string('EBRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PEcalEndcapRcd'), tag = cms.string('EERECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PEcalPreshowerRcd'),tag = cms.string('EPRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PHcalRcd'), tag = cms.string('HCALRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('HcalParametersRcd'), tag = cms.string('HCALParameters_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PCaloTowerRcd'), tag = cms.string('CTRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PZdcRcd'), tag = cms.string('ZDCRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('PCastorRcd'), tag = cms.string('CASTORRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('CSCRecoGeometryRcd'),tag = cms.string('CSCRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('CSCRecoDigiParametersRcd'),tag = cms.string('CSCRECODIGI_Geometry_TagXX')),
+ cms.PSet(record = cms.string('DTRecoGeometryRcd'),tag = cms.string('DTRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('RPCRecoGeometryRcd'),tag = cms.string('RPCRECO_Geometry_TagXX')),
+ cms.PSet(record = cms.string('GEMRecoGeometryRcd'),tag = cms.string('GEMRECO_Geometry_TagXX'))
+ )
+ )
+
+process.maxEvents = cms.untracked.PSet(
+ input = cms.untracked.int32(1)
+ )
+
+process.p1 = cms.Path(process.XMLGeometryWriter+process.TrackerGeometryWriter+process.TrackerParametersWriter+process.CaloGeometryWriter+process.HcalParametersWriter+process.CSCGeometryWriter+process.DTGeometryWriter+process.RPCGeometryWriter+process.GEMGeometryWriter)
diff --git a/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_xmlwriter.py b/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_xmlwriter.py
new file mode 100644
index 0000000000000..23100a9d6aa84
--- /dev/null
+++ b/CondTools/Geometry/test/writehelpers/geometryExtended2021DD4hep_xmlwriter.py
@@ -0,0 +1,31 @@
+import FWCore.ParameterSet.Config as cms
+
+process = cms.Process("GeometryXMLWriter")
+
+process.source = cms.Source("EmptyIOVSource",
+ lastValue = cms.uint64(1),
+ timetype = cms.string('runnumber'),
+ firstValue = cms.uint64(1),
+ interval = cms.uint64(1)
+ )
+
+process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
+ confGeomXMLFiles = cms.FileInPath('Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml'),
+ appendToDataLabel = cms.string('make-payload')
+ )
+
+process.DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer",
+ appendToDataLabel = cms.string('make-payload')
+ )
+
+process.BigXMLWriter = cms.EDAnalyzer("OutputDD4hepToDDL",
+ fileName = cms.untracked.string("./geSingleBigFile.xml")
+ )
+
+
+process.maxEvents = cms.untracked.PSet(
+ input = cms.untracked.int32(1)
+ )
+
+process.p1 = cms.Path(process.BigXMLWriter)
+
diff --git a/DetectorDescription/DDCMS/interface/DDDetector.h b/DetectorDescription/DDCMS/interface/DDDetector.h
index 8d6f49e8ed543..b1b8ec26125c7 100644
--- a/DetectorDescription/DDCMS/interface/DDDetector.h
+++ b/DetectorDescription/DDCMS/interface/DDDetector.h
@@ -2,7 +2,6 @@
#define DetectorDescription_DDCMS_DDDetector_h
#include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h"
-#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
#include
#include
#include
@@ -12,7 +11,7 @@ class TGeoManager;
namespace cms {
class DDDetector {
public:
- explicit DDDetector(const std::string&, const std::string&, bool bigXML = false, bool makePayload = false);
+ explicit DDDetector(const std::string&, const std::string&, bool bigXML = false);
DDDetector() = delete;
cms::DDVectorsMap const& vectors() const { return m_vectors; }
@@ -35,8 +34,6 @@ namespace cms {
dd4hep::Detector const* description() const { return m_description; }
- DDParsingContext* m_context;
-
private:
void process(const std::string&);
void processXML(const std::string&);
diff --git a/DetectorDescription/DDCMS/interface/DDNamespace.h b/DetectorDescription/DDCMS/interface/DDNamespace.h
index 8dadbefa6bf36..97c0c887dde3e 100644
--- a/DetectorDescription/DDCMS/interface/DDNamespace.h
+++ b/DetectorDescription/DDCMS/interface/DDNamespace.h
@@ -62,12 +62,11 @@ namespace cms {
dd4hep::Solid addSolid(const std::string& name, dd4hep::Solid solid) const;
dd4hep::Solid addSolidNS(const std::string& name, dd4hep::Solid solid) const;
- dd4hep::Assembly assembly(const std::string& name) const;
+ dd4hep::Assembly assembly(const std::string& name, bool exception = true) const;
dd4hep::Assembly addAssembly(dd4hep::Assembly asmb, bool addSolid = true) const;
dd4hep::Assembly addAssemblySolid(dd4hep::Assembly assembly) const;
dd4hep::Volume volume(const std::string& name, bool exc = true) const;
- dd4hep::Volume* getVolPtr(const std::string& name) const;
dd4hep::Volume addVolume(dd4hep::Volume vol) const;
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const;
diff --git a/DetectorDescription/DDCMS/interface/DDParsingContext.h b/DetectorDescription/DDCMS/interface/DDParsingContext.h
index ca95d16507f8b..135571f0fa425 100644
--- a/DetectorDescription/DDCMS/interface/DDParsingContext.h
+++ b/DetectorDescription/DDCMS/interface/DDParsingContext.h
@@ -20,7 +20,6 @@ namespace cms {
rotations.reserve(3000);
shapes.reserve(4000);
volumes.reserve(3000);
- volPtrs.reserve(3000);
unresolvedMaterials.reserve(300);
unresolvedVectors.reserve(300);
unresolvedShapes.reserve(1000);
@@ -82,7 +81,6 @@ namespace cms {
std::unordered_map rotRevMap;
std::unordered_map shapes;
std::unordered_map volumes;
- std::unordered_map volPtrs;
std::vector namespaces;
std::unordered_map> unresolvedMaterials;
diff --git a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc
index 9fff129717e2c..103d46920153f 100644
--- a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc
+++ b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc
@@ -59,7 +59,6 @@ class DDDetectorESProducer : public ESProducer, public EventSetupRecordIntervalF
const string confGeomXMLFiles_;
const string rootDDName_;
const string label_;
- const bool makePayload_;
edm::ESGetToken mfToken_;
edm::ESGetToken geomToken_;
};
@@ -69,8 +68,7 @@ DDDetectorESProducer::DDDetectorESProducer(const ParameterSet& iConfig)
appendToDataLabel_(iConfig.getParameter("appendToDataLabel")),
confGeomXMLFiles_(fromDB_ ? "none" : iConfig.getParameter("confGeomXMLFiles").fullPath()),
rootDDName_(iConfig.getParameter("rootDDName")),
- label_(iConfig.getParameter("label")),
- makePayload_(iConfig.getParameter("makePayload")) {
+ label_(iConfig.getParameter("label")) {
usesResources({edm::ESSharedResourceNames::kDD4Hep});
if (rootDDName_ == "MagneticFieldVolumes:MAGF" || rootDDName_ == "cmsMagneticField:MAGF") {
auto c = setWhatProduced(this,
@@ -98,14 +96,12 @@ void DDDetectorESProducer::fillDescriptions(ConfigurationDescriptions& descripti
desc.add("rootDDName", "cms:OCMS");
desc.add("label", "");
desc.add("fromDB", false);
- desc.add("makePayload", false);
descriptions.add("DDDetectorESProducer", desc);
edm::ParameterSetDescription descDB;
descDB.add("rootDDName", "cms:OCMS");
descDB.add("label", "Extended");
descDB.add("fromDB", true);
- descDB.add("makePayload", false);
descriptions.add("DDDetectorESProducerFromDB", descDB);
}
@@ -135,13 +131,13 @@ DDDetectorESProducer::ReturnType DDDetectorESProducer::produceGeom(const IdealGe
return make_unique(label_, string(tb->begin(), tb->end()), true);
} else {
- return make_unique(appendToDataLabel_, confGeomXMLFiles_, false, makePayload_);
+ return make_unique(appendToDataLabel_, confGeomXMLFiles_, false);
}
}
DDDetectorESProducer::ReturnType DDDetectorESProducer::produce() {
LogVerbatim("Geometry") << "DDDetectorESProducer::Produce " << appendToDataLabel_;
- return make_unique(appendToDataLabel_, confGeomXMLFiles_, false, makePayload_);
+ return make_unique(appendToDataLabel_, confGeomXMLFiles_, false);
}
DEFINE_FWK_EVENTSETUP_SOURCE(DDDetectorESProducer);
diff --git a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc
index fa3403c9b3923..08d81af2650c1 100644
--- a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc
+++ b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc
@@ -931,8 +931,8 @@ void Converter::operator()(xml_h element) const {
Volume parent = ns.volume(parentName, false);
Volume child = ns.volume(childName, false);
- Volume* parentPtr = ns.getVolPtr(parentName);
- Volume* childPtr = ns.getVolPtr(childName);
+ Assembly parAsmb = ns.assembly(parentName, false);
+ Assembly childAsmb = ns.assembly(childName, false);
#ifdef EDM_ML_DEBUG
@@ -948,25 +948,26 @@ void Converter::operator()(xml_h element) const {
#endif
- if (!parent.isValid() && strchr(parentName.c_str(), NAMESPACE_SEP) == nullptr)
+ if (!parent.isValid() && !parAsmb.isValid() && strchr(parentName.c_str(), NAMESPACE_SEP) == nullptr) {
parentName = ns.prepend(parentName);
- parent = ns.volume(parentName, false);
- if (parentPtr == nullptr)
- parentPtr = ns.getVolPtr(parentName);
- if (!parent.isValid() && parentPtr == nullptr)
- throw runtime_error("Unknown volume identifier:" + parentName);
+ parAsmb = ns.assembly(parentName, false);
+ if (!parAsmb.isValid())
+ parent = ns.volume(parentName);
+ }
- if (!child.isValid() && strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
+ if (!child.isValid() && !childAsmb.isValid() && strchr(childName.c_str(), NAMESPACE_SEP) == nullptr) {
childName = ns.prepend(childName);
- child = ns.volume(childName, false);
- if (childPtr == nullptr)
- childPtr = ns.getVolPtr(childName);
- if (childPtr != nullptr && parentPtr != nullptr && ((*parentPtr)->IsAssembly() || (*childPtr)->IsAssembly())) {
+ child = ns.volume(childName, false);
+ childAsmb = ns.assembly(childName, false);
+ }
+ if (parAsmb.isValid() || childAsmb.isValid()) {
printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
"DD4CMS",
"***** Placing assembly parent %s, child %s",
parentName.c_str(),
childName.c_str());
+ Volume* parentPtr = parAsmb.isValid() ? &parAsmb : &parent;
+ Volume* childPtr = childAsmb.isValid() ? &childAsmb : &child;
placeAssembly(parentPtr, parentName, childPtr, childName, copy, transform, ns);
return;
}
@@ -1716,7 +1717,6 @@ void Converter::operator()(xml_h element) const {
ns.context()->debug_shapes ? ALWAYS : DEBUG, "DD4CMS", "+ Assembly: Adding solid -> Assembly: %s", nam.c_str());
#endif
- ns.addSolid(nam, Box(nam, 1, 1, 1)); // Add a dummy solid to allow assembly to be treated like other volumes
ns.addAssemblySolid(nam);
}
@@ -1863,9 +1863,6 @@ void Converter::operator()(xml_h element) const {
Volume child = parent.divide(childName, static_cast(axesmap.at(axis)), numCopies, startInDeg, widthInDeg);
ns.context()->volumes[childName] = child;
- // ns.context()->volPtrs[childName] = &(ns.context()->volumes[childName]);
- // TGeoVolumeMulti objects not needed in volPtrs list, and they cause
- // crash when IsAssembly() method is called on them.
#ifdef EDM_ML_DEBUG
@@ -1901,7 +1898,6 @@ void Converter::operator()(xml_h element) const {
Volume child = parent.divide(childName, static_cast(axesmap.at(axis)), nReplicas, -dy + offset + width, width);
ns.context()->volumes[childName] = child;
- // ns.context()->volPtrs[childName] = &(ns.context()->volumes[childName]);
#ifdef EDM_ML_DEBUG
diff --git a/DetectorDescription/DDCMS/src/DDDetector.cc b/DetectorDescription/DDCMS/src/DDDetector.cc
index 159f081d868cf..a64cb73da092b 100644
--- a/DetectorDescription/DDCMS/src/DDDetector.cc
+++ b/DetectorDescription/DDCMS/src/DDDetector.cc
@@ -1,4 +1,5 @@
#include "DetectorDescription/DDCMS/interface/DDDetector.h"
+#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include
#include
@@ -10,18 +11,23 @@
namespace cms {
- DDDetector::DDDetector(const std::string& tag, const std::string& fileName, bool bigXML, bool makePayload)
- : m_tag(tag) {
+ DDDetector::DDDetector(const std::string& tag, const std::string& fileName, bool bigXML) : m_tag(tag) {
//We do not want to use any previously created TGeoManager but we do want to reset after we are done.
auto oldGeoManager = gGeoManager;
gGeoManager = nullptr;
auto resetManager = [oldGeoManager](TGeoManager*) { gGeoManager = oldGeoManager; };
std::unique_ptr sentry(oldGeoManager, resetManager);
- m_description = &dd4hep::Detector::getInstance(tag);
+ std::string tagStr(m_tag);
+ bool makePayload = false;
+ if (tagStr == "make-payload") {
+ makePayload = true;
+ tagStr = "";
+ }
+ m_description = &dd4hep::Detector::getInstance(tagStr);
m_description->addExtension(&m_vectors);
- m_context = new cms::DDParsingContext(*m_description, makePayload);
- m_description->addExtension(m_context);
+ auto parsingContext = new cms::DDParsingContext(*m_description, makePayload); // Removed at end of constructor
+ m_description->addExtension(parsingContext);
m_description->addExtension(&m_partsels);
m_description->addExtension(&m_specpars);
m_description->setStdConditions("NTP");
diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc
index dcb2a0938f1ba..d656338ca47bb 100644
--- a/DetectorDescription/DDCMS/src/DDFilteredView.cc
+++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc
@@ -553,7 +553,7 @@ const std::vector DDFilteredView::parameters() const {
const cms::DDSolidShape DDFilteredView::shape() const {
assert(node_);
if ((volume().volume())->IsAssembly()) {
- return (cms::DDSolidShape::ddbox); // Return dummy box
+ return (cms::DDSolidShape::ddbox); // Needs to be box to match DDFilteredView::solid()
}
return cms::dd::value(cms::DDSolidShapeMap, std::string(node_->GetVolume()->GetShape()->GetTitle()));
}
@@ -865,6 +865,7 @@ std::string_view DDFilteredView::fullName() const {
dd4hep::Solid DDFilteredView::solid() const {
if ((volume().volume())->IsAssembly()) {
std::string solName(name());
+ // Valid solid is needed, use a dummy box
return (dd4hep::Box(solName, 1., 1., 1.));
}
return (volume().volume().solid());
diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc
index a780974126d20..e71aab1b3429c 100644
--- a/DetectorDescription/DDCMS/src/DDNamespace.cc
+++ b/DetectorDescription/DDCMS/src/DDNamespace.cc
@@ -182,7 +182,6 @@ dd4hep::Volume DDNamespace::addVolumeNS(dd4hep::Volume vol) const {
dd4hep::Material m = vol.material();
vol->SetName(n.c_str());
m_context->volumes[n] = vol;
- m_context->volPtrs[n] = &(m_context->volumes[n]);
const char* solidName = "Invalid solid";
if (s.isValid()) // Protect against seg fault
solidName = s.name(); // If Solid is not valid, s.name() will seg fault.
@@ -201,7 +200,6 @@ dd4hep::Volume DDNamespace::addVolume(dd4hep::Volume vol) const {
dd4hep::Solid s = vol.solid();
dd4hep::Material m = vol.material();
m_context->volumes[n] = vol;
- m_context->volPtrs[n] = &(m_context->volumes[n]);
const char* solidName = "Invalid solid";
if (s.isValid()) // Protect against seg fault
solidName = s.name(); // If Solid is not valid, s.name() will seg fault.
@@ -219,7 +217,6 @@ dd4hep::Volume DDNamespace::addVolume(dd4hep::Volume vol) const {
dd4hep::Assembly DDNamespace::addAssembly(dd4hep::Assembly assembly, bool addSolid) const {
string n = assembly.name();
m_context->assemblies[n] = assembly;
- m_context->volPtrs[n] = &(m_context->assemblies[n]);
if (addSolid) { // In algorithms, Assembly solids are not added separately, so add it here
m_context->assemblySolids.emplace(n);
}
@@ -236,7 +233,7 @@ dd4hep::Assembly DDNamespace::addAssemblySolid(dd4hep::Assembly assembly) const
return assembly;
}
-dd4hep::Assembly DDNamespace::assembly(const std::string& name) const {
+dd4hep::Assembly DDNamespace::assembly(const std::string& name, bool exception) const {
auto i = m_context->assemblies.find(name);
if (i != m_context->assemblies.end()) {
return (*i).second;
@@ -246,7 +243,11 @@ dd4hep::Assembly DDNamespace::assembly(const std::string& name) const {
if (i != m_context->assemblies.end())
return (*i).second;
}
- throw runtime_error("Unknown assembly identifier:" + name);
+ if (exception) {
+ throw runtime_error("Unknown assembly identifier: " + name);
+ }
+ dd4hep::Volume nullVol(nullptr);
+ return nullVol;
}
dd4hep::Volume DDNamespace::volume(const string& name, bool exc) const {
@@ -265,19 +266,6 @@ dd4hep::Volume DDNamespace::volume(const string& name, bool exc) const {
return nullptr;
}
-dd4hep::Volume* DDNamespace::getVolPtr(const string& name) const {
- auto i = m_context->volPtrs.find(name);
- if (i != m_context->volPtrs.end()) {
- return (*i).second;
- }
- if (name.front() == NAMESPACE_SEP) {
- i = m_context->volPtrs.find(name.substr(1, name.size()));
- if (i != m_context->volPtrs.end())
- return (*i).second;
- }
- return nullptr;
-}
-
dd4hep::Solid DDNamespace::addSolidNS(const string& name, dd4hep::Solid solid) const {
dd4hep::printout(m_context->debug_shapes ? dd4hep::ALWAYS : dd4hep::DEBUG,
"DD4CMS",
diff --git a/DetectorDescription/OfflineDBLoader/BuildFile.xml b/DetectorDescription/OfflineDBLoader/BuildFile.xml
index d4a2371c79865..c8b7837494e42 100644
--- a/DetectorDescription/OfflineDBLoader/BuildFile.xml
+++ b/DetectorDescription/OfflineDBLoader/BuildFile.xml
@@ -1,4 +1,9 @@
+
+
+
+
+
diff --git a/DetectorDescription/OfflineDBLoader/interface/DDCoreToDDXMLOutput.h b/DetectorDescription/OfflineDBLoader/interface/DDCoreToDDXMLOutput.h
index 7913a690b3200..69c6ebf2ea5ac 100644
--- a/DetectorDescription/OfflineDBLoader/interface/DDCoreToDDXMLOutput.h
+++ b/DetectorDescription/OfflineDBLoader/interface/DDCoreToDDXMLOutput.h
@@ -14,15 +14,20 @@
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/Core/interface/DDsvalues.h"
+#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
+
+#include "DD4hep/SpecParRegistry.h"
+
+#include "TGeoMaterial.h"
+
class DDPartSelection;
class DDRotation;
struct DDPosData;
/** @class DDCoreToDDXMLOutput DDCoreToDDXMLOutput.h
*
- * @author: Michael Case Initial Version
- * @version: 0.0
- * @date: 17.10.08
+ * @author: Michael Case Revison for DD4hep
+ * @version: 1.0
*
* Description:
* The idea is to store one large XML file containing the XML elements
@@ -34,26 +39,42 @@ struct DDPosData;
struct DDCoreToDDXMLOutput {
void solid(const DDSolid& solid, std::ostream& xos);
+ void solid(const dd4hep::Solid& solid, const cms::DDParsingContext& context, std::ostream& xos);
+ void element(const TGeoMaterial* element, std::ostream& xos);
void material(const DDMaterial& material, std::ostream& xos);
+ void material(
+ const std::pair>>& material,
+ std::ostream& xos);
void rotation(const DDRotation& rotation, std::ostream& xos, const std::string& rotn = "");
+ void rotation(const dd4hep::Rotation3D& rotation,
+ std::ostream& xos,
+ const cms::DDParsingContext& context,
+ const std::string& rotn);
void logicalPart(const DDLogicalPart& lp, std::ostream& xos);
+ void logicalPart(const std::string& asName, std::ostream& xos);
+ void logicalPart(const TGeoVolume& lp, std::ostream& xos);
void position(const DDLogicalPart& parent,
const DDLogicalPart& child,
- DDPosData* edgeToChild
- // , PIdealGeometry& geom
- ,
+ DDPosData* edgeToChild,
int& rotNameSeed,
std::ostream& xos);
+ void position(const TGeoVolume& parent,
+ const TGeoNode& child,
+ const std::string& childName,
+ cms::DDParsingContext& context,
+ std::ostream& xos);
+ //
// left in for now as legacy...
void specpar(const DDSpecifics& sp, std::ostream& xos);
- void specpar(const std::pair >& pssv, std::ostream& xos);
+ void specpar(const std::pair>& pssv, std::ostream& xos);
+ void specpar(const std::string& name, const dd4hep::SpecPar& specPar, std::ostream& xos);
+ static std::string trimShapeName(const std::string& solidName);
std::string ns_; // default namespace
- double tol_;
};
#endif
diff --git a/DetectorDescription/OfflineDBLoader/plugins/OutputDD4hepToDDL.cc b/DetectorDescription/OfflineDBLoader/plugins/OutputDD4hepToDDL.cc
new file mode 100644
index 0000000000000..caa71771f1f6b
--- /dev/null
+++ b/DetectorDescription/OfflineDBLoader/plugins/OutputDD4hepToDDL.cc
@@ -0,0 +1,190 @@
+#include "FWCore/Framework/interface/one/EDAnalyzer.h"
+#include "FWCore/Framework/interface/Event.h"
+#include "FWCore/Framework/interface/EventSetup.h"
+#include "FWCore/Framework/interface/ESTransientHandle.h"
+#include "FWCore/ParameterSet/interface/ParameterSet.h"
+#include "FWCore/Utilities/interface/ESGetToken.h"
+#include "FWCore/Framework/interface/ConsumesCollector.h"
+#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
+#include "FWCore/Framework/interface/MakerMacros.h"
+#include "DataFormats/Math/interface/angle_units.h"
+#include "DetectorDescription/OfflineDBLoader/interface/DDCoreToDDXMLOutput.h"
+#include "DetectorDescription/DDCMS/interface/DDAlgoArguments.h"
+#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
+#include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
+#include "DetectorDescription/DDCMS/interface/DDSolidShapes.h"
+#include "Geometry/Records/interface/IdealGeometryRecord.h"
+
+#include "TGeoManager.h"
+
+#include
+#include
+#include
+#include