Skip to content

Commit

Permalink
Merge branch 'main' into generic-param-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored May 31, 2024
2 parents 6559e6f + 67c62d9 commit 9453a8c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/key4hep-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
build_type: ["release", "nightly"]
image: ["alma9", "ubuntu22", "centos7"]
image: ["alma9", "ubuntu22"]
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 2 additions & 6 deletions k4FWCore/components/IOSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ std::tuple<std::vector<std::shared_ptr<podio::CollectionBase>>, std::vector<std:
podio::Frame frame;
{
std::scoped_lock<std::mutex> lock(m_changeBufferLock);
info() << "m_nextEntry = " << m_nextEntry << " m_entries = " << m_entries << endmsg;
if (m_nextEntry < m_entries) {
frame = podio::Frame(std::move(m_reader->readEntry(podio::Category::Event, m_nextEntry)));
} else {
Expand All @@ -88,14 +87,12 @@ std::tuple<std::vector<std::shared_ptr<podio::CollectionBase>>, std::vector<std:
}

if (m_nextEntry >= m_entries) {
// if (true) {
auto ep = serviceLocator()->as<IEventProcessor>();
StatusCode sc = ep->stopRun();
if (sc.isFailure()) {
error() << "Error when stopping run" << endmsg;
throw GaudiException("Error when stopping run", name(), StatusCode::FAILURE);
}
info() << "m_nextEntry = " << m_nextEntry << " m_entries = " << m_entries << endmsg;
}

std::vector<std::shared_ptr<podio::CollectionBase>> collections;
Expand Down Expand Up @@ -143,10 +140,9 @@ void IOSvc::handle(const Incident& incident) {
if (code.isSuccess()) {
debug() << "Removing the collection: " << coll << " from the store" << endmsg;
code = m_dataSvc->unregisterObject(collPtr);
} else {
error() << "Expected collection " << coll << " in the store but it was not found" << endmsg;
}
// else {
// info() << "Collection not found: " << coll << endmsg;
// }
}
}

Expand Down
8 changes: 5 additions & 3 deletions k4FWCore/include/k4FWCore/FunctionalUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ namespace k4FWCore {
// 1. a mistake was made in the input types of a functional algorithm
// 2. the data was produced using the old DataHandle, which is never going to be in the input type
if (e.message().find("different from") != std::string::npos) {
thisClass->error() << "Trying to cast the collection " << std::get<Index>(handles)[0].objKey()
<< " to the requested type " << thisClass->name() << endmsg;
thisClass->debug() << "Trying to cast the collection " << std::get<Index>(handles)[0].objKey()
<< " to the requested type didn't work " << endmsg;
DataObject* p;
IDataProviderSvc* svc = thisClass->serviceLocator()->template service<IDataProviderSvc>("EventDataSvc");
svc->retrieveObject("/Event/" + std::get<Index>(handles)[0].objKey(), p).ignore();
const auto wrp = dynamic_cast<const DataWrapper<std::tuple_element_t<Index, std::tuple<In...>>>*>(p);
if (!wrp) {
throw GaudiException(thisClass->name(),
"Failed to cast collection " + std::get<Index>(handles)[0].objKey(),
"Failed to cast collection " + std::get<Index>(handles)[0].objKey() +
" to the requested type " +
typeid(std::tuple_element_t<Index, std::tuple<In...>>).name(),
StatusCode::FAILURE);
}
std::get<Index>(inputTuple) = const_cast<std::tuple_element_t<Index, std::tuple<In...>>*>(wrp->getData());
Expand Down
9 changes: 6 additions & 3 deletions test/k4FWCoreTest/options/runFunctionalMix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# This is an example mixing functional and non-functional algorithms
#

from Gaudi.Configuration import INFO, DEBUG
from Gaudi.Configuration import INFO
from Configurables import (
ExampleFunctionalConsumerMultiple,
ExampleFunctionalTransformerMultiple,
Expand Down Expand Up @@ -102,7 +102,9 @@
InputCollectionParticles=["FunctionalMCParticles"],
Offset=0,
)
consumer_producerfun_algorithm = k4FWCoreTest_CheckExampleEventData("CheckFunctional")
consumer_producerfun_algorithm = k4FWCoreTest_CheckExampleEventData(
"CheckFunctional", keepEventNumberZero=True
)
consumer_producerfun_algorithm.mcparticles = "FunctionalMCParticles"
consumer_producerfun_algorithm.keepEventNumberZero = True

Expand All @@ -125,6 +127,7 @@
)
consumer_produceralg_algorithm = k4FWCoreTest_CheckExampleEventData("CheckAlgorithm")
consumer_produceralg_algorithm.mcparticles = "OldAlgorithmMCParticles"
consumer_produceralg_algorithm.vectorfloat = "OldAlgorithmVectorFloat"

###############################

Expand Down Expand Up @@ -160,5 +163,5 @@
EvtSel="NONE",
EvtMax=10,
ExtSvc=[iosvc if args.iosvc else podioevent],
OutputLevel=DEBUG,
OutputLevel=INFO,
)
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ struct ExampleFunctionalConsumerMultiple final
}

