From 67c62d92492807d501578dd174f33f11da5a5de0 Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Wed, 29 May 2024 14:43:30 +0200 Subject: [PATCH] Remove some messages and fix some tests (#197) --- k4FWCore/components/IOSvc.cpp | 8 ++------ k4FWCore/include/k4FWCore/FunctionalUtils.h | 8 +++++--- test/k4FWCoreTest/options/runFunctionalMix.py | 9 ++++++--- .../k4FWCoreTest_CheckExampleEventData.cpp | 18 ++++-------------- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/k4FWCore/components/IOSvc.cpp b/k4FWCore/components/IOSvc.cpp index b88858bd..0a92a560 100644 --- a/k4FWCore/components/IOSvc.cpp +++ b/k4FWCore/components/IOSvc.cpp @@ -74,7 +74,6 @@ std::tuple>, std::vector 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 { @@ -88,14 +87,12 @@ std::tuple>, std::vector= m_entries) { - // if (true) { auto ep = serviceLocator()->as(); 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> collections; @@ -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; - // } } } diff --git a/k4FWCore/include/k4FWCore/FunctionalUtils.h b/k4FWCore/include/k4FWCore/FunctionalUtils.h index 61aab1aa..84778e53 100644 --- a/k4FWCore/include/k4FWCore/FunctionalUtils.h +++ b/k4FWCore/include/k4FWCore/FunctionalUtils.h @@ -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(handles)[0].objKey() - << " to the requested type " << thisClass->name() << endmsg; + thisClass->debug() << "Trying to cast the collection " << std::get(handles)[0].objKey() + << " to the requested type didn't work " << endmsg; DataObject* p; IDataProviderSvc* svc = thisClass->serviceLocator()->template service("EventDataSvc"); svc->retrieveObject("/Event/" + std::get(handles)[0].objKey(), p).ignore(); const auto wrp = dynamic_cast>>*>(p); if (!wrp) { throw GaudiException(thisClass->name(), - "Failed to cast collection " + std::get(handles)[0].objKey(), + "Failed to cast collection " + std::get(handles)[0].objKey() + + " to the requested type " + + typeid(std::tuple_element_t>).name(), StatusCode::FAILURE); } std::get(inputTuple) = const_cast>*>(wrp->getData()); diff --git a/test/k4FWCoreTest/options/runFunctionalMix.py b/test/k4FWCoreTest/options/runFunctionalMix.py index d80bac86..5c1387e4 100644 --- a/test/k4FWCoreTest/options/runFunctionalMix.py +++ b/test/k4FWCoreTest/options/runFunctionalMix.py @@ -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, @@ -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 @@ -125,6 +127,7 @@ ) consumer_produceralg_algorithm = k4FWCoreTest_CheckExampleEventData("CheckAlgorithm") consumer_produceralg_algorithm.mcparticles = "OldAlgorithmMCParticles" +consumer_produceralg_algorithm.vectorfloat = "OldAlgorithmVectorFloat" ############################### @@ -160,5 +163,5 @@ EvtSel="NONE", EvtMax=10, ExtSvc=[iosvc if args.iosvc else podioevent], - OutputLevel=DEBUG, + OutputLevel=INFO, ) diff --git a/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp b/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp index 172d51f1..afb26804 100644 --- a/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp +++ b/test/k4FWCoreTest/src/components/k4FWCoreTest_CheckExampleEventData.cpp @@ -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) @@ -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();