Skip to content
Snippets Groups Projects
Commit 54ed5d7f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch '22.0-unit_test-TrkTrackSummaryTool' into 'master'

22.0-unit_test-TrkTrackSummaryTool

See merge request atlas/athena!38968
parents 68686766 9e421226
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,17 @@ atlas_subdir( TrkTrackSummaryTool ) ...@@ -7,7 +7,17 @@ atlas_subdir( TrkTrackSummaryTool )
atlas_add_component( TrkTrackSummaryTool atlas_add_component( TrkTrackSummaryTool
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps GaudiKernel TrkParameters TrkTrackSummary TrkToolInterfaces AtlasDetDescr Identifier TrkDetElementBase TrkGeometry TrkCompetingRIOsOnTrack TrkEventPrimitives TrkMeasurementBase TrkRIO_OnTrack TrkTrack TRT_ElectronPidToolsLib ) LINK_LIBRARIES AthenaBaseComps GaudiKernel TrkTrackSummary TrkToolInterfaces AtlasDetDescr Identifier TrkDetElementBase TrkGeometry TrkCompetingRIOsOnTrack TrkEventPrimitives TrkMeasurementBase TrkRIO_OnTrack TrkTrack TRT_ElectronPidToolsLib )
atlas_add_test(TrackSummaryTool_test
SOURCES test/TrackSummaryTool_test.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel IdDictParser StoreGateLib TrkToolInterfaces AtlasDetDescr Identifier TrkDetElementBase TrkGeometry TrkCompetingRIOsOnTrack TrkEventPrimitives TrkMeasurementBase TrkRIO_OnTrack TrkTrack TRT_ElectronPidToolsLib
POST_EXEC_SCRIPT "nopost.sh" )
# Install files from the package:
atlas_install_joboptions( share/*.txt )
# Install files from the package: # Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
EventDataSvc.ForceLeaves = true;
EventDataSvc.RootCLID = 1;
ApplicationMgr.Dlls += { "AthenaServices" };
ApplicationMgr.ExtSvc = {"StoreGateSvc"};
ApplicationMgr.EvtMax = 1;
ApplicationMgr.EvtSel = "TestEvtSelector";
ApplicationMgr.HistogramPersistency = "NONE";
MessageSvc.OutputLevel = 5;
EventDataSvc.ForceLeaves = true;
EventDataSvc.RootCLID = 1;
ApplicationMgr.Dlls += { "AthenaServices", "StoreGate" };
ApplicationMgr.ExtSvc = {"StoreGateSvc", "StoreGateSvc/DetectorStore"};
ApplicationMgr.EvtMax = 1;
ApplicationMgr.EvtSel = "TestEvtSelector";
ApplicationMgr.HistogramPersistency = "NONE";
MessageSvc.OutputLevel = 3;
...@@ -66,8 +66,7 @@ StatusCode ...@@ -66,8 +66,7 @@ StatusCode
Trk::TrackSummaryTool::initialize(){ Trk::TrackSummaryTool::initialize(){
ATH_CHECK( detStore()->retrieve(m_detID, "AtlasID" )); ATH_CHECK( detStore()->retrieve(m_detID, "AtlasID" ));
if (m_idTool.empty() && m_muonTool.empty()) { if (m_idTool.empty() && m_muonTool.empty()) {
ATH_MSG_ERROR ("Could get neither InDetHelperTool nor MuonHelperTool. Must abort."); ATH_MSG_WARNING ("Could get neither InDetHelperTool nor MuonHelperTool.");
return StatusCode::FAILURE;
} }
if (not m_idTool.empty()) ATH_CHECK(m_idTool.retrieve()); if (not m_idTool.empty()) ATH_CHECK(m_idTool.retrieve());
if (not m_eProbabilityTool.empty()) ATH_CHECK(m_eProbabilityTool.retrieve()); if (not m_eProbabilityTool.empty()) ATH_CHECK(m_eProbabilityTool.retrieve());
...@@ -305,7 +304,9 @@ Trk::TrackSummaryTool::updateSharedHitCount( ...@@ -305,7 +304,9 @@ Trk::TrackSummaryTool::updateSharedHitCount(
TrackSummary& summary) const TrackSummary& summary) const
{ {
// first check if track has no summary - then it is recreated // first check if track has no summary - then it is recreated
m_idTool->updateSharedHitCount(track, prdToTrackMap, summary); if (m_idTool){
m_idTool->updateSharedHitCount(track, prdToTrackMap, summary);
}
} }
void void
...@@ -330,10 +331,12 @@ Trk::TrackSummaryTool::updateAdditionalInfo(const Track& track, ...@@ -330,10 +331,12 @@ Trk::TrackSummaryTool::updateAdditionalInfo(const Track& track,
if (track.info().trackFitter() != TrackInfo::Unknown && !m_dedxtool.empty()) { if (track.info().trackFitter() != TrackInfo::Unknown && !m_dedxtool.empty()) {
dedx = m_dedxtool->dEdx(track, nHitsUsed_dEdx, nOverflowHits_dEdx); dedx = m_dedxtool->dEdx(track, nHitsUsed_dEdx, nOverflowHits_dEdx);
} }
m_idTool->updateAdditionalInfo(summary, eProbability,dedx, nHitsUsed_dEdx,nOverflowHits_dEdx); if (m_idTool){
m_idTool->updateExpectedHitInfo(track, summary); m_idTool->updateAdditionalInfo(summary, eProbability,dedx, nHitsUsed_dEdx,nOverflowHits_dEdx);
if (m_addInDetDetailedSummary) { m_idTool->updateExpectedHitInfo(track, summary);
m_idTool->addDetailedTrackSummary(track,summary); if (m_addInDetDetailedSummary) m_idTool->addDetailedTrackSummary(track,summary);
} else {
ATH_MSG_INFO("No updates attempted, as the SummaryHelperTool is not defined.");
} }
} }
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
/*
*/
/**
* @file TrkTrackSummaryUpdater/test/TrackSummaryUpdater_test.cxx
* @author Shaun Roe
* @date Dec, 2020
* @brief Some tests for TrackSummaryTool algorithm in the Boost framework
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE TEST_TRKTRACKSUMMARYTOOL
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#include <boost/test/unit_test.hpp>
#pragma GCC diagnostic pop
//
#include "GaudiKernel/ISvcLocator.h"
#include "StoreGate/StoreGateSvc.h"
#include "CxxUtils/checker_macros.h"
#include "TInterpreter.h"
//
#include "GaudiKernel/IAppMgrUI.h"
#include "GaudiKernel/SmartIF.h"
#include "GaudiKernel/EventContext.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "CxxUtils/ubsan_suppress.h"
#include "IdDictParser/IdDictParser.h"
#include "AtlasDetDescr/AtlasDetectorID.h"
#include "TrkTrackSummaryTool/TrackSummaryTool.h"
ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // This test uses global svcLoc.
// Gaudi fixture
class GaudiFixture {
public:
ISvcLocator *
svcLoc(){
return m_svcLoc;
}
IToolSvc *
toolSvc(){
return m_toolSvc;
}
StoreGateSvc*
storeGateSvc(){
return m_sg;
}
StoreGateSvc*
detStore(){
return m_detStore;
}
GaudiFixture(const std::string & joPath = "TrkTrackSummaryUpdater/TrackSummaryUpdater_test.txt") {
setUpGaudi(joPath);
}
~GaudiFixture() {
tearDownGaudi();
}
private:
void
setUpGaudi(const std::string & joPath) {
CxxUtils::ubsan_suppress ([]() { TInterpreter::Instance(); } );
m_appMgr = Gaudi::createApplicationMgr();
m_svcLoc = m_appMgr;
m_svcMgr = m_appMgr;
m_propMgr = m_appMgr;
m_propMgr->setProperty( "EvtSel", "NONE" ).ignore() ;
m_propMgr->setProperty( "JobOptionsType", "FILE" ).ignore();
m_propMgr->setProperty( "JobOptionsPath", joPath ).ignore();
m_toolSvc = m_svcLoc->service("ToolSvc");
m_appMgr->configure().ignore();
m_appMgr->initialize().ignore();
m_sg = nullptr;
m_svcLoc->service ("StoreGateSvc", m_sg).ignore();
m_svcLoc->service ("StoreGateSvc/DetectorStore", m_detStore).ignore();
}
void
tearDownGaudi() {
m_svcMgr->finalize().ignore();
m_appMgr->finalize().ignore();
m_appMgr->terminate().ignore();
m_svcLoc->release();
m_svcMgr->release();
Gaudi::setInstance( static_cast<IAppMgrUI*>(nullptr) );
}
StoreGateSvc*
evtStore(){
return m_sg;
}
//member variables for Core Gaudi components
IAppMgrUI* m_appMgr{nullptr};
SmartIF<ISvcLocator> m_svcLoc;
SmartIF<ISvcManager> m_svcMgr;
SmartIF<IToolSvc> m_toolSvc;
SmartIF<IProperty> m_propMgr;
StoreGateSvc* m_sg{ nullptr };
StoreGateSvc * m_detStore{nullptr};
};
BOOST_AUTO_TEST_SUITE(TrackSummaryUpdaterTest)
GaudiFixture g("TrkTrackSummaryTool/TrackSummaryTool_test.txt");
auto pSvcLoc=g.svcLoc();
auto pToolSvc=g.toolSvc();
auto pDetStore=g.detStore();
IAlgTool* pToolInterface{};
BOOST_AUTO_TEST_CASE( sanityCheck ){
const bool svcLocatorIsOk=(pSvcLoc != nullptr);
BOOST_TEST(svcLocatorIsOk);
const bool toolSvcIsOk = ( pToolSvc != nullptr);
BOOST_TEST(toolSvcIsOk);
const bool detStoreIsOk = (pDetStore != nullptr);
BOOST_TEST(detStoreIsOk);
}
BOOST_AUTO_TEST_CASE(retrieveTool){
static IdDictParser parser;
parser.register_external_entity ("InnerDetector","IdDictInnerDetector.xml");
parser.register_external_entity ("MuonSpectrometer","IdDictMuonSpectrometer_S.02.xml");
parser.register_external_entity ("Calorimeter","IdDictCalorimeter_L1Onl.xml");
IdDictMgr& idDict = parser.parse ("IdDictParser/ATLAS_IDS.xml");
auto atlasId = std::make_unique<AtlasDetectorID>();
atlasId->initialize_from_dictionary (idDict);
if (pDetStore and (not pDetStore->contains<AtlasDetectorID>("AtlasID"))) {
BOOST_TEST ( pDetStore->record (std::move (atlasId), "AtlasID").isSuccess() );
}
BOOST_TEST ( pToolSvc->retrieveTool("Trk::TrackSummaryTool", pToolInterface).isSuccess());
BOOST_TEST(pToolInterface -> initialize());
}
BOOST_AUTO_TEST_SUITE_END()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment