From e02ce256bd2c2beba8db40c1a8a0b71ec5cd4045 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Wed, 11 Jan 2023 17:37:38 +0100
Subject: [PATCH] Rebase to DD4hep master
---
DDDigi/README.md | 6 +-
DDDigi/io/DigiEdm4hepInput.cpp | 6 +-
examples/ClientTests/CMakeLists.txt | 12 ++++
.../scripts/MiniTelEdm4hepWrite.py | 63 +++++++++++++++++++
examples/ClientTests/scripts/MiniTel_hepmc.py | 4 +-
examples/DDDigi/CMakeLists.txt | 3 +-
examples/DDDigi/scripts/DigiTest.py | 6 +-
examples/DDDigi/scripts/TestEdm4hepInput.py | 24 +++++++
examples/DDG4/CMakeLists.txt | 1 +
9 files changed, 112 insertions(+), 13 deletions(-)
create mode 100644 examples/ClientTests/scripts/MiniTelEdm4hepWrite.py
create mode 100644 examples/DDDigi/scripts/TestEdm4hepInput.py
diff --git a/DDDigi/README.md b/DDDigi/README.md
index 5e5633703..140ed76e5 100644
--- a/DDDigi/README.md
+++ b/DDDigi/README.md
@@ -63,8 +63,8 @@ DigiDDG4ROOT
- Reader for ROOT files produced with DDG4. <br/>
Properties: <br/>
- |**Property**|**Data type**|**Description**|
- |:--- |:--- |:--- |
+ |**Property** |**Data type** |**Description** |
+ |:--- |:--- |:--- |
|`.input` | vector<string> | List of input files to be processed |
|`.tree` | string | Name of the main data tree. default: `EVENT` |
|`.containers` | vector<string> | List of containers to be loaded to DDDigi. |
@@ -155,10 +155,8 @@ DigiAttenuatorSequence
|`.signal_decay` | string | Decay function. default: `exponential` |
|`.t0` | double | Time constant for exponential signal decay. |
-
DigiDepositSmearPositionTrack
-----------------------------
-
- Smear energy deposit positions by an ellipse of the track passing in the
x-y plane.
diff --git a/DDDigi/io/DigiEdm4hepInput.cpp b/DDDigi/io/DigiEdm4hepInput.cpp
index 4e39c45c3..977fc3acf 100644
--- a/DDDigi/io/DigiEdm4hepInput.cpp
+++ b/DDDigi/io/DigiEdm4hepInput.cpp
@@ -32,7 +32,7 @@ namespace dd4hep {
using namespace std::placeholders;
- class DigiEdm4hepROOT : public DigiROOTInput {
+ class DigiEdm4hepInput : public DigiROOTInput {
public:
static constexpr double epsilon = std::numeric_limits<double>::epsilon();
@@ -58,7 +58,7 @@ namespace dd4hep {
public:
/// Initializing constructor
- DigiEdm4hepROOT(const DigiKernel& krnl, const std::string& nam)
+ DigiEdm4hepInput(const DigiKernel& krnl, const std::string& nam)
: DigiROOTInput(krnl, nam)
{
declareProperty("keep_raw", m_keep_raw);
@@ -123,4 +123,4 @@ namespace dd4hep {
};
} // End namespace digi
} // End namespace dd4hep
-DECLARE_DIGIACTION_NS(dd4hep::digi,DigiEdm4hepROOT)
+DECLARE_DIGIACTION_NS(dd4hep::digi,DigiEdm4hepInput)
diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt
index 49f544d49..77c521b3e 100644
--- a/examples/ClientTests/CMakeLists.txt
+++ b/examples/ClientTests/CMakeLists.txt
@@ -485,4 +485,16 @@ if (DD4HEP_USE_GEANT4)
REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" )
endforeach(script)
#
+ #
+ # Test EDM4HEP output module
+ if (DD4HEP_USE_EDM4HEP)
+ # Test EDM4HEP write (needs to be expanded)
+ dd4hep_add_test_reg(ClientTests_sim_MinitTel_edm4hep_write
+ COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+ EXEC_ARGS ${Python_EXECUTABLE} ${ClientTestsEx_INSTALL}/scripts/MiniTelEdm4hepWrite.py
+ -batch -events 5
+ REGEX_PASS "\\+\\+\\+ Finished run 0 after 5 events \\(5 events in total\\)"
+ REGEX_FAIL "Error;ERROR;Exception"
+ )
+ endif()
endif(DD4HEP_USE_GEANT4)
diff --git a/examples/ClientTests/scripts/MiniTelEdm4hepWrite.py b/examples/ClientTests/scripts/MiniTelEdm4hepWrite.py
new file mode 100644
index 000000000..80329c684
--- /dev/null
+++ b/examples/ClientTests/scripts/MiniTelEdm4hepWrite.py
@@ -0,0 +1,63 @@
+# ==========================================================================
+# AIDA Detector description implementation
+# --------------------------------------------------------------------------
+# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+# All rights reserved.
+#
+# For the licensing terms see $DD4hepINSTALL/LICENSE.
+# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+#
+# ==========================================================================
+from __future__ import absolute_import, unicode_literals
+import DDG4
+#
+"""
+
+ dd4hep example setup using the python configuration
+
+ \author M.Frank
+ \version 1.0
+
+"""
+
+
+def run():
+ from g4units import GeV
+ from MiniTelSetup import Setup
+ args = DDG4.CommandLine()
+ m = Setup(geometry='/examples/ClientTests/compact/MiniTelGenerate.xml')
+ kernel = m.kernel
+ if args.batch:
+ run = '/run/beamOn ' + str(args.events)
+ DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
+ m.ui.Commands = [run, '/ddg4/UI/terminate']
+ m.configure()
+ wr = m.geant4.setupEDM4hepOutput('edm4hep', 'MiniTel_ddg4_edm4hep.root')
+ gen = DDG4.GeneratorAction(kernel, 'Geant4GeneratorActionInit/GenerationInit')
+ kernel.generatorAction().adopt(gen)
+
+ gun = DDG4.GeneratorAction(kernel, 'Geant4IsotropeGenerator/IsotropPi+1')
+ gun.Mask = 1 << 0
+ gun.Particle = 'pi+'
+ gun.Energy = 100 * GeV
+ gun.Multiplicity = 1
+ gun.Distribution = 'cos(theta)'
+ kernel.generatorAction().adopt(gun)
+ gun = None
+
+ gen = DDG4.GeneratorAction(kernel, 'Geant4InteractionMerger/InteractionMerger')
+ gen.enableUI()
+ kernel.generatorAction().adopt(gen)
+
+ gen = DDG4.GeneratorAction(kernel, 'Geant4PrimaryHandler/PrimaryHandler')
+ gen.enableUI()
+ kernel.generatorAction().adopt(gen)
+ gen = None
+
+ m.setupGenerator()
+ m.setupPhysics()
+ m.run()
+
+
+if __name__ == '__main__':
+ run()
diff --git a/examples/ClientTests/scripts/MiniTel_hepmc.py b/examples/ClientTests/scripts/MiniTel_hepmc.py
index 708f7a3b1..26787af63 100644
--- a/examples/ClientTests/scripts/MiniTel_hepmc.py
+++ b/examples/ClientTests/scripts/MiniTel_hepmc.py
@@ -33,12 +33,12 @@ def run():
m.configure()
m.defineOutput()
fname = os.environ['DD4hepExamplesINSTALL'] + '/examples/DDG4/data/Muons10GeV.HEPEvt'
- m.setupInput("Geant4EventReaderHepEvtShort|" + fname)
+ m.setupInput('Geant4EventReaderHepEvtShort|' + fname)
m.setupGenerator()
m.setupPhysics(model='FTFP_BERT')
m.phys.decays = True
m.run(num_events=1)
-if __name__ == "__main__":
+if __name__ == '__main__':
run()
diff --git a/examples/DDDigi/CMakeLists.txt b/examples/DDDigi/CMakeLists.txt
index 392d557af..6aeda661a 100644
--- a/examples/DDDigi/CMakeLists.txt
+++ b/examples/DDDigi/CMakeLists.txt
@@ -216,8 +216,9 @@ if (DD4HEP_USE_GEANT4)
REGEX_FAIL "Error;ERROR;Exception"
)
#
+ # Test EDM4HEP output module
if (DD4HEP_USE_EDM4HEP)
- # Test edm4hep write (needs to be expanded)
+ # Test EDM4HEP write (needs to be expanded)
dd4hep_add_test_reg(DDDigi_test_edm4hep_write
COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh"
EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestWriteEdm4hep.py
diff --git a/examples/DDDigi/scripts/DigiTest.py b/examples/DDDigi/scripts/DigiTest.py
index ed359782c..5ca235d4f 100644
--- a/examples/DDDigi/scripts/DigiTest.py
+++ b/examples/DDDigi/scripts/DigiTest.py
@@ -59,7 +59,7 @@ class Test(dddigi.Digitize):
return obj
def load_geo(self, volume_manager=None):
- fname = "file:" + os.environ['DD4hepExamplesINSTALL'] + "/examples/ClientTests/compact/MiniTelGenerate.xml"
+ fname = 'file:' + os.environ['DD4hepExamplesINSTALL'] + '/examples/ClientTests/compact/MiniTelGenerate.xml'
self.kernel().loadGeometry(str(fname))
self.printDetectors()
if volume_manager:
@@ -110,7 +110,7 @@ class Test(dddigi.Digitize):
return next_source
def run_checked(self, num_events=5, num_threads=5, parallel=3):
- result = "FAILED"
+ result = 'FAILED'
if self.num_events:
num_events = int(self.num_events)
if self.num_threads:
@@ -119,7 +119,7 @@ class Test(dddigi.Digitize):
parallel = int(self.events_parallel)
evt_done = self.run(num_events=num_events, num_threads=num_threads, parallel=parallel)
if evt_done == num_events:
- result = "PASSED"
+ result = 'PASSED'
self.always('%s Test finished after processing %d events. [%d parallel threads, %d parallel events]'
% (result, evt_done, num_threads, parallel, ))
self.always('Test done. Exiting')
diff --git a/examples/DDDigi/scripts/TestEdm4hepInput.py b/examples/DDDigi/scripts/TestEdm4hepInput.py
new file mode 100644
index 000000000..1e775a5ef
--- /dev/null
+++ b/examples/DDDigi/scripts/TestEdm4hepInput.py
@@ -0,0 +1,24 @@
+# ==========================================================================
+# AIDA Detector description implementation
+# --------------------------------------------------------------------------
+# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+# All rights reserved.
+#
+# For the licensing terms see $DD4hepINSTALL/LICENSE.
+# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+#
+# ==========================================================================
+from __future__ import absolute_import
+
+
+def run():
+ import DigiTest
+ digi = DigiTest.Test(geometry=None)
+ read = digi.input_action('DigiEdm4hepInput/SignalReader', mask=0x0, input=['../ClientTests/MiniTel_ddg4_edm4hep.root'])
+ dump = digi.event_action('DigiStoreDump/StoreDump', parallel=False)
+ digi.check_creation([read, dump])
+ digi.run_checked(num_events=5, num_threads=5, parallel=3)
+
+
+if __name__ == '__main__':
+ run()
diff --git a/examples/DDG4/CMakeLists.txt b/examples/DDG4/CMakeLists.txt
index 8ca826955..ca4290a5c 100644
--- a/examples/DDG4/CMakeLists.txt
+++ b/examples/DDG4/CMakeLists.txt
@@ -103,4 +103,5 @@ if (DD4HEP_USE_GEANT4)
REGEX_PASS " Parameter value at call 13 is 'terminate-command-2'"
REGEX_FAIL " ERROR ;EXCEPTION;Exception"
)
+ #
endif()
--
GitLab