From 7b115d1e45da5ce92c60d56d411ca8a4c224aa9e Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Mon, 28 Oct 2024 10:56:04 -0700 Subject: [PATCH 01/12] initial implementation of curved SVT with RSU. the SubtractionSolid method has unknown offset between tube components. Will switch to part-by-part frame construction instead --- compact/tracking/vertex_barrel_curved.xml | 189 ++++++++++ src/SVTBarrelTracker_geo.cpp | 410 ++++++++++++++++++++++ 2 files changed, 599 insertions(+) create mode 100644 compact/tracking/vertex_barrel_curved.xml create mode 100644 src/SVTBarrelTracker_geo.cpp diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml new file mode 100644 index 0000000000..8e3d7cbc27 --- /dev/null +++ b/compact/tracking/vertex_barrel_curved.xml @@ -0,0 +1,189 @@ + + + + + + + Main parameters + + + + + + + + + each RSU contains four tiles (2x2), along with backbone, biasing, and readout. + The width and length (along z) are given below. modifying them without changing + the other dimensions in SVTBarrelTracker_geo.cpp may introduce inconsistency. + Tile thickness is set to be SiVertexSensor_thickness in frame. Use dummy for the total thickness calculation. + + + + + + + + + + + + ensure we are within the vertex envelope with some margin. + + + + - Currently there are 3 sensor layers. Each is composed of 2 half-cylinders modules with only + 40um of silicon thickness. + - Both support shells are 300um thick, implemented as the integrated tracker support/service + setup + + + + + + + + + + rmin are set to accommodate 12,16,and 38 RSU rows in phi + + + + + + + + + + + + + + + ### Actual detectors + + + + + The thickness of the detector volume is calculated to accommodate all components + + + Vertex Barrel Modules + + Tile components will be ignored if no frame (RSU) is provided. + An inactive si layer will be created from frame if no tiles are provided. + + + + + + + + + + + + + + Layers composed of many arrayed modules + + + + + + phi0 : Starting phi of first module in rphi plane. + zstart : starting z of the first module in z, default = barrel_start + + + + + + + + + + + + + + + + + + + + system:8,layer:4,module:12,sensor:2,x:32:-16,y:-16 + + + + \ No newline at end of file diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp new file mode 100644 index 0000000000..046ade9cbb --- /dev/null +++ b/src/SVTBarrelTracker_geo.cpp @@ -0,0 +1,410 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2022-2024 Whitney Armstrong, Nivedith Ramasubramanian, Yann Bedfer, Shujie Li + +/** \addtogroup Trackers Trackers + * \brief Type: **Curved Silicon Vertex Tracker Barrel with inactive area**. + * \author Shujie Li, Jonathan Witte + * + * + * \ingroup trackers + * + * @{ + */ +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "DD4hep/Shapes.h" +#include "DDRec/DetectorData.h" +#include "DDRec/Surface.h" +#include "XML/Layering.h" +#include "XML/Utilities.h" +#include +#include "DD4hepDetectorHelper.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::rec; +using namespace dd4hep::detail; + +#include "Math/Vector2D.h" +using ROOT::Math::XYVector; + +/** Curved Silicon Vertex Tracker Barrel with inactive area + * + * - Designed to process "mpgd_barrel.xml" ("mpgd_barrel_ver1" as of 2024/02). + * + * - Derived from "BarrelTrackerWithFrame_geo.cpp". + * + * - "support" tag not addressed. + * + * - "frame" tag within the module element. + * + * but a single XML and a single . + * + * \code + * \endcode + * + * + * @author Yann Bedfer + */ +static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDetector sens) { + xml_det_t x_det = e; + Material air = description.air(); + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + DetElement sdet(det_name, det_id); + + // vector volumes; + map volumes; + typedef vector Placements; + map sensitives; + map> volplane_surfaces; + + PlacedVolume pv; + + // Set detector type flag + dd4hep::xml::setDetectorTypeFlag(x_det, sdet); + auto& params = DD4hepDetectorHelper::ensureExtension(sdet); + + // Add the volume boundary material if configured + for (xml_coll_t bmat(x_det, _Unicode(boundary_material)); bmat; ++bmat) { + xml_comp_t x_boundary_material = bmat; + DD4hepDetectorHelper::xmlToProtoSurfaceMaterial(x_boundary_material, params, + "boundary_material"); + } + + dd4hep::xml::Dimension dimensions(x_det.dimensions()); + Assembly assembly(det_name); + sens.setType("tracker"); + double det_length = dimensions.length(); + double det_z0 = getAttrOrDefault(dimensions, _U(z0), 0.); + double det_start = det_z0 - (det_length / 2); + double det_end = det_z0 + (det_length / 2); + + // ********** MODULE + struct StaveModule { + std::string name; + Double_t rmin; + Double_t width = 0.0; + Double_t length = 0.0; + bool has_rsu = false; + Double_t uthickness = 0.0; // for the RSU + string uname; + string uvis; + string umaterial; + }; + map staveModules; + + for (xml_coll_t mi(x_det, _U(module)); mi; ++mi) { + xml_comp_t x_mod = mi; + StaveModule sM; + sM.rmin = x_mod.rmin(); + sM.name = x_mod.nameStr(); + sM.width = x_mod.width(); + sM.length = getAttrOrDefault(x_mod, _U(length), det_length); + + // read RSU dimension from frame, and save in sM + if (x_mod.hasChild(_U(frame))) { + // xml_comp_t m_frame = x_mod.child(_U(frame)); + xml_coll_t fi(x_mod, _U(frame)); + if (fi.size() > 1) { + printout(ERROR, "SVTBarrelTracker", "Number of frames = %d. Must be 0 or 1", + (int)fi.size()); + throw runtime_error("Logics error in building modules."); + } + xml_comp_t x_frame = fi; + sM.uthickness = x_frame.thickness(); + sM.has_rsu = 1; + sM.uname = x_frame.nameStr(); + sM.uvis = x_frame.visStr(); + sM.umaterial = x_frame.materialStr(); + } + if (staveModules.find(sM.name) != staveModules.end()) { + printout(ERROR, "SVTBarrelTracker: ", + string((string("staveModule with named ") + sM.name + string(" already exists."))) + .c_str()); + throw runtime_error("Logics error in building modules."); + } + staveModules[sM.name] = sM; + + // ***** TOTAL THICKNESS from components + double total_thickness = 0; + xml_coll_t ci(x_mod, _U(module_component)); + for (ci.reset(), total_thickness = 0.0; ci; ++ci) { + const xml_comp_t x_comp = ci; + double cthickness = x_comp.thickness(); + printout(DEBUG, "SVTBarrelTracker", "\"%s\": \t comp_thickness %.4f cm", + x_comp.nameStr().c_str(), cthickness / cm); + total_thickness += cthickness; + } + if(sM.has_rsu){ + total_thickness += sM.uthickness; + printout(DEBUG, "SVTBarrelTracker", "\"%s\": \t comp_thickness %.4f cm", sM.name.c_str(), + sM.uthickness / cm); + } + printout(DEBUG, "SVTBarrelTracker", " => total_thickness %.4f cm", total_thickness / cm); + + // ***** ASSEMBLY VOLUME + Assembly m_vol(sM.name); + if (volumes.find(sM.name) != volumes.end()) { + printout(ERROR, "SVTBarrelTracker: ", + string((string("Module volumes with named ") + sM.name + string(" already exists."))) + .c_str()); + throw runtime_error("Logics error in building modules."); + } + volumes[sM.name] = m_vol; + m_vol.setVisAttributes(description.visAttributes(x_mod.visStr())); + + // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing + // "|" = backbone: + // + // | ------readout-------- | -------readout-------- + // | tile | tile + // | ------biasing-------- | -------biasing-------- + // | ------biasing-------- | -------biasing-------- + // | tile | tile + // | ------readout-------- | -------readout-------- + // please keep, RSU dimensions are calculated from the number below in mm: + // const double tile_width = 9.197; + // const double tile_length = 10.773; // along the stave (z) + const double BackboneWidth = 0.06; + // const double BackboneLength = 9.782; + // const double Readout_Pads_Width = 10.773; + // const double Readout_Pads_Length = 0.525; + const double BiasingWidth = 0.06; // x2 for two sets + // const double BiasingLength = 10.773; // along the stave (z) + + // creat the total frame volume of RSU + Solid rsu_frame; + // IntersectionSolid rsu_frame; + if (sM.has_rsu) { + double dphi = sM.width / sM.rmin / 2; + rsu_frame=Tube(sM.rmin, sM.rmin + sM.uthickness, sM.length / 2, -dphi, dphi); + } + + + // ********** LOOP OVER COMPONENTS + // always put RSU at innermost surface + double comp_rmin = sM.rmin; + double thickness_so_far = 0; + if (sM.has_rsu){ + thickness_so_far+=sM.uthickness; + comp_rmin+=sM.uthickness; + } + // xml_comp_t* sensitiveComp = 0; + int sensor_number = 1; + for (xml_coll_t mci(x_mod, _U(module_component)); mci; ++mci) { + xml_comp_t x_comp = mci; + const string c_nam = x_comp.nameStr(); + double comp_thickness = x_comp.thickness(); + double comp_length = sM.length; // default value for a regular component (not a frame) + double comp_width = sM.width; // default value for a regular component (not a frame) + + double pz=0; // default: create the module at center + double rphi=0; // default: no rotation + bool is_tile = 0; + if (sM.has_rsu) { // if has a frame, use RSU size, and determine the tile offset by comp name + double rphi_temp = (0.5 * x_comp.width() + BiasingWidth*mm)/sM.rmin; //tile_width along rphi + double pz_temp = 0.5 * x_comp.length(); //tile_length along z + is_tile = 1; + if ((c_nam == "UpperRightTile")) { + rphi = rphi_temp; + pz = -pz_temp-BackboneWidth*mm; + } else if (c_nam == "UpperLeftTile") { + rphi = rphi_temp; + pz = pz_temp; + } else if (c_nam == "LowerRightTile") { + rphi = -rphi_temp; + pz = -pz_temp-BackboneWidth*mm; + } else if (c_nam == "LowerLeftTile") { + rphi = -rphi_temp; + pz = pz_temp; + } else { + is_tile=0; + } + } + RotationZYX rot(rphi, 0, 0); + Position pos(0,0,pz);// x: along R pointing out. y: along rphi, + Transform3D tr(rot, pos); + Solid c_tube; + if (is_tile) { // has frame with tiles, use RSU dimension + double dphi = x_comp.width() / sM.rmin / 2; + double phi_start = -dphi, phi_end = dphi; + c_tube = Tube(sM.rmin, sM.rmin + sM.uthickness, x_comp.length() / 2, phi_start, phi_end); + // subtract tile volume from the inactive frame + rsu_frame = SubtractionSolid(rsu_frame, c_tube, tr); + } else{ + double dphi = comp_width / sM.rmin / 2; + double phi_start = -dphi, phi_end = dphi; + c_tube=Tube(comp_rmin, comp_rmin + comp_thickness, comp_length / 2, phi_start, phi_end); + } + + Volume c_vol(c_nam, c_tube, description.material(x_comp.materialStr())); + pv = m_vol.placeVolume(c_vol, tr); + c_vol.setVisAttributes(description, x_comp.visStr()); + + if (x_comp.isSensitive()) { + // // ***** SENSITIVE VOLUME + pv.addPhysVolID("sensor", sensor_number++); + c_vol.setSensitiveDetector(sens); + sensitives[sM.name].push_back(pv); + + // -------- create a measurement plane for the tracking surface attached to the sensitive volume ----- + Vector3D u(-1., 0., 0.); + Vector3D v(0., -1., 0.); + Vector3D n(0., 0., 1.); + + // Compute the inner (i.e. thickness until mid-sensitive-volume) and + // outer (from mid-sensitive-volume to top) + // thicknesses that need to be assigned to the tracking surface + // depending on wether the support is above or below the sensor (!?) + + double inner_thickness, outer_thickness; + if (is_tile){ + inner_thickness = sM.uthickness / 2; + outer_thickness = total_thickness - inner_thickness - sM.uthickness / 2; + } else{ + inner_thickness = thickness_so_far + comp_thickness / 2; + outer_thickness = total_thickness - inner_thickness - comp_thickness / 2; + } + + SurfaceType type(SurfaceType::Sensitive); + VolPlane surf(c_vol, type, inner_thickness, outer_thickness, u, v, n); //,o ) ; + volplane_surfaces[sM.name].push_back(surf); + } + comp_rmin += comp_thickness; + thickness_so_far += comp_thickness; + } //end of module component loop + //place the frame + if (sM.has_rsu){ + Volume rsu_vol(sM.uname, rsu_frame, description.material(sM.umaterial)); + pv = m_vol.placeVolume(rsu_vol, Position(0, 0, 0)); + rsu_vol.setVisAttributes(description, sM.uvis); + } + } //end of module loop + + // ********** LAYER + // ***** RETRIEVE PARAMETERS + for (xml_coll_t li(x_det, _U(layer)); li; ++li) { + xml_comp_t x_layer = li; + int lay_id = x_layer.id(); + string m_nam = x_layer.moduleStr(); + Volume& module_vol = volumes[m_nam]; + Placements& sensVols = sensitives[m_nam]; + + xml_comp_t x_barrel = x_layer.child(_U(barrel_envelope)); + double barrel_length = x_barrel.z_length(); + double barrel_z0 = getAttrOrDefault(x_barrel, _U(z0), 0.); + // Calculate barrel ends + double barrel_start = barrel_z0 - (barrel_length / 2); + double barrel_end = barrel_z0 + (barrel_length / 2); + if (det_start > barrel_start || det_end < barrel_end) { + printout(ERROR, "SVTBarrelTracker", + "Layer #%d is outside the detector envelop\n" + "det_start < barrel_start: %.4f < %.4f\n " + "det_end > barrel_end : %.4f > %.4f\n ", + det_start, barrel_start, det_end, barrel_end); + throw runtime_error("Logics error in building modules."); + } + + // ***** LAYOUTS + xml_comp_t x_layout = x_layer.child(_U(rphi_layout)); + double phi0 = x_layout.phi0(); // Starting phi of first module. + xml_comp_t z_layout = x_layer.child(_U(z_layout)); // Get the element. + double layer_zstart = getAttrOrDefault(z_layout, _U(zstart), barrel_start); + if (barrel_start > layer_zstart) { + printout(ERROR, "SVTBarrelTracker", "Layer #%d: barrel_start>layer_zstart: %.4f > %.4f\n ", + barrel_start, layer_zstart); + throw runtime_error("Logics error in building modules."); + } + + // ********** LAYER + // ***** ENVELOPE + string lay_nam = det_name + _toString(x_layer.id(), "_layer%d"); + Tube lay_tub(x_barrel.inner_r(), x_barrel.outer_r(), barrel_length / 2); + Volume lay_vol(lay_nam, lay_tub, air); // Create the layer envelope volume. + Position lay_pos(0, 0, barrel_z0); + lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr())); + printout(DEBUG, "SVTBarrelTracker", "Layer \"%s\": rmin,max = %.2f,%.2f cm 1/2length = %.2f cm", + lay_nam.c_str(), x_barrel.inner_r(), x_barrel.outer_r(), barrel_length / 2); + + DetElement lay_elt(sdet, lay_nam, lay_id); + + // the local coordinate systems of modules in dd4hep and acts differ + // see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html + auto& layerParams = + DD4hepDetectorHelper::ensureExtension(lay_elt); + for (xml_coll_t lmat(x_layer, _Unicode(layer_material)); lmat; ++lmat) { + xml_comp_t x_layer_material = lmat; + DD4hepDetectorHelper::xmlToProtoSurfaceMaterial(x_layer_material, layerParams, + "layer_material"); + } + // ********** LOOP OVER THE SECTORS IN z and phi + auto sM = staveModules[m_nam]; + // Determine "nphi" from RSU width and radius + int nphi = int(2 * M_PI * sM.rmin / sM.width); // always round down to avoid overlap + + // ***** SECTOR POSITIONS ALONG Z + // double modz_pos[1] = {-barrel_length / 2.0}; + int nz = int((barrel_end - layer_zstart) / sM.length); + double zstart = layer_zstart; // for modules in z + double z_incr = sM.length; + double module_z = zstart + z_incr / 2; // module center in z + int nModules = 0; + + for (int iz = 0; iz < nz; iz++) { + double phi_incr = 2 * M_PI / nphi; // Phi increment for one module. + // ***** LOOP OVER THE STAVES IN phi. + int iphi; + double phic; + for (iphi = 0, phic = phi0; iphi < nphi; iphi++, phic += phi_incr, nModules++) { + double x1, y1; // Coordinates of the centre of curvature of + x1 = 0; //rc * std::cos(phic); + y1 = 0; //rc * std::sin(phic); + // int module_id = 100 * iz + iphi; + string module_name = _toString(nModules, "module%d"); + DetElement mod_elt(lay_elt, module_name, nModules); + RotationZYX rot; + rot = RotationZYX(phic, 0, 0); + Transform3D tr(rot, Position(x1, y1, module_z)); + pv = lay_vol.placeVolume(module_vol, tr); + pv.addPhysVolID("module", nModules); + mod_elt.setPlacement(pv); + + // ***** SENSITIVE COMPONENT + for (size_t ic = 0; ic < sensVols.size(); ++ic) { + PlacedVolume sens_pv = sensVols[ic]; + DetElement comp_de(mod_elt, std::string("de_") + sens_pv.volume().name(), nModules); + comp_de.setPlacement(sens_pv); + auto& comp_de_params = + DD4hepDetectorHelper::ensureExtension(comp_de); + comp_de_params.set("axis_definitions", "XYZ"); + volSurfaceList(comp_de)->push_back(volplane_surfaces[m_nam][ic]); + } + } + module_z += z_incr; + } + + // ***** CREATE THE PhysicalVolume FOR THE LAYER. + pv = assembly.placeVolume(lay_vol, lay_pos); // Place layer in mother + pv.addPhysVolID("layer", lay_id); // Set the layer ID. + lay_elt.setAttributes(description, lay_vol, x_layer.regionStr(), x_layer.limitsStr(), + x_layer.visStr()); + lay_elt.setPlacement(pv); + } + sdet.setAttributes(description, assembly, x_det.regionStr(), x_det.limitsStr(), x_det.visStr()); + assembly.setVisAttributes(description.invisible()); + pv = description.pickMotherVolume(sdet).placeVolume(assembly); + pv.addPhysVolID("system", det_id); // Set the subdetector system ID. + sdet.setPlacement(pv); + + // #ifdef DEBUG_SVTBarrelTracker + // // Reset initial print level before exiting + // setPrintLevel(priorPrintLevel); + // #endif + + return sdet; +} + +//@} +// clang-format off +DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) From 839e9f154bfe853b6ca95ef0060652748a4713b4 Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Tue, 29 Oct 2024 12:22:28 -0700 Subject: [PATCH 02/12] build the curved sensor by assembling all parts. still need to fix the segmentation for tubes --- compact/tracking/vertex_barrel_curved.xml | 69 +++++--- src/SVTBarrelTracker_geo.cpp | 184 +++++++++++++--------- 2 files changed, 155 insertions(+), 98 deletions(-) diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index 8e3d7cbc27..e81f4ae0d8 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -80,18 +80,14 @@ - Vertex Barrel Modules - + Vertex Barrel Modules + Tile components will be ignored if no frame (RSU) is provided. - An inactive si layer will be created from frame if no tiles are provided. + width and length in component will be ignored for non-tiles. - - - - + + + + + + + + Layers composed of many arrayed modules @@ -140,7 +163,7 @@ - + @@ -180,7 +203,7 @@ - + TODO: set segmentation for tube system:8,layer:4,module:12,sensor:2,x:32:-16,y:-16 diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 046ade9cbb..4465ea0d91 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -154,32 +154,15 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe volumes[sM.name] = m_vol; m_vol.setVisAttributes(description.visAttributes(x_mod.visStr())); - // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing - // "|" = backbone: - // - // | ------readout-------- | -------readout-------- - // | tile | tile - // | ------biasing-------- | -------biasing-------- - // | ------biasing-------- | -------biasing-------- - // | tile | tile - // | ------readout-------- | -------readout-------- - // please keep, RSU dimensions are calculated from the number below in mm: - // const double tile_width = 9.197; - // const double tile_length = 10.773; // along the stave (z) - const double BackboneWidth = 0.06; - // const double BackboneLength = 9.782; - // const double Readout_Pads_Width = 10.773; - // const double Readout_Pads_Length = 0.525; - const double BiasingWidth = 0.06; // x2 for two sets - // const double BiasingLength = 10.773; // along the stave (z) - - // creat the total frame volume of RSU - Solid rsu_frame; + + // creat the total RSU volume, then subtract the tiles to get frame. + // this method doesn't work well, has strange residuals + // Solid rsu_frame; // IntersectionSolid rsu_frame; - if (sM.has_rsu) { - double dphi = sM.width / sM.rmin / 2; - rsu_frame=Tube(sM.rmin, sM.rmin + sM.uthickness, sM.length / 2, -dphi, dphi); - } + // if (sM.has_rsu) { + // double dphi = sM.width / sM.rmin / 2; + // rsu_frame=Tube(sM.rmin, sM.rmin + sM.uthickness, sM.length / 2, -dphi, dphi); + // } // ********** LOOP OVER COMPONENTS @@ -191,7 +174,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe comp_rmin+=sM.uthickness; } // xml_comp_t* sensitiveComp = 0; - int sensor_number = 1; + int sensor_number = 1; for (xml_coll_t mci(x_mod, _U(module_component)); mci; ++mci) { xml_comp_t x_comp = mci; const string c_nam = x_comp.nameStr(); @@ -199,54 +182,107 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe double comp_length = sM.length; // default value for a regular component (not a frame) double comp_width = sM.width; // default value for a regular component (not a frame) - double pz=0; // default: create the module at center - double rphi=0; // default: no rotation - bool is_tile = 0; - if (sM.has_rsu) { // if has a frame, use RSU size, and determine the tile offset by comp name - double rphi_temp = (0.5 * x_comp.width() + BiasingWidth*mm)/sM.rmin; //tile_width along rphi - double pz_temp = 0.5 * x_comp.length(); //tile_length along z - is_tile = 1; - if ((c_nam == "UpperRightTile")) { - rphi = rphi_temp; - pz = -pz_temp-BackboneWidth*mm; - } else if (c_nam == "UpperLeftTile") { - rphi = rphi_temp; - pz = pz_temp; - } else if (c_nam == "LowerRightTile") { - rphi = -rphi_temp; - pz = -pz_temp-BackboneWidth*mm; - } else if (c_nam == "LowerLeftTile") { - rphi = -rphi_temp; - pz = pz_temp; - } else { - is_tile=0; - } + Volume c_vol; + PlacedVolume pv_sens; + + bool is_tile=0; + // place four tiles. Other components are set at center + if ((c_nam == "UpperRightTile")||(c_nam == "UpperLeftTile")||(c_nam == "LowerRightTile")||(c_nam == "LowerLeftTile")){ + if (sM.has_rsu) { // ignore tiles if no frame provided + is_tile=1; + double rphi_lo=0, rphi_hi=0, z_left=0, z_right=0, rphi_hihi=0; + double drphi = x_comp.width(); //tile_width along rphi + double dz = x_comp.length(); //tile_length along z + // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing + // "|" = backbone: + // + // | ------readout-------- | -------readout-------- + // | tile | tile + // | ------biasing-------- | -------biasing-------- + // | ------biasing-------- | -------biasing-------- + // | tile | tile + // | ------readout-------- | -------readout-------- + // please keep, RSU dimensions are calculated from the number below in mm: + const double tile_width = drphi;//9.197; + const double tile_length = dz;//10.773; // along the stave (z) + const double BiasingWidth = 0.06*mm; // need to x2 for two sets + // const double BiasingLength = tile_length; // along the stave (z) + // const double ReadoutPadsLength = tile_length; + const double ReadoutPadsWidth = sM.width/2-BiasingWidth-tile_width; + const double BackboneLength = sM.length/2-tile_length;//0.06; + const double BackboneWidth = sM.width/2; + + if ((c_nam == "UpperRightTile")) { + rphi_lo = BiasingWidth; + rphi_hi = rphi_lo + drphi; + rphi_hihi = sM.width/2; + z_left = BackboneLength; + z_right = z_left + dz; + } else if (c_nam == "UpperLeftTile") { + rphi_lo = BiasingWidth; + rphi_hihi = sM.width/2; + rphi_hi = rphi_lo + drphi; + z_right = 0; + z_left = z_right - dz; + } else if (c_nam == "LowerRightTile") { + rphi_lo = -BiasingWidth; + rphi_hi = rphi_lo - drphi; //hi: farther away from phi=0, with sign + rphi_hihi = -sM.width/2; + z_left = BackboneLength; + z_right = z_left + dz; + } else if (c_nam == "LowerLeftTile") { + rphi_lo = -BiasingWidth; + rphi_hi = rphi_lo - drphi; + rphi_hihi = -sM.width/2; + z_right = 0; + z_left = z_right - dz; + } + double dphi = drphi/sM.rmin; + double pz = (z_right+z_left)/2; + double phi = (rphi_hi+rphi_lo)/2/sM.rmin; + Position pos(0,0,pz);// x: along R pointing out. y: along rphi, + RotationZYX rot(phi,0,0); + Transform3D tr(rot, pos); + Tube c_tube(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); + c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); + pv_sens = m_vol.placeVolume(c_vol, tr); + // subtract tile volume from the inactive frame // doesn't work, has unknown residuals + // rsu_frame = SubtractionSolid(rsu_frame, c_tube, tr); + // biasing + dphi = BiasingWidth/sM.rmin; + Tube f_tube1(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); + Volume f_vol1(c_nam+"_biasing", f_tube1, description.material(sM.umaterial)); + pv = m_vol.placeVolume(f_vol1, Transform3D(RotationZYX(rphi_lo/sM.rmin/2,0,0),pos)); + f_vol1.setVisAttributes(description, sM.uvis); + + // read out + dphi = ReadoutPadsWidth/sM.rmin; + Tube f_tube2(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); + Volume f_vol2(c_nam+"_readout", f_tube2, description.material(sM.umaterial)); + pv = m_vol.placeVolume(f_vol2, Transform3D(RotationZYX((rphi_hihi+rphi_hi)/sM.rmin/2,0,0),pos)); + f_vol2.setVisAttributes(description, sM.uvis); + + // backbone + dphi = BackboneWidth/sM.rmin; + Tube f_tube3(sM.rmin, sM.rmin + sM.uthickness, BackboneLength/2, -dphi/2, dphi/2); + Volume f_vol3(c_nam+"_backbone", f_tube3, description.material(sM.umaterial)); + pv = m_vol.placeVolume(f_vol3, Transform3D(RotationZYX(rphi_hihi/sM.rmin/2,0,0),Position(0,0,z_left-BackboneLength/2))); + f_vol3.setVisAttributes(description, sM.uvis); + } } - RotationZYX rot(rphi, 0, 0); - Position pos(0,0,pz);// x: along R pointing out. y: along rphi, - Transform3D tr(rot, pos); - Solid c_tube; - if (is_tile) { // has frame with tiles, use RSU dimension - double dphi = x_comp.width() / sM.rmin / 2; - double phi_start = -dphi, phi_end = dphi; - c_tube = Tube(sM.rmin, sM.rmin + sM.uthickness, x_comp.length() / 2, phi_start, phi_end); - // subtract tile volume from the inactive frame - rsu_frame = SubtractionSolid(rsu_frame, c_tube, tr); - } else{ - double dphi = comp_width / sM.rmin / 2; - double phi_start = -dphi, phi_end = dphi; - c_tube=Tube(comp_rmin, comp_rmin + comp_thickness, comp_length / 2, phi_start, phi_end); + else{ // other component, place at given thickness, and module center + double dphi = comp_width / comp_rmin; + Tube c_tube(comp_rmin, comp_rmin + comp_thickness, comp_length / 2, -dphi/2, dphi/2); + c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); + pv_sens = m_vol.placeVolume(c_vol, Transform3D(RotationZYX(0,0,0),Position(0,0,0))); } - - Volume c_vol(c_nam, c_tube, description.material(x_comp.materialStr())); - pv = m_vol.placeVolume(c_vol, tr); c_vol.setVisAttributes(description, x_comp.visStr()); - + if (x_comp.isSensitive()) { // // ***** SENSITIVE VOLUME - pv.addPhysVolID("sensor", sensor_number++); + pv_sens.addPhysVolID("sensor", sensor_number++); c_vol.setSensitiveDetector(sens); - sensitives[sM.name].push_back(pv); + sensitives[sM.name].push_back(pv_sens); // -------- create a measurement plane for the tracking surface attached to the sensitive volume ----- Vector3D u(-1., 0., 0.); @@ -256,8 +292,6 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe // Compute the inner (i.e. thickness until mid-sensitive-volume) and // outer (from mid-sensitive-volume to top) // thicknesses that need to be assigned to the tracking surface - // depending on wether the support is above or below the sensor (!?) - double inner_thickness, outer_thickness; if (is_tile){ inner_thickness = sM.uthickness / 2; @@ -275,11 +309,11 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe thickness_so_far += comp_thickness; } //end of module component loop //place the frame - if (sM.has_rsu){ - Volume rsu_vol(sM.uname, rsu_frame, description.material(sM.umaterial)); - pv = m_vol.placeVolume(rsu_vol, Position(0, 0, 0)); - rsu_vol.setVisAttributes(description, sM.uvis); - } + // if (sM.has_rsu){ + // Volume rsu_vol(sM.uname, rsu_frame, description.material(sM.umaterial)); + // pv = m_vol.placeVolume(rsu_vol, Position(0, 0, 0)); + // rsu_vol.setVisAttributes(description, sM.uvis); + // } } //end of module loop // ********** LAYER From b30007d645cb79f2481b11bea1f3397aa669d2ed Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Tue, 5 Nov 2024 21:46:40 -0800 Subject: [PATCH 03/12] the four tile one module design with updated L2 radius. Having issue with ACTS e.g. only half of the unit is valid when making sourcelinks --- compact/tracking/vertex_barrel_curved.xml | 54 ++++++++++++----------- src/SVTBarrelTracker_geo.cpp | 40 ++++++++--------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index e81f4ae0d8..751f494849 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -45,23 +45,23 @@ - rmin are set to accommodate 12,16,and 38 RSU rows in phi + rmin are set to accommodate 12,16,and 40 RSU rows in phi - - + + + + - - + - - - @@ -85,7 +85,7 @@ Tile components will be ignored if no frame (RSU) is provided. width and length in component will be ignored for non-tiles. - + - + - + Layers composed of many arrayed modules - + @@ -163,10 +163,10 @@ - + @@ -178,10 +178,10 @@ - + @@ -203,9 +203,13 @@ - TODO: set segmentation for tube - - system:8,layer:4,module:12,sensor:2,x:32:-16,y:-16 + + + + + + + system:8,layer:4,module:12,sensor:3,phi:30:-18,z:-16 diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 4465ea0d91..576b1a75bd 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022-2024 Whitney Armstrong, Nivedith Ramasubramanian, Yann Bedfer, Shujie Li +// Copyright (C) 2022-2024 Whitney Armstrong, Nivedith Ramasubramanian, Yann Bedfer, Shujie Li, Jonathan Witte /** \addtogroup Trackers Trackers * \brief Type: **Curved Silicon Vertex Tracker Barrel with inactive area**. @@ -30,15 +30,10 @@ using ROOT::Math::XYVector; /** Curved Silicon Vertex Tracker Barrel with inactive area * - * - Designed to process "mpgd_barrel.xml" ("mpgd_barrel_ver1" as of 2024/02). + * - Designed to process "vertex_barrel_curved.xml" * - * - Derived from "BarrelTrackerWithFrame_geo.cpp". - * - * - "support" tag not addressed. - * - * - "frame" tag within the module element. - * - * but a single XML and a single . + * - Derived from "MPGDCylinderBarrelTracker_geo.cpp". + * - Build-in RSU structure with four tiles * * \code * \endcode @@ -60,7 +55,6 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe map> volplane_surfaces; PlacedVolume pv; - // Set detector type flag dd4hep::xml::setDetectorTypeFlag(x_det, sdet); auto& params = DD4hepDetectorHelper::ensureExtension(sdet); @@ -226,7 +220,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe z_left = z_right - dz; } else if (c_nam == "LowerRightTile") { rphi_lo = -BiasingWidth; - rphi_hi = rphi_lo - drphi; //hi: farther away from phi=0, with sign + rphi_hi = rphi_lo - drphi; //hi: farther away from phi=0. Signed rphi_hihi = -sM.width/2; z_left = BackboneLength; z_right = z_left + dz; @@ -244,10 +238,10 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe RotationZYX rot(phi,0,0); Transform3D tr(rot, pos); Tube c_tube(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); - c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); + c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); pv_sens = m_vol.placeVolume(c_vol, tr); - // subtract tile volume from the inactive frame // doesn't work, has unknown residuals - // rsu_frame = SubtractionSolid(rsu_frame, c_tube, tr); + + // ** inactive areas ** // biasing dphi = BiasingWidth/sM.rmin; Tube f_tube1(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); @@ -287,26 +281,28 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe // -------- create a measurement plane for the tracking surface attached to the sensitive volume ----- Vector3D u(-1., 0., 0.); Vector3D v(0., -1., 0.); - Vector3D n(0., 0., 1.); + Vector3D n(0., 0. , 1.); // Compute the inner (i.e. thickness until mid-sensitive-volume) and // outer (from mid-sensitive-volume to top) // thicknesses that need to be assigned to the tracking surface double inner_thickness, outer_thickness; - if (is_tile){ - inner_thickness = sM.uthickness / 2; - outer_thickness = total_thickness - inner_thickness - sM.uthickness / 2; + if (is_tile){ // always put the tile at inner most layer + inner_thickness = 0 + sM.uthickness/2; + outer_thickness = total_thickness - sM.uthickness/2; } else{ - inner_thickness = thickness_so_far + comp_thickness / 2; - outer_thickness = total_thickness - inner_thickness - comp_thickness / 2; + inner_thickness = thickness_so_far + comp_thickness/2 ; + outer_thickness = total_thickness - inner_thickness; } SurfaceType type(SurfaceType::Sensitive); VolPlane surf(c_vol, type, inner_thickness, outer_thickness, u, v, n); //,o ) ; volplane_surfaces[sM.name].push_back(surf); } - comp_rmin += comp_thickness; - thickness_so_far += comp_thickness; + if (!is_tile){ + comp_rmin += comp_thickness; + thickness_so_far += comp_thickness; + } } //end of module component loop //place the frame // if (sM.has_rsu){ From 70fe21d69148ee7751279e0bc3641dc80d37ec12 Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Sun, 10 Nov 2024 17:51:48 -0800 Subject: [PATCH 04/12] update three SVT layers with curved RSU structure with four tiles and inactive areas --- compact/tracking/definitions_craterlake.xml | 2 +- compact/tracking/vertex_barrel_curved.xml | 298 +++++----- configurations/craterlake.yml | 2 +- configurations/craterlake_10x100.yml | 2 +- configurations/craterlake_10x275.yml | 2 +- configurations/craterlake_18x110_Au.yml | 2 +- configurations/craterlake_18x275.yml | 2 +- configurations/craterlake_5x100.yml | 2 +- configurations/craterlake_5x41.yml | 2 +- configurations/craterlake_bic_6layers.yml | 2 +- configurations/craterlake_material_map.yml | 2 +- configurations/craterlake_no_bhcal.yml | 2 +- configurations/craterlake_no_zdc_lyso.yml | 2 +- configurations/craterlake_tracking_only.yml | 2 +- configurations/forward_detectors.yml | 2 +- .../forward_detectors_with_inserts.yml | 2 +- configurations/full.yml | 2 +- configurations/inner_detector.yml | 2 +- configurations/vertex_only.yml | 2 +- src/SVTBarrelTracker_geo.cpp | 553 +++++++----------- 20 files changed, 392 insertions(+), 495 deletions(-) diff --git a/compact/tracking/definitions_craterlake.xml b/compact/tracking/definitions_craterlake.xml index 3963c0ec53..79c5aa6fcf 100644 --- a/compact/tracking/definitions_craterlake.xml +++ b/compact/tracking/definitions_craterlake.xml @@ -14,7 +14,7 @@ Main parameters for the vertex tracker - + Main parameters for the SiBarrel layer geometry diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index 751f494849..7f902e96a2 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -7,61 +7,66 @@ Main parameters - - - - - - each RSU contains four tiles (2x2), along with backbone, biasing, and readout. - The width and length (along z) are given below. modifying them without changing - the other dimensions in SVTBarrelTracker_geo.cpp may introduce inconsistency. - Tile thickness is set to be SiVertexSensor_thickness in frame. Use dummy for the total thickness calculation. - - - - - + + 1 RSU = 2x2 tiles with inactive areas + 1 module = 1 tile + 1 stave = 1 row of 12 RSU=24 tiles + + + + + # of staves in R: 12, 16, 40 RSUs = 24, 32, 80 tiles + + + + - ensure we are within the vertex envelope with some margin. - + + + - - - Currently there are 3 sensor layers. Each is composed of 2 half-cylinders modules with only - 40um of silicon thickness. - - Both support shells are 300um thick, implemented as the integrated tracker support/service - setup + + + + + - Currently there are 3 sensor layers: Layer 1,2,3 = L0, L1, L2. + - assume they are of the same length and aligned. - - + + + + + + ensure the modules within the z stave with some margin. + -- not sure where this is used + + - - - rmin are set to accommodate 12,16,and 40 RSU rows in phi - - - - - - + - - + + value="VertexBarrelLayer2_rmin + VertexBarrelLayer_thickness" /> + + + + ensure we are within the vertex envelope with some margin. + @@ -76,121 +81,124 @@ insideTrackingVolume="true"> - The thickness of the detector volume is calculated to accommodate all components + - Vertex Barrel Modules. + - For tiles (1 module = 1 upper/lower tile): + --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer + to allow the geo plugin find both modules. + -- also need to specify type="upper" or "lower" in components. + - for other modules and components: + no need to specify upper and lower anywhere. - - Vertex Barrel Modules - - Tile components will be ignored if no frame (RSU) is provided. - width and length in component will be ignored for non-tiles. - - - - - - - + + + + + - - - - - - + + + - - - - - - + + + + + + + + + - Layers composed of many arrayed modules - + L0 + - - + + - phi0 : Starting phi of first module in rphi plane. - zstart : starting z of the first module in z, default = barrel_start + phi0 : Starting phi of first module. + nphi : Number of modules in phi. + z0 : Z position of first module's center. + nz : Number of modules to place in z. - - + + - + L1 + - - - - phi0 : Starting phi of first module. - zstart : starting z of the first module in z, default = barrel_start - - - + + + + - + L2 + - - - - phi0 : Starting phi of first module. - zstart : starting z of the first module in z, default = barrel_start - - - + + + + @@ -203,12 +211,18 @@ - - - - - - + + + + + + system:8,layer:4,module:12,sensor:3,phi:30:-18,z:-16 diff --git a/configurations/craterlake.yml b/configurations/craterlake.yml index c31cb13186..27560a3122 100644 --- a/configurations/craterlake.yml +++ b/configurations/craterlake.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_10x100.yml b/configurations/craterlake_10x100.yml index 3e6f1ec6ec..8bfee5fcb3 100644 --- a/configurations/craterlake_10x100.yml +++ b/configurations/craterlake_10x100.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_10x275.yml b/configurations/craterlake_10x275.yml index 021150e71f..6a8890c888 100644 --- a/configurations/craterlake_10x275.yml +++ b/configurations/craterlake_10x275.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_18x110_Au.yml b/configurations/craterlake_18x110_Au.yml index 55963a6fec..cb3677919e 100644 --- a/configurations/craterlake_18x110_Au.yml +++ b/configurations/craterlake_18x110_Au.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_18x275.yml b/configurations/craterlake_18x275.yml index b1fe4981e0..9c880eeebc 100644 --- a/configurations/craterlake_18x275.yml +++ b/configurations/craterlake_18x275.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_5x100.yml b/configurations/craterlake_5x100.yml index 25b7b6c1e9..0f843aed57 100644 --- a/configurations/craterlake_5x100.yml +++ b/configurations/craterlake_5x100.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_5x41.yml b/configurations/craterlake_5x41.yml index ef920a70db..30f1192347 100644 --- a/configurations/craterlake_5x41.yml +++ b/configurations/craterlake_5x41.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_bic_6layers.yml b/configurations/craterlake_bic_6layers.yml index 45cd342d6d..56111b6fd1 100644 --- a/configurations/craterlake_bic_6layers.yml +++ b/configurations/craterlake_bic_6layers.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_material_map.yml b/configurations/craterlake_material_map.yml index c613df2190..5d40f3d6ff 100644 --- a/configurations/craterlake_material_map.yml +++ b/configurations/craterlake_material_map.yml @@ -3,7 +3,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_no_bhcal.yml b/configurations/craterlake_no_bhcal.yml index 889884c895..32cb34404c 100644 --- a/configurations/craterlake_no_bhcal.yml +++ b/configurations/craterlake_no_bhcal.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_no_zdc_lyso.yml b/configurations/craterlake_no_zdc_lyso.yml index 4f24db21c8..377f844fe3 100644 --- a/configurations/craterlake_no_zdc_lyso.yml +++ b/configurations/craterlake_no_zdc_lyso.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_tracking_only.yml b/configurations/craterlake_tracking_only.yml index f7291b9910..e11337346e 100644 --- a/configurations/craterlake_tracking_only.yml +++ b/configurations/craterlake_tracking_only.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/forward_detectors.yml b/configurations/forward_detectors.yml index eedc65bf26..d8798751e7 100644 --- a/configurations/forward_detectors.yml +++ b/configurations/forward_detectors.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: silicon_disks: diff --git a/configurations/forward_detectors_with_inserts.yml b/configurations/forward_detectors_with_inserts.yml index 61edc648da..1c9da6376f 100644 --- a/configurations/forward_detectors_with_inserts.yml +++ b/configurations/forward_detectors_with_inserts.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: silicon_disks: diff --git a/configurations/full.yml b/configurations/full.yml index ef920a70db..30f1192347 100644 --- a/configurations/full.yml +++ b/configurations/full.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/inner_detector.yml b/configurations/inner_detector.yml index 1f8281e046..fcab67d27f 100644 --- a/configurations/inner_detector.yml +++ b/configurations/inner_detector.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/vertex_only.yml b/configurations/vertex_only.yml index 1a712ffb62..9b595cea86 100644 --- a/configurations/vertex_only.yml +++ b/configurations/vertex_only.yml @@ -3,4 +3,4 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel: + vertex_barrel_curved: diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 576b1a75bd..2d985bdb83 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -1,15 +1,20 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022-2024 Whitney Armstrong, Nivedith Ramasubramanian, Yann Bedfer, Shujie Li, Jonathan Witte +// Copyright (C) 2022 Whitney Armstrong, Jonathan Witte, Shujie Li -/** \addtogroup Trackers Trackers - * \brief Type: **Curved Silicon Vertex Tracker Barrel with inactive area**. - * \author Shujie Li, Jonathan Witte +/** Curved Silicon Vertex Tracker Barrel with RSU. * + * - Designed to process "vertex_barrel_curved.xml" + * + * - Derived from "BarrelTrackerWithFrame_geo.cpp". + * - Build-in RSU structure with four tiles and inactive areas * - * \ingroup trackers + * \code + * \endcode * - * @{ + * + * @author Whitney Armstrong, Jonathan Witte, Shujie Li */ + #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Printout.h" #include "DD4hep/Shapes.h" @@ -25,36 +30,24 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace dd4hep::detail; -#include "Math/Vector2D.h" -using ROOT::Math::XYVector; +static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, + SensitiveDetector sens) { -/** Curved Silicon Vertex Tracker Barrel with inactive area - * - * - Designed to process "vertex_barrel_curved.xml" - * - * - Derived from "MPGDCylinderBarrelTracker_geo.cpp". - * - Build-in RSU structure with four tiles - * - * \code - * \endcode - * - * - * @author Yann Bedfer - */ -static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDetector sens) { + xml_det_t x_det = e; Material air = description.air(); int det_id = x_det.id(); string det_name = x_det.nameStr(); DetElement sdet(det_name, det_id); - // vector volumes; - map volumes; typedef vector Placements; + map volumes; map sensitives; map> volplane_surfaces; + map> module_length; + + PlacedVolume pv, pv_frame; - PlacedVolume pv; // Set detector type flag dd4hep::xml::setDetectorTypeFlag(x_det, sdet); auto& params = DD4hepDetectorHelper::ensureExtension(sdet); @@ -66,355 +59,251 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe "boundary_material"); } - dd4hep::xml::Dimension dimensions(x_det.dimensions()); Assembly assembly(det_name); + sens.setType("tracker"); - double det_length = dimensions.length(); - double det_z0 = getAttrOrDefault(dimensions, _U(z0), 0.); - double det_start = det_z0 - (det_length / 2); - double det_end = det_z0 + (det_length / 2); - - // ********** MODULE - struct StaveModule { - std::string name; - Double_t rmin; - Double_t width = 0.0; - Double_t length = 0.0; - bool has_rsu = false; - Double_t uthickness = 0.0; // for the RSU - string uname; - string uvis; - string umaterial; - }; - map staveModules; + // loop over the modules for (xml_coll_t mi(x_det, _U(module)); mi; ++mi) { xml_comp_t x_mod = mi; - StaveModule sM; - sM.rmin = x_mod.rmin(); - sM.name = x_mod.nameStr(); - sM.width = x_mod.width(); - sM.length = getAttrOrDefault(x_mod, _U(length), det_length); - - // read RSU dimension from frame, and save in sM - if (x_mod.hasChild(_U(frame))) { - // xml_comp_t m_frame = x_mod.child(_U(frame)); - xml_coll_t fi(x_mod, _U(frame)); - if (fi.size() > 1) { - printout(ERROR, "SVTBarrelTracker", "Number of frames = %d. Must be 0 or 1", - (int)fi.size()); - throw runtime_error("Logics error in building modules."); - } - xml_comp_t x_frame = fi; - sM.uthickness = x_frame.thickness(); - sM.has_rsu = 1; - sM.uname = x_frame.nameStr(); - sM.uvis = x_frame.visStr(); - sM.umaterial = x_frame.materialStr(); - } - if (staveModules.find(sM.name) != staveModules.end()) { - printout(ERROR, "SVTBarrelTracker: ", - string((string("staveModule with named ") + sM.name + string(" already exists."))) - .c_str()); + string m_nam = x_mod.nameStr(); + double m_rmin = x_mod.rmin(); + double m_length = x_mod.length(); + double m_width = x_mod.width(); + module_length[m_nam].push_back(m_length); + + if (volumes.find(m_nam) != volumes.end()) { + printout(ERROR, "SVTBarrelTracker", + string((string("Module with named ") + m_nam + string(" already exists."))).c_str()); throw runtime_error("Logics error in building modules."); } - staveModules[sM.name] = sM; - - // ***** TOTAL THICKNESS from components + 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) { - const xml_comp_t x_comp = ci; - double cthickness = x_comp.thickness(); - printout(DEBUG, "SVTBarrelTracker", "\"%s\": \t comp_thickness %.4f cm", - x_comp.nameStr().c_str(), cthickness / cm); - total_thickness += cthickness; - } - if(sM.has_rsu){ - total_thickness += sM.uthickness; - printout(DEBUG, "SVTBarrelTracker", "\"%s\": \t comp_thickness %.4f cm", sM.name.c_str(), - sM.uthickness / cm); - } - printout(DEBUG, "SVTBarrelTracker", " => total_thickness %.4f cm", total_thickness / cm); - - // ***** ASSEMBLY VOLUME - Assembly m_vol(sM.name); - if (volumes.find(sM.name) != volumes.end()) { - printout(ERROR, "SVTBarrelTracker: ", - string((string("Module volumes with named ") + sM.name + string(" already exists."))) - .c_str()); - throw runtime_error("Logics error in building modules."); + total_thickness += xml_comp_t(ci).thickness(); } - volumes[sM.name] = m_vol; + // the module assembly volume + Assembly m_vol(m_nam); + volumes[m_nam] = m_vol; m_vol.setVisAttributes(description.visAttributes(x_mod.visStr())); - - // creat the total RSU volume, then subtract the tiles to get frame. - // this method doesn't work well, has strange residuals - // Solid rsu_frame; - // IntersectionSolid rsu_frame; - // if (sM.has_rsu) { - // double dphi = sM.width / sM.rmin / 2; - // rsu_frame=Tube(sM.rmin, sM.rmin + sM.uthickness, sM.length / 2, -dphi, dphi); - // } - - - // ********** LOOP OVER COMPONENTS - // always put RSU at innermost surface - double comp_rmin = sM.rmin; - double thickness_so_far = 0; - if (sM.has_rsu){ - thickness_so_far+=sM.uthickness; - comp_rmin+=sM.uthickness; - } - // xml_comp_t* sensitiveComp = 0; - int sensor_number = 1; - for (xml_coll_t mci(x_mod, _U(module_component)); mci; ++mci) { - xml_comp_t x_comp = mci; - const string c_nam = x_comp.nameStr(); - double comp_thickness = x_comp.thickness(); - double comp_length = sM.length; // default value for a regular component (not a frame) - double comp_width = sM.width; // default value for a regular component (not a frame) - + double thickness_so_far = 0.0; + for (xml_coll_t mci(x_mod, _U(module_component)); mci; ++mci, ++ncomponents) { Volume c_vol; - PlacedVolume pv_sens; - - bool is_tile=0; - // place four tiles. Other components are set at center - if ((c_nam == "UpperRightTile")||(c_nam == "UpperLeftTile")||(c_nam == "LowerRightTile")||(c_nam == "LowerLeftTile")){ - if (sM.has_rsu) { // ignore tiles if no frame provided - is_tile=1; - double rphi_lo=0, rphi_hi=0, z_left=0, z_right=0, rphi_hihi=0; - double drphi = x_comp.width(); //tile_width along rphi - double dz = x_comp.length(); //tile_length along z - // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing - // "|" = backbone: - // - // | ------readout-------- | -------readout-------- - // | tile | tile - // | ------biasing-------- | -------biasing-------- - // | ------biasing-------- | -------biasing-------- - // | tile | tile - // | ------readout-------- | -------readout-------- - // please keep, RSU dimensions are calculated from the number below in mm: - const double tile_width = drphi;//9.197; - const double tile_length = dz;//10.773; // along the stave (z) - const double BiasingWidth = 0.06*mm; // need to x2 for two sets - // const double BiasingLength = tile_length; // along the stave (z) - // const double ReadoutPadsLength = tile_length; - const double ReadoutPadsWidth = sM.width/2-BiasingWidth-tile_width; - const double BackboneLength = sM.length/2-tile_length;//0.06; - const double BackboneWidth = sM.width/2; - - if ((c_nam == "UpperRightTile")) { - rphi_lo = BiasingWidth; - rphi_hi = rphi_lo + drphi; - rphi_hihi = sM.width/2; - z_left = BackboneLength; - z_right = z_left + dz; - } else if (c_nam == "UpperLeftTile") { - rphi_lo = BiasingWidth; - rphi_hihi = sM.width/2; - rphi_hi = rphi_lo + drphi; - z_right = 0; - z_left = z_right - dz; - } else if (c_nam == "LowerRightTile") { - rphi_lo = -BiasingWidth; - rphi_hi = rphi_lo - drphi; //hi: farther away from phi=0. Signed - rphi_hihi = -sM.width/2; - z_left = BackboneLength; - z_right = z_left + dz; - } else if (c_nam == "LowerLeftTile") { - rphi_lo = -BiasingWidth; - rphi_hi = rphi_lo - drphi; - rphi_hihi = -sM.width/2; - z_right = 0; - z_left = z_right - dz; - } - double dphi = drphi/sM.rmin; - double pz = (z_right+z_left)/2; - double phi = (rphi_hi+rphi_lo)/2/sM.rmin; - Position pos(0,0,pz);// x: along R pointing out. y: along rphi, - RotationZYX rot(phi,0,0); - Transform3D tr(rot, pos); - Tube c_tube(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); - c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); - pv_sens = m_vol.placeVolume(c_vol, tr); - - // ** inactive areas ** - // biasing - dphi = BiasingWidth/sM.rmin; - Tube f_tube1(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); - Volume f_vol1(c_nam+"_biasing", f_tube1, description.material(sM.umaterial)); - pv = m_vol.placeVolume(f_vol1, Transform3D(RotationZYX(rphi_lo/sM.rmin/2,0,0),pos)); - f_vol1.setVisAttributes(description, sM.uvis); - - // read out - dphi = ReadoutPadsWidth/sM.rmin; - Tube f_tube2(sM.rmin, sM.rmin + sM.uthickness, dz/2, -dphi/2, dphi/2); - Volume f_vol2(c_nam+"_readout", f_tube2, description.material(sM.umaterial)); - pv = m_vol.placeVolume(f_vol2, Transform3D(RotationZYX((rphi_hihi+rphi_hi)/sM.rmin/2,0,0),pos)); - f_vol2.setVisAttributes(description, sM.uvis); - - // backbone - dphi = BackboneWidth/sM.rmin; - Tube f_tube3(sM.rmin, sM.rmin + sM.uthickness, BackboneLength/2, -dphi/2, dphi/2); - Volume f_vol3(c_nam+"_backbone", f_tube3, description.material(sM.umaterial)); - pv = m_vol.placeVolume(f_vol3, Transform3D(RotationZYX(rphi_hihi/sM.rmin/2,0,0),Position(0,0,z_left-BackboneLength/2))); - f_vol3.setVisAttributes(description, sM.uvis); - } + xml_comp_t x_comp = mci; + const string c_nam = x_comp.nameStr();// _toString(ncomponents, "component%d"); + const string c_mat = x_comp.materialStr(); + double c_thickness = x_comp.thickness(); + double c_width = getAttrOrDefault(x_comp, _U(width) , m_width) ; + double c_length = getAttrOrDefault(x_comp, _U(length), m_length); + double c_rmin = m_rmin+thickness_so_far; + double c_dphi = c_width/c_rmin; + + if (c_nam=="RSU"){ // for RSU, create ONE upper or lower tile. + // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing + // Having issue including multiple sensitive surfaces in one Tube module (worked with box). + // Therefore use type "upper" and "lower" to create two tiles. (left right is identical) + // + // "|" = backbone. Length alone z. + // + // | ------readout-------- | -------readout-------- + // | tile | tile + // | ------biasing-------- | -------biasing-------- + // | ------biasing-------- | -------biasing-------- + // | tile | tile + // | ------readout-------- | -------readout-------- + const string frame_vis ="VertexSupportLayerVis"; + const string c_type = x_comp.typeStr(); + const double BiasingWidth = 0.06*mm; // need to x2 for two sets + const double ReadoutPadsWidth = m_width-BiasingWidth-c_width; + const double BackboneLength = m_length-c_length;//0.06*mm; + + double px=0, py=0, pz=0; + double c_z0 = -m_length/2; + double c_z1 = c_z0+BackboneLength; + double c_z2 = m_length/2; + pz = (c_z1 + c_z2)/2; // tile central z + + double c_phi0 = 0; + double c_phi1, c_phi2; + double c_phi3 = m_width/m_rmin; + string c_nam1, c_nam2; + if (c_type=="upper"){ + c_phi1 = BiasingWidth/c_rmin; + c_phi2 = c_phi1 + c_dphi; + c_nam1 = "biasing"; + c_nam2 = "readout"; + } + else if (c_type=="lower"){ + c_phi1 = ReadoutPadsWidth/c_rmin; + c_phi2 = c_phi1 + c_dphi; + c_nam1 = "readout"; + c_nam2 = "biasing"; + } + else{ + printout(ERROR, "SVTBarrelTracker", + string((string("Module ") + m_nam + string(": invalid RSU component type [")+c_type+string("], should be upper or lower"))).c_str()); + throw runtime_error("Logics error in building modules."); + } + + // *** inactive areas + // biasing and readout (horizontal) + Tube f_tube1(c_rmin, c_rmin + c_thickness, c_length/2, c_phi0, c_phi1); + Volume f_vol1(c_nam1, f_tube1, description.material(c_mat)); + pv_frame = m_vol.placeVolume(f_vol1, Position(px,py,pz)); + f_vol1.setVisAttributes(description, frame_vis); + + Tube f_tube2(c_rmin, c_rmin + c_thickness, c_length/2, c_phi2, c_phi3); + Volume f_vol2(c_nam2, f_tube2, description.material(c_mat)); + pv_frame = m_vol.placeVolume(f_vol2, Position(px,py,pz)); + f_vol2.setVisAttributes(description, frame_vis); + + // backbone (vertical) + Tube f_tube3(c_rmin, c_rmin + c_thickness, BackboneLength/2, c_phi0, c_phi3); + Volume f_vol3("backbone", f_tube3, description.material(c_mat)); + pv_frame = m_vol.placeVolume(f_vol3, Position(px, py, (c_z0+c_z1)/2)); + f_vol3.setVisAttributes(description, frame_vis); + + // *** sensitive tile + Tube c_tube(c_rmin, c_rmin+c_thickness, c_length/2, c_phi1, c_phi2); + c_vol= Volume(c_nam+"_"+c_type, c_tube, description.material(c_mat)); + pv = m_vol.placeVolume(c_vol,Position(px, py, pz)); } - else{ // other component, place at given thickness, and module center - double dphi = comp_width / comp_rmin; - Tube c_tube(comp_rmin, comp_rmin + comp_thickness, comp_length / 2, -dphi/2, dphi/2); - c_vol = Volume(c_nam, c_tube, description.material(x_comp.materialStr())); - pv_sens = m_vol.placeVolume(c_vol, Transform3D(RotationZYX(0,0,0),Position(0,0,0))); + else{ // for regular component, no difference b/w upper/lower + Tube c_tube(c_rmin, c_rmin+c_thickness, c_length/2, 0, c_dphi); + c_vol= Volume(c_nam, c_tube, description.material(c_mat)); + pv = m_vol.placeVolume(c_vol,Position(0,0,0)); } + c_vol.setRegion(description, x_comp.regionStr()); + c_vol.setLimitSet(description, x_comp.limitsStr()); c_vol.setVisAttributes(description, x_comp.visStr()); - if (x_comp.isSensitive()) { - // // ***** SENSITIVE VOLUME - pv_sens.addPhysVolID("sensor", sensor_number++); + pv.addPhysVolID("sensor", sensor_number++); c_vol.setSensitiveDetector(sens); - sensitives[sM.name].push_back(pv_sens); - - // -------- create a measurement plane for the tracking surface attached to the sensitive volume ----- + sensitives[m_nam].push_back(pv); + // -------- create a measurement plane for the tracking surface attched to the sensitive volume ----- Vector3D u(-1., 0., 0.); Vector3D v(0., -1., 0.); - Vector3D n(0., 0. , 1.); - - // Compute the inner (i.e. thickness until mid-sensitive-volume) and - // outer (from mid-sensitive-volume to top) - // thicknesses that need to be assigned to the tracking surface - double inner_thickness, outer_thickness; - if (is_tile){ // always put the tile at inner most layer - inner_thickness = 0 + sM.uthickness/2; - outer_thickness = total_thickness - sM.uthickness/2; - } else{ - inner_thickness = thickness_so_far + comp_thickness/2 ; - outer_thickness = total_thickness - inner_thickness; - } + Vector3D n(0., 0., 1.); + + // compute the inner and outer thicknesses that need to be assigned to the tracking surface + // depending on wether the support is above or below the sensor + double inner_thickness = thickness_so_far+c_thickness / 2.0; + double outer_thickness = total_thickness - inner_thickness; SurfaceType type(SurfaceType::Sensitive); VolPlane surf(c_vol, type, inner_thickness, outer_thickness, u, v, n); //,o ) ; - volplane_surfaces[sM.name].push_back(surf); - } - if (!is_tile){ - comp_rmin += comp_thickness; - thickness_so_far += comp_thickness; + volplane_surfaces[m_nam].push_back(surf); } - } //end of module component loop - //place the frame - // if (sM.has_rsu){ - // Volume rsu_vol(sM.uname, rsu_frame, description.material(sM.umaterial)); - // pv = m_vol.placeVolume(rsu_vol, Position(0, 0, 0)); - // rsu_vol.setVisAttributes(description, sM.uvis); - // } - } //end of module loop - - // ********** LAYER - // ***** RETRIEVE PARAMETERS - for (xml_coll_t li(x_det, _U(layer)); li; ++li) { - xml_comp_t x_layer = li; - int lay_id = x_layer.id(); - string m_nam = x_layer.moduleStr(); - Volume& module_vol = volumes[m_nam]; - Placements& sensVols = sensitives[m_nam]; - - xml_comp_t x_barrel = x_layer.child(_U(barrel_envelope)); - double barrel_length = x_barrel.z_length(); - double barrel_z0 = getAttrOrDefault(x_barrel, _U(z0), 0.); - // Calculate barrel ends - double barrel_start = barrel_z0 - (barrel_length / 2); - double barrel_end = barrel_z0 + (barrel_length / 2); - if (det_start > barrel_start || det_end < barrel_end) { - printout(ERROR, "SVTBarrelTracker", - "Layer #%d is outside the detector envelop\n" - "det_start < barrel_start: %.4f < %.4f\n " - "det_end > barrel_end : %.4f > %.4f\n ", - det_start, barrel_start, det_end, barrel_end); - throw runtime_error("Logics error in building modules."); + thickness_so_far += c_thickness; } + } - // ***** LAYOUTS + // now build the layers by alternating upper and lower modules. + for (xml_coll_t li(x_det, _U(layer)); li; ++li) { + xml_comp_t x_layer = li; + xml_comp_t x_barrel = x_layer.child(_U(barrel_envelope)); xml_comp_t x_layout = x_layer.child(_U(rphi_layout)); - double phi0 = x_layout.phi0(); // Starting phi of first module. xml_comp_t z_layout = x_layer.child(_U(z_layout)); // Get the element. - double layer_zstart = getAttrOrDefault(z_layout, _U(zstart), barrel_start); - if (barrel_start > layer_zstart) { - printout(ERROR, "SVTBarrelTracker", "Layer #%d: barrel_start>layer_zstart: %.4f > %.4f\n ", - barrel_start, layer_zstart); - throw runtime_error("Logics error in building modules."); - } - - // ********** LAYER - // ***** ENVELOPE - string lay_nam = det_name + _toString(x_layer.id(), "_layer%d"); - Tube lay_tub(x_barrel.inner_r(), x_barrel.outer_r(), barrel_length / 2); + int lay_id = x_layer.id(); + string m_nam = x_layer.moduleStr(); + string lay_nam = det_name + _toString(x_layer.id(), "_layer%d"); + Tube lay_tub(x_barrel.inner_r(), x_barrel.outer_r(), x_barrel.z_length() / 2.0); Volume lay_vol(lay_nam, lay_tub, air); // Create the layer envelope volume. - Position lay_pos(0, 0, barrel_z0); + Position lay_pos(0, 0, getAttrOrDefault(x_barrel, _U(z0), 0.)); lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr())); - printout(DEBUG, "SVTBarrelTracker", "Layer \"%s\": rmin,max = %.2f,%.2f cm 1/2length = %.2f cm", - lay_nam.c_str(), x_barrel.inner_r(), x_barrel.outer_r(), barrel_length / 2); + double phi0 = x_layout.phi0(); // Starting phi of first module. + int l_nphi = x_layout.nphi(); // Number of modules in phi. + int nphi[2] = {int((l_nphi+1)/2), int(l_nphi/2)}; // number of modules in uppper and lower modules. + double phi_incr = (M_PI * 2) / l_nphi; // Phi increment for one module. + double z0 = z_layout.z0(); // Z position of first module in phi. + double nz = z_layout.nz(); // Number of modules to place in z. + + Volume module_env[2]; + Placements sensVols[2]; + string m_nams[2]={m_nam+"_upper",m_nam+"_lower"}; + // if both upper and lower modules are provided (for RSU tiles) + if ((volumes.find(m_nams[0]) != volumes.end())&&(volumes.find(m_nams[1]) != volumes.end())) { + if (nphi[0]!=nphi[1]){ + printout(ERROR, "SVTBarrelTracker", + string((string("Layer ")+lay_nam+string(": nphi must be even number to allow upper and lower modules")).c_str())); + throw runtime_error("Logics error in building modules."); + } + module_env[0] = volumes[m_nams[0]]; + module_env[1] = volumes[m_nams[1]]; + sensVols[0] = sensitives[m_nams[0]]; + sensVols[1] = sensitives[m_nams[1]]; + } + // for other regular modules + else if(volumes.find(m_nam) != volumes.end()){ + module_env[0] = volumes[m_nam]; + module_env[1] = volumes[m_nam]; + sensVols[0] = sensitives[m_nam]; + sensVols[1] = sensitives[m_nam]; + m_nams[0]=m_nam; + m_nams[1]=m_nam; + } DetElement lay_elt(sdet, lay_nam, lay_id); // the local coordinate systems of modules in dd4hep and acts differ // see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html auto& layerParams = DD4hepDetectorHelper::ensureExtension(lay_elt); + for (xml_coll_t lmat(x_layer, _Unicode(layer_material)); lmat; ++lmat) { xml_comp_t x_layer_material = lmat; DD4hepDetectorHelper::xmlToProtoSurfaceMaterial(x_layer_material, layerParams, "layer_material"); } - // ********** LOOP OVER THE SECTORS IN z and phi - auto sM = staveModules[m_nam]; - // Determine "nphi" from RSU width and radius - int nphi = int(2 * M_PI * sM.rmin / sM.width); // always round down to avoid overlap - - // ***** SECTOR POSITIONS ALONG Z - // double modz_pos[1] = {-barrel_length / 2.0}; - int nz = int((barrel_end - layer_zstart) / sM.length); - double zstart = layer_zstart; // for modules in z - double z_incr = sM.length; - double module_z = zstart + z_incr / 2; // module center in z - int nModules = 0; - - for (int iz = 0; iz < nz; iz++) { - double phi_incr = 2 * M_PI / nphi; // Phi increment for one module. - // ***** LOOP OVER THE STAVES IN phi. - int iphi; - double phic; - for (iphi = 0, phic = phi0; iphi < nphi; iphi++, phic += phi_incr, nModules++) { - double x1, y1; // Coordinates of the centre of curvature of - x1 = 0; //rc * std::cos(phic); - y1 = 0; //rc * std::sin(phic); - // int module_id = 100 * iz + iphi; - string module_name = _toString(nModules, "module%d"); - DetElement mod_elt(lay_elt, module_name, nModules); - RotationZYX rot; - rot = RotationZYX(phic, 0, 0); - Transform3D tr(rot, Position(x1, y1, module_z)); - pv = lay_vol.placeVolume(module_vol, tr); - pv.addPhysVolID("module", nModules); - mod_elt.setPlacement(pv); - - // ***** SENSITIVE COMPONENT - for (size_t ic = 0; ic < sensVols.size(); ++ic) { - PlacedVolume sens_pv = sensVols[ic]; - DetElement comp_de(mod_elt, std::string("de_") + sens_pv.volume().name(), nModules); - comp_de.setPlacement(sens_pv); - auto& comp_de_params = - DD4hepDetectorHelper::ensureExtension(comp_de); - comp_de_params.set("axis_definitions", "XYZ"); - volSurfaceList(comp_de)->push_back(volplane_surfaces[m_nam][ic]); + + // Z increment for module placement along Z axis. + // Adjust for z0 at center of module rather than + // the end of cylindrical envelope. + // double z_incr = nz > 1 ? (2.0 * abs(z0)) / (nz - 1) : 0.0; + // Starting z for module placement along Z axis. + int module = 1; + + // Loop over the number of modules in phi. + for (int kk=0; kk<2; kk++){ + int iphi = nphi[kk]; + double z_incr = module_length[m_nams[kk]][0]; + + for (int ii = 0; ii < iphi; ii++) { + // Loop over the number of modules in z. + double module_z = z0; + for (int j = 0; j < nz; j++, module_z+=z_incr) { + string module_name = _toString(module, "module%d"); + DetElement mod_elt(lay_elt, module_name, module); + Transform3D tr(RotationZYX(phi0+phi_incr*ii*2, 0, 0), + Position(0, 0, module_z)); // altering upper and lower module to fill every other row + pv = lay_vol.placeVolume(module_env[kk], tr); + pv.addPhysVolID("module", module); + mod_elt.setPlacement(pv); + for (size_t ic = 0; ic < sensVols[kk].size(); ++ic) { + PlacedVolume sens_pv = sensVols[kk][ic]; + DetElement comp_de(mod_elt, std::string("de_") + sens_pv.volume().name(), module); + comp_de.setPlacement(sens_pv); + auto& comp_de_params = + DD4hepDetectorHelper::ensureExtension(comp_de); + comp_de_params.set("axis_definitions", "XYZ"); + // comp_de.setAttributes(description, sens_pv.volume(), x_layer.regionStr(), x_layer.limitsStr(), + // xml_det_t(xmleles[m_nam]).visStr()); + // + volSurfaceList(comp_de)->push_back(volplane_surfaces[m_nams[kk]][ic]); + } + + /// Increase counters etc. + module++; } } - module_z += z_incr; + phi0+=phi_incr; // switch from upper to lower modules } - - // ***** CREATE THE PhysicalVolume FOR THE LAYER. + // Create the PhysicalVolume for the layer. pv = assembly.placeVolume(lay_vol, lay_pos); // Place layer in mother pv.addPhysVolID("layer", lay_id); // Set the layer ID. lay_elt.setAttributes(description, lay_vol, x_layer.regionStr(), x_layer.limitsStr(), @@ -426,15 +315,9 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe pv = description.pickMotherVolume(sdet).placeVolume(assembly); pv.addPhysVolID("system", det_id); // Set the subdetector system ID. sdet.setPlacement(pv); - - // #ifdef DEBUG_SVTBarrelTracker - // // Reset initial print level before exiting - // setPrintLevel(priorPrintLevel); - // #endif - return sdet; } //@} // clang-format off -DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) +DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) \ No newline at end of file From f127bbd8b7acf6e7ab356e40013a5a4e68542725 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 01:58:53 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/tracking/vertex_barrel_curved.xml | 24 ++-- src/SVTBarrelTracker_geo.cpp | 145 +++++++++++----------- 2 files changed, 85 insertions(+), 84 deletions(-) diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index 7f902e96a2..d7c98c313e 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -41,12 +41,12 @@ - - - + + - - ensure the modules within the z stave with some margin. + + ensure the modules within the z stave with some margin. -- not sure where this is used @@ -61,10 +61,10 @@ + value="VertexBarrelMod3_rmin" /> - + ensure we are within the vertex envelope with some margin. @@ -81,7 +81,7 @@ insideTrackingVolume="true"> - - Vertex Barrel Modules. + - Vertex Barrel Modules. - For tiles (1 module = 1 upper/lower tile): --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer to allow the geo plugin find both modules. @@ -104,7 +104,7 @@ @@ -125,7 +125,7 @@ @@ -146,7 +146,7 @@ @@ -227,4 +227,4 @@ - \ No newline at end of file + diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 2d985bdb83..2ec63c2ca8 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -1,9 +1,9 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Jonathan Witte, Shujie Li +// Copyright (C) 2022 Whitney Armstrong, Jonathan Witte, Shujie Li -/** Curved Silicon Vertex Tracker Barrel with RSU. +/** Curved Silicon Vertex Tracker Barrel with RSU. * - * - Designed to process "vertex_barrel_curved.xml" + * - Designed to process "vertex_barrel_curved.xml" * * - Derived from "BarrelTrackerWithFrame_geo.cpp". * - Build-in RSU structure with four tiles and inactive areas @@ -12,7 +12,7 @@ * \endcode * * - * @author Whitney Armstrong, Jonathan Witte, Shujie Li + * @author Whitney Armstrong, Jonathan Witte, Shujie Li */ #include "DD4hep/DetFactoryHelper.h" @@ -30,10 +30,8 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace dd4hep::detail; -static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, - SensitiveDetector sens) { +static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDetector sens) { - xml_det_t x_det = e; Material air = description.air(); int det_id = x_det.id(); @@ -94,16 +92,16 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, double thickness_so_far = 0.0; for (xml_coll_t mci(x_mod, _U(module_component)); mci; ++mci, ++ncomponents) { Volume c_vol; - xml_comp_t x_comp = mci; - const string c_nam = x_comp.nameStr();// _toString(ncomponents, "component%d"); - const string c_mat = x_comp.materialStr(); - double c_thickness = x_comp.thickness(); - double c_width = getAttrOrDefault(x_comp, _U(width) , m_width) ; - double c_length = getAttrOrDefault(x_comp, _U(length), m_length); - double c_rmin = m_rmin+thickness_so_far; - double c_dphi = c_width/c_rmin; - - if (c_nam=="RSU"){ // for RSU, create ONE upper or lower tile. + xml_comp_t x_comp = mci; + const string c_nam = x_comp.nameStr(); // _toString(ncomponents, "component%d"); + const string c_mat = x_comp.materialStr(); + double c_thickness = x_comp.thickness(); + double c_width = getAttrOrDefault(x_comp, _U(width), m_width); + double c_length = getAttrOrDefault(x_comp, _U(length), m_length); + double c_rmin = m_rmin + thickness_so_far; + double c_dphi = c_width / c_rmin; + + if (c_nam == "RSU") { // for RSU, create ONE upper or lower tile. // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing // Having issue including multiple sensitive surfaces in one Tube module (worked with box). // Therefore use type "upper" and "lower" to create two tiles. (left right is identical) @@ -116,67 +114,66 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, // | ------biasing-------- | -------biasing-------- // | tile | tile // | ------readout-------- | -------readout-------- - const string frame_vis ="VertexSupportLayerVis"; - const string c_type = x_comp.typeStr(); - const double BiasingWidth = 0.06*mm; // need to x2 for two sets - const double ReadoutPadsWidth = m_width-BiasingWidth-c_width; - const double BackboneLength = m_length-c_length;//0.06*mm; - - double px=0, py=0, pz=0; - double c_z0 = -m_length/2; - double c_z1 = c_z0+BackboneLength; - double c_z2 = m_length/2; - pz = (c_z1 + c_z2)/2; // tile central z + const string frame_vis = "VertexSupportLayerVis"; + const string c_type = x_comp.typeStr(); + const double BiasingWidth = 0.06 * mm; // need to x2 for two sets + const double ReadoutPadsWidth = m_width - BiasingWidth - c_width; + const double BackboneLength = m_length - c_length; //0.06*mm; + + double px = 0, py = 0, pz = 0; + double c_z0 = -m_length / 2; + double c_z1 = c_z0 + BackboneLength; + double c_z2 = m_length / 2; + pz = (c_z1 + c_z2) / 2; // tile central z double c_phi0 = 0; double c_phi1, c_phi2; - double c_phi3 = m_width/m_rmin; + double c_phi3 = m_width / m_rmin; string c_nam1, c_nam2; - if (c_type=="upper"){ - c_phi1 = BiasingWidth/c_rmin; + if (c_type == "upper") { + c_phi1 = BiasingWidth / c_rmin; c_phi2 = c_phi1 + c_dphi; c_nam1 = "biasing"; c_nam2 = "readout"; - } - else if (c_type=="lower"){ - c_phi1 = ReadoutPadsWidth/c_rmin; + } else if (c_type == "lower") { + c_phi1 = ReadoutPadsWidth / c_rmin; c_phi2 = c_phi1 + c_dphi; c_nam1 = "readout"; c_nam2 = "biasing"; - } - else{ + } else { printout(ERROR, "SVTBarrelTracker", - string((string("Module ") + m_nam + string(": invalid RSU component type [")+c_type+string("], should be upper or lower"))).c_str()); + string((string("Module ") + m_nam + string(": invalid RSU component type [") + + c_type + string("], should be upper or lower"))) + .c_str()); throw runtime_error("Logics error in building modules."); } // *** inactive areas // biasing and readout (horizontal) - Tube f_tube1(c_rmin, c_rmin + c_thickness, c_length/2, c_phi0, c_phi1); + Tube f_tube1(c_rmin, c_rmin + c_thickness, c_length / 2, c_phi0, c_phi1); Volume f_vol1(c_nam1, f_tube1, description.material(c_mat)); - pv_frame = m_vol.placeVolume(f_vol1, Position(px,py,pz)); + pv_frame = m_vol.placeVolume(f_vol1, Position(px, py, pz)); f_vol1.setVisAttributes(description, frame_vis); - Tube f_tube2(c_rmin, c_rmin + c_thickness, c_length/2, c_phi2, c_phi3); + Tube f_tube2(c_rmin, c_rmin + c_thickness, c_length / 2, c_phi2, c_phi3); Volume f_vol2(c_nam2, f_tube2, description.material(c_mat)); - pv_frame = m_vol.placeVolume(f_vol2, Position(px,py,pz)); + pv_frame = m_vol.placeVolume(f_vol2, Position(px, py, pz)); f_vol2.setVisAttributes(description, frame_vis); // backbone (vertical) - Tube f_tube3(c_rmin, c_rmin + c_thickness, BackboneLength/2, c_phi0, c_phi3); + Tube f_tube3(c_rmin, c_rmin + c_thickness, BackboneLength / 2, c_phi0, c_phi3); Volume f_vol3("backbone", f_tube3, description.material(c_mat)); - pv_frame = m_vol.placeVolume(f_vol3, Position(px, py, (c_z0+c_z1)/2)); + pv_frame = m_vol.placeVolume(f_vol3, Position(px, py, (c_z0 + c_z1) / 2)); f_vol3.setVisAttributes(description, frame_vis); // *** sensitive tile - Tube c_tube(c_rmin, c_rmin+c_thickness, c_length/2, c_phi1, c_phi2); - c_vol= Volume(c_nam+"_"+c_type, c_tube, description.material(c_mat)); - pv = m_vol.placeVolume(c_vol,Position(px, py, pz)); - } - else{ // for regular component, no difference b/w upper/lower - Tube c_tube(c_rmin, c_rmin+c_thickness, c_length/2, 0, c_dphi); - c_vol= Volume(c_nam, c_tube, description.material(c_mat)); - pv = m_vol.placeVolume(c_vol,Position(0,0,0)); + Tube c_tube(c_rmin, c_rmin + c_thickness, c_length / 2, c_phi1, c_phi2); + c_vol = Volume(c_nam + "_" + c_type, c_tube, description.material(c_mat)); + pv = m_vol.placeVolume(c_vol, Position(px, py, pz)); + } else { // for regular component, no difference b/w upper/lower + Tube c_tube(c_rmin, c_rmin + c_thickness, c_length / 2, 0, c_dphi); + c_vol = Volume(c_nam, c_tube, description.material(c_mat)); + pv = m_vol.placeVolume(c_vol, Position(0, 0, 0)); } c_vol.setRegion(description, x_comp.regionStr()); c_vol.setLimitSet(description, x_comp.limitsStr()); @@ -192,7 +189,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, // compute the inner and outer thicknesses that need to be assigned to the tracking surface // depending on wether the support is above or below the sensor - double inner_thickness = thickness_so_far+c_thickness / 2.0; + double inner_thickness = thickness_so_far + c_thickness / 2.0; double outer_thickness = total_thickness - inner_thickness; SurfaceType type(SurfaceType::Sensitive); @@ -217,22 +214,25 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, Position lay_pos(0, 0, getAttrOrDefault(x_barrel, _U(z0), 0.)); lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr())); - double phi0 = x_layout.phi0(); // Starting phi of first module. - int l_nphi = x_layout.nphi(); // Number of modules in phi. - int nphi[2] = {int((l_nphi+1)/2), int(l_nphi/2)}; // number of modules in uppper and lower modules. - double phi_incr = (M_PI * 2) / l_nphi; // Phi increment for one module. + double phi0 = x_layout.phi0(); // Starting phi of first module. + int l_nphi = x_layout.nphi(); // Number of modules in phi. + int nphi[2] = {int((l_nphi + 1) / 2), + int(l_nphi / 2)}; // number of modules in uppper and lower modules. + double phi_incr = (M_PI * 2) / l_nphi; // Phi increment for one module. double z0 = z_layout.z0(); // Z position of first module in phi. double nz = z_layout.nz(); // Number of modules to place in z. Volume module_env[2]; Placements sensVols[2]; - string m_nams[2]={m_nam+"_upper",m_nam+"_lower"}; + string m_nams[2] = {m_nam + "_upper", m_nam + "_lower"}; // if both upper and lower modules are provided (for RSU tiles) - if ((volumes.find(m_nams[0]) != volumes.end())&&(volumes.find(m_nams[1]) != volumes.end())) { - if (nphi[0]!=nphi[1]){ + if ((volumes.find(m_nams[0]) != volumes.end()) && (volumes.find(m_nams[1]) != volumes.end())) { + if (nphi[0] != nphi[1]) { printout(ERROR, "SVTBarrelTracker", - string((string("Layer ")+lay_nam+string(": nphi must be even number to allow upper and lower modules")).c_str())); - throw runtime_error("Logics error in building modules."); + string((string("Layer ") + lay_nam + + string(": nphi must be even number to allow upper and lower modules")) + .c_str())); + throw runtime_error("Logics error in building modules."); } module_env[0] = volumes[m_nams[0]]; module_env[1] = volumes[m_nams[1]]; @@ -240,13 +240,13 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, sensVols[1] = sensitives[m_nams[1]]; } // for other regular modules - else if(volumes.find(m_nam) != volumes.end()){ + else if (volumes.find(m_nam) != volumes.end()) { module_env[0] = volumes[m_nam]; module_env[1] = volumes[m_nam]; sensVols[0] = sensitives[m_nam]; sensVols[1] = sensitives[m_nam]; - m_nams[0]=m_nam; - m_nams[1]=m_nam; + m_nams[0] = m_nam; + m_nams[1] = m_nam; } DetElement lay_elt(sdet, lay_nam, lay_id); @@ -266,21 +266,22 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, // the end of cylindrical envelope. // double z_incr = nz > 1 ? (2.0 * abs(z0)) / (nz - 1) : 0.0; // Starting z for module placement along Z axis. - int module = 1; + int module = 1; // Loop over the number of modules in phi. - for (int kk=0; kk<2; kk++){ - int iphi = nphi[kk]; + for (int kk = 0; kk < 2; kk++) { + int iphi = nphi[kk]; double z_incr = module_length[m_nams[kk]][0]; for (int ii = 0; ii < iphi; ii++) { // Loop over the number of modules in z. double module_z = z0; - for (int j = 0; j < nz; j++, module_z+=z_incr) { + for (int j = 0; j < nz; j++, module_z += z_incr) { string module_name = _toString(module, "module%d"); DetElement mod_elt(lay_elt, module_name, module); - Transform3D tr(RotationZYX(phi0+phi_incr*ii*2, 0, 0), - Position(0, 0, module_z)); // altering upper and lower module to fill every other row + Transform3D tr( + RotationZYX(phi0 + phi_incr * ii * 2, 0, 0), + Position(0, 0, module_z)); // altering upper and lower module to fill every other row pv = lay_vol.placeVolume(module_env[kk], tr); pv.addPhysVolID("module", module); mod_elt.setPlacement(pv); @@ -301,7 +302,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, module++; } } - phi0+=phi_incr; // switch from upper to lower modules + phi0 += phi_incr; // switch from upper to lower modules } // Create the PhysicalVolume for the layer. pv = assembly.placeVolume(lay_vol, lay_pos); // Place layer in mother @@ -320,4 +321,4 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, //@} // clang-format off -DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) \ No newline at end of file +DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) From 6e3ca57ada5f878b7a2c0e2bada492204e68c7d3 Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Thu, 14 Nov 2024 16:45:10 -0800 Subject: [PATCH 06/12] fixed a bug in segmentation syntax. Also updated comments --- compact/tracking/vertex_barrel_curved.xml | 103 ++++++++++++---------- src/SVTBarrelTracker_geo.cpp | 24 ++--- 2 files changed, 68 insertions(+), 59 deletions(-) diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index d7c98c313e..fe985e4f5f 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -10,18 +10,18 @@ - - + + - 1 RSU = 2x2 tiles with inactive areas - 1 module = 1 tile - 1 stave = 1 row of 12 RSU=24 tiles + 1 RSU = 2x6 tiles with inactive areas == 2x2 sections + 1 section (module) = 3-tiles along z + 1 "stave" = 1 row of 12 RSU - # of staves in R: 12, 16, 40 RSUs = 24, 32, 80 tiles + # of staves in R: 12, 16, 40 RSUs = 24, 32, 80 sections @@ -31,15 +31,22 @@ - - - + + + + + + for the segmentation. Assume sensors are placed at the inner most surface for each layer + + + + - Currently there are 3 sensor layers: Layer 1,2,3 = L0, L1, L2. - assume they are of the same length and aligned. - + @@ -52,19 +59,13 @@ - - - - - - - + + + + + + + ensure we are within the vertex envelope with some margin. @@ -81,13 +82,21 @@ insideTrackingVolume="true"> - - Vertex Barrel Modules. - - For tiles (1 module = 1 upper/lower tile): + - Vertex Barrel Modules. + - For RSU (1 module = 1 upper/lower section of three tiles): --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer to allow the geo plugin find both modules. -- also need to specify type="upper" or "lower" in components. - for other modules and components: no need to specify upper and lower anywhere. + - one RSU ("|" = backbone. Length alone z.): + | ------readout-------- | -------readout-------- + | tilex3 | tilex3 + | ------biasing-------- | -------biasing-------- + | ------biasing-------- | -------biasing-------- + | tilex3 | tilex3 + | ------readout-------- | -------readout-------- + @@ -95,8 +104,8 @@ material="Silicon" sensitive="true" thickness="SiVertexSensor_thickness" - width="Tile_width" - length="Tile_length" + width="Section_width" + length="Section_length" vis="VertexLayerVis" /> @@ -116,8 +125,8 @@ material="Silicon" sensitive="true" thickness="SiVertexSensor_thickness" - width="Tile_width" - length="Tile_length" + width="Section_width" + length="Section_length" vis="VertexLayerVis" /> @@ -137,8 +146,8 @@ material="Silicon" sensitive="true" thickness="SiVertexSensor_thickness" - width="Tile_width" - length="Tile_length" + width="Section_width" + length="Section_length" vis="VertexLayerVis" /> @@ -214,15 +223,15 @@ - + grid_size_phi="0.02*mm/VertexBarrelSeg1_r" grid_size_z="0.02*mm" + radius="VertexBarrelSeg1_r" /> + grid_size_phi="0.02*mm/VertexBarrelSeg2_r" grid_size_z="0.02*mm" + radius="VertexBarrelSeg2_r" /> + grid_size_phi="0.02*mm/VertexBarrelSeg3_r" grid_size_z="0.02*mm" + radius="VertexBarrelSeg3_r" /> + system:8,layer:4,module:12,sensor:3,phi:30:-18,z:-16 diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 2ec63c2ca8..78ec66d981 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -6,7 +6,7 @@ * - Designed to process "vertex_barrel_curved.xml" * * - Derived from "BarrelTrackerWithFrame_geo.cpp". - * - Build-in RSU structure with four tiles and inactive areas + * - Build-in RSU structure with 12 tiles and inactive areas * * \code * \endcode @@ -101,18 +101,18 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe double c_rmin = m_rmin + thickness_so_far; double c_dphi = c_width / c_rmin; - if (c_nam == "RSU") { // for RSU, create ONE upper or lower tile. - // **** hard-coded RSU design with 4 tiles, plus backbones, readout pads, biasing + if (c_nam=="RSU"){ // for RSU, create ONE upper or lower 3-tile sections. + // **** hard-coded RSU design with 12 tiles, plus backbones, readout pads, biasing // Having issue including multiple sensitive surfaces in one Tube module (worked with box). - // Therefore use type "upper" and "lower" to create two tiles. (left right is identical) + // Therefore use type "upper" and "lower" to create two mirrored tile sections. (left right is identical) // // "|" = backbone. Length alone z. // // | ------readout-------- | -------readout-------- - // | tile | tile + // | tilex3 | tilex3 // | ------biasing-------- | -------biasing-------- // | ------biasing-------- | -------biasing-------- - // | tile | tile + // | tilex3 | tilex3 // | ------readout-------- | -------readout-------- const string frame_vis = "VertexSupportLayerVis"; const string c_type = x_comp.typeStr(); @@ -120,11 +120,11 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe const double ReadoutPadsWidth = m_width - BiasingWidth - c_width; const double BackboneLength = m_length - c_length; //0.06*mm; - double px = 0, py = 0, pz = 0; - double c_z0 = -m_length / 2; - double c_z1 = c_z0 + BackboneLength; - double c_z2 = m_length / 2; - pz = (c_z1 + c_z2) / 2; // tile central z + double px=0, py=0, pz=0; + double c_z0 = -m_length/2; + double c_z1 = c_z0+BackboneLength; + double c_z2 = m_length/2; + pz = (c_z1 + c_z2)/2; // section central z double c_phi0 = 0; double c_phi1, c_phi2; @@ -186,7 +186,6 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe Vector3D u(-1., 0., 0.); Vector3D v(0., -1., 0.); Vector3D n(0., 0., 1.); - // compute the inner and outer thicknesses that need to be assigned to the tracking surface // depending on wether the support is above or below the sensor double inner_thickness = thickness_so_far + c_thickness / 2.0; @@ -210,6 +209,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe string m_nam = x_layer.moduleStr(); string lay_nam = det_name + _toString(x_layer.id(), "_layer%d"); Tube lay_tub(x_barrel.inner_r(), x_barrel.outer_r(), x_barrel.z_length() / 2.0); + Volume lay_vol(lay_nam, lay_tub, air); // Create the layer envelope volume. Position lay_pos(0, 0, getAttrOrDefault(x_barrel, _U(z0), 0.)); lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr())); From bfb8b56f7266c23d92efbec2bc430e7cf5302c24 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:50:00 +0000 Subject: [PATCH 07/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/tracking/vertex_barrel_curved.xml | 16 ++++++++-------- src/SVTBarrelTracker_geo.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml index fe985e4f5f..307fb0d107 100644 --- a/compact/tracking/vertex_barrel_curved.xml +++ b/compact/tracking/vertex_barrel_curved.xml @@ -10,7 +10,7 @@ - + @@ -63,9 +63,9 @@ - + - + ensure we are within the vertex envelope with some margin. @@ -82,7 +82,7 @@ insideTrackingVolume="true"> - - Vertex Barrel Modules. + - Vertex Barrel Modules. - For RSU (1 module = 1 upper/lower section of three tiles): --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer to allow the geo plugin find both modules. @@ -96,7 +96,7 @@ | ------biasing-------- | -------biasing-------- | tilex3 | tilex3 | ------readout-------- | -------readout-------- - + @@ -113,7 +113,7 @@ @@ -134,7 +134,7 @@ @@ -155,7 +155,7 @@ diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 78ec66d981..8aea348cac 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -101,7 +101,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe double c_rmin = m_rmin + thickness_so_far; double c_dphi = c_width / c_rmin; - if (c_nam=="RSU"){ // for RSU, create ONE upper or lower 3-tile sections. + if (c_nam == "RSU") { // for RSU, create ONE upper or lower 3-tile sections. // **** hard-coded RSU design with 12 tiles, plus backbones, readout pads, biasing // Having issue including multiple sensitive surfaces in one Tube module (worked with box). // Therefore use type "upper" and "lower" to create two mirrored tile sections. (left right is identical) @@ -120,11 +120,11 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe const double ReadoutPadsWidth = m_width - BiasingWidth - c_width; const double BackboneLength = m_length - c_length; //0.06*mm; - double px=0, py=0, pz=0; - double c_z0 = -m_length/2; - double c_z1 = c_z0+BackboneLength; - double c_z2 = m_length/2; - pz = (c_z1 + c_z2)/2; // section central z + double px = 0, py = 0, pz = 0; + double c_z0 = -m_length / 2; + double c_z1 = c_z0 + BackboneLength; + double c_z2 = m_length / 2; + pz = (c_z1 + c_z2) / 2; // section central z double c_phi0 = 0; double c_phi1, c_phi2; From 2f9873e634e1ddcd6dbe698a2372fc28c9d4f6e2 Mon Sep 17 00:00:00 2001 From: ShujieL Date: Sat, 16 Nov 2024 13:59:59 -0800 Subject: [PATCH 08/12] Update src/SVTBarrelTracker_geo.cpp Co-authored-by: Wouter Deconinck --- src/SVTBarrelTracker_geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SVTBarrelTracker_geo.cpp b/src/SVTBarrelTracker_geo.cpp index 8aea348cac..5752f85327 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/SVTBarrelTracker_geo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Jonathan Witte, Shujie Li +// Copyright (C) 2022-2024 Whitney Armstrong, Jonathan Witte, Shujie Li /** Curved Silicon Vertex Tracker Barrel with RSU. * From 372d0e2283663ebae05b986bb5998feb4aab1339 Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Wed, 20 Nov 2024 23:17:15 -0800 Subject: [PATCH 09/12] clean up code --- compact/tracking/vertex_barrel.xml | 278 +++++++++++------- compact/tracking/vertex_barrel_curved.xml | 239 --------------- compact/tracking/vertex_barrel_flat_stave.xml | 158 ++++++++++ configurations/craterlake.yml | 2 +- configurations/craterlake_10x100.yml | 2 +- configurations/craterlake_10x275.yml | 2 +- configurations/craterlake_18x110_Au.yml | 2 +- configurations/craterlake_18x275.yml | 2 +- configurations/craterlake_5x100.yml | 2 +- configurations/craterlake_5x41.yml | 2 +- configurations/craterlake_bic_6layers.yml | 2 +- configurations/craterlake_material_map.yml | 2 +- configurations/craterlake_no_bhcal.yml | 2 +- configurations/craterlake_no_zdc_lyso.yml | 2 +- configurations/craterlake_tracking_only.yml | 2 +- configurations/forward_detectors.yml | 2 +- .../forward_detectors_with_inserts.yml | 2 +- configurations/full.yml | 2 +- configurations/inner_detector.yml | 2 +- configurations/vertex_only.yml | 2 +- ...er_geo.cpp => CurvedBarrelTracker_geo.cpp} | 19 +- 21 files changed, 360 insertions(+), 368 deletions(-) delete mode 100644 compact/tracking/vertex_barrel_curved.xml create mode 100644 compact/tracking/vertex_barrel_flat_stave.xml rename src/{SVTBarrelTracker_geo.cpp => CurvedBarrelTracker_geo.cpp} (96%) diff --git a/compact/tracking/vertex_barrel.xml b/compact/tracking/vertex_barrel.xml index f2fc4ad20b..639eabc544 100644 --- a/compact/tracking/vertex_barrel.xml +++ b/compact/tracking/vertex_barrel.xml @@ -1,5 +1,5 @@ - + @@ -7,151 +7,223 @@ Main parameters - - - - + + + + + + + 1 RSU = 2x6 tiles with inactive areas == 2x2 sections + 1 section (module) = 3-tiles along z + 1 "stave" = 1 row of 12 RSU + + + + + # of RSU in phi: 12, 16, 40 RSUs = 24, 32, 80 sections + + + + - - - + + + - ensure we are within the vertex envelope with some margin. - + + + - - Currently there are 3 sensor layers. Each is composed of 2 half-cylinders modules with only 40um of silicon thickness. - - Both support shells are 300um thick, implemented as the integrated tracker support/service setup - + for the segmentation. Assume sensors are placed at the inner most surface for each layer + + + + + - Currently there are 3 sensor layers: Layer 1,2,3 = L0, L1, L2. + - assume they are of the same length and aligned. + - - - - - - Layer 3 already set as main parameter - - - - - - - - - - Extra parameters to approximate a cylinder as a set of skinny staves - due to ACTS limitations. - FIXME: this shouldn't be needed anymore, need to update the cylindrical plugin. - - - - - - - + + + + + + + + + + + + - ### Actual detectors + ### Actual detectors - - - Vertex Barrel Modules - - + + + - Vertex Barrel Modules. + - For RSU (1 module = 1 upper/lower section of three tiles): + --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer + to allow the geo plugin find both modules. + -- also need to specify type="upper" or "lower" in components. + - for other modules and components: + no need to specify upper and lower anywhere. + - one RSU ("|" = backbone. Length alone z.): + | ------readout-------- | -------readout-------- + | tilex3 | tilex3 + | ------biasing-------- | -------biasing-------- + | ------biasing-------- | -------biasing-------- + | tilex3 | tilex3 + | ------readout-------- | -------readout-------- + + + + + + + + + + + + + + - - + + + - - + + - Layers composed of many arrayed modules + + Layers composed of many arrayed modules + L0 + + + + + + phi0 : Starting phi of first module. + nphi : Number of modules in phi. + z0 : Z position of first module's center. + nz : Number of modules to place in z. + + + + + + L1 - - - - phi0 : Starting phi of first module. - phi_tilt : Phi tilt of a module. - rc : Radius of the module center. - nphi : Number of modules in phi. - rphi_dr : The delta radius of every other module. - z0 : Z position of first module in phi. - nz : Number of modules to place in z. - dr : Radial displacement parameter, of every other module. - - - + + + + + + L2 - - - - - - - - - - - + + + + - - + + - - system:8,layer:4,module:12,sensor:2,x:32:-16,y:-16 + + + + + + system:8,layer:4,module:12,sensor:2,phi:32:-16,z:-16 diff --git a/compact/tracking/vertex_barrel_curved.xml b/compact/tracking/vertex_barrel_curved.xml deleted file mode 100644 index 307fb0d107..0000000000 --- a/compact/tracking/vertex_barrel_curved.xml +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - Main parameters - - - - - - - - - - 1 RSU = 2x6 tiles with inactive areas == 2x2 sections - 1 section (module) = 3-tiles along z - 1 "stave" = 1 row of 12 RSU - - - - - # of staves in R: 12, 16, 40 RSUs = 24, 32, 80 sections - - - - - - - - - - - - - - - for the segmentation. Assume sensors are placed at the inner most surface for each layer - - - - - - - - Currently there are 3 sensor layers: Layer 1,2,3 = L0, L1, L2. - - assume they are of the same length and aligned. - - - - - - - - ensure the modules within the z stave with some margin. - -- not sure where this is used - - - - - - - - - - - - ensure we are within the vertex envelope with some margin. - - - - - - ### Actual detectors - - - - - - Vertex Barrel Modules. - - For RSU (1 module = 1 upper/lower section of three tiles): - --Use [mod_name]_upper and [mod_name]_lower here, and [mod_name] in corresponding layer - to allow the geo plugin find both modules. - -- also need to specify type="upper" or "lower" in components. - - for other modules and components: - no need to specify upper and lower anywhere. - - one RSU ("|" = backbone. Length alone z.): - | ------readout-------- | -------readout-------- - | tilex3 | tilex3 - | ------biasing-------- | -------biasing-------- - | ------biasing-------- | -------biasing-------- - | tilex3 | tilex3 - | ------readout-------- | -------readout-------- - - - - - - - - - - - - - - - - - - - - - - - - Layers composed of many arrayed modules - L0 - - - - - - phi0 : Starting phi of first module. - nphi : Number of modules in phi. - z0 : Z position of first module's center. - nz : Number of modules to place in z. - - - - - - L1 - - - - - - - - - L2 - - - - - - - - - - - - - - - - - - - - - - - - - system:8,layer:4,module:12,sensor:3,phi:30:-18,z:-16 - - - - diff --git a/compact/tracking/vertex_barrel_flat_stave.xml b/compact/tracking/vertex_barrel_flat_stave.xml new file mode 100644 index 0000000000..f2fc4ad20b --- /dev/null +++ b/compact/tracking/vertex_barrel_flat_stave.xml @@ -0,0 +1,158 @@ + + + + + + + Main parameters + + + + + + + + + + + + + ensure we are within the vertex envelope with some margin. + + + + - Currently there are 3 sensor layers. Each is composed of 2 half-cylinders modules with only 40um of silicon thickness. + - Both support shells are 300um thick, implemented as the integrated tracker support/service setup + + + + + + + + + + Layer 3 already set as main parameter + + + + + + + + + + Extra parameters to approximate a cylinder as a set of skinny staves + due to ACTS limitations. + FIXME: this shouldn't be needed anymore, need to update the cylindrical plugin. + + + + + + + + + + + + ### Actual detectors + + + + + Vertex Barrel Modules + + + + + + + + + + Layers composed of many arrayed modules + + + + + + phi0 : Starting phi of first module. + phi_tilt : Phi tilt of a module. + rc : Radius of the module center. + nphi : Number of modules in phi. + rphi_dr : The delta radius of every other module. + z0 : Z position of first module in phi. + nz : Number of modules to place in z. + dr : Radial displacement parameter, of every other module. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + system:8,layer:4,module:12,sensor:2,x:32:-16,y:-16 + + + + diff --git a/configurations/craterlake.yml b/configurations/craterlake.yml index 27560a3122..c31cb13186 100644 --- a/configurations/craterlake.yml +++ b/configurations/craterlake.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_10x100.yml b/configurations/craterlake_10x100.yml index 8bfee5fcb3..3e6f1ec6ec 100644 --- a/configurations/craterlake_10x100.yml +++ b/configurations/craterlake_10x100.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_10x275.yml b/configurations/craterlake_10x275.yml index 6a8890c888..021150e71f 100644 --- a/configurations/craterlake_10x275.yml +++ b/configurations/craterlake_10x275.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_18x110_Au.yml b/configurations/craterlake_18x110_Au.yml index cb3677919e..55963a6fec 100644 --- a/configurations/craterlake_18x110_Au.yml +++ b/configurations/craterlake_18x110_Au.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_18x275.yml b/configurations/craterlake_18x275.yml index 9c880eeebc..b1fe4981e0 100644 --- a/configurations/craterlake_18x275.yml +++ b/configurations/craterlake_18x275.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_5x100.yml b/configurations/craterlake_5x100.yml index 0f843aed57..25b7b6c1e9 100644 --- a/configurations/craterlake_5x100.yml +++ b/configurations/craterlake_5x100.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_5x41.yml b/configurations/craterlake_5x41.yml index 30f1192347..ef920a70db 100644 --- a/configurations/craterlake_5x41.yml +++ b/configurations/craterlake_5x41.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_bic_6layers.yml b/configurations/craterlake_bic_6layers.yml index 56111b6fd1..45cd342d6d 100644 --- a/configurations/craterlake_bic_6layers.yml +++ b/configurations/craterlake_bic_6layers.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_material_map.yml b/configurations/craterlake_material_map.yml index 5d40f3d6ff..c613df2190 100644 --- a/configurations/craterlake_material_map.yml +++ b/configurations/craterlake_material_map.yml @@ -3,7 +3,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_no_bhcal.yml b/configurations/craterlake_no_bhcal.yml index 32cb34404c..889884c895 100644 --- a/configurations/craterlake_no_bhcal.yml +++ b/configurations/craterlake_no_bhcal.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_no_zdc_lyso.yml b/configurations/craterlake_no_zdc_lyso.yml index 377f844fe3..4f24db21c8 100644 --- a/configurations/craterlake_no_zdc_lyso.yml +++ b/configurations/craterlake_no_zdc_lyso.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/craterlake_tracking_only.yml b/configurations/craterlake_tracking_only.yml index e11337346e..f7291b9910 100644 --- a/configurations/craterlake_tracking_only.yml +++ b/configurations/craterlake_tracking_only.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/forward_detectors.yml b/configurations/forward_detectors.yml index d8798751e7..eedc65bf26 100644 --- a/configurations/forward_detectors.yml +++ b/configurations/forward_detectors.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: silicon_disks: diff --git a/configurations/forward_detectors_with_inserts.yml b/configurations/forward_detectors_with_inserts.yml index 1c9da6376f..61edc648da 100644 --- a/configurations/forward_detectors_with_inserts.yml +++ b/configurations/forward_detectors_with_inserts.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: silicon_disks: diff --git a/configurations/full.yml b/configurations/full.yml index 30f1192347..ef920a70db 100644 --- a/configurations/full.yml +++ b/configurations/full.yml @@ -4,7 +4,7 @@ features: beampipe: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/inner_detector.yml b/configurations/inner_detector.yml index fcab67d27f..1f8281e046 100644 --- a/configurations/inner_detector.yml +++ b/configurations/inner_detector.yml @@ -4,7 +4,7 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: silicon_barrel: mpgd_barrel: support_service_craterlake: diff --git a/configurations/vertex_only.yml b/configurations/vertex_only.yml index 9b595cea86..1a712ffb62 100644 --- a/configurations/vertex_only.yml +++ b/configurations/vertex_only.yml @@ -3,4 +3,4 @@ features: marco: tracking: definitions_craterlake: - vertex_barrel_curved: + vertex_barrel: diff --git a/src/SVTBarrelTracker_geo.cpp b/src/CurvedBarrelTracker_geo.cpp similarity index 96% rename from src/SVTBarrelTracker_geo.cpp rename to src/CurvedBarrelTracker_geo.cpp index 5752f85327..589654e84c 100644 --- a/src/SVTBarrelTracker_geo.cpp +++ b/src/CurvedBarrelTracker_geo.cpp @@ -1,12 +1,13 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022-2024 Whitney Armstrong, Jonathan Witte, Shujie Li -/** Curved Silicon Vertex Tracker Barrel with RSU. +/** Curved Barrel tracker + * - Derived from "BarrelTrackerWithFrame_geo.cpp". * - * - Designed to process "vertex_barrel_curved.xml" + * - Designed to process "vertex_barrel.xml": + * - When the upper and lower modules are provided, will use the + * Build-in EIC-LAS RSU structure with four sections and inactive areas * - * - Derived from "BarrelTrackerWithFrame_geo.cpp". - * - Build-in RSU structure with 12 tiles and inactive areas * * \code * \endcode @@ -30,7 +31,7 @@ using namespace dd4hep; using namespace dd4hep::rec; using namespace dd4hep::detail; -static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDetector sens) { +static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; Material air = description.air(); @@ -71,7 +72,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe module_length[m_nam].push_back(m_length); if (volumes.find(m_nam) != volumes.end()) { - printout(ERROR, "SVTBarrelTracker", + printout(ERROR, "CurvedBarrelTracker", string((string("Module with named ") + m_nam + string(" already exists."))).c_str()); throw runtime_error("Logics error in building modules."); } @@ -141,7 +142,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe c_nam1 = "readout"; c_nam2 = "biasing"; } else { - printout(ERROR, "SVTBarrelTracker", + printout(ERROR, "CurvedBarrelTracker", string((string("Module ") + m_nam + string(": invalid RSU component type [") + c_type + string("], should be upper or lower"))) .c_str()); @@ -228,7 +229,7 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe // if both upper and lower modules are provided (for RSU tiles) if ((volumes.find(m_nams[0]) != volumes.end()) && (volumes.find(m_nams[1]) != volumes.end())) { if (nphi[0] != nphi[1]) { - printout(ERROR, "SVTBarrelTracker", + printout(ERROR, "CurvedBarrelTracker", string((string("Layer ") + lay_nam + string(": nphi must be even number to allow upper and lower modules")) .c_str())); @@ -321,4 +322,4 @@ static Ref_t create_SVTBarrelTracker(Detector& description, xml_h e, SensitiveDe //@} // clang-format off -DECLARE_DETELEMENT(epic_CylinderSVTBarrel, create_SVTBarrelTracker) +DECLARE_DETELEMENT(epic_CylinderSVTBarrel,create_CurvedBarrelTracker) From 559a991e67b1758d00ad2be95ee0a2e5feaa790f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:17:55 +0000 Subject: [PATCH 10/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/CurvedBarrelTracker_geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CurvedBarrelTracker_geo.cpp b/src/CurvedBarrelTracker_geo.cpp index 589654e84c..10f2940a4a 100644 --- a/src/CurvedBarrelTracker_geo.cpp +++ b/src/CurvedBarrelTracker_geo.cpp @@ -5,7 +5,7 @@ * - Derived from "BarrelTrackerWithFrame_geo.cpp". * * - Designed to process "vertex_barrel.xml": - * - When the upper and lower modules are provided, will use the + * - When the upper and lower modules are provided, will use the * Build-in EIC-LAS RSU structure with four sections and inactive areas * * From 797978d29514e44922f54ea289df9ff572b77e36 Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Mon, 18 Aug 2025 23:11:50 -0700 Subject: [PATCH 11/12] added SVT L0 and L1 frame. To do: FPC, and L2 --- compact/definitions.xml | 9 +- compact/display.xml | 8 +- compact/materials.xml | 4 + compact/tracking/definitions_craterlake.xml | 2 +- compact/tracking/vertex_barrel.xml | 29 +- compact/tracking/vertex_barrel_support.xml | 1175 +++++++++++++++++++ compact/tracking/vertex_test.xml | 41 + src/CurvedBarrelTracker_geo.cpp | 15 +- src/SupportServiceMaterial_geo.cpp | 99 +- 9 files changed, 1356 insertions(+), 26 deletions(-) create mode 100644 compact/tracking/vertex_barrel_support.xml create mode 100644 compact/tracking/vertex_test.xml diff --git a/compact/definitions.xml b/compact/definitions.xml index c4ec7b2d09..751a0cc45e 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -105,7 +105,12 @@ The unused IDs below are saved for future use. - + + + + + + diff --git a/compact/display.xml b/compact/display.xml index 1ba062ac8c..f34d958605 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -23,10 +23,10 @@ - - - - + + + + diff --git a/compact/materials.xml b/compact/materials.xml index 7e79bb1f4a..1eaa7a9368 100644 --- a/compact/materials.xml +++ b/compact/materials.xml @@ -567,4 +567,8 @@ + + + + diff --git a/compact/tracking/definitions_craterlake.xml b/compact/tracking/definitions_craterlake.xml index 4a0c449e67..4e37eecff2 100644 --- a/compact/tracking/definitions_craterlake.xml +++ b/compact/tracking/definitions_craterlake.xml @@ -12,7 +12,7 @@ Main parameters for the vertex tracker - + diff --git a/compact/tracking/vertex_barrel.xml b/compact/tracking/vertex_barrel.xml index 639eabc544..5c00b459a7 100644 --- a/compact/tracking/vertex_barrel.xml +++ b/compact/tracking/vertex_barrel.xml @@ -31,10 +31,22 @@ - - + + the radius here include a gap b/w upper and lower half. + L0 and L1 values from drawing (see vertex_barrel_support.xml) + + + + + roughly (38.15*2pi-234.8)/4 + + + + for the segmentation. Assume sensors are placed at the inner most surface for each layer @@ -46,13 +58,12 @@ - Currently there are 3 sensor layers: Layer 1,2,3 = L0, L1, L2. - assume they are of the same length and aligned. - - + @@ -82,10 +93,10 @@ no need to specify upper and lower anywhere. - one RSU ("|" = backbone. Length alone z.): | ------readout-------- | -------readout-------- - | tilex3 | tilex3 + | tile*3 | tile*3 upper module | ------biasing-------- | -------biasing-------- | ------biasing-------- | -------biasing-------- - | tilex3 | tilex3 + | tile*3 | tile*3 lower module | ------readout-------- | -------readout-------- @@ -164,12 +175,12 @@ - phi0 : Starting phi of first module. + phi0 : Starting phi of first module at the first/second halve. nphi : Number of modules in phi. z0 : Z position of first module's center. nz : Number of modules to place in z. - + @@ -183,7 +194,7 @@ bins1="100" /> - + diff --git a/compact/tracking/vertex_barrel_support.xml b/compact/tracking/vertex_barrel_support.xml new file mode 100644 index 0000000000..454c4d7e50 --- /dev/null +++ b/compact/tracking/vertex_barrel_support.xml @@ -0,0 +1,1175 @@ + + + + + + Tracker support and service materials for IB + + + + + + ------------------------------ + L0 L1 (sheet 1) + ------------------------------ + Radius: ring1 is the inner ring (L0), ring2 is the outer ring (L1). + ring1_2 is the disk connecting ring1 and 2 + + + + + + + + all plates have same thickness and length + + + + + + + + + + + + + + innner (smaller abs(z)) and outer endcap rings on negative and postive direction + + + + + + + + + ------------------------------ + L0 L1 (sheet 3) + ------------------------------ + L0 and L1 air tubes on the positive end (approx as disk), sheet 3 + + + + + + + + + + + + + + + + ------------------------------ + L1 (sheet 2) + ------------------------------ + ring1 (smaller r) and 2. ring1_2 is the disk connecting two rings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ------------------------------ + Frame (sheet 4) + ------------------------------ + + + + + + + + + + + + + + L1PosCone + + + + + + + + + + + + + + + + + + + L1NegCone + + + + + + + + + + + + + + + + + + + + + + L2PosFlange + L2NegFlange + + + + + + + + -------------------------------L1--------------------------------------------- + + + + negative cone (sheet 4) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + positive cone (sheet 4) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -----------------------------sheet 2--------------- + air cooling support + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + plate2 + + + + + + + + + + + + + + + + + + + plate1 (lower) + + + + + + + + + + + + + + + plate1 (upper) + + + + + + + + + + + + + + + plate 1_2 (lower) + + + + + + + + + + + + + + + + + + + + + + plate 1_2 (upper) + + + + + + + + + + + + + + + + + + + + + + Forward (positive) rings + + + + + + + + + + + + + + Backward (negative) rings + + + + + + + + + + + + + + + + + -------------------------------L0 and L1 (sheet1 and sheet 3)--------------------------------- + + + + + air cooling tubes on sheet 3 + + + + + + + + + + + + + + + + + + + + + + + + Forward (positive) rings + + + + + + + + + + + + + + + + + + + Backward (negative) rings + + + + + + + + + + + + + + + + + + + plates (lower left) + + + + + + + + + + plates (lower right) + + + + + + + + + + plates (lower middle) + + + + + + + + + + + + plates (upper left) + + + + + + + + + + plates (upper right) + + + + + + + + + + plates (Upper middle) + + + + + + + + + + + + + diff --git a/compact/tracking/vertex_test.xml b/compact/tracking/vertex_test.xml new file mode 100644 index 0000000000..b8fa060954 --- /dev/null +++ b/compact/tracking/vertex_test.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CurvedBarrelTracker_geo.cpp b/src/CurvedBarrelTracker_geo.cpp index 10f2940a4a..e2a2d81067 100644 --- a/src/CurvedBarrelTracker_geo.cpp +++ b/src/CurvedBarrelTracker_geo.cpp @@ -115,7 +115,7 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv // | ------biasing-------- | -------biasing-------- // | tilex3 | tilex3 // | ------readout-------- | -------readout-------- - const string frame_vis = "VertexSupportLayerVis"; + const string frame_vis = "SVTReadoutVis"; const string c_type = x_comp.typeStr(); const double BiasingWidth = 0.06 * mm; // need to x2 for two sets const double ReadoutPadsWidth = m_width - BiasingWidth - c_width; @@ -201,6 +201,7 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv } // now build the layers by alternating upper and lower modules. + // each layer has a gap b/w the upper and lower half (see phi0 and phi1) for (xml_coll_t li(x_det, _U(layer)); li; ++li) { xml_comp_t x_layer = li; xml_comp_t x_barrel = x_layer.child(_U(barrel_envelope)); @@ -215,11 +216,11 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv Position lay_pos(0, 0, getAttrOrDefault(x_barrel, _U(z0), 0.)); lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr())); - double phi0 = x_layout.phi0(); // Starting phi of first module. int l_nphi = x_layout.nphi(); // Number of modules in phi. + double phi0 = x_layout.phi0(); // Starting phi of first module. int nphi[2] = {int((l_nphi + 1) / 2), int(l_nphi / 2)}; // number of modules in uppper and lower modules. - double phi_incr = (M_PI * 2) / l_nphi; // Phi increment for one module. + double phi_incr = (M_PI*2 - phi0*2) / l_nphi; // Phi increment for one module. double z0 = z_layout.z0(); // Z position of first module in phi. double nz = z_layout.nz(); // Number of modules to place in z. @@ -268,20 +269,21 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv // double z_incr = nz > 1 ? (2.0 * abs(z0)) / (nz - 1) : 0.0; // Starting z for module placement along Z axis. int module = 1; - // Loop over the number of modules in phi. for (int kk = 0; kk < 2; kk++) { int iphi = nphi[kk]; double z_incr = module_length[m_nams[kk]][0]; - for (int ii = 0; ii < iphi; ii++) { + double dphi=phi0; + if (ii>(iphi/2)-1) + dphi=2*phi0; // Loop over the number of modules in z. double module_z = z0; for (int j = 0; j < nz; j++, module_z += z_incr) { string module_name = _toString(module, "module%d"); DetElement mod_elt(lay_elt, module_name, module); Transform3D tr( - RotationZYX(phi0 + phi_incr * ii * 2, 0, 0), + RotationZYX(dphi + phi_incr*kk + phi_incr * ii * 2, 0, 0), Position(0, 0, module_z)); // altering upper and lower module to fill every other row pv = lay_vol.placeVolume(module_env[kk], tr); pv.addPhysVolID("module", module); @@ -303,7 +305,6 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv module++; } } - phi0 += phi_incr; // switch from upper to lower modules } // Create the PhysicalVolume for the layer. pv = assembly.placeVolume(lay_vol, lay_pos); // Place layer in mother diff --git a/src/SupportServiceMaterial_geo.cpp b/src/SupportServiceMaterial_geo.cpp index 2bab397305..b921791145 100644 --- a/src/SupportServiceMaterial_geo.cpp +++ b/src/SupportServiceMaterial_geo.cpp @@ -50,6 +50,12 @@ std::pair build_shape(const Detector& descr, const xml_det_ x_child, _Unicode(phimax), getAttrOrDefault(x_support, _Unicode(phimax), 360.0 * deg)); solid = Tube(rmin, rmin + thickness, length / 2, phimin, phimax); } + else if (type == "Box") { + const double box_x = getAttrOrDefault(x_child, _U(x), x_support.x()); + const double box_y = getAttrOrDefault(x_child, _U(y), x_support.y()); + const double box_z = getAttrOrDefault(x_child, _U(z), x_support.z()); + solid = Box(box_x / 2.0, box_y / 2.0, box_z / 2.0); + } // A disk is a cylinder, constructed differently else if (type == "Disk") { const double thickness = getAttrOrDefault(x_child, _U(thickness), x_support.thickness()); @@ -127,7 +133,19 @@ std::pair build_shape(const Detector& descr, const xml_det_ } solid = Polycone(phimin, deltaphi, v_rmin, v_rmax, v_z); } - } else { + } + else if (type == "Disk") { + const double thickness = getAttrOrDefault(x_child, _U(thickness), x_support.thickness()); + const double rmin = getAttrOrDefault(x_child, _U(rmin), x_support.rmin()); + const double rmax = getAttrOrDefault(x_child, _U(rmax), x_support.rmax()); + const double phimin = getAttrOrDefault( + x_child, _Unicode(phimin), getAttrOrDefault(x_support, _Unicode(phimin), 0.0 * deg)); + const double phimax = getAttrOrDefault( + x_child, _Unicode(phimax), getAttrOrDefault(x_support, _Unicode(phimax), 360.0 * deg)); + pos3D = pos3D + Position(0, 0, -x_support.thickness() / 2 + thickness / 2 + offset); + solid = Tube(rmin, rmax, thickness / 2, phimin, phimax); + } + else { printout(ERROR, x_det.nameStr(), "Unknown support type: %s", type.c_str()); std::exit(1); } @@ -145,6 +163,70 @@ std::pair build_shape(const Detector& descr, const xml_det_ } return {vol, tr}; } + +// Function to create a subtraction of two shapes +std::pair build_subtraction(const Detector& descr, const xml_det_t& x_det, + const xml_comp_t& x_subtraction) { + // Get the two shapes to subtract + xml_comp_t x_shape1 = x_subtraction.child(_Unicode(shape1)); + xml_comp_t x_shape2 = x_subtraction.child(_Unicode(shape2)); + + // Build the primary shape (without transformation) + auto [vol1, tr1_unused] = build_shape(descr, x_det, x_shape1, x_shape1); + Solid solid1 = vol1.solid(); + + // Build the shape to subtract (without transformation) + auto [vol2, tr2_unused] = build_shape(descr, x_det, x_shape2, x_shape2); + Solid solid2 = vol2.solid(); + + // Get relative transformation for shape2 (relative to shape1's center) + xml_dim_t x_pos2(x_shape2.child(_U(position), false)); + xml_dim_t x_rot2(x_shape2.child(_U(rotation), false)); + Position pos2{0, 0, 0}; + Rotation3D rot2; + + if (x_rot2) { + rot2 = RotationZYX(x_rot2.z(0), x_rot2.y(0), x_rot2.x(0)); + } + if (x_pos2) { + pos2 = Position(x_pos2.x(0), x_pos2.y(0), x_pos2.z(0)); + } + + // Create the subtraction solid + Transform3D tr_relative(rot2, pos2); + SubtractionSolid subtracted_solid(solid1, solid2, tr_relative); + + // Create volume with the subtracted solid + Material mat = descr.material(getAttrOrDefault(x_subtraction, _U(material), "Air")); + std::string vol_name = getAttrOrDefault(x_subtraction, _U(name), "subtraction_vol"); + Volume vol{vol_name, subtracted_solid, mat}; + + // Get overall position/rotation for the subtracted volume + xml_dim_t x_pos(x_subtraction.child(_U(position), false)); + xml_dim_t x_rot(x_subtraction.child(_U(rotation), false)); + Position pos3D{0, 0, 0}; + Rotation3D rot3D; + + if (x_rot) { + rot3D = RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); + } + if (x_pos) { + pos3D = Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); + } + + Transform3D tr(rot3D, pos3D); + + // Set visualization if specified + if (x_subtraction.hasAttr(_U(vis))) { + vol.setVisAttributes(descr.visAttributes(x_subtraction.visStr())); + } + + // Debug output + printout(DEBUG, "SupportServiceMaterial", "Created subtraction volume: %s", vol_name.c_str()); + + return {vol, tr}; +} + std::pair build_shape(const Detector& descr, const xml_det_t& x_det, const xml_comp_t& x_support, const double offset = 0) { return build_shape(descr, x_det, x_support, x_support, offset); @@ -170,17 +252,28 @@ static Ref_t create_SupportServiceMaterial(Detector& description, xml_h e, // Loop over the supports for (xml_coll_t su{x_det, _U(support)}; su; ++su) { xml_comp_t x_sup = su; + const double rot_z = getAttrOrDefault(x_sup, _U(phi0), 0.); + RotationZ rot(rot_z); + Transform3D tr_rot(rot, Position(0, 0, 0)); // additional rotation of the module after position offset + auto [vol, tr] = build_shape(description, x_det, x_sup); - [[maybe_unused]] auto pv = assembly.placeVolume(vol, tr); + [[maybe_unused]] auto pv = assembly.placeVolume(vol, tr_rot*tr); // Loop over support components, if any double cumulative_thickness = 0; for (xml_coll_t com{x_sup, _U(component)}; com; ++com) { xml_comp_t x_com = com; auto [cvol, ctr] = build_shape(description, x_det, x_sup, x_com, cumulative_thickness); - vol.placeVolume(cvol, ctr); + vol.placeVolume(cvol, tr_rot*ctr); cumulative_thickness += x_com.thickness(); } } + // Loop over any subtraction volumes + for (xml_coll_t sub{x_det, _Unicode(subtraction)}; sub; ++sub) { + xml_comp_t x_sub = sub; + auto [vol, tr] = build_subtraction(description, x_det, x_sub); + assembly.placeVolume(vol, tr); + } + // final placement Volume motherVol = description.pickMotherVolume(det); From 3203844e63ade5fde9d182411f8ff18a379df37a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 17:44:01 +0000 Subject: [PATCH 12/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compact/tracking/vertex_barrel_support.xml | 140 ++++++++++----------- compact/tracking/vertex_test.xml | 32 ++--- src/CurvedBarrelTracker_geo.cpp | 16 +-- src/SupportServiceMaterial_geo.cpp | 53 ++++---- 4 files changed, 119 insertions(+), 122 deletions(-) diff --git a/compact/tracking/vertex_barrel_support.xml b/compact/tracking/vertex_barrel_support.xml index 454c4d7e50..94fa961c6b 100644 --- a/compact/tracking/vertex_barrel_support.xml +++ b/compact/tracking/vertex_barrel_support.xml @@ -10,9 +10,9 @@ ------------------------------ - L0 L1 (sheet 1) + L0 L1 (sheet 1) ------------------------------ - Radius: ring1 is the inner ring (L0), ring2 is the outer ring (L1). + Radius: ring1 is the inner ring (L0), ring2 is the outer ring (L1). ring1_2 is the disk connecting ring1 and 2 @@ -29,14 +29,14 @@ - - - - - + + + + + innner (smaller abs(z)) and outer endcap rings on negative and postive direction - + @@ -45,7 +45,7 @@ ------------------------------ - L0 L1 (sheet 3) + L0 L1 (sheet 3) ------------------------------ L0 and L1 air tubes on the positive end (approx as disk), sheet 3 @@ -64,7 +64,7 @@ ------------------------------ - L1 (sheet 2) + L1 (sheet 2) ------------------------------ ring1 (smaller r) and 2. ring1_2 is the disk connecting two rings @@ -108,31 +108,31 @@ - - - - + + + + - - - - - + + + + + - - - - + + + + @@ -158,12 +158,12 @@ - - - + + + ------------------------------ - Frame (sheet 4) + Frame (sheet 4) ------------------------------ @@ -180,10 +180,10 @@ L1PosCone - - - - + + + + @@ -197,19 +197,19 @@ - L1NegCone + L1NegCone - - + + - - - - + + + + @@ -219,16 +219,16 @@ - L2PosFlange - L2NegFlange + L2PosFlange + L2NegFlange - - -------------------------------L1--------------------------------------------- + + -------------------------------L1--------------------------------------------- positive cone (sheet 4) - + - + @@ -887,8 +887,8 @@ thickness="L1_pos_ring1_2_dz"> - - + + Backward (negative) rings - - + + - - - -------------------------------L0 and L1 (sheet1 and sheet 3)--------------------------------- + + + -------------------------------L0 and L1 (sheet1 and sheet 3)--------------------------------- @@ -932,17 +932,17 @@ air cooling tubes on sheet 3 - + - + @@ -951,18 +951,18 @@ - + - + diff --git a/compact/tracking/vertex_test.xml b/compact/tracking/vertex_test.xml index b8fa060954..17b0a70f57 100644 --- a/compact/tracking/vertex_test.xml +++ b/compact/tracking/vertex_test.xml @@ -1,41 +1,41 @@ - + - + - + - - - - + - - \ No newline at end of file + + diff --git a/src/CurvedBarrelTracker_geo.cpp b/src/CurvedBarrelTracker_geo.cpp index e2a2d81067..7b3e64b579 100644 --- a/src/CurvedBarrelTracker_geo.cpp +++ b/src/CurvedBarrelTracker_geo.cpp @@ -219,10 +219,10 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv int l_nphi = x_layout.nphi(); // Number of modules in phi. double phi0 = x_layout.phi0(); // Starting phi of first module. int nphi[2] = {int((l_nphi + 1) / 2), - int(l_nphi / 2)}; // number of modules in uppper and lower modules. - double phi_incr = (M_PI*2 - phi0*2) / l_nphi; // Phi increment for one module. - double z0 = z_layout.z0(); // Z position of first module in phi. - double nz = z_layout.nz(); // Number of modules to place in z. + int(l_nphi / 2)}; // number of modules in uppper and lower modules. + double phi_incr = (M_PI * 2 - phi0 * 2) / l_nphi; // Phi increment for one module. + double z0 = z_layout.z0(); // Z position of first module in phi. + double nz = z_layout.nz(); // Number of modules to place in z. Volume module_env[2]; Placements sensVols[2]; @@ -274,16 +274,16 @@ static Ref_t create_CurvedBarrelTracker(Detector& description, xml_h e, Sensitiv int iphi = nphi[kk]; double z_incr = module_length[m_nams[kk]][0]; for (int ii = 0; ii < iphi; ii++) { - double dphi=phi0; - if (ii>(iphi/2)-1) - dphi=2*phi0; + double dphi = phi0; + if (ii > (iphi / 2) - 1) + dphi = 2 * phi0; // Loop over the number of modules in z. double module_z = z0; for (int j = 0; j < nz; j++, module_z += z_incr) { string module_name = _toString(module, "module%d"); DetElement mod_elt(lay_elt, module_name, module); Transform3D tr( - RotationZYX(dphi + phi_incr*kk + phi_incr * ii * 2, 0, 0), + RotationZYX(dphi + phi_incr * kk + phi_incr * ii * 2, 0, 0), Position(0, 0, module_z)); // altering upper and lower module to fill every other row pv = lay_vol.placeVolume(module_env[kk], tr); pv.addPhysVolID("module", module); diff --git a/src/SupportServiceMaterial_geo.cpp b/src/SupportServiceMaterial_geo.cpp index b921791145..bb076c627d 100644 --- a/src/SupportServiceMaterial_geo.cpp +++ b/src/SupportServiceMaterial_geo.cpp @@ -49,12 +49,11 @@ std::pair build_shape(const Detector& descr, const xml_det_ const double phimax = getAttrOrDefault( x_child, _Unicode(phimax), getAttrOrDefault(x_support, _Unicode(phimax), 360.0 * deg)); solid = Tube(rmin, rmin + thickness, length / 2, phimin, phimax); - } - else if (type == "Box") { + } else if (type == "Box") { const double box_x = getAttrOrDefault(x_child, _U(x), x_support.x()); const double box_y = getAttrOrDefault(x_child, _U(y), x_support.y()); const double box_z = getAttrOrDefault(x_child, _U(z), x_support.z()); - solid = Box(box_x / 2.0, box_y / 2.0, box_z / 2.0); + solid = Box(box_x / 2.0, box_y / 2.0, box_z / 2.0); } // A disk is a cylinder, constructed differently else if (type == "Disk") { @@ -133,8 +132,7 @@ std::pair build_shape(const Detector& descr, const xml_det_ } solid = Polycone(phimin, deltaphi, v_rmin, v_rmax, v_z); } - } - else if (type == "Disk") { + } else if (type == "Disk") { const double thickness = getAttrOrDefault(x_child, _U(thickness), x_support.thickness()); const double rmin = getAttrOrDefault(x_child, _U(rmin), x_support.rmin()); const double rmax = getAttrOrDefault(x_child, _U(rmax), x_support.rmax()); @@ -144,8 +142,7 @@ std::pair build_shape(const Detector& descr, const xml_det_ x_child, _Unicode(phimax), getAttrOrDefault(x_support, _Unicode(phimax), 360.0 * deg)); pos3D = pos3D + Position(0, 0, -x_support.thickness() / 2 + thickness / 2 + offset); solid = Tube(rmin, rmax, thickness / 2, phimin, phimax); - } - else { + } else { printout(ERROR, x_det.nameStr(), "Unknown support type: %s", type.c_str()); std::exit(1); } @@ -170,60 +167,60 @@ std::pair build_subtraction(const Detector& descr, const xm // Get the two shapes to subtract xml_comp_t x_shape1 = x_subtraction.child(_Unicode(shape1)); xml_comp_t x_shape2 = x_subtraction.child(_Unicode(shape2)); - + // Build the primary shape (without transformation) auto [vol1, tr1_unused] = build_shape(descr, x_det, x_shape1, x_shape1); - Solid solid1 = vol1.solid(); - + Solid solid1 = vol1.solid(); + // Build the shape to subtract (without transformation) auto [vol2, tr2_unused] = build_shape(descr, x_det, x_shape2, x_shape2); - Solid solid2 = vol2.solid(); - + Solid solid2 = vol2.solid(); + // Get relative transformation for shape2 (relative to shape1's center) xml_dim_t x_pos2(x_shape2.child(_U(position), false)); xml_dim_t x_rot2(x_shape2.child(_U(rotation), false)); Position pos2{0, 0, 0}; Rotation3D rot2; - + if (x_rot2) { rot2 = RotationZYX(x_rot2.z(0), x_rot2.y(0), x_rot2.x(0)); } if (x_pos2) { pos2 = Position(x_pos2.x(0), x_pos2.y(0), x_pos2.z(0)); } - + // Create the subtraction solid Transform3D tr_relative(rot2, pos2); SubtractionSolid subtracted_solid(solid1, solid2, tr_relative); - + // Create volume with the subtracted solid Material mat = descr.material(getAttrOrDefault(x_subtraction, _U(material), "Air")); std::string vol_name = getAttrOrDefault(x_subtraction, _U(name), "subtraction_vol"); Volume vol{vol_name, subtracted_solid, mat}; - + // Get overall position/rotation for the subtracted volume xml_dim_t x_pos(x_subtraction.child(_U(position), false)); xml_dim_t x_rot(x_subtraction.child(_U(rotation), false)); Position pos3D{0, 0, 0}; Rotation3D rot3D; - + if (x_rot) { rot3D = RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); } if (x_pos) { pos3D = Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); } - + Transform3D tr(rot3D, pos3D); - + // Set visualization if specified if (x_subtraction.hasAttr(_U(vis))) { vol.setVisAttributes(descr.visAttributes(x_subtraction.visStr())); } - + // Debug output printout(DEBUG, "SupportServiceMaterial", "Created subtraction volume: %s", vol_name.c_str()); - + return {vol, tr}; } @@ -251,30 +248,30 @@ static Ref_t create_SupportServiceMaterial(Detector& description, xml_h e, // Loop over the supports for (xml_coll_t su{x_det, _U(support)}; su; ++su) { - xml_comp_t x_sup = su; - const double rot_z = getAttrOrDefault(x_sup, _U(phi0), 0.); + xml_comp_t x_sup = su; + const double rot_z = getAttrOrDefault(x_sup, _U(phi0), 0.); RotationZ rot(rot_z); - Transform3D tr_rot(rot, Position(0, 0, 0)); // additional rotation of the module after position offset + Transform3D tr_rot( + rot, Position(0, 0, 0)); // additional rotation of the module after position offset auto [vol, tr] = build_shape(description, x_det, x_sup); - [[maybe_unused]] auto pv = assembly.placeVolume(vol, tr_rot*tr); + [[maybe_unused]] auto pv = assembly.placeVolume(vol, tr_rot * tr); // Loop over support components, if any double cumulative_thickness = 0; for (xml_coll_t com{x_sup, _U(component)}; com; ++com) { xml_comp_t x_com = com; auto [cvol, ctr] = build_shape(description, x_det, x_sup, x_com, cumulative_thickness); - vol.placeVolume(cvol, tr_rot*ctr); + vol.placeVolume(cvol, tr_rot * ctr); cumulative_thickness += x_com.thickness(); } } // Loop over any subtraction volumes for (xml_coll_t sub{x_det, _Unicode(subtraction)}; sub; ++sub) { xml_comp_t x_sub = sub; - auto [vol, tr] = build_subtraction(description, x_det, x_sub); + auto [vol, tr] = build_subtraction(description, x_det, x_sub); assembly.placeVolume(vol, tr); } - // final placement Volume motherVol = description.pickMotherVolume(det); Position pos(0, 0, offset);