Skip to content

Commit

Permalink
Don't use GaudiAlg (key4hep#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell authored Mar 15, 2024
1 parent 83fb539 commit 017cba2
Show file tree
Hide file tree
Showing 29 changed files with 121 additions and 256 deletions.
2 changes: 1 addition & 1 deletion doc/uniqueIDGen.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ StatusCode SomeGaudiAlgorithm::initialize() {
Then use the service during execution:
```cpp
StatusCode MarlinProcessorWrapper::execute() {
StatusCode MarlinProcessorWrapper::execute(const EventContext&) const {
m_service->getUniqueID(1, 2, name());
}
```
4 changes: 2 additions & 2 deletions k4FWCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gaudi_install(PYTHON)
gaudi_add_library(k4FWCore
SOURCES src/PodioDataSvc.cpp
src/KeepDropSwitch.cpp
LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel podio::podioRootIO ROOT::Core ROOT::RIO ROOT::Tree
LINK Gaudi::GaudiKernel podio::podioRootIO ROOT::Core ROOT::RIO ROOT::Tree
)
target_include_directories(k4FWCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
Expand All @@ -40,7 +40,7 @@ target_include_directories(k4FWCore PUBLIC
file(GLOB k4fwcore_plugin_sources components/*.cpp)
gaudi_add_module(k4FWCorePlugins
SOURCES ${k4fwcore_plugin_sources}
LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel k4FWCore k4FWCore::k4Interface ROOT::Core ROOT::RIO ROOT::Tree EDM4HEP::edm4hep)
LINK Gaudi::GaudiKernel k4FWCore k4FWCore::k4Interface ROOT::Core ROOT::RIO ROOT::Tree EDM4HEP::edm4hep)
target_include_directories(k4FWCorePlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
Expand Down
8 changes: 4 additions & 4 deletions k4FWCore/components/EventHeaderCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@

DECLARE_COMPONENT(EventHeaderCreator)

EventHeaderCreator::EventHeaderCreator(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
EventHeaderCreator::EventHeaderCreator(const std::string& name, ISvcLocator* svcLoc) : Gaudi::Algorithm(name, svcLoc) {
declareProperty("EventHeaderCollection", m_headerCol,
"Name of the EventHeaderCollection that will be stored in the output root file.");
}

StatusCode EventHeaderCreator::initialize() {
if (GaudiAlgorithm::initialize().isFailure())
if (Gaudi::Algorithm::initialize().isFailure())
return StatusCode::FAILURE;
return StatusCode::SUCCESS;
}

StatusCode EventHeaderCreator::execute() {
StatusCode EventHeaderCreator::execute(const EventContext&) const {
static int eventNumber = 0;
debug() << "Filling EventHeader with runNumber " << int(m_runNumber) << " and eventNumber "
<< eventNumber + m_eventNumberOffset << endmsg;
Expand All @@ -44,7 +44,7 @@ StatusCode EventHeaderCreator::execute() {
}

StatusCode EventHeaderCreator::finalize() {
if (GaudiAlgorithm::finalize().isFailure())
if (Gaudi::Algorithm::finalize().isFailure())
return StatusCode::FAILURE;
return StatusCode::SUCCESS;
}
12 changes: 6 additions & 6 deletions k4FWCore/components/EventHeaderCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef K4FWCORE_EVENTHEADERCREATOR
#define K4FWCORE_EVENTHEADERCREATOR

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "k4FWCore/DataHandle.h"

/***
Expand All @@ -30,13 +30,13 @@ namespace edm4hep {
class EventHeaderCollection;
}

class EventHeaderCreator : public GaudiAlgorithm {
class EventHeaderCreator : public Gaudi::Algorithm {
public:
EventHeaderCreator(const std::string& name, ISvcLocator* svcLoc);

virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
StatusCode initialize();
StatusCode execute(const EventContext&) const;
StatusCode finalize();

private:
// Run number value (fixed for the entire job, to be set by the job submitter)
Expand All @@ -46,7 +46,7 @@ class EventHeaderCreator : public GaudiAlgorithm {
this, "eventNumberOffset", 0,
"Event number offset, eventNumber will be filled with 'event_index + eventNumberOffset'"};
// datahandle for the EventHeader
DataHandle<edm4hep::EventHeaderCollection> m_headerCol{"EventHeader", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::EventHeaderCollection> m_headerCol{"EventHeader", Gaudi::DataHandle::Writer, this};
};

#endif
2 changes: 1 addition & 1 deletion k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
#include "PodioInput.h"
#include "GaudiAlg/Consumer.h"
#include "Gaudi/Functional/Consumer.h"

#include "k4FWCore/PodioDataSvc.h"

Expand Down
2 changes: 1 addition & 1 deletion k4FWCore/components/PodioInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef FWCORE_PODIOINPUT_H
#define FWCORE_PODIOINPUT_H
// Gaudi
#include "Gaudi/Functional/Consumer.h"
#include "Gaudi/Property.h"
#include "GaudiAlg/Consumer.h"

// STL
#include <string>
Expand Down
8 changes: 4 additions & 4 deletions k4FWCore/components/PodioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
DECLARE_COMPONENT(PodioOutput)

PodioOutput::PodioOutput(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc), m_firstEvent(true) {}
: Gaudi::Algorithm(name, svcLoc), m_firstEvent(true) {}

StatusCode PodioOutput::initialize() {
if (GaudiAlgorithm::initialize().isFailure())
if (Gaudi::Algorithm::initialize().isFailure())
return StatusCode::FAILURE;

// check whether we have the PodioEvtSvc active
Expand All @@ -44,7 +44,7 @@ StatusCode PodioOutput::initialize() {
return StatusCode::SUCCESS;
}

StatusCode PodioOutput::execute() {
StatusCode PodioOutput::execute(const EventContext&) const {
auto& frame = m_podioDataSvc->getEventFrame();

// register for writing
Expand Down Expand Up @@ -89,7 +89,7 @@ StatusCode PodioOutput::execute() {
*
*/
StatusCode PodioOutput::finalize() {
if (GaudiAlgorithm::finalize().isFailure())
if (Gaudi::Algorithm::finalize().isFailure())
return StatusCode::FAILURE;
//// prepare job options metadata ///////////////////////
// retrieve the configuration of the job
Expand Down
14 changes: 7 additions & 7 deletions k4FWCore/components/PodioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef FWCORE_PODIOOUTPUT_H
#define FWCORE_PODIOOUTPUT_H

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "k4FWCore/KeepDropSwitch.h"
#include "podio/CollectionBase.h"
#include "podio/podioVersion.h"
Expand All @@ -37,22 +37,22 @@ namespace podio {
// forward declarations
class PodioDataSvc;

class PodioOutput : public GaudiAlgorithm {
class PodioOutput : public Gaudi::Algorithm {
public:
/// Constructor.
PodioOutput(const std::string& name, ISvcLocator* svcLoc);

/// Initialization of PodioOutput. Acquires the data service, creates trees and root file.
virtual StatusCode initialize();
StatusCode initialize();
/// Execute. For the first event creates branches for all collections known to PodioDataSvc and prepares them for
/// writing. For the following events it reconnects the branches with collections and prepares them for write.
virtual StatusCode execute();
StatusCode execute(const EventContext&) const;
/// Finalize. Writes the meta data tree; writes file and cleans up all ROOT-pointers.
virtual StatusCode finalize();
StatusCode finalize();

private:
/// First event or not
bool m_firstEvent;
mutable bool m_firstEvent;
/// Root file name the output is written to
Gaudi::Property<std::string> m_filename{this, "filename", "output.root", "Name of the file to create"};
/// Commands which output is to be kept
Expand All @@ -68,7 +68,7 @@ class PodioOutput : public GaudiAlgorithm {
/// The stored collections
std::vector<podio::CollectionBase*> m_storedCollections;
/// The collections to write out
std::vector<std::string> m_collection_names_to_write;
mutable std::vector<std::string> m_collection_names_to_write;
};

#endif
2 changes: 1 addition & 1 deletion k4FWCore/include/k4FWCore/BaseClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef K4FWCORE_FUNCTIONALUTILS_H
#define K4FWCORE_FUNCTIONALUTILS_H

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "GaudiKernel/DataObjectHandle.h"
#include "k4FWCore/DataWrapper.h"

Expand Down
2 changes: 1 addition & 1 deletion k4FWCore/include/k4FWCore/MetaDataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define K4FWCORE_METADATAHANDLE_H

// GAUDI
#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"

#include "k4FWCore/PodioDataSvc.h"
#include "podio/GenericParameters.h"
Expand Down
3 changes: 1 addition & 2 deletions test/k4FWCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ file(GLOB k4fwcoretest_plugin_sources src/components/*.cpp)

gaudi_add_module(k4FWCoreTestPlugins
SOURCES ${k4fwcoretest_plugin_sources}
LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel k4FWCore k4FWCore::k4Interface ROOT::Core ROOT::RIO ROOT::Tree EDM4HEP::edm4hepDict EDM4HEP::edm4hep)
LINK Gaudi::GaudiKernel k4FWCore k4FWCore::k4Interface ROOT::Core ROOT::RIO ROOT::Tree EDM4HEP::edm4hepDict EDM4HEP::edm4hep)

include(CTest)

Expand Down Expand Up @@ -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)
Expand Down
43 changes: 0 additions & 43 deletions test/k4FWCoreTest/options/TestDataHandleUniquePtr.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include "k4FWCore/BaseClass.h"

#include <Gaudi/Functional/Consumer.h>
#include <Gaudi/Property.h>
#include <GaudiAlg/Consumer.h>
#include <GaudiKernel/ISvcLocator.h>

#include <fmt/core.h>
Expand Down
56 changes: 0 additions & 56 deletions test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.cpp

This file was deleted.

54 changes: 0 additions & 54 deletions test/k4FWCoreTest/src/components/TestDataHandleUniquePtr.h

This file was deleted.

Loading

0 comments on commit 017cba2

Please sign in to comment.