-
Notifications
You must be signed in to change notification settings - Fork 45
Implement Celeritas-DD4hep integration plugin #1756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 37 commits
9d8d49c
926bf32
78c4a61
32a4c12
d88d5d0
2eb55b2
5e0c2b4
2e18c6f
518ed0b
242c8e7
db4682a
2d9531e
92ef544
45675e3
d8cb34b
3426206
ffdebc9
eab608a
e1b7f2e
247c802
544e71f
d382ba3
3ff27fc
c393a26
e3b43be
372ffbc
cd7c7f5
be6380d
06c2650
d3870b6
791c0f3
8fa69e1
3d8fa86
5bcf1c4
945037b
a99b483
e7565fb
10dda0c
71c5bf6
29543ed
2e6d880
2893153
962233c
938fd43
7a43205
acadfb8
a17b72c
193b27b
dabb8d3
f7d60ee
b6a68df
f853755
8e4dc01
b781260
f53a239
908143d
2209929
718d5ee
0f5e37c
2578b1e
bff4df5
b23e4c5
df18cec
1e996a7
f17d96c
d00b13a
8d222b0
f9721a7
9120784
0167a04
f8720bd
aca4052
e654cf2
667aaca
80a94a7
953a072
b416eb7
1b437a6
020c94b
92b18b7
93967bb
fdfbbf9
7c487c5
4f24883
41240e7
cf3684d
064e040
e89d113
ccda8f1
6ef1501
b0ea549
654795e
a5cb800
aeadd13
d865047
2f61586
c621268
9eaff43
d491cb1
965fc39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #------------------------------- -- cmake -- -------------------------------# | ||
| # Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| # SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| #-----------------------------------------------------------------------------# | ||
| cmake_minimum_required(VERSION 3.18) | ||
| project(CeleritasDD4hepExample VERSION 0.0.1 LANGUAGES CXX) | ||
| cmake_policy(VERSION 3.12...3.30) | ||
|
|
||
| # Find DD4hep | ||
| find_package(DD4hep REQUIRED COMPONENTS DDG4 DDRec DDAlign) | ||
|
|
||
| # Include DD4hep | ||
| include(${DD4hep_DIR}/cmake/DD4hep.cmake) | ||
|
|
||
| # Add the detector plugin | ||
| dd4hep_add_plugin(CeleritasDD4hep | ||
| SOURCES celeritas-dd4hep.cc | ||
| USES DD4hep::DDCore DD4hep::DDRec | ||
| ) | ||
|
|
||
| # Install the plugin | ||
| install(TARGETS CeleritasDD4hep | ||
| LIBRARY DESTINATION lib | ||
| ) | ||
|
|
||
|
||
| # Install the geometry files | ||
| install(FILES | ||
| celeritas-dd4hep.xml | ||
| DESTINATION share/CeleritasDD4hep | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| //------------------------------- -*- C++ -*- -------------------------------// | ||
| // Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| //---------------------------------------------------------------------------// | ||
| //! \file ddceler/celertias-dd4hep.cc | ||
| //---------------------------------------------------------------------------// | ||
|
|
||
| #include <cmath> | ||
|
|
||
| #include "DD4hep/DetFactoryHelper.h" | ||
| #include "DD4hep/Printout.h" | ||
| #include "XML/Layering.h" | ||
|
|
||
| using namespace std; | ||
| using namespace dd4hep; | ||
| using namespace dd4hep::detail; | ||
|
|
||
| static Ref_t | ||
| create_detector(Detector& description, xml_h e, SensitiveDetector sens) | ||
| { | ||
| xml_det_t x_det = e; | ||
| Material material = description.material(x_det.materialStr()); | ||
| string det_name = x_det.nameStr(); | ||
| string det_type = x_det.typeStr(); | ||
| string sens_type = x_det.attr<string>(Unicode("sens_type")); | ||
| int det_id = x_det.id(); | ||
|
|
||
| DetElement detector(det_name, det_id); | ||
|
|
||
| // Create an assembly volume for automatic envelope | ||
| Assembly assembly(det_name + "_assembly"); | ||
|
|
||
| // Set visualization attributes | ||
| if (x_det.hasAttr(_U(vis))) | ||
| { | ||
| assembly.setVisAttributes(description.visAttributes(x_det.visStr())); | ||
| } | ||
|
|
||
| // Set sensor type | ||
| if (sens.isValid()) | ||
| { | ||
| sens.setType(sens_type.c_str()); | ||
| } | ||
|
|
||
| // Create layers | ||
| int layer_num = 0; | ||
| for (xml_coll_t c(x_det, _U(layer)); c; ++c) | ||
| { | ||
| xml_comp_t x_layer = c; | ||
| layer_num++; | ||
|
|
||
| double layer_rmin = x_layer.inner_r(); | ||
| double layer_rmax = x_layer.outer_r(); | ||
| double layer_z = x_layer.z_length(); | ||
|
|
||
| // Create layer tube | ||
| Tube layer_tube(layer_rmin, layer_rmax, layer_z / 2.0); | ||
| Volume layer_vol( | ||
| det_name + "_layer_" + to_string(layer_num), layer_tube, material); | ||
|
|
||
| // Set sensitivity if this is an active detector | ||
| if (sens.isValid()) | ||
| { | ||
| layer_vol.setSensitiveDetector(sens); | ||
| } | ||
|
|
||
| // Create detector element for this layer | ||
| DetElement layer_det( | ||
| detector, "layer_" + to_string(layer_num), layer_num); | ||
|
|
||
| // Place the layer in the assembly | ||
| PlacedVolume layer_pv = assembly.placeVolume(layer_vol); | ||
| layer_pv.addPhysVolID("layer", layer_num); | ||
| layer_det.setPlacement(layer_pv); | ||
|
|
||
| printout(DEBUG, | ||
| "SimpleCylindrical", | ||
| "Created layer %d: rmin=%.1f mm, rmax=%.1f mm, z=%.1f mm", | ||
| layer_num, | ||
| layer_rmin / mm, | ||
| layer_rmax / mm, | ||
| layer_z / mm); | ||
| } | ||
|
|
||
| // Create the detector element and place it in the world | ||
| Volume mother_vol = description.pickMotherVolume(detector); | ||
| PlacedVolume detector_pv = mother_vol.placeVolume(assembly); | ||
| detector_pv.addPhysVolID("system", det_id); | ||
| detector.setPlacement(detector_pv); | ||
|
|
||
| printout(INFO, | ||
| "SimpleCylindrical", | ||
| "Created detector '%s' with %d layers", | ||
| det_name.c_str(), | ||
| layer_num); | ||
|
|
||
| return detector; | ||
| } | ||
|
|
||
| // Register the detector constructor | ||
| DECLARE_DETELEMENT(SimpleCylindrical, create_detector) |
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" | ||
| xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
| xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> | ||
|
|
||
| <info name="CeleritasDD4hep" title="Celeritas DD4hep Geometry" author="Sakib Rahman" url="http://dd4hep.cern.ch" status="development" version="1.0"> | ||
| <comment> | ||
| ------------------------------- -*- XML -*- --------------------------------- | ||
| Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| ----------------------------------------------------------------------------- | ||
| \file ddceler/celertias-dd4hep.xml | ||
| ----------------------------------------------------------------------------- | ||
| Minimal detector geometry with a calorimeter and 2 tracker layers to test the | ||
| celeritas-dd4hep integration plugin | ||
| ----------------------------------------------------------------------------- | ||
| </comment> | ||
| </info> | ||
|
|
||
| <define> | ||
| <!-- World dimensions --> | ||
| <constant name="world_side" value="5*m"/> | ||
| <constant name="world_x" value="world_side"/> | ||
| <constant name="world_y" value="world_side"/> | ||
| <constant name="world_z" value="world_side"/> | ||
| <constant name="tracker_region_rmax" value="world_side"/> | ||
| <constant name="tracker_region_zmax" value="world_side"/> | ||
|
|
||
| <!-- Beampipe parameters --> | ||
| <constant name="beampipe_inner_radius" value="15*mm"/> | ||
| <constant name="beampipe_outer_radius" value="17*mm"/> | ||
| <constant name="beampipe_length" value="2000*mm"/> | ||
| <constant name="beampipe_thickness" value="beampipe_outer_radius - beampipe_inner_radius"/> | ||
|
|
||
| <!-- Tracker parameters --> | ||
| <constant name="tracker_inner_radius" value="20*mm"/> | ||
| <constant name="tracker_outer_radius" value="200*mm"/> | ||
| <constant name="tracker_layer1_radius" value="50*mm"/> | ||
| <constant name="tracker_layer2_radius" value="100*mm"/> | ||
| <constant name="tracker_layer_thickness" value="0.3*mm"/> | ||
| <constant name="tracker_length" value="600*mm"/> | ||
|
|
||
| <!-- Calorimeter parameters --> | ||
| <constant name="calorimeter_inner_radius" value="250*mm"/> | ||
| <constant name="calorimeter_outer_radius" value="800*mm"/> | ||
| <constant name="calorimeter_length" value="1200*mm"/> | ||
|
|
||
| <!-- Field parameters --> | ||
| <constant name="field_strength" value="3.0*tesla"/> | ||
| </define> | ||
|
|
||
| <includes> | ||
| <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> | ||
| </includes> | ||
|
|
||
| <materials> | ||
| <!-- Basic elements --> | ||
| <material name="Air" formula="N0.78O0.22Ar0.01"> | ||
| <D unit="g/cm3" value="0.0012"/> | ||
| <composite n="0.78" ref="N"/> | ||
| <composite n="0.22" ref="O"/> | ||
| <composite n="0.01" ref="Ar"/> | ||
| </material> | ||
|
|
||
| <material name="Silicon" formula="Si"> | ||
| <D unit="g/cm3" value="2.33"/> | ||
| <composite n="1" ref="Si"/> | ||
| </material> | ||
|
|
||
| <material name="Lead" formula="Pb"> | ||
| <D unit="g/cm3" value="11.34"/> | ||
| <composite n="1" ref="Pb"/> | ||
| </material> | ||
|
|
||
| <material name="Beryllium" formula="Be"> | ||
| <D unit="g/cm3" value="1.85"/> | ||
| <composite n="1" ref="Be"/> | ||
| </material> | ||
|
|
||
| <material name="Scintillator"> | ||
| <D unit="g/cm3" value="1.032"/> | ||
| <composite n="9" ref="C"/> | ||
| <composite n="10" ref="H"/> | ||
| </material> | ||
|
|
||
| <!-- Vacuum for world volume --> | ||
| <material name="Vacuum"> | ||
| <D unit="g/cm3" value="1e-25"/> | ||
| <composite n="1" ref="H"/> | ||
| </material> | ||
| </materials> | ||
|
|
||
| <limits> | ||
| <limitset name="cal_limits"> | ||
| <limit name="step_length_max" particles="*" value="5.0" unit="mm"/> | ||
| </limitset> | ||
| </limits> | ||
|
|
||
| <regions> | ||
| <region name="BeamPipeRegion" eunit="MeV" lunit="mm" cut="0.001" threshold="0.001"/> | ||
| <region name="TrackerRegion" eunit="MeV" lunit="mm" cut="0.001" threshold="0.001"/> | ||
| <region name="CalorimeterRegion" eunit="MeV" lunit="mm" cut="0.001" threshold="0.001"/> | ||
| </regions> | ||
|
|
||
| <display> | ||
| <vis name="InvisibleNoDaughters" showDaughters="false" visible="false"/> | ||
| <vis name="InvisibleWithDaughters" showDaughters="true" visible="false"/> | ||
| <vis name="WorldVis" showDaughters="true" visible="false"/> | ||
| <vis name="BeampipeVis" alpha="0.3" r="0.5" g="0.5" b="0.5" showDaughters="true" visible="true"/> | ||
| <vis name="TrackerVis" alpha="0.5" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> | ||
| <vis name="CalorimeterVis" alpha="0.5" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> | ||
| </display> | ||
|
|
||
| <detectors> | ||
| <detector id="0" name="Beampipe" type="SimpleCylindrical" vis="BeampipeVis" sens_type="passive"> | ||
| <layer id="1" inner_r="beampipe_inner_radius" outer_r="beampipe_outer_radius" z_length="beampipe_length"/> | ||
| <material name="Beryllium"/> | ||
| </detector> | ||
|
|
||
| <detector id="1" name="InnerTracker" type="SimpleCylindrical" readout="TrackerHits" vis="TrackerVis" sens_type="tracker"> | ||
| <layer id="1" inner_r="tracker_layer1_radius" outer_r="tracker_layer1_radius + tracker_layer_thickness" z_length="tracker_length" /> | ||
| <layer id="2" inner_r="tracker_layer2_radius" outer_r="tracker_layer2_radius + tracker_layer_thickness" z_length="tracker_length" /> | ||
| <material name="Silicon"/> | ||
| </detector> | ||
|
|
||
| <detector id="2" name="Calorimeter" type="SimpleCylindrical" readout="CalorimeterHits" vis="CalorimeterVis" sens_type="calorimeter"> | ||
| <layer id="1" inner_r="calorimeter_inner_radius" outer_r="calorimeter_outer_radius" z_length="calorimeter_length"/> | ||
| <material name="Lead"/> | ||
| </detector> | ||
| </detectors> | ||
|
|
||
| <readouts> | ||
| <readout name="TrackerHits"> | ||
| <segmentation type="CartesianGridXY" grid_size_x="0.1*mm" grid_size_y="0.1*mm"/> | ||
| <id>system:8,layer:4,x:32:-16,y:-16</id> | ||
| </readout> | ||
|
|
||
| <readout name="CalorimeterHits"> | ||
| <segmentation type="CartesianGridXY" grid_size_x="10*mm" grid_size_y="10*mm"/> | ||
| <id>system:8,layer:4,x:32:-16,y:-16</id> | ||
| </readout> | ||
| </readouts> | ||
|
|
||
| <fields> | ||
| <field name="UniformSolenoid" type="solenoid" strength="field_strength" inner_field="field_strength" outer_field="field_strength" zmin="-1.0*world_side" zmax="world_side" inner_radius="world_side" outer_radius="2.0*world_side"/> | ||
| </fields> | ||
|
|
||
| </lccdd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? We don't use it in epic, but we use it in npsim...