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 #27636 from vargasa/DD4hep_PixPhase1FwdDiskAlgo_Mig
DD4Hep: Tracker DDPixPhase1FwdDiskAlgo Migration
- Loading branch information
Showing
4 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
DetectorDescription/DDCMS/data/cms-test-ddpixphase1fwddisk-algo.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,33 @@ | ||
<?xml version="1.0"?> | ||
<DDDefinition> | ||
<debug> | ||
<debug_shapes/> | ||
<debug_includes/> | ||
<debug_rotations/> | ||
<debug_volumes/> | ||
<debug_materials/> | ||
<debug_constants/> | ||
<debug_namespaces/> | ||
<debug_placements/> | ||
<debug_algorithms/> | ||
<debug_specpars/> | ||
</debug> | ||
<open_geometry/> | ||
<close_geometry/> | ||
|
||
<ConstantsSection label="" eval="true"> | ||
<Constant name="world_x" value="5*m"/> | ||
<Constant name="world_y" value="5*m"/> | ||
<Constant name="fm" value="1e-12*m"/> | ||
<Constant name="world_z" value="5*m"/> | ||
<Constant name="Air" value="materials:Air" type="string"/> | ||
<Constant name="Vacuum" value="materials:Vacuum" type="string"/> | ||
</ConstantsSection> | ||
|
||
<IncludeSection> | ||
<Include ref="DetectorDescription/DDCMS/data/testDDPixPhase1FwdDiskAlgo.xml"/> | ||
<Include ref="Geometry/TrackerCommonData/data/PhaseI/PixelForward/pixfwdDisks.xml"/> | ||
<Include ref="DetectorDescription/DDCMS/data/materials.xml"/> | ||
</IncludeSection> | ||
|
||
</DDDefinition> |
66 changes: 66 additions & 0 deletions
66
DetectorDescription/DDCMS/data/testDDPixPhase1FwdDiskAlgo.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,66 @@ | ||
<?xml version="1.0"?> | ||
<DDDefinition> | ||
|
||
<SolidSection> | ||
<Box name="MotherOfAllBoxes" dx="10*m" dy="10*m" dz="10*m"/> | ||
<Box name="ChildVolume" dx="10*m" dy="10*m" dz="10*m"/> | ||
</SolidSection> | ||
|
||
<LogicalPartSection> | ||
<LogicalPart name="MotherOfAllBoxes"> | ||
<rMaterial name="materials:Air"/> | ||
<rSolid name="MotherOfAllBoxes"/> | ||
</LogicalPart> | ||
<LogicalPart name="ChildVolume"> | ||
<rMaterial name="materials:Air"/> | ||
<rSolid name="ChildVolume"/> | ||
</LogicalPart> | ||
</LogicalPartSection> | ||
|
||
<ConstantsSection label="pixfwdInnerDisk1.xml" eval="true"> | ||
<Constant name="InnerRingRMin" value="37.5*mm"/> | ||
<Constant name="InnerRingRMax" value="[InnerRingRMin]+2.0*mm"/> | ||
<Constant name="InnerRingCFRMin" value="[InnerRingRMax]"/> | ||
<Constant name="InnerRingCFRMax" value="[InnerRingCFRMin]+0.5*mm"/> | ||
<Constant name="InnerRingHalfWidth" value="15.0*mm"/> | ||
<Constant name="InnerRingZ" value="[pixfwdDisks:DiskHalfWidth]-[InnerRingHalfWidth]"/> | ||
<Constant name="OuterRingRMax" value="116.6*mm"/> | ||
<Constant name="OuterRingRMin" value="[OuterRingRMax]-2.00*mm"/> | ||
<Constant name="OuterRingCFRMax" value="[OuterRingRMin]"/> | ||
<Constant name="OuterRingCFRMin" value="[OuterRingCFRMax]-0.5*mm"/> | ||
<Constant name="OuterRingHalfWidth" value="14*mm"/> | ||
<Constant name="OuterRingZ" value="[pixfwdDisks:DiskHalfWidth]-[OuterRingHalfWidth]"/> | ||
</ConstantsSection> | ||
|
||
<Algorithm name="track:DDPixPhase1FwdDiskAlgo"> | ||
<rParent name="testDDPixPhase1FwdDiskAlgo:MotherOfAllBoxes"/> | ||
<String name="ChildName" value="testDDPixPhase1FwdDiskAlgo:ChildVolume"/> | ||
<Numeric name="StartCopyNo" value="0"/> | ||
<Numeric name="NumberOfBlades" value="22"/> | ||
<Numeric name="BladeAngle" value="20*deg"/> | ||
<Numeric name="BladeTilt" value="12*deg"/> | ||
<Numeric name="BladeCommonZ" value="-18.7*mm"/> | ||
<Vector name="BladeZShift" type="numeric" nEntries="22"> | ||
7.12*mm, 2.62*mm, -1.88*mm, -6.38*mm, -10.88*mm, | ||
11.62*mm, 7.12*mm, 2.62*mm, -1.88*mm, -6.38*mm, -10.88*mm, | ||
7.12*mm, 2.62*mm, -1.88*mm, -6.38*mm, -10.88*mm, | ||
11.62*mm, 7.12*mm, 2.62*mm, -1.88*mm, -6.38*mm, -10.88*mm | ||
</Vector> | ||
|
||
<Numeric name="AnchorRadius" value="78.7*mm"/> | ||
<String name="RotationName" value="pixfwdInnerDisk1:PixInner"/> | ||
<String name="FlagString" value="YYYYYYYYYYYYYYYYYYYYYY"/> | ||
</Algorithm> | ||
|
||
<PosPartSection label=""> | ||
<PosPart copyNumber="2"> | ||
<rParent name=":world_volume"/> | ||
<rChild name="MotherOfAllBoxes"/> | ||
</PosPart> | ||
<PosPart copyNumber="100"> | ||
<rParent name="MotherOfAllBoxes"/> | ||
<rChild name="testDDPixPhase1FwdDiskAlgo:ChildVolume"/> | ||
</PosPart> | ||
</PosPartSection> | ||
|
||
</DDDefinition> |
121 changes: 121 additions & 0 deletions
121
DetectorDescription/DDCMS/plugins/DDPixPhase1FwdDiskAlgo.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,121 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// File: DDPixPhase1FwdDiskAlgo.cc | ||
// Description: Position n copies at given z-values | ||
/////////////////////////////////////////////////////////////////////////////// | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "DetectorDescription/DDCMS/interface/DDPlugins.h" | ||
#include "DD4hep/DetFactoryHelper.h" | ||
#include "DD4hep/Printout.h" | ||
|
||
#include "DataFormats/Math/interface/GeantUnits.h" | ||
|
||
#include <sstream> | ||
|
||
using namespace geant_units::operators; // _deg and convertRadToDeg | ||
|
||
static long algorithm(dd4hep::Detector& /* description */, | ||
cms::DDParsingContext& ctxt, | ||
xml_h e, | ||
dd4hep::SensitiveDetector& /* sens */) { | ||
cms::DDNamespace ns(ctxt, e, true); | ||
cms::DDAlgoArguments args(ctxt, e); | ||
|
||
int nBlades; //Number of blades | ||
int startCopyNo; //Start Copy number | ||
double bladeAngle; //Angle of blade rotation aroung y-axis | ||
double bladeTilt; //Tilt of the blade around x-axis | ||
double zPlane; //Common shift in z for all blades | ||
std::vector<double> bladeZShift; //Shift in Z of individual blades | ||
double anchorR; //Distance of beam line to anchor point | ||
|
||
std::string childName; //Child name | ||
std::string rotName; //Name of the base rotation matrix | ||
std::string flagString; //Flag if a blade is present | ||
|
||
dd4hep::Volume mother = ns.volume(args.parentName()); | ||
dd4hep::PlacedVolume pv; | ||
|
||
startCopyNo = args.find("startCopyNo") ? args.value<int>("StartCopyNo") : 1; | ||
nBlades = args.value<int>("NumberOfBlades"); | ||
bladeAngle = args.value<double>("BladeAngle"); | ||
bladeTilt = args.value<double>("BladeTilt"); | ||
zPlane = args.value<double>("BladeCommonZ"); | ||
anchorR = args.value<double>("AnchorRadius"); | ||
|
||
bladeZShift = args.value<std::vector<double> >("BladeZShift"); | ||
|
||
childName = args.value<std::string>("ChildName"); | ||
rotName = args.value<std::string>("RotationName"); | ||
flagString = args.value<std::string>("FlagString"); | ||
|
||
dd4hep::Volume child = ns.volume(childName); | ||
|
||
edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo debug: Parent " << mother.name() << "\tChild " << child.name() | ||
<< " NameSpace " << ns.name() << "\tRot Name " << rotName << "\tCopyNo (Start/Total) " | ||
<< startCopyNo << ", " << nBlades << "\tAngles " << convertRadToDeg(bladeAngle) | ||
<< ", " << convertRadToDeg(bladeTilt) << "\tZshifts " << zPlane << "\tAnchor Radius " | ||
<< anchorR; | ||
|
||
for (int iBlade = 0; iBlade < nBlades; ++iBlade) { | ||
edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade] | ||
<< " zshift " << bladeZShift[iBlade]; | ||
} | ||
|
||
double deltaPhi = 360.0_deg / (double)nBlades; | ||
int copyNo = startCopyNo; | ||
std::string flagSelector = "Y"; | ||
|
||
for (int iBlade = 0; iBlade < nBlades; ++iBlade) { | ||
if (flagString[iBlade] == flagSelector[0]) { | ||
std::string rotstr = rotName[0] + std::to_string(double(copyNo)); | ||
double phi = (iBlade + 0.5) * deltaPhi; | ||
double phiy = atan2(cos(phi), -sin(phi)); | ||
double thety = acos(sin(bladeTilt)); | ||
double phix = atan2(cos(bladeAngle) * sin(phi) + cos(phi) * sin(bladeTilt) * sin(bladeAngle), | ||
cos(phi) * cos(bladeAngle) - sin(phi) * sin(bladeTilt) * sin(bladeAngle)); | ||
double thetx = acos(-cos(bladeTilt) * sin(bladeAngle)); | ||
double phiz = atan2(sin(phi) * sin(bladeAngle) - cos(phi) * cos(bladeAngle) * sin(bladeTilt), | ||
cos(phi) * sin(bladeAngle) + cos(bladeAngle) * sin(phi) * sin(bladeTilt)); | ||
double thetz = acos(cos(bladeTilt) * cos(bladeAngle)); | ||
|
||
auto rot = dd4hep::Rotation3D(); | ||
|
||
auto irot = ctxt.rotations.find(ns.prepend(rotstr)); | ||
|
||
if (irot != ctxt.rotations.end()) { | ||
edm::LogVerbatim("TrackerGeom") << "DDPixPhase1FwdDiskAlgo test: Creating a new " | ||
<< "rotation: " << rotstr << "\t" << convertRadToDeg(thetx) << ", " | ||
<< convertRadToDeg(phix) << ", " << convertRadToDeg(thety) << ", " | ||
<< convertRadToDeg(phiy) << ", " << convertRadToDeg(thetz) << ", " | ||
<< convertRadToDeg(phiz); | ||
|
||
edm::LogVerbatim("TrackerGeom") << "Rotation Matrix (" << convertRadToDeg(phi) << ", " | ||
<< convertRadToDeg(bladeAngle) << ", " << convertRadToDeg(bladeTilt) << ") " | ||
<< cos(phi) * cos(bladeAngle) << ", " | ||
<< (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt)) | ||
<< ", " | ||
<< (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt)) | ||
<< ", " << sin(phi) * cos(bladeAngle) << ", " | ||
<< (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt)) | ||
<< ", " | ||
<< (-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt)) | ||
<< ", " << -sin(bladeAngle) << ", " << cos(bladeAngle) * sin(bladeTilt) << ", " | ||
<< cos(bladeAngle) * cos(bladeTilt); | ||
rot = cms::makeRotation3D(thetx, phix, thety, phiy, thetz, phiz); | ||
} | ||
double xpos = -anchorR * sin(phi); | ||
double ypos = anchorR * cos(phi); | ||
double zpos = zPlane + bladeZShift[iBlade % nBlades]; | ||
|
||
dd4hep::Position tran(xpos, ypos, zpos); | ||
pv = mother.placeVolume(child, copyNo, dd4hep::Transform3D(rot, tran)); | ||
edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo test: " << pv.name() << ": " << childName << " number " | ||
<< copyNo << " positioned in " << mother.name() << " at " << tran << " with " | ||
<< rot; | ||
} | ||
copyNo++; | ||
} | ||
return cms::s_executed; | ||
} | ||
|
||
DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixPhase1FwdDiskAlgo, algorithm) |
48 changes: 48 additions & 0 deletions
48
DetectorDescription/DDCMS/test/python/testDDPixPhase1FwdDiskAlgorithm.py
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,48 @@ | ||
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.MessageLogger = cms.Service( | ||
"MessageLogger", | ||
statistics = cms.untracked.vstring('cout', 'testDDPixPhase1FwdDiskAlgo'), | ||
categories = cms.untracked.vstring('TrackerGeom'), | ||
cout = cms.untracked.PSet( | ||
threshold = cms.untracked.string('WARNING'), | ||
noLineBreaks = cms.untracked.bool(True) | ||
), | ||
testDDPixPhase1FwdDiskAlgo = 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'), | ||
TrackerGeom = cms.untracked.PSet( | ||
limit = cms.untracked.int32(-1) | ||
) | ||
), | ||
destinations = cms.untracked.vstring('cout', | ||
'testDDPixPhase1FwdDiskAlgo') | ||
) | ||
|
||
process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", | ||
confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-test-ddpixphase1fwddisk-algo.xml'), | ||
appendToDataLabel = cms.string('testDDPixPhase1FwdDiskAlgo') | ||
) | ||
|
||
process.testDump = cms.EDAnalyzer("DDTestDumpFile", | ||
DDDetector = cms.ESInputTag('','testDDPixPhase1FwdDiskAlgo') | ||
) | ||
|
||
process.p = cms.Path(process.testDump) |