Skip to content

Commit

Permalink
Merge pull request #26371 from ianna/dd4hep-mdt-geometry-v0
Browse files Browse the repository at this point in the history
DD4hep: MTD Geometry Description
  • Loading branch information
cmsbuild authored Apr 9, 2019
2 parents bfad7ea + 846d426 commit ea6e7da
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<PosPartSection label="">
<PosPart copyNumber="1">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="cms:OCMS"/>
</PosPart>
</PosPartSection>
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms-mf-geometry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="cms:MCMS"/>
</PosPart>
</PosPartSection>
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms-test-shapes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="testLogicalParts:MotherOfAllBoxes"/>
</PosPart>
</PosPartSection>
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms-tracker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@

<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="tracker:Tracker"/>
</PosPart>
</PosPartSection>
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms_tracker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@

<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="tracker:Tracker"/>
</PosPart>
</PosPartSection>
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/testDDAngularAlgorithm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</Algorithm>
<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="testDDAngularAlgorithm:MotherOfAllBoxes"/>
</PosPart>
<PosPart copyNumber="13">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</Algorithm>
<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rParent name=":world_volume"/>
<rChild name="testDDHGCalCellAlgorithm:MotherOfAllBoxes"/>
</PosPart>
<PosPart copyNumber="1">
Expand Down
30 changes: 17 additions & 13 deletions DetectorDescription/DDCMS/plugins/DDCMSDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,27 @@ DDCMSDetector::analyze(const Event&, const EventSetup& iEventSetup)
ESTransientHandle<DDDetector> det;
iEventSetup.get<GeometryFileRcd>().get(m_tag.module(), det);

LogInfo("DDCMS") << "Iterate over the detectors:\n";
for( auto const& it : det->description()->detectors()) {
dd4hep::DetElement det(it.second);
LogInfo("DDCMS") << it.first << ": " << det.path() << "\n";
}
LogInfo("DDCMS") << "..done!\n";
LogVerbatim("Geometry") << "Iterate over the detectors:\n";
LogVerbatim("Geometry").log([&](auto& log) {
for(auto const& it : det->description()->detectors()) {
dd4hep::DetElement det(it.second);
log << it.first << ": " << det.path();
}
});
LogVerbatim("Geometry") << "..done!";

ESTransientHandle<DDVectorRegistry> registry;
iEventSetup.get<DDVectorRegistryRcd>().get(m_tag.module(), registry);

LogInfo("DDCMS") << "DD Vector Registry size: " << registry->vectors.size() << "\n";
for( const auto& p: registry->vectors ) {
LogInfo("DDCMS") << " " << p.first << " => ";
for( const auto& i : p.second )
LogInfo("DDCMS") << i << ", ";
LogInfo("DDCMS") << '\n';
}
LogVerbatim("Geometry") << "DD Vector Registry size: " << registry->vectors.size();
LogVerbatim("Geometry").log([&](auto& log) {
for(const auto& p: registry->vectors) {
log << " " << p.first << " => ";
for(const auto& i : p.second)
log << i << ", ";
log << '\n';
}
});
}

