Commit 7f31c86d authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Added parameterized vertex tracker

 - Vertex tracker endcaps are simple disk trackers.
parent c1f89473
Pipeline #8253 failed with stages
in 3 minutes and 27 seconds
......@@ -16,7 +16,7 @@ set(a_lib_name reference_detector)
dd4hep_configure_output()
dd4hep_add_plugin(${a_lib_name} SOURCES src/*.cpp
# USES ActsCore ActsPluginDD4hep
USES ActsCore ActsPluginDD4hep
)
target_link_libraries(${a_lib_name}
PUBLIC DD4hep::DDCore DD4hep::DDRec
......
......@@ -3,6 +3,32 @@
<comment> Central Barrel Vertex Detector </comment>
<define>
<constant name="cb_VTX_Barrel_rmin" value="VertexTrackerInnerRadius"/>
<constant name="cb_VTX_Barrel_rmax" value="VertexTrackerOuterRadius"/>
<constant name="cb_VTX_Barrel_length" value="VertexTrackerOuterBarrelLength"/>
<constant name="cb_VTX_Barrel_x_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_y_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_z_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_layer" value="6"/>
<comment> Need to cleanup and be more consistent with naming here </comment>
<constant name="VertexTrackerBarrelLength" value="400.0*mm"/>
<constant name="SiVertexEndcapP_rmin" value="VertexTrackerInnerRadius"/>
<constant name="SiVertexEndcapP_rmax" value="VertexTrackerOuterRadius"/>
<constant name="SiVertexEndcapP_zmin" value="VertexTrackerBarrelLength + 5*mm"/>
<constant name="SiVertexEndcapN_rmin" value="VertexTrackerInnerRadius"/>
<constant name="SiVertexEndcapN_rmax" value="VertexTrackerOuterRadius"/>
<constant name="SiVertexEndcapN_zmin" value="VertexTrackerBarrelLength + 5*mm"/>
<constant name="SiVertexEndcap_NLayers" value="5"/>
<constant name="SiVertexEndcapP_zmax" value="VertexTrackingRegion_length/2 - SiVertexEndcapN_zmin"/>
<constant name="SiVertexEndcapP_zmax" value="VertexTrackingRegion_length/2 - SiVertexEndcapN_zmin"/>
<constant name="SiVertexEndcap_delta" value="(SiVertexEndcapP_zmax - SiVertexEndcapP_zmin)/SiVertexEndcap_NLayers"/>
</define>
<limits>
......@@ -15,6 +41,16 @@
</display>
<detectors>
<detector id="SiVertexSubAssembly_ID"
name="SiVertexSubAssembly"
type="DD4hep_SubdetectorAssembly"
vis="SiTrackerSubAssemblyVis">
<composite name="SiVertexEndcapN"/>
<composite name="SiVertexEndcapP"/>
<composite name="cb_VTX_Barrel"/>
</detector>
<detector id="cb_VTX_Barrel_ID" name="cb_VTX_Barrel" type="cb_VTX_Barrel" readout="cb_VTX_Barrel_Hits" vis="cb_VTX_BarrelVis" insideTrackingVloume="true">
<dimensions rmin="cb_VTX_Barrel_rmin" rmax="cb_VTX_Barrel_rmax" length="cb_VTX_Barrel_length"/>
<position x="cb_VTX_Barrel_x_pos" y="cb_VTX_Barrel_y_pos" z="cb_VTX_Barrel_z_pos"/>
......@@ -22,6 +58,76 @@
<slice name="Silicon_slice" material="Si" sensitive="true"/>
</layer>
</detector>
<detector id="SiVertexEndcapP_ID" name="SiVertexEndcapP" type="ref_DiskTracker"
insideTrackingVolume="true" reflect="false" vis="Argonne_Red">
<position x="0" y="0" z="0"/>
<layer id="1" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 0*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="2" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 1*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="3" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 2*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="4" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 3*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="5" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 4*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
</detector>
<detector id="SiVertexEndcapN_ID" name="SiVertexEndcapN" type="ref_DiskTracker"
insideTrackingVolume="true" reflect="true" vis="Argonne_Red">
<position x="0" y="0" z="0"/>
<layer id="1" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 0*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="2" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 1*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="3" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 2*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="4" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 3*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="5" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 4*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
</detector>
</detectors>
<readouts>
......
......@@ -69,6 +69,11 @@
Layer 5 subassembly ID: 30
</comment>
<constant name="cb_VTX_Barrel_ID" value="25"/>
<constant name="SiVertexBarrel_ID" value="cb_VTX_Barrel_ID"/>
<constant name="SiVertexSubAssembly_ID" value="26"/>
<constant name="SiVertexEndcapP_ID" value="30"/>
<constant name="SiVertexEndcapN_ID" value="40"/>
<comment>
Unused values reserved for vertex:
constant name="SiVertexSubAssemblyLayer1_ID" value="121"
......@@ -338,19 +343,9 @@
-------------------------
</comment>
<constant name="VertexTrackerInnerRadius" value="30.0*mm"/>
<constant name="VertexTrackerOuterRadius" value="90.0*mm"/>
<constant name="VertexTrackerOuterRadius" value="150.0*mm"/>
<constant name="VertexTrackerOuterBarrelLength" value="400.0*mm"/>
<constant name="cb_VTX_Barrel_rmin" value="33.0*mm"/>
<constant name="cb_VTX_Barrel_rmax" value="165.0*mm"/>
<constant name="cb_VTX_Barrel_length" value="740.0*mm"/>
<constant name="cb_VTX_Barrel_x_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_y_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_z_pos" value="0.0*mm"/>
<constant name="cb_VTX_Barrel_layer" value="6"/>
<comment>
--------------------------
Silicon Tracker Parameters
......@@ -368,8 +363,9 @@
The central tracking detectors are assumed to be symmtric about the origin.
</comment>
<constant name="CentralTracking_rmax" value="SiliconTrackerOuterRadius"/>
<constant name="CentralTracking_length" value="SiliconTrackerOuterBarrelLength + ForwardTrackingGEMLength"/>
<constant name="CentralTracking_rmax" value="SiliconTrackerOuterRadius"/>
<constant name="CentralTracking_length" value="SiliconTrackerOuterBarrelLength + ForwardTrackingGEMLength"/>
<constant name="VertexTrackingRegion_length" value="SiliconTrackerOuterBarrelLength"/>
<comment> These are used by ddsim </comment>
<constant name="tracker_region_rmax" value="Solenoid_rmax/2.0"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<lccdd>
<define>
<constant name="VertexTrackerRadius1" value="30*mm"/>
<constant name="VertexTrackerRadius2" value="38*mm"/>
<constant name="VertexTrackerRadius3" value="46*mm"/>
<constant name="VertexTrackerRadius4" value="54*mm"/>
<constant name="VertexTrackerRadius5" value="62*mm"/>
<constant name="VertexTrackerRadius6" value="70*mm"/>
<constant name="VertexTrackerRadius7" value="78*mm"/>
<constant name="VertexTrackerRadius8" value="86*mm"/>
<constant name="VertexTrackerNModules1" value="14"/>
<constant name="VertexTrackerNModules2" value="18"/>
<constant name="VertexTrackerNModules3" value="22"/>
<constant name="VertexTrackerNModules4" value="24"/>
<constant name="VertexTrackerNModules5" value="28"/>
<constant name="VertexTrackerNModules6" value="32"/>
<constant name="VertexTrackerNModules7" value="36"/>
<constant name="VertexTrackerNModules8" value="40"/>
<constant name="VertexTrackerBarrelLength" value="400.0*mm"/>
<constant name="SiVertexEndcapP_rmin" value="VertexTrackerInnerRadius"/>
<constant name="SiVertexEndcapP_rmax" value="VertexTrackerOuterRadius"/>
<constant name="SiVertexEndcapP_zmin" value="VertexTrackerBarrelLength + 5*mm"/>
<constant name="SiVertexEndcapN_rmin" value="VertexTrackerInnerRadius"/>
<constant name="SiVertexEndcapN_rmax" value="VertexTrackerOuterRadius"/>
<constant name="SiVertexEndcapN_zmin" value="VertexTrackerBarrelLength + 5*mm"/>
<constant name="SiVertexEndcap_NLayers" value="5"/>
<constant name="SiVertexEndcapP_zmax" value="VertexTrackingRegion_length/2 - SiVertexEndcapN_zmin"/>
<constant name="SiVertexEndcapP_zmax" value="VertexTrackingRegion_length/2 - SiVertexEndcapN_zmin"/>
<constant name="SiVertexEndcap_delta" value="(SiVertexEndcapP_zmax - SiVertexEndcapP_zmin)/SiVertexEndcap_NLayers"/>
</define>
<display>
</display>
<detectors>
<detector id="SiVertexSubAssembly_ID"
name="SiVertexSubAssembly"
type="DD4hep_SubdetectorAssembly"
vis="SiTrackerSubAssemblyVis">
<composite name="SiVertexEndcapN"/>
<composite name="SiVertexEndcapP"/>
<composite name="SiVertexBarrel"/>
</detector>
<detector id="SiVertexBarrel_ID" name="SiVertexBarrel" type="refdet_SiVertexBarrel"
readout="SiVertexBarrelHits" insideTrackingVolume="true" >
<dimensions rmin="VertexTrackerRadius1-5*mm" rmax="VertexTrackerRadius8+5*mm" length="VertexTrackerBarrelLength+1.0*mm"/>
<comment> Define available modules </comment>
<module name="SOIPIXD" vis="PurpleVis">
<frame width="15*mm" height="3.0*mm" length="VertexTrackerBarrelLength" thickness="0.1 * mm" material="CarbonFiber_25percent" vis="BlueGreenVis" />
<module_component name="silicon" width="14.0*mm" length="VertexTrackerBarrelLength-0.1*mm"
thickness="0.05*mm" material="Silicon" sensitive="true">
<position z="-0.025*mm" y="0*mm"/>
</module_component>
</module>
<module name="UFSD">
<frame width="15*mm" height="3.0*mm" length="VertexTrackerBarrelLength" thickness="0.1 * mm" material="CarbonFiber_25percent" vis="BlueGreenVis" />
<module_component name="silicon" width="14.0*mm" length="VertexTrackerBarrelLength-0.1*mm"
thickness="0.05*mm" material="Silicon" sensitive="true">
<position z="-0.025*mm" y="0*mm"/>
</module_component>
</module>
<comment> Layers composed of many arrayed modules </comment>
<layer module="SOIPIXD" id="2" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius1+VertexTrackerRadius2)/2"
outer_r="(VertexTrackerRadius2+VertexTrackerRadius3)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules2" phi0="0.0" rc="VertexTrackerRadius2" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="UFSD" id="3" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius2+VertexTrackerRadius3)/2"
outer_r="(VertexTrackerRadius3+VertexTrackerRadius4)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules3" phi0="0.0" rc="VertexTrackerRadius3" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="UFSD" id="4" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius3+VertexTrackerRadius4)/2"
outer_r="(VertexTrackerRadius4+VertexTrackerRadius5)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules4" phi0="0.0" rc="VertexTrackerRadius4" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="UFSD" id="5" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius4+VertexTrackerRadius5)/2"
outer_r="(VertexTrackerRadius5+VertexTrackerRadius6)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules5" phi0="0.0" rc="VertexTrackerRadius5" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="UFSD" id="6" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius5+VertexTrackerRadius6)/2"
outer_r="(VertexTrackerRadius6+VertexTrackerRadius7)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules6" phi0="0.0" rc="VertexTrackerRadius6" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="SOIPIXD" id="7" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius6+VertexTrackerRadius7)/2"
outer_r="(VertexTrackerRadius7+VertexTrackerRadius8)/2" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules7" phi0="0.0" rc="VertexTrackerRadius7" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
<layer module="SOIPIXD" id="8" vis="InvisibleWithDaughters">
<barrel_envelope inner_r="(VertexTrackerRadius7+VertexTrackerRadius8)/2"
outer_r="VertexTrackerRadius8+5*mm" z_length="VertexTrackerBarrelLength+0.1*mm"/>
<rphi_layout phi_tilt="10.0*degree" nphi="VertexTrackerNModules8" phi0="0.0" rc="VertexTrackerRadius8" dr="0.0 * mm"/>
<z_layout dr="0.0 * mm" z0="0.0 * mm" nz="1"/>
</layer>
</detector>
<detector id="SiVertexEndcapP_ID" name="SiVertexEndcapP" type="ref_DiskTracker"
insideTrackingVolume="true" reflect="false" vis="Argonne_Red">
<position x="0" y="0" z="0"/>
<layer id="1" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 0*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="2" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 1*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="3" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 2*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="4" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 3*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="5" vis="Argonne_Orange"
inner_z="SiVertexEndcapP_zmin + 4*SiVertexEndcap_delta"
inner_r="SiVertexEndcapP_rmin"
outer_r="SiVertexEndcapP_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
</detector>
<detector id="SiVertexEndcapN_ID" name="SiVertexEndcapN" type="ref_DiskTracker"
insideTrackingVolume="true" reflect="true" vis="Argonne_Red">
<position x="0" y="0" z="0"/>
<layer id="1" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 0*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="2" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 1*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="3" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 2*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="4" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 3*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
<layer id="5" vis="Argonne_Orange"
inner_z="SiVertexEndcapN_zmin + 4*SiVertexEndcap_delta"
inner_r="SiVertexEndcapN_rmin"
outer_r="SiVertexEndcapN_rmax">
<slice material="Air" thickness="1.0*mm" vis="Argonne_Orange" />
</layer>
</detector>
</detectors>
<readouts>
<readout name="SiVertexBarrelHits">
<segmentation type="CartesianGridXY" grid_size_x="0.20*mm" grid_size_y="0.20*mm" />
<id>system:8,barrel:2,layer:4,module:12,sensor:2,x:32:-16,y:-16</id>
</readout>
<readout name="SiVertexEndcapHits">
<segmentation type="CartesianGridXY" grid_size_x="0.20*mm" grid_size_y="0.20*mm" />
<id>system:8,barrel:2,layer:4,module:12,sensor:2,x:32:-16,y:-16</id>
</readout>
</readouts>
</lccdd>
......@@ -127,8 +127,9 @@
<include ref="compact/B0_tracker.xml"/>
<include ref="compact/forward_romanpot.xml"/>
<include ref="compact/forward_offM_tracker.xml"/>
<include ref="compact/cb_VTX_Barrel.xml"/>
<include ref="compact/vertex_tracker.xml"/>
<!--
<include ref="compact/cb_VTX_Barrel.xml"/>
<include ref="compact/ci_HCAL.xml"/>
<include ref="compact/forward_rich.xml"/>
<include ref="compact/roman_pots.xml"/>
......
/** \addtogroup VertexTracker Vertex Trackers
* \brief Type: **SiVertexBarrel**.
* \author W. Armstrong
* \ingroup trackers
*
*
* \code
* \endcode
*
* @{
*/
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#include "DD4hep/Shapes.h"
#include "DDRec/Surface.h"
#include "DDRec/DetectorData.h"
#include "XML/Layering.h"
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Surfaces/PlanarBounds.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Surfaces/TrapezoidBounds.hpp"
#include "Acts/Definitions/Units.hpp"
using namespace std;
using namespace dd4hep;
using namespace dd4hep::rec;
using namespace dd4hep::detail;
static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
typedef vector<PlacedVolume> Placements;
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);
//Assembly assembly(det_name);
map<string, Volume> volumes;
map<string, Placements> sensitives;
map<string, xml_h> xmleles;
PlacedVolume pv;
dd4hep::xml::Dimension dimensions(x_det.dimensions());
Acts::ActsExtension* detWorldExt = new Acts::ActsExtension();
detWorldExt->addType("barrel", "detector");
sdet.addExtension<Acts::ActsExtension>(detWorldExt);
Tube topVolumeShape(dimensions.rmin(), dimensions.rmax(), dimensions.length() * 0.5);
Volume assembly(det_name,topVolumeShape,air);
sens.setType("tracker");
// loop over the modules
for (xml_coll_t mi(x_det, _U(module)); mi; ++mi) {
xml_comp_t x_mod = mi;
xml_comp_t m_env = x_mod.child(_U(frame));
string m_nam = x_mod.nameStr();
xmleles[m_nam] = x_mod;
// triangular volume envelope
double frame_thickness = m_env.thickness();
double frame_width = m_env.width();
double frame_height = getAttrOrDefault<double>(m_env, _U(height), 5.0 * mm);
double tanth = frame_height/(frame_width/2.0);
double frame_height2 = frame_height-frame_thickness-frame_thickness/tanth;
double frame_width2 = 2.0*frame_height2/tanth;
Trd1 moduleframe_part1(frame_width / 2, 0.001 * mm, m_env.length() / 2,
frame_height / 2);
Trd1 moduleframe_part2(frame_width2/2, 0.001 * mm,
m_env.length() / 2, frame_height2/2);
SubtractionSolid moduleframe(moduleframe_part1, moduleframe_part2,Position(0.0,frame_thickness,0.0));
Volume v_module(m_nam+"_vol", moduleframe, description.material(m_env.materialStr()));
v_module.setVisAttributes(description, m_env.visStr());
// module assembly
Assembly m_vol( m_nam );
m_vol.placeVolume(v_module, Position(0.0,0.0,frame_height/2));
int ncomponents = 0;
int sensor_number = 1;
if (volumes.find(m_nam) != volumes.end()) {
printout(ERROR, "SiTrackerBarrel", "Logics error in building modules.");
throw runtime_error("Logics error in building modules.");
}
volumes[m_nam] = m_vol;
m_vol.setVisAttributes(description.visAttributes(x_mod.visStr()));
for (xml_coll_t ci(x_mod, _U(module_component)); ci; ++ci, ++ncomponents) {
xml_comp_t x_comp = ci;
xml_comp_t x_pos = x_comp.position(false);
xml_comp_t x_rot = x_comp.rotation(false);
string c_nam = _toString(ncomponents, "component%d");
Box c_box(x_comp.width() / 2, x_comp.length() / 2, x_comp.thickness() / 2);
Volume c_vol(c_nam, c_box, description.material(x_comp.materialStr()));
if (x_pos && x_rot) {
Position c_pos(x_pos.x(0), x_pos.y(0), x_pos.z(0));
RotationZYX c_rot(x_rot.z(0), x_rot.y(0), x_rot.x(0));
pv = m_vol.placeVolume(c_vol, Transform3D(c_rot, c_pos));
} else if (x_rot) {
pv = m_vol.placeVolume(c_vol, RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)));
} else if (x_pos) {
pv = m_vol.placeVolume(c_vol, Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)));
} else {
pv = m_vol.placeVolume(c_vol);
}
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()) {
pv.addPhysVolID(_U(sensor), sensor_number++);
c_vol.setSensitiveDetector(sens);
sensitives[m_nam].push_back(pv);
}
}
}
// now build the layers
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));
xml_comp_t z_layout = x_layer.child(_U(z_layout)); // Get the <z_layout> element.
int lay_id = x_layer.id();
string m_nam = x_layer.moduleStr();
string lay_nam = _toString(x_layer.id(), "layer%d");
Tube lay_tub(x_barrel.inner_r()+0.1*mm, x_barrel.outer_r()-0.1*mm, x_barrel.z_length() / 2);
Volume lay_vol(lay_nam, lay_tub, air); // Create the layer envelope volume.
lay_vol.setVisAttributes(description.visAttributes(x_layer.visStr()));
double phi0 = x_layout.phi0(); // Starting phi of first module.
double phi_tilt = x_layout.phi_tilt(); // Phi tilt of a module.
double rc = x_layout.rc(); // Radius of the module center.
int nphi = x_layout.nphi(); // Number of modules in phi.
double rphi_dr = x_layout.dr(); // The delta radius of every other module.
double phi_incr = (M_PI * 2) / nphi; // Phi increment for one module.
double phic = phi0; // Phi of the module center.
double z0 = z_layout.z0(); // Z position of first module in phi.
double nz = z_layout.nz(); // Number of modules to place in z.
double z_dr = z_layout.dr(); // Radial displacement parameter, of every other module.
Volume module_env = volumes[m_nam];
DetElement lay_elt(sdet, _toString(x_layer.id(), "layer%d"), lay_id);
Placements& sensVols = sensitives[m_nam];
// the local coordinate systems of modules in dd4hep and acts differ
// see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html
Acts::ActsExtension* layerExtension = new Acts::ActsExtension();
layerExtension->addType("sensitive cylinder", "layer");
//layerExtension->addType("axes", "definitions", "XzY");
lay_elt.addExtension<Acts::ActsExtension>(layerExtension);
// 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 * z0) / (nz - 1) : 0.0;
// Starting z for module placement along Z axis.
double module_z = -z0;
int module = 1;
// Loop over the number of modules in phi.
for (int ii = 0; ii < nphi; ii++) {
double dx = z_dr * std::cos(phic + phi_tilt); // Delta x of module position.
double dy = z_dr * std::sin(phic + phi_tilt); // Delta y of module position.
double x = rc * std::cos(phic); // Basic x module position.
double y = rc * std::sin(phic); // Basic y module position.
// Loop over the number of modules in z.
for (int j = 0; j < nz; j++) {
string module_name = _toString(module, "module%d");
DetElement mod_elt(lay_elt, module_name, module);
Transform3D tr(RotationZYX(0, ((M_PI / 2) - phic - phi_tilt), -M_PI / 2),
Position(x, y, module_z));
pv = lay_vol.placeVolume(module_env, tr);
pv.addPhysVolID("module", module);
mod_elt.setPlacement(pv);
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(), module);
comp_de.setPlacement(sens_pv);
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension();
comp_de.addExtension<Acts::ActsExtension>(moduleExtension);
comp_de.setAttributes(description, sens_pv.volume(), x_layer.regionStr(), x_layer.limitsStr(),
xml_det_t(xmleles[m_nam]).visStr());
}
/// Increase counters etc.
module++;
// Adjust the x and y coordinates of the module.
x += dx;
y += dy;
// Flip sign of x and y adjustments.
dx *= -1;
dy *= -1;
// Add z increment to get next z placement pos.
module_z += z_incr;
}
phic += phi_incr; // Increment the phi placement of module.
rc += rphi_dr; // Increment the center radius according to dr parameter.
rphi_dr *= -1; // Flip sign of dr parameter.
module_z = -z0; // Reset the Z placement parameter for module.