From 95d85b5ccc64cfe53999a1e6909def73d7e8f73e Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 19 Jan 2024 09:02:25 +0100 Subject: [PATCH] Set Cardinality to 1 in algorithms with mutable --- test/k4FWCoreTest/CMakeLists.txt | 1 - .../options/TestDataHandleUniquePtr.py | 42 -------------- .../components/TestDataHandleUniquePtr.cpp | 56 ------------------- .../src/components/TestDataHandleUniquePtr.h | 54 ------------------ .../k4FWCoreTest_CheckExampleEventData.cpp | 2 + .../k4FWCoreTest_CreateExampleEventData.cpp | 2 + .../components/k4FWCoreTest_cellID_reader.cpp | 2 + .../components/k4FWCoreTest_cellID_writer.cpp | 2 + 8 files changed, 8 insertions(+), 153 deletions(-) delete mode 100644 test/k4FWCoreTest/options/TestDataHandleUniquePtr.py delete mode 100644 test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.cpp delete mode 100644 test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.h diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index 48576819..cf973449 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -92,7 +92,6 @@ add_test(NAME checkKeepDropSwitch COMMAND python scripts/check_KeepDropSwitch.py) set_test_env(checkKeepDropSwitch) set_property(TEST checkKeepDropSwitch APPEND PROPERTY DEPENDS ReadExampleEventData) -add_test_with_env(TestDataHandleUniquePtr options/TestDataHandleUniquePtr.py) add_test_with_env(TestUniqueIDGenSvc options/TestUniqueIDGenSvc.py) add_test_with_env(TestEventHeaderFiller options/createEventHeader.py) add_test_with_env(EventHeaderCheck options/runEventHeaderCheck.py PROPERTIES DEPENDS TestEventHeaderFiller) diff --git a/test/k4FWCoreTest/options/TestDataHandleUniquePtr.py b/test/k4FWCoreTest/options/TestDataHandleUniquePtr.py deleted file mode 100644 index 4b054adf..00000000 --- a/test/k4FWCoreTest/options/TestDataHandleUniquePtr.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 2014-2024 Key4hep-Project. -# -# This file is part of Key4hep. -# See https://key4hep.github.io/key4hep-doc/ for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from Gaudi.Configuration import * - -from Configurables import ApplicationMgr -ApplicationMgr().EvtSel = "NONE" -ApplicationMgr().EvtMax = 100 -ApplicationMgr().OutputLevel = INFO -ApplicationMgr().StopOnSignal = True - -from Configurables import k4DataSvc -podioevent = k4DataSvc("EventDataSvc") -ApplicationMgr().ExtSvc += [podioevent] - -from Configurables import TestDataHandleUniquePtr -producer = TestDataHandleUniquePtr() -ApplicationMgr().TopAlg += [producer] - -from Configurables import PodioOutput -out = PodioOutput("out") -out.filename = "output_TestDataHandleUniquePtr.root" -out.outputCommands = ["keep *"] -ApplicationMgr().TopAlg += [out] - - - diff --git a/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.cpp b/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.cpp deleted file mode 100644 index 2b941fbb..00000000 --- a/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014-2024 Key4hep-Project. - * - * This file is part of Key4hep. - * See https://key4hep.github.io/key4hep-doc/ for further info. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "TestDataHandleUniquePtr.h" - -// datamodel -#include "edm4hep/MCParticleCollection.h" - -DECLARE_COMPONENT(TestDataHandleUniquePtr) - -TestDataHandleUniquePtr::TestDataHandleUniquePtr(const std::string& aName, ISvcLocator* aSvcLoc) - : Gaudi::Algorithm(aName, aSvcLoc) { - declareProperty("mcparticles", m_mcParticleHandle, "Dummy Particle collection (output)"); -} - -TestDataHandleUniquePtr::~TestDataHandleUniquePtr() {} - -StatusCode TestDataHandleUniquePtr::initialize() { - if (Gaudi::Algorithm::initialize().isFailure()) { - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} - -StatusCode TestDataHandleUniquePtr::execute(const EventContext&) const { - auto coll = std::make_unique(); - - auto particle = coll->create(); - - auto& p4 = particle.momentum(); - p4.x = 5; - p4.y = 6; - p4.z = 7; - particle.setMass(8); - - m_mcParticleHandle.put(std::move(coll)); - - return StatusCode::SUCCESS; -} - -StatusCode TestDataHandleUniquePtr::finalize() { return Gaudi::Algorithm::finalize(); } diff --git a/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.h b/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.h deleted file mode 100644 index dec03532..00000000 --- a/test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014-2024 Key4hep-Project. - * - * This file is part of Key4hep. - * See https://key4hep.github.io/key4hep-doc/ for further info. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef TESTFWCORE_TESTDATAHANDLEUNIQUEPTR -#define TESTFWCORE_TESTDATAHANDLEUNIQUEPTR - -// GAUDI -#include "Gaudi/Algorithm.h" - -// edm4hep -#include "TTree.h" -#include "k4FWCore/DataHandle.h" - -// datamodel -namespace edm4hep { - class MCParticleCollection; -} - -class TestDataHandleUniquePtr : public Gaudi::Algorithm { -public: - explicit TestDataHandleUniquePtr(const std::string&, ISvcLocator*); - virtual ~TestDataHandleUniquePtr(); - /** Initialize. - * @return status code - */ - virtual StatusCode initialize() final; - /** Execute. - * @return status code - */ - virtual StatusCode execute(const EventContext&) const final; - /** Finalize. - * @return status code - */ - virtual StatusCode finalize() final; - -private: - mutable DataHandle m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Writer, this}; -}; -#endif /* TESTFWCORE_TESTDATAHANDLEUNIQUEPTR */ diff --git a/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp b/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp index 99e1b3d6..07c60d76 100644 --- a/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp +++ b/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp @@ -31,6 +31,8 @@ k4FWCoreTest_CheckExampleEventData::k4FWCoreTest_CheckExampleEventData(const std : Gaudi::Algorithm(aName, aSvcLoc) { declareProperty("mcparticles", m_mcParticleHandle, "Dummy Particle collection (output)"); declareProperty("vectorfloat", m_vectorFloatHandle, "Dummy collection (output)"); + // Set Cardinality to 1 because this algorithm is not prepared to run in parallel + setProperty("Cardinality", 1).ignore(); } StatusCode k4FWCoreTest_CheckExampleEventData::initialize() { return Gaudi::Algorithm::initialize(); } diff --git a/test/k4FWCoreTest/src/components/k4FWCoreTest_CreateExampleEventData.cpp b/test/k4FWCoreTest/src/components/k4FWCoreTest_CreateExampleEventData.cpp index 1b8d9254..9d3dd11a 100644 --- a/test/k4FWCoreTest/src/components/k4FWCoreTest_CreateExampleEventData.cpp +++ b/test/k4FWCoreTest/src/components/k4FWCoreTest_CreateExampleEventData.cpp @@ -43,6 +43,8 @@ k4FWCoreTest_CreateExampleEventData::k4FWCoreTest_CreateExampleEventData(const s declareProperty("trackhits", m_TrackerHitHandle, "Dummy Hit collection (output)"); declareProperty("tracks", m_trackHandle, "Dummy track collection (output)"); declareProperty("vectorfloat", m_vectorFloatHandle, "Dummy collection (output)"); + // Set Cardinality to 1 because this algorithm is not prepared to run in parallel + setProperty("Cardinality", 1).ignore(); } k4FWCoreTest_CreateExampleEventData::~k4FWCoreTest_CreateExampleEventData() {} diff --git a/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_reader.cpp b/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_reader.cpp index b7d5e9d9..4e6ac18e 100644 --- a/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_reader.cpp +++ b/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_reader.cpp @@ -25,6 +25,8 @@ k4FWCoreTest_cellID_reader::k4FWCoreTest_cellID_reader(const std::string& aName, : Gaudi::Algorithm(aName, aSvcLoc) { ; declareProperty("simtrackhits_r", m_simTrackerHitReaderHandle, "Dummy Hit collection Reader"); + // Set Cardinality to 1 because this algorithm is not prepared to run in parallel + setProperty("Cardinality", 1).ignore(); } k4FWCoreTest_cellID_reader::~k4FWCoreTest_cellID_reader() {} diff --git a/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_writer.cpp b/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_writer.cpp index 014c1df3..ea83fd5a 100644 --- a/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_writer.cpp +++ b/test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_writer.cpp @@ -24,6 +24,8 @@ k4FWCoreTest_cellID_writer::k4FWCoreTest_cellID_writer(const std::string& aName, : Gaudi::Algorithm(aName, aSvcLoc) { ; declareProperty("simtrackhits_w", m_simTrackerHitWriterHandle, "Dummy Hit collection Writer"); + // Set Cardinality to 1 because this algorithm is not prepared to run in parallel + setProperty("Cardinality", 1).ignore(); } k4FWCoreTest_cellID_writer::~k4FWCoreTest_cellID_writer() {}