void
Expand Down
9 changes: 6 additions & 3 deletions DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,9 @@ template <> void Converter<DDLPosPart>::operator()( xml_h element ) const {
int copy = e.attr<int>( DD_CMU( copyNumber ));
string parentName = ns.attr<string>( e.child( DD_CMU( rParent )), _U( name ));
string childName = ns.attr<string>( e.child( DD_CMU( rChild )), _U( name ));

if( strchr( parentName.c_str(), NAMESPACE_SEP ) == nullptr )
parentName = ns.name() + parentName;
Volume parent = ns.volume( parentName );

if( strchr( childName.c_str(), NAMESPACE_SEP ) == nullptr )
Expand Down Expand Up @@ -1312,12 +1315,11 @@ template <> void Converter<DDRegistry>::operator()(xml_h /* element */) const {
cms::DDParsingContext* context = _param<cms::DDParsingContext>();
DDRegistry* res = _option<DDRegistry>();
cms::DDNamespace ns( context );

int count = 0;

printout( context->debug_constants ? ALWAYS : DEBUG,
"DD4CMS","+++ RESOLVING %ld unknown constants.....", res->unresolvedConst.size());

// FIXME: Avoid an infinite loop in a case
// when a referred constant is not defined
while( !res->unresolvedConst.empty()) {
for( auto i : res->unresolvedConst ) {
const string& n = i.first;
Expand Down Expand Up @@ -1348,6 +1350,7 @@ template <> void Converter<DDRegistry>::operator()(xml_h /* element */) const {
break;
}
}
if( ++count > 10000) break;
}
if( !res->unresolvedConst.empty()) {
for(const auto& e : res->unresolvedConst)
Expand Down
7 changes: 2 additions & 5 deletions DetectorDescription/DDCMS/src/DDNamespace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,12 @@ DDNamespace::addVolume( dd4hep::Volume vol ) const
dd4hep::Volume
DDNamespace::volume( const string& name, bool exc ) const
{
size_t idx;
auto i = m_context->volumes.find( name );
if( i != m_context->volumes.end()) {
return (*i).second;
}
if(( idx = name.find( NAMESPACE_SEP )) != string::npos ) {
string n = name;
n[idx] = NAMESPACE_SEP;
i = m_context->volumes.find( n );
if(name.front() == NAMESPACE_SEP) {
i = m_context->volumes.find(name.substr(1,name.size()));
if( i != m_context->volumes.end())
return (*i).second;
}
Expand Down
69 changes: 69 additions & 0 deletions Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<DDDefinition>
<debug>
<debug_shapes/>
<debug_includes/>
<debug_rotations/>
<debug_includes/>
<debug_volumes/>
<debug_constants/>
<debug_materials/>
<debug_namespaces/>
<debug_placements/>
<debug_algorithms/>
<debug_materials/>
<debug_visattr/>
<debug_specpars/>
</debug>

<open_geometry/>
<close_geometry/>

<ConstantsSection label="" eval="true">
<Constant name="world_x" value="100*m"/>
<Constant name="world_y" value="100*m"/>
<Constant name="world_z" value="100*m"/>
<Constant name="fm" value="1e-12*m"/>
<Constant name="mum" value="1.e-3*mm"/>
<Constant name="Air" value="materials:Air" type="string"/>
<Constant name="Vacuum" value="materials:Vacuum" type="string"/>
</ConstantsSection>

<IncludeSection>
<Include ref='Geometry/CMSCommonData/data/materials.xml'/>
<Include ref='Geometry/CMSCommonData/data/rotations.xml'/>
<Include ref='Geometry/CMSCommonData/data/extend/v2/cmsextent.xml'/>
<Include ref='Geometry/CMSCommonData/data/cms/2023/v2/cms.xml'/>
<Include ref='Geometry/CMSCommonData/data/eta3/etaMax.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMother.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsTracker.xml'/>
<Include ref='Geometry/CMSCommonData/data/caloBase/2023/v1/caloBase.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsCalo.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonBase/2023/v2/muonBase.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMuon.xml'/>
<Include ref='Geometry/CMSCommonData/data/mgnt.xml'/>
<Include ref='Geometry/CMSCommonData/data/beampipe/2023/v1/beampipe.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsBeam/2023/v1/cmsBeam.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMB.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMagnet.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavern/2017/v2/cavern.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml'/>
<Include ref='Geometry/CMSCommonData/data/cavernFloor/2017/v1/cavernFloor.xml'/>
<Include ref='Geometry/CMSCommonData/data/caloBase/2023/v2/caloBase.xml'/>
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixfwd.xml'/>
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/tracker.xml'/>
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/pixbar.xml'/>
<Include ref='Geometry/MTDCommonData/data/btl.xml'/>
<Include ref='Geometry/MTDCommonData/data/etl/v2/etl.xml'/>
<Include ref='Geometry/MTDCommonData/data/CrystalBarPhiFlat/v2/mtd.xml'/>
<Include ref='Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdStructureTopology.xml'/>
<Include ref='Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml'/>
</IncludeSection>

<PosPartSection label="">
<PosPart copyNumber="1">
<rParent name=":world_volume"/>
<rChild name="cms:OCMS"/>
</PosPart>
</PosPartSection>
</DDDefinition>
58 changes: 58 additions & 0 deletions Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("MTDGeometryTest")

process.source = cms.Source("EmptySource")
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1)
)

process.MessageLogger = cms.Service(
"MessageLogger",
statistics = cms.untracked.vstring('cout', 'mtdGeometry'),
categories = cms.untracked.vstring('Geometry'),
cout = cms.untracked.PSet(
threshold = cms.untracked.string('WARNING'),
noLineBreaks = cms.untracked.bool(True)
),
mtdGeometry = cms.untracked.PSet(
INFO = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
noLineBreaks = cms.untracked.bool(True),
DEBUG = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
WARNING = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
ERROR = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
threshold = cms.untracked.string('INFO'),
Geometry = cms.untracked.PSet(
limit = cms.untracked.int32(-1)
)
),
destinations = cms.untracked.vstring('cout',
'mtdGeometry')
)

process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml'),
appendToDataLabel = cms.string('MTD')
)

process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer",
appendToDataLabel = cms.string('MTD')
)

process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer",
appendToDataLabel = cms.string('MTD')
)

process.test = cms.EDAnalyzer("DDCMSDetector",
DDDetector = cms.ESInputTag('MTD')
)

process.p = cms.Path(process.test)

0 comments on commit ea6e7da

Please sign in to comment.