From 4182a448079ce1656cf7b78d5cc1e57cb1bcfc04 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 14 Jun 2024 11:25:52 +0800 Subject: [PATCH 1/5] add edm4cepc --- cmake/CEPCSWDependencies.cmake | 9 +++++++++ cmake/CEPCSWOptions.cmake | 3 +++ cmake/internal_edm4cepc.cmake | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 cmake/internal_edm4cepc.cmake diff --git a/cmake/CEPCSWDependencies.cmake b/cmake/CEPCSWDependencies.cmake index 90d8914e..f14a91c5 100644 --- a/cmake/CEPCSWDependencies.cmake +++ b/cmake/CEPCSWDependencies.cmake @@ -44,3 +44,12 @@ else() message("Try to use an internal installation of CKF BELLE") include("${CMAKE_CURRENT_LIST_DIR}/internal_ckf.cmake") endif() + + +if (CEPCSW_USE_SYSTEM_EDM4CEPC) + message("Try to use an existing installation of EDM4CEPC") + find_package(EDM4CEPC) +else() + message("Try to use an internal installation of EDM4CEPC") + include("${CMAKE_CURRENT_LIST_DIR}/internal_edm4cepc.cmake") +endif() diff --git a/cmake/CEPCSWOptions.cmake b/cmake/CEPCSWOptions.cmake index 32e00142..a853022f 100644 --- a/cmake/CEPCSWOptions.cmake +++ b/cmake/CEPCSWOptions.cmake @@ -8,3 +8,6 @@ option(CEPCSW_USE_SYSTEM_CKF_BELLE "Use the existing installation of CKF BELLE. Otherwise the internal version will be used." FALSE) +option(CEPCSW_USER_SYSTEM_EDM4CEPC + "Use the existing installation of EDM4CEPC. Otherwise the internal version will be used." + FALSE) diff --git a/cmake/internal_edm4cepc.cmake b/cmake/internal_edm4cepc.cmake new file mode 100644 index 00000000..0b75a2e6 --- /dev/null +++ b/cmake/internal_edm4cepc.cmake @@ -0,0 +1,10 @@ + +include(FetchContent) + +FetchContent_Declare( + EDM4CEPC + GIT_REPOSITORY https://code.ihep.ac.cn/cepc/externals/EDM4cepc.git + GIT_TAG db03e59584b1b92a8b1c47ee281f768c611d5dc8 + ) + +FetchContent_MakeAvailable(EDM4CEPC) -- GitLab From 9b18e01435a4af1100f1b9feec277aa618e5d4c2 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 14 Jun 2024 13:45:56 +0800 Subject: [PATCH 2/5] update edm4cepc to support alias. --- Examples/CMakeLists.txt | 2 ++ cmake/internal_edm4cepc.cmake | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 6d37ea63..2a4bf50b 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -8,12 +8,14 @@ gaudi_add_module(Examples src/Edm4hepTest/Edm4hepReadAlg.cpp src/Edm4hepTest/Edm4hepReadDCAlg.cpp src/Edm4hepTest/Edm4hepWriteAlg.cpp + src/Edm4hepTest/Edm4cepcWriteAlg.cpp src/DumpIDAlg/DumpIDAlg.cpp LINK DetInterface k4FWCore::k4FWCore Gaudi::GaudiAlgLib Gaudi::GaudiKernel ${LCIO_LIBRARIES} ${DD4hep_COMPONENT_LIBRARIES} + EDM4CEPC::edm4cepc EDM4CEPC::edm4cepcDict EDM4HEP::edm4hep EDM4HEP::edm4hepDict ${podio_LIBRARIES} podio::podioRootIO ) diff --git a/cmake/internal_edm4cepc.cmake b/cmake/internal_edm4cepc.cmake index 0b75a2e6..65c5f1f6 100644 --- a/cmake/internal_edm4cepc.cmake +++ b/cmake/internal_edm4cepc.cmake @@ -4,7 +4,7 @@ include(FetchContent) FetchContent_Declare( EDM4CEPC GIT_REPOSITORY https://code.ihep.ac.cn/cepc/externals/EDM4cepc.git - GIT_TAG db03e59584b1b92a8b1c47ee281f768c611d5dc8 + GIT_TAG 8eb38894b7b055bf6fe99d4b156e97f7e9466a26 ) FetchContent_MakeAvailable(EDM4CEPC) -- GitLab From 7b07858b3e82cec452e9be29584b922e4b85b3c1 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 14 Jun 2024 13:48:42 +0800 Subject: [PATCH 3/5] add the algorithm. --- Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp diff --git a/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp new file mode 100644 index 00000000..29618cb1 --- /dev/null +++ b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp @@ -0,0 +1,41 @@ +/* + * Description: + * This algorithm is used to test the EDM4hep extension for cepc. + * + * In the extension, we keep the same namespace as edm4hep. + * The header file path is different. + * + * Author: + * Tao Lin <lintao AT ihep.ac.cn> + */ + +#include "k4FWCore/DataHandle.h" +#include "GaudiAlg/GaudiAlgorithm.h" + +#include "edm4cepc/RecTofCollection.h" + +class Edm4cepcWriteAlg: public GaudiAlgorithm { +public: + + Edm4cepcWriteAlg(const std::string& name, ISvcLocator* svcLoc) + : GaudiAlgorithm(name, svcLoc) { + + } + + StatusCode initialized() { + + return GaudiAlgorithm::initialize(); + } + + StatusCode execute() { + + return StatusCode::SUCCESS; + } + + StatusCode finalize() { + + return GaudiAlgorithm::finalize(); + } +}; + +DECLARE_COMPONENT(Edm4cepcWriteAlg) -- GitLab From 0f6bcbabbe923bc3f34c745cfc373d1662f29496 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 14 Jun 2024 14:26:24 +0800 Subject: [PATCH 4/5] create RecTofCollection. --- Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp index 29618cb1..87b2e219 100644 --- a/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp +++ b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp @@ -29,6 +29,18 @@ public: StatusCode execute() { + auto rectofCol = m_rectofCol.createAndPut(); + + for (size_t i = 0; i < 3; ++i) { + auto rectof = rectofCol->create(); + + rectof.setTime(100.); + rectof.setTimeExp({99.,99.5,100,100.5,101}); + rectof.setSigma(1.); + rectof.setPathLength({50,50.5,51,51.5,52}); + rectof.setPosition({100,100,10}); + } + return StatusCode::SUCCESS; } @@ -36,6 +48,10 @@ public: return GaudiAlgorithm::finalize(); } + +private: + DataHandle<edm4hep::RecTofCollection> m_rectofCol{"RecTofCollection", Gaudi::DataHandle::Writer, this}; + }; DECLARE_COMPONENT(Edm4cepcWriteAlg) -- GitLab From 1166aca4c93e764dadfde2c7bc11021ba0c1f2b9 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 14 Jun 2024 14:30:05 +0800 Subject: [PATCH 5/5] update. --- Examples/options/edm4cepc_write.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Examples/options/edm4cepc_write.py diff --git a/Examples/options/edm4cepc_write.py b/Examples/options/edm4cepc_write.py new file mode 100644 index 00000000..133b2470 --- /dev/null +++ b/Examples/options/edm4cepc_write.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +from Gaudi.Configuration import * + +from Configurables import k4DataSvc +dsvc = k4DataSvc("EventDataSvc") + +from Configurables import Edm4cepcWriteAlg +alg = Edm4cepcWriteAlg("Edm4cepcWriteAlg") + +from Configurables import PodioOutput +out = PodioOutput("out") +out.filename = "test.root" +out.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [alg, out], + EvtSel = 'NONE', + EvtMax = 10, + ExtSvc=[dsvc], + OutputLevel=DEBUG +) -- GitLab