Skip to content

Commit

Permalink
Don't use the event frame, improve checks for missing collections
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Jul 9, 2024
1 parent a6a021b commit 1449d9c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,24 @@ void EDM4hep2LcioTool::convertEventHeader(const std::string& e4h_coll_name, lcio
void EDM4hep2LcioTool::convertAdd(const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event, CollectionPairMappings& collection_pairs,
std::vector<EDM4hep2LCIOConv::ParticleIDConvData>& pidCollections) {
const auto& evtFrame = m_podioDataSvc->getEventFrame();
const auto& metadata = m_podioDataSvc->getMetaDataFrame();
auto collPtr = evtFrame.get(e4h_coll_name);
const auto& metadata = m_podioDataSvc->getMetaDataFrame();
podio::CollectionBase* collPtr = nullptr;
DataObject* p;
auto sc = m_podioDataSvc->retrieveObject(e4h_coll_name, p);
if (sc.isFailure()) {
throw GaudiException("Collection not found", name(), StatusCode::FAILURE);
}
auto ptr = dynamic_cast<DataWrapperBase*>(p);
if (ptr) {
collPtr = ptr->collectionBase();
}
// When the collection can't be retrieved from the frame
// there is still the possibility that it was generated
// from a functional algorithm
if (!collPtr) {
DataObject* p;
auto sc = m_podioDataSvc->retrieveObject(e4h_coll_name, p);
auto ptr = dynamic_cast<AnyDataWrapper<std::shared_ptr<podio::CollectionBase>>*>(p);
if (sc.isFailure() || !ptr) {
error() << "No collection with name: " << e4h_coll_name << " available for conversion" << endmsg;
else {
auto ptr = dynamic_cast<AnyDataWrapper<std::shared_ptr<podio::CollectionBase>>*>(p);
if (!ptr) {
throw GaudiException("Collection could not be casted to the expected type", name(), StatusCode::FAILURE);
} else {
collPtr = dynamic_cast<podio::CollectionBase*>(ptr->getData().get());
}
Expand Down

0 comments on commit 1449d9c

Please sign in to comment.