From 2c48b2d393e03d37a0865153f33605b7c42a65e1 Mon Sep 17 00:00:00 2001 From: Sanghyun Ko <37464245+SanghyunKo@users.noreply.github.com> Date: Mon, 26 Apr 2021 13:38:32 +0900 Subject: [PATCH] Migrate SIM step to EDM4hep (#11) * take care corner cases of small # of rotations in phi * estimate numx & numy on-the-fly instead of saving them in CellID (overflow of field with small # of rotations) * fix readouts * workaround for HSF CMakeTools (for LCG >= 97a_FCC_4) * [WIP] edm4hep + alpha for DR calorimeter (1) * [WIP] edm4hep + alpha for DR calorimeter (1) * [WIP] edm4hep + alpha for DR calorimeter (2) * [WIP] edm4hep + alpha for DR calorimeter (2) * migrate to EDM4hep (G4 part only) * handle fiber allocation corner cases * use RawCalorimeterHit instead of SimCalorimeterHit * CMake clean-up * move to LCG_99 (LCG_97a_FCC4 not working) * CMake clean-up * fix segmentation fault * migrate to G4.10.07.p01 and fix for multithreading --- Detector/CMakeLists.txt | 3 --- Detector/DRcalo/CMakeLists.txt | 17 +++++++++---- Detector/DRcalo/compact/DRcalo.xml | 2 +- Detector/DRcalo/compact/DRcalo_IDEA.xml | 2 +- Detector/DRsegmentation/CMakeLists.txt | 15 ++++++++---- Detector/DRsegmentation/src/GridDRcalo.cpp | 4 +++- Detector/DRsensitive/CMakeLists.txt | 25 +++++++++----------- Detector/DRsensitive/include/DRcaloSiPMHit.h | 6 ++--- Detector/DRsensitive/src/DRcaloSiPMSD.cpp | 11 ++++----- Detector/DetComponents/CMakeLists.txt | 20 +++++++++------- 10 files changed, 57 insertions(+), 48 deletions(-) diff --git a/Detector/CMakeLists.txt b/Detector/CMakeLists.txt index cbc533c2..573164f2 100644 --- a/Detector/CMakeLists.txt +++ b/Detector/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(ddDR) - add_subdirectory(DRcalo) add_subdirectory(DRsensitive) add_subdirectory(DRsegmentation) diff --git a/Detector/DRcalo/CMakeLists.txt b/Detector/DRcalo/CMakeLists.txt index ea729ab0..5169a5d8 100644 --- a/Detector/DRcalo/CMakeLists.txt +++ b/Detector/DRcalo/CMakeLists.txt @@ -1,13 +1,20 @@ project(ddDRcalo) -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -dd4hep_add_plugin(ddDRcalo SOURCES src/*.cpp - USES DD4hep::DDCore DD4hep::DDCond ROOT::Core ROOT::Geom ROOT::GenVector ROOT::MathCore ddDRsegmentation) +dd4hep_add_plugin(ddDRcalo SOURCES src/*.cpp USES + DD4hep::DDCore + DD4hep::DDCond + ROOT::Core + ROOT::Geom + ROOT::GenVector + ROOT::MathCore + ddDRsegmentation +) + install(TARGETS ddDRcalo LIBRARY DESTINATION lib) -install(DIRECTORY compact DESTINATION bin ) +install(DIRECTORY compact DESTINATION bin) + dd4hep_configure_scripts( ddDRcalo DEFAULT_SETUP WITH_TESTS) diff --git a/Detector/DRcalo/compact/DRcalo.xml b/Detector/DRcalo/compact/DRcalo.xml index f3e27a14..243c2e96 100644 --- a/Detector/DRcalo/compact/DRcalo.xml +++ b/Detector/DRcalo/compact/DRcalo.xml @@ -703,7 +703,7 @@ - system:5,eta:-8,phi:9,x:32:6,y:6,c:1,module:2 + system:5,eta:-8,phi:9,x:32:-7,y:-7,c:1,module:2 diff --git a/Detector/DRcalo/compact/DRcalo_IDEA.xml b/Detector/DRcalo/compact/DRcalo_IDEA.xml index 7b736989..de6c8cb0 100644 --- a/Detector/DRcalo/compact/DRcalo_IDEA.xml +++ b/Detector/DRcalo/compact/DRcalo_IDEA.xml @@ -688,7 +688,7 @@ - system:5,eta:-8,phi:9,x:32:10,y:8,c:1,module:2 + system:5,eta:-8,phi:9,x:32:-11,y:-9,c:1,module:2 diff --git a/Detector/DRsegmentation/CMakeLists.txt b/Detector/DRsegmentation/CMakeLists.txt index f5ae5002..468a097b 100644 --- a/Detector/DRsegmentation/CMakeLists.txt +++ b/Detector/DRsegmentation/CMakeLists.txt @@ -1,7 +1,5 @@ project(ddDRsegmentation) -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) @@ -10,8 +8,17 @@ file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp ) -add_library(ddDRsegmentation SHARED ${sources}) -target_include_directories(ddDRsegmentation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${DD4hep_DIR}/include) +file(GLOB headers + ${PROJECT_SOURCE_DIR}/include/*.h +) + +add_library(ddDRsegmentation SHARED ${sources} ${headers}) + +target_include_directories(ddDRsegmentation PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${DD4hep_DIR}/include +) + target_link_libraries( ddDRsegmentation DD4hep::DDCore diff --git a/Detector/DRsegmentation/src/GridDRcalo.cpp b/Detector/DRsegmentation/src/GridDRcalo.cpp index 03687af1..d78adecd 100644 --- a/Detector/DRsegmentation/src/GridDRcalo.cpp +++ b/Detector/DRsegmentation/src/GridDRcalo.cpp @@ -54,7 +54,9 @@ Vector3D GridDRcalo::position(const CellID& cID) const { DRparamBase* paramBase = setParamBase(noEta); auto transformA = paramBase->GetSipmTransform3D(noPhi); - dd4hep::Position localPos = dd4hep::Position( localPosition(cID) ); + dd4hep::Position localPos = dd4hep::Position(0.,0.,0.); + if ( IsSiPM(cID) ) localPos = dd4hep::Position( localPosition(cID) ); + dd4hep::RotationZYX rot = dd4hep::RotationZYX(M_PI, 0., 0.); // AdHoc rotation, potentially bug dd4hep::Transform3D transformB = dd4hep::Transform3D(rot,localPos); auto total = transformA*transformB; diff --git a/Detector/DRsensitive/CMakeLists.txt b/Detector/DRsensitive/CMakeLists.txt index 3ca2c826..4247930e 100644 --- a/Detector/DRsensitive/CMakeLists.txt +++ b/Detector/DRsensitive/CMakeLists.txt @@ -1,16 +1,5 @@ project(ddDRsensitive) -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - -option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" OFF) -if(WITH_GEANT4_UIVIS) - find_package(Geant4 REQUIRED ui_all vis_all) -else() - find_package(Geant4 REQUIRED) -endif() - -include(${Geant4_USE_FILE}) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) @@ -19,12 +8,20 @@ file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp ) -add_library(ddDRsensitive SHARED ${sources}) -target_include_directories(ddDRsensitive PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${DD4hep_DIR}/include) +file(GLOB headers + ${PROJECT_SOURCE_DIR}/include/*.h +) + +add_library(ddDRsensitive SHARED ${sources} ${headers}) + +target_include_directories(ddDRsensitive PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${DD4hep_DIR}/include +) + target_link_libraries( ddDRsensitive ddDRsegmentation - ${Geant4_LIBRARIES} rootIO DD4hep::DDCore DD4hep::DDG4 diff --git a/Detector/DRsensitive/include/DRcaloSiPMHit.h b/Detector/DRsensitive/include/DRcaloSiPMHit.h index 0e713ca6..c3a3b47e 100644 --- a/Detector/DRsensitive/include/DRcaloSiPMHit.h +++ b/Detector/DRsensitive/include/DRcaloSiPMHit.h @@ -32,13 +32,13 @@ namespace ddDRcalo { unsigned long GetPhotonCount() const { return fPhotons; } void SetSiPMnum(dd4hep::DDSegmentation::CellID n) { fSiPMnum = n; } - dd4hep::DDSegmentation::CellID GetSiPMnum() const { return fSiPMnum; } + const dd4hep::DDSegmentation::CellID& GetSiPMnum() const { return fSiPMnum; } void CountWavlenSpectrum(DRsimInterface::hitRange range); - DRsimInterface::DRsimWavlenSpectrum GetWavlenSpectrum() const { return fWavlenSpectrum; } + const DRsimInterface::DRsimWavlenSpectrum& GetWavlenSpectrum() const { return fWavlenSpectrum; } void CountTimeStruct(DRsimInterface::hitRange range); - DRsimInterface::DRsimTimeStruct GetTimeStruct() const { return fTimeStruct; } + const DRsimInterface::DRsimTimeStruct& GetTimeStruct() const { return fTimeStruct; } private: dd4hep::DDSegmentation::CellID fSiPMnum; diff --git a/Detector/DRsensitive/src/DRcaloSiPMSD.cpp b/Detector/DRsensitive/src/DRcaloSiPMSD.cpp index 41f31ea6..6b7b587d 100644 --- a/Detector/DRsensitive/src/DRcaloSiPMSD.cpp +++ b/Detector/DRsensitive/src/DRcaloSiPMSD.cpp @@ -9,11 +9,8 @@ #include "G4ParticleDefinition.hh" #include "G4ParticleTypes.hh" -#ifdef HAVE_GEANT4_UNITS -#define MM_2_CM 1.0 -#else -#define MM_2_CM 0.1 -#endif +#include "G4SystemOfUnits.hh" +#include "DD4hep/DD4hepUnits.h" ddDRcalo::DRcaloSiPMSD::DRcaloSiPMSD(const std::string aName, const std::string aReadoutName, const dd4hep::Segmentation& aSeg) : G4VSensitiveDetector(aName), fHitCollection(0), fHCID(-1), @@ -43,8 +40,8 @@ G4bool ddDRcalo::DRcaloSiPMSD::ProcessHits(G4Step* step, G4TouchableHistory*) { G4ThreeVector global = step->GetPostStepPoint()->GetPosition(); G4ThreeVector local = theTouchable->GetHistory()->GetTopTransform().TransformPoint( global ); - dd4hep::Position loc(local.x() * MM_2_CM, local.y() * MM_2_CM, local.z() * MM_2_CM); - dd4hep::Position glob(global.x() * MM_2_CM, global.y() * MM_2_CM, global.z() * MM_2_CM); + dd4hep::Position loc(local.x() * dd4hep::millimeter/CLHEP::millimeter, local.y() * dd4hep::millimeter/CLHEP::millimeter, local.z() * dd4hep::millimeter/CLHEP::millimeter); + dd4hep::Position glob(global.x() * dd4hep::millimeter/CLHEP::millimeter, global.y() * dd4hep::millimeter/CLHEP::millimeter, global.z() * dd4hep::millimeter/CLHEP::millimeter); auto cID = fSeg->cellID(loc, glob, volID); diff --git a/Detector/DetComponents/CMakeLists.txt b/Detector/DetComponents/CMakeLists.txt index 9a8772e3..c2a3b57a 100644 --- a/Detector/DetComponents/CMakeLists.txt +++ b/Detector/DetComponents/CMakeLists.txt @@ -1,11 +1,5 @@ project(DetComponents) -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) - -find_package(Geant4 REQUIRED) - -include(${Geant4_USE_FILE}) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) @@ -14,11 +8,19 @@ file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp ) -add_library(DetComponents SHARED ${sources}) -target_include_directories(DetComponents PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${DD4hep_DIR}/include) +file(GLOB headers + ${PROJECT_SOURCE_DIR}/include/*.h +) + +add_library(DetComponents SHARED ${sources} ${headers}) + +target_include_directories(DetComponents PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${DD4hep_DIR}/include +) + target_link_libraries( DetComponents - ${Geant4_LIBRARIES} DD4hep::DDCore DD4hep::DDG4 )