Skip to content
Snippets Groups Projects
Commit e1bef9a0 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Updated cmake and added TestDetector

	modified:   CMakeLists.txt

	new file:   src/TestDetector.cpp
parent 6322189f
No related branches found
No related tags found
No related merge requests found
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"
......
#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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment