From bfcfd935288f76fcbcba46ad6788b9284b3e743a Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 13:20:19 -0400 Subject: [PATCH 01/79] First implementation of the B0 yoke --- .../beamline_extension_hadron.xml | 6 - compact/far_backward/magnets.xml | 28 -- compact/far_forward/electron_beamline.xml | 31 -- compact/far_forward/ion_beamline.xml | 60 +--- src/CylindricalDipoleMagnet_geo.cpp | 267 +++++++++++++++--- 5 files changed, 239 insertions(+), 153 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 4727479a50..7b9b4a6250 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -13,12 +13,6 @@ Hadron side beam magnet volumes - - - - - - Electron side beam magnet volumes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 17e27815c1..68bfbecdc1 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -22,52 +22,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 33f9318849..bbb70a86ee 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -15,48 +15,231 @@ using namespace dd4hep::rec; using namespace ROOT::Math; static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - int det_id = x_det.id(); - string det_name = x_det.nameStr(); - xml_dim_t pos = x_det.child(_U(placement)); - double pos_x = pos.x(); - double pos_y = pos.y(); - double pos_z = pos.z(); - double pos_theta = pos.attr(_U(theta)); - xml_dim_t dims = x_det.dimensions(); - double dim_r = dims.r(); - double dim_z = dims.z(); - xml_dim_t apperture = x_det.child(_Unicode(apperture)); - double app_r = apperture.r(); - Material iron = dtor.material("Iron"); - - DetElement sdet(det_name, det_id); - Assembly assembly(det_name + "_assembly"); - - const string module_name = "Quad_magnet"; - - const string yoke_vis = - dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); - - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - - // -- yoke - Tube yoke_tube(app_r, dim_r, 0.5 * dim_z); - Volume yoke_vol("yoke_vol", yoke_tube, iron); - auto yoke_pv = assembly.placeVolume(yoke_vol); - yoke_pv.addPhysVolID("element", 1); - DetElement yoke_de(sdet, "yoke_de", 1); - yoke_de.setPlacement(yoke_pv); - yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - - // -- finishing steps - auto final_pos = Transform3D(Translation3D(pos_x, pos_y, pos_z) * RotationY(pos_theta)); - auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); - pv.addPhysVolID("system", det_id); - sdet.setPlacement(pv); - - assembly->GetShape()->ComputeBBox(); - return sdet; + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + Material iron = dtor.material("Iron"); + + DetElement sdet(det_name, det_id); + Assembly assembly(det_name + "_assembly"); + + const string yoke_vis = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + + //---- YOKE ---- + // get all yokes + xml_coll_t yokes_c(x_det, _Unicode(yoke)); + int yoke_id = 1; + // loop over yokes + for (; yokes_c; ++yokes_c) + { + // get one yoke + xml_comp_t yoke_c = yokes_c; + // get placement coordinates + xml_dim_t yoke_pos = yoke_c.child(_U(placement)); + double yoke_theta = yoke_pos.attr("theta"); + // get dimentions + xml_dim_t yoke_dim = yoke_c.child(_U(dimensions)); + double yoke_rmin = yoke_dim.attr("rmin"); + double yoke_rmax = yoke_dim.attr("rmax"); + double yoke_half_l = yoke_dim.attr("half_length"); + + // build solid + Tube yoke_tube(yoke_rmin,yoke_rmax,yoke_half_l); + Solid yoke_final(yoke_tube); + + // get all cuts + xml_coll_t cuts_c(yoke_c, _Unicode(cut)); + // loop over cuts + for (; cuts_c; ++cuts_c) + { + // get one cut + xml_comp_t cut_c = cuts_c; + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_theta = cut_pos.attr("theta"); + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + string cut_rot_axis = cut_rot.attr("axis"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + // subtract the cut from yoke solid + yoke_final = SubtractionSolid("yoke_tube",yoke_final,cut_tube,tf_tmp); + } + } + + // create volume + string yoke_vol_name = "yoke_vol_" + to_string(yoke_id); + Volume yoke_vol(yoke_vol_name, yoke_final, iron); + + // placement + auto yoke_pv = assembly.placeVolume(yoke_vol); + yoke_pv.addPhysVolID("element", yoke_id); + DetElement yoke_de(sdet, "yoke_de", yoke_id); + yoke_de.setPlacement(yoke_pv); + yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + yoke_id++; + + // finishing steps + auto final_pos = Transform3D( + Translation3D(yoke_pos.x(),yoke_pos.y(),yoke_pos.z()) * RotationY(yoke_theta)); + auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); + pv.addPhysVolID("system", det_id); + sdet.setPlacement(pv); + + // update bounding box + assembly->GetShape()->ComputeBBox(); + } + + return sdet; } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) + +/* from compact/far_forward/ion_beamline.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + + +/* from compact/far_forward/ion_beamline.xml + + + + + + !--unchecked-- + + + + + + + + + + + + + + + + !--unchecked-- + + + + + + + + + + +*/ + +/* from compact/far_backward/magnets.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + +/* from compact/far_backward/beamline_extension_hadron.xml + + + + + + +*/ From 6385d7b4cc2c0843a03c054d83735225e6d7fa7c Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 17:16:55 -0400 Subject: [PATCH 02/79] Added coils, support tubes, manifold(endplates). --- compact/colors.xml | 1 + compact/display.xml | 8 +- compact/far_forward/ion_beamline.xml | 40 ++++- src/CylindricalDipoleMagnet_geo.cpp | 244 ++++++++++++++++++++++----- 4 files changed, 242 insertions(+), 51 deletions(-) diff --git a/compact/colors.xml b/compact/colors.xml index 4c320b287c..b233b2fb2b 100644 --- a/compact/colors.xml +++ b/compact/colors.xml @@ -11,6 +11,7 @@ + diff --git a/compact/display.xml b/compact/display.xml index 69e76b048d..a4297cd035 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -141,9 +141,11 @@ Beam line with magnets - - - + + + + + ZDC visualization diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 68bfbecdc1..6058b528b4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -21,10 +21,10 @@ ===================================== - - + + - + @@ -36,6 +36,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index bbb70a86ee..ca9254bb1d 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -14,42 +14,205 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace ROOT::Math; -static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - int det_id = x_det.id(); - string det_name = x_det.nameStr(); - Material iron = dtor.material("Iron"); +void buildMagElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material); +void buildCryoElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material); + +static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) +{ + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); DetElement sdet(det_name, det_id); Assembly assembly(det_name + "_assembly"); - const string yoke_vis = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + // get materials + Material iron = dtor.material("Iron"); + Material nbti = dtor.material("SolenoidCoil"); + Material steel = dtor.material("StainlessSteel"); + + // build magnet components + buildMagElement(sdet,assembly,dtor,x_det,"yoke",iron); + buildMagElement(sdet,assembly,dtor,x_det,"coil",nbti); + buildMagElement(sdet,assembly,dtor,x_det,"tube",steel); + buildCryoElement(sdet,assembly,dtor,x_det,"endplate",steel); + + // final placement + auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); + pv_assembly.addPhysVolID("system", det_id); + sdet.setPlacement(pv_assembly); - //---- YOKE ---- - // get all yokes - xml_coll_t yokes_c(x_det, _Unicode(yoke)); - int yoke_id = 1; - // loop over yokes - for (; yokes_c; ++yokes_c) + // update bounding box + assembly->GetShape()->ComputeBBox(); + + return sdet; +} + +void buildCryoElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material) +{ + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) { - // get one yoke - xml_comp_t yoke_c = yokes_c; + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); // get placement coordinates - xml_dim_t yoke_pos = yoke_c.child(_U(placement)); - double yoke_theta = yoke_pos.attr("theta"); + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); + std::vector z; + std::vector rmax; + std::vector rmin; + // loop over z-planes + xml_coll_t zplanes_c(elem_c, _Unicode(zplane)); + for (; zplanes_c; ++zplanes_c) + { + // get z-plane + xml_comp_t zplane_c = zplanes_c; + z.push_back(zplane_c.attr(_Unicode(z))); + rmin.push_back(zplane_c.attr(_Unicode(rmin))); + rmax.push_back(zplane_c.attr(_Unicode(rmax))); + } + + // set attributes + const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); + + // build solid + Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); + Solid elem_final(elem_tube); + + // get all cuts + xml_coll_t cuts_c(elem_c, _Unicode(cut)); + // loop over cuts + for (; cuts_c; ++cuts_c) + { + // get one cut + xml_comp_t cut_c = cuts_c; + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_theta = cut_pos.attr("theta"); + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + string cut_rot_axis = cut_rot.attr("axis"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); + } + } + + // create volume + Volume elem_vol(elem_name, elem_final, material); + + // placement + auto elem_pv = assembly.placeVolume(elem_vol, + Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; + } + + return; +} + +void buildMagElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material) +{ + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) + { + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); + // get placement coordinates + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); // get dimentions - xml_dim_t yoke_dim = yoke_c.child(_U(dimensions)); - double yoke_rmin = yoke_dim.attr("rmin"); - double yoke_rmax = yoke_dim.attr("rmax"); - double yoke_half_l = yoke_dim.attr("half_length"); + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin = elem_dim.attr("rmin"); + double elem_rmax = elem_dim.attr("rmax"); + double elem_half_l = elem_dim.attr("half_length"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // set attributes + const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); // build solid - Tube yoke_tube(yoke_rmin,yoke_rmax,yoke_half_l); - Solid yoke_final(yoke_tube); + Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); + Solid elem_final(elem_tube); + + // combine sub-elements + if(elem_pos.hasAttr(_Unicode(phiNum))) + { + int phi_num = elem_pos.attr("phiNum"); + double phi_step = elem_pos.attr("phiStep"); + double phi_start = elem_pos.attr("phiStart"); + + // loop over steps + for(int i = 0; i < phi_num; i++) + { + double phi_tmp = phi_start + i * phi_step; + Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); + // unite sub-elements + elem_final = UnionSolid("elem_tube",elem_final,elem_tube,tf_tmp); + } + } // get all cuts - xml_coll_t cuts_c(yoke_c, _Unicode(cut)); + xml_coll_t cuts_c(elem_c, _Unicode(cut)); // loop over cuts for (; cuts_c; ++cuts_c) { @@ -84,35 +247,26 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) pos_tmp = rot_tmp * pos_tmp; Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); - // subtract the cut from yoke solid - yoke_final = SubtractionSolid("yoke_tube",yoke_final,cut_tube,tf_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); } } // create volume - string yoke_vol_name = "yoke_vol_" + to_string(yoke_id); - Volume yoke_vol(yoke_vol_name, yoke_final, iron); + Volume elem_vol(elem_name, elem_final, material); // placement - auto yoke_pv = assembly.placeVolume(yoke_vol); - yoke_pv.addPhysVolID("element", yoke_id); - DetElement yoke_de(sdet, "yoke_de", yoke_id); - yoke_de.setPlacement(yoke_pv); - yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - yoke_id++; - - // finishing steps - auto final_pos = Transform3D( - Translation3D(yoke_pos.x(),yoke_pos.y(),yoke_pos.z()) * RotationY(yoke_theta)); - auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); - pv.addPhysVolID("system", det_id); - sdet.setPlacement(pv); - - // update bounding box - assembly->GetShape()->ComputeBBox(); + auto elem_pv = assembly.placeVolume(elem_vol, + Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; } - return sdet; + return; } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) From c9b99ed1896c31b433694f2dd9dd0b8a44b6b7c0 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 23:43:22 -0400 Subject: [PATCH 03/79] Added heatshield and cryo --- compact/display.xml | 2 + compact/far_forward/ion_beamline.xml | 66 ++++++++++++++++- compact/materials.xml | 20 +++++ src/CylindricalDipoleMagnet_geo.cpp | 105 ++++++++++++++++++--------- 4 files changed, 156 insertions(+), 37 deletions(-) diff --git a/compact/display.xml b/compact/display.xml index a4297cd035..88a2993699 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -146,6 +146,8 @@ + + ZDC visualization diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 6058b528b4..d3e2c5fd27 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -58,19 +58,77 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/compact/materials.xml b/compact/materials.xml index fbefb06383..adac18b784 100644 --- a/compact/materials.xml +++ b/compact/materials.xml @@ -538,4 +538,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index ca9254bb1d..d4473494fb 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -14,13 +14,13 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace ROOT::Math; -void buildMagElement(dd4hep::DetElement &sdet, +void buildTubeElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, string element, dd4hep::Material material); -void buildCryoElement(dd4hep::DetElement &sdet, +void buildPolyElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -37,15 +37,22 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) Assembly assembly(det_name + "_assembly"); // get materials - Material iron = dtor.material("Iron"); - Material nbti = dtor.material("SolenoidCoil"); - Material steel = dtor.material("StainlessSteel"); + Material iron = dtor.material("Iron"); + Material nbti = dtor.material("SolenoidCoil"); + Material steel_304l = dtor.material("StainlessSteel"); + Material alum = dtor.material("Al6061T6"); + Material steel_a53 = dtor.material("StainlessSteelA53"); // build magnet components - buildMagElement(sdet,assembly,dtor,x_det,"yoke",iron); - buildMagElement(sdet,assembly,dtor,x_det,"coil",nbti); - buildMagElement(sdet,assembly,dtor,x_det,"tube",steel); - buildCryoElement(sdet,assembly,dtor,x_det,"endplate",steel); + buildTubeElement(sdet,assembly,dtor,x_det,"yoke",iron); + buildTubeElement(sdet,assembly,dtor,x_det,"coil",nbti); + buildTubeElement(sdet,assembly,dtor,x_det,"tube",steel_304l); + buildPolyElement(sdet,assembly,dtor,x_det,"endplate",steel_304l); + buildTubeElement(sdet,assembly,dtor,x_det,"yokeshield",steel_304l); + buildTubeElement(sdet,assembly,dtor,x_det,"heatshieldbarrel",alum); + buildPolyElement(sdet,assembly,dtor,x_det,"heatshieldend",alum); + buildTubeElement(sdet,assembly,dtor,x_det,"cryobarrel",steel_a53); + buildPolyElement(sdet,assembly,dtor,x_det,"cryoend",steel_a53); // final placement auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); @@ -58,7 +65,7 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) return sdet; } -void buildCryoElement(dd4hep::DetElement &sdet, +void buildPolyElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -100,6 +107,53 @@ void buildCryoElement(dd4hep::DetElement &sdet, Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); Solid elem_final(elem_tube); + // get all adds + xml_coll_t adds_c(elem_c, _Unicode(add)); + // loop over adds + for (; adds_c; ++adds_c) + { + // get one cut + xml_comp_t add_c = adds_c; + // get shape + string add_shape = add_c.attr("shape"); + // get placement coordinates + xml_dim_t add_pos = add_c.child(_U(placement)); + double add_theta = add_pos.attr("theta"); + // get dimentions + xml_dim_t add_dim = add_c.child(_U(dimensions)); + + Transform3D tf_tmp( + RotationZYX(0, add_theta, 0), + Position(add_pos.x(),add_pos.y(),add_pos.z())); + + if(add_shape == "Prism") + { + double add_pdx1 = add_dim.attr("pdx1"); + double add_pdx2 = add_dim.attr("pdx2"); + double add_pdy1 = add_dim.attr("pdy1"); + double add_pdy2 = add_dim.attr("pdy2"); + double add_pdz = add_dim.attr("pdz"); + + // build a solid + Trapezoid add_prism(add_pdx1,add_pdx2,add_pdy1,add_pdy2,add_pdz); + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_prism,tf_tmp); + } + else if(add_shape == "Tube") + { + double add_rmin = add_dim.attr("rmin"); + double add_rmax = add_dim.attr("rmax"); + double add_half_l = add_dim.attr("half_length"); + + // build a solid + Tube add_tube(add_rmin,add_rmax,add_half_l); + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_tube,tf_tmp); + } + } + // get all cuts xml_coll_t cuts_c(elem_c, _Unicode(cut)); // loop over cuts @@ -115,30 +169,15 @@ void buildCryoElement(dd4hep::DetElement &sdet, double cut_rmin = cut_dim.attr("rmin"); double cut_rmax = cut_dim.attr("rmax"); double cut_half_l = cut_dim.attr("half_length"); - // get rotation coordinates - xml_dim_t cut_rot = cut_c.child(_U(rotation)); - int cut_rot_num = cut_rot.attr("num"); - double cut_rot_step = cut_rot.attr("step"); - string cut_rot_axis = cut_rot.attr("axis"); // build a solid Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); - // loop over rot steps - for(int i = 0; i < cut_rot_num; i++) - { - Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = i * cut_rot_step; - Rotation3D rot_tmp; - if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} - else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} - else {rot_tmp = RotationZ(ang_tmp);} - pos_tmp = rot_tmp * pos_tmp; - - Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); - } + Transform3D tf_tmp( + RotationZYX(0, cut_theta, 0), + Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); } // create volume @@ -158,7 +197,7 @@ void buildCryoElement(dd4hep::DetElement &sdet, return; } -void buildMagElement(dd4hep::DetElement &sdet, +void buildTubeElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -207,7 +246,7 @@ void buildMagElement(dd4hep::DetElement &sdet, double phi_tmp = phi_start + i * phi_step; Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); // unite sub-elements - elem_final = UnionSolid("elem_tube",elem_final,elem_tube,tf_tmp); + elem_final = UnionSolid("elem_final",elem_final,elem_tube,tf_tmp); } } @@ -248,7 +287,7 @@ void buildMagElement(dd4hep::DetElement &sdet, Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); + elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); } } From 8f3ad143dc045f968bfd5cb9b55be9fcbb5b86fc Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 10:11:43 -0400 Subject: [PATCH 04/79] Added Q0eF tubes and coils --- compact/far_forward/electron_beamline.xml | 26 +++++++++++++++++++++++ compact/far_forward/ion_beamline.xml | 1 + 2 files changed, 27 insertions(+) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 337bd984bc..7ac6bbcea2 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -55,7 +55,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index d3e2c5fd27..58e41808a2 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -21,6 +21,7 @@ ===================================== + From 9896e0050422096e89539ea3cd32435db5775204 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 11:27:13 -0400 Subject: [PATCH 05/79] Polished XML, define common variables --- compact/far_forward/electron_beamline.xml | 15 ++++++--- compact/far_forward/ion_beamline.xml | 40 +++++++++++++---------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 7ac6bbcea2..b2b0fec264 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -4,6 +4,11 @@ + + + + + @@ -61,23 +66,23 @@ - + - + - + - + - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 58e41808a2..e607573a41 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -3,6 +3,12 @@ + + + + + + @@ -24,7 +30,7 @@ - + @@ -38,49 +44,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -97,7 +103,7 @@ - + @@ -110,13 +116,13 @@ - + - - - + + + From bb49969df471d381d6367d251cdb874c07cb70b0 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 12:11:42 -0400 Subject: [PATCH 06/79] Added B0ApF --- compact/far_forward/ion_beamline.xml | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index e607573a41..9ac1aa86b4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -8,6 +8,11 @@ + + + + + @@ -137,5 +142,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a8c8d6676076d8efa35534945b0c328a867094d8 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 13:53:02 -0400 Subject: [PATCH 07/79] Added Q1ApF --- compact/far_forward/ion_beamline.xml | 96 ++++++++++++++++++++++++---- src/CylindricalDipoleMagnet_geo.cpp | 62 ++++++++++++------ 2 files changed, 128 insertions(+), 30 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9ac1aa86b4..1683361b0e 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -13,6 +13,11 @@ + + + + + @@ -38,12 +43,12 @@ - + - + @@ -103,7 +108,7 @@ - + @@ -112,11 +117,11 @@ - + - + @@ -137,7 +142,7 @@ - + @@ -149,7 +154,7 @@ - + @@ -175,7 +180,7 @@ - + @@ -184,7 +189,7 @@ - + @@ -197,7 +202,7 @@ - + @@ -206,10 +211,79 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index d4473494fb..0585f7a655 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -112,6 +112,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, // loop over adds for (; adds_c; ++adds_c) { + Solid add_elem; // get one cut xml_comp_t add_c = adds_c; // get shape @@ -136,9 +137,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, // build a solid Trapezoid add_prism(add_pdx1,add_pdx2,add_pdy1,add_pdy2,add_pdz); - - // unite the add with the element solid - elem_final = UnionSolid("elem_final",elem_final,add_prism,tf_tmp); + add_elem = add_prism; } else if(add_shape == "Tube") { @@ -148,10 +147,11 @@ void buildPolyElement(dd4hep::DetElement &sdet, // build a solid Tube add_tube(add_rmin,add_rmax,add_half_l); - - // unite the add with the element solid - elem_final = UnionSolid("elem_final",elem_final,add_tube,tf_tmp); + add_elem = add_tube; } + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_elem,tf_tmp); } // get all cuts @@ -163,7 +163,9 @@ void buildPolyElement(dd4hep::DetElement &sdet, xml_comp_t cut_c = cuts_c; // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_theta = cut_pos.attr("theta"); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); // get dimentions xml_dim_t cut_dim = cut_c.child(_U(dimensions)); double cut_rmin = cut_dim.attr("rmin"); @@ -174,7 +176,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); Transform3D tf_tmp( - RotationZYX(0, cut_theta, 0), + RotationZYX(cut_rotX,cut_rotY,cut_rotZ), Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); // subtract the cut from the element solid elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); @@ -257,23 +259,45 @@ void buildTubeElement(dd4hep::DetElement &sdet, { // get one cut xml_comp_t cut_c = cuts_c; + // get shape + string add_shape = dd4hep::getAttrOrDefault( + cut_c, _Unicode(shape), "Tube"); // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_theta = cut_pos.attr("theta"); - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); // get rotation coordinates xml_dim_t cut_rot = cut_c.child(_U(rotation)); int cut_rot_num = cut_rot.attr("num"); double cut_rot_step = cut_rot.attr("step"); string cut_rot_axis = cut_rot.attr("axis"); - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + Solid cut_elem; + if(add_shape == "Box") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_dx = cut_dim.attr("dx"); + double cut_dy = cut_dim.attr("dy"); + double cut_dz = cut_dim.attr("dz"); + // build a solid + Box cut_box(cut_dx,cut_dy,cut_dz); + cut_elem = cut_box; + } + else if(add_shape == "Tube") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + cut_elem = cut_tube; + } // loop over rot steps for(int i = 0; i < cut_rot_num; i++) { @@ -285,9 +309,9 @@ void buildTubeElement(dd4hep::DetElement &sdet, else {rot_tmp = RotationZ(ang_tmp);} pos_tmp = rot_tmp * pos_tmp; - Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); + elem_final = SubtractionSolid("elem_final",elem_final,cut_elem,tf_tmp); } } @@ -362,7 +386,7 @@ DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) */ -/* from compact/far_forward/ion_beamline.xml +/* from compact/far_forward/electron_beamline.xml From 78590100f08aec97a722fd98ac9e4fdd67aa9c46 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 14:25:39 -0400 Subject: [PATCH 08/79] Added Q1BpF --- compact/far_forward/ion_beamline.xml | 101 +++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 1683361b0e..50acf17efc 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -18,6 +18,11 @@ + + + + + @@ -284,8 +289,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c79504937bb38b7e4605c6af21297622bf3c53e6 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 14:36:29 -0400 Subject: [PATCH 09/79] Added Q1eF --- compact/far_forward/electron_beamline.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index b2b0fec264..5c1d820015 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -4,12 +4,18 @@ - - + + + + + + + + @@ -85,8 +91,16 @@ + + + + + + + + From 59e47774a175be01f34ccfe43c4d761033d609bb Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 16:18:31 -0400 Subject: [PATCH 10/79] Added Q2pF yoke --- compact/far_forward/ion_beamline.xml | 67 +++++++++++++++++++++------- src/CylindricalDipoleMagnet_geo.cpp | 3 +- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 50acf17efc..1e8ddccb37 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -23,6 +23,11 @@ + + + + + @@ -50,12 +55,12 @@ - + - + @@ -161,7 +166,7 @@ - + @@ -230,27 +235,27 @@ - + - + - + - + - + @@ -259,12 +264,12 @@ - + - + @@ -299,27 +304,27 @@ - + - + - + - + - + @@ -328,12 +333,12 @@ - + - + @@ -366,7 +371,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 0585f7a655..5b980ae87e 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -271,6 +271,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, xml_dim_t cut_rot = cut_c.child(_U(rotation)); int cut_rot_num = cut_rot.attr("num"); double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); string cut_rot_axis = cut_rot.attr("axis"); Solid cut_elem; @@ -302,7 +303,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, for(int i = 0; i < cut_rot_num; i++) { Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = i * cut_rot_step; + double ang_tmp = cut_rot_start + i * cut_rot_step; Rotation3D rot_tmp; if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} From eefdc4b56087ef6af9258bcd7f81d8da852af9db Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 16:26:48 -0400 Subject: [PATCH 11/79] Added Q2pF yoke (more holes) --- compact/far_forward/ion_beamline.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 1e8ddccb37..33eca49fbc 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -398,7 +398,11 @@ - + + + + + From 694d574721dbea8c9264fc40b1bb14a49ef4fb93 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 05:52:46 -0400 Subject: [PATCH 12/79] Added Q2pF --- compact/far_forward/ion_beamline.xml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 33eca49fbc..236f4ccccb 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -404,6 +404,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From af2148a1059eb042f787f072de1e0bc6c2d55cfb Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 07:05:16 -0400 Subject: [PATCH 13/79] Added B1pF --- compact/far_forward/ion_beamline.xml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 236f4ccccb..9dc422fdd4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -28,6 +28,11 @@ + + + + + @@ -440,6 +445,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2666862b402b66d4ed0498deb1666e53ff63ce93 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 08:34:22 -0400 Subject: [PATCH 14/79] Fixed rotation around Y --- compact/far_forward/ion_beamline.xml | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9dc422fdd4..5ab37a57a5 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -12,27 +12,27 @@ - + - + - + - + - + @@ -169,7 +169,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -217,7 +217,7 @@ - + @@ -226,7 +226,7 @@ - + @@ -238,7 +238,7 @@ - + @@ -282,7 +282,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -307,7 +307,7 @@ - + @@ -351,7 +351,7 @@ - + @@ -360,7 +360,7 @@ - + @@ -369,11 +369,11 @@ - + - + @@ -384,7 +384,7 @@ - + @@ -453,7 +453,7 @@ - + From eb8f9c19bf0f106e6a69cb337e6cb1928625bd0b Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 9 Jun 2025 17:51:50 -0400 Subject: [PATCH 15/79] Added B1ApF (full) and Q1ApR (yoke) --- compact/definitions.xml | 5 + .../beamline_extension_hadron.xml | 21 +++ compact/far_forward/ion_beamline.xml | 140 +++++++++++++++++- src/CylindricalDipoleMagnet_geo.cpp | 14 ++ 4 files changed, 177 insertions(+), 3 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index a684281bc4..6ec74e8689 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -319,6 +319,11 @@ The unused IDs below are saved for future use. + + #### (200-210) Far Backward Beamline Magnets + + + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 7b9b4a6250..664f7a4276 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -8,11 +8,32 @@ Implemented to allow overlap checks with the far backwards systems + + + + + + + + Hadron side beam magnet volumes + + + + + + + + + + + + + - + + + + + + @@ -484,7 +489,7 @@ - + @@ -492,9 +497,138 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 5b980ae87e..6cd8b95995 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -299,6 +299,20 @@ void buildTubeElement(dd4hep::DetElement &sdet, Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); cut_elem = cut_tube; } + else if(add_shape == "Cone") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); + cut_elem = cut_cone; + } // loop over rot steps for(int i = 0; i < cut_rot_num; i++) { From 9a550c20a8614629821a5aae2058800626772476 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 9 Jun 2025 22:31:38 -0400 Subject: [PATCH 16/79] Added Q1ApR coils --- .../beamline_extension_hadron.xml | 19 +++ src/CylindricalDipoleMagnet_geo.cpp | 154 +++++++----------- 2 files changed, 74 insertions(+), 99 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 664f7a4276..37e4cf6c45 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -14,6 +14,11 @@ + + + + + @@ -31,7 +36,21 @@ + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 6cd8b95995..f63ef1609d 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -219,21 +219,64 @@ void buildTubeElement(dd4hep::DetElement &sdet, // get placement coordinates xml_dim_t elem_pos = elem_c.child(_U(placement)); double elem_theta = elem_pos.attr("theta"); - // get dimentions - xml_dim_t elem_dim = elem_c.child(_U(dimensions)); - double elem_rmin = elem_dim.attr("rmin"); - double elem_rmax = elem_dim.attr("rmax"); - double elem_half_l = elem_dim.attr("half_length"); - double elem_sphi = elem_dim.attr("sphi"); - double elem_dphi = elem_dim.attr("dphi"); // set attributes - const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + const string elem_vis = + dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); - // build solid - Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); - Solid elem_final(elem_tube); + // get shape + string elem_shape = dd4hep::getAttrOrDefault(elem_c, _Unicode(shape), "Tube"); + + Solid elem_sub; + if(elem_shape == "Cone") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + + // build a solid + Cone elem_cone(elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2); + elem_sub = elem_cone; + } + else if(elem_shape == "ConeSegment") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build a solid + ConeSegment elem_conesegment( + elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2,elem_sphi, + elem_sphi+elem_dphi); + elem_sub = elem_conesegment; + } + else if(elem_shape == "Tube") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin = elem_dim.attr("rmin"); + double elem_rmax = elem_dim.attr("rmax"); + double elem_half_l = elem_dim.attr("half_length"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build solid + Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); + elem_sub = elem_tube; + } + + Solid elem_final(elem_sub); // combine sub-elements if(elem_pos.hasAttr(_Unicode(phiNum))) @@ -248,7 +291,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, double phi_tmp = phi_start + i * phi_step; Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); // unite sub-elements - elem_final = UnionSolid("elem_final",elem_final,elem_tube,tf_tmp); + elem_final = UnionSolid("elem_final",elem_final,elem_sub,tf_tmp); } } @@ -349,93 +392,6 @@ void buildTubeElement(dd4hep::DetElement &sdet, DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) -/* from compact/far_forward/ion_beamline.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - - -/* from compact/far_forward/electron_beamline.xml - - - - - - !--unchecked-- - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - - -*/ - /* from compact/far_backward/magnets.xml From 2007a5ebcdbf20edb4ec3f84458daa4f1d54b493 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 12:10:55 -0400 Subject: [PATCH 17/79] Added Q1ApR --- .../beamline_extension_hadron.xml | 114 ++++++++++++++++++ compact/far_forward/ion_beamline.xml | 18 ++- src/CylindricalDipoleMagnet_geo.cpp | 66 ++++++++-- 3 files changed, 184 insertions(+), 14 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 37e4cf6c45..f3c1553483 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -41,6 +41,11 @@ + + + + + @@ -50,6 +55,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index c748bf0a1b..acf5ee1d98 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -130,6 +130,7 @@ + @@ -139,10 +140,12 @@ + + @@ -164,6 +167,7 @@ + @@ -202,6 +206,7 @@ + @@ -211,6 +216,7 @@ + @@ -224,6 +230,7 @@ + @@ -233,6 +240,7 @@ + @@ -289,6 +297,7 @@ + @@ -298,6 +307,7 @@ + @@ -358,6 +368,7 @@ + @@ -367,6 +378,7 @@ + @@ -603,17 +615,19 @@ + + - + @@ -622,10 +636,12 @@ + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index f63ef1609d..8858c62856 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -156,30 +156,70 @@ void buildPolyElement(dd4hep::DetElement &sdet, // get all cuts xml_coll_t cuts_c(elem_c, _Unicode(cut)); + + Solid cut_final; // loop over cuts for (; cuts_c; ++cuts_c) { // get one cut - xml_comp_t cut_c = cuts_c; + xml_comp_t cut_c = cuts_c; + // get shape + string cut_shape = dd4hep::getAttrOrDefault(cut_c, _Unicode(shape), "Tube"); + // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); double cut_rotX = cut_pos.attr("rotX"); double cut_rotY = cut_pos.attr("rotY"); double cut_rotZ = cut_pos.attr("rotZ"); - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); + string cut_rot_axis = cut_rot.attr("axis"); - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + if(cut_shape == "Cone") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); + cut_final = cut_cone; + } + else if(cut_shape == "Tube") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + cut_final = cut_tube; + } + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = cut_rot_start + i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; - Transform3D tf_tmp( - RotationZYX(cut_rotX,cut_rotY,cut_rotZ), - Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); + Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final",elem_final,cut_final,tf_tmp); + } } // create volume From 86e54bd33228ee8c03f40bda57f675e044c6f3d6 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 14:01:29 -0400 Subject: [PATCH 18/79] Added Q1BpR --- compact/definitions.xml | 1 + .../beamline_extension_hadron.xml | 111 +++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index 6ec74e8689..d4417307f6 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -323,6 +323,7 @@ The unused IDs below are saved for future use. #### (200-210) Far Backward Beamline Magnets + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index f3c1553483..2b0cf8ec21 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -18,6 +18,15 @@ + + + + + + + + + @@ -95,7 +104,7 @@ - + @@ -115,7 +124,7 @@ - + @@ -164,7 +173,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8ba0128fc83b9d587a9b921fda22dbe6a5d5b0de Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 15:00:00 -0400 Subject: [PATCH 19/79] Added Q2pR --- compact/definitions.xml | 1 + .../beamline_extension_hadron.xml | 132 +++++++++++++++++- 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index d4417307f6..78a58b7c79 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -324,6 +324,7 @@ The unused IDs below are saved for future use. + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 2b0cf8ec21..6925a3c7db 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -27,6 +27,15 @@ + + + + + + + + + @@ -266,14 +275,135 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Mon, 16 Jun 2025 16:56:57 -0400 Subject: [PATCH 20/79] Added Q1eR and Q2eR --- compact/definitions.xml | 2 + .../beamline_extension_electron.xml | 42 +++++++++++++++++++ .../beamline_extension_hadron.xml | 2 - 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index 78a58b7c79..3e13ab867a 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -325,6 +325,8 @@ The unused IDs below are saved for future use. + + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index e1346df240..75c811fee1 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -3,11 +3,53 @@ + + + + + + + + + + + + + + + Outgoing electron beam pipes Implemented to allow overlap checks with the far backwards systems + + + + + + + + + + + + + + + + + + + + + + + + + + + Electron side extended beam pipe volumes diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 6925a3c7db..1f8f19418a 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -399,9 +399,7 @@ - - From a734fbbfb02d8f489b194e9b3b9b8aacfa452c9f Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 17:11:37 -0400 Subject: [PATCH 21/79] Corrected visualization in XML files --- compact/display.xml | 12 +- compact/display_detailed.xml | 7 - compact/display_geoviewer.xml | 7 - .../beamline_extension_electron.xml | 8 +- .../beamline_extension_hadron.xml | 66 ++++----- compact/far_forward/electron_beamline.xml | 12 +- compact/far_forward/ion_beamline.xml | 126 +++++++++--------- src/CylindricalDipoleMagnet_geo.cpp | 40 ------ 8 files changed, 112 insertions(+), 166 deletions(-) diff --git a/compact/display.xml b/compact/display.xml index 88a2993699..80574fdbaa 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -142,12 +142,12 @@ Beam line with magnets - - - - - - + + + + + + ZDC visualization diff --git a/compact/display_detailed.xml b/compact/display_detailed.xml index 0c98e51c29..9857e2d3b4 100644 --- a/compact/display_detailed.xml +++ b/compact/display_detailed.xml @@ -114,13 +114,6 @@ - - Beam line with magnets - - - - - ZDC visualization diff --git a/compact/display_geoviewer.xml b/compact/display_geoviewer.xml index eadeee7ff1..9ea8e3750c 100644 --- a/compact/display_geoviewer.xml +++ b/compact/display_geoviewer.xml @@ -114,13 +114,6 @@ - - Beam line with magnets - - - - - ZDC visualization diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 75c811fee1..06bbfde433 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -26,11 +26,11 @@ - + - + @@ -38,11 +38,11 @@ - + - + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 1f8f19418a..97f968d361 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -46,7 +46,7 @@ - + @@ -65,15 +65,15 @@ - + - + - + @@ -93,7 +93,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -153,19 +153,19 @@ - + - + - + - + @@ -186,7 +186,7 @@ - + @@ -205,15 +205,15 @@ - + - + - + @@ -228,7 +228,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -258,7 +258,7 @@ - + @@ -273,15 +273,15 @@ - + - + - + @@ -289,7 +289,7 @@ - + @@ -303,15 +303,15 @@ - + - + - + @@ -326,7 +326,7 @@ - + @@ -341,7 +341,7 @@ - + @@ -356,7 +356,7 @@ - + @@ -371,19 +371,19 @@ - + - + - + - + @@ -406,7 +406,7 @@ + vis="MagnetVis"> diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 5c1d820015..f918763093 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -71,23 +71,23 @@ - + - + - + - + - + @@ -95,7 +95,7 @@ - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index acf5ee1d98..5fb8cecfb2 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -59,7 +59,7 @@ - + @@ -73,49 +73,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -133,7 +133,7 @@ - + @@ -148,11 +148,11 @@ - + - + @@ -174,7 +174,7 @@ - + @@ -183,23 +183,23 @@ - + - + - + - + - + @@ -209,7 +209,7 @@ - + @@ -219,11 +219,11 @@ - + - + @@ -233,7 +233,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -276,7 +276,7 @@ - + @@ -290,7 +290,7 @@ - + @@ -300,7 +300,7 @@ - + @@ -310,7 +310,7 @@ - + @@ -318,7 +318,7 @@ - + @@ -347,7 +347,7 @@ - + @@ -361,7 +361,7 @@ - + @@ -371,7 +371,7 @@ - + @@ -381,15 +381,15 @@ - + - + - + @@ -397,7 +397,7 @@ - + @@ -426,7 +426,7 @@ - + @@ -440,25 +440,25 @@ - + - + - + - + - + @@ -466,7 +466,7 @@ - + @@ -480,15 +480,15 @@ - + - + - + @@ -497,15 +497,15 @@ - + - + - + @@ -513,7 +513,7 @@ - + @@ -542,7 +542,7 @@ - + @@ -571,7 +571,7 @@ - + @@ -580,33 +580,33 @@ - + - + - + - + - + - + - + @@ -623,11 +623,11 @@ - + - + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 8858c62856..02ad2fb8de 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -431,43 +431,3 @@ void buildTubeElement(dd4hep::DetElement &sdet, } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) - -/* from compact/far_backward/magnets.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* from compact/far_backward/beamline_extension_hadron.xml - - - - - - -*/ From e459addf227768ffb32653cf50716a2738262edc Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 14:52:36 -0400 Subject: [PATCH 22/79] Minor corrections --- compact/far_forward/ion_beamline.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 5fb8cecfb2..2714842118 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -406,7 +406,7 @@ - + From 76e2f65870568ace0a16ee6e1e3060ef3310cf00 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 15:32:11 -0400 Subject: [PATCH 23/79] build a single beam pipe + vacuum for the electron ring on the fwd side from the end of the center beam pipe to the end of the fwd cryostat <-- will be replaced by the realistic beam pipe model later --- compact/far_forward/electron_beamline.xml | 26 ++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index f918763093..6ed4bca964 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -33,35 +33,23 @@ - - + + - + - - - - - - - + From ed5ddb6b07fda5cafa4f011a4353e6c2b4bf7dce Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 16:01:30 -0400 Subject: [PATCH 24/79] Switched from Cone to ConeSegment for the vacuum volume between the IP beam pipe and B0pF: covering in phi 280deg, instead of 260 deg to avoid overlaps with B0 cryostat and heatshield --- src/magnetVacuumFF.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/magnetVacuumFF.cpp b/src/magnetVacuumFF.cpp index 94f915bbba..be99a7aacb 100644 --- a/src/magnetVacuumFF.cpp +++ b/src/magnetVacuumFF.cpp @@ -246,8 +246,8 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * std::string piece_name = Form("GapVacuum%d", numGaps + numMagnets); - Cone specialGap(piece_name, specialGapLength / 2, 0.0, vacuumDiameterEntrance / 2, 0.0, - vacuumDiameterExit / 2); + ConeSegment specialGap(piece_name, specialGapLength / 2, 0.0, vacuumDiameterEntrance / 2, 0.0, + vacuumDiameterExit / 2, 40 * deg, (360 - 40) * deg); Volume specialGap_v(piece_name, specialGap, m_Vac); sdet.setAttributes(det, specialGap_v, x_det.regionStr(), x_det.limitsStr(), vis_name); From 019dad38e4a7d07a90d1f6f4ffa9d31efdb51c0c Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 16:18:07 -0400 Subject: [PATCH 25/79] Enlarged a hole in the non-IP heat shield of the B0 cryo to avoid overlaps with the hadron beam pipe --- compact/far_forward/ion_beamline.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 2714842118..68816a201f 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -144,7 +144,7 @@ - + From e75bb1e3b735dfe5ae1165aaf8035121eed93abf Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 17:00:22 -0400 Subject: [PATCH 26/79] Reduced inner radius for the fwd hadron beam pipe to avoid overlaps with the cryostat --- compact/far_forward/definitions.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compact/far_forward/definitions.xml b/compact/far_forward/definitions.xml index 1ad75fef5c..ceeaa1fe0d 100644 --- a/compact/far_forward/definitions.xml +++ b/compact/far_forward/definitions.xml @@ -42,9 +42,9 @@ - - - + + + From c2c07c9c54811c90141b7ce2c78e8a1a8a339199 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 13:30:20 -0400 Subject: [PATCH 27/79] Adjusted far-fwd hadron beam pipe to avoid overlaps with the fwd cryostat --- compact/far_forward/offM_tracker.xml | 8 ++++---- src/forwardBeamPipeBrazil.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/compact/far_forward/offM_tracker.xml b/compact/far_forward/offM_tracker.xml index b3ba6d2f3f..bcaba76af4 100644 --- a/compact/far_forward/offM_tracker.xml +++ b/compact/far_forward/offM_tracker.xml @@ -30,7 +30,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -55,7 +55,7 @@ readout="ForwardOffMTrackerHits" vis="AnlRed" reflect="false"> - + @@ -80,7 +80,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -105,7 +105,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + diff --git a/src/forwardBeamPipeBrazil.cpp b/src/forwardBeamPipeBrazil.cpp index aa3cc2cd20..ac24eb8811 100644 --- a/src/forwardBeamPipeBrazil.cpp +++ b/src/forwardBeamPipeBrazil.cpp @@ -260,6 +260,8 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * //------------------------------------------ //begin building main volumes here //------------------------------------------ + // A box to cut out from the beam pipe to avoid overlaps with the fwd cryostat + Box cutout_for_FWD_cryo(1 * dd4hep::m, 1 * dd4hep::m, 2 * dd4hep::m); //------------------------------------------------------------------- @@ -290,6 +292,14 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * tmpAfterB1APF, neutral_exit_window_cutout, Position(160.0 * dd4hep::mm, 0.0, 0.5 * beampipe_dimensions[pieceIdx].length)); + //----------------------------------------------------------------- + // Cut on the IP side to avoid overlaps with the fwd cryostat + tmpAfterB1APF = SubtractionSolid( + tmpAfterB1APF, cutout_for_FWD_cryo, + Position(0.0, 0.0, (-beampipe_dimensions[pieceIdx].length) / 2)); + //----------------------------------------------------------------- + + Volume v_pipeAfterB1APF(Form("v_pipeAfterB1APF_%d", pieceIdx), tmpAfterB1APF, m_SS); sdet.setAttributes(det, v_pipeAfterB1APF, x_det.regionStr(), x_det.limitsStr(), vis_name); @@ -517,10 +527,21 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * SubtractionSolid final_vacuum_main_pipe( vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2251.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2551.0 - beampipe_dimensions[pieceIdx].zCenter))); final_vacuum_main_pipe = SubtractionSolid(final_vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2451.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2701.0 - beampipe_dimensions[pieceIdx].zCenter))); + + //----------------------------------------------------------------- + // Cut on the IP side to avoid overlaps with the fwd cryostat + final_vacuum_main_pipe = + SubtractionSolid(final_vacuum_main_pipe, cutout_for_FWD_cryo, + Position(0.0, 0.0, (2400.0 * dd4hep::cm - 2 * dd4hep::m - beampipe_dimensions[pieceIdx].zCenter))); + Tube pipe_for_FWD_cryo(0.0, 16.0 * dd4hep::cm, 97.0 * dd4hep::cm); + final_vacuum_main_pipe = + UnionSolid(final_vacuum_main_pipe, pipe_for_FWD_cryo, + Position(6.5 * dd4hep::cm, 0.0, (2400.0 * dd4hep::cm - 97.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); + //----------------------------------------------------------------- Volume v_vacuum_main_pipe("v_vacuum_main_pipe", final_vacuum_main_pipe, m_vac); sdet.setAttributes(det, v_vacuum_main_pipe, x_det.regionStr(), x_det.limitsStr(), "AnlBlue"); From adc08f39b1424dc75f5dd2617b7421b892f59be1 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 14:04:10 -0400 Subject: [PATCH 28/79] Adjusted far-bwd electron beam pipe to avoid overlaps with the bwd cryostat --- compact/far_backward/definitions.xml | 8 ++++---- compact/far_backward/magnets.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index c85aadb6d3..fe91ca0c5a 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -14,19 +14,19 @@ Electron magnet dimensions and positions - + - + - + - + diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index f40b521e41..a2c867d1d2 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -11,7 +11,7 @@ Date: Wed, 18 Jun 2025 14:25:20 -0400 Subject: [PATCH 29/79] Enlarged hole opening in the B0 exit window to avoid overlaps with Q0eF quad coils and support tubes --- compact/far_forward/beampipe_hadron_B0.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/beampipe_hadron_B0.xml b/compact/far_forward/beampipe_hadron_B0.xml index b55e377ab5..d1c69ae330 100644 --- a/compact/far_forward/beampipe_hadron_B0.xml +++ b/compact/far_forward/beampipe_hadron_B0.xml @@ -16,7 +16,7 @@ - + From 05fec7e3f5b9459892df8a1c557f04d7ab05f604 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 14:40:13 -0400 Subject: [PATCH 30/79] Reduced small tracker outer radius in B0 to avoid overlaps with Q0eF --- compact/far_forward/B0_tracker.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compact/far_forward/B0_tracker.xml b/compact/far_forward/B0_tracker.xml index 88ec565e7a..3d44537cb3 100644 --- a/compact/far_forward/B0_tracker.xml +++ b/compact/far_forward/B0_tracker.xml @@ -46,19 +46,19 @@ - + - + - + - + From 81da6932d91c30cea7cd446c57bf2a78297cf3b7 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 13:20:19 -0400 Subject: [PATCH 31/79] First implementation of the B0 yoke --- .../beamline_extension_hadron.xml | 6 - compact/far_backward/magnets.xml | 28 -- compact/far_forward/electron_beamline.xml | 31 -- compact/far_forward/ion_beamline.xml | 60 +--- src/CylindricalDipoleMagnet_geo.cpp | 267 +++++++++++++++--- 5 files changed, 239 insertions(+), 153 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 4727479a50..7b9b4a6250 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -13,12 +13,6 @@ Hadron side beam magnet volumes - - - - - - Electron side beam magnet volumes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 17e27815c1..68bfbecdc1 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -22,52 +22,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 33f9318849..bbb70a86ee 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -15,48 +15,231 @@ using namespace dd4hep::rec; using namespace ROOT::Math; static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - int det_id = x_det.id(); - string det_name = x_det.nameStr(); - xml_dim_t pos = x_det.child(_U(placement)); - double pos_x = pos.x(); - double pos_y = pos.y(); - double pos_z = pos.z(); - double pos_theta = pos.attr(_U(theta)); - xml_dim_t dims = x_det.dimensions(); - double dim_r = dims.r(); - double dim_z = dims.z(); - xml_dim_t apperture = x_det.child(_Unicode(apperture)); - double app_r = apperture.r(); - Material iron = dtor.material("Iron"); - - DetElement sdet(det_name, det_id); - Assembly assembly(det_name + "_assembly"); - - const string module_name = "Quad_magnet"; - - const string yoke_vis = - dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); - - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - - // -- yoke - Tube yoke_tube(app_r, dim_r, 0.5 * dim_z); - Volume yoke_vol("yoke_vol", yoke_tube, iron); - auto yoke_pv = assembly.placeVolume(yoke_vol); - yoke_pv.addPhysVolID("element", 1); - DetElement yoke_de(sdet, "yoke_de", 1); - yoke_de.setPlacement(yoke_pv); - yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - - // -- finishing steps - auto final_pos = Transform3D(Translation3D(pos_x, pos_y, pos_z) * RotationY(pos_theta)); - auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); - pv.addPhysVolID("system", det_id); - sdet.setPlacement(pv); - - assembly->GetShape()->ComputeBBox(); - return sdet; + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + Material iron = dtor.material("Iron"); + + DetElement sdet(det_name, det_id); + Assembly assembly(det_name + "_assembly"); + + const string yoke_vis = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + + //---- YOKE ---- + // get all yokes + xml_coll_t yokes_c(x_det, _Unicode(yoke)); + int yoke_id = 1; + // loop over yokes + for (; yokes_c; ++yokes_c) + { + // get one yoke + xml_comp_t yoke_c = yokes_c; + // get placement coordinates + xml_dim_t yoke_pos = yoke_c.child(_U(placement)); + double yoke_theta = yoke_pos.attr("theta"); + // get dimentions + xml_dim_t yoke_dim = yoke_c.child(_U(dimensions)); + double yoke_rmin = yoke_dim.attr("rmin"); + double yoke_rmax = yoke_dim.attr("rmax"); + double yoke_half_l = yoke_dim.attr("half_length"); + + // build solid + Tube yoke_tube(yoke_rmin,yoke_rmax,yoke_half_l); + Solid yoke_final(yoke_tube); + + // get all cuts + xml_coll_t cuts_c(yoke_c, _Unicode(cut)); + // loop over cuts + for (; cuts_c; ++cuts_c) + { + // get one cut + xml_comp_t cut_c = cuts_c; + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_theta = cut_pos.attr("theta"); + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + string cut_rot_axis = cut_rot.attr("axis"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + // subtract the cut from yoke solid + yoke_final = SubtractionSolid("yoke_tube",yoke_final,cut_tube,tf_tmp); + } + } + + // create volume + string yoke_vol_name = "yoke_vol_" + to_string(yoke_id); + Volume yoke_vol(yoke_vol_name, yoke_final, iron); + + // placement + auto yoke_pv = assembly.placeVolume(yoke_vol); + yoke_pv.addPhysVolID("element", yoke_id); + DetElement yoke_de(sdet, "yoke_de", yoke_id); + yoke_de.setPlacement(yoke_pv); + yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + yoke_id++; + + // finishing steps + auto final_pos = Transform3D( + Translation3D(yoke_pos.x(),yoke_pos.y(),yoke_pos.z()) * RotationY(yoke_theta)); + auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); + pv.addPhysVolID("system", det_id); + sdet.setPlacement(pv); + + // update bounding box + assembly->GetShape()->ComputeBBox(); + } + + return sdet; } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) + +/* from compact/far_forward/ion_beamline.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + + +/* from compact/far_forward/ion_beamline.xml + + + + + + !--unchecked-- + + + + + + + + + + + + + + + + !--unchecked-- + + + + + + + + + + +*/ + +/* from compact/far_backward/magnets.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + +/* from compact/far_backward/beamline_extension_hadron.xml + + + + + + +*/ From 2413455d91215d645a24455254b2c002deea847a Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 17:16:55 -0400 Subject: [PATCH 32/79] Added coils, support tubes, manifold(endplates). --- compact/colors.xml | 1 + compact/display.xml | 8 +- compact/far_forward/ion_beamline.xml | 40 ++++- src/CylindricalDipoleMagnet_geo.cpp | 244 ++++++++++++++++++++++----- 4 files changed, 242 insertions(+), 51 deletions(-) diff --git a/compact/colors.xml b/compact/colors.xml index 4c320b287c..b233b2fb2b 100644 --- a/compact/colors.xml +++ b/compact/colors.xml @@ -11,6 +11,7 @@ + diff --git a/compact/display.xml b/compact/display.xml index 69e76b048d..a4297cd035 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -141,9 +141,11 @@ Beam line with magnets - - - + + + + + ZDC visualization diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 68bfbecdc1..6058b528b4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -21,10 +21,10 @@ ===================================== - - + + - + @@ -36,6 +36,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index bbb70a86ee..ca9254bb1d 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -14,42 +14,205 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace ROOT::Math; -static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - int det_id = x_det.id(); - string det_name = x_det.nameStr(); - Material iron = dtor.material("Iron"); +void buildMagElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material); +void buildCryoElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material); + +static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) +{ + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); DetElement sdet(det_name, det_id); Assembly assembly(det_name + "_assembly"); - const string yoke_vis = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "FFMagnetVis"); - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), yoke_vis); + // get materials + Material iron = dtor.material("Iron"); + Material nbti = dtor.material("SolenoidCoil"); + Material steel = dtor.material("StainlessSteel"); + + // build magnet components + buildMagElement(sdet,assembly,dtor,x_det,"yoke",iron); + buildMagElement(sdet,assembly,dtor,x_det,"coil",nbti); + buildMagElement(sdet,assembly,dtor,x_det,"tube",steel); + buildCryoElement(sdet,assembly,dtor,x_det,"endplate",steel); + + // final placement + auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); + pv_assembly.addPhysVolID("system", det_id); + sdet.setPlacement(pv_assembly); - //---- YOKE ---- - // get all yokes - xml_coll_t yokes_c(x_det, _Unicode(yoke)); - int yoke_id = 1; - // loop over yokes - for (; yokes_c; ++yokes_c) + // update bounding box + assembly->GetShape()->ComputeBBox(); + + return sdet; +} + +void buildCryoElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material) +{ + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) { - // get one yoke - xml_comp_t yoke_c = yokes_c; + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); // get placement coordinates - xml_dim_t yoke_pos = yoke_c.child(_U(placement)); - double yoke_theta = yoke_pos.attr("theta"); + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); + std::vector z; + std::vector rmax; + std::vector rmin; + // loop over z-planes + xml_coll_t zplanes_c(elem_c, _Unicode(zplane)); + for (; zplanes_c; ++zplanes_c) + { + // get z-plane + xml_comp_t zplane_c = zplanes_c; + z.push_back(zplane_c.attr(_Unicode(z))); + rmin.push_back(zplane_c.attr(_Unicode(rmin))); + rmax.push_back(zplane_c.attr(_Unicode(rmax))); + } + + // set attributes + const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); + + // build solid + Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); + Solid elem_final(elem_tube); + + // get all cuts + xml_coll_t cuts_c(elem_c, _Unicode(cut)); + // loop over cuts + for (; cuts_c; ++cuts_c) + { + // get one cut + xml_comp_t cut_c = cuts_c; + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_theta = cut_pos.attr("theta"); + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + string cut_rot_axis = cut_rot.attr("axis"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); + } + } + + // create volume + Volume elem_vol(elem_name, elem_final, material); + + // placement + auto elem_pv = assembly.placeVolume(elem_vol, + Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; + } + + return; +} + +void buildMagElement(dd4hep::DetElement &sdet, + dd4hep::Assembly &assembly, + dd4hep::Detector &dtor, + dd4hep::xml::DetElement x_det, + string element, + dd4hep::Material material) +{ + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) + { + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); + // get placement coordinates + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); // get dimentions - xml_dim_t yoke_dim = yoke_c.child(_U(dimensions)); - double yoke_rmin = yoke_dim.attr("rmin"); - double yoke_rmax = yoke_dim.attr("rmax"); - double yoke_half_l = yoke_dim.attr("half_length"); + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin = elem_dim.attr("rmin"); + double elem_rmax = elem_dim.attr("rmax"); + double elem_half_l = elem_dim.attr("half_length"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // set attributes + const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); // build solid - Tube yoke_tube(yoke_rmin,yoke_rmax,yoke_half_l); - Solid yoke_final(yoke_tube); + Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); + Solid elem_final(elem_tube); + + // combine sub-elements + if(elem_pos.hasAttr(_Unicode(phiNum))) + { + int phi_num = elem_pos.attr("phiNum"); + double phi_step = elem_pos.attr("phiStep"); + double phi_start = elem_pos.attr("phiStart"); + + // loop over steps + for(int i = 0; i < phi_num; i++) + { + double phi_tmp = phi_start + i * phi_step; + Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); + // unite sub-elements + elem_final = UnionSolid("elem_tube",elem_final,elem_tube,tf_tmp); + } + } // get all cuts - xml_coll_t cuts_c(yoke_c, _Unicode(cut)); + xml_coll_t cuts_c(elem_c, _Unicode(cut)); // loop over cuts for (; cuts_c; ++cuts_c) { @@ -84,35 +247,26 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) pos_tmp = rot_tmp * pos_tmp; Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); - // subtract the cut from yoke solid - yoke_final = SubtractionSolid("yoke_tube",yoke_final,cut_tube,tf_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); } } // create volume - string yoke_vol_name = "yoke_vol_" + to_string(yoke_id); - Volume yoke_vol(yoke_vol_name, yoke_final, iron); + Volume elem_vol(elem_name, elem_final, material); // placement - auto yoke_pv = assembly.placeVolume(yoke_vol); - yoke_pv.addPhysVolID("element", yoke_id); - DetElement yoke_de(sdet, "yoke_de", yoke_id); - yoke_de.setPlacement(yoke_pv); - yoke_de.setAttributes(dtor, yoke_vol, x_det.regionStr(), x_det.limitsStr(), yoke_vis); - yoke_id++; - - // finishing steps - auto final_pos = Transform3D( - Translation3D(yoke_pos.x(),yoke_pos.y(),yoke_pos.z()) * RotationY(yoke_theta)); - auto pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, final_pos); - pv.addPhysVolID("system", det_id); - sdet.setPlacement(pv); - - // update bounding box - assembly->GetShape()->ComputeBBox(); + auto elem_pv = assembly.placeVolume(elem_vol, + Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; } - return sdet; + return; } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) From ffd0d877439ea07589698a5c116998d3ea57a39c Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 5 Jun 2025 23:43:22 -0400 Subject: [PATCH 33/79] Added heatshield and cryo --- compact/display.xml | 2 + compact/far_forward/ion_beamline.xml | 66 ++++++++++++++++- compact/materials.xml | 20 +++++ src/CylindricalDipoleMagnet_geo.cpp | 105 ++++++++++++++++++--------- 4 files changed, 156 insertions(+), 37 deletions(-) diff --git a/compact/display.xml b/compact/display.xml index a4297cd035..88a2993699 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -146,6 +146,8 @@ + + ZDC visualization diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 6058b528b4..d3e2c5fd27 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -58,19 +58,77 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/compact/materials.xml b/compact/materials.xml index 358f4b6954..7e79bb1f4a 100644 --- a/compact/materials.xml +++ b/compact/materials.xml @@ -547,4 +547,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index ca9254bb1d..d4473494fb 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -14,13 +14,13 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace ROOT::Math; -void buildMagElement(dd4hep::DetElement &sdet, +void buildTubeElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, string element, dd4hep::Material material); -void buildCryoElement(dd4hep::DetElement &sdet, +void buildPolyElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -37,15 +37,22 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) Assembly assembly(det_name + "_assembly"); // get materials - Material iron = dtor.material("Iron"); - Material nbti = dtor.material("SolenoidCoil"); - Material steel = dtor.material("StainlessSteel"); + Material iron = dtor.material("Iron"); + Material nbti = dtor.material("SolenoidCoil"); + Material steel_304l = dtor.material("StainlessSteel"); + Material alum = dtor.material("Al6061T6"); + Material steel_a53 = dtor.material("StainlessSteelA53"); // build magnet components - buildMagElement(sdet,assembly,dtor,x_det,"yoke",iron); - buildMagElement(sdet,assembly,dtor,x_det,"coil",nbti); - buildMagElement(sdet,assembly,dtor,x_det,"tube",steel); - buildCryoElement(sdet,assembly,dtor,x_det,"endplate",steel); + buildTubeElement(sdet,assembly,dtor,x_det,"yoke",iron); + buildTubeElement(sdet,assembly,dtor,x_det,"coil",nbti); + buildTubeElement(sdet,assembly,dtor,x_det,"tube",steel_304l); + buildPolyElement(sdet,assembly,dtor,x_det,"endplate",steel_304l); + buildTubeElement(sdet,assembly,dtor,x_det,"yokeshield",steel_304l); + buildTubeElement(sdet,assembly,dtor,x_det,"heatshieldbarrel",alum); + buildPolyElement(sdet,assembly,dtor,x_det,"heatshieldend",alum); + buildTubeElement(sdet,assembly,dtor,x_det,"cryobarrel",steel_a53); + buildPolyElement(sdet,assembly,dtor,x_det,"cryoend",steel_a53); // final placement auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); @@ -58,7 +65,7 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) return sdet; } -void buildCryoElement(dd4hep::DetElement &sdet, +void buildPolyElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -100,6 +107,53 @@ void buildCryoElement(dd4hep::DetElement &sdet, Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); Solid elem_final(elem_tube); + // get all adds + xml_coll_t adds_c(elem_c, _Unicode(add)); + // loop over adds + for (; adds_c; ++adds_c) + { + // get one cut + xml_comp_t add_c = adds_c; + // get shape + string add_shape = add_c.attr("shape"); + // get placement coordinates + xml_dim_t add_pos = add_c.child(_U(placement)); + double add_theta = add_pos.attr("theta"); + // get dimentions + xml_dim_t add_dim = add_c.child(_U(dimensions)); + + Transform3D tf_tmp( + RotationZYX(0, add_theta, 0), + Position(add_pos.x(),add_pos.y(),add_pos.z())); + + if(add_shape == "Prism") + { + double add_pdx1 = add_dim.attr("pdx1"); + double add_pdx2 = add_dim.attr("pdx2"); + double add_pdy1 = add_dim.attr("pdy1"); + double add_pdy2 = add_dim.attr("pdy2"); + double add_pdz = add_dim.attr("pdz"); + + // build a solid + Trapezoid add_prism(add_pdx1,add_pdx2,add_pdy1,add_pdy2,add_pdz); + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_prism,tf_tmp); + } + else if(add_shape == "Tube") + { + double add_rmin = add_dim.attr("rmin"); + double add_rmax = add_dim.attr("rmax"); + double add_half_l = add_dim.attr("half_length"); + + // build a solid + Tube add_tube(add_rmin,add_rmax,add_half_l); + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_tube,tf_tmp); + } + } + // get all cuts xml_coll_t cuts_c(elem_c, _Unicode(cut)); // loop over cuts @@ -115,30 +169,15 @@ void buildCryoElement(dd4hep::DetElement &sdet, double cut_rmin = cut_dim.attr("rmin"); double cut_rmax = cut_dim.attr("rmax"); double cut_half_l = cut_dim.attr("half_length"); - // get rotation coordinates - xml_dim_t cut_rot = cut_c.child(_U(rotation)); - int cut_rot_num = cut_rot.attr("num"); - double cut_rot_step = cut_rot.attr("step"); - string cut_rot_axis = cut_rot.attr("axis"); // build a solid Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); - // loop over rot steps - for(int i = 0; i < cut_rot_num; i++) - { - Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = i * cut_rot_step; - Rotation3D rot_tmp; - if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} - else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} - else {rot_tmp = RotationZ(ang_tmp);} - pos_tmp = rot_tmp * pos_tmp; - - Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); - } + Transform3D tf_tmp( + RotationZYX(0, cut_theta, 0), + Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); } // create volume @@ -158,7 +197,7 @@ void buildCryoElement(dd4hep::DetElement &sdet, return; } -void buildMagElement(dd4hep::DetElement &sdet, +void buildTubeElement(dd4hep::DetElement &sdet, dd4hep::Assembly &assembly, dd4hep::Detector &dtor, dd4hep::xml::DetElement x_det, @@ -207,7 +246,7 @@ void buildMagElement(dd4hep::DetElement &sdet, double phi_tmp = phi_start + i * phi_step; Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); // unite sub-elements - elem_final = UnionSolid("elem_tube",elem_final,elem_tube,tf_tmp); + elem_final = UnionSolid("elem_final",elem_final,elem_tube,tf_tmp); } } @@ -248,7 +287,7 @@ void buildMagElement(dd4hep::DetElement &sdet, Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_tube",elem_final,cut_tube,tf_tmp); + elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); } } From 8fbafab25b44e6722589db3b6213a348669bc2e2 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 10:11:43 -0400 Subject: [PATCH 34/79] Added Q0eF tubes and coils --- compact/far_forward/electron_beamline.xml | 26 +++++++++++++++++++++++ compact/far_forward/ion_beamline.xml | 1 + 2 files changed, 27 insertions(+) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 337bd984bc..7ac6bbcea2 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -55,7 +55,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index d3e2c5fd27..58e41808a2 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -21,6 +21,7 @@ ===================================== + From dbcffde436a07ccefa00fd90f0fa6618adeb7feb Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 11:27:13 -0400 Subject: [PATCH 35/79] Polished XML, define common variables --- compact/far_forward/electron_beamline.xml | 15 ++++++--- compact/far_forward/ion_beamline.xml | 40 +++++++++++++---------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 7ac6bbcea2..b2b0fec264 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -4,6 +4,11 @@ + + + + + @@ -61,23 +66,23 @@ - + - + - + - + - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 58e41808a2..e607573a41 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -3,6 +3,12 @@ + + + + + + @@ -24,7 +30,7 @@ - + @@ -38,49 +44,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -97,7 +103,7 @@ - + @@ -110,13 +116,13 @@ - + - - - + + + From 5326433a0987f4d6fa48ba2b688a01346df8dea7 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 12:11:42 -0400 Subject: [PATCH 36/79] Added B0ApF --- compact/far_forward/ion_beamline.xml | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index e607573a41..9ac1aa86b4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -8,6 +8,11 @@ + + + + + @@ -137,5 +142,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 44b7fffad3c77b57cf562d8ac280e455804e039c Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 13:53:02 -0400 Subject: [PATCH 37/79] Added Q1ApF --- compact/far_forward/ion_beamline.xml | 96 ++++++++++++++++++++++++---- src/CylindricalDipoleMagnet_geo.cpp | 62 ++++++++++++------ 2 files changed, 128 insertions(+), 30 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9ac1aa86b4..1683361b0e 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -13,6 +13,11 @@ + + + + + @@ -38,12 +43,12 @@ - + - + @@ -103,7 +108,7 @@ - + @@ -112,11 +117,11 @@ - + - + @@ -137,7 +142,7 @@ - + @@ -149,7 +154,7 @@ - + @@ -175,7 +180,7 @@ - + @@ -184,7 +189,7 @@ - + @@ -197,7 +202,7 @@ - + @@ -206,10 +211,79 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index d4473494fb..0585f7a655 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -112,6 +112,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, // loop over adds for (; adds_c; ++adds_c) { + Solid add_elem; // get one cut xml_comp_t add_c = adds_c; // get shape @@ -136,9 +137,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, // build a solid Trapezoid add_prism(add_pdx1,add_pdx2,add_pdy1,add_pdy2,add_pdz); - - // unite the add with the element solid - elem_final = UnionSolid("elem_final",elem_final,add_prism,tf_tmp); + add_elem = add_prism; } else if(add_shape == "Tube") { @@ -148,10 +147,11 @@ void buildPolyElement(dd4hep::DetElement &sdet, // build a solid Tube add_tube(add_rmin,add_rmax,add_half_l); - - // unite the add with the element solid - elem_final = UnionSolid("elem_final",elem_final,add_tube,tf_tmp); + add_elem = add_tube; } + + // unite the add with the element solid + elem_final = UnionSolid("elem_final",elem_final,add_elem,tf_tmp); } // get all cuts @@ -163,7 +163,9 @@ void buildPolyElement(dd4hep::DetElement &sdet, xml_comp_t cut_c = cuts_c; // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_theta = cut_pos.attr("theta"); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); // get dimentions xml_dim_t cut_dim = cut_c.child(_U(dimensions)); double cut_rmin = cut_dim.attr("rmin"); @@ -174,7 +176,7 @@ void buildPolyElement(dd4hep::DetElement &sdet, Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); Transform3D tf_tmp( - RotationZYX(0, cut_theta, 0), + RotationZYX(cut_rotX,cut_rotY,cut_rotZ), Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); // subtract the cut from the element solid elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); @@ -257,23 +259,45 @@ void buildTubeElement(dd4hep::DetElement &sdet, { // get one cut xml_comp_t cut_c = cuts_c; + // get shape + string add_shape = dd4hep::getAttrOrDefault( + cut_c, _Unicode(shape), "Tube"); // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_theta = cut_pos.attr("theta"); - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); // get rotation coordinates xml_dim_t cut_rot = cut_c.child(_U(rotation)); int cut_rot_num = cut_rot.attr("num"); double cut_rot_step = cut_rot.attr("step"); string cut_rot_axis = cut_rot.attr("axis"); - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + Solid cut_elem; + if(add_shape == "Box") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_dx = cut_dim.attr("dx"); + double cut_dy = cut_dim.attr("dy"); + double cut_dz = cut_dim.attr("dz"); + // build a solid + Box cut_box(cut_dx,cut_dy,cut_dz); + cut_elem = cut_box; + } + else if(add_shape == "Tube") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + cut_elem = cut_tube; + } // loop over rot steps for(int i = 0; i < cut_rot_num; i++) { @@ -285,9 +309,9 @@ void buildTubeElement(dd4hep::DetElement &sdet, else {rot_tmp = RotationZ(ang_tmp);} pos_tmp = rot_tmp * pos_tmp; - Transform3D tf_tmp(RotationZYX(0, cut_theta, 0),pos_tmp); + Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); + elem_final = SubtractionSolid("elem_final",elem_final,cut_elem,tf_tmp); } } @@ -362,7 +386,7 @@ DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) */ -/* from compact/far_forward/ion_beamline.xml +/* from compact/far_forward/electron_beamline.xml From 10d7534cbc1c7a3b8f761cdbe62811a6acb20f6a Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 14:25:39 -0400 Subject: [PATCH 38/79] Added Q1BpF --- compact/far_forward/ion_beamline.xml | 101 +++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 1683361b0e..50acf17efc 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -18,6 +18,11 @@ + + + + + @@ -284,8 +289,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 29dc09300140bc54bbd277c53e841a5870682aa0 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 14:36:29 -0400 Subject: [PATCH 39/79] Added Q1eF --- compact/far_forward/electron_beamline.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index b2b0fec264..5c1d820015 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -4,12 +4,18 @@ - - + + + + + + + + @@ -85,8 +91,16 @@ + + + + + + + + From 3fa32dae35f2acf51a0c117cd73d789bd99a6ac4 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 16:18:31 -0400 Subject: [PATCH 40/79] Added Q2pF yoke --- compact/far_forward/ion_beamline.xml | 67 +++++++++++++++++++++------- src/CylindricalDipoleMagnet_geo.cpp | 3 +- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 50acf17efc..1e8ddccb37 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -23,6 +23,11 @@ + + + + + @@ -50,12 +55,12 @@ - + - + @@ -161,7 +166,7 @@ - + @@ -230,27 +235,27 @@ - + - + - + - + - + @@ -259,12 +264,12 @@ - + - + @@ -299,27 +304,27 @@ - + - + - + - + - + @@ -328,12 +333,12 @@ - + - + @@ -366,7 +371,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 0585f7a655..5b980ae87e 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -271,6 +271,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, xml_dim_t cut_rot = cut_c.child(_U(rotation)); int cut_rot_num = cut_rot.attr("num"); double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); string cut_rot_axis = cut_rot.attr("axis"); Solid cut_elem; @@ -302,7 +303,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, for(int i = 0; i < cut_rot_num; i++) { Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = i * cut_rot_step; + double ang_tmp = cut_rot_start + i * cut_rot_step; Rotation3D rot_tmp; if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} From dbf38c138ff05a377b064bf43351ceb099b1b3b2 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 6 Jun 2025 16:26:48 -0400 Subject: [PATCH 41/79] Added Q2pF yoke (more holes) --- compact/far_forward/ion_beamline.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 1e8ddccb37..33eca49fbc 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -398,7 +398,11 @@ - + + + + + From 2d9e648fd8b37cc98e95cae6fc6561eda5081985 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 05:52:46 -0400 Subject: [PATCH 42/79] Added Q2pF --- compact/far_forward/ion_beamline.xml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 33eca49fbc..236f4ccccb 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -404,6 +404,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8db96092afa33b40fc2b7056ac500baa26708989 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 07:05:16 -0400 Subject: [PATCH 43/79] Added B1pF --- compact/far_forward/ion_beamline.xml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 236f4ccccb..9dc422fdd4 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -28,6 +28,11 @@ + + + + + @@ -440,6 +445,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f515ddf895387dce774f44fd15125277a436a074 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Sat, 7 Jun 2025 08:34:22 -0400 Subject: [PATCH 44/79] Fixed rotation around Y --- compact/far_forward/ion_beamline.xml | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9dc422fdd4..5ab37a57a5 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -12,27 +12,27 @@ - + - + - + - + - + @@ -169,7 +169,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -217,7 +217,7 @@ - + @@ -226,7 +226,7 @@ - + @@ -238,7 +238,7 @@ - + @@ -282,7 +282,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -307,7 +307,7 @@ - + @@ -351,7 +351,7 @@ - + @@ -360,7 +360,7 @@ - + @@ -369,11 +369,11 @@ - + - + @@ -384,7 +384,7 @@ - + @@ -453,7 +453,7 @@ - + From 2137085e04700e0e309908bf6ef30405b9d643fd Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 9 Jun 2025 17:51:50 -0400 Subject: [PATCH 45/79] Added B1ApF (full) and Q1ApR (yoke) --- compact/definitions.xml | 5 + .../beamline_extension_hadron.xml | 21 +++ compact/far_forward/ion_beamline.xml | 140 +++++++++++++++++- src/CylindricalDipoleMagnet_geo.cpp | 14 ++ 4 files changed, 177 insertions(+), 3 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index a684281bc4..6ec74e8689 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -319,6 +319,11 @@ The unused IDs below are saved for future use. + + #### (200-210) Far Backward Beamline Magnets + + + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 7b9b4a6250..664f7a4276 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -8,11 +8,32 @@ Implemented to allow overlap checks with the far backwards systems + + + + + + + + Hadron side beam magnet volumes + + + + + + + + + + + + + - + + + + + + @@ -484,7 +489,7 @@ - + @@ -492,9 +497,138 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 5b980ae87e..6cd8b95995 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -299,6 +299,20 @@ void buildTubeElement(dd4hep::DetElement &sdet, Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); cut_elem = cut_tube; } + else if(add_shape == "Cone") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); + cut_elem = cut_cone; + } // loop over rot steps for(int i = 0; i < cut_rot_num; i++) { From 25b02d3f4a0c04e771c49508c65eb6a4a9e1ab75 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 9 Jun 2025 22:31:38 -0400 Subject: [PATCH 46/79] Added Q1ApR coils --- .../beamline_extension_hadron.xml | 19 +++ src/CylindricalDipoleMagnet_geo.cpp | 154 +++++++----------- 2 files changed, 74 insertions(+), 99 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 664f7a4276..37e4cf6c45 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -14,6 +14,11 @@ + + + + + @@ -31,7 +36,21 @@ + + + + + + + + + + + + + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 6cd8b95995..f63ef1609d 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -219,21 +219,64 @@ void buildTubeElement(dd4hep::DetElement &sdet, // get placement coordinates xml_dim_t elem_pos = elem_c.child(_U(placement)); double elem_theta = elem_pos.attr("theta"); - // get dimentions - xml_dim_t elem_dim = elem_c.child(_U(dimensions)); - double elem_rmin = elem_dim.attr("rmin"); - double elem_rmax = elem_dim.attr("rmax"); - double elem_half_l = elem_dim.attr("half_length"); - double elem_sphi = elem_dim.attr("sphi"); - double elem_dphi = elem_dim.attr("dphi"); // set attributes - const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + const string elem_vis = + dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); - // build solid - Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); - Solid elem_final(elem_tube); + // get shape + string elem_shape = dd4hep::getAttrOrDefault(elem_c, _Unicode(shape), "Tube"); + + Solid elem_sub; + if(elem_shape == "Cone") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + + // build a solid + Cone elem_cone(elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2); + elem_sub = elem_cone; + } + else if(elem_shape == "ConeSegment") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build a solid + ConeSegment elem_conesegment( + elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2,elem_sphi, + elem_sphi+elem_dphi); + elem_sub = elem_conesegment; + } + else if(elem_shape == "Tube") + { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin = elem_dim.attr("rmin"); + double elem_rmax = elem_dim.attr("rmax"); + double elem_half_l = elem_dim.attr("half_length"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build solid + Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); + elem_sub = elem_tube; + } + + Solid elem_final(elem_sub); // combine sub-elements if(elem_pos.hasAttr(_Unicode(phiNum))) @@ -248,7 +291,7 @@ void buildTubeElement(dd4hep::DetElement &sdet, double phi_tmp = phi_start + i * phi_step; Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); // unite sub-elements - elem_final = UnionSolid("elem_final",elem_final,elem_tube,tf_tmp); + elem_final = UnionSolid("elem_final",elem_final,elem_sub,tf_tmp); } } @@ -349,93 +392,6 @@ void buildTubeElement(dd4hep::DetElement &sdet, DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) -/* from compact/far_forward/ion_beamline.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - - -/* from compact/far_forward/electron_beamline.xml - - - - - - !--unchecked-- - - - - - - - - - - - - - - - - !--unchecked-- - - - - - - - - - - -*/ - /* from compact/far_backward/magnets.xml From bc8e45f167d760347ddf8f66eeb7ba6cba32fd97 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 12:10:55 -0400 Subject: [PATCH 47/79] Added Q1ApR --- .../beamline_extension_hadron.xml | 114 ++++++++++++++++++ compact/far_forward/ion_beamline.xml | 18 ++- src/CylindricalDipoleMagnet_geo.cpp | 66 ++++++++-- 3 files changed, 184 insertions(+), 14 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 37e4cf6c45..f3c1553483 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -41,6 +41,11 @@ + + + + + @@ -50,6 +55,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index c748bf0a1b..acf5ee1d98 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -130,6 +130,7 @@ + @@ -139,10 +140,12 @@ + + @@ -164,6 +167,7 @@ + @@ -202,6 +206,7 @@ + @@ -211,6 +216,7 @@ + @@ -224,6 +230,7 @@ + @@ -233,6 +240,7 @@ + @@ -289,6 +297,7 @@ + @@ -298,6 +307,7 @@ + @@ -358,6 +368,7 @@ + @@ -367,6 +378,7 @@ + @@ -603,17 +615,19 @@ + + - + @@ -622,10 +636,12 @@ + + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index f63ef1609d..8858c62856 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -156,30 +156,70 @@ void buildPolyElement(dd4hep::DetElement &sdet, // get all cuts xml_coll_t cuts_c(elem_c, _Unicode(cut)); + + Solid cut_final; // loop over cuts for (; cuts_c; ++cuts_c) { // get one cut - xml_comp_t cut_c = cuts_c; + xml_comp_t cut_c = cuts_c; + // get shape + string cut_shape = dd4hep::getAttrOrDefault(cut_c, _Unicode(shape), "Tube"); + // get placement coordinates xml_dim_t cut_pos = cut_c.child(_U(placement)); double cut_rotX = cut_pos.attr("rotX"); double cut_rotY = cut_pos.attr("rotY"); double cut_rotZ = cut_pos.attr("rotZ"); - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); + string cut_rot_axis = cut_rot.attr("axis"); - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + if(cut_shape == "Cone") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); + cut_final = cut_cone; + } + else if(cut_shape == "Tube") + { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); + cut_final = cut_tube; + } + + // loop over rot steps + for(int i = 0; i < cut_rot_num; i++) + { + Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); + double ang_tmp = cut_rot_start + i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} + else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} + else {rot_tmp = RotationZ(ang_tmp);} + pos_tmp = rot_tmp * pos_tmp; - Transform3D tf_tmp( - RotationZYX(cut_rotX,cut_rotY,cut_rotZ), - Position(cut_pos.x(),cut_pos.y(),cut_pos.z())); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_tube,tf_tmp); + Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final",elem_final,cut_final,tf_tmp); + } } // create volume From 094b61e244489ddc2c69e66335f87dbe511c985f Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 14:01:29 -0400 Subject: [PATCH 48/79] Added Q1BpR --- compact/definitions.xml | 1 + .../beamline_extension_hadron.xml | 111 +++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index 6ec74e8689..d4417307f6 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -323,6 +323,7 @@ The unused IDs below are saved for future use. #### (200-210) Far Backward Beamline Magnets + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index f3c1553483..2b0cf8ec21 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -18,6 +18,15 @@ + + + + + + + + + @@ -95,7 +104,7 @@ - + @@ -115,7 +124,7 @@ - + @@ -164,7 +173,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 78d9fe1d6913eb66ea07eab5191c5723e2f9be4e Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 15:00:00 -0400 Subject: [PATCH 49/79] Added Q2pR --- compact/definitions.xml | 1 + .../beamline_extension_hadron.xml | 132 +++++++++++++++++- 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index d4417307f6..78a58b7c79 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -324,6 +324,7 @@ The unused IDs below are saved for future use. + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 2b0cf8ec21..6925a3c7db 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -27,6 +27,15 @@ + + + + + + + + + @@ -266,14 +275,135 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Mon, 16 Jun 2025 16:56:57 -0400 Subject: [PATCH 50/79] Added Q1eR and Q2eR --- compact/definitions.xml | 2 + .../beamline_extension_electron.xml | 42 +++++++++++++++++++ .../beamline_extension_hadron.xml | 2 - 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index 78a58b7c79..3e13ab867a 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -325,6 +325,8 @@ The unused IDs below are saved for future use. + + ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index e1346df240..75c811fee1 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -3,11 +3,53 @@ + + + + + + + + + + + + + + + Outgoing electron beam pipes Implemented to allow overlap checks with the far backwards systems + + + + + + + + + + + + + + + + + + + + + + + + + + + Electron side extended beam pipe volumes diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 6925a3c7db..1f8f19418a 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -399,9 +399,7 @@ - - From 64b10d0509730556aff7af280c9315eba0ce0ecf Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 16 Jun 2025 17:11:37 -0400 Subject: [PATCH 51/79] Corrected visualization in XML files --- compact/display.xml | 12 +- compact/display_detailed.xml | 7 - compact/display_geoviewer.xml | 7 - .../beamline_extension_electron.xml | 8 +- .../beamline_extension_hadron.xml | 66 ++++----- compact/far_forward/electron_beamline.xml | 12 +- compact/far_forward/ion_beamline.xml | 126 +++++++++--------- src/CylindricalDipoleMagnet_geo.cpp | 40 ------ 8 files changed, 112 insertions(+), 166 deletions(-) diff --git a/compact/display.xml b/compact/display.xml index 88a2993699..80574fdbaa 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -142,12 +142,12 @@ Beam line with magnets - - - - - - + + + + + + ZDC visualization diff --git a/compact/display_detailed.xml b/compact/display_detailed.xml index 0c98e51c29..9857e2d3b4 100644 --- a/compact/display_detailed.xml +++ b/compact/display_detailed.xml @@ -114,13 +114,6 @@ - - Beam line with magnets - - - - - ZDC visualization diff --git a/compact/display_geoviewer.xml b/compact/display_geoviewer.xml index eadeee7ff1..9ea8e3750c 100644 --- a/compact/display_geoviewer.xml +++ b/compact/display_geoviewer.xml @@ -114,13 +114,6 @@ - - Beam line with magnets - - - - - ZDC visualization diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 75c811fee1..06bbfde433 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -26,11 +26,11 @@ - + - + @@ -38,11 +38,11 @@ - + - + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 1f8f19418a..97f968d361 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -46,7 +46,7 @@ - + @@ -65,15 +65,15 @@ - + - + - + @@ -93,7 +93,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -153,19 +153,19 @@ - + - + - + - + @@ -186,7 +186,7 @@ - + @@ -205,15 +205,15 @@ - + - + - + @@ -228,7 +228,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -258,7 +258,7 @@ - + @@ -273,15 +273,15 @@ - + - + - + @@ -289,7 +289,7 @@ - + @@ -303,15 +303,15 @@ - + - + - + @@ -326,7 +326,7 @@ - + @@ -341,7 +341,7 @@ - + @@ -356,7 +356,7 @@ - + @@ -371,19 +371,19 @@ - + - + - + - + @@ -406,7 +406,7 @@ + vis="MagnetVis"> diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 5c1d820015..f918763093 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -71,23 +71,23 @@ - + - + - + - + - + @@ -95,7 +95,7 @@ - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index acf5ee1d98..5fb8cecfb2 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -59,7 +59,7 @@ - + @@ -73,49 +73,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -133,7 +133,7 @@ - + @@ -148,11 +148,11 @@ - + - + @@ -174,7 +174,7 @@ - + @@ -183,23 +183,23 @@ - + - + - + - + - + @@ -209,7 +209,7 @@ - + @@ -219,11 +219,11 @@ - + - + @@ -233,7 +233,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -276,7 +276,7 @@ - + @@ -290,7 +290,7 @@ - + @@ -300,7 +300,7 @@ - + @@ -310,7 +310,7 @@ - + @@ -318,7 +318,7 @@ - + @@ -347,7 +347,7 @@ - + @@ -361,7 +361,7 @@ - + @@ -371,7 +371,7 @@ - + @@ -381,15 +381,15 @@ - + - + - + @@ -397,7 +397,7 @@ - + @@ -426,7 +426,7 @@ - + @@ -440,25 +440,25 @@ - + - + - + - + - + @@ -466,7 +466,7 @@ - + @@ -480,15 +480,15 @@ - + - + - + @@ -497,15 +497,15 @@ - + - + - + @@ -513,7 +513,7 @@ - + @@ -542,7 +542,7 @@ - + @@ -571,7 +571,7 @@ - + @@ -580,33 +580,33 @@ - + - + - + - + - + - + - + @@ -623,11 +623,11 @@ - + - + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 8858c62856..02ad2fb8de 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -431,43 +431,3 @@ void buildTubeElement(dd4hep::DetElement &sdet, } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) - -/* from compact/far_backward/magnets.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* from compact/far_backward/beamline_extension_hadron.xml - - - - - - -*/ From 86b413b7544b724d559bb822cf61a7c200139c6f Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 14:52:36 -0400 Subject: [PATCH 52/79] Minor corrections --- compact/far_forward/ion_beamline.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 5fb8cecfb2..2714842118 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -406,7 +406,7 @@ - + From 934d2ef3d2f43618f2d091f3f681e63c61092f22 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 15:32:11 -0400 Subject: [PATCH 53/79] build a single beam pipe + vacuum for the electron ring on the fwd side from the end of the center beam pipe to the end of the fwd cryostat <-- will be replaced by the realistic beam pipe model later --- compact/far_forward/electron_beamline.xml | 26 ++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index f918763093..6ed4bca964 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -33,35 +33,23 @@ - - + + - + - - - - - - - + From d911cdb3d987639d2abd37ffd39659a6b8cdb694 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 16:01:30 -0400 Subject: [PATCH 54/79] Switched from Cone to ConeSegment for the vacuum volume between the IP beam pipe and B0pF: covering in phi 280deg, instead of 260 deg to avoid overlaps with B0 cryostat and heatshield --- src/magnetVacuumFF.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/magnetVacuumFF.cpp b/src/magnetVacuumFF.cpp index 94f915bbba..be99a7aacb 100644 --- a/src/magnetVacuumFF.cpp +++ b/src/magnetVacuumFF.cpp @@ -246,8 +246,8 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * std::string piece_name = Form("GapVacuum%d", numGaps + numMagnets); - Cone specialGap(piece_name, specialGapLength / 2, 0.0, vacuumDiameterEntrance / 2, 0.0, - vacuumDiameterExit / 2); + ConeSegment specialGap(piece_name, specialGapLength / 2, 0.0, vacuumDiameterEntrance / 2, 0.0, + vacuumDiameterExit / 2, 40 * deg, (360 - 40) * deg); Volume specialGap_v(piece_name, specialGap, m_Vac); sdet.setAttributes(det, specialGap_v, x_det.regionStr(), x_det.limitsStr(), vis_name); From 96ba2fcbc5d7cff4fc7dbb88d879c07f6ea2dab2 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 16:18:07 -0400 Subject: [PATCH 55/79] Enlarged a hole in the non-IP heat shield of the B0 cryo to avoid overlaps with the hadron beam pipe --- compact/far_forward/ion_beamline.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 2714842118..68816a201f 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -144,7 +144,7 @@ - + From 5f246ed935023fba4f80711cd9c17e8e7cb8ed67 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Tue, 17 Jun 2025 17:00:22 -0400 Subject: [PATCH 56/79] Reduced inner radius for the fwd hadron beam pipe to avoid overlaps with the cryostat --- compact/far_forward/definitions.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compact/far_forward/definitions.xml b/compact/far_forward/definitions.xml index 1ad75fef5c..ceeaa1fe0d 100644 --- a/compact/far_forward/definitions.xml +++ b/compact/far_forward/definitions.xml @@ -42,9 +42,9 @@ - - - + + + From d047a5adf97af32519c9515ef85d08071c3f93d2 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 13:30:20 -0400 Subject: [PATCH 57/79] Adjusted far-fwd hadron beam pipe to avoid overlaps with the fwd cryostat --- compact/far_forward/offM_tracker.xml | 8 ++++---- src/forwardBeamPipeBrazil.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/compact/far_forward/offM_tracker.xml b/compact/far_forward/offM_tracker.xml index b3ba6d2f3f..bcaba76af4 100644 --- a/compact/far_forward/offM_tracker.xml +++ b/compact/far_forward/offM_tracker.xml @@ -30,7 +30,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -55,7 +55,7 @@ readout="ForwardOffMTrackerHits" vis="AnlRed" reflect="false"> - + @@ -80,7 +80,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -105,7 +105,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + diff --git a/src/forwardBeamPipeBrazil.cpp b/src/forwardBeamPipeBrazil.cpp index be797c9181..3a8a1bb31d 100644 --- a/src/forwardBeamPipeBrazil.cpp +++ b/src/forwardBeamPipeBrazil.cpp @@ -260,6 +260,8 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * //------------------------------------------ //begin building main volumes here //------------------------------------------ + // A box to cut out from the beam pipe to avoid overlaps with the fwd cryostat + Box cutout_for_FWD_cryo(1 * dd4hep::m, 1 * dd4hep::m, 2 * dd4hep::m); //------------------------------------------------------------------- @@ -290,6 +292,14 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * tmpAfterB1APF, neutral_exit_window_cutout, Position(160.0 * dd4hep::mm, 0.0, 0.5 * beampipe_dimensions[pieceIdx].length)); + //----------------------------------------------------------------- + // Cut on the IP side to avoid overlaps with the fwd cryostat + tmpAfterB1APF = SubtractionSolid( + tmpAfterB1APF, cutout_for_FWD_cryo, + Position(0.0, 0.0, (-beampipe_dimensions[pieceIdx].length) / 2)); + //----------------------------------------------------------------- + + Volume v_pipeAfterB1APF(Form("v_pipeAfterB1APF_%d", pieceIdx), tmpAfterB1APF, m_SS); sdet.setAttributes(det, v_pipeAfterB1APF, x_det.regionStr(), x_det.limitsStr(), vis_name); @@ -517,10 +527,21 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * SubtractionSolid final_vacuum_main_pipe( vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2251.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2551.0 - beampipe_dimensions[pieceIdx].zCenter))); final_vacuum_main_pipe = SubtractionSolid(final_vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2451.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2701.0 - beampipe_dimensions[pieceIdx].zCenter))); + + //----------------------------------------------------------------- + // Cut on the IP side to avoid overlaps with the fwd cryostat + final_vacuum_main_pipe = + SubtractionSolid(final_vacuum_main_pipe, cutout_for_FWD_cryo, + Position(0.0, 0.0, (2400.0 * dd4hep::cm - 2 * dd4hep::m - beampipe_dimensions[pieceIdx].zCenter))); + Tube pipe_for_FWD_cryo(0.0, 16.0 * dd4hep::cm, 97.0 * dd4hep::cm); + final_vacuum_main_pipe = + UnionSolid(final_vacuum_main_pipe, pipe_for_FWD_cryo, + Position(6.5 * dd4hep::cm, 0.0, (2400.0 * dd4hep::cm - 97.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); + //----------------------------------------------------------------- Volume v_vacuum_main_pipe("v_vacuum_main_pipe", final_vacuum_main_pipe, m_vac); sdet.setAttributes(det, v_vacuum_main_pipe, x_det.regionStr(), x_det.limitsStr(), "AnlBlue"); From 806582ba1e9724829d43a523fd1a3de0f190e86e Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 14:04:10 -0400 Subject: [PATCH 58/79] Adjusted far-bwd electron beam pipe to avoid overlaps with the bwd cryostat --- compact/far_backward/definitions.xml | 8 ++++---- compact/far_backward/magnets.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index c85aadb6d3..fe91ca0c5a 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -14,19 +14,19 @@ Electron magnet dimensions and positions - + - + - + - + diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index f40b521e41..a2c867d1d2 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -11,7 +11,7 @@ Date: Wed, 18 Jun 2025 14:25:20 -0400 Subject: [PATCH 59/79] Enlarged hole opening in the B0 exit window to avoid overlaps with Q0eF quad coils and support tubes Rebased --- compact/far_forward/beampipe_hadron_B0.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compact/far_forward/beampipe_hadron_B0.xml b/compact/far_forward/beampipe_hadron_B0.xml index f23e72b590..21501127d7 100644 --- a/compact/far_forward/beampipe_hadron_B0.xml +++ b/compact/far_forward/beampipe_hadron_B0.xml @@ -16,7 +16,7 @@ - + From 7c72887f6f8daa836d591657b1a50f58f3532b1b Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 18 Jun 2025 14:40:13 -0400 Subject: [PATCH 60/79] Reduced small tracker outer radius in B0 to avoid overlaps with Q0eF --- compact/far_forward/B0_tracker.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compact/far_forward/B0_tracker.xml b/compact/far_forward/B0_tracker.xml index 88ec565e7a..3d44537cb3 100644 --- a/compact/far_forward/B0_tracker.xml +++ b/compact/far_forward/B0_tracker.xml @@ -46,19 +46,19 @@ - + - + - + - + From 858e94e2097f47067472f328a45eadd34e2ea0bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 00:05:00 +0000 Subject: [PATCH 61/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/display.xml | 14 +- .../beamline_extension_hadron.xml | 64 +- compact/far_forward/ion_beamline.xml | 115 ++- src/CylindricalDipoleMagnet_geo.cpp | 781 +++++++++--------- src/forwardBeamPipeBrazil.cpp | 20 +- src/magnetVacuumFF.cpp | 2 +- 6 files changed, 469 insertions(+), 527 deletions(-) diff --git a/compact/display.xml b/compact/display.xml index 80574fdbaa..1ba062ac8c 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -141,13 +141,13 @@ Beam line with magnets - - - - - - - + + + + + + + ZDC visualization diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 97f968d361..55364a9808 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -75,8 +75,8 @@ - - + + @@ -95,8 +95,8 @@ - - + + @@ -115,8 +115,8 @@ - - + + @@ -135,8 +135,8 @@ - - + + @@ -167,10 +167,10 @@ - - - - + + + + @@ -215,8 +215,8 @@ - - + + @@ -230,8 +230,8 @@ - - + + @@ -245,8 +245,8 @@ - - + + @@ -260,8 +260,8 @@ - - + + @@ -313,8 +313,8 @@ - - + + @@ -328,8 +328,8 @@ - - + + @@ -343,8 +343,8 @@ - - + + @@ -358,8 +358,8 @@ - - + + @@ -385,10 +385,10 @@ - - - - + + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 68816a201f..de8b93b1cd 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -99,13 +99,13 @@ - - + + - - + + @@ -117,8 +117,8 @@ - - + + @@ -135,8 +135,8 @@ - - + + @@ -154,8 +154,8 @@ - - + + @@ -201,8 +201,8 @@ - - + + @@ -211,8 +211,8 @@ - - + + @@ -225,8 +225,8 @@ - - + + @@ -235,8 +235,8 @@ - - + + @@ -292,8 +292,8 @@ - - + + @@ -302,8 +302,8 @@ - - + + @@ -363,8 +363,8 @@ - - + + @@ -373,8 +373,8 @@ - - + + @@ -442,13 +442,13 @@ - - + + - - + + @@ -490,12 +490,12 @@ - - - - - - + + + + + + @@ -590,13 +590,13 @@ - - + + - - + + @@ -608,10 +608,10 @@ - - - - + + + + @@ -629,10 +629,10 @@ - - - - + + + + @@ -647,22 +647,3 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 02ad2fb8de..d0f39549ca 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -14,420 +14,381 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace ROOT::Math; -void buildTubeElement(dd4hep::DetElement &sdet, - dd4hep::Assembly &assembly, - dd4hep::Detector &dtor, - dd4hep::xml::DetElement x_det, - string element, - dd4hep::Material material); -void buildPolyElement(dd4hep::DetElement &sdet, - dd4hep::Assembly &assembly, - dd4hep::Detector &dtor, - dd4hep::xml::DetElement x_det, - string element, - dd4hep::Material material); - -static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) -{ - xml_det_t x_det = e; - int det_id = x_det.id(); - string det_name = x_det.nameStr(); - - DetElement sdet(det_name, det_id); - Assembly assembly(det_name + "_assembly"); - - // get materials - Material iron = dtor.material("Iron"); - Material nbti = dtor.material("SolenoidCoil"); - Material steel_304l = dtor.material("StainlessSteel"); - Material alum = dtor.material("Al6061T6"); - Material steel_a53 = dtor.material("StainlessSteelA53"); - - // build magnet components - buildTubeElement(sdet,assembly,dtor,x_det,"yoke",iron); - buildTubeElement(sdet,assembly,dtor,x_det,"coil",nbti); - buildTubeElement(sdet,assembly,dtor,x_det,"tube",steel_304l); - buildPolyElement(sdet,assembly,dtor,x_det,"endplate",steel_304l); - buildTubeElement(sdet,assembly,dtor,x_det,"yokeshield",steel_304l); - buildTubeElement(sdet,assembly,dtor,x_det,"heatshieldbarrel",alum); - buildPolyElement(sdet,assembly,dtor,x_det,"heatshieldend",alum); - buildTubeElement(sdet,assembly,dtor,x_det,"cryobarrel",steel_a53); - buildPolyElement(sdet,assembly,dtor,x_det,"cryoend",steel_a53); - - // final placement - auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); - pv_assembly.addPhysVolID("system", det_id); - sdet.setPlacement(pv_assembly); - - // update bounding box - assembly->GetShape()->ComputeBBox(); - - return sdet; +void buildTubeElement(dd4hep::DetElement& sdet, dd4hep::Assembly& assembly, dd4hep::Detector& dtor, + dd4hep::xml::DetElement x_det, string element, dd4hep::Material material); +void buildPolyElement(dd4hep::DetElement& sdet, dd4hep::Assembly& assembly, dd4hep::Detector& dtor, + dd4hep::xml::DetElement x_det, string element, dd4hep::Material material); + +static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) { + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + + DetElement sdet(det_name, det_id); + Assembly assembly(det_name + "_assembly"); + + // get materials + Material iron = dtor.material("Iron"); + Material nbti = dtor.material("SolenoidCoil"); + Material steel_304l = dtor.material("StainlessSteel"); + Material alum = dtor.material("Al6061T6"); + Material steel_a53 = dtor.material("StainlessSteelA53"); + + // build magnet components + buildTubeElement(sdet, assembly, dtor, x_det, "yoke", iron); + buildTubeElement(sdet, assembly, dtor, x_det, "coil", nbti); + buildTubeElement(sdet, assembly, dtor, x_det, "tube", steel_304l); + buildPolyElement(sdet, assembly, dtor, x_det, "endplate", steel_304l); + buildTubeElement(sdet, assembly, dtor, x_det, "yokeshield", steel_304l); + buildTubeElement(sdet, assembly, dtor, x_det, "heatshieldbarrel", alum); + buildPolyElement(sdet, assembly, dtor, x_det, "heatshieldend", alum); + buildTubeElement(sdet, assembly, dtor, x_det, "cryobarrel", steel_a53); + buildPolyElement(sdet, assembly, dtor, x_det, "cryoend", steel_a53); + + // final placement + auto pv_assembly = dtor.pickMotherVolume(sdet).placeVolume(assembly); + pv_assembly.addPhysVolID("system", det_id); + sdet.setPlacement(pv_assembly); + + // update bounding box + assembly->GetShape()->ComputeBBox(); + + return sdet; } -void buildPolyElement(dd4hep::DetElement &sdet, - dd4hep::Assembly &assembly, - dd4hep::Detector &dtor, - dd4hep::xml::DetElement x_det, - string element, - dd4hep::Material material) -{ - // get all elems - xml_coll_t elems_c(x_det, element.c_str()); - int elem_id = 1; - - // loop over elems - for (; elems_c; ++elems_c) - { - // get one element - xml_comp_t elem_c = elems_c; - string elem_name = elem_c.nameStr(); - // get placement coordinates - xml_dim_t elem_pos = elem_c.child(_U(placement)); - double elem_theta = elem_pos.attr("theta"); - std::vector z; - std::vector rmax; - std::vector rmin; - // loop over z-planes - xml_coll_t zplanes_c(elem_c, _Unicode(zplane)); - for (; zplanes_c; ++zplanes_c) - { - // get z-plane - xml_comp_t zplane_c = zplanes_c; - z.push_back(zplane_c.attr(_Unicode(z))); - rmin.push_back(zplane_c.attr(_Unicode(rmin))); - rmax.push_back(zplane_c.attr(_Unicode(rmax))); - } - - // set attributes - const string elem_vis = dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); - - // build solid - Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); - Solid elem_final(elem_tube); - - // get all adds - xml_coll_t adds_c(elem_c, _Unicode(add)); - // loop over adds - for (; adds_c; ++adds_c) - { - Solid add_elem; - // get one cut - xml_comp_t add_c = adds_c; - // get shape - string add_shape = add_c.attr("shape"); - // get placement coordinates - xml_dim_t add_pos = add_c.child(_U(placement)); - double add_theta = add_pos.attr("theta"); - // get dimentions - xml_dim_t add_dim = add_c.child(_U(dimensions)); - - Transform3D tf_tmp( - RotationZYX(0, add_theta, 0), - Position(add_pos.x(),add_pos.y(),add_pos.z())); - - if(add_shape == "Prism") - { - double add_pdx1 = add_dim.attr("pdx1"); - double add_pdx2 = add_dim.attr("pdx2"); - double add_pdy1 = add_dim.attr("pdy1"); - double add_pdy2 = add_dim.attr("pdy2"); - double add_pdz = add_dim.attr("pdz"); - - // build a solid - Trapezoid add_prism(add_pdx1,add_pdx2,add_pdy1,add_pdy2,add_pdz); - add_elem = add_prism; - } - else if(add_shape == "Tube") - { - double add_rmin = add_dim.attr("rmin"); - double add_rmax = add_dim.attr("rmax"); - double add_half_l = add_dim.attr("half_length"); - - // build a solid - Tube add_tube(add_rmin,add_rmax,add_half_l); - add_elem = add_tube; - } - - // unite the add with the element solid - elem_final = UnionSolid("elem_final",elem_final,add_elem,tf_tmp); - } - - // get all cuts - xml_coll_t cuts_c(elem_c, _Unicode(cut)); - - Solid cut_final; - // loop over cuts - for (; cuts_c; ++cuts_c) - { - // get one cut - xml_comp_t cut_c = cuts_c; - // get shape - string cut_shape = dd4hep::getAttrOrDefault(cut_c, _Unicode(shape), "Tube"); - - // get placement coordinates - xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_rotX = cut_pos.attr("rotX"); - double cut_rotY = cut_pos.attr("rotY"); - double cut_rotZ = cut_pos.attr("rotZ"); - // get rotation coordinates - xml_dim_t cut_rot = cut_c.child(_U(rotation)); - int cut_rot_num = cut_rot.attr("num"); - double cut_rot_step = cut_rot.attr("step"); - double cut_rot_start = cut_rot.attr("start"); - string cut_rot_axis = cut_rot.attr("axis"); - - if(cut_shape == "Cone") - { - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin1 = cut_dim.attr("rmin1"); - double cut_rmax1 = cut_dim.attr("rmax1"); - double cut_rmin2 = cut_dim.attr("rmin2"); - double cut_rmax2 = cut_dim.attr("rmax2"); - double cut_dz = cut_dim.attr("dz"); - - // build a solid - Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); - cut_final = cut_cone; - } - else if(cut_shape == "Tube") - { - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); - - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); - cut_final = cut_tube; - } - - // loop over rot steps - for(int i = 0; i < cut_rot_num; i++) - { - Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = cut_rot_start + i * cut_rot_step; - Rotation3D rot_tmp; - if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} - else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} - else {rot_tmp = RotationZ(ang_tmp);} - pos_tmp = rot_tmp * pos_tmp; - - Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_final,tf_tmp); - } - } - - // create volume - Volume elem_vol(elem_name, elem_final, material); - - // placement - auto elem_pv = assembly.placeVolume(elem_vol, - Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * - RotationY(elem_theta))); - elem_pv.addPhysVolID(element, elem_id); - DetElement elem_de(sdet, elem_name, elem_id); - elem_de.setPlacement(elem_pv); - elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); - elem_id++; - } - - return; +void buildPolyElement(dd4hep::DetElement& sdet, dd4hep::Assembly& assembly, dd4hep::Detector& dtor, + dd4hep::xml::DetElement x_det, string element, dd4hep::Material material) { + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) { + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); + // get placement coordinates + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); + std::vector z; + std::vector rmax; + std::vector rmin; + // loop over z-planes + xml_coll_t zplanes_c(elem_c, _Unicode(zplane)); + for (; zplanes_c; ++zplanes_c) { + // get z-plane + xml_comp_t zplane_c = zplanes_c; + z.push_back(zplane_c.attr(_Unicode(z))); + rmin.push_back(zplane_c.attr(_Unicode(rmin))); + rmax.push_back(zplane_c.attr(_Unicode(rmax))); + } + + // set attributes + const string elem_vis = + dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); + + // build solid + Polycone elem_tube(0, 2.0 * M_PI, rmin, rmax, z); + Solid elem_final(elem_tube); + + // get all adds + xml_coll_t adds_c(elem_c, _Unicode(add)); + // loop over adds + for (; adds_c; ++adds_c) { + Solid add_elem; + // get one cut + xml_comp_t add_c = adds_c; + // get shape + string add_shape = add_c.attr("shape"); + // get placement coordinates + xml_dim_t add_pos = add_c.child(_U(placement)); + double add_theta = add_pos.attr("theta"); + // get dimentions + xml_dim_t add_dim = add_c.child(_U(dimensions)); + + Transform3D tf_tmp(RotationZYX(0, add_theta, 0), + Position(add_pos.x(), add_pos.y(), add_pos.z())); + + if (add_shape == "Prism") { + double add_pdx1 = add_dim.attr("pdx1"); + double add_pdx2 = add_dim.attr("pdx2"); + double add_pdy1 = add_dim.attr("pdy1"); + double add_pdy2 = add_dim.attr("pdy2"); + double add_pdz = add_dim.attr("pdz"); + + // build a solid + Trapezoid add_prism(add_pdx1, add_pdx2, add_pdy1, add_pdy2, add_pdz); + add_elem = add_prism; + } else if (add_shape == "Tube") { + double add_rmin = add_dim.attr("rmin"); + double add_rmax = add_dim.attr("rmax"); + double add_half_l = add_dim.attr("half_length"); + + // build a solid + Tube add_tube(add_rmin, add_rmax, add_half_l); + add_elem = add_tube; + } + + // unite the add with the element solid + elem_final = UnionSolid("elem_final", elem_final, add_elem, tf_tmp); + } + + // get all cuts + xml_coll_t cuts_c(elem_c, _Unicode(cut)); + + Solid cut_final; + // loop over cuts + for (; cuts_c; ++cuts_c) { + // get one cut + xml_comp_t cut_c = cuts_c; + // get shape + string cut_shape = dd4hep::getAttrOrDefault(cut_c, _Unicode(shape), "Tube"); + + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); + string cut_rot_axis = cut_rot.attr("axis"); + + if (cut_shape == "Cone") { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz, cut_rmin1, cut_rmax1, cut_rmin2, cut_rmax2); + cut_final = cut_cone; + } else if (cut_shape == "Tube") { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin, cut_rmax, cut_half_l); + cut_final = cut_tube; + } + + // loop over rot steps + for (int i = 0; i < cut_rot_num; i++) { + Position pos_tmp(cut_pos.x(), cut_pos.y(), cut_pos.z()); + double ang_tmp = cut_rot_start + i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") { + rot_tmp = RotationX(ang_tmp); + } else if (cut_rot_axis == "Y") { + rot_tmp = RotationY(ang_tmp); + } else { + rot_tmp = RotationZ(ang_tmp); + } + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(cut_rotZ, cut_rotY, cut_rotX), pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final", elem_final, cut_final, tf_tmp); + } + } + + // create volume + Volume elem_vol(elem_name, elem_final, material); + + // placement + auto elem_pv = assembly.placeVolume( + elem_vol, Transform3D(Translation3D(elem_pos.x(), elem_pos.y(), elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; + } + + return; } -void buildTubeElement(dd4hep::DetElement &sdet, - dd4hep::Assembly &assembly, - dd4hep::Detector &dtor, - dd4hep::xml::DetElement x_det, - string element, - dd4hep::Material material) -{ - // get all elems - xml_coll_t elems_c(x_det, element.c_str()); - int elem_id = 1; - - // loop over elems - for (; elems_c; ++elems_c) - { - // get one element - xml_comp_t elem_c = elems_c; - string elem_name = elem_c.nameStr(); - // get placement coordinates - xml_dim_t elem_pos = elem_c.child(_U(placement)); - double elem_theta = elem_pos.attr("theta"); - - // set attributes - const string elem_vis = - dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); - sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); - - // get shape - string elem_shape = dd4hep::getAttrOrDefault(elem_c, _Unicode(shape), "Tube"); - - Solid elem_sub; - if(elem_shape == "Cone") - { - // get dimentions - xml_dim_t elem_dim = elem_c.child(_U(dimensions)); - double elem_rmin1 = elem_dim.attr("rmin1"); - double elem_rmax1 = elem_dim.attr("rmax1"); - double elem_rmin2 = elem_dim.attr("rmin2"); - double elem_rmax2 = elem_dim.attr("rmax2"); - double elem_dz = elem_dim.attr("dz"); - - // build a solid - Cone elem_cone(elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2); - elem_sub = elem_cone; - } - else if(elem_shape == "ConeSegment") - { - // get dimentions - xml_dim_t elem_dim = elem_c.child(_U(dimensions)); - double elem_rmin1 = elem_dim.attr("rmin1"); - double elem_rmax1 = elem_dim.attr("rmax1"); - double elem_rmin2 = elem_dim.attr("rmin2"); - double elem_rmax2 = elem_dim.attr("rmax2"); - double elem_dz = elem_dim.attr("dz"); - double elem_sphi = elem_dim.attr("sphi"); - double elem_dphi = elem_dim.attr("dphi"); - - // build a solid - ConeSegment elem_conesegment( - elem_dz,elem_rmin1,elem_rmax1,elem_rmin2,elem_rmax2,elem_sphi, - elem_sphi+elem_dphi); - elem_sub = elem_conesegment; - } - else if(elem_shape == "Tube") - { - // get dimentions - xml_dim_t elem_dim = elem_c.child(_U(dimensions)); - double elem_rmin = elem_dim.attr("rmin"); - double elem_rmax = elem_dim.attr("rmax"); - double elem_half_l = elem_dim.attr("half_length"); - double elem_sphi = elem_dim.attr("sphi"); - double elem_dphi = elem_dim.attr("dphi"); - - // build solid - Tube elem_tube(elem_rmin,elem_rmax,elem_half_l,elem_sphi,elem_sphi+elem_dphi); - elem_sub = elem_tube; - } - - Solid elem_final(elem_sub); - - // combine sub-elements - if(elem_pos.hasAttr(_Unicode(phiNum))) - { - int phi_num = elem_pos.attr("phiNum"); - double phi_step = elem_pos.attr("phiStep"); - double phi_start = elem_pos.attr("phiStart"); - - // loop over steps - for(int i = 0; i < phi_num; i++) - { - double phi_tmp = phi_start + i * phi_step; - Transform3D tf_tmp(RotationZ(phi_tmp),Position(0,0,0)); - // unite sub-elements - elem_final = UnionSolid("elem_final",elem_final,elem_sub,tf_tmp); - } - } - - // get all cuts - xml_coll_t cuts_c(elem_c, _Unicode(cut)); - // loop over cuts - for (; cuts_c; ++cuts_c) - { - // get one cut - xml_comp_t cut_c = cuts_c; - // get shape - string add_shape = dd4hep::getAttrOrDefault( - cut_c, _Unicode(shape), "Tube"); - // get placement coordinates - xml_dim_t cut_pos = cut_c.child(_U(placement)); - double cut_rotX = cut_pos.attr("rotX"); - double cut_rotY = cut_pos.attr("rotY"); - double cut_rotZ = cut_pos.attr("rotZ"); - // get rotation coordinates - xml_dim_t cut_rot = cut_c.child(_U(rotation)); - int cut_rot_num = cut_rot.attr("num"); - double cut_rot_step = cut_rot.attr("step"); - double cut_rot_start = cut_rot.attr("start"); - string cut_rot_axis = cut_rot.attr("axis"); - - Solid cut_elem; - if(add_shape == "Box") - { - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_dx = cut_dim.attr("dx"); - double cut_dy = cut_dim.attr("dy"); - double cut_dz = cut_dim.attr("dz"); - - // build a solid - Box cut_box(cut_dx,cut_dy,cut_dz); - cut_elem = cut_box; - } - else if(add_shape == "Tube") - { - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin = cut_dim.attr("rmin"); - double cut_rmax = cut_dim.attr("rmax"); - double cut_half_l = cut_dim.attr("half_length"); - - // build a solid - Tube cut_tube(cut_rmin,cut_rmax,cut_half_l); - cut_elem = cut_tube; - } - else if(add_shape == "Cone") - { - // get dimentions - xml_dim_t cut_dim = cut_c.child(_U(dimensions)); - double cut_rmin1 = cut_dim.attr("rmin1"); - double cut_rmax1 = cut_dim.attr("rmax1"); - double cut_rmin2 = cut_dim.attr("rmin2"); - double cut_rmax2 = cut_dim.attr("rmax2"); - double cut_dz = cut_dim.attr("dz"); - - // build a solid - Cone cut_cone(cut_dz,cut_rmin1,cut_rmax1,cut_rmin2,cut_rmax2); - cut_elem = cut_cone; - } - // loop over rot steps - for(int i = 0; i < cut_rot_num; i++) - { - Position pos_tmp(cut_pos.x(),cut_pos.y(),cut_pos.z()); - double ang_tmp = cut_rot_start + i * cut_rot_step; - Rotation3D rot_tmp; - if (cut_rot_axis == "X") {rot_tmp = RotationX(ang_tmp);} - else if (cut_rot_axis == "Y") {rot_tmp = RotationY(ang_tmp);} - else {rot_tmp = RotationZ(ang_tmp);} - pos_tmp = rot_tmp * pos_tmp; - - Transform3D tf_tmp(RotationZYX(cut_rotZ,cut_rotY,cut_rotX),pos_tmp); - // subtract the cut from the element solid - elem_final = SubtractionSolid("elem_final",elem_final,cut_elem,tf_tmp); - } - } - - // create volume - Volume elem_vol(elem_name, elem_final, material); - - // placement - auto elem_pv = assembly.placeVolume(elem_vol, - Transform3D( Translation3D(elem_pos.x(),elem_pos.y(),elem_pos.z()) * - RotationY(elem_theta))); - elem_pv.addPhysVolID(element, elem_id); - DetElement elem_de(sdet, elem_name, elem_id); - elem_de.setPlacement(elem_pv); - elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); - elem_id++; - } - - return; +void buildTubeElement(dd4hep::DetElement& sdet, dd4hep::Assembly& assembly, dd4hep::Detector& dtor, + dd4hep::xml::DetElement x_det, string element, dd4hep::Material material) { + // get all elems + xml_coll_t elems_c(x_det, element.c_str()); + int elem_id = 1; + + // loop over elems + for (; elems_c; ++elems_c) { + // get one element + xml_comp_t elem_c = elems_c; + string elem_name = elem_c.nameStr(); + // get placement coordinates + xml_dim_t elem_pos = elem_c.child(_U(placement)); + double elem_theta = elem_pos.attr("theta"); + + // set attributes + const string elem_vis = + dd4hep::getAttrOrDefault(elem_c, _Unicode(vis), "FFMagnetVis"); + sdet.setAttributes(dtor, assembly, x_det.regionStr(), x_det.limitsStr(), elem_vis); + + // get shape + string elem_shape = dd4hep::getAttrOrDefault(elem_c, _Unicode(shape), "Tube"); + + Solid elem_sub; + if (elem_shape == "Cone") { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + + // build a solid + Cone elem_cone(elem_dz, elem_rmin1, elem_rmax1, elem_rmin2, elem_rmax2); + elem_sub = elem_cone; + } else if (elem_shape == "ConeSegment") { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin1 = elem_dim.attr("rmin1"); + double elem_rmax1 = elem_dim.attr("rmax1"); + double elem_rmin2 = elem_dim.attr("rmin2"); + double elem_rmax2 = elem_dim.attr("rmax2"); + double elem_dz = elem_dim.attr("dz"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build a solid + ConeSegment elem_conesegment(elem_dz, elem_rmin1, elem_rmax1, elem_rmin2, elem_rmax2, + elem_sphi, elem_sphi + elem_dphi); + elem_sub = elem_conesegment; + } else if (elem_shape == "Tube") { + // get dimentions + xml_dim_t elem_dim = elem_c.child(_U(dimensions)); + double elem_rmin = elem_dim.attr("rmin"); + double elem_rmax = elem_dim.attr("rmax"); + double elem_half_l = elem_dim.attr("half_length"); + double elem_sphi = elem_dim.attr("sphi"); + double elem_dphi = elem_dim.attr("dphi"); + + // build solid + Tube elem_tube(elem_rmin, elem_rmax, elem_half_l, elem_sphi, elem_sphi + elem_dphi); + elem_sub = elem_tube; + } + + Solid elem_final(elem_sub); + + // combine sub-elements + if (elem_pos.hasAttr(_Unicode(phiNum))) { + int phi_num = elem_pos.attr("phiNum"); + double phi_step = elem_pos.attr("phiStep"); + double phi_start = elem_pos.attr("phiStart"); + + // loop over steps + for (int i = 0; i < phi_num; i++) { + double phi_tmp = phi_start + i * phi_step; + Transform3D tf_tmp(RotationZ(phi_tmp), Position(0, 0, 0)); + // unite sub-elements + elem_final = UnionSolid("elem_final", elem_final, elem_sub, tf_tmp); + } + } + + // get all cuts + xml_coll_t cuts_c(elem_c, _Unicode(cut)); + // loop over cuts + for (; cuts_c; ++cuts_c) { + // get one cut + xml_comp_t cut_c = cuts_c; + // get shape + string add_shape = dd4hep::getAttrOrDefault(cut_c, _Unicode(shape), "Tube"); + // get placement coordinates + xml_dim_t cut_pos = cut_c.child(_U(placement)); + double cut_rotX = cut_pos.attr("rotX"); + double cut_rotY = cut_pos.attr("rotY"); + double cut_rotZ = cut_pos.attr("rotZ"); + // get rotation coordinates + xml_dim_t cut_rot = cut_c.child(_U(rotation)); + int cut_rot_num = cut_rot.attr("num"); + double cut_rot_step = cut_rot.attr("step"); + double cut_rot_start = cut_rot.attr("start"); + string cut_rot_axis = cut_rot.attr("axis"); + + Solid cut_elem; + if (add_shape == "Box") { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_dx = cut_dim.attr("dx"); + double cut_dy = cut_dim.attr("dy"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Box cut_box(cut_dx, cut_dy, cut_dz); + cut_elem = cut_box; + } else if (add_shape == "Tube") { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin = cut_dim.attr("rmin"); + double cut_rmax = cut_dim.attr("rmax"); + double cut_half_l = cut_dim.attr("half_length"); + + // build a solid + Tube cut_tube(cut_rmin, cut_rmax, cut_half_l); + cut_elem = cut_tube; + } else if (add_shape == "Cone") { + // get dimentions + xml_dim_t cut_dim = cut_c.child(_U(dimensions)); + double cut_rmin1 = cut_dim.attr("rmin1"); + double cut_rmax1 = cut_dim.attr("rmax1"); + double cut_rmin2 = cut_dim.attr("rmin2"); + double cut_rmax2 = cut_dim.attr("rmax2"); + double cut_dz = cut_dim.attr("dz"); + + // build a solid + Cone cut_cone(cut_dz, cut_rmin1, cut_rmax1, cut_rmin2, cut_rmax2); + cut_elem = cut_cone; + } + // loop over rot steps + for (int i = 0; i < cut_rot_num; i++) { + Position pos_tmp(cut_pos.x(), cut_pos.y(), cut_pos.z()); + double ang_tmp = cut_rot_start + i * cut_rot_step; + Rotation3D rot_tmp; + if (cut_rot_axis == "X") { + rot_tmp = RotationX(ang_tmp); + } else if (cut_rot_axis == "Y") { + rot_tmp = RotationY(ang_tmp); + } else { + rot_tmp = RotationZ(ang_tmp); + } + pos_tmp = rot_tmp * pos_tmp; + + Transform3D tf_tmp(RotationZYX(cut_rotZ, cut_rotY, cut_rotX), pos_tmp); + // subtract the cut from the element solid + elem_final = SubtractionSolid("elem_final", elem_final, cut_elem, tf_tmp); + } + } + + // create volume + Volume elem_vol(elem_name, elem_final, material); + + // placement + auto elem_pv = assembly.placeVolume( + elem_vol, Transform3D(Translation3D(elem_pos.x(), elem_pos.y(), elem_pos.z()) * + RotationY(elem_theta))); + elem_pv.addPhysVolID(element, elem_id); + DetElement elem_de(sdet, elem_name, elem_id); + elem_de.setPlacement(elem_pv); + elem_de.setAttributes(dtor, elem_vol, x_det.regionStr(), x_det.limitsStr(), elem_vis); + elem_id++; + } + + return; } DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) diff --git a/src/forwardBeamPipeBrazil.cpp b/src/forwardBeamPipeBrazil.cpp index 3a8a1bb31d..131d79f884 100644 --- a/src/forwardBeamPipeBrazil.cpp +++ b/src/forwardBeamPipeBrazil.cpp @@ -294,12 +294,10 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * //----------------------------------------------------------------- // Cut on the IP side to avoid overlaps with the fwd cryostat - tmpAfterB1APF = SubtractionSolid( - tmpAfterB1APF, cutout_for_FWD_cryo, - Position(0.0, 0.0, (-beampipe_dimensions[pieceIdx].length) / 2)); + tmpAfterB1APF = SubtractionSolid(tmpAfterB1APF, cutout_for_FWD_cryo, + Position(0.0, 0.0, (-beampipe_dimensions[pieceIdx].length) / 2)); //----------------------------------------------------------------- - Volume v_pipeAfterB1APF(Form("v_pipeAfterB1APF_%d", pieceIdx), tmpAfterB1APF, m_SS); sdet.setAttributes(det, v_pipeAfterB1APF, x_det.regionStr(), x_det.limitsStr(), vis_name); @@ -534,13 +532,15 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * //----------------------------------------------------------------- // Cut on the IP side to avoid overlaps with the fwd cryostat - final_vacuum_main_pipe = - SubtractionSolid(final_vacuum_main_pipe, cutout_for_FWD_cryo, - Position(0.0, 0.0, (2400.0 * dd4hep::cm - 2 * dd4hep::m - beampipe_dimensions[pieceIdx].zCenter))); + final_vacuum_main_pipe = SubtractionSolid( + final_vacuum_main_pipe, cutout_for_FWD_cryo, + Position(0.0, 0.0, + (2400.0 * dd4hep::cm - 2 * dd4hep::m - beampipe_dimensions[pieceIdx].zCenter))); Tube pipe_for_FWD_cryo(0.0, 16.0 * dd4hep::cm, 97.0 * dd4hep::cm); - final_vacuum_main_pipe = - UnionSolid(final_vacuum_main_pipe, pipe_for_FWD_cryo, - Position(6.5 * dd4hep::cm, 0.0, (2400.0 * dd4hep::cm - 97.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); + final_vacuum_main_pipe = UnionSolid( + final_vacuum_main_pipe, pipe_for_FWD_cryo, + Position(6.5 * dd4hep::cm, 0.0, + (2400.0 * dd4hep::cm - 97.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); //----------------------------------------------------------------- Volume v_vacuum_main_pipe("v_vacuum_main_pipe", final_vacuum_main_pipe, m_vac); diff --git a/src/magnetVacuumFF.cpp b/src/magnetVacuumFF.cpp index be99a7aacb..ef7fd54249 100644 --- a/src/magnetVacuumFF.cpp +++ b/src/magnetVacuumFF.cpp @@ -247,7 +247,7 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * std::string piece_name = Form("GapVacuum%d", numGaps + numMagnets); ConeSegment specialGap(piece_name, specialGapLength / 2, 0.0, vacuumDiameterEntrance / 2, 0.0, - vacuumDiameterExit / 2, 40 * deg, (360 - 40) * deg); + vacuumDiameterExit / 2, 40 * deg, (360 - 40) * deg); Volume specialGap_v(piece_name, specialGap, m_Vac); sdet.setAttributes(det, specialGap_v, x_det.regionStr(), x_det.limitsStr(), vis_name); From fce470216815bc94fab0f80b526bf2ddc6cd261e Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 19 Jun 2025 08:50:54 -0400 Subject: [PATCH 62/79] Removed unnecessary magnet IDs --- compact/definitions.xml | 9 --------- compact/far_backward/beamline_extension_electron.xml | 4 ++-- compact/far_backward/beamline_extension_hadron.xml | 6 +++--- compact/far_forward/electron_beamline.xml | 4 ++-- src/CylindricalDipoleMagnet_geo.cpp | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/compact/definitions.xml b/compact/definitions.xml index 3e13ab867a..a684281bc4 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -319,15 +319,6 @@ The unused IDs below are saved for future use. - - #### (200-210) Far Backward Beamline Magnets - - - - - - - ## Detector Definition Parameters diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 06bbfde433..55542006c5 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -25,7 +25,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 97f968d361..09d0c6cce6 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -45,7 +45,7 @@ Hadron side beam magnet volumes - + @@ -185,7 +185,7 @@ - + @@ -288,7 +288,7 @@ - + diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 6ed4bca964..689f9ad65c 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -58,7 +58,7 @@ - + @@ -82,7 +82,7 @@ - + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CylindricalDipoleMagnet_geo.cpp index 02ad2fb8de..da6b5933dd 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CylindricalDipoleMagnet_geo.cpp @@ -39,7 +39,7 @@ static Ref_t build_magnet(Detector& dtor, xml_h e, SensitiveDetector /* sens */) // get materials Material iron = dtor.material("Iron"); Material nbti = dtor.material("SolenoidCoil"); - Material steel_304l = dtor.material("StainlessSteel"); + Material steel_304l = dtor.material("StainlessSteelSAE304"); Material alum = dtor.material("Al6061T6"); Material steel_a53 = dtor.material("StainlessSteelA53"); From 0cafea986ac1a5a16fd8bff83b7a8840f221084f Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 19 Jun 2025 09:02:41 -0400 Subject: [PATCH 63/79] Renamed CylindricalDipoleMagnet to CryostatMagnet class for cryostat magnets to better reflect the purpose of the class --- .../far_backward/beamline_extension_electron.xml | 4 ++-- compact/far_backward/beamline_extension_hadron.xml | 6 +++--- compact/far_forward/electron_beamline.xml | 4 ++-- compact/far_forward/ion_beamline.xml | 14 +++++++------- ...DipoleMagnet_geo.cpp => CryostatMagnet_geo.cpp} | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) rename src/{CylindricalDipoleMagnet_geo.cpp => CryostatMagnet_geo.cpp} (99%) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 55542006c5..566a32d90a 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -25,7 +25,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 9d1ec5f4e4..03a68209ba 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -45,7 +45,7 @@ Hadron side beam magnet volumes - + @@ -185,7 +185,7 @@ - + @@ -288,7 +288,7 @@ - + diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 689f9ad65c..12e30e09c3 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -58,7 +58,7 @@ - + @@ -82,7 +82,7 @@ - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index de8b93b1cd..758b755382 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -58,7 +58,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -317,7 +317,7 @@ - + @@ -396,7 +396,7 @@ - + @@ -465,7 +465,7 @@ - + @@ -512,7 +512,7 @@ - + diff --git a/src/CylindricalDipoleMagnet_geo.cpp b/src/CryostatMagnet_geo.cpp similarity index 99% rename from src/CylindricalDipoleMagnet_geo.cpp rename to src/CryostatMagnet_geo.cpp index 5de8d88341..e785cd3b7a 100644 --- a/src/CylindricalDipoleMagnet_geo.cpp +++ b/src/CryostatMagnet_geo.cpp @@ -391,4 +391,4 @@ void buildTubeElement(dd4hep::DetElement& sdet, dd4hep::Assembly& assembly, dd4h return; } -DECLARE_DETELEMENT(ip6_CylindricalDipoleMagnet, build_magnet) +DECLARE_DETELEMENT(ip6_CryostatMagnet, build_magnet) From 33f35a5a47c8d84f89d74714307574c9bc041f04 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 20 Jun 2025 16:09:30 -0400 Subject: [PATCH 64/79] enlarged BWD cryostat hole openening to avoid overlaps with outdated electron beam pipe --- .../beamline_extension_hadron.xml | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 03a68209ba..1b82f5176e 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -55,7 +55,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -103,7 +103,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -177,7 +177,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -223,7 +223,7 @@ - + @@ -238,7 +238,7 @@ - + @@ -253,7 +253,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -298,8 +298,9 @@ - - + + + @@ -311,7 +312,7 @@ - + @@ -321,12 +322,13 @@ - - + + + - + @@ -336,12 +338,12 @@ - + - + @@ -351,12 +353,13 @@ - - + + + - + @@ -366,7 +369,7 @@ - + @@ -395,8 +398,9 @@ - - + + + From f7df771d317460723d18f50fb1e179675a2cbd1d Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 23 Jun 2025 11:04:06 -0400 Subject: [PATCH 65/79] Added instructions on how to define cryostat magnet coordinates --- .../beamline_extension_electron.xml | 1 + .../beamline_extension_hadron.xml | 2 + compact/far_forward/electron_beamline.xml | 5 ++ compact/far_forward/ion_beamline.xml | 47 +++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 566a32d90a..71e35efd1d 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -21,6 +21,7 @@ Outgoing electron beam pipes Implemented to allow overlap checks with the far backwards systems + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description - the same is applied to the electron magnet elements diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 1b82f5176e..700772e029 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -6,8 +6,10 @@ Incident hadron beam pipes Implemented to allow overlap checks with the far backwards systems + See compact/far_forward/ion_beamline.xml for magnet element coordinate description + diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 12e30e09c3..369650ed07 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -3,7 +3,12 @@ + + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description - the same is applied to the electron magnet elements + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 758b755382..9adf630589 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -41,6 +41,53 @@ + + Instructions on how to obtain magnet element coordinates and dimensions. + + The reference STEP file, provided by the Superconducting Magnet Division (SMD), is available on SharePoint: + EIC Public Sharing Docs → Documents → Experimental Program → ePIC → Engineering → STR-Files → IR6_CRYOSTAT_2200m_top_4-24-2025.stp + [https://brookhavenlab.sharepoint.com/:u:/s/EICPublicSharingDocs/EdR44ODny1BEmMTTks61CCwBe8tJYMc0iWkPIYY_EjYEuw?e=2XLUEt] + + - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. + - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. + - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. + - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: + [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf?csf=1&web=1&e=7Vhl0m] + + -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). + -- Apply a rotation of 8 mrad to align with the ePIC detector axis. + + Example of how to extract coordinates from Onshape and compute the yoke's position and orientation: + + TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side + TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side + // Rotate around the Y axis by (π - 8e-3) + double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis + coord1.RotateY(angle * rad); + coord2.RotateY(angle * rad); + // Compute center + TVector3 center = 0.5 * (coord1 + coord2); + center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset + // Compute rotation angle around Y + double deltaX = coord2.X() - coord1.X(); + double deltaZ = coord2.Z() - coord1.Z(); + double rotY_angle = atan(deltaX / deltaZ) * rad; + // Threshold small angles + if (std::abs(rotY_angle) < 1e-6) { + rotY_angle = 0; + } + // Add 'center' and 'rotY_angle' to the XML file + + - Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: + + + + + + Here, 160.817560 cm is the distance between the inner surfaces of the two Q1ApF endplates (mounted on both ends of the magnet), + and 15.246221 cm is the Z-thickness of the endplate on the IP side (note the minus sign). + + ===================================== (170-177) Forward Hadron Beamline Magnets (up to B0pf) From 8758ea2b354b408ebb435b4970e2efdb68112d95 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:04:18 +0000 Subject: [PATCH 66/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/far_forward/ion_beamline.xml | 72 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9adf630589..9a64fac6d6 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -42,50 +42,50 @@ - Instructions on how to obtain magnet element coordinates and dimensions. + Instructions on how to obtain magnet element coordinates and dimensions. - The reference STEP file, provided by the Superconducting Magnet Division (SMD), is available on SharePoint: - EIC Public Sharing Docs → Documents → Experimental Program → ePIC → Engineering → STR-Files → IR6_CRYOSTAT_2200m_top_4-24-2025.stp - [https://brookhavenlab.sharepoint.com/:u:/s/EICPublicSharingDocs/EdR44ODny1BEmMTTks61CCwBe8tJYMc0iWkPIYY_EjYEuw?e=2XLUEt] + The reference STEP file, provided by the Superconducting Magnet Division (SMD), is available on SharePoint: + EIC Public Sharing Docs → Documents → Experimental Program → ePIC → Engineering → STR-Files → IR6_CRYOSTAT_2200m_top_4-24-2025.stp + [https://brookhavenlab.sharepoint.com/:u:/s/EICPublicSharingDocs/EdR44ODny1BEmMTTks61CCwBe8tJYMc0iWkPIYY_EjYEuw?e=2XLUEt] - - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. - - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. - - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. - - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: - [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf?csf=1&web=1&e=7Vhl0m] + - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. + - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. + - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. + - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: + [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf?csf=1&web=1&e=7Vhl0m] - -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). - -- Apply a rotation of 8 mrad to align with the ePIC detector axis. + -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). + -- Apply a rotation of 8 mrad to align with the ePIC detector axis. - Example of how to extract coordinates from Onshape and compute the yoke's position and orientation: + Example of how to extract coordinates from Onshape and compute the yoke's position and orientation: - TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side - TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side - // Rotate around the Y axis by (π - 8e-3) - double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis - coord1.RotateY(angle * rad); - coord2.RotateY(angle * rad); - // Compute center - TVector3 center = 0.5 * (coord1 + coord2); - center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset - // Compute rotation angle around Y - double deltaX = coord2.X() - coord1.X(); - double deltaZ = coord2.Z() - coord1.Z(); - double rotY_angle = atan(deltaX / deltaZ) * rad; - // Threshold small angles - if (std::abs(rotY_angle) < 1e-6) { - rotY_angle = 0; - } - // Add 'center' and 'rotY_angle' to the XML file + TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side + TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side + // Rotate around the Y axis by (π - 8e-3) + double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis + coord1.RotateY(angle * rad); + coord2.RotateY(angle * rad); + // Compute center + TVector3 center = 0.5 * (coord1 + coord2); + center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset + // Compute rotation angle around Y + double deltaX = coord2.X() - coord1.X(); + double deltaZ = coord2.Z() - coord1.Z(); + double rotY_angle = atan(deltaX / deltaZ) * rad; + // Threshold small angles + if (std::abs(rotY_angle) < 1e-6) { + rotY_angle = 0; + } + // Add 'center' and 'rotY_angle' to the XML file - - Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: + - Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: - - - + + + - Here, 160.817560 cm is the distance between the inner surfaces of the two Q1ApF endplates (mounted on both ends of the magnet), - and 15.246221 cm is the Z-thickness of the endplate on the IP side (note the minus sign). + Here, 160.817560 cm is the distance between the inner surfaces of the two Q1ApF endplates (mounted on both ends of the magnet), + and 15.246221 cm is the Z-thickness of the endplate on the IP side (note the minus sign). From b7154b368bd9e8f3434422cb8cfd658d630a17c5 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 23 Jun 2025 11:43:18 -0400 Subject: [PATCH 67/79] Minor corrections to the XML comments --- compact/far_forward/ion_beamline.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 9adf630589..a2f8d1f975 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -52,7 +52,7 @@ - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: - [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf?csf=1&web=1&e=7Vhl0m] + [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf] -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). -- Apply a rotation of 8 mrad to align with the ePIC detector axis. @@ -73,7 +73,7 @@ double deltaZ = coord2.Z() - coord1.Z(); double rotY_angle = atan(deltaX / deltaZ) * rad; // Threshold small angles - if (std::abs(rotY_angle) < 1e-6) { + if (1e-6 > std::abs(rotY_angle)) { rotY_angle = 0; } // Add 'center' and 'rotY_angle' to the XML file From 56410ada3ddd8c3aac4a1992f0a5424b79ad8705 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:44:54 +0000 Subject: [PATCH 68/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/far_forward/ion_beamline.xml | 46 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index dc2e2f443a..eef8196888 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -48,35 +48,35 @@ EIC Public Sharing Docs → Documents → Experimental Program → ePIC → Engineering → STR-Files → IR6_CRYOSTAT_2200m_top_4-24-2025.stp [https://brookhavenlab.sharepoint.com/:u:/s/EICPublicSharingDocs/EdR44ODny1BEmMTTks61CCwBe8tJYMc0iWkPIYY_EjYEuw?e=2XLUEt] - - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. - - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. - - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. - - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: - [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf] + - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. + - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. + - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. + - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: + [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf] -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). -- Apply a rotation of 8 mrad to align with the ePIC detector axis. Example of how to extract coordinates from Onshape and compute the yoke's position and orientation: - TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side - TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side - // Rotate around the Y axis by (π - 8e-3) - double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis - coord1.RotateY(angle * rad); - coord2.RotateY(angle * rad); - // Compute center - TVector3 center = 0.5 * (coord1 + coord2); - center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset - // Compute rotation angle around Y - double deltaX = coord2.X() - coord1.X(); - double deltaZ = coord2.Z() - coord1.Z(); - double rotY_angle = atan(deltaX / deltaZ) * rad; - // Threshold small angles - if (1e-6 > std::abs(rotY_angle)) { - rotY_angle = 0; - } - // Add 'center' and 'rotY_angle' to the XML file + TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side + TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side + // Rotate around the Y axis by (π - 8e-3) + double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis + coord1.RotateY(angle * rad); + coord2.RotateY(angle * rad); + // Compute center + TVector3 center = 0.5 * (coord1 + coord2); + center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset + // Compute rotation angle around Y + double deltaX = coord2.X() - coord1.X(); + double deltaZ = coord2.Z() - coord1.Z(); + double rotY_angle = atan(deltaX / deltaZ) * rad; + // Threshold small angles + if (1e-6 > std::abs(rotY_angle)) { + rotY_angle = 0; + } + // Add 'center' and 'rotY_angle' to the XML file - Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: From ba21e2d705ca483327e9ec62581706164e5bb798 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Wed, 25 Jun 2025 15:48:10 -0400 Subject: [PATCH 69/79] Restored previous electron outgoing beam pipe sizes (to avoid any impact on the low-Q^2 benchmarks and physics performance studies). Enlarged rear cryostat openings to avoid overlaps with the outdated electron beam pipe. --- .../beamline_extension_electron.xml | 12 ++++--- .../beamline_extension_hadron.xml | 34 ++++++++++++------- compact/far_backward/definitions.xml | 8 ++--- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 71e35efd1d..84f7124a9f 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -29,11 +29,13 @@ - + + - + + @@ -41,11 +43,13 @@ - + + - + + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 700772e029..37377a9a8e 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -58,7 +58,8 @@ - + + @@ -86,7 +87,8 @@ - + + @@ -106,7 +108,8 @@ - + + @@ -126,7 +129,8 @@ - + + @@ -146,7 +150,8 @@ - + + @@ -198,7 +203,8 @@ - + + @@ -241,7 +247,8 @@ - + + @@ -256,7 +263,8 @@ - + + @@ -271,7 +279,8 @@ - + + @@ -302,7 +311,7 @@ - + @@ -341,7 +350,8 @@ - + + @@ -402,7 +412,7 @@ - + diff --git a/compact/far_backward/definitions.xml b/compact/far_backward/definitions.xml index fe91ca0c5a..c85aadb6d3 100644 --- a/compact/far_backward/definitions.xml +++ b/compact/far_backward/definitions.xml @@ -14,19 +14,19 @@ Electron magnet dimensions and positions - + - + - + - + From 26727a74380ca5ba37949dc9c0e56339edd0af57 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 30 Jun 2025 10:23:13 -0400 Subject: [PATCH 70/79] Updated the copyright statements to include 'Andrii Natochii' --- compact/far_backward/beamline_extension_electron.xml | 2 +- compact/far_backward/beamline_extension_hadron.xml | 2 +- compact/far_forward/electron_beamline.xml | 2 +- compact/far_forward/ion_beamline.xml | 2 +- src/CryostatMagnet_geo.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 84f7124a9f..f62413e472 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -1,5 +1,5 @@ - + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 37377a9a8e..5f6dd72308 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -1,5 +1,5 @@ - + diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 369650ed07..9e6137734a 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -1,5 +1,5 @@ - + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index eef8196888..e334031a5e 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -1,5 +1,5 @@ - + diff --git a/src/CryostatMagnet_geo.cpp b/src/CryostatMagnet_geo.cpp index e785cd3b7a..42276e3746 100644 --- a/src/CryostatMagnet_geo.cpp +++ b/src/CryostatMagnet_geo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Alex Jentsch, Wouter Deconinck, Whitney Armstrong +// Copyright (C) 2022 Alex Jentsch, Wouter Deconinck, Whitney Armstrong, Andrii Natochii #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Printout.h" From 79ffe1fb708e7716fbefe793d193523c4c877ff4 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 30 Jun 2025 10:30:50 -0400 Subject: [PATCH 71/79] Removed the white space between the numbers, units and operators in the xml --- .../beamline_extension_electron.xml | 30 +- .../beamline_extension_hadron.xml | 436 ++++++------ compact/far_forward/electron_beamline.xml | 38 +- compact/far_forward/ion_beamline.xml | 650 +++++++++--------- 4 files changed, 577 insertions(+), 577 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index f62413e472..bcc8e517fb 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -6,50 +6,50 @@ - + - + - + - + Outgoing electron beam pipes Implemented to allow overlap checks with the far backwards systems - See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description - the same is applied to the electron magnet elements + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements - - - + + + - - + + - - - + + + - - + + diff --git a/compact/far_backward/beamline_extension_hadron.xml b/compact/far_backward/beamline_extension_hadron.xml index 5f6dd72308..23a4073cf0 100644 --- a/compact/far_backward/beamline_extension_hadron.xml +++ b/compact/far_backward/beamline_extension_hadron.xml @@ -12,32 +12,32 @@ - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + @@ -50,143 +50,143 @@ - + - - - + + + - - - - + + + + - - - + + + - - + + - + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - + + + - + - - + + - - + + - - - - + + + + - - - + + + - - - + + + @@ -195,106 +195,106 @@ - + - - - + + + - - - - + + + + - - - + + + - - + + - + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - + - - + + - + @@ -302,118 +302,118 @@ - + - - - + + + - - - - + + + + - - + + - + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - + + + - + - - + + - - + + - - - - + + + + - - - + + + - - - - + + + + @@ -457,24 +457,24 @@ type="BeamPipeChain" wall_thickness="2*mm"> diff --git a/compact/far_forward/electron_beamline.xml b/compact/far_forward/electron_beamline.xml index 9e6137734a..e4af388608 100644 --- a/compact/far_forward/electron_beamline.xml +++ b/compact/far_forward/electron_beamline.xml @@ -4,22 +4,22 @@ - See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description - the same is applied to the electron magnet elements + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements - - - - + + + + - - - - + + + + @@ -65,32 +65,32 @@ - - + + - - + + - - + + - + - + - - + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index e334031a5e..7d365e0f61 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -4,41 +4,41 @@ - - - - + + + + - - - - + + + + - - - - + + + + - + - + - - - - + + + + - - + + - + - - - - - + + + + + @@ -48,10 +48,10 @@ EIC Public Sharing Docs → Documents → Experimental Program → ePIC → Engineering → STR-Files → IR6_CRYOSTAT_2200m_top_4-24-2025.stp [https://brookhavenlab.sharepoint.com/:u:/s/EICPublicSharingDocs/EdR44ODny1BEmMTTks61CCwBe8tJYMc0iWkPIYY_EjYEuw?e=2XLUEt] - - The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. - - Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. - - The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. - - Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: + -The file can be opened using Onshape (www.onshape.com), a free, cloud-based CAD platform for 3D modeling and mechanical design. + -Both the forward (FWD) and backward (BWD/rear) cryostats contain multiple sub-cryostats, primarily associated with hadron magnets. + -The main components are the magnet yokes; most other elements—such as coils, support tubes, yoke shielding, heat shielding, and vessels—are positioned relative to these yokes. + -Since the STEP file provides coordinates in the RHIC coordinate system, a rotation and translation must be applied before using them in the geometry XML files. See page 19 of the following PDF from the IR Meeting on May 30, 2025: [https://brookhavenlab.sharepoint.com/:b:/r/sites/eRHIC/bnl%26slac/EIC%20IR%20Meeting%20Minutes%20%20Documents/IR-Meeting/2025/05-30-2025/EIC_CRYO_GEANT4_May2025_NATOCHII_UPDATED.pdf] -- Apply a shift of 81 cm (the offset between RHIC and EIC IP6 interaction points). @@ -59,30 +59,30 @@ Example of how to extract coordinates from Onshape and compute the yoke's position and orientation: - TVector3 coord1(-47.389536 * cm, 0, -1704.865494 * cm); // B1pF yoke endcap — IP side - TVector3 coord2(-41.351827 * cm, 0, -2009.882603 * cm); // B1pF yoke endcap — non-IP side - // Rotate around the Y axis by (π - 8e-3) - double angle = M_PI - 8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis - coord1.RotateY(angle * rad); - coord2.RotateY(angle * rad); + TVector3 coord1(-47.389536*cm, 0, -1704.865494*cm); // B1pF yoke endcap — IP side + TVector3 coord2(-41.351827*cm, 0, -2009.882603*cm); // B1pF yoke endcap — non-IP side + // Rotate around the Y axis by (π-8e-3) + double angle = M_PI-8e-3; // π flips the Z-axis; 8e-3 rad aligns with ePIC axis + coord1.RotateY(angle*rad); + coord2.RotateY(angle*rad); // Compute center - TVector3 center = 0.5 * (coord1 + coord2); - center += TVector3(-81. * cm, 0, 0); // Apply RHIC → EIC IP6 offset + TVector3 center = 0.5*(coord1+coord2); + center += TVector3(-81.*cm, 0, 0); // Apply RHIC → EIC IP6 offset // Compute rotation angle around Y - double deltaX = coord2.X() - coord1.X(); - double deltaZ = coord2.Z() - coord1.Z(); - double rotY_angle = atan(deltaX / deltaZ) * rad; + double deltaX = coord2.X()-coord1.X(); + double deltaZ = coord2.Z()-coord1.Z(); + double rotY_angle = atan(deltaX/deltaZ)*rad; // Threshold small angles if (1e-6 > std::abs(rotY_angle)) { rotY_angle = 0; } // Add 'center' and 'rotY_angle' to the XML file - - Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: + -Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: - - + + Here, 160.817560 cm is the distance between the inner surfaces of the two Q1ApF endplates (mounted on both ends of the magnet), and 15.246221 cm is the Z-thickness of the endplate on the IP side (note the minus sign). @@ -108,113 +108,113 @@ - + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - + - + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + @@ -223,71 +223,71 @@ - + - - - + + + - - + + - - + + - + - + - - + + - - - + + + - - + + - - - + + + - + - - + + - - - + + + - - + + - - - + + + @@ -296,70 +296,70 @@ - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - + @@ -367,78 +367,78 @@ - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - + - - + + - - + + @@ -446,68 +446,68 @@ - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - + - + - - + + @@ -515,180 +515,180 @@ - + - - - + + + - - - + + + - - + + - + - - - - - - + + + + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - + - + - - + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - - + + + - - + + - - - - + + + + - - - + + + - - - + + + From 5daaae8ea1ae3e7580f4c0b7a462d1880e6e8d77 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Mon, 30 Jun 2025 19:16:09 -0400 Subject: [PATCH 72/79] Moved cryo magnets from far_backwardbeamline_extension_e/h.xml to far_backward/magnets.xml --- .../beamline_extension_electron.xml | 48 -- .../beamline_extension_hadron.xml | 408 ---------------- compact/far_backward/magnets.xml | 453 ++++++++++++++++++ 3 files changed, 453 insertions(+), 456 deletions(-) diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index bcc8e517fb..d3542c26da 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -3,60 +3,12 @@ - - - - - - - - - - - - - - - Outgoing electron beam pipes Implemented to allow overlap checks with the far backwards systems - See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Electron side extended beam pipe volumes Incident hadron beam pipes Implemented to allow overlap checks with the far backwards systems - See compact/far_forward/ion_beamline.xml for magnet element coordinate description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hadron side beam magnet volumes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hadron side beam pipe volumes + + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Electron side magnets + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Electron side beam pipe volumes @@ -55,6 +133,381 @@ + + Hadron side magnets + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 926457693374c5ce84200cd94c62fea6369cb4c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 23:17:44 +0000 Subject: [PATCH 73/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/far_backward/magnets.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index 1ef6d32d59..dfb1e42f16 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -3,9 +3,9 @@ - - See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements - + + See compact/far_forward/ion_beamline.xml for hadron magnet element coordinate description-the same is applied to the electron magnet elements + From 4fc2de9c34d661e14c44b11786a76aa28d15b57f Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Thu, 3 Jul 2025 17:03:33 -0400 Subject: [PATCH 74/79] Enlarged radius for hadron ring endplates to avoid overlaps with a beam pipe (acceptance for far-fwd detectors) --- compact/far_forward/definitions.xml | 6 +- compact/far_forward/ion_beamline.xml | 94 +++++++++++++++------------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/compact/far_forward/definitions.xml b/compact/far_forward/definitions.xml index ceeaa1fe0d..1ad75fef5c 100644 --- a/compact/far_forward/definitions.xml +++ b/compact/far_forward/definitions.xml @@ -42,9 +42,9 @@ - - - + + + diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index 7d365e0f61..a41ba261bc 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -81,8 +81,8 @@ -Some barrel elements (e.g., heat shield, vessel) and endplates are described using polygons with two or more Z-planes. Example: - - + + Here, 160.817560 cm is the distance between the inner surfaces of the two Q1ApF endplates (mounted on both ends of the magnet), and 15.246221 cm is the Z-thickness of the endplate on the IP side (note the minus sign). @@ -248,8 +248,8 @@ - - + + @@ -258,8 +258,8 @@ - - + + @@ -339,8 +339,8 @@ - - + + @@ -349,8 +349,8 @@ - - + + @@ -410,8 +410,8 @@ - - + + @@ -420,8 +420,10 @@ - - + + + + @@ -434,11 +436,11 @@ - + - + @@ -490,12 +492,12 @@ - + - + @@ -507,7 +509,7 @@ - + @@ -529,20 +531,26 @@ - + + - + + - - - - - - + + + + + + + + + + @@ -550,11 +558,11 @@ - + - + @@ -637,13 +645,13 @@ - - + + - - + + @@ -651,14 +659,14 @@ - + - - - - + + + + @@ -672,14 +680,14 @@ - + - - - - + + + + From 0613861881d5c757335317ab43b3f607c29f9faf Mon Sep 17 00:00:00 2001 From: Alexander Jentsch Date: Thu, 3 Jul 2025 17:30:29 -0400 Subject: [PATCH 75/79] add some missing units in the HSR beamline --- compact/far_forward/ion_beamline.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compact/far_forward/ion_beamline.xml b/compact/far_forward/ion_beamline.xml index a41ba261bc..8fea2e790c 100644 --- a/compact/far_forward/ion_beamline.xml +++ b/compact/far_forward/ion_beamline.xml @@ -19,9 +19,9 @@ - + - + @@ -31,7 +31,7 @@ - + From 795b58eacbce0fc902ef7e050f115ca22aa7ea0f Mon Sep 17 00:00:00 2001 From: Alexander Jentsch Date: Thu, 3 Jul 2025 17:34:46 -0400 Subject: [PATCH 76/79] shift OMD in x-direction to account for shift in z --- compact/far_forward/offM_tracker.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compact/far_forward/offM_tracker.xml b/compact/far_forward/offM_tracker.xml index bcaba76af4..c9547adc78 100644 --- a/compact/far_forward/offM_tracker.xml +++ b/compact/far_forward/offM_tracker.xml @@ -30,7 +30,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -55,7 +55,7 @@ readout="ForwardOffMTrackerHits" vis="AnlRed" reflect="false"> - + @@ -80,7 +80,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -105,7 +105,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + From 0f6ab126b2b94b95b4cfc4d0903c5dbd3291d5d9 Mon Sep 17 00:00:00 2001 From: Andrii Natochii Date: Fri, 4 Jul 2025 00:35:03 -0400 Subject: [PATCH 77/79] Added missing units and fixed old typos --- compact/far_backward/magnets.xml | 8 ++++---- compact/far_forward/vacuum.xml | 16 ++++++++-------- src/forwardBeamPipeBrazil.cpp | 4 ++-- src/magnetVacuumFF.cpp | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compact/far_backward/magnets.xml b/compact/far_backward/magnets.xml index dfb1e42f16..6976fa2d4d 100644 --- a/compact/far_backward/magnets.xml +++ b/compact/far_backward/magnets.xml @@ -10,15 +10,15 @@ - + - + - + - + diff --git a/compact/far_forward/vacuum.xml b/compact/far_forward/vacuum.xml index ad5c8acab7..15b2688ca6 100644 --- a/compact/far_forward/vacuum.xml +++ b/compact/far_forward/vacuum.xml @@ -14,49 +14,49 @@ - + - + - + - + - + - + - + - + diff --git a/src/forwardBeamPipeBrazil.cpp b/src/forwardBeamPipeBrazil.cpp index 131d79f884..7f7cb0fb59 100644 --- a/src/forwardBeamPipeBrazil.cpp +++ b/src/forwardBeamPipeBrazil.cpp @@ -525,10 +525,10 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * SubtractionSolid final_vacuum_main_pipe( vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2551.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2551.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); final_vacuum_main_pipe = SubtractionSolid(final_vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2701.0 - beampipe_dimensions[pieceIdx].zCenter))); + Position(0.0, 0.0, (2701.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); //----------------------------------------------------------------- // Cut on the IP side to avoid overlaps with the fwd cryostat diff --git a/src/magnetVacuumFF.cpp b/src/magnetVacuumFF.cpp index ef7fd54249..220285b401 100644 --- a/src/magnetVacuumFF.cpp +++ b/src/magnetVacuumFF.cpp @@ -88,8 +88,8 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * double pos_theta = pos.attr(_U(theta)); xml_dim_t dims = c.child(_U(dimensions)); //dimensions(); double dim_z = dims.z(); - xml_dim_t apperture = c.child(_Unicode(apperture)); - double app_r = apperture.r(); + xml_dim_t aperture = c.child(_Unicode(aperture)); + double app_r = aperture.r(); radii_magnet.push_back(app_r); // cm lengths_magnet.push_back(dim_z); //cm From 50b65d5c470d5d1e29d9f1e60304d7746f2e5b46 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 04:35:12 +0000 Subject: [PATCH 78/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/forwardBeamPipeBrazil.cpp | 6 +++--- src/magnetVacuumFF.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/forwardBeamPipeBrazil.cpp b/src/forwardBeamPipeBrazil.cpp index 7f7cb0fb59..3e02e587ef 100644 --- a/src/forwardBeamPipeBrazil.cpp +++ b/src/forwardBeamPipeBrazil.cpp @@ -526,9 +526,9 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * SubtractionSolid final_vacuum_main_pipe( vacuum_main_pipe, cutout_for_OMD_station, Position(0.0, 0.0, (2551.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); - final_vacuum_main_pipe = - SubtractionSolid(final_vacuum_main_pipe, cutout_for_OMD_station, - Position(0.0, 0.0, (2701.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); + final_vacuum_main_pipe = SubtractionSolid( + final_vacuum_main_pipe, cutout_for_OMD_station, + Position(0.0, 0.0, (2701.0 * dd4hep::cm - beampipe_dimensions[pieceIdx].zCenter))); //----------------------------------------------------------------- // Cut on the IP side to avoid overlaps with the fwd cryostat diff --git a/src/magnetVacuumFF.cpp b/src/magnetVacuumFF.cpp index 220285b401..2f26763206 100644 --- a/src/magnetVacuumFF.cpp +++ b/src/magnetVacuumFF.cpp @@ -81,15 +81,15 @@ static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens * for (xml_coll_t c(x_det, _U(element)); c; ++c) { - xml_dim_t pos = c.child(_U(placement)); - double pos_x = pos.x(); - double pos_y = pos.y(); - double pos_z = pos.z(); - double pos_theta = pos.attr(_U(theta)); - xml_dim_t dims = c.child(_U(dimensions)); //dimensions(); - double dim_z = dims.z(); - xml_dim_t aperture = c.child(_Unicode(aperture)); - double app_r = aperture.r(); + xml_dim_t pos = c.child(_U(placement)); + double pos_x = pos.x(); + double pos_y = pos.y(); + double pos_z = pos.z(); + double pos_theta = pos.attr(_U(theta)); + xml_dim_t dims = c.child(_U(dimensions)); //dimensions(); + double dim_z = dims.z(); + xml_dim_t aperture = c.child(_Unicode(aperture)); + double app_r = aperture.r(); radii_magnet.push_back(app_r); // cm lengths_magnet.push_back(dim_z); //cm From 090fe4edd28089d2fd1435494b180bc72d495c31 Mon Sep 17 00:00:00 2001 From: Alexander Jentsch Date: Mon, 7 Jul 2025 15:51:46 -0400 Subject: [PATCH 79/79] adjust x positions of OMD to properly center on OMD protons --- compact/far_forward/offM_tracker.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compact/far_forward/offM_tracker.xml b/compact/far_forward/offM_tracker.xml index c9547adc78..d2fe86676e 100644 --- a/compact/far_forward/offM_tracker.xml +++ b/compact/far_forward/offM_tracker.xml @@ -30,7 +30,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -55,7 +55,7 @@ readout="ForwardOffMTrackerHits" vis="AnlRed" reflect="false"> - + @@ -80,7 +80,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - + @@ -105,7 +105,7 @@ readout="ForwardOffMTrackerHits" vis="FFTrackerVis" reflect="false"> - +