From 8e432f40bfcd26fc3cb5101b70f46dc2d2c1a551 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 19 Jul 2023 18:58:20 +0200 Subject: [PATCH] Switch LCIO to EDM4hep conversion to use k4EDM4hep2LcioConv functionality (#114) * Implement conversion on top of k4EDM4hep2LcioConv * Remove no longer necessary k4LCIOReader * Add error outputs to track comparison * Make sure to convert TrackerHits in tests * Update the expected anajob outputs --- CMakeLists.txt | 1 - k4MarlinWrapper/CMakeLists.txt | 2 +- .../k4MarlinWrapper/converters/Lcio2EDM4hep.h | 54 +++- .../src/components/Lcio2EDM4hep.cpp | 262 +++++++----------- test/CMakeLists.txt | 1 - test/gaudi_opts/edm_converters.py | 2 +- test/inputFiles/anajob_Output_DST.expected | 24 +- test/inputFiles/anajob_Output_REC.expected | 24 +- test/src/TestE4H2L.cpp | 25 ++ 9 files changed, 189 insertions(+), 206 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2caeed31..3efc67da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,6 @@ find_package(Marlin REQUIRED) find_package(EDM4HEP REQUIRED) find_package(k4FWCore REQUIRED) find_package(k4EDM4hep2LcioConv REQUIRED) -find_package(k4LCIOReader REQUIRED) include(CTest) diff --git a/k4MarlinWrapper/CMakeLists.txt b/k4MarlinWrapper/CMakeLists.txt index 13183211..50517e93 100644 --- a/k4MarlinWrapper/CMakeLists.txt +++ b/k4MarlinWrapper/CMakeLists.txt @@ -82,7 +82,7 @@ gaudi_add_module(Lcio2EDM4hep Gaudi::GaudiAlgLib EDM4HEP::edm4hep k4FWCore::k4FWCore - k4LCIOReader::k4LCIOReader + k4EDM4hep2LcioConv::k4EDM4hep2LcioConv ) target_include_directories(Lcio2EDM4hep PUBLIC diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h index 6e54236c..c0a35496 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h @@ -1,5 +1,5 @@ -#ifndef K4MARLINWRAPPER_K4LCIOREADERWRAPPER_H -#define K4MARLINWRAPPER_K4LCIOREADERWRAPPER_H +#ifndef K4MARLINWRAPPER_LCIO2EDM4HEP_H +#define K4MARLINWRAPPER_LCIO2EDM4HEP_H // GAUDI #include @@ -8,15 +8,25 @@ #include #include -// k4LCIOReader -#include -#include - // Converter Interface #include "k4MarlinWrapper/converters/IEDMConverter.h" #include #include +#include +#include + +namespace podio { + class CollectionBase; +} + +namespace LCIO2EDM4hepConv { + struct LcioEdmTypeMapping; +} + +namespace EVENT { + class LCCollection; +} class Lcio2EDM4hepTool : public GaudiTool, virtual public IEDMConverter { public: @@ -25,23 +35,41 @@ class Lcio2EDM4hepTool : public GaudiTool, virtual public IEDMConverter { virtual StatusCode initialize(); virtual StatusCode finalize(); - StatusCode convertCollections(lcio::LCEventImpl* lcio_event); + // ********************************** + // - Convert all collections indicated in Tool parameters + // - Some collections implicitly convert associated collections + // - Convert associated collections from LCRelation for existing EDM4hep relations + // - Converted collections are put into TES + // ********************************** + StatusCode convertCollections(lcio::LCEventImpl* lcio_event) override; private: Gaudi::Property> m_collNames{this, "collNameMapping", {}}; Gaudi::Property m_convertAll{this, "convertAll", true}; - std::map m_dataHandlesMap; - ServiceHandle m_eds; PodioLegacyDataSvc* m_podioDataSvc; + // ********************************** + // Check if a collection was already registered to skip it + // ********************************** bool collectionExist(const std::string& collection_name); - template - void convertRegister(const std::string& edm_name, const std::string& lcio_name, - std::unique_ptr& lcio_conver, const lcio::LCCollection* const lcio_coll, - const bool cnv_metadata = false); + /** + * Register a collection into the TES. If the lcioColl is not a nullptr also + * convert the metadata from the input lcio collection. + */ + void registerCollection(std::tuple> namedColl, + EVENT::LCCollection* lcioColl = nullptr); + + /** + * Register a collection into the TES. If the lcioColl is not a nullptr also + * convert the metadata from the input lcio collection. + */ + void registerCollection(const std::string& name, std::unique_ptr&& coll, + EVENT::LCCollection* lcioColl = nullptr) { + registerCollection(std::make_tuple(name, std::move(coll)), lcioColl); + } }; #endif diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index 3bb22fcf..4264e3f9 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -1,5 +1,23 @@ #include "k4MarlinWrapper/converters/Lcio2EDM4hep.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h" + DECLARE_COMPONENT(Lcio2EDM4hepTool); Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& name, const IInterface* parent) @@ -19,115 +37,65 @@ StatusCode Lcio2EDM4hepTool::initialize() { return GaudiTool::initialize(); } -StatusCode Lcio2EDM4hepTool::finalize() { - for (const auto& [key, val] : m_dataHandlesMap) { - delete val; - } - - return GaudiTool::finalize(); -} +StatusCode Lcio2EDM4hepTool::finalize() { return GaudiTool::finalize(); } -// ********************************** -// Convert EDM4hep collection using k4LCIOConverter -// Register converted collection with Podio Data Service to Event Store -// ********************************** -template -void Lcio2EDM4hepTool::convertRegister(const std::string& edm_name, const std::string& lcio_name, - std::unique_ptr& lcio_converter, - const lcio::LCCollection* const lcio_coll, const bool cnv_metadata) { - debug() << "Converting collection: " << lcio_name << " from LCIO to EDM4hep " << edm_name << endmsg; - - // Convert and get EDM4hep collection - auto* e4h_generic_coll = lcio_converter->getCollection(lcio_name); - - if (e4h_generic_coll == nullptr) { - error() << "LCIO Collection " << lcio_name << " failed to convert to EDM4hep in k4LCIOConverter." << endmsg; - return; +bool Lcio2EDM4hepTool::collectionExist(const std::string& collection_name) { + auto collections = m_podioDataSvc->getCollections(); + for (const auto& [name, coll] : collections) { + if (collection_name == name) { + debug() << "Collection named " << name << " already registered, skipping conversion." << endmsg; + return true; + } } + return false; +} - // Cast to specific type based on typename - T* mycoll = dynamic_cast(e4h_generic_coll); - if (mycoll == nullptr) { - error() << "LCIO Collection " << lcio_name - << " did not get correct type to be registered. Type was: " << typeid(T).name() << endmsg; +void Lcio2EDM4hepTool::registerCollection( + std::tuple> namedColl, EVENT::LCCollection* lcioColl) { + auto& [name, e4hColl] = namedColl; + if (e4hColl == nullptr) { + error() << "Could not convert collection " << name << endmsg; return; } - // Manually register object instead of using DataHandle - DataWrapper* wrapper = new DataWrapper(); - wrapper->setData(mycoll); - - // Check if collection was already registered - auto collections = m_podioDataSvc->getCollections(); - bool is_registered = false; - for (auto& coll : collections) { - if (coll.first == edm_name) { - is_registered = true; - return; - } - } + auto wrapper = new DataWrapper(); + wrapper->setData(e4hColl.release()); - if (is_registered == false) { - StatusCode sc = m_podioDataSvc->registerObject("/Event", "/" + std::string(edm_name), wrapper); - if (sc == StatusCode::FAILURE) { - error() << "Error registering collection " << edm_name << endmsg; - return; - } - } else { - debug() << "Collection " << edm_name << " was already registered" << endmsg; + // No need to check for pre-existing collections, since we only ever end up + // here if that is not the case + auto sc = m_podioDataSvc->registerObject("/Event", "/" + std::string(name), wrapper); + if (sc == StatusCode::FAILURE) { + error() << "Could not register collection " << name << endmsg; } - // Convert Metadata - if (cnv_metadata) { - // int params_size = lcio_coll->getParameters().size(); + auto handle = DataHandle{name, Gaudi::DataHandle::Reader, this}; - DataHandle ahandle{edm_name, Gaudi::DataHandle::Reader, this}; - const auto acoll = ahandle.get(); - auto acollid = acoll->getID(); + // Convert metadata + if (lcioColl != nullptr) { + const auto acollid = handle.get()->getID(); std::vector string_keys = {}; - lcio_coll->getParameters().getStringKeys(string_keys); + lcioColl->getParameters().getStringKeys(string_keys); auto& e4h_coll_md = m_podioDataSvc->getProvider().getCollectionMetaData(acollid); for (auto& elem : string_keys) { if (elem == "CellIDEncoding") { - std::string lcio_coll_cellid_str = lcio_coll->getParameters().getStringVal(lcio::LCIO::CellIDEncoding); + std::string lcio_coll_cellid_str = lcioColl->getParameters().getStringVal(lcio::LCIO::CellIDEncoding); e4h_coll_md.setValue("CellIDEncodingString", lcio_coll_cellid_str); } else { - std::string lcio_coll_value = lcio_coll->getParameters().getStringVal(elem); + std::string lcio_coll_value = lcioColl->getParameters().getStringVal(elem); e4h_coll_md.setValue(elem, lcio_coll_value); } } } } -// ********************************** -// Check if a collection was already registered to skip it -// ********************************** -bool Lcio2EDM4hepTool::collectionExist(const std::string& collection_name) { - auto collections = m_podioDataSvc->getCollections(); - for (const auto& [name, coll] : collections) { - if (collection_name == name) { - debug() << "Collection named " << name << " already registered, skipping conversion." << endmsg; - return true; - } - } - return false; -} - -// ********************************** -// - Convert all collections indicated in Tool parameters -// - Some collections implicitly convert associated collections, as for -// key4hep/k4LCIOReader -// - Convert associated collections from LCRelation for existing EDM4hep relations -// - Converted collections are put into TES -// ********************************** StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) { - // Set the event to the converter - podio::CollectionIDTable* id_table = m_podioDataSvc->getCollectionIDs(); - std::unique_ptr lcio_converter = std::make_unique(id_table); - lcio_converter->set(the_event); + // Convert Event Header outside the collections loop + if (!collectionExist("EventHeader")) { + registerCollection("EventHeader", LCIO2EDM4hepConv::createEventHeader(the_event)); + } // Start off with the pre-defined collection name mappings auto collsToConvert{m_collNames.value()}; @@ -140,98 +108,62 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) { } } - // Convert Event Header outside the collections loop - if (!collectionExist("EventHeader")) { - convertRegister("EventHeader", "EventHeader", lcio_converter, nullptr); - } + auto lcio2edm4hepMaps = LCIO2EDM4hepConv::LcioEdmTypeMapping{}; + + std::vector> lcRelationColls{}; + std::vector> subsetColls{}; - // Convert collections indicated in the parameters for (const auto& [lcioName, edm4hepName] : collsToConvert) { - if (!collectionExist(edm4hepName)) { - std::string lcio_coll_type_str = ""; - lcio::LCCollection* lcio_coll = nullptr; - try { - // Get type string from collection name - lcio_coll = the_event->getCollection(lcioName); - lcio_coll_type_str = lcio_coll->getTypeName(); - } catch (const lcio::DataNotAvailableException& ex) { - warning() << "LCIO Collection " << lcioName << " not found in the event, skipping conversion to EDM4hep" - << endmsg; + try { + auto* lcio_coll = the_event->getCollection(lcioName); + debug() << "Converting collection " << lcioName << " (storing it as " << edm4hepName << "). "; + if (collectionExist(edm4hepName)) { + debug() << "Collection already exists, skipping." << endmsg; + continue; // No need to convert again + } + const auto& lcio_coll_type_str = lcio_coll->getTypeName(); + debug() << "LCIO type of the relation is " << lcio_coll_type_str << endmsg; + + // We deal with subset collections and LCRelations once we have all data + // converted + if (lcio_coll->isSubset()) { + subsetColls.emplace_back(std::make_tuple(edm4hepName, lcio_coll, lcio_coll_type_str)); continue; } + if (lcio_coll_type_str == "LCRelation") { + lcRelationColls.emplace_back(std::make_pair(edm4hepName, lcio_coll)); + } - if (lcio_coll_type_str == "ReconstructedParticle") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - // Get associated collection. Name hardcoded in k4LCIOConverter - convertRegister("ParticleID_EXT", "ParticleID_EXT", lcio_converter, nullptr); - convertRegister("Vertex_EXT", "Vertex_EXT", lcio_converter, nullptr); - } else if (lcio_coll_type_str == "ParticleID") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "MCParticle") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "Vertex") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "Track") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "TrackerHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll, true); - } else if (lcio_coll_type_str == "TrackerHitPlane") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll, true); - } else if (lcio_coll_type_str == "SimTrackerHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll, true); - } else if (lcio_coll_type_str == "CalorimeterHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll, true); - } else if (lcio_coll_type_str == "SimCalorimeterHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll, true); - // Get associated collections - // This collection name is hardcoded in k4LCIOConverter - convertRegister("CaloHitContribution_EXT", "CaloHitContribution_EXT", - lcio_converter, nullptr); - } else if (lcio_coll_type_str == "RawCalorimeterHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "TPCHit") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (lcio_coll_type_str == "Cluster") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - // Get associated collection. Name hardcoded in k4LCIOConverter - convertRegister("ParticleID_EXT", "ParticleID_EXT", lcio_converter, nullptr); - } else if (lcio_coll_type_str == "LCRelation") { - // Get specific relation type from converted - auto* conv_collection = lcio_converter->getCollection(lcioName); - if (conv_collection == nullptr) { - error() << "Unable to convert collection " << lcioName << std::endl; - continue; - } - auto e4h_coll_type_str = conv_collection->getValueTypeName(); - - if (e4h_coll_type_str == "edm4hep::MCRecoCaloAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, lcio_coll); - } else if (e4h_coll_type_str == "edm4hep::MCRecoTrackerAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, - lcio_coll); - } else if (e4h_coll_type_str == "edm4hep::MCRecoParticleAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, - lcio_coll); - } else if (e4h_coll_type_str == "edm4hep::MCRecoCaloParticleAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, - lcio_coll); - } else if (e4h_coll_type_str == "edm4hep::MCRecoTrackParticleAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, - lcio_coll); - } else if (e4h_coll_type_str == "edm4hep::RecoParticleVertexAssociation") { - convertRegister(edm4hepName, lcioName, lcio_converter, - lcio_coll); + for (auto&& e4hColl : LCIO2EDM4hepConv::convertCollection(edm4hepName, lcio_coll, lcio2edm4hepMaps)) { + if (std::get<1>(e4hColl)) { + registerCollection(std::move(e4hColl)); } else { - error() << "Unsuported LCRelation for collection " << lcioName << std::endl; + error() << "Could not convert collection " << lcioName << " (type: " << lcio_coll_type_str << ")" << endmsg; } - - } else { - error() << lcio_coll_type_str << ": conversion type not supported." << endmsg; } - } else { - debug() << "EDM4hep Collection " << edm4hepName << " already in place, skipping conversion." << endmsg; + } catch (const lcio::DataNotAvailableException& ex) { + warning() << "LCIO Collection " << lcioName << " not found in the event, skipping conversion to EDM4hep" + << endmsg; + continue; } } + // Now we can resolve relations, subset collections and LCRelations + LCIO2EDM4hepConv::resolveRelations(lcio2edm4hepMaps); + + for (const auto& [name, coll, type] : subsetColls) { + registerCollection(name, LCIO2EDM4hepConv::fillSubset(coll, lcio2edm4hepMaps, type)); + } + + for (auto&& assocColl : LCIO2EDM4hepConv::createAssociations(lcio2edm4hepMaps, lcRelationColls)) { + registerCollection(std::move(assocColl)); + } + + if (!lcio2edm4hepMaps.simCaloHits.empty()) { + registerCollection( + name() + "_CaloHitContributions", + LCIO2EDM4hepConv::createCaloHitContributions(lcio2edm4hepMaps.simCaloHits, lcio2edm4hepMaps.mcParticles)); + } + return StatusCode::SUCCESS; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c7849ed0..644b1131 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,6 @@ gaudi_add_module(TestE4H2L ${LCIO_LIBRARIES} k4FWCore::k4FWCore EDM4HEP::edm4hep - k4LCIOReader::k4LCIOReader ) target_include_directories(TestE4H2L PUBLIC diff --git a/test/gaudi_opts/edm_converters.py b/test/gaudi_opts/edm_converters.py index 4bfa25a2..aa5bcc84 100644 --- a/test/gaudi_opts/edm_converters.py +++ b/test/gaudi_opts/edm_converters.py @@ -27,7 +27,7 @@ lcioConvTool.convertAll = False lcioConvTool.collNameMapping = { "LCIO_CaloHitCollection": "E4H_CaloHitCollection_conv", - # "LCIO_TrackerHitCollection": "E4H_TrackerHitCollection_conv", + "LCIO_TrackerHitCollection": "E4H_TrackerHitCollection_conv", "LCIO_SimTrackerHitCollection": "E4H_SimTrackerHitCollection_conv", "LCIO_TrackCollection": "E4H_TrackCollection_conv", "LCIO_MCParticleCollection": "E4H_MCParticleCollection_conv", diff --git a/test/inputFiles/anajob_Output_DST.expected b/test/inputFiles/anajob_Output_DST.expected index fdc929e8..af32995e 100644 --- a/test/inputFiles/anajob_Output_DST.expected +++ b/test/inputFiles/anajob_Output_DST.expected @@ -1,6 +1,6 @@ anajob: will open and read from files: - Output_DST.slcio [ number of runs: 0, number of events: 1 ] + Output_DST.slcio [ number of runs: 0, number of events: 3 ] will reopen and read from files: @@ -50,7 +50,7 @@ TightSelectedPandoraPFOs ReconstructedParticle 67 /////////////////////////////////// -EVENT: 0 +EVENT: 1 RUN: 0 DETECTOR: unknown COLLECTIONS: (see below) @@ -59,8 +59,8 @@ COLLECTIONS: (see below) --------------------------------------------------------------------------- COLLECTION NAME COLLECTION TYPE NUMBER OF ELEMENTS =========================================================================== -BuildUpVertices Vertex 3 -BuildUpVertices_RP ReconstructedParticle 3 +BuildUpVertices Vertex 2 +BuildUpVertices_RP ReconstructedParticle 2 BuildUpVertices_V0 Vertex 0 BuildUpVertices_V0_RP ReconstructedParticle 0 LE_LooseSelectedPandoraPFOs ReconstructedParticle 92 @@ -80,21 +80,21 @@ PrimaryVertices Vertex 1 PrimaryVertices_RP ReconstructedParticle 1 RecoMCTruthLink LCRelation 93 RefinedVertexJets ReconstructedParticle 2 -RefinedVertexJets_rel LCRelation 2 -RefinedVertexJets_vtx Vertex 2 -RefinedVertexJets_vtx_RP ReconstructedParticle 2 -RefinedVertices Vertex 2 -RefinedVertices_RP ReconstructedParticle 2 -SelectedPandoraPFOs ReconstructedParticle 83 +RefinedVertexJets_rel LCRelation 1 +RefinedVertexJets_vtx Vertex 1 +RefinedVertexJets_vtx_RP ReconstructedParticle 1 +RefinedVertices Vertex 1 +RefinedVertices_RP ReconstructedParticle 1 +SelectedPandoraPFOs ReconstructedParticle 82 SiTracks Track 43 SiTracks_Refitted Track 43 -TightSelectedPandoraPFOs ReconstructedParticle 70 +TightSelectedPandoraPFOs ReconstructedParticle 69 --------------------------------------------------------------------------- /////////////////////////////////// -EVENT: 0 +EVENT: 2 RUN: 0 DETECTOR: unknown COLLECTIONS: (see below) diff --git a/test/inputFiles/anajob_Output_REC.expected b/test/inputFiles/anajob_Output_REC.expected index d91cd938..f9c96948 100644 --- a/test/inputFiles/anajob_Output_REC.expected +++ b/test/inputFiles/anajob_Output_REC.expected @@ -1,6 +1,6 @@ anajob: will open and read from files: - Output_REC.slcio [ number of runs: 0, number of events: 1 ] + Output_REC.slcio [ number of runs: 0, number of events: 3 ] will reopen and read from files: @@ -96,7 +96,7 @@ YokeEndcapCollection SimCalorimeterHit 6 /////////////////////////////////// -EVENT: 0 +EVENT: 1 RUN: 0 DETECTOR: unknown COLLECTIONS: (see below) @@ -106,8 +106,8 @@ COLLECTIONS: (see below) COLLECTION NAME COLLECTION TYPE NUMBER OF ELEMENTS =========================================================================== BeamCalCollection SimCalorimeterHit 6 -BuildUpVertices Vertex 3 -BuildUpVertices_RP ReconstructedParticle 3 +BuildUpVertices Vertex 2 +BuildUpVertices_RP ReconstructedParticle 2 BuildUpVertices_V0 Vertex 0 BuildUpVertices_V0_RP ReconstructedParticle 0 CalohitMCTruthLink LCRelation 9010 @@ -159,19 +159,19 @@ PrimaryVertices Vertex 1 PrimaryVertices_RP ReconstructedParticle 1 RecoMCTruthLink LCRelation 93 RefinedVertexJets ReconstructedParticle 2 -RefinedVertexJets_rel LCRelation 2 -RefinedVertexJets_vtx Vertex 2 -RefinedVertexJets_vtx_RP ReconstructedParticle 2 -RefinedVertices Vertex 2 -RefinedVertices_RP ReconstructedParticle 2 +RefinedVertexJets_rel LCRelation 1 +RefinedVertexJets_vtx Vertex 1 +RefinedVertexJets_vtx_RP ReconstructedParticle 1 +RefinedVertices Vertex 1 +RefinedVertices_RP ReconstructedParticle 1 RelationCaloHit LCRelation 8909 RelationMuonHit LCRelation 0 -SelectedPandoraPFOs ReconstructedParticle 83 +SelectedPandoraPFOs ReconstructedParticle 82 SiTracks Track 43 SiTracksCT Track 43 SiTracksMCTruthLink LCRelation 43 SiTracks_Refitted Track 43 -TightSelectedPandoraPFOs ReconstructedParticle 70 +TightSelectedPandoraPFOs ReconstructedParticle 69 VXDEndcapTrackerHitRelations LCRelation 19 VXDEndcapTrackerHits TrackerHitPlane 19 VXDTrackerHitRelations LCRelation 268 @@ -186,7 +186,7 @@ YokeEndcapCollection SimCalorimeterHit 0 /////////////////////////////////// -EVENT: 0 +EVENT: 2 RUN: 0 DETECTOR: unknown COLLECTIONS: (see below) diff --git a/test/src/TestE4H2L.cpp b/test/src/TestE4H2L.cpp index b7d8e290..7d61c626 100644 --- a/test/src/TestE4H2L.cpp +++ b/test/src/TestE4H2L.cpp @@ -1000,6 +1000,11 @@ bool TestE4H2L::checkEDMTrackEDMTrack(const std::vector>& bool track_same = (*track_coll_orig).size() == (*track_coll).size(); + if (!track_same) { + error() << "Track collections do not have the same size (expected " << track_coll_orig->size() << ", actual " + << track_coll->size() << ")" << endmsg; + } + if (track_same) { for (int i = 0; i < (*track_coll).size(); ++i) { auto edm_track_orig = (*track_coll_orig)[i]; @@ -1015,6 +1020,12 @@ bool TestE4H2L::checkEDMTrackEDMTrack(const std::vector>& track_same = track_same && (edm_track_orig.getRadiusOfInnermostHit() == edm_track.getRadiusOfInnermostHit()); track_same = track_same && (edm_track_orig.trackerHits_size() == edm_track.trackerHits_size()); + + if (!track_same) { + error() << "Track " << i << " differs: (expected: " << edm_track_orig << ", actual: " << edm_track << ")" + << endmsg; + } + if ((edm_track_orig.trackerHits_size() == edm_track.trackerHits_size())) { for (int j = 0; j < edm_track_orig.trackerHits_size(); ++j) { auto edm_trackerhit_orig = edm_track_orig.getTrackerHits(j); @@ -1030,6 +1041,11 @@ bool TestE4H2L::checkEDMTrackEDMTrack(const std::vector>& track_same = track_same && (edm_trackerhit_orig.getPosition() == edm_trackerhit.getPosition()); track_same = track_same && (edm_trackerhit_orig.getCovMatrix() == edm_trackerhit.getCovMatrix()); + if (!track_same) { + error() << "TrackerHit " << j << " of track " << i << " differs: (expected: " << edm_trackerhit_orig + << ", actual: " << edm_trackerhit << ")" << endmsg; + } + // TODO Raw hits } } @@ -1076,6 +1092,10 @@ bool TestE4H2L::checkEDMTrackEDMTrack(const std::vector>& } #endif + if (!track_same) { + error() << "subdetectorHitNumbers of track " << i << " differ" << endmsg; + } + track_same = track_same && (edm_track_orig.trackStates_size() == edm_track.trackStates_size()); if ((edm_track_orig.trackStates_size() == edm_track.trackStates_size())) { for (int j = 0; j < edm_track_orig.trackStates_size(); ++j) { @@ -1093,6 +1113,11 @@ bool TestE4H2L::checkEDMTrackEDMTrack(const std::vector>& for (int k = 0; k < 15; ++k) { track_same = track_same && (edm_trackestate_orig.covMatrix[k] == edm_trackestate.covMatrix[k]); } + + if (!track_same) { + error() << "trackState " << j << " of track " << i << " differs (expected: " << edm_trackestate_orig + << ", actual: " << edm_trackestate << ")" << endmsg; + } } } }