From 976b05f1ddf6a7381edf71daa7082e3cec7c3099 Mon Sep 17 00:00:00 2001 From: Whitney Armstrong <warmstrong@anl.gov> Date: Fri, 13 Aug 2021 23:36:56 +0000 Subject: [PATCH] Optional frame for BarrelTrackerWithFrame --- compact/vertex_tracker.xml | 43 +++++++----------- src/BarrelTrackerWithFrame_geo.cpp | 73 ++++++++++++++++++------------ src/TrapEndcapTracker_geo.cpp | 1 - 3 files changed, 61 insertions(+), 56 deletions(-) diff --git a/compact/vertex_tracker.xml b/compact/vertex_tracker.xml index 60ccaa20..81aee020 100644 --- a/compact/vertex_tracker.xml +++ b/compact/vertex_tracker.xml @@ -38,15 +38,21 @@ Simple carbon fiber support shell. <constant name="VertexBarrelMod2_rmin" value="5.7*cm"/> <constant name="VertexBarrelLayer_rmin1" value="VertexBarrelMod1_rmin - VertexBarrelLayer_thickness/2.0"/> <constant name="VertexBarrelLayer_rmin2" value="VertexBarrelMod2_rmin - VertexBarrelLayer_thickness/2.0"/> - - <constant name="VertexBarrelLayer_offset" value="VertexBarrelLayer_rmin2-VertexBarrelLayer_rmin1"/> <constant name="VertexBarrelLayer_rmax1" value="VertexBarrelLayer_rmin1 + VertexBarrelLayer_thickness"/> <constant name="VertexBarrelLayer_rmax2" value="VertexBarrelLayer_rmin2 + VertexBarrelLayer_thickness"/> - <constant name="VertexBarrelShell_rmin" value="VertexBarrelLayer_rmin2+VertexBarrelLayer_offset"/> + <comment> + "Support" is to "shell" like "layer" is to "module", and is need for the flat stave barrel implementation. + </comment> + <constant name="VertexBarrelShell_rmin" value="10.0*cm"/> <constant name="VertexBarrelShell_thickness" value="300*um"/> <constant name="VertexBarrelShell_rmax" value="VertexBarrelShell_rmin + VertexBarrelShell_thickness"/> - <constant name="VertexBarrelShell_length" value="VertexBarrel_length"/> + <constant name="VertexBarrelShell_length" value="VertexBarrelLayer_length-VertexBarrelShell_thickness"/> + + <constant name="VertexBarrelSupport_thickness" value="1.0*cm"/> + <constant name="VertexBarrelSupport_rmin" value="VertexBarrelShell_rmin-VertexBarrelSupport_thickness/2.0"/> + <constant name="VertexBarrelSupport_rmax" value="VertexBarrelSupport_rmin + VertexBarrelSupport_thickness"/> + <constant name="VertexBarrelSupport_length" value="VertexBarrelLayer_length"/> <constant name="VertexTrackerEndcapN_zmin" value="VertexTrackerBarrel_zmax"/> <constant name="VertexTrackerEndcapP_zmin" value="VertexTrackerBarrel_zmax"/> @@ -68,7 +74,7 @@ Simple carbon fiber support shell. <constant name="VertexBarrelStave_count" value="128"/> <constant name="VertexBarrelStave1_width" value="2*VertexBarrelMod1_rmin * tan(180*degree/VertexBarrelStave_count)"/> <constant name="VertexBarrelStave2_width" value="2*VertexBarrelMod2_rmin * tan(180*degree/VertexBarrelStave_count)"/> - <constant name="VertexBarrelShellStave_width" value="2*VertexBarrelShell_rmin * tan(180*degree/VertexBarrelStave_count)"/> + <constant name="VertexBarrelShellStave_width" value="2*VertexBarrelShell_rmin * tan(180*degree/VertexBarrelStave_count)"/> </define> <display> @@ -83,15 +89,10 @@ Simple carbon fiber support shell. insideTrackingVolume="true"> <dimensions rmin="VertexBarrelLayer_rmin1" - rmax="VertexBarrelShell_rmax+0.2*cm" - length="VertexBarrelLayer_length" /> + rmax="VertexBarrelSupport_rmax" + length="VertexBarrel_length" /> <comment>Vertex Barrel Modules</comment> <module name="Module1" vis="VertexLayerVis"> - <frame material="Air" vis="InvisibleNoDaughters" - width="VertexBarrelStave1_width" - length="VertexBarrelMod_length" - height="1*mm" - thickness="0.1*um" /> <module_component name="ITS3" material="Silicon" sensitive="true" @@ -101,11 +102,6 @@ Simple carbon fiber support shell. vis="VertexLayerVis" /> </module> <module name="Module2" vis="VertexLayerVis"> - <frame material="Air" vis="InvisibleNoDaughters" - width="VertexBarrelStave2_width" - length="VertexBarrelMod_length" - height="1*mm" - thickness="0.1*um" /> <module_component name="ITS3" material="Silicon" sensitive="true" @@ -115,16 +111,11 @@ Simple carbon fiber support shell. vis="VertexLayerVis" /> </module> <module name="SupportShell" vis="VertexSupportVis"> - <frame material="Air" vis="InvisibleNoDaughters" - width="VertexBarrelShellStave_width" - length="VertexBarrelMod_length" - height="1*mm" - thickness="0.1*um" /> <module_component name="CF Shell" material="CarbonFiber" sensitive="true" width="VertexBarrelShellStave_width" - length="VertexBarrelMod_length" + length="VertexBarrelShell_length" thickness="VertexBarrelShell_thickness" vis="VertexLayerVis" /> </module> @@ -157,9 +148,9 @@ Simple carbon fiber support shell. </layer> <layer module="SupportShell" id="3" vis="VertexSupportVis"> <barrel_envelope - inner_r="VertexBarrelShell_rmin" - outer_r="VertexBarrelShell_rmax" - z_length="VertexBarrelShell_length" /> + inner_r="VertexBarrelSupport_rmin" + outer_r="VertexBarrelSupport_rmax" + z_length="VertexBarrelSupport_length" /> <rphi_layout phi_tilt="0.0*degree" nphi="VertexBarrelStave_count" phi0="0.0" rc="VertexBarrelShell_rmin" dr="0.0 * mm"/> <z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/> </layer> diff --git a/src/BarrelTrackerWithFrame_geo.cpp b/src/BarrelTrackerWithFrame_geo.cpp index 3109cc6f..71969284 100644 --- a/src/BarrelTrackerWithFrame_geo.cpp +++ b/src/BarrelTrackerWithFrame_geo.cpp @@ -1,6 +1,7 @@ /** \addtogroup VertexTracker Vertex Trackers * \brief Type: **SiVertexBarrel**. * \author W. Armstrong + * * \ingroup trackers * * @@ -27,7 +28,15 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace dd4hep::detail; -static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) { + +/** Barrel Tracker with space frame. + * + * - Optional "frame" tag within the module element. + * - Optional "support" tag within the detector element. + * + * + */ +static Ref_t create_BarrelTrackerWithFrame(Detector& description, xml_h e, SensitiveDetector sens) { typedef vector<PlacedVolume> Placements; xml_det_t x_det = e; Material air = description.air(); @@ -38,7 +47,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s map<string, Volume> volumes; map<string, Placements> sensitives; map<string, std::vector<VolPlane>> volplane_surfaces; - map<string, xml_h> xmleles; + //map<string, xml_h> xmleles; PlacedVolume pv; dd4hep::xml::Dimension dimensions(x_det.dimensions()); @@ -85,44 +94,50 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s // loop over the modules for (xml_coll_t mi(x_det, _U(module)); mi; ++mi) { xml_comp_t x_mod = mi; - xml_comp_t m_env = x_mod.child(_U(frame)); string m_nam = x_mod.nameStr(); - xmleles[m_nam] = x_mod; - - // triangular volume envelope - double frame_thickness = m_env.thickness(); - double frame_width = m_env.width(); - double frame_height = getAttrOrDefault<double>(m_env, _U(height), 5.0 * mm); - double tanth = frame_height/(frame_width/2.0); - double frame_height2 = frame_height-frame_thickness-frame_thickness/tanth; - double frame_width2 = 2.0*frame_height2/tanth; - - Trd1 moduleframe_part1(frame_width / 2, 0.001 * mm, m_env.length() / 2, - frame_height / 2); - Trd1 moduleframe_part2(frame_width2/2, 0.001 * mm, - m_env.length() / 2 + 0.01 * mm, frame_height2/2); - SubtractionSolid moduleframe(moduleframe_part1, moduleframe_part2,Position(0.0,frame_thickness,0.0)); - Volume v_module(m_nam+"_vol", moduleframe, description.material(m_env.materialStr())); - v_module.setVisAttributes(description, m_env.visStr()); - - int ncomponents = 0; - int sensor_number = 1; if (volumes.find(m_nam) != volumes.end()) { - printout(ERROR, "SiTrackerBarrel", "Logics error in building modules."); + printout(ERROR, "BarrelTrackerWithFrame", string((string("Module with named ") + m_nam + string(" already exists."))).c_str() ); throw runtime_error("Logics error in building modules."); } + + int ncomponents = 0; + int sensor_number = 1; double total_thickness = 0; + + // Compute module total thickness from components xml_coll_t ci(x_mod, _U(module_component)); for (ci.reset(), total_thickness = 0.0; ci; ++ci) { total_thickness += xml_comp_t(ci).thickness(); } - // module assembly + // the module assembly volume Assembly m_vol( m_nam ); - m_vol.placeVolume(v_module, Position(0.0,0.0,frame_height/2+total_thickness/2.0)); volumes[m_nam] = m_vol; m_vol.setVisAttributes(description.visAttributes(x_mod.visStr())); + // Optional module frame. + if(x_mod.hasChild("frame")){ + xml_comp_t m_frame = x_mod.child(_U(frame)); + //xmleles[m_nam] = x_mod; + double frame_thickness = m_frame.thickness(); + double frame_width = m_frame.width(); + double frame_height = getAttrOrDefault<double>(m_frame, _U(height), 5.0 * mm); + double tanth = frame_height/(frame_width/2.0); + double frame_height2 = frame_height-frame_thickness-frame_thickness/tanth; + double frame_width2 = 2.0*frame_height2/tanth; + + Trd1 moduleframe_part1(frame_width / 2, 0.001 * mm, m_frame.length() / 2, + frame_height / 2); + Trd1 moduleframe_part2(frame_width2/2, 0.001 * mm, + m_frame.length() / 2 + 0.01 * mm, frame_height2/2); + + SubtractionSolid moduleframe(moduleframe_part1, moduleframe_part2,Position(0.0,frame_thickness,0.0)); + Volume v_moduleframe(m_nam+"_vol", moduleframe, description.material(m_frame.materialStr())); + v_moduleframe.setVisAttributes(description, m_frame.visStr()); + m_vol.placeVolume(v_moduleframe, Position(0.0, 0.0, frame_height / 2 + total_thickness / 2.0)); + } + + double thickness_so_far = 0.0; double thickness_sum = -total_thickness/2.0; for (xml_coll_t ci(x_mod, _U(module_component)); ci; ++ci, ++ncomponents) { @@ -298,6 +313,6 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s //@} // clang-format off -DECLARE_DETELEMENT(BarrelTrackerWithFrame, create_detector) -DECLARE_DETELEMENT(athena_TrackerBarrel, create_detector) -DECLARE_DETELEMENT(athena_VertexBarrel, create_detector) +DECLARE_DETELEMENT(BarrelTrackerWithFrame, create_BarrelTrackerWithFrame) +DECLARE_DETELEMENT(athena_TrackerBarrel, create_BarrelTrackerWithFrame) +DECLARE_DETELEMENT(athena_VertexBarrel, create_BarrelTrackerWithFrame) diff --git a/src/TrapEndcapTracker_geo.cpp b/src/TrapEndcapTracker_geo.cpp index 1c486dfc..cde820c6 100644 --- a/src/TrapEndcapTracker_geo.cpp +++ b/src/TrapEndcapTracker_geo.cpp @@ -41,7 +41,6 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s sens.setType("tracker"); for (xml_coll_t su(x_det, _U(support)); su; ++su) { - std::cout << "support !!!\n"; xml_comp_t x_support = su; double support_thickness = getAttrOrDefault(x_support, _U(thickness), 2.0 * mm); double support_length = getAttrOrDefault(x_support, _U(length), 2.0 * mm); -- GitLab