Skip to content

Commit

Permalink
Migrate SIM step to EDM4hep (HEP-FCC#11)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SanghyunKo authored Apr 26, 2021
1 parent 5894d92 commit 2c48b2d
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 48 deletions.
3 changes: 0 additions & 3 deletions Detector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(ddDR)

add_subdirectory(DRcalo)
add_subdirectory(DRsensitive)
add_subdirectory(DRsegmentation)
Expand Down
17 changes: 12 additions & 5 deletions Detector/DRcalo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion Detector/DRcalo/compact/DRcalo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@
<readout name="DRcaloSiPMreadout">
<segmentation type="GridDRcalo"/>
<!-- Mendatory to use the first 32 bits for tower infos & the last 32 bits for fiber/SiPM infos -->
<id>system:5,eta:-8,phi:9,x:32:6,y:6,c:1,module:2</id>
<id>system:5,eta:-8,phi:9,x:32:-7,y:-7,c:1,module:2</id>
</readout>
</readouts>

Expand Down
2 changes: 1 addition & 1 deletion Detector/DRcalo/compact/DRcalo_IDEA.xml
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@
<readout name="DRcaloSiPMreadout">
<segmentation type="GridDRcalo"/>
<!-- Mendatory to use the first 32 bits for tower infos & the last 32 bits for fiber/SiPM infos -->
<id>system:5,eta:-8,phi:9,x:32:10,y:8,c:1,module:2</id>
<id>system:5,eta:-8,phi:9,x:32:-11,y:-9,c:1,module:2</id>
</readout>
</readouts>

Expand Down
15 changes: 11 additions & 4 deletions Detector/DRsegmentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(ddDRsegmentation)

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Detector/DRsegmentation/src/GridDRcalo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 11 additions & 14 deletions Detector/DRsensitive/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Detector/DRsensitive/include/DRcaloSiPMHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 4 additions & 7 deletions Detector/DRsensitive/src/DRcaloSiPMSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 11 additions & 9 deletions Detector/DetComponents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Expand All @@ -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
)
Expand Down

0 comments on commit 2c48b2d

Please sign in to comment.