Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26386 from ianna/dd4hep-mdt-geometry-v1
DD4hep: add an algorithm needed to build MTD geometry
- Loading branch information
Showing
10 changed files
with
405 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("EcalGeometryTest") | ||
|
||
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', 'ecalGeometry'), | ||
categories = cms.untracked.vstring('Geometry'), | ||
cout = cms.untracked.PSet( | ||
threshold = cms.untracked.string('WARNING'), | ||
noLineBreaks = cms.untracked.bool(True) | ||
), | ||
ecalGeometry = 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', | ||
'ecalGeometry') | ||
) | ||
|
||
process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", | ||
confGeomXMLFiles = cms.FileInPath('Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml'), | ||
appendToDataLabel = cms.string('Ecal') | ||
) | ||
|
||
process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", | ||
appendToDataLabel = cms.string('Ecal') | ||
) | ||
|
||
process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer", | ||
appendToDataLabel = cms.string('Ecal') | ||
) | ||
|
||
process.test = cms.EDAnalyzer("DDCMSDetector", | ||
DDDetector = cms.ESInputTag('Ecal') | ||
) | ||
|
||
process.p = cms.Path(process.test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/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/EcalCommonData/data/ectkcable.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/PhaseII/eregalgo.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/ebalgo.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/ebcon.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/ebrot.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/eecon.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/PhaseII/escon.xml'/> | ||
<Include ref='Geometry/EcalCommonData/data/PhaseII/esalgo.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/trackermaterial.xml'/> | ||
</IncludeSection> | ||
|
||
<PosPartSection label=""> | ||
<PosPart copyNumber="1"> | ||
<rParent name=":world_volume"/> | ||
<rChild name="cms:OCMS"/> | ||
</PosPart> | ||
</PosPartSection> | ||
</DDDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?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/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/trackerParameters.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/pixfwdCommon.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixfwd.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/pixbar.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/trackermaterial.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/otst.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/tracker.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixel.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerbar.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerfwd.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerStructureTopology.xml'/> | ||
<Include ref='Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixelStructureTopology.xml'/> | ||
</IncludeSection> | ||
|
||
<PosPartSection label=""> | ||
<PosPart copyNumber="1"> | ||
<rParent name=":world_volume"/> | ||
<rChild name="cms:OCMS"/> | ||
</PosPart> | ||
</PosPartSection> | ||
</DDDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include "DD4hep/DetFactoryHelper.h" | ||
#include "DataFormats/Math/interface/GeantUnits.h" | ||
#include "DetectorDescription/DDCMS/interface/DDPlugins.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
using namespace std; | ||
using namespace dd4hep; | ||
using namespace cms; | ||
using namespace geant_units::operators; | ||
|
||
namespace { | ||
long algorithm(Detector& /* description */, | ||
cms::DDParsingContext& ctxt, xml_h e, | ||
SensitiveDetector& /* sens */) | ||
{ | ||
DDNamespace ns(ctxt, e, true); | ||
DDAlgoArguments args(ctxt, e); | ||
Volume mother = ns.volume(args.parentName()); | ||
string childName = args.value<string>("ChildName"); | ||
Volume child = ns.volume(childName); | ||
|
||
string parentName = args.parentName(); | ||
int n = args.value<int>("N"); | ||
int startCopyNo = args.value<int>("StartCopyNo"); | ||
int incrCopyNo = args.value<int>("IncrCopyNo"); | ||
double rangeAngle = args.value<double>("RangeAngle"); | ||
double startAngle = args.value<double>("StartAngle"); | ||
double radius = args.value<double>("Radius"); | ||
vector<double> center = args.value<vector<double> >("Center"); | ||
bool isZPlus = args.value<int>("IsZPlus") == 1; | ||
double tiltAngle = args.value<double>("TiltAngle"); | ||
bool isFlipped = args.value<int>("IsFlipped") == 1; | ||
double delta = 0.; | ||
|
||
if(abs(rangeAngle - 360.0_deg) < 0.001_deg) { | ||
delta = rangeAngle/double(n); | ||
} else { | ||
if(n > 1) { | ||
delta = rangeAngle/double(n-1); | ||
} else { | ||
delta = 0.; | ||
} | ||
} | ||
|
||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position" | ||
<< "ing:: n " << n << " Start, Range, Delta " | ||
<< convertRadToDeg(startAngle) << " " | ||
<< convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) | ||
<< " Radius " << radius << " Centre " << center[0] | ||
<< ", " << center[1] << ", "<< center[2]; | ||
|
||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName | ||
<< "\tChild " << childName << " NameSpace " | ||
<< ns.name(); | ||
|
||
Rotation3D flipRot, tiltRot, phiRot, globalRot; // Identity | ||
Rotation3D flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix | ||
|
||
// flipMatrix calculus | ||
if(isFlipped) { | ||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " | ||
<< "\t90., 180., " | ||
<< "90., 90., " | ||
<< "180., 0."; | ||
flipRot = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0._deg); | ||
flipMatrix = flipRot; | ||
} | ||
// tiltMatrix calculus | ||
if(isZPlus) { | ||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " | ||
<< "\t90., 90., " | ||
<< convertRadToDeg(tiltAngle) << ", 180., " | ||
<< convertRadToDeg(90._deg - tiltAngle) << ", 0."; | ||
tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 180._deg, 90._deg - tiltAngle, 0._deg); | ||
tiltMatrix = tiltRot; | ||
if(isFlipped) { tiltMatrix *= flipMatrix; } | ||
} | ||
else { | ||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " | ||
<< "\t90., 90., " | ||
<< convertRadToDeg(tiltAngle) << ", 0., " | ||
<< convertRadToDeg(90._deg + tiltAngle) << ", 0."; | ||
tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 0._deg, 90._deg + tiltAngle, 0._deg); | ||
tiltMatrix = tiltRot; | ||
if(isFlipped) { tiltMatrix *= flipMatrix; } | ||
} | ||
|
||
// Loops for all phi values | ||
double theta = 90._deg; | ||
int copy = startCopyNo; | ||
double phi = startAngle; | ||
|
||
for(int i = 0; i < n; ++i) { | ||
// phiRotMatrix calculus | ||
double phix = phi; | ||
double phiy = phix + 90._deg; | ||
double phideg = convertRadToDeg(phix); | ||
if(phideg != 0.) { | ||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " | ||
<< "\t90., " << convertRadToDeg(phix) | ||
<< ", 90.," << convertRadToDeg(phiy) | ||
<<", 0., 0."; | ||
phiRot = makeRotation3D(theta, phix, theta, phiy, 0., 0.); | ||
phiRotMatrix = phiRot; | ||
} | ||
|
||
// globalRot def | ||
globalRotMatrix = phiRotMatrix * tiltMatrix; | ||
globalRot = Rotation3D(globalRotMatrix); | ||
|
||
// translation def | ||
double xpos = radius*cos(phi) + center[0]; | ||
double ypos = radius*sin(phi) + center[1]; | ||
double zpos = center[2]; | ||
Position tran(xpos, ypos, zpos); | ||
|
||
// Positions child with respect to parent | ||
mother.placeVolume(child, copy, Transform3D(globalRot, tran)); | ||
LogDebug("TrackerGeom") << "DDTrackerRingAlgo test " << child << " number " | ||
<< copy << " positioned in " << mother << " at " | ||
<< tran << " with " << globalRot; | ||
|
||
copy += incrCopyNo; | ||
phi += delta; | ||
} | ||
return s_executed; | ||
} | ||
} | ||
// first argument is the type from the xml file | ||
DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerRingAlgo,::algorithm) | ||
|
Oops, something went wrong.