diff --git a/CMakeLists.txt b/CMakeLists.txt index 70248b4112cd7b43e2cb58a841958b7c74153840..36f5f7a4da46ba2fe85a30375479d4e8b3b04b04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,25 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) +PROJECT(detector_template + VERSION 0.0.1 + LANGUAGES CXX + DESCRIPTION "A template dd4hep+acts detector" + ) + +find_package( DD4hep REQUIRED COMPONENTS DDCore DDG4 ) -#set(CMAKE_PREFIX_PATH $ENV{HOME}/lib CMAKE_PREFIX_PATH) #find_package(Acts REQUIRED COMPONENTS Core IdentificationPlugin TGeoPlugin DD4hepPlugin PATHS /home/whit/lib/cmake NO_DEFAULT_PATH) -find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep ) +#find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep ) #----------------------------------------------------------------------------------- -set(a_lib_name topside2) +set(a_lib_name detector_template) + +if("${PROJECT_NAME}" STREQUAL "detector_template") + message(WARNING " + Current project and library is named detector_template! + Please rename library to match corresponding detector implmentation.") +endif() + dd4hep_configure_output() -#dd4hep_package (${a_lib_name} MAJOR 0 MINOR 0 PATCH 1 -# USES [ROOT REQUIRED COMPONENTS Geom GenVector] -# [DD4hep REQUIRED COMPONENTS DDCore DDRec] -# OPTIONAL XERCESC -# INCLUDE_DIRS include -# ) dd4hep_add_plugin(${a_lib_name} SOURCES src/*.cpp USES ActsCore ActsPluginDD4hep @@ -22,6 +29,7 @@ target_link_libraries(${a_lib_name} ) #----------------------------------------------------------------------------------- +# Install the detector description files. install(DIRECTORY compact/ DESTINATION share/${PROJECT_NAME}/${a_lib_name} FILES_MATCHING PATTERN "*.xml" diff --git a/src/TestDetector.cpp b/src/TestDetector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5669184b4de5cdaecc87ee6d8bb29df7ef910c33 --- /dev/null +++ b/src/TestDetector.cpp @@ -0,0 +1,36 @@ +#include <XML/Helper.h> + +using namespace dd4hep; + +static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens) { + xml::DetElement detElem = handle; + std::string detName = detElem.nameStr(); + int detID = detElem.id(); + + xml::Component dims = detElem.dimensions(); + double rInner = dims.inner_radius(); + double rMin = dims.rmin(); + double thickness = dims.thickness(); + double innerZ = dims.inner_z(); + double angle = dims.angle(); + + Material mat = desc.material(detElem.materialStr()); + + Tube outerTubeShape(rMin, rInner + thickness, innerZ + thickness); + Tube innerTubeShape(0, rInner, innerZ); + SubtractionSolid unchamferedShape(outerTubeShape, innerTubeShape); + Cone chamferShape(thickness, 0, rMin, 0, rMin + 2 * tan(angle) * thickness); + SubtractionSolid detShape(unchamferedShape, chamferShape, Position(0, 0, innerZ + thickness)); + Volume detVol(detName, detShape, mat); + + detVol.setVisAttributes(desc.visAttributes(detElem.visStr())); + + DetElement det(detName, detID); + Volume motherVol = desc.pickMotherVolume(det); + PlacedVolume detPV = motherVol.placeVolume(detVol); + det.setPlacement(detPV); + return det; +} + +// clang-format off +DECLARE_DETELEMENT(TestDetector, createDetector)