From 3ef3ea5c2f441e1025b269722edf990e28cee75f Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Wed, 14 Aug 2013 08:34:39 +0000
Subject: [PATCH] - added example implemetation for Calice test beam
calorimeters: CaliceTbeam (Shaojun Lu, DESY)
---
CMakeLists.txt | 1 +
DDExamples/CaliceTbeam/CMakeLists.txt | 73 +++++++
DDExamples/CaliceTbeam/README.txt | 10 +
DDExamples/CaliceTbeam/compact/AHcal.xml | 83 ++++++++
.../CaliceTbeam/compact/Calice_testbeam.xml | 177 ++++++++++++++++
DDExamples/CaliceTbeam/compact/DHcal.xml | 85 ++++++++
DDExamples/CaliceTbeam/compact/SiWEcal.xml | 86 ++++++++
DDExamples/CaliceTbeam/compact/Tcmt.xml | 89 ++++++++
DDExamples/CaliceTbeam/compact/geant4SD.xml | 31 +++
DDExamples/CaliceTbeam/compact/materials.xml | 156 ++++++++++++++
DDExamples/CaliceTbeam/run_g4.mac | 26 +++
.../src/compact/CalotbeamBox_geo.cpp | 191 ++++++++++++++++++
12 files changed, 1008 insertions(+)
create mode 100644 DDExamples/CaliceTbeam/CMakeLists.txt
create mode 100644 DDExamples/CaliceTbeam/README.txt
create mode 100644 DDExamples/CaliceTbeam/compact/AHcal.xml
create mode 100644 DDExamples/CaliceTbeam/compact/Calice_testbeam.xml
create mode 100644 DDExamples/CaliceTbeam/compact/DHcal.xml
create mode 100644 DDExamples/CaliceTbeam/compact/SiWEcal.xml
create mode 100644 DDExamples/CaliceTbeam/compact/Tcmt.xml
create mode 100644 DDExamples/CaliceTbeam/compact/geant4SD.xml
create mode 100644 DDExamples/CaliceTbeam/compact/materials.xml
create mode 100644 DDExamples/CaliceTbeam/run_g4.mac
create mode 100644 DDExamples/CaliceTbeam/src/compact/CalotbeamBox_geo.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ec365bb6..baeec6285 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,7 @@ if( DD4HEP_WITH_LCIO )
add_subdirectory(DDExamples/ILDExDet)
add_subdirectory(DDExamples/ILDExReco)
add_subdirectory(DDExamples/ILDExTest)
+add_subdirectory(DDExamples/CaliceTbeam)
endif()
diff --git a/DDExamples/CaliceTbeam/CMakeLists.txt b/DDExamples/CaliceTbeam/CMakeLists.txt
new file mode 100644
index 000000000..0ea4c7045
--- /dev/null
+++ b/DDExamples/CaliceTbeam/CMakeLists.txt
@@ -0,0 +1,73 @@
+cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
+
+
+##----- check if LCIO is available
+#find_package(LCIO QUIET)
+#
+#if( NOT LCIO_FOUND ) # downlaod and build LCIO
+#
+# INCLUDE( ExternalProject )
+#
+# set( lcio_download_url SVN_REPOSITORY "svn://svn.freehep.org/lcio/trunk" )
+#
+# set( lcio_cmake_args
+# "-DLCIO_GENERATE_HEADERS=OFF"
+# "-DINSTALL_JAR=OFF"
+# "-DBUILD_LCIO_EXAMPLES=OFF"
+# "-DBUILD_ROOTDICT=OFF"
+# "-DBUILD_F77_TESTJOBS=OFF"
+# )
+#
+# ExternalProject_Add( LCIO
+# ${lcio_download_url}
+# CMAKE_ARGS ${lcio_cmake_args} install
+# PREFIX ${DD4hep_BINARY_DIR}/dependencies
+# )
+#
+# MESSAGE( STATUS "=============== Adding LCIO as external project ====================" )
+# MESSAGE( STATUS " to use an existing LCIO installation please specify -D LCIO_DIR=path_to_lcio !! " )
+# MESSAGE( STATUS "======================================================================" )
+#
+# set(LCIO_INCLUDE_DIRS "${DD4hep_BINARY_DIR}/dependencies/src/LCIO/include" )
+#
+# set(LCIO_LIBRARIES
+# "${DD4hep_BINARY_DIR}/dependencies/src/LCIO/lib/${CMAKE_SHARED_LIBRARY_PREFIX}sio${CMAKE_SHARED_LIBRARY_SUFFIX}"
+# "${DD4hep_BINARY_DIR}/dependencies/src/LCIO/lib/${CMAKE_SHARED_LIBRARY_PREFIX}lcio${CMAKE_SHARED_LIBRARY_SUFFIX}"
+# )
+#
+#endif()
+##-------------- lcio -------------------
+
+
+
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/DDCore/include
+ ${ROOT_INCLUDE_DIR}
+ ${LCIO_INCLUDE_DIRS})
+
+file(GLOB sources src/*.cpp src/compact/*.cpp)
+file(GLOB headers include/*.h)
+
+include(DD4hep_XML_setup)
+
+if(DD4HEP_USE_PYROOT)
+ ROOT_GENERATE_DICTIONARY(G__CaliceTbeamEx ${headers} LINKDEF include/ROOT/LinkDef.h)
+ list(APPEND sources G__CaliceTbeamEx.cxx)
+#fg: removing these causes undefined symbols in libILdEx.so/.dylib
+# list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/src/VersatileDiskRowLayoutSeg.cpp)
+# list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/src/VersatileDiskRowLayout.cpp)
+endif()
+
+add_library(CaliceTbeamEx SHARED ${sources})
+target_link_libraries(CaliceTbeamEx DD4hepCore ${LCIO_LIBRARIES})
+#---Rootmap generation--------------------------------------------------------------
+dd4hep_generate_rootmap(CaliceTbeamEx)
+
+#--- install target-------------------------------------
+
+install(TARGETS CaliceTbeamEx
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ )
+# to do: add corresponding uninstall...
+#-------------------------------------------------------
\ No newline at end of file
diff --git a/DDExamples/CaliceTbeam/README.txt b/DDExamples/CaliceTbeam/README.txt
new file mode 100644
index 000000000..1b2d49eed
--- /dev/null
+++ b/DDExamples/CaliceTbeam/README.txt
@@ -0,0 +1,10 @@
+A driver for CALICE tesbeam box prototype.
+Examples of compact for individual SiwEcal, Ahcal, DHcal and Tcmt.
+Example of compact for testbeam with SiwEcal, Ahcal and Tcmt.
+
+
+[1] ./bin/ILDExSimu -i file:../DDExamples/CaliceTbeam/compact/Calice_testbeam.xml file:../DDExamples/CaliceTbeam/compact/geant4SD.xml
+ ./bin/ILDExSimu file:../DDExamples/CaliceTbeam/compact/Calice_testbeam.xml file:../DDExamples/CaliceTbeam/compact/geant4SD.xml ../DDExamples/CaliceTbeam/run_g4.mac
+[2] geoConverter -compact2lcdd -input Calice_testbeam.xml -output Calice_testbeam.lcdd
+[2] slic -n -g Calice_testbeam.lcdd
+
diff --git a/DDExamples/CaliceTbeam/compact/AHcal.xml b/DDExamples/CaliceTbeam/compact/AHcal.xml
new file mode 100644
index 000000000..dfd66d5a7
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/AHcal.xml
@@ -0,0 +1,83 @@
+<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="CALICE_TB_Calo"
+ title="CALICE testbeam calo detectors model"
+ author="S. Lu"
+ url="http://ilcsoft.desy.de"
+ status="development"
+ version="$Id: CALICETb.xml Lu $">
+ <comment>The compact format for the CALICE testbeam Detector - toy model </comment>
+ </info>
+
+ <includes>
+ <gdmlFile ref="elements.xml"/>
+ <gdmlFile ref="materials.xml"/>
+ <pyBuilder ref="../drivers"/>
+ </includes>
+
+ <define>
+ <constant name="world_side" value="10*m"/>
+ <constant name="world_x" value="world_side/2"/>
+ <constant name="world_y" value="world_side/2"/>
+ <constant name="world_z" value="world_side/2"/>
+
+ <constant name="TBAHcal_cell_size" value="30*mm"/> <!-- CellSize 30*mm-->
+ <constant name="TBAHcal_cell_Imax" value="30"/> <!-- HBU 24 -->
+ <constant name="TBAHcal_cell_Jmax" value="30"/> <!-- HBU 24 -->
+ <constant name="TBAHcal_layers" value="38"/> <!-- Total Layers -->
+ <constant name="Hcal_chamber_thickness" value="17.5*mm"/>
+ <constant name="Hcal_radiator_thickness" value="20.0*mm"/>
+ <constant name="TBAHcal_layer_thickness" value="Hcal_radiator_thickness+Hcal_chamber_thickness"/>
+
+ <constant name="TBAHcal_position" value="3000.0*mm"/>
+ </define>
+
+ <limits>
+ <limitset name="cal_limits">
+ <limit name="step_length_max" particles="*" value="30.0" unit="mm" />
+ </limitset>
+ </limits>
+
+ <display>
+ <vis name="AHcalVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="AHcalRadiatorVis" alpha="1" r="0.69" g="0.77" b="0.87"showDaughters="true" visible="true"/>
+ <vis name="AHcalLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="AHcalSensorVis" alpha="1" r="0" g="1" b="1" showDaughters="true" visible="true"/>
+ <vis name="AHcalFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="AHcalCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="AHcalAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+ </display>
+
+ <detectors>
+ <detector id="7" name="AHcal" type="CalotbeamBox" readout="AHcalHits" vis="AHcalVis" calorimeterType="HCAL">
+ <comment>Analog Hadron Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="TBAHcal_cell_size*TBAHcal_cell_Imax" y="TBAHcal_cell_size*TBAHcal_cell_Jmax" z="TBAHcal_layer_thickness*TBAHcal_layers+20.0"/>
+ <position x="0" y="0" z="TBAHcal_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="(int) TBAHcal_layers">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="AHcalRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="AHcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="AHcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="AHcalCuVis" />
+ <slice material = "Air" thickness = "7.7*mm" /> <!--vis="AHcalAirVis" /-->
+ </layer>
+ <layer repeat="(int) 1">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="AHcalRadiatorVis" />
+ </layer>
+ </layers>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="AHcalHits">
+ <segmentation type="GlobalGridXY" gridSizeX="30.0*mm" gridSizeY="30.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+
+</lccdd>
diff --git a/DDExamples/CaliceTbeam/compact/Calice_testbeam.xml b/DDExamples/CaliceTbeam/compact/Calice_testbeam.xml
new file mode 100644
index 000000000..de0f659a1
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/Calice_testbeam.xml
@@ -0,0 +1,177 @@
+<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="CALICE_TB_Calo"
+ title="CALICE testbeam calo detectors model"
+ author="S. Lu"
+ url="http://ilcsoft.desy.de"
+ status="development"
+ version="$Id: CALICETb.xml Lu $">
+ <comment>The compact format for the CALICE testbeam Detector - toy model </comment>
+ </info>
+
+ <includes>
+ <gdmlFile ref="elements.xml"/>
+ <gdmlFile ref="materials.xml"/>
+ <pyBuilder ref="../drivers"/>
+ </includes>
+
+ <define>
+ <constant name="world_side" value="10*m"/>
+ <constant name="world_x" value="world_side/2"/>
+ <constant name="world_y" value="world_side/2"/>
+ <constant name="world_z" value="world_side/2"/>
+
+ <constant name="TBAHcal_cell_size" value="30*mm"/> <!-- CellSize 30*mm-->
+ <constant name="TBAHcal_cell_Imax" value="30"/> <!-- HBU 24 -->
+ <constant name="TBAHcal_cell_Jmax" value="30"/> <!-- HBU 24 -->
+ <constant name="TBAHcal_layers" value="38"/> <!-- Total Layers -->
+ <constant name="Hcal_chamber_thickness" value="17.5*mm"/>
+ <constant name="Hcal_radiator_thickness" value="20.0*mm"/>
+ <constant name="TBAHcal_layer_thickness" value="Hcal_radiator_thickness+Hcal_chamber_thickness"/>
+
+ <constant name="TBSiWcal_position" value="2000.0*mm"/>
+ <constant name="TBAHcal_position" value="3000.0*mm"/>
+ <constant name="TBTcmt_position" value="4500.0*mm"/>
+ </define>
+
+ <limits>
+ <limitset name="cal_limits">
+ <limit name="step_length_max" particles="*" value="5.0" unit="mm" />
+ </limitset>
+ </limits>
+
+ <display>
+ <vis name="SiWEcalVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="SiWEcalRadiatorVis" alpha="1" r="0.47" g="0.53" b="0.6" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalSensorVis" alpha="1" r="0.96" g="0.64" b="0.38"showDaughters="true" visible="true"/>
+ <vis name="SiWEcalFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="SiWEcalCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+
+ <vis name="AHcalVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="AHcalRadiatorVis" alpha="1" r="0.69" g="0.77" b="0.87"showDaughters="true" visible="true"/>
+ <vis name="AHcalLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="AHcalSensorVis" alpha="1" r="0" g="1" b="1" showDaughters="true" visible="true"/>
+ <vis name="AHcalFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="AHcalCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="AHcalAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+
+ <vis name="TcmtVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="TcmtRadiatorVis" alpha="1" r="0.69" g="0.77" b="0.87"showDaughters="true" visible="true"/>
+ <vis name="TcmtLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="TcmtSensorVis" alpha="1" r="0" g="1" b="1" showDaughters="true" visible="true"/>
+ <vis name="TcmtFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="TcmtCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="TcmtAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+ </display>
+
+ <detectors>
+ <detector id="6" name="SiWEcal" type="CalotbeamBox" readout="SiWEcalHits" vis="SiWEcalVis" calorimeterType="ECAL">
+ <comment>The Silicon Tungsten ECAL Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="180.0*mm" y="180.0*mm" z="(5.0+6.4+7.8)*5.0*mm"/>
+ <position x="0" y="0" z="TBSiWcal_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "1.4*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "2.8*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "4.2*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ </layers>
+ </detector>
+
+ <detector id="7" name="AHcal" type="CalotbeamBox" readout="AHcalHits" vis="AHcalVis" calorimeterType="HCAL">
+ <comment>Analog Hadron Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="TBAHcal_cell_size*TBAHcal_cell_Imax" y="TBAHcal_cell_size*TBAHcal_cell_Jmax" z="TBAHcal_layer_thickness*TBAHcal_layers+20.0
+"/>
+ <position x="0" y="0" z="TBAHcal_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="(int) TBAHcal_layers">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="AHcalRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="AHcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="AHcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="AHcalCuVis" />
+ <slice material = "Air" thickness = "7.7*mm" /> <!--vis="AHcalAirVis" /-->
+ </layer>
+ <layer repeat="(int) 1">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="AHcalRadiatorVis" />
+ </layer>
+ </layers>
+ </detector>
+
+ <detector id="8" name="Tcmt" type="CalotbeamBox" readout="TcmtHits" vis="TcmtVis" calorimeterType="TCMT">
+ <comment>Analog Hadron Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="1080" y="1080" z="(26.5+46.5+66.5+10.0)*10.0+20.0"/>
+ <position x="0" y="0" z="TBTcmt_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "30.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "50.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="(int) 1">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="TcmtRadiatorVis" />
+ </layer>
+ </layers>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="SiWEcalHits">
+ <segmentation type="GlobalGridXY" gridSizeX="5.0*mm" gridSizeY="5.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ <readout name="AHcalHits">
+ <segmentation type="GlobalGridXY" gridSizeX="30.0*mm" gridSizeY="30.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ <readout name="TcmtHits">
+ <segmentation type="GlobalGridXY" gridSizeX="30.0*mm" gridSizeY="30.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+
+</lccdd>
diff --git a/DDExamples/CaliceTbeam/compact/DHcal.xml b/DDExamples/CaliceTbeam/compact/DHcal.xml
new file mode 100644
index 000000000..368b22294
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/DHcal.xml
@@ -0,0 +1,85 @@
+<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="CALICE_TB_Calo"
+ title="CALICE testbeam calo detectors model"
+ author="S. Lu"
+ url="http://ilcsoft.desy.de"
+ status="development"
+ version="$Id: CALICETb.xml Lu $">
+ <comment>The compact format for the CALICE testbeam Detector - toy model </comment>
+ </info>
+
+ <includes>
+ <gdmlFile ref="elements.xml"/>
+ <gdmlFile ref="materials.xml"/>
+ <pyBuilder ref="../drivers"/>
+ </includes>
+
+ <define>
+ <constant name="world_side" value="10*m"/>
+ <constant name="world_x" value="world_side/2"/>
+ <constant name="world_y" value="world_side/2"/>
+ <constant name="world_z" value="world_side/2"/>
+
+ <constant name="TBDHcal_position" value="3000.0*mm"/>
+ </define>
+
+ <limits>
+ <limitset name="cal_limits">
+ <limit name="step_length_max" particles="*" value="10.0" unit="mm" />
+ </limitset>
+ </limits>
+
+ <display>
+ <vis name="DHcalVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="DHcalRadiatorVis" alpha="1" r="0.69" g="0.77" b="0.87"showDaughters="true" visible="true"/>
+ <vis name="DHcalLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="DHcalSensorVis" alpha="1" r="0" g="1" b="1" showDaughters="true" visible="true"/>
+ <vis name="DHcalG10Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="DHcalMylarVis" alpha="1" r="1" g="1" b="0" showDaughters="true" visible="true"/>
+ <vis name="DHcalCarbonVis" alpha="1" r="0" g="0" b="0" showDaughters="true" visible="true"/>
+ <vis name="DHcalGlassVis" alpha="1" r="0" g="1" b="0" showDaughters="true" visible="true"/>
+ <vis name="DHcalAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+ </display>
+
+ <detectors>
+ <detector id="7" name="DHcal" type="CalotbeamBox" readout="DHcalHits" vis="DHcalVis" calorimeterType="HCAL">
+ <comment>Analog Hadron Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="960.0*mm" y="960.0*mm" z="26.8*40+20.0"/>
+ <position x="0" y="0" z="TBDHcal_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="(int) 40">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="DHcalRadiatorVis" />
+ <slice material = "G10" thickness = "1.6*mm" vis="DHcalG10Vis" /> <!--RPCElectronics -->
+ <slice material = "G10" thickness = "0.8*mm" vis="DHcalG10Vis" /> <!--RPCPCB -->
+ <slice material = "mylar" thickness = "0.05*mm" vis="DHcalMylarVis" /> <!--RPCmylarAnode -->
+ <!--slice material = "graphite" thickness = "0.05*mm" vis="DHcalCarbonVis" /--> <!--RPCGraphiteAnode -->
+ <slice material = "Carbon" thickness = "0.05*mm" vis="DHcalCarbonVis" /> <!--RPCGraphiteAnode -->
+ <slice material = "Quartz" thickness = "0.7*mm" vis="DHcalGlassVis" /> <!--RPCThinGlass -->
+ <slice material = "RPCGasDefault" thickness = "1.2*mm" sensitive = "yes" limits="cal_limits" vis="DHcalSensorVis"/>
+ <slice material = "Quartz" thickness = "1.1*mm" vis="DHcalGlassVis" /> <!--RPCThickGlass -->
+ <slice material = "Carbon" thickness = "0.1*mm" vis="DHcalCarbonVis" /> <!--RPCGraphiteCathode -->
+ <!--slice material = "graphite" thickness = "0.1*mm" vis="DHcalCarbonVis" /--> <!--RPCGraphiteCathode -->
+ <slice material = "mylar" thickness = "0.2*mm" vis="DHcalMylarVis" /> <!--RPCmylarCathode -->
+ <slice material = "Air" thickness = "1.0*mm" /> <!--vis="DHcalAirVis" /-->
+ </layer>
+ <layer repeat="(int) 1">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="DHcalRadiatorVis" />
+ </layer>
+ </layers>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="DHcalHits">
+ <segmentation type="GlobalGridXY" gridSizeX="10.0*mm" gridSizeY="10.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+
+</lccdd>
diff --git a/DDExamples/CaliceTbeam/compact/SiWEcal.xml b/DDExamples/CaliceTbeam/compact/SiWEcal.xml
new file mode 100644
index 000000000..eb974f9b6
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/SiWEcal.xml
@@ -0,0 +1,86 @@
+<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="CALICE_TB_Calo"
+ title="CALICE testbeam calo detectors model"
+ author="S. Lu"
+ url="http://ilcsoft.desy.de"
+ status="development"
+ version="$Id: CALICETb.xml Lu $">
+ <comment>The compact format for the CALICE testbeam Detector - toy model </comment>
+ </info>
+
+ <includes>
+ <gdmlFile ref="elements.xml"/>
+ <gdmlFile ref="materials.xml"/>
+ <pyBuilder ref="../drivers"/>
+ </includes>
+
+ <define>
+ <constant name="world_side" value="10*m"/>
+ <constant name="world_x" value="world_side/2"/>
+ <constant name="world_y" value="world_side/2"/>
+ <constant name="world_z" value="world_side/2"/>
+
+ <constant name="TBSiWcal_position" value="2000.0*mm"/>
+ </define>
+
+ <limits>
+ <limitset name="cal_limits">
+ <limit name="step_length_max" particles="*" value="5.0" unit="mm" />
+ </limitset>
+ </limits>
+
+ <display>
+ <vis name="SiWEcalVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="SiWEcalRadiatorVis" alpha="1" r="0.47" g="0.53" b="0.6" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalSensorVis" alpha="1" r="0.96" g="0.64" b="0.38"showDaughters="true" visible="true"/>
+ <vis name="SiWEcalFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="SiWEcalCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="SiWEcalAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+ </display>
+
+ <detectors>
+ <detector id="6" name="SiWEcal" type="CalotbeamBox" readout="SiWEcalHits" vis="SiWEcalVis" calorimeterType="ECAL">
+ <comment>The Silicon Tungsten ECAL Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="180.0*mm" y="180.0*mm" z="(5.0+6.4+7.8)*5.0*mm"/>
+ <position x="0" y="0" z="TBSiWcal_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "1.4*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "2.8*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ <layer repeat="5">
+ <slice material = "Tungsten" thickness = "4.2*mm" vis="SiWEcalRadiatorVis" />
+ <slice material = "Silicon" thickness = "0.1*mm" sensitive = "yes" limits="cal_limits" vis="SiWEcalSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="SiWEcalFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="SiWEcalCuVis" />
+ <slice material = "Air" thickness = "2.7*mm" /> <!--vis="SiWEcalAirVis" /-->
+ </layer>
+ </layers>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="SiWEcalHits">
+ <segmentation type="GlobalGridXY" gridSizeX="5.0*mm" gridSizeY="5.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+
+</lccdd>
diff --git a/DDExamples/CaliceTbeam/compact/Tcmt.xml b/DDExamples/CaliceTbeam/compact/Tcmt.xml
new file mode 100644
index 000000000..ae4c62f2a
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/Tcmt.xml
@@ -0,0 +1,89 @@
+<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="CALICE_TB_Calo"
+ title="CALICE testbeam calo detectors model"
+ author="S. Lu"
+ url="http://ilcsoft.desy.de"
+ status="development"
+ version="$Id: CALICETb.xml Lu $">
+ <comment>The compact format for the CALICE testbeam Detector - toy model </comment>
+ </info>
+
+ <includes>
+ <gdmlFile ref="elements.xml"/>
+ <gdmlFile ref="materials.xml"/>
+ <pyBuilder ref="../drivers"/>
+ </includes>
+
+ <define>
+ <constant name="world_side" value="10*m"/>
+ <constant name="world_x" value="world_side/2"/>
+ <constant name="world_y" value="world_side/2"/>
+ <constant name="world_z" value="world_side/2"/>
+
+ <constant name="TBTcmt_position" value="4500.0*mm"/>
+ </define>
+
+ <limits>
+ <limitset name="cal_limits">
+ <limit name="step_length_max" particles="*" value="30.0" unit="mm" />
+ </limitset>
+ </limits>
+
+ <display>
+ <vis name="TcmtVis" alpha="1" r="1" g="1" b="0.1" showDaughters="true" visible="false"/>
+ <vis name="TcmtRadiatorVis" alpha="1" r="0.69" g="0.77" b="0.87"showDaughters="true" visible="true"/>
+ <vis name="TcmtLayerVis" alpha="1" r="1" g="0" b="0.5" showDaughters="true" visible="true"/>
+ <vis name="TcmtSensorVis" alpha="1" r="0" g="1" b="1" showDaughters="true" visible="true"/>
+ <vis name="TcmtFR4Vis" alpha="1" r="0.44" g="0.77" b="0.44"showDaughters="true" visible="true"/>
+ <vis name="TcmtCuVis" alpha="1" r="0.8" g="0.4" b="0" showDaughters="true" visible="true"/>
+ <vis name="TcmtAirVis" alpha="1" r="1" g="1" b="1" showDaughters="true" visible="true"/>
+ </display>
+
+ <detectors>
+ <detector id="8" name="Tcmt" type="CalotbeamBox" readout="TcmtHits" vis="TcmtVis" calorimeterType="TCMT">
+ <comment>Analog Hadron Calorimeter Prototype</comment>
+
+ <!-- detector online alignment -->
+ <dimensions x="1080" y="1080" z="(26.5+46.5+66.5+10.0)*10.0+20.0"/>
+ <position x="0" y="0" z="TBTcmt_position"/>
+ <rotation x="0" y="0" z="0"/>
+ <layers>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "30.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="10">
+ <slice material = "Steel235" thickness = "50.0*mm" vis="TcmtRadiatorVis" />
+ <slice material = "Polystyrene" thickness = "3.0*mm" sensitive = "yes" limits="cal_limits" vis="TcmtSensorVis"/>
+ <slice material = "FR4" thickness = "0.7*mm" vis="TcmtFR4Vis" />
+ <slice material = "Cu" thickness = "0.1*mm" vis="TcmtCuVis" />
+ <slice material = "Air" thickness = "12.7*mm" /> <!--vis="TcmtAirVis" /-->
+ </layer>
+ <layer repeat="(int) 1">
+ <slice material = "Steel235" thickness = "20.0*mm" vis="TcmtRadiatorVis" />
+ </layer>
+ </layers>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="TcmtHits">
+ <segmentation type="GlobalGridXY" gridSizeX="30.0*mm" gridSizeY="30.0*mm" />
+ <id>system:6,module:7,layer:8,slice:5,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+
+</lccdd>
diff --git a/DDExamples/CaliceTbeam/compact/geant4SD.xml b/DDExamples/CaliceTbeam/compact/geant4SD.xml
new file mode 100644
index 000000000..92395d215
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/geant4SD.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<geant4>
+ <sensitive_detectors>
+ <sd name="SiWEcal"
+ type="Geant4Calorimeter"
+ ecut="0.5*keV"
+ verbose="true"
+ hit_aggregation="position">
+ </sd>
+ <sd name="AHcal"
+ type="Geant4Calorimeter"
+ ecut="0.5*keV"
+ verbose="true"
+ hit_aggregation="position">
+ </sd>
+ <sd name="Tcmt"
+ type="Geant4Calorimeter"
+ ecut="0.5*keV"
+ verbose="true"
+ hit_aggregation="position">
+ </sd>
+<!--
+ <sd name="DHcal"
+ type="Geant4Calorimeter"
+ ecut="0.5*keV"
+ verbose="true"
+ hit_aggregation="position">
+ </sd>
+-->
+ </sensitive_detectors>
+</geant4>
diff --git a/DDExamples/CaliceTbeam/compact/materials.xml b/DDExamples/CaliceTbeam/compact/materials.xml
new file mode 100644
index 000000000..4e7074cad
--- /dev/null
+++ b/DDExamples/CaliceTbeam/compact/materials.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<materials>
+
+ <!--
+ Air by weight from
+
+ http://www.engineeringtoolbox.com/air-composition-24_212.html
+ -->
+ <material name="mylar">
+ <D type="density" unit="g/cm3" value="1.4"/>
+ <fraction n="3" ref="C"/>
+ <fraction n="4" ref="H"/>
+ <fraction n="2" ref="O"/>
+ </material>
+
+ <material name="FR4">
+ <D type="density" unit="g/cm3" value="1.7"/>
+ <fraction n="0.1808" ref="Si"/>
+ <fraction n="0.4056" ref="O"/>
+ <fraction n="0.2780" ref="C"/>
+ <fraction n="0.0684" ref="H"/>
+ <fraction n="0.0671" ref="Br"/>
+ </material>
+
+ <material name="Air">
+ <D type="density" unit="g/cm3" value="0.0012"/>
+ <fraction n="0.754" ref="N"/>
+ <fraction n="0.234" ref="O"/>
+ <fraction n="0.012" ref="Ar"/>
+ </material>
+
+ <material name="Vacuum">
+ <D type="density" unit="g/cm3" value="0.00000001" />
+ <fraction n="1" ref="H" />
+ </material>
+
+ <material name="Epoxy">
+ <D type="density" value="1.3" unit="g/cm3"/>
+ <composite n="44" ref="H"/>
+ <composite n="15" ref="C"/>
+ <composite n="7" ref="O"/>
+ </material>
+
+ <material name="Quartz">
+ <D type="density" value="2.2" unit="g/cm3"/>
+ <composite n="1" ref="Si"/>
+ <composite n="2" ref="O"/>
+ </material>
+
+ <material name="G10">
+ <D type="density" value="1.7" unit="g/cm3"/>
+ <fraction n="0.08" ref="Cl"/>
+ <fraction n="0.773" ref="Quartz"/>
+ <fraction n="0.147" ref="Epoxy"/>
+ </material>
+
+ <material name="Polystyrene">
+ <D value="1.032" unit="g/cm3"/>
+ <composite n="19" ref="C"/>
+ <composite n="21" ref="H"/>
+ </material>
+
+ <material name="Steel235">
+ <D value="7.85" unit="g/cm3"/>
+ <fraction n="0.998" ref="Fe"/>
+ <fraction n=".002" ref="C"/>
+ </material>
+
+ <material name="SiliconOxide">
+ <D type="density" value="2.65" unit="g/cm3"/>
+ <composite n="1" ref="Si"/>
+ <composite n="2" ref="O"/>
+ </material>
+
+ <material name="BoronOxide">
+ <D type="density" value="2.46" unit="g/cm3"/>
+ <composite n="2" ref="B"/>
+ <composite n="3" ref="O"/>
+ </material>
+
+ <material name="SodiumOxide">
+ <D type="density" value="2.65" unit="g/cm3"/>
+ <composite n="2" ref="Na"/>
+ <composite n="1" ref="O"/>
+ </material>
+
+ <material name="AluminumOxide">
+ <D type="density" value="3.89" unit="g/cm3"/>
+ <composite n="2" ref="Al"/>
+ <composite n="3" ref="O"/>
+ </material>
+
+ <material name="PyrexGlass">
+ <D type="density" value="2.23" unit="g/cm3"/>
+ <fraction n="0.806" ref="SiliconOxide"/>
+ <fraction n="0.130" ref="BoronOxide"/>
+ <fraction n="0.040" ref="SodiumOxide"/>
+ <fraction n="0.023" ref="AluminumOxide"/>
+ </material>
+
+ <material name="CarbonFiber">
+ <D type="density" value="1.5" unit="g/cm3"/>
+ <fraction n="0.65" ref="C"/>
+ <fraction n="0.35" ref="Epoxy"/>
+ </material>
+
+ <material name="CarbonFiber_50D">
+ <D type="density" value="0.75" unit="g/cm3"/>
+ <fraction n="0.65" ref="C"/>
+ <fraction n="0.35" ref="Epoxy"/>
+ </material>
+
+ <material name="Rohacell31">
+ <D type="density" value="0.032" unit="g/cm3"/>
+ <composite n="9" ref="C"/>
+ <composite n="13" ref="H"/>
+ <composite n="2" ref="O"/>
+ <composite n="1" ref="N"/>
+ </material>
+
+ <material name="Rohacell31_50D">
+ <D type="density" value="0.016" unit="g/cm3"/>
+ <composite n="9" ref="C"/>
+ <composite n="13" ref="H"/>
+ <composite n="2" ref="O"/>
+ <composite n="1" ref="N"/>
+ </material>
+
+ <material name="RPCGasDefault" state="gas">
+ <D type="density" value="0.0037" unit="g/cm3"/>
+ <composite n="209" ref="C"/>
+ <composite n="239" ref="H"/>
+ <composite n="381" ref="F"/>
+ </material>
+
+ <material name="PolystyreneFoam">
+ <D type="density" value="0.0056" unit="g/cm3"/>
+ <fraction n="1.0" ref="Polystyrene"/>
+ </material>
+
+ <material name="Kapton">
+ <D value="1.43" unit="g/cm3" />
+ <composite n="22" ref="C"/>
+ <composite n="10" ref="H" />
+ <composite n="2" ref="N" />
+ <composite n="5" ref="O" />
+ </material>
+
+ <material name="PEEK">
+ <D value="1.37" unit="g/cm3" />
+ <composite n="19" ref="C"/>
+ <composite n="12" ref="H" />
+ <composite n="3" ref="O" />
+ </material>
+
+</materials>
diff --git a/DDExamples/CaliceTbeam/run_g4.mac b/DDExamples/CaliceTbeam/run_g4.mac
new file mode 100644
index 000000000..ee207bcca
--- /dev/null
+++ b/DDExamples/CaliceTbeam/run_g4.mac
@@ -0,0 +1,26 @@
+# $Id:$
+#
+# Macro file for CaliceTbeam example:
+#
+#
+#
+
+/control/verbose 0
+/control/saveHistory
+#
+/run/verbose 0
+/event/verbose 0
+/tracking/verbose 2
+
+# only for Slic:
+#/generator/select gun
+
+/vis/drawTree world OGLIX
+/vis/viewer/set/viewpointThetaPhi 90 180
+/vis/scene/add/trajectories
+/vis/scene/add/hits
+
+/gun/direction 0. 0. 1.
+/gun/particle pi+
+/gun/energy 10 GeV
+/run/beamOn 3
diff --git a/DDExamples/CaliceTbeam/src/compact/CalotbeamBox_geo.cpp b/DDExamples/CaliceTbeam/src/compact/CalotbeamBox_geo.cpp
new file mode 100644
index 000000000..4958ec034
--- /dev/null
+++ b/DDExamples/CaliceTbeam/src/compact/CalotbeamBox_geo.cpp
@@ -0,0 +1,191 @@
+//====================================================================
+// AIDA Detector description implementation
+// for CALICE testbeam box prototypes
+// Box shape for HCAL, ECAL, trigger, Absobers
+//--------------------------------------------------------------------
+//
+// Author : S.Lu
+//
+// Basic idea:
+// 1. Create the Hcal module envelope.
+// Note: with default material air.
+//
+// 2. Create the Hcal Layer.
+// Create the Layer with slices (Steel235,Polystyrene,Cu,FR4,air).
+// Place each slice into the layer with the right position,
+// And registry the ID for slices
+//
+// 3. Place the same Layer into the module envelope.
+// It will be repeated, and registry the IDs for layer.
+//
+// 4. Place the module into the world volume,
+// with the right position and rotation.
+// And registry the ID for System.
+//
+// 5. Customer material FR4 and Steel235 defined in materials.xml
+//
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "XML/Layering.h"
+
+using namespace std;
+using namespace DD4hep;
+using namespace DD4hep::Geometry;
+
+static Ref_t create_detector(LCDD& lcdd, xml_h element, SensitiveDetector sens) {
+ xml_det_t x_det = element;
+ Layering layering(x_det.child(_U(layers)));
+ string det_name = x_det.nameStr();
+ string det_type = x_det.typeStr();
+ Material air = lcdd.air();
+ xml_dim_t dim = x_det.dimensions();
+ xml_dim_t x_pos (x_det.child(_U(position)));
+ xml_dim_t x_rot (x_det.child(_U(rotation)));
+
+ Translation3D det_pos(x_pos.x(),x_pos.y(),x_pos.z());
+ //Rotation is ROOT::Math::RotationZYX
+ //The input is Rotation(z,y,x)
+ Rotation det_rot(x_rot.z(),x_rot.y(),x_rot.x());
+
+ DetElement sdet(det_name,x_det.id());
+ Volume motherVol = lcdd.pickMotherVolume(sdet);
+
+
+
+ // ========= Create Hcal Modules envelope ============================
+ // They will be the volume for palcing the Hcal Layers.
+ // Themself will be placed into the world volume.
+ // ==========================================================================
+
+ // Hcal module shape
+ double box_half_x = dim.x()/2.0;
+ double box_half_y = dim.y()/2.0;
+ double box_half_z = dim.z()/2.0;
+
+ Box BoxModule(box_half_x,box_half_y,box_half_z);
+
+ // define the name of Module
+ string envelopeVol_name = det_name+_toString("_envelope");
+
+ Volume envelopeVol(envelopeVol_name,BoxModule,air);
+
+ // Set envelope volume attributes.
+ envelopeVol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
+
+
+ // ========= Create Hcal Layers===== ==============================
+ // It will be the sub volume for placing the slices.
+ // Itself will be placed into the Hcal modules envelope.
+ // ================================================================
+
+ // create Layer (air) and place the slices into it.
+ // place the Layer into the Hcal Modules envelope.
+
+ // Hcal layer start position
+ double layer_pos_z = - box_half_z;
+
+ // Create Hcal Chamber without radiator
+ // Place into the Hcal module envelope
+ int layer_num = 0;
+ int module_num = 0;
+ for(xml_coll_t c(x_det.child(_U(layers)),_U(layer)); c; ++c) {
+ xml_comp_t x_layer = c;
+ //Layering layering(x_layer);
+ int repeat = x_layer.repeat();
+ const Layer* lay = layering.layer(layer_num); // Get the layer from the layering engine.
+
+ string layer_name = det_name+ _toString(module_num,"_module%d_layer");
+ double layer_thickness = lay->thickness();
+ DetElement layer(layer_name,"layerModule",x_det.id());
+
+ // Layer box & volume
+ double layer_dim_x = box_half_x;
+ double layer_dim_y = box_half_y;
+ double layer_dim_z = layer_thickness/2.0;
+
+ // Build chamber including air gap
+ // The Layer will be filled with slices,
+ Volume layer_vol(layer_name, Box(layer_dim_x,layer_dim_y,layer_dim_z), air);
+
+
+ // ========= Create sublayer slices =========================================
+ // Create and place the slices into Layer
+ // ==========================================================================
+
+ // Create the slices (sublayers) within the Hcal Chamber.
+ double slice_pos_z = -(layer_thickness / 2.0);
+ int slice_number = 0;
+ for(xml_coll_t k(x_layer,_U(slice)); k; ++k) {
+ xml_comp_t x_slice = k;
+ string slice_name = layer_name + _toString(slice_number,"_slice%d");
+ double slice_thickness = x_slice.thickness();
+ Material slice_material = lcdd.material(x_slice.materialStr());
+ DetElement slice(layer,_toString(slice_number,"slice%d"),x_det.id());
+
+ slice_pos_z += slice_thickness / 2.0;
+
+ // Slice volume & box
+ Volume slice_vol(slice_name,Box(layer_dim_x,layer_dim_y,slice_thickness/2.0),slice_material);
+
+ if ( x_slice.isSensitive() ) {
+ sens.setType("calorimeter");
+ slice_vol.setSensitiveDetector(sens);
+ }
+ // Set region, limitset, and vis.
+ slice_vol.setAttributes(lcdd,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
+ // slice PlacedVolume
+ PlacedVolume slice_phv = layer_vol.placeVolume(slice_vol,Position(0,0,slice_pos_z));
+ slice_phv.addPhysVolID("slice",slice_number);
+
+ slice.setPlacement(slice_phv);
+ // Increment Z position for next slice.
+ slice_pos_z += slice_thickness / 2.0;
+ // Increment slice number.
+ ++slice_number;
+ }
+ // Set region, limitset, and vis.
+ layer_vol.setAttributes(lcdd,x_layer.regionStr(),x_layer.limitsStr(),x_layer.visStr());
+
+
+ // ========= Place the Layer (i.e. Chamber) =================================
+ // Place the Layer into the Hcal module envelope.
+ // with the right position, and registry the ID layer
+ // ==========================================================================
+
+ for (int j = 0; j < repeat; j++) {
+
+ // Layer position in z within the Modules.
+ layer_pos_z += layer_thickness / 2.0;
+
+ PlacedVolume layer_phv = envelopeVol.placeVolume(layer_vol,Position(0,0,layer_pos_z));
+
+ // registry the ID of Layer
+ layer_phv.addPhysVolID("layer",layer_num);
+ layer_phv.addPhysVolID("module",j);
+
+ // then setPlacement for it.
+ layer.setPlacement(layer_phv);
+
+ // Increment the layer_pos_z
+ layer_pos_z += layer_thickness / 2.0;
+ ++layer_num;
+ }
+
+ module_num++;
+ }
+
+
+ // for the alignment in the compact XML file
+ Transform3D Tr3D = Transform3D(det_rot,det_pos);
+ PlacedVolume env_phv = motherVol.placeVolume(envelopeVol,Tr3D);
+
+
+ env_phv.addPhysVolID("system",x_det.id());
+ sdet.setPlacement(env_phv);
+
+ return sdet;
+}
+
+
+
+DECLARE_DETELEMENT(CalotbeamBox, create_detector);
--
GitLab