From 7dd76a9921d3117afac7e4aa64bdf983a8603df7 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 18 Jun 2025 16:16:57 +0100 Subject: [PATCH 01/11] Allow incoming rotation in tagger box --- compact/far_backward/taggers.xml | 1 + src/BackwardsTaggers_geo.cpp | 35 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/compact/far_backward/taggers.xml b/compact/far_backward/taggers.xml index 7c16fa727e..429dbff786 100644 --- a/compact/far_backward/taggers.xml +++ b/compact/far_backward/taggers.xml @@ -17,6 +17,7 @@ diff --git a/src/BackwardsTaggers_geo.cpp b/src/BackwardsTaggers_geo.cpp index 96745409dc..89fad83840 100644 --- a/src/BackwardsTaggers_geo.cpp +++ b/src/BackwardsTaggers_geo.cpp @@ -48,7 +48,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { double off = pos.z(); // Beamline rotation - xml_dim_t rot = x_det.rotation(); + double out_theta = x_det.rotation().theta(); // Beampipe thickness double wall = dd4hep::getAttrOrDefault(x_det, _Unicode(wall), 1 * mm); @@ -61,6 +61,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { double BB_MaxX = BB.xmax(); double BB_MaxY = BB.ymax(); double BB_MaxZ = BB.zmax(); + double in_theta = BB.theta(); double BB_X = abs(BB_MaxX - BB_MinX); double BB_Y = abs(BB_MaxY - BB_MinY); @@ -76,7 +77,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { double Lumi_R = EB.attr(_Unicode(lumiR)); // Maximum theta to exit the dipole from - double exitTheta = EB.attr(_Unicode(maxTheta)); + double maxTheta = EB.attr(_Unicode(maxTheta)); // Generic box for making intersection solid with double xbox = 10 * m; @@ -117,9 +118,9 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { // Theta coverage expected double thetamin = - dd4hep::getAttrOrDefault(mod, _Unicode(theta_min), 0.030 * rad) - rot.theta(); + dd4hep::getAttrOrDefault(mod, _Unicode(theta_min), 0.030 * rad) - out_theta; double thetamax = - dd4hep::getAttrOrDefault(mod, _Unicode(theta_max), 0.030 * rad) - rot.theta(); + dd4hep::getAttrOrDefault(mod, _Unicode(theta_max), 0.030 * rad) - out_theta; // Align box to max or minimum theta expected at the tagger from focal point bool max_align = dd4hep::getAttrOrDefault(mod, _Unicode(max_align), false); @@ -223,33 +224,33 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { // CutTube Lumi_Exit (0, Lumi_R, ED_Z, 0,2*pi, sin(angle),0,cos(angle), 0,0,1); // Add entry boxes to main beamline volume - Wall_Box = UnionSolid(Wall_Box, Entry_Beam_Box, Transform3D(RotationY(-rot.theta()))); - Vacuum_Box = UnionSolid(Vacuum_Box, Entry_Vacuum_Box, Transform3D(RotationY(-rot.theta()))); - Vacuum_Box = UnionSolid(Vacuum_Box, Lumi_Exit, Transform3D(RotationY(-rot.theta()))); + Wall_Box = UnionSolid(Wall_Box, Entry_Beam_Box, Transform3D(RotationY(-out_theta))); + Vacuum_Box = UnionSolid(Vacuum_Box, Entry_Vacuum_Box, Transform3D(RotationY(-out_theta))); + Vacuum_Box = UnionSolid(Vacuum_Box, Lumi_Exit, Transform3D(RotationY(-out_theta))); } //----------------------------------------------------------------- - // Restrict tagger boxes into region defined by exitTheta from the dipole magnet + // Restrict tagger boxes into region defined by maxTheta from the dipole magnet //----------------------------------------------------------------- double exitDist = BB_MinZ - off; - double cutX = (ED_X - exitDist * tan(-rot.theta())) * cos(rot.theta()); + double cutX = (ED_X - exitDist * tan(-out_theta)) * cos(out_theta); double cutZ = - (ED_X - exitDist * tan(-rot.theta())) * sin(rot.theta()) + exitDist * cos(rot.theta()); - double cutXwall = (ED_X - wall - exitDist * tan(-rot.theta())) * cos(rot.theta()); + (ED_X - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta); + double cutXwall = (ED_X - wall - exitDist * tan(-out_theta)) * cos(out_theta); double cutZwall = - (ED_X - wall - exitDist * tan(-rot.theta())) * sin(rot.theta()) + exitDist * cos(rot.theta()); + (ED_X - wall - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta); Wall_Box = IntersectionSolid(Wall_Box, Cut_Box, - Transform3D(RotationY(exitTheta), Position(xbox - cutX, 0, cutZ))); + Transform3D(RotationY(maxTheta), Position(xbox - cutX, 0, cutZ))); Vacuum_Box = IntersectionSolid(Vacuum_Box, Cut_Box, - Transform3D(RotationY(exitTheta), Position(xbox - cutXwall, 0, cutZwall))); + Transform3D(RotationY(maxTheta), Position(xbox - cutXwall, 0, cutZwall))); //----------------------------------------------------------------- // Cut solids so they are only in the far backwards box //----------------------------------------------------------------- - RotationY rotate2(-rot.theta()); - Position position(0, 0, (exitDist - BB_Z) / cos(rot.theta())); + RotationY rotate2(in_theta-out_theta); + Position position(0, 0, (exitDist - BB_Z) / cos(out_theta-in_theta)); IntersectionSolid Wall_Box_Sub(Wall_Box, Far_Backwards_Box, Transform3D(rotate2, position)); IntersectionSolid Vacuum_Box_Sub(Vacuum_Box, Far_Backwards_Box, Transform3D(rotate2, position)); @@ -271,7 +272,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { backAssembly.placeVolume(DetAssemblyAir); // placement in mother volume - Transform3D tr(RotationY(rot.theta()), Position(pos.x(), pos.y(), pos.z())); + Transform3D tr(RotationY(out_theta), Position(pos.x(), pos.y(), pos.z())); PlacedVolume detPV = desc.pickMotherVolume(det).placeVolume(backAssembly, tr); detPV.addPhysVolID("system", detID); From e822bb4e7da9bbd54a6660797f8e978bd8009826 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 5 Mar 2025 15:41:04 +0000 Subject: [PATCH 02/11] Fix visualization --- compact/far_backward/beamline_extension_electron.xml | 2 +- compact/far_backward/beamline_extension_hadron.xml | 2 +- src/CylindricalMagnetChain_geo.cpp | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index e1346df240..359a1c1c65 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -65,7 +65,7 @@ + vis="FFMagnetVis"> diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 4727479a50..770524e14e 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -13,7 +13,7 @@ Hadron side beam magnet volumes - + diff --git a/src/CylindricalMagnetChain_geo.cpp b/src/CylindricalMagnetChain_geo.cpp index 607a575f96..0de2fdc02b 100644 --- a/src/CylindricalMagnetChain_geo.cpp +++ b/src/CylindricalMagnetChain_geo.cpp @@ -33,6 +33,7 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /* xml_comp_t magnet(magnet_coll); string name = getAttrOrDefault(magnet, _Unicode(name), ""); + int id = getAttrOrDefault(magnet, _Unicode(id), 0); double x = getAttrOrDefault(magnet, _Unicode(x), 0); double y = getAttrOrDefault(magnet, _Unicode(y), 0); double z = getAttrOrDefault(magnet, _Unicode(z), 0); @@ -45,9 +46,14 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /* Tube yoke_tube(rin, rout, 0.5 * length); Volume v_yoke("v_yoke_" + name, yoke_tube, m_Iron); - v_yoke.setVisAttributes(description.visAttributes(vis_name)); + v_yoke.setVisAttributes(x_det.visStr()); + + auto yoke_pv = assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z))); - assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z))); + yoke_pv.addPhysVolID("element", id); + DetElement yoke_de(sdet, name, id); + yoke_de.setPlacement(yoke_pv); + yoke_de.setAttributes(description, v_yoke, x_det.regionStr(), x_det.limitsStr(), vis_name); } // Final placement From fc22c1a45433bc356dd04d9debd6c0aaacc7bb09 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 5 Mar 2025 16:10:45 +0000 Subject: [PATCH 03/11] Add visualization of FF electron magnets --- compact/far_forward/electron_beamline.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 6dbac133dc..2a835e43d4 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -56,7 +56,7 @@ - + @@ -72,7 +72,7 @@ - + From 33d5b1313fe09a5cad84c37293d27cd0a7862efc Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 18 Jun 2025 11:49:42 +0100 Subject: [PATCH 04/11] Put fields definitions after far detectors --- templates/epic.xml.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/epic.xml.jinja2 b/templates/epic.xml.jinja2 index 687347a0e4..1253a6f3b5 100644 --- a/templates/epic.xml.jinja2 +++ b/templates/epic.xml.jinja2 @@ -44,10 +44,10 @@ The ip6 (or other ip) defines should be included first. These files have only a define tags. - + From 77699be240e17e3d73752af97c67a3381016a778 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 18 Jun 2025 16:58:08 +0100 Subject: [PATCH 05/11] Change vis for Q3eR --- compact/far_backward/magnets.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index f4bc82bd45..e84da38e7d 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -37,8 +37,8 @@ @@ -67,7 +67,7 @@ - + @@ -76,7 +76,7 @@ + vis="FFMagnetVis"> From 847f2633c39628b983da64cfc3d3f093954a7c9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:07:10 +0000 Subject: [PATCH 06/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/BackwardsTaggers_geo.cpp | 11 +++++------ src/CylindricalMagnetChain_geo.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/BackwardsTaggers_geo.cpp b/src/BackwardsTaggers_geo.cpp index 89fad83840..2745470a18 100644 --- a/src/BackwardsTaggers_geo.cpp +++ b/src/BackwardsTaggers_geo.cpp @@ -48,7 +48,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { double off = pos.z(); // Beamline rotation - double out_theta = x_det.rotation().theta(); + double out_theta = x_det.rotation().theta(); // Beampipe thickness double wall = dd4hep::getAttrOrDefault(x_det, _Unicode(wall), 1 * mm); @@ -77,7 +77,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { double Lumi_R = EB.attr(_Unicode(lumiR)); // Maximum theta to exit the dipole from - double maxTheta = EB.attr(_Unicode(maxTheta)); + double maxTheta = EB.attr(_Unicode(maxTheta)); // Generic box for making intersection solid with double xbox = 10 * m; @@ -234,8 +234,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { //----------------------------------------------------------------- double exitDist = BB_MinZ - off; double cutX = (ED_X - exitDist * tan(-out_theta)) * cos(out_theta); - double cutZ = - (ED_X - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta); + double cutZ = (ED_X - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta); double cutXwall = (ED_X - wall - exitDist * tan(-out_theta)) * cos(out_theta); double cutZwall = (ED_X - wall - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta); @@ -249,8 +248,8 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) { //----------------------------------------------------------------- // Cut solids so they are only in the far backwards box //----------------------------------------------------------------- - RotationY rotate2(in_theta-out_theta); - Position position(0, 0, (exitDist - BB_Z) / cos(out_theta-in_theta)); + RotationY rotate2(in_theta - out_theta); + Position position(0, 0, (exitDist - BB_Z) / cos(out_theta - in_theta)); IntersectionSolid Wall_Box_Sub(Wall_Box, Far_Backwards_Box, Transform3D(rotate2, position)); IntersectionSolid Vacuum_Box_Sub(Vacuum_Box, Far_Backwards_Box, Transform3D(rotate2, position)); diff --git a/src/CylindricalMagnetChain_geo.cpp b/src/CylindricalMagnetChain_geo.cpp index 0de2fdc02b..b12497ecac 100644 --- a/src/CylindricalMagnetChain_geo.cpp +++ b/src/CylindricalMagnetChain_geo.cpp @@ -47,7 +47,7 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /* Volume v_yoke("v_yoke_" + name, yoke_tube, m_Iron); v_yoke.setVisAttributes(x_det.visStr()); - + auto yoke_pv = assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z))); yoke_pv.addPhysVolID("element", id); From 2f9be18dab631da028c7f7efc5549c69d6c5b830 Mon Sep 17 00:00:00 2001 From: simonge Date: Wed, 18 Jun 2025 17:52:06 +0100 Subject: [PATCH 07/11] Add constants which went missing --- compact/far_backward/definitions.xml | 2 ++ compact/far_backward/magnets.xml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index c85aadb6d3..36a064a992 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -28,7 +28,9 @@ + + diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index e84da38e7d..6d32e160e5 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -37,7 +37,7 @@ @@ -67,7 +67,7 @@ - + From ef9b816a4d073c7adaca600014caf148b12ef336 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 19 Jun 2025 06:32:43 +0100 Subject: [PATCH 08/11] Make constant names consistent --- .../beamline_extension_electron.xml | 2 +- compact/far_backward/definitions.xml | 16 +++---- compact/far_backward/magnets.xml | 32 ++++++------- compact/far_forward/beampipe_hadron_B0.xml | 4 +- compact/far_forward/definitions.xml | 46 +++++++++---------- compact/far_forward/ion_beamline.xml | 16 +++---- compact/far_forward/magnets.xml | 16 +++---- compact/far_forward/offM_tracker.xml | 4 +- compact/far_forward/romanpots.xml | 8 ++-- compact/far_forward/vacuum.xml | 16 +++---- 10 files changed, 80 insertions(+), 80 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 359a1c1c65..e70fa8574f 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -17,7 +17,7 @@ type="BeamPipeChain" wall_thickness="2*mm"> diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index 36a064a992..e8aebbcfec 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -16,20 +16,20 @@ - + - + - + - - + + @@ -38,9 +38,9 @@ - + + - Note: Placements for Q4eR, B3eR, B4eR, B5eR, B6eR, B7eR are approximate (valid to within ~1 cm). @@ -176,7 +176,7 @@ - + diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index 6d32e160e5..7ef57011dd 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -14,30 +14,30 @@ wall_thickness="2*mm" vis="BeamPipeVis"> @@ -46,28 +46,28 @@ Electron side beam magnet volumes - + - + - + - + @@ -78,7 +78,7 @@ type="CylindricalMagnetChain" vis="FFMagnetVis"> @@ -91,21 +91,21 @@ - + - + - + @@ -113,13 +113,13 @@ - + - + diff --git a/compact/far_forward/beampipe_hadron_B0.xml b/compact/far_forward/beampipe_hadron_B0.xml index f23e72b590..7f3722c16a 100644 --- a/compact/far_forward/beampipe_hadron_B0.xml +++ b/compact/far_forward/beampipe_hadron_B0.xml @@ -11,13 +11,13 @@ - + - + diff --git a/compact/far_forward/definitions.xml b/compact/far_forward/definitions.xml index 1ad75fef5c..47cfb00b7d 100644 --- a/compact/far_forward/definitions.xml +++ b/compact/far_forward/definitions.xml @@ -66,31 +66,31 @@ - - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 17e27815c1..66148a43a9 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -22,49 +22,49 @@ - + - + - + - + - + - + - + - + diff --git a/compact/far_forward/magnets.xml b/compact/far_forward/magnets.xml index 048cc584ad..57ea1141b1 100644 --- a/compact/far_forward/magnets.xml +++ b/compact/far_forward/magnets.xml @@ -4,56 +4,56 @@ - + - + - + - + - + - + - + - + diff --git a/compact/far_forward/offM_tracker.xml b/compact/far_forward/offM_tracker.xml index b3ba6d2f3f..4b6745cc61 100644 --- a/compact/far_forward/offM_tracker.xml +++ b/compact/far_forward/offM_tracker.xml @@ -8,8 +8,8 @@ Forward Off-Momentum Tracker Parameters ---------------------------------------- - - + + diff --git a/compact/far_forward/romanpots.xml b/compact/far_forward/romanpots.xml index f6e75532a3..a77050231e 100644 --- a/compact/far_forward/romanpots.xml +++ b/compact/far_forward/romanpots.xml @@ -8,10 +8,10 @@ Far Forward B0 Tracker Parameters --------------------------------- - - - - + + + + diff --git a/compact/far_forward/vacuum.xml b/compact/far_forward/vacuum.xml index ad5c8acab7..74c357f1db 100644 --- a/compact/far_forward/vacuum.xml +++ b/compact/far_forward/vacuum.xml @@ -12,49 +12,49 @@ - + - + - + - + - + - + - + - + From 715bc30e38ebfad44628f9372a2ee58ad70e9856 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 19 Jun 2025 06:40:48 +0100 Subject: [PATCH 09/11] fix typo --- compact/far_forward/magnets.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/compact/far_forward/magnets.xml b/compact/far_forward/magnets.xml index 57ea1141b1..ec04713d20 100644 --- a/compact/far_forward/magnets.xml +++ b/compact/far_forward/magnets.xml @@ -4,56 +4,56 @@ - + - + - + - + - + - + - + - + From e82a1ea756c255e79bc89f255dca084dffaa647d Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 20 Jun 2025 16:01:42 -0500 Subject: [PATCH 10/11] fix: style --- compact/far_backward/definitions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index e8aebbcfec..aea6197ed5 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -176,7 +176,7 @@ - + From 0e3b196431238acba17929c0c318ba0d0efe6670 Mon Sep 17 00:00:00 2001 From: simonge Date: Mon, 23 Jun 2025 14:26:03 +0100 Subject: [PATCH 11/11] Remove unnecessary detector element --- src/CylindricalMagnetChain_geo.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CylindricalMagnetChain_geo.cpp b/src/CylindricalMagnetChain_geo.cpp index b12497ecac..b8f678b5d8 100644 --- a/src/CylindricalMagnetChain_geo.cpp +++ b/src/CylindricalMagnetChain_geo.cpp @@ -46,14 +46,11 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /* Tube yoke_tube(rin, rout, 0.5 * length); Volume v_yoke("v_yoke_" + name, yoke_tube, m_Iron); - v_yoke.setVisAttributes(x_det.visStr()); + v_yoke.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), vis_name); auto yoke_pv = assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z))); yoke_pv.addPhysVolID("element", id); - DetElement yoke_de(sdet, name, id); - yoke_de.setPlacement(yoke_pv); - yoke_de.setAttributes(description, v_yoke, x_det.regionStr(), x_det.limitsStr(), vis_name); } // Final placement