diff --git a/compact/definitions.xml b/compact/definitions.xml index 0af5fd609..5b3eac10f 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -314,6 +314,7 @@ The unused IDs below are saved for future use. + diff --git a/compact/far_backward/beamline_extension_electron.xml b/compact/far_backward/beamline_extension_electron.xml index 9a47d3f38..e1346df24 100644 --- a/compact/far_backward/beamline_extension_electron.xml +++ b/compact/far_backward/beamline_extension_electron.xml @@ -25,7 +25,8 @@ + rout1="Q4eR_InnerRadius" rout2="Q4eR_InnerRadius" + limits="kill_limits"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + system:8,pipe:8,end:2 + + + + + diff --git a/compact/far_backward/extended.xml b/compact/far_backward/extended.xml index bcbb157de..dbd48fc5b 100644 --- a/compact/far_backward/extended.xml +++ b/compact/far_backward/extended.xml @@ -13,4 +13,6 @@ + + diff --git a/scripts/material_map/run_material_map_validation.sh b/scripts/material_map/run_material_map_validation.sh index 3daafd1bd..e964ed00f 100755 --- a/scripts/material_map/run_material_map_validation.sh +++ b/scripts/material_map/run_material_map_validation.sh @@ -11,7 +11,7 @@ if [[ -z ${DETECTOR_PATH} || -z ${DETECTOR_CONFIG} ]] ; then fi # Download required Acts files -ACTS_VERSION="682d2080d36712ac15975340c92f860b25169213" +ACTS_VERSION="00591a593a648430820e980b031301d25c18f1c7" # v33.1.0 ACTS_URL="https://github.com/acts-project/acts/raw/" ACTS_FILES=( "Examples/Scripts/Python/geometry.py" @@ -35,6 +35,20 @@ for file in ${ACTS_FILES[@]} ; do done export PYTHONPATH=$PWD/Examples/Scripts/Python:$PYTHONPATH +# FIXME +# Disable ACTS FpeMonitor due to unexplained FPEINV in RootMaterialTrackReader +# FPE summary for Reader: RootMaterialTrackReader +# FLTINV: (2 times) +# 0# Acts::MaterialSlab::MaterialSlab(Acts::Material const&, float) in /opt/local/python/acts/../../lib/libActsCore.so +# 1# ActsExamples::RootMaterialTrackReader::read(ActsExamples::AlgorithmContext const&) in /opt/local/python/acts/../../lib/libActsExamplesIoRoot.so +# 2# ActsExamples::Sequencer::run()::$_0::operator()() const::{lambda(tbb::blocked_range const&)#1}::operator()(tbb::blocked_range const&) const in /opt/local/python/acts/../../lib/libActsExamplesFramework.so +# 3# ActsExamples::Sequencer::run()::$_0::operator()() const in /opt/local/python/acts/../../lib/libActsExamplesFramework.so +# 4# ActsExamples::Sequencer::run() in /opt/local/python/acts/../../lib/libActsExamplesFramework.so +# 5# 0x000070B51DE55640 in /opt/local/python/acts/ActsPythonBindings.cpython-310-x86_64-linux-gnu.so +# 6# 0x000070B51DE49ACD in /opt/local/python/acts/ActsPythonBindings.cpython-310-x86_64-linux-gnu.so +# 7# cfunction_call at Objects/methodobject.c:543 +export ACTS_SEQUENCER_DISABLE_FPEMON=1 + # Default arguments nevents=1000 nparticles=1000 diff --git a/src/BeamPipeChain_geo.cpp b/src/BeamPipeChain_geo.cpp index 8da51d510..706c7e810 100644 --- a/src/BeamPipeChain_geo.cpp +++ b/src/BeamPipeChain_geo.cpp @@ -31,6 +31,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector / double thickness = getAttrOrDefault(x_det, _Unicode(wall_thickness), 0); vector names; + vector ids; vector xCenters; vector zCenters; vector lengths; @@ -44,6 +45,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector / xml_comp_t pipe(pipe_coll); names.push_back(getAttrOrDefault(pipe, _Unicode(name), "")); + ids.push_back(getAttrOrDefault(pipe, _Unicode(id), 0)); // Vectors momentarily filled with zeros for pipes in between magnets xCenters.push_back(getAttrOrDefault(pipe, _Unicode(xcenter), 0)); @@ -108,8 +110,12 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector / assembly.placeVolume(v_tube, Transform3D(RotationY(thetas[pipeN]), Position(xCenters[pipeN], 0, zCenters[pipeN]))); - assembly.placeVolume(v_vacuum, Transform3D(RotationY(thetas[pipeN]), - Position(xCenters[pipeN], 0, zCenters[pipeN]))); + auto placed_vacuum = + assembly.placeVolume(v_vacuum, Transform3D(RotationY(thetas[pipeN]), + Position(xCenters[pipeN], 0, zCenters[pipeN]))); + + DetElement vacuum_element(sdet, names[pipeN] + "_vacuum", ids[pipeN]); + vacuum_element.setPlacement(placed_vacuum); } // Final placement diff --git a/src/BeamPipeStop_geo.cpp b/src/BeamPipeStop_geo.cpp new file mode 100644 index 000000000..5b42e33d9 --- /dev/null +++ b/src/BeamPipeStop_geo.cpp @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Simon Gardner + +//========================================================================== +// +// Places a small sensitive disk of vacuum at the end of beam pipes +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "TMath.h" +#include + +using namespace std; +using namespace dd4hep; + +static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector /* sens */) { + + using namespace ROOT::Math; + xml_det_t x_det = e; + string det_name = x_det.nameStr(); + int det_id = x_det.id(); + Material m_Vacuum = description.material("Vacuum"); + string vis_name = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "BeamPipeVis"); + + string grandmotherName = x_det.attr(_Unicode(grandmother)); + string motherName = x_det.attr(_Unicode(mother)); + bool detStart = getAttrOrDefault(x_det, _Unicode(end), true); + DetElement mother = description.detector(grandmotherName).child(motherName); + + DetElement sdet(det_name, det_id); + + // Get the mother volume + Volume mother_vol = mother.volume(); + + // Get mother volume shape as cone segment + ConeSegment mother_shape = mother_vol.solid(); + + // Get the parameters of the mother volume + double rOuter1 = mother_shape.rMax1(); + double rOuter2 = mother_shape.rMax2(); + double length = 2 * mother_shape.dZ(); + + double sensitive_thickness = 100 * mm; + + //Calculate R or cone after sensitive layer + double rEnd = rOuter2 - (rOuter2 - rOuter1) * sensitive_thickness / length; + double zPos = length / 2.0 - sensitive_thickness / 2.0; + if (detStart) { + rEnd = rOuter1 - (rOuter1 - rOuter2) * sensitive_thickness / length; + zPos = -length / 2.0 + sensitive_thickness / 2.0; + } + + ConeSegment s_start_disk(sensitive_thickness / 2, 0.0, rOuter2, 0.0, rEnd); + Volume v_start_disk("stop_disk_" + motherName, s_start_disk, m_Vacuum); + + v_start_disk.setLimitSet(description, "kill_limits"); + + auto disk_placement = mother_vol.placeVolume(v_start_disk, Position(0.0, 0.0, zPos)); + + sdet.setPlacement(disk_placement); + description.declareParent(det_name, mother); + + return sdet; +} + +DECLARE_DETELEMENT(BeamPipeStop, create_detector) diff --git a/src/BeamPipeTracking_geo.cpp b/src/BeamPipeTracking_geo.cpp new file mode 100644 index 000000000..d8f4d2953 --- /dev/null +++ b/src/BeamPipeTracking_geo.cpp @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Simon Gardner + +//========================================================================== +// +// Places a small sensitive disk of vacuum at the end of beam pipes +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "TMath.h" +#include + +using namespace std; +using namespace dd4hep; + +static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) { + + using namespace ROOT::Math; + xml_det_t x_det = e; + string det_name = x_det.nameStr(); + int det_id = x_det.id(); + Material m_Vacuum = description.material("Vacuum"); + string vis_name = dd4hep::getAttrOrDefault(x_det, _Unicode(vis), "BeamPipeVis"); + + sens.setType("tracker"); + + DetElement sdet(det_name, det_id); + Assembly assembly(det_name + "_assembly"); + + // Grab info for beamline magnets + for (xml_coll_t slice_coll(x_det, _Unicode(slice)); slice_coll; slice_coll++) { // pipes + + string grandmotherName = slice_coll.attr(_Unicode(grandmother)); + string motherName = slice_coll.attr(_Unicode(mother)); + bool detStart = getAttrOrDefault(slice_coll, _Unicode(end), true); + int pipe_id = getAttrOrDefault(slice_coll, _Unicode(pipe_id), 0); + string slice_name = slice_coll.attr(_Unicode(name)); + DetElement mother = description.detector(grandmotherName).child(motherName); + + // Get the mother volume + Volume mother_vol = mother.volume(); + + // Get mother volume shape as cone segment + ConeSegment mother_shape = mother_vol.solid(); + + // Get the parameters of the mother volume + double rOuter1 = mother_shape.rMax1(); + double rOuter2 = mother_shape.rMax2(); + double length = 2 * mother_shape.dZ(); + + double sensitive_thickness = 0.1 * mm; + + //Calculate R or cone after sensitive layer + + double rEnd = rOuter2 - (rOuter2 - rOuter1) * sensitive_thickness / length; + double zPos = length / 2.0 - sensitive_thickness / 2.0; + if (detStart) { + rEnd = rOuter1 - (rOuter1 - rOuter2) * sensitive_thickness / length; + zPos = -length / 2.0 + sensitive_thickness / 2.0; + } + + ConeSegment s_start_disk(sensitive_thickness / 2, 0.0, rOuter2, 0.0, rEnd); + Volume v_start_disk("v_start_disk_" + motherName, s_start_disk, m_Vacuum); + v_start_disk.setSensitiveDetector(sens); + + auto disk_placement = mother_vol.placeVolume(v_start_disk, Position(0.0, 0.0, zPos)); + disk_placement.addPhysVolID("end", detStart); + disk_placement.addPhysVolID("pipe", pipe_id); + disk_placement.addPhysVolID("system", det_id); + + DetElement slice_element(sdet, slice_name, pipe_id); + + slice_element.setPlacement(disk_placement); + description.declareParent(slice_name, mother); + } + + auto pv_assembly = description.worldVolume().placeVolume(assembly, Position(0.0, 0.0, 0.0)); + pv_assembly.addPhysVolID("system", det_id); + sdet.setPlacement(pv_assembly); + + return sdet; +} + +DECLARE_DETELEMENT(BeamPipeTracking, create_detector) diff --git a/templates/epic.xml.jinja2 b/templates/epic.xml.jinja2 index 0472526f2..c3729f8f5 100644 --- a/templates/epic.xml.jinja2 +++ b/templates/epic.xml.jinja2 @@ -71,6 +71,9 @@ + + +