Skip to content

Commit

Permalink
Add DDMuonAngular algorithm
Browse files Browse the repository at this point in the history
Fix Muon units
  • Loading branch information
ianna committed Nov 12, 2018
1 parent ac29e29 commit 3bac8a4
Show file tree
Hide file tree
Showing 8 changed files with 9,353 additions and 0 deletions.
69 changes: 69 additions & 0 deletions DetectorDescription/DDCMS/data/cms-2015-muon-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>

<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/cmsextent.xml'/>
<Include ref='Geometry/CMSCommonData/data/cms.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMother.xml'/>
<!-- Include ref='Geometry/CMSCommonData/data/cmsTracker.xml'/ -->
<!-- Include ref='Geometry/CMSCommonData/data/caloBase.xml'/ -->
<!-- Include ref='Geometry/CMSCommonData/data/cmsCalo.xml'/ -->
<Include ref='Geometry/CMSCommonData/data/muonBase.xml'/>
<Include ref='Geometry/CMSCommonData/data/cmsMuon.xml'/>
<Include ref='Geometry/CMSCommonData/data/mgnt.xml'/>
<!-- Include ref='Geometry/CMSCommonData/data/beampipe/2015/v1/beampipe.xml'/-->
<Include ref='Geometry/CMSCommonData/data/cmsBeam.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMB.xml'/>
<Include ref='Geometry/CMSCommonData/data/muonMagnet.xml'/>
<!-- Include ref='Geometry/CMSCommonData/data/cavern.xml'/ -->
<Include ref='Geometry/MuonCommonData/data/mbCommon/2015/v2/mbCommon.xml'/>
<Include ref='Geometry/MuonCommonData/data/mb1/2015/v2/mb1.xml'/>
<Include ref='Geometry/MuonCommonData/data/mb2/2015/v2/mb2.xml'/>
<Include ref='Geometry/MuonCommonData/data/mb3/2015/v2/mb3.xml'/>
<Include ref='Geometry/MuonCommonData/data/mb4/2015/v2/mb4.xml'/>
<!-- Include ref='Geometry/MuonCommonData/data/design/muonYoke.xml'/ -->
<Include ref='Geometry/MuonCommonData/data/mf/2015/v1/mf.xml'/>
<!-- Include ref='Geometry/MuonCommonData/data/rpcf/2015/v1/rpcf.xml'/ -->
<!-- Include ref='Geometry/MuonCommonData/data/csc/2015/v1/csc.xml'/-->
<!-- Include ref='Geometry/MuonCommonData/data/mfshield/2015/v1/mfshield.xml'/-->
</IncludeSection>

<PosPartSection label="">
<PosPart copyNumber="1">
<rParent name="world_volume"/>
<rChild name="cms:OCMS"/>
</PosPart>
</PosPartSection>
</DDDefinition>
61 changes: 61 additions & 0 deletions DetectorDescription/DDCMS/plugins/DDMuonAngular.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

using namespace std;
using namespace dd4hep;
using namespace cms;

static long algorithm( Detector& /* description */,
cms::DDParsingContext& context,
xml_h element,
SensitiveDetector& /* sens */)
{
cms::DDNamespace ns( context, element, true );
DDAlgoArguments args( context, element );

int n = args.value<int>("n");
int startCopyNo = args.find("startCopyNo") ? args.value<int>("startCopyNo") : 1;
int incrCopyNo = args.find("incrCopyNo") ? args.value<int>("incrCopyNo") : 1;
double startAngle = args.value<double>("startAngle");
double stepAngle = args.value<double>("stepAngle");
double zoffset = args.value<double>("zoffset");
string rotns = args.value<string>("RotNameSpace");
Volume mother = ns.volume(args.parentName());
Volume child = ns.volume(args.value<string>("ChildName"));

LogDebug("DDAlgorithm") << "debug: Parameters for positioning:: n "
<< n << " Start, Step "
<< ConvertTo( startAngle, deg ) << " "
<< ConvertTo( stepAngle, deg ) << " "
<< ", zoffset " << zoffset << " "
<< ", RotNameSpace " << rotns.c_str();
LogDebug("DDAlgorithm") << "debug: Parent " << mother.name()
<< "\tChild " << child.name() << " NameSpace "
<< ns.name();

double phi = startAngle;
int copyNo = startCopyNo;

for( int i = 0; i < n; ++i ) {
double phitmp = phi;
if( phitmp >= 2._pi ) phitmp -= 2._pi;
Rotation3D rotation = makeRotation3D( 90._deg, phitmp, 90._deg, 90._deg + phitmp, 0., 0.);
string rotstr = ns.nsName( child.name()) + std::to_string( phitmp * 10. );
auto irot = context.rotations.find( ns.prepend( rotstr ));
if( irot != context.rotations.end()) {
rotation = ns.rotation( ns.prepend( rotstr ));
}
Position tran( 0., 0., zoffset );
mother.placeVolume( child, copyNo, Transform3D( rotation, tran ));
LogDebug("DDAlgorithm") << "test " << child.name() << " number "
<< copyNo << " positioned in " << mother.name() << " at "
<< tran << " with " << rotstr << ": " << rotation;
phi += stepAngle;
copyNo += incrCopyNo;
}
return 1;
}

// first argument is the type from the xml file
DECLARE_DDCMS_DETELEMENT( DDCMS_global_DDMuonAngular, algorithm )
23 changes: 23 additions & 0 deletions DetectorDescription/DDCMS/test/python/testMuonGeometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("DDCMSDetectorTest")

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

process.test = cms.EDAnalyzer("DDCMSDetector",
geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml',
'Geometry/CMSCommonData/data/cms.xml',
'DetectorDescription/DDCMS/data/cmsMagneticField.xml',
'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_1.xml',
'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_2.xml',
'Geometry/CMSCommonData/data/materials.xml'),
confGeomXMLFiles = cms.string('DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml')
)

process.testVectors = cms.EDAnalyzer("DDTestVectors")
process.testDump = cms.EDAnalyzer("DDTestDumpFile")

process.p = cms.Path(process.test+process.testVectors+process.testDump)
Loading

0 comments on commit 3bac8a4

Please sign in to comment.