From c651348743d33c76cc4990284e094df2129903df Mon Sep 17 00:00:00 2001 From: Will Buttinger <William.Buttinger@cern.ch> Date: Mon, 1 Aug 2016 08:56:45 +0200 Subject: [PATCH] 'fix cmake' (TriggerMatchingTool-00-00-12) * fix cmake * tagging 00-00-12 2016-06-27 Will Buttinger <will@cern.ch> * MatchingImplementation.cxx: Avoid running Munkres is doomed to fail threshold cut * src/TestMatchingToolAlg: update to store and output decisions for monitoring in atn nightlies * Tagging TriggerMatchingTool-00-00-10 * cmt/requirements: add missing use statement * Tagging TriggerMatchingTool-00-00-11 2016-04-06 Lukas Heinrich * Tagging TriggerMatchingTool-00-00-09 * silence DEBUG Former-commit-id: 173ed41e569dd0fb48c983d9bae54ac0843e3371 --- .../TriggerMatchingTool/CMakeLists.txt | 7 ++- .../Root/MatchingImplementation.cxx | 16 +++++- .../TriggerMatchingTool/cmt/requirements | 4 +- .../share/TestMatchingToolAlgJobOptions.py | 6 +- .../src/TestMatchingToolAlg.cxx | 57 ++++++++++++++----- .../src/TestMatchingToolAlg.h | 5 ++ .../test/TriggerMatchingTool.xml | 5 +- 7 files changed, 75 insertions(+), 25 deletions(-) diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/CMakeLists.txt b/Trigger/TrigAnalysis/TriggerMatchingTool/CMakeLists.txt index 701bd630e43f..c4ba875d82ae 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/CMakeLists.txt +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/CMakeLists.txt @@ -16,6 +16,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthAnalysisBaseComps Event/FourMomUtils ) + # External dependencies: find_package( Boost COMPONENTS filesystem thread system ) find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) @@ -27,16 +28,16 @@ atlas_add_library( TriggerMatchingToolLib PUBLIC_HEADERS TriggerMatchingTool PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES AsgTools xAODBase GaudiKernel TrigNavStructure TrigDecisionToolLib - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthAnalysisBaseComps FourMomUtils ) + PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib FourMomUtils ) atlas_add_component( TriggerMatchingTool src/components/*.cxx INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools xAODBase GaudiKernel TrigDecisionToolLib TrigNavStructure AthAnalysisBaseComps FourMomUtils TriggerMatchingToolLib ) + LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools xAODBase GaudiKernel TrigDecisionToolLib TrigNavStructure AthAnalysisBaseCompsLib FourMomUtils TriggerMatchingToolLib ) atlas_add_dictionary( TriggerMatchingToolDict TriggerMatchingTool/TriggerMatchingToolDict.h TriggerMatchingTool/selection.xml INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools xAODBase GaudiKernel TrigDecisionToolLib TrigNavStructure AthAnalysisBaseComps FourMomUtils TriggerMatchingToolLib ) + LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools xAODBase GaudiKernel TrigDecisionToolLib TrigNavStructure AthAnalysisBaseCompsLib FourMomUtils TriggerMatchingToolLib ) diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/Root/MatchingImplementation.cxx b/Trigger/TrigAnalysis/TriggerMatchingTool/Root/MatchingImplementation.cxx index 370766276d32..54e9512ea14e 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/Root/MatchingImplementation.cxx +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/Root/MatchingImplementation.cxx @@ -9,7 +9,6 @@ namespace Trig { MatchingImplementation::MatchingImplementation(MatchingTool& mt, double threshold) : asg::AsgMessaging("MatchingImplementation"), m_tool(mt), m_threshold(threshold) { - msg().setLevel(MSG::DEBUG); m_strategies[Trig::MatchingStrategy::MinimalSum] = std::unique_ptr<IAssociationStrategy>(new MinimalSumAssociation()); } @@ -38,6 +37,7 @@ bool MatchingImplementation::matchDistanceMatrix(const std::vector<std::vector<d ATH_MSG_DEBUG("matching a " << nrows << "x" << ncols << "matrix now"); + auto MSG_MATRIX = MSG::DEBUG; if(msgLvl(MSG_MATRIX)){ msg() << MSG_MATRIX << "===========" << endreq; @@ -50,9 +50,21 @@ bool MatchingImplementation::matchDistanceMatrix(const std::vector<std::vector<d } msg() << MSG_MATRIX << "===========" << endreq; } + + + //require that every row contains an entry that is smaller than threshold, otherwise matching will obviously fail + for(auto& row : matrix) { + bool rowOk=false; + for(auto distance : row) { + if( distance < m_threshold ) { rowOk = true; break; } + } + if(!rowOk) { + ATH_MSG_DEBUG("row of matrix does not contain any distance below threshold. Return false"); return false; + } + } auto association_map = m_strategies[strategy]->associate(matrix); return assocIsMatched(association_map,matrix); } -} \ No newline at end of file +} diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/cmt/requirements b/Trigger/TrigAnalysis/TriggerMatchingTool/cmt/requirements index 40f7657aec6e..95d0bd734418 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/cmt/requirements +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/cmt/requirements @@ -1,9 +1,11 @@ package TriggerMatchingTool author Lukas Heinrich <lukas.heinrich@cern.ch> +author Will Buttinger <will@cern.ch> use AtlasPolicy AtlasPolicy-* + public use GaudiInterface GaudiInterface-* External use AsgTools AsgTools-* Control/AthToolSupport @@ -18,7 +20,7 @@ use FourMomUtils FourMomUtils-* Event use AthAnalysisBaseComps AthAnalysisBaseComps-* Control #uncomment the next line to use ROOT libraries in your package -#use AtlasROOT AtlasROOT-* External +use AtlasROOT AtlasROOT-* External #use xAODEventInfo xAODEventInfo-* Event/xAOD diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/share/TestMatchingToolAlgJobOptions.py b/Trigger/TrigAnalysis/TriggerMatchingTool/share/TestMatchingToolAlgJobOptions.py index b207a969f500..873812f261db 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/share/TestMatchingToolAlgJobOptions.py +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/share/TestMatchingToolAlgJobOptions.py @@ -1,6 +1,6 @@ #Skeleton joboption for a simple analysis job -theApp.EvtMax=10 #says how many events to run over. Set to -1 for all events +theApp.EvtMax=1000 #says how many events to run over. Set to -1 for all events import AthenaPoolCnvSvc.ReadAthenaPool #sets up reading of POOL files (e.g. xAODs) inputfile = os.environ.get("ASG_TEST_FILE_MC", "/afs/cern.ch/user/a/asgbase/patspace/xAODs/r6630/mc15_13TeV.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.recon.AOD.e3601_s2576_s2132_r6630_tid05358812_00/AOD.05358812._000010.pool.root.1") @@ -12,7 +12,7 @@ ToolSvc += CfgMgr.Trig__MatchingTool("MyMatchingTool",OutputLevel=DEBUG) algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer algseq += CfgMgr.TestMatchingToolAlg() #adds an instance of your alg to it - +#svcMgr.MessageSvc.infoLimit=9999999999 +#svcMgr.MessageSvc.debugLimit=9999999999 include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above - diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.cxx b/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.cxx index fad009e52b79..7d5b19614e80 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.cxx +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.cxx @@ -6,6 +6,9 @@ #include "TestMatchingToolAlg.h" #include "xAODBase/IParticleContainer.h" +#include "TH1D.h" +#include "TFile.h" + StatusCode TestMatchingToolAlg::initialize() { m_tmt.setTypeAndName("Trig::MatchingTool/MyMatchingTool"); CHECK(m_tmt.retrieve()); //important to retrieve here, because TrigDecisionTool must be initialized before event loop @@ -34,11 +37,14 @@ StatusCode TestMatchingToolAlg::execute() { std::vector<const xAOD::IParticle*> myParticles; //here's an example of a single object trigger + bool res(false); if (electrons) { for(uint i = 0; i< electrons->size(); i++) { myParticles.clear(); myParticles.push_back( electrons->at(i) ); - ATH_MSG_INFO("HLT_e17_lhloose Matching Decision = " << m_tmt->match(myParticles,"HLT_e17_lhloose",0.07 /*explicit dR threhsold*/) ); + res = m_tmt->match(myParticles,"HLT_e17_lhloose",0.07 /*explicit dR threhsold*/); + m_matches["HLT_e17_lhloose"] += res; + ATH_MSG_INFO("HLT_e17_lhloose Matching Decision = " << res ); // here's an example of a combined trigger // e-mu @@ -47,7 +53,9 @@ StatusCode TestMatchingToolAlg::execute() { myParticles.clear(); myParticles.push_back(electrons->at(i)); myParticles.push_back(muons->at(j)); - ATH_MSG_INFO("HLT_e17_lhloose_mu14 = " << m_tmt->match(myParticles,"HLT_e17_lhloose_mu14")); + res = m_tmt->match(myParticles,"HLT_e17_lhloose_mu14"); + m_matches["HLT_e17_lhloose_mu14"] += res; + ATH_MSG_INFO("HLT_e17_lhloose_mu14 = " << res); } } // e-tau @@ -56,7 +64,9 @@ StatusCode TestMatchingToolAlg::execute() { myParticles.clear(); myParticles.push_back(electrons->at(i)); myParticles.push_back(taus->at(j)); - ATH_MSG_INFO("HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo = " << m_tmt->match(myParticles,"HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo")); + res = m_tmt->match(myParticles,"HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo"); + m_matches["HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo"] += res; + ATH_MSG_INFO("HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo = " << res); } } } @@ -65,28 +75,47 @@ StatusCode TestMatchingToolAlg::execute() { // here's an example for muon trigger, using the method for single-object trigger matching if(muons){ for(auto muon : *muons) { - ATH_MSG_INFO("HLT_mu18 = " << m_tmt->match(*muon,"HLT_mu18")); + res = m_tmt->match(*muon,"HLT_mu18"); + m_matches["HLT_mu18"] += res; + ATH_MSG_INFO("HLT_mu18 = " << res); } } // here's an examplefor a tau trigger if(taus){ for(uint j = 0; j < taus->size(); j++) { - myParticles.clear(); - myParticles.push_back(taus->at(j)); - ATH_MSG_INFO("HLT_tau25_loose1_ptonly = " << m_tmt->match(myParticles,"HLT_tau25_loose1_ptonly")); + res = m_tmt->match(*taus->at(j),"HLT_tau25_loose1_ptonly"); + m_matches["HLT_tau25_loose1_ptonly"] += res; + ATH_MSG_INFO("HLT_tau25_loose1_ptonly = " << res); } } //here's an example for a dilepton trigger //form pairs to test a dilepton trigger - for(uint i = 0; i< electrons->size()-1; i++) { - for(uint j = i+1; j < electrons->size(); j++) { - myParticles.clear(); - myParticles.push_back( electrons->at(i) ); - myParticles.push_back( electrons->at(j) ); - ATH_MSG_INFO("HLT_2e17_lhloose Matching Decision = " << m_tmt->match(myParticles,"HLT_2e17_lhloose") ); - } + if(electrons) { + for(uint i = 0; i< electrons->size(); i++) { + for(uint j = i+1; j < electrons->size(); j++) { + myParticles.clear(); + myParticles.push_back( electrons->at(i) ); + myParticles.push_back( electrons->at(j) ); + res = m_tmt->match(myParticles,"HLT_2e17_lhloose", 0.07); + m_matches["HLT_2e17_lhloose"] += res; + ATH_MSG_INFO("HLT_2e17_lhloose Matching Decision = " << res ); + } + } } return StatusCode::SUCCESS; } + +StatusCode TestMatchingToolAlg::finalize() { + //write results out to a file ... single bin histograms + TFile f1("TestMatchingToolAlg.results.root","RECREATE"); + for(auto& t : m_matches) { + TH1D* h = new TH1D(t.first.c_str(),t.first.c_str(),1,0,1); + h->SetBinContent(1,t.second); + h->Write(); + } + f1.Close(); + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.h b/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.h index 65066d4fc511..ac3171c94404 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.h +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/src/TestMatchingToolAlg.h @@ -9,6 +9,8 @@ #include "TriggerMatchingTool/IMatchingTool.h" +#include <map> + class TestMatchingToolAlg: public ::AthAnalysisAlgorithm { public: TestMatchingToolAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AthAnalysisAlgorithm( name, pSvcLocator ) {} @@ -16,10 +18,13 @@ class TestMatchingToolAlg: public ::AthAnalysisAlgorithm { virtual StatusCode initialize(); virtual StatusCode execute(); + virtual StatusCode finalize(); private: ToolHandle<Trig::IMatchingTool> m_tmt; + + std::map<std::string,int> m_matches; }; diff --git a/Trigger/TrigAnalysis/TriggerMatchingTool/test/TriggerMatchingTool.xml b/Trigger/TrigAnalysis/TriggerMatchingTool/test/TriggerMatchingTool.xml index d903c919690a..410ce2a1082f 100644 --- a/Trigger/TrigAnalysis/TriggerMatchingTool/test/TriggerMatchingTool.xml +++ b/Trigger/TrigAnalysis/TriggerMatchingTool/test/TriggerMatchingTool.xml @@ -1,13 +1,14 @@ <?xml version="1.0"?> <atn> <TEST name="TestMatchingToolAlg" type="athena" suite="ASGTests"> - <options_atn>TriggerMatchingTool/TestMatchingToolAlgJobOptions.py</options_atn> - <timelimit>5</timelimit> + <options_atn>TriggerMatchingTool/TestMatchingToolAlgJobOptions.py || { rm TestMatchingToolAlg.results.root;exit 1; }</options_atn> + <timelimit>15</timelimit> <author> Lukas Heinrich </author> <mailto> lukas.heinrich@cern.ch </mailto> <expectations> <errorMessage>FAILURE (ERROR)</errorMessage> <returnValue>0</returnValue> </expectations> + <postscript>rootcomp.py --html --atnMode --output rootcomp.TestMatchingToolAlg.results TestMatchingToolAlg.results.root</postscript> </TEST> </atn> -- GitLab