diff --git a/Detector/DetEcalMatrix/CMakeLists.txt b/Detector/DetEcalMatrix/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..569a9e8fdb5ae716b4d7982c4f6a5a4fb5a8944f --- /dev/null +++ b/Detector/DetEcalMatrix/CMakeLists.txt @@ -0,0 +1,32 @@ +############################################################################### +# Package: DetEcalMatrix +# Based on package: lcgeo +################################################################################ +gaudi_subdir(DetEcalMatrix v0r0) + +gaudi_depends_on_subdirs(GaudiKernel) + + +find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED) +find_package(Geant4) +include(${Geant4_USE_FILE}) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake ) +include( DD4hep ) + +find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED) + +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/compact DESTINATION Detector/DetEcalMatrix) + +set(DetEcalMatrix_src + src/calorimeter/EcalMatrix.cpp +) + +gaudi_add_module(DetEcalMatrix + ${DetEcalMatrix_src} + INCLUDE_DIRS DD4hep ROOT Geant4 src/include + LINK_LIBRARIES GaudiKernel DD4hep ${DD4hep_COMPONENT_LIBRARIES} ROOT Geant4) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}") +dd4hep_generate_rootmap(DetEcalMatrix) diff --git a/Detector/DetEcalMatrix/compact/det.xml b/Detector/DetEcalMatrix/compact/det.xml new file mode 100644 index 0000000000000000000000000000000000000000..54fb0648554f2475603846ec97f7a776d47ed4ec --- /dev/null +++ b/Detector/DetEcalMatrix/compact/det.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd> + + <info name="EcalMatrix" + title="Test with Chunxiu Liu's EcalMatrix" + author="Tao Lin" + url="http://cepcgit.ihep.ac.cn" + status="development" + version="v0"> + <comment>Test with Chunxiu Liu's EcalMatrix</comment> + </info> + + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <constant name="world_size" value="30*m"/> + <constant name="world_x" value="world_size"/> + <constant name="world_y" value="world_size"/> + <constant name="world_z" value="world_size"/> + </define> + + <display> + <vis name="Invisible" showDaughters="false" visible="false"/> + <vis name="InvisibleWithChildren" showDaughters="true" visible="false"/> + <vis name="VisibleRed" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="VisibleBlue" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/> + <vis name="VisibleGreen" alpha="1.0" r="0.0" g="1.0" b="0.0" drawingStyle="solid" lineStyle="solid" showDaughters="true" visible="true"/> + </display> + + <detectors> + <detector id="1" name="CaloDetector" type="EcalMatrix" readout="CaloHits" vis="VisibleGreen" sensitive="true"> + <position x="0" y="0" z="1800*mm"/> + </detector> + </detectors> + + <readouts> + <readout name="CaloHits"> + <id>system:8</id> + </readout> + </readouts> + +</lccdd> diff --git a/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp b/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..822abbc8c9e504e4ba6344df9db053942b2b2020 --- /dev/null +++ b/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp @@ -0,0 +1,57 @@ +//==================================================================== +// Detector description implementation for Chunxiu Liu's EcalMatrix +//-------------------------------------------------------------------- +// +// Author : Tao Lin +// Examples from lcgeo +// lcgeo/detector/calorimeter/ +// +//==================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "XML/Layering.h" +#include "XML/Utilities.h" +#include "DDRec/DetectorData.h" +#include "DDSegmentation/Segmentation.h" + +#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl; +#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl; + +static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, + xml_h e, + dd4hep::SensitiveDetector sens) { + + xml_det_t x_det = e; + + std::string det_name = x_det.nameStr(); + std::string det_type = x_det.typeStr(); + MYDEBUGVAL(det_name); + MYDEBUGVAL(det_type); + xml_dim_t pos (x_det.child(_U(position))); + + + dd4hep::DetElement sdet(det_name, x_det.id()); + + dd4hep::Volume motherVol = theDetector.pickMotherVolume(sdet); + + dd4hep::Material det_mat(theDetector.material("Air")); + dd4hep::Volume det_vol(det_name+"_vol", dd4hep::Box(60, 60, 60), det_mat); + + dd4hep::Transform3D transform(dd4hep::Rotation3D(), + dd4hep::Position(pos.x(),pos.y(),pos.z())); + dd4hep::PlacedVolume phv = motherVol.placeVolume(det_vol,transform); + + if ( x_det.isSensitive() ) { + dd4hep::SensitiveDetector sd = sens; + det_vol.setSensitiveDetector(sens); + sd.setType("calorimeter"); + } + if ( x_det.hasAttr(_U(id)) ) { + phv.addPhysVolID("system",x_det.id()); + } + sdet.setPlacement(phv); + + MYDEBUG("create_detector DONE. "); + return sdet; +} + +DECLARE_DETELEMENT(EcalMatrix, create_detector)