diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 6d37ea639a5354eb09dd50e37a86ce23a596654a..2a4bf50bdd5a09f4f6fcb973bbb20f5ba242b925 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/Examples/options/edm4cepc_write.py b/Examples/options/edm4cepc_write.py new file mode 100644 index 0000000000000000000000000000000000000000..133b24709b7dd83e9d0a4f9953494d81c94ab63f --- /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 +) diff --git a/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87b2e219598bc722e8a46581e74a4059d9717a99 --- /dev/null +++ b/Examples/src/Edm4hepTest/Edm4cepcWriteAlg.cpp @@ -0,0 +1,57 @@ +/* + * 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() { + + 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; + } + + StatusCode finalize() { + + return GaudiAlgorithm::finalize(); + } + +private: + DataHandle<edm4hep::RecTofCollection> m_rectofCol{"RecTofCollection", Gaudi::DataHandle::Writer, this}; + +}; + +DECLARE_COMPONENT(Edm4cepcWriteAlg) diff --git a/cmake/CEPCSWDependencies.cmake b/cmake/CEPCSWDependencies.cmake index 90d8914ebf8dbf5a2e916aa515711a87c6683863..f14a91c508ee6a5027b3af9184050a8808a1baba 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 32e00142e62ddd467f0cb89b23b8cbecb69b2e25..a853022fe2e1b1c98683eb56177849d632074a1f 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 0000000000000000000000000000000000000000..65c5f1f6419b4319152d1711c4085faffe31c37f --- /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 8eb38894b7b055bf6fe99d4b156e97f7e9466a26 + ) + +FetchContent_MakeAvailable(EDM4CEPC)