if ((tracks[0].getType() != 1) || (std::abs(tracks[0].getChi2() - 2.1) > 1e-6) || (tracks[0].getNdf() != 3) ||
(std::abs(tracks[0].getDEdx() - 4.1) > 1e-6) || (std::abs(tracks[0].getDEdxError() - 5.1) > 1e-6) ||
(std::abs(tracks[0].getRadiusOfInnermostHit() - 6.1) > 1e-6)) {
std::stringstream error;
error << "Wrong data in tracks collection, expected 1, 2.1, 3, 4.1, 5.1, 6.1 got " << tracks[0].getType() << ", "
<< tracks[0].getChi2() << ", " << tracks[0].getNdf() << ", " << tracks[0].getDEdx() << ", "
<< tracks[0].getDEdxError() << ", " << tracks[0].getRadiusOfInnermostHit() << "";
<< tracks[0].getChi2() << ", " << tracks[0].getNdf() << ", " << tracks[0].getRadiusOfInnermostHit() << "";
throw std::runtime_error(error.str());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ struct ExampleFunctionalConsumerRuntimeCollectionsMultiple final
}
for (auto& [key, tracks] : trackMap) {
if ((tracks[0].getType() != 1) || (std::abs(tracks[0].getChi2() - 2.1) > 1e-6) || (tracks[0].getNdf() != 3) ||
(std::abs(tracks[0].getDEdx() - 4.1) > 1e-6) || (std::abs(tracks[0].getDEdxError() - 5.1) > 1e-6) ||
(std::abs(tracks[0].getRadiusOfInnermostHit() - 6.1) > 1e-6)) {
std::stringstream error;
error << "Wrong data in tracks collection, expected 1, 2.1, 3, 4.1, 5.1, 6.1 got " << tracks[0].getType()
<< ", " << tracks[0].getChi2() << ", " << tracks[0].getNdf() << ", " << tracks[0].getDEdx() << ", "
<< tracks[0].getDEdxError() << ", " << tracks[0].getRadiusOfInnermostHit() << "";
<< ", " << tracks[0].getChi2() << ", " << tracks[0].getNdf() << ", "
<< tracks[0].getRadiusOfInnermostHit() << "";
throw std::runtime_error(error.str());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ struct ExampleFunctionalProducerMultiple final : k4FWCore::Producer<retType()> {
track.setType(1);
track.setChi2(2.1);
track.setNdf(3);
track.setDEdx(4.1);
track.setDEdxError(5.1);
track.setRadiusOfInnermostHit(6.1);
track.addToSubdetectorHitNumbers(1);
track.addToSubdetectorHitNumbers(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@ struct ExampleFunctionalTransformerRuntimeCollectionsMultiple final
for (auto& [key, tracks] : trackMap) {
auto coll = edm4hep::TrackCollection();
if ((tracks.at(0).getType() != 1) || (std::abs(tracks.at(0).getChi2() - 2.1) > 1e-6) ||
(tracks.at(0).getNdf() != 3) || (std::abs(tracks.at(0).getDEdx() - 4.1) > 1e-6) ||
(std::abs(tracks.at(0).getDEdxError() - 5.1) > 1e-6) ||
(std::abs(tracks.at(0).getRadiusOfInnermostHit() - 6.1) > 1e-6)) {
(tracks.at(0).getNdf() != 3) || (std::abs(tracks.at(0).getRadiusOfInnermostHit() - 6.1) > 1e-6)) {
std::stringstream error;
error << "Wrong data in tracks collection, expected 1, 2.1, 3, 4.1, 5.1, 6.1 got " << tracks.at(0).getType()
<< ", " << tracks.at(0).getChi2() << ", " << tracks.at(0).getNdf() << ", " << tracks.at(0).getDEdx()
<< ", " << tracks.at(0).getDEdxError() << ", " << tracks.at(0).getRadiusOfInnermostHit() << "";
<< ", " << tracks.at(0).getChi2() << ", " << tracks.at(0).getNdf() << ", "
<< tracks.at(0).getRadiusOfInnermostHit() << "";
throw std::runtime_error(error.str());
}
coll->push_back(tracks.at(0).clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@

// datamodel
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "edm4hep/TrackerHitPlaneCollection.h"

DECLARE_COMPONENT(k4FWCoreTest_CheckExampleEventData)

Expand All @@ -48,9 +37,10 @@ StatusCode k4FWCoreTest_CheckExampleEventData::initialize() { return Gaudi::Algo
StatusCode k4FWCoreTest_CheckExampleEventData::execute(const EventContext&) const {
auto floatVector = m_vectorFloatHandle.get();
if (floatVector->size() != 3 || (*floatVector)[2] != m_event) {
fatal() << "Contents of vectorfloat collection is not as expected: size = " << floatVector->size()
<< " (expected 3), contents = " << *floatVector << " (expected [125., 25., " << m_event << "]) " << endmsg;
// return StatusCode::FAILURE;
std::stringstream error;
error << "Contents of vectorfloat collection is not as expected: size = " << floatVector->size()
<< " (expected 3), contents = " << *floatVector << " (expected [125., 25., " << m_event << "]) ";
throw std::runtime_error(error.str());
}

auto particles = m_mcParticleHandle.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ StatusCode k4FWCoreTest_CreateExampleEventData::execute(const EventContext&) con
track.setType(1);
track.setChi2(2.1);
track.setNdf(3);
track.setDEdx(4.1);
track.setDEdxError(5.1);
track.setRadiusOfInnermostHit(6.1);
// set vectormembers
#if EDM4HEP_BUILD_VERSION > EDM4HEP_VERSION(0, 9, 0)
Expand Down

0 comments on commit 9453a8c

Please sign in to comment.