diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h index 9f505dd56ffef8d1ee98762214805c8bfd71e26b..389ed7832ba935bb64613d666752a2b47d4431d1 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h @@ -5,8 +5,11 @@ #ifndef TRIGHLTJETHYPO_IJET_H #define TRIGHLTJETHYPO_IJET_H +#include "xAODJet/Jet.h" #include <string> #include <ostream> +#include <optional> + class TLorentzVector; namespace HypoJet{ @@ -22,7 +25,8 @@ namespace HypoJet{ virtual double rapidity() const = 0; virtual TLorentzVector p4() const = 0; virtual unsigned int position() const = 0; - + virtual std::optional<const xAOD::Jet*> xAODJet() const = 0; + virtual bool getAttribute(const std::string &name, float&) const =0; virtual std::string toString() const = 0; }; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJet.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJet.h index 6689af2a7c8eaf12e6b54a820ee5504833daeb95..bb96cd1780af09ec531854ad0501b46fd8e238e8 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJet.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJet.h @@ -26,6 +26,9 @@ namespace HypoJet{ double rapidity() const override; TLorentzVector p4() const override; unsigned int position() const override; + + + virtual std::optional<const xAOD::Jet*> xAODJet() const override; bool getAttribute(const std::string&, float&) const override; private: diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.cxx index b8f76e1035e7124d103966cb0352af6726ae95fb..146b6eea4474a29e8cd8b55b97e42deadece925f 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.cxx @@ -27,6 +27,7 @@ AndHelperTool::AndHelperTool(const std::string& type, bool AndHelperTool::pass(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { ATH_MSG_DEBUG("AndHelperTool::pass... " << jets.size() << " jets"); @@ -34,10 +35,10 @@ AndHelperTool::pass(HypoJetVector& jets, if(collector){ timer.start(); } - bool pass = m_lhs->pass(jets, collector); + bool pass = m_lhs->pass(jets, jetCollector, collector); if (pass){ ATH_MSG_DEBUG("LHS passed"); - pass = m_rhs->pass(jets, collector); + pass = m_rhs->pass(jets, jetCollector, collector); ATH_MSG_DEBUG("RHS " <<std::boolalpha << pass); } else { ATH_MSG_DEBUG("LHS failed"); diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.h index de26a2061166757b901c183584a58a653e5b0190..731a8aa3e812aacd6f7a8de47068fd852e013a04 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/AndHelperTool.h @@ -18,7 +18,9 @@ #include "ITrigJetHypoToolConfig.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" #include "./ITrigJetHypoInfoCollector.h" + class ITrigJetHypoInfoCollector; +class xAODJetCollector; class AndHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { @@ -29,6 +31,7 @@ class AndHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { const IInterface* parent); bool pass(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override; virtual StatusCode getDescription(ITrigJetHypoInfoCollector&) const override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.cxx index c9511b67d90b19c8be175c749e9fe86df5938521..2e0a36c8757c7f8faf8e10a294dc55966abff74b 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.cxx @@ -76,6 +76,7 @@ struct HypoJetSelector{ bool CombinationsHelperTool::pass(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { /* seek first jet group that passes all children */ @@ -105,7 +106,7 @@ CombinationsHelperTool::pass(HypoJetVector& jets, exeTimer.start(); for(auto& gjets : jetGroups){ - if (testGroup(gjets, collector)){ + if (testGroup(gjets, jetCollector, collector)){ pass = true; exeTimer.stop(); collectData(setupTimer.readAndReset(), @@ -130,9 +131,10 @@ CombinationsHelperTool::pass(HypoJetVector& jets, bool CombinationsHelperTool::testGroup(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { for(auto child : m_children){ - auto childPass = child->pass(jets, collector); + auto childPass = child->pass(jets, jetCollector, collector); if (!childPass){ return false;} } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.h index 2345b4fa2f73e1f9a7a6374b2e62e5cc9cb7062a..a30cfc6df2dfe7f465355955e26720abff61e107 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CombinationsHelperTool.h @@ -15,6 +15,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" class ITrigJetInfoCollector; +class xAODJetCollector; class CombinationsHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { public: @@ -27,6 +28,7 @@ class CombinationsHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperM virtual StatusCode initialize() override; virtual bool pass(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>& ) const override; @@ -62,6 +64,7 @@ class CombinationsHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperM bool testGroup(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const; void collectData(const std::string& setuptime, const std::string& exetime, diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/IGroupsMatcherMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/IGroupsMatcherMT.h index ec8df1ffc06cd43708cb14cddedef55b238d99f3..c0cc5d5654995e6e2c447c876efe9fbe99988f99 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/IGroupsMatcherMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/IGroupsMatcherMT.h @@ -23,6 +23,7 @@ #include <string> class ITrigJetHypoInfoCollector; +class xAODJetCollector; class IGroupsMatcherMT{ public: @@ -31,6 +32,7 @@ class IGroupsMatcherMT{ virtual std::optional<bool> match(const HypoJetGroupCIter&, const HypoJetGroupCIter&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&, bool debug=false) const = 0; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolHelperMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolHelperMT.h index 9aadde0ceaffeb5d39b937bf764cf625602babd0..3affb961abd01edb3735964796989d54a3a0f4e8 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolHelperMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolHelperMT.h @@ -10,6 +10,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" class ITrigJetHypoInfoCollector; +class xAODJetCollector; class ITrigJetHypoToolHelperMT : virtual public ::IAlgTool { @@ -22,6 +23,7 @@ public: // generated at L1. virtual bool pass(HypoJetVector& jets, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const = 0; virtual StatusCode getDescription(ITrigJetHypoInfoCollector&) const = 0; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolMT.h deleted file mode 100644 index 53bb3120a9d5b0af7dc69adfdec53086767d5fa9..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ITrigJetHypoToolMT.h +++ /dev/null @@ -1,31 +0,0 @@ - -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGHLTJETHYPO_ITRIGJETHYPOTOOLMT_H -#define TRIGHLTJETHYPO_ITRIGJETHYPOTOOLMT_H - -#include "GaudiKernel/IAlgTool.h" -#include "xAODJet/JetContainer.h" - -#include "DecisionHandling/TrigCompositeUtils.h" - -namespace HLT{ - class Identifier; -} - -class ITrigJetHypoToolMT : virtual public ::IAlgTool { - -public: - DeclareInterfaceID(ITrigJetHypoToolMT, 1, 0); - virtual ~ITrigJetHypoToolMT(){}; - // make a decision (yes/no) based on the jets in the jet container, - // set the new decision object according to this decision, and previous - // devicsion objects. Jets typically have only a decision object - // generated at L1. - virtual StatusCode decide(const xAOD::JetContainer*, bool& pass) const = 0; - virtual const HLT::Identifier& getId() const = 0; - -}; -#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.cxx index e3648512b5fabb5be003f368974210f582049198..7f04c5d24af8cc39d1c9b8bcbc83cdea87c98bb1 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.cxx @@ -16,6 +16,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/FlowNetwork.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/FordFulkerson.h" #include "./ITrigJetHypoInfoCollector.h" +#include "./xAODJetCollector.h" #include "./MultijetFlowNetworkBuilder.h" #include <cmath> @@ -32,6 +33,7 @@ MaximumBipartiteGroupsMatcherMT::MaximumBipartiteGroupsMatcherMT(const Condition std::optional<bool> MaximumBipartiteGroupsMatcherMT::match(const HypoJetGroupCIter& groups_b, const HypoJetGroupCIter& groups_e, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector, bool) const { /* setup a FlowNetwork. @@ -118,6 +120,8 @@ MaximumBipartiteGroupsMatcherMT::match(const HypoJetGroupCIter& groups_b, iter, std::back_inserter(passing_jets), [&nodeToJet](const auto& edge){return nodeToJet[edge->from()];}); + + jetCollector.addJets(passing_jets.cbegin(), passing_jets.cend()); return std::make_optional<bool>(pass); diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.h index 00098c69e45dacc5ef39bb4dc820ff30f29f7728..aa6b8643e8246625cf6c87ffebab5b6fed14fcee 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/MaximumBipartiteGroupsMatcherMT.h @@ -24,6 +24,7 @@ #include <optional> class ITrigJetHypoInfoCollector; +class xAODJetCollector; class MaximumBipartiteGroupsMatcherMT: virtual public IGroupsMatcherMT { @@ -41,6 +42,7 @@ public: // cannot match if internal problem (eg FlowNetwork error) std::optional<bool> match(const HypoJetGroupCIter&, const HypoJetGroupCIter&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&, bool debug=false) const override; std::string toString() const noexcept override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.cxx index 9cbd5c8c05e87ff9562884b832264f56772e2574..92b4c8a95742c23b726a60fe184d4596ae588e1f 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.cxx @@ -27,6 +27,7 @@ NotHelperTool::NotHelperTool(const std::string& type, bool NotHelperTool::pass(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { ATH_MSG_DEBUG("NotHelperTool::pass... " << jets.size() << " jets"); @@ -35,7 +36,7 @@ NotHelperTool::pass(HypoJetVector& jets, timer.start(); } - auto pass = !m_hypoTool->pass(jets, collector); + auto pass = !m_hypoTool->pass(jets, jetCollector, collector); if (collector){ timer.stop(); collector->collect(name(), nodeIDPrinter(name(), diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.h index 21b762b0f9c464281d83b1d27d2e8be84cfe041e..2fd3165a212f50ff868760097d0bf4c45d1fd296 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/NotHelperTool.h @@ -20,6 +20,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" class ITrigJetInfoCollector; +class xAODJetCollector; class NotHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { @@ -30,6 +31,7 @@ class NotHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { const IInterface* parent); bool pass(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.cxx index e9db2ff8b78fdb231ad15997091c9233f9120654..f86aef887fbe45e44a5150207304834f4349ab47 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.cxx @@ -27,6 +27,7 @@ OrHelperTool::OrHelperTool(const std::string& type, bool OrHelperTool::pass(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { ATH_MSG_DEBUG("OrHelperTool::pass... " << jets.size() << " jets"); @@ -35,12 +36,12 @@ OrHelperTool::pass(HypoJetVector& jets, timer.start(); } - bool pass = m_lhs->pass(jets, collector); + bool pass = m_lhs->pass(jets, jetCollector, collector); if (pass){ ATH_MSG_DEBUG("LHS passed"); return pass; } else { - pass = m_rhs->pass(jets, collector); + pass = m_rhs->pass(jets, jetCollector, collector); ATH_MSG_DEBUG("RHS " <<std::boolalpha << pass); } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.h index 6d970bd36ee4d6684f730188f43fd0ad2a95f1ed..c6fa2c85c23a6e759ba53a4d010f4314158dd0aa 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/OrHelperTool.h @@ -18,6 +18,8 @@ #include "ITrigJetHypoToolConfig.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" +class xAODJetCollector; + class OrHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { public: @@ -27,6 +29,7 @@ class OrHelperTool: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { const IInterface* parent); bool pass(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override; virtual StatusCode getDescription(ITrigJetHypoInfoCollector&) const override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.cxx index b1a67e37ae1f824394cb8a4c14baec134f500684..e42260eb77b0e7dd588245cf0316726b4da7e70e 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.cxx @@ -13,6 +13,7 @@ // #include "./SingleConditionMatcherMT.h" +#include "./xAODJetCollector.h" #include <sstream> #include <algorithm> @@ -23,12 +24,14 @@ SingleConditionMatcherMT::SingleConditionMatcherMT(const ConditionBridgeMT& cb): std::optional<bool> SingleConditionMatcherMT::match(const HypoJetGroupCIter& jets_b, const HypoJetGroupCIter& jets_e, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& v, - bool) const { + bool ) const { for(auto i=jets_b; i != jets_e; ++i){ if (m_condition.isSatisfied(*i, v)){ + jetCollector.addJets((*i).cbegin(), (*i).cend()); return std::make_optional<bool>(true); } } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.h index d7d131c4a4c50d69452f236bcc105cdcff5f9f1a..0dd488c6a9b5e825f7a5d287fe5445ab8614b765 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/SingleConditionMatcherMT.h @@ -22,6 +22,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h" #include <set> +class xAODJetCollector; class SingleConditionMatcherMT: virtual public IGroupsMatcherMT { @@ -38,6 +39,7 @@ public: virtual std::optional<bool> match(const HypoJetGroupCIter&, const HypoJetGroupCIter&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&, bool debug) const override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigHLTJetHypoUtils/xAODJetAsIJet.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigHLTJetHypoUtils/xAODJetAsIJet.cxx index ca72df3b86f6527a59ae482896a87c37eebb38ad..738490d8b600aab0ffc4592afb3f7f7068665201 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigHLTJetHypoUtils/xAODJetAsIJet.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigHLTJetHypoUtils/xAODJetAsIJet.cxx @@ -31,5 +31,9 @@ TLorentzVector xAODJetAsIJet::p4() const {return m_jet->p4();} unsigned int xAODJetAsIJet::position() const {return m_position;} bool xAODJetAsIJet::getAttribute(const std::string &name, float& val) const{ - {return m_jet->getAttribute<float>(name, val);} + return m_jet->getAttribute<float>(name, val); +} + +std::optional<const xAOD::Jet*> xAODJetAsIJet::xAODJet() const{ + return std::make_optional<const xAOD::Jet*>(m_jet); } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.cxx deleted file mode 100644 index 4b169a56a5f0b1af348342a11cf281f2b42a1bf1..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -// ******************************************************************** -// -// NAME: TrigJetAndToolMT.cxx -// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo -// -// -// ******************************************************************** - -#include "TrigJetAndToolMT.h" - -#include "GaudiKernel/StatusCode.h" - -#include "DecisionHandling/HLTIdentifier.h" -#include "DecisionHandling/TrigCompositeUtils.h" - -using TrigCompositeUtils::DecisionID; -using TrigCompositeUtils::Decision; -using TrigCompositeUtils::DecisionContainer; - -TrigJetAndToolMT::TrigJetAndToolMT(const std::string& type, - const std::string& name, - const IInterface* parent) : - base_class(type, name, parent), - m_decisionId(HLT::Identifier::fromToolName(name)) { -} - - -TrigJetAndToolMT::~TrigJetAndToolMT(){ -} - -StatusCode TrigJetAndToolMT::initialize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetAndToolMT::finalize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetAndToolMT::decide(const xAOD::JetContainer* jets, - bool& pass) const { - - m_lhs->decide(jets, pass); - if (pass){ - ATH_MSG_DEBUG("LHS passed"); - m_rhs->decide(jets, pass); - ATH_MSG_DEBUG("RHS " <<std::boolalpha << pass); - } else { - ATH_MSG_DEBUG("LHS failed"); - } - - - return StatusCode::SUCCESS; -} - - -const HLT::Identifier& TrigJetAndToolMT::getId() const{ - return m_decisionId; -} diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.h deleted file mode 100644 index 1536f08fb460ece5c1f8a3e8d8ea0bd1461f445d..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetAndToolMT.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGJETANDTOOLMT_H -#define TRIGJETANDTOOLMT_H -/******************************************************************** - * - * NAME: TrigJetAndToolMT.h - * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo - * - * - *********************************************************************/ - - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "DecisionHandling/HLTIdentifier.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "DecisionHandling/TrigCompositeUtils.h" -#include "AthenaMonitoring/GenericMonitoringTool.h" - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ICleaner.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" - -#include "ITrigJetHypoToolMT.h" -#include "ITrigJetHypoToolConfig.h" - -class TrigJetAndToolMT: public extends<AthAlgTool, ITrigJetHypoToolMT> { - - public: - - TrigJetAndToolMT(const std::string& type, - const std::string& name, - const IInterface* parent); - virtual ~TrigJetAndToolMT(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; - - // ITrigJetHypoToolMT interface - virtual StatusCode - decide(const xAOD::JetContainer*, bool& pass) const override; - virtual const HLT::Identifier& getId() const override; - private: - - // Identifier is used to keep track of which tool made which decision. - // The information is stored in the event store. - HLT::Identifier m_decisionId; - - ToolHandle<ITrigJetHypoToolMT> m_lhs { - this, "lhs", {}, "LHS boolean binary expression"}; - ToolHandle<ITrigJetHypoToolMT> m_rhs { - this, "rhs", {}, "RHS boolean binary expression"}; - -}; -#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx index 45fd41423c3a5c9f304f8cb62c872c5c6f376e7b..e5934b68aa69d2aad98fa077a7eb17e64691f8ec 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.cxx @@ -41,6 +41,7 @@ StatusCode TrigJetHypoAlgMT::execute( const EventContext& context ) const { // read in the previous Decisions made before running this hypo Alg. // The container should have only one such Decision (for L1) as deding // on jets is a one step process. + auto h_prevDecisions = SG::makeHandle(decisionInput(), context ); if( not h_prevDecisions.isValid() || h_prevDecisions->size() ==0) {//implicit @@ -54,107 +55,72 @@ StatusCode TrigJetHypoAlgMT::execute( const EventContext& context ) const { return StatusCode::FAILURE; } - auto prevDecisions = h_prevDecisions.get(); + const DecisionContainer* prevDecisions = h_prevDecisions.get(); + const Decision* previousDecision = prevDecisions->at(0); + + // previousDecision contains all active jet chains (i.e. seeded by L1, + // passed prescale) + + // Create container to write output Decision objects - there will be one per + // jet + SG::WriteHandle<DecisionContainer> outputHandle = + createAndStore(decisionOutput(), context); - // new output decisions - SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context ); - auto newDecisions = outputHandle.ptr(); + DecisionContainer* outputDecisions = outputHandle.ptr(); // read in a jets collection, and obtain a bare pointer to it + auto h_jets = SG::makeHandle(m_jetsKey, context ); - // SG::ReadHandle<JetContainer> h_jets(m_jetsKey); ATH_MSG_DEBUG("Retrieving jets from: " << h_jets.key()); ATH_CHECK(h_jets.isValid()); const JetContainer* jets = h_jets.get(); - // Test whether the hypo tools pass the event, and update the decision - // containers accordingly. - // for (const auto& tool: m_hypoTools) { - // CHECK(decide(jets, newDecisions, prevDecisions, tool)); - // } - - CHECK(decide(jets, newDecisions, prevDecisions)); - - - // output the decisions for all chains for this event. - ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); + CHECK(decide(jets, previousDecision, outputDecisions)); - - // debug.... - if ( msgLvl(MSG::DEBUG)) { - TrigCompositeUtils::DecisionIDContainer allPassingIDs; - for ( auto decisionObject: *outputHandle ) { - TrigCompositeUtils::decisionIDs( decisionObject, allPassingIDs ); - } - - for ( TrigCompositeUtils::DecisionID id : allPassingIDs ) { - ATH_MSG_DEBUG( " +++ " << HLT::Identifier( id ) ); - } - } + // Common debug printing + printDebugInformation(outputHandle); return StatusCode::SUCCESS; } - StatusCode TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets, - DecisionContainer* nDecisions, - const DecisionContainer* oDecisions) const{ + const Decision* previousDecision, + DecisionContainer* outputDecisions) const{ + + // Pair to associate each jet with its corresponding Decision object - + // this will record the chains which the jet passes. - - auto previousDecision = (*oDecisions)[0]; - auto newdecision = TrigCompositeUtils::newDecisionIn(nDecisions); + std::vector<std::pair<const xAOD::Jet*,Decision*>> jetHypoInputs; + for (const xAOD::Jet* jet : *jets) { + + // Create a new Decision object to mirror this Jet. + // Link it to its parent Decision object and attach the jet as a "feature" + + Decision* newDecision = + TrigCompositeUtils::newDecisionIn(outputDecisions, previousDecision); + + ElementLink<xAOD::JetContainer> jetLink = + ElementLink<xAOD::JetContainer>(*jets, jet->index()); + + newDecision->setObjectLink<xAOD::JetContainer>(featureString(), jetLink); + jetHypoInputs.push_back( std::make_pair(jet, newDecision) ); + } + + // Extract the IDs of the jet chains which are active. + // previousDecisionIDs is a std::set<uint32_t>. const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{ - TrigCompositeUtils::decisionIDs(previousDecision).begin(), - TrigCompositeUtils::decisionIDs( previousDecision ).end() + TrigCompositeUtils::decisionIDs(previousDecision).begin(), + TrigCompositeUtils::decisionIDs(previousDecision).end() }; - + for (const auto& tool: m_hypoTools) { - auto decisionId = tool->getId(); - if (TrigCompositeUtils::passed(decisionId.numeric(), - previousDecisionIDs)){ - - bool pass; - CHECK(tool->decide(jets, pass)); - if (pass) { - TrigCompositeUtils::addDecisionID(decisionId, newdecision); - } - } + CHECK(tool->decide(jets, previousDecisionIDs, jetHypoInputs)); } return StatusCode::SUCCESS; } -// StatusCode -// TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets, -// std::unique_ptr<DecisionContainer>& nDecisions, -// const DecisionContainer* oDecisions, -// const ToolHandle<ITrigJetHypoToolMT>& tool) const{ - - -// auto previousDecision = (*oDecisions)[0]; - -// const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{ -// TrigCompositeUtils::decisionIDs(previousDecision).begin(), -// TrigCompositeUtils::decisionIDs( previousDecision ).end() -// }; - -// auto decisionId = tool->getId(); -// if (TrigCompositeUtils::passed(decisionId.numeric(), -// previousDecisionIDs)){ -// bool pass; -// CHECK(tool->decide(jets, pass)); -// if (pass) { -// // create a new Decision object. This object has been placed in the -// // nDecisions container. -// auto decision = TrigCompositeUtils::newDecisionIn(nDecisions); -// TrigCompositeUtils::addDecisionID(decisionId, decision); -// } -// // what if does not pass? -// } - -// return StatusCode::SUCCESS; -// } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.h index 3157bf40f2a40ff4429ff4ab2230c06b1fdf62b8..5b3e8851746001b0e288b0b0d071410163dad8cc 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoAlgMT.h @@ -9,10 +9,10 @@ #include "TrigJetHypoAlgMT.h" #include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "xAODJet/JetContainer.h" -// #include "DecisionHandling/TrigCompositeUtils.h" + #include "DecisionHandling/HypoBase.h" -#include "ITrigJetHypoToolMT.h" +#include "TrigJetHypoToolMT.h" /** * @class TrigJetHypoAlgMT @@ -31,21 +31,30 @@ class TrigJetHypoAlgMT : public ::HypoBase { private: - StatusCode decide(const xAOD::JetContainer*, - TrigCompositeUtils::DecisionContainer* newDecisions, - const TrigCompositeUtils::DecisionContainer* previousDecisions - /* , */ - /* const ToolHandle<ITrigJetHypoToolMT>&xs */ - ) const; +/** + * @brief Populate outputDecisions and run all HypoTools over the jet + * collection. + * @param[in] jets Input container of reco jets + * @param[in] previousDecision The Decision object from the previous step + * (L1Decoder). Jet workflow specifies there to be exactly one previous + * decision object. + * @param[out] outputDecisions Output container of Decision objects. + * To be populated with one Decision object per jet, and these filled with IDs + * of passing chains. + **/ + StatusCode decide(const xAOD::JetContainer* jets, + const TrigCompositeUtils::Decision* previousDecision, + TrigCompositeUtils::DecisionContainer* outputDecisions + ) const; - ToolHandleArray<ITrigJetHypoToolMT> m_hypoTools { + + ToolHandleArray<TrigJetHypoToolMT> m_hypoTools { this, "HypoTools", {}, "Hypo tools"}; SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey { this, "Jets", "Jets", "jet container key, full scan"}; - }; #endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.cxx index 4e49d8ba3fd49a77199b05a0e80181df839dbf20..4cbc1d5fe5ebebb7aa9b4d11d972aafa9a00baa9 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.cxx @@ -4,6 +4,7 @@ #include "./TrigJetHypoToolHelperMT.h" #include "./ITrigJetHypoInfoCollector.h" +#include "./xAODJetCollector.h" #include "./groupsMatcherFactoryMT.h" #include "./JetTrigTimer.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerFactory.h" @@ -46,6 +47,7 @@ TrigJetHypoToolHelperMT::collectData(const std::string& exetime, bool TrigJetHypoToolHelperMT::pass(HypoJetVector& jets, + xAODJetCollector& jetCollector, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const { @@ -70,7 +72,10 @@ TrigJetHypoToolHelperMT::pass(HypoJetVector& jets, } auto jetGroups = m_grouper->group(begin, end); - auto pass = m_matcher->match(jetGroups.begin(), jetGroups.end(), collector); + auto pass = m_matcher->match(jetGroups.begin(), + jetGroups.end(), + jetCollector, + collector); timer.stop(); diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.h index 5c4865e89e582498c85b8bd6302f2dd0137c0f12..357d3550a0b8581fc5795971242731214593a754 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolHelperMT.h @@ -29,6 +29,7 @@ #include "ITrigJetHypoToolConfig.h" class ITrigJetHypoInfoCollector; +class xAODJetCollector; class TrigJetHypoToolHelperMT: public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { @@ -40,7 +41,11 @@ public extends<AthAlgTool, ITrigJetHypoToolHelperMT> { StatusCode initialize() override; virtual bool + + // pass - tests wethewr a jet collection passes cuts, and collects + // information about the decision. pass(HypoJetVector&, + xAODJetCollector&, const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override; virtual StatusCode getDescription(ITrigJetHypoInfoCollector&) const override; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx index 9843c2a622e7cf5552c799be9886c72ec0d71e5c..e8126fa9d9404521e8f730d732c30a647ef78845 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.cxx @@ -18,6 +18,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJetFactory.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/lineSplitter.h" #include "./DebugInfoCollector.h" +#include "./xAODJetCollector.h" #include "DecisionHandling/HLTIdentifier.h" #include "DecisionHandling/TrigCompositeUtils.h" @@ -29,7 +30,7 @@ using TrigCompositeUtils::DecisionContainer; TrigJetHypoToolMT::TrigJetHypoToolMT(const std::string& type, const std::string& name, const IInterface* parent) : - base_class(type, name, parent), + AthAlgTool(type, name, parent), m_decisionId(HLT::Identifier::fromToolName(name)), m_eventSN(std::make_unique<EventSN>()){ } @@ -58,10 +59,19 @@ StatusCode TrigJetHypoToolMT::finalize(){ return StatusCode::SUCCESS; } -StatusCode TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets, - bool& pass) const { +StatusCode +TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets, + const TrigCompositeUtils::DecisionIDContainer& previousDecisionIDs, + std::vector<JetDecision>& jetHypoInputs) const { + + if (not TrigCompositeUtils::passed(getId().numeric(), previousDecisionIDs)) { + // This HypoTool's chain is not active - + // we must not check this tool's logic. + + return StatusCode::SUCCESS; + } + - pass = false; HypoJetVector hypoJets(jets->size()); std::transform(jets -> begin(), @@ -82,14 +92,43 @@ StatusCode TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets, infocollector.reset(new DebugInfoCollector(collectorName)); } + xAODJetCollector jetCollector; + bool pass; try{ - pass = m_helper->pass(hypoJets, infocollector); + pass = m_helper->pass(hypoJets, jetCollector, infocollector); } catch(std::exception& e){ ATH_MSG_ERROR("Exception raised by the TrigJetHypoToolHelperMT: " << e.what()); return StatusCode::FAILURE; } - + + if (pass) { + if (jetCollector.empty()) { + ATH_MSG_ERROR("HypoTool passed the event for " << + getId().name() << + ", but did not specify which jets participated"); + return StatusCode::FAILURE; + } + + // jet hypo inputs: + // pairs of const xAOD::Jet* (first) and mutable Decision* (second) + + auto participating_jets = jetCollector.xAODJets(); + + for (auto& pair : jetHypoInputs) { + auto it = std::find(participating_jets.begin(), + participating_jets.end(), + pair.first); + if (it != participating_jets.end()) { + + // This jet particpated in passing the event. + // Add this HypoTool's ID to this Decision object. + + TrigCompositeUtils::addDecisionID(getId().numeric(), pair.second); + } + } + } + if (infocollector){ infocollector->write(); } @@ -98,6 +137,7 @@ StatusCode TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets, ATH_MSG_DEBUG("hypo testing done chain " << " no of input jets " << jets->size() + << " no of particlating jets " << jetCollector.size() << " pass " << pass ); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.h index 4af9527cd0b8104e2d58d7a4d6f76abdf5a5ac32..7fca5fdab9daa387595dd361c352733acb007ea6 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolMT.h @@ -18,53 +18,56 @@ #include "DecisionHandling/TrigCompositeUtils.h" #include "AthenaMonitoring/GenericMonitoringTool.h" - #include "ITrigJetHypoToolHelperMT.h" -#include "ITrigJetHypoToolMT.h" #include "xAODEventInfo/EventInfo.h" +#include "xAODJet/JetContainer.h" struct EventSN{ std::size_t m_id{0}; std::size_t getSN(){return m_id++;} }; - -class TrigJetHypoToolMT: public extends<AthAlgTool, ITrigJetHypoToolMT> { - +class TrigJetHypoToolMT: public AthAlgTool{ + public: TrigJetHypoToolMT(const std::string& type, const std::string& name, const IInterface* parent); -virtual ~TrigJetHypoToolMT(); -virtual StatusCode initialize() override; -virtual StatusCode finalize() override; - -// ITrigJetHypoToolMT interface -virtual StatusCode -decide(const xAOD::JetContainer*, bool& pass) const override; -virtual const HLT::Identifier& getId() const override; -private: - -// Identifier is used to keep track of which tool made which decision. -// The information is stored in the event store. -HLT::Identifier m_decisionId; - -private: -ToolHandle<ITrigJetHypoToolHelperMT> m_helper { -this, "helper_tool", {}, "Jet hypo helper AlgTool"}; - -Gaudi::Property<bool> -m_visitDebug {this, "visit_debug", false, "debug flag"}; - - - SG::ReadHandleKey<xAOD::EventInfo> m_evt{ - this, "Event", "Event", "read handle key for event info object"}; + ~TrigJetHypoToolMT(); + StatusCode initialize(); + StatusCode finalize(); + + // typedef for passing jet - decision object assocation + using JetDecision = std::pair<const xAOD::Jet*,TrigCompositeUtils::Decision*>; + + StatusCode + decide(const xAOD::JetContainer* jets, + const TrigCompositeUtils::DecisionIDContainer& previousDecisionIDs, + std::vector<JetDecision>& jetHypoInputs) const; + + const HLT::Identifier& getId() const; + + private: + + // Identifier is used to keep track of which tool made which decision. + // The information is stored in the event store. + HLT::Identifier m_decisionId; + + + ToolHandle<ITrigJetHypoToolHelperMT> m_helper { + this, "helper_tool", {}, "Jet hypo helper AlgTool"}; + + Gaudi::Property<bool> + m_visitDebug {this, "visit_debug", false, "debug flag"}; + + + SG::ReadHandleKey<xAOD::EventInfo> m_evt{ + this, "Event", "Event", "read handle key for event info object"}; + + std::unique_ptr<EventSN> m_eventSN; - std::unique_ptr<EventSN> m_eventSN; - - }; #endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.cxx deleted file mode 100644 index 2ec75ba2f8c83a8fd7a4af063b19fc2839940593..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -// ******************************************************************** -// -// NAME: TrigJetNotToolMT.cxx -// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo -// -// -// ******************************************************************** - -#include "TrigJetNotToolMT.h" - -#include "GaudiKernel/StatusCode.h" - -#include "DecisionHandling/HLTIdentifier.h" -#include "DecisionHandling/TrigCompositeUtils.h" - -using TrigCompositeUtils::DecisionID; -using TrigCompositeUtils::Decision; -using TrigCompositeUtils::DecisionContainer; - -TrigJetNotToolMT::TrigJetNotToolMT(const std::string& type, - const std::string& name, - const IInterface* parent) : - base_class(type, name, parent), - m_decisionId(HLT::Identifier::fromToolName(name)) { -} - - -TrigJetNotToolMT::~TrigJetNotToolMT(){ -} - -StatusCode TrigJetNotToolMT::initialize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetNotToolMT::finalize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetNotToolMT::decide(const xAOD::JetContainer* jets, - bool& pass) const { - - m_hypoTool->decide(jets, pass); - - if(pass){ - ATH_MSG_DEBUG("hypoTool passed"); - } else { - ATH_MSG_DEBUG("hypoTool failed"); - } - - pass = !pass; - - return StatusCode::SUCCESS; -} - - -const HLT::Identifier& TrigJetNotToolMT::getId() const{ - return m_decisionId; -} - diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.h deleted file mode 100644 index 9c51b7361396f51e22062c81ef2c7466b38f2237..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetNotToolMT.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collabnotation -*/ - -#ifndef TRIGJETNOTTOOLMT_H -#define TRIGJETNOTTOOLMT_H -/******************************************************************** - * - * NAME: TrigJetNotToolMT.h - * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo - * - * - *********************************************************************/ - - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "DecisionHandling/HLTIdentifier.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "DecisionHandling/TrigCompositeUtils.h" -#include "AthenaMonitoring/GenericMonitoringTool.h" - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ICleaner.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" - -#include "ITrigJetHypoToolMT.h" -#include "ITrigJetHypoToolConfig.h" - -class TrigJetNotToolMT: public extends<AthAlgTool, ITrigJetHypoToolMT> { - - public: - - TrigJetNotToolMT(const std::string& type, - const std::string& name, - const IInterface* parent); - virtual ~TrigJetNotToolMT(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; - - // ITrigJetHypoToolMT interface - virtual StatusCode - decide(const xAOD::JetContainer*, bool& pass) const override; - virtual const HLT::Identifier& getId() const override; - private: - - // Identifier is used to keep track of which tool made which decision. - // The information is stored in the event store. - HLT::Identifier m_decisionId; - - ToolHandle<ITrigJetHypoToolMT> m_hypoTool { - this, "hypoTool", {}, "predicate to be inverted"}; - - -}; -#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.cxx deleted file mode 100644 index 80846e55aeabf7fd464632eb925790392511d383..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -// ******************************************************************** -// -// NAME: TrigJetOrToolMT.cxx -// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo -// -// -// ******************************************************************** - -#include "TrigJetOrToolMT.h" - -#include "GaudiKernel/StatusCode.h" - -#include "DecisionHandling/HLTIdentifier.h" -#include "DecisionHandling/TrigCompositeUtils.h" - -using TrigCompositeUtils::DecisionID; -using TrigCompositeUtils::Decision; -using TrigCompositeUtils::DecisionContainer; - -TrigJetOrToolMT::TrigJetOrToolMT(const std::string& type, - const std::string& name, - const IInterface* parent) : - base_class(type, name, parent), - m_decisionId(HLT::Identifier::fromToolName(name)) { -} - - -TrigJetOrToolMT::~TrigJetOrToolMT(){ -} - -StatusCode TrigJetOrToolMT::initialize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetOrToolMT::finalize(){ - return StatusCode::SUCCESS; -} - -StatusCode TrigJetOrToolMT::decide(const xAOD::JetContainer* jets, - bool& pass) const { - - m_lhs->decide(jets, pass); - if (not pass){ - m_rhs->decide(jets, pass); - ATH_MSG_DEBUG("LHS failed " << " RHS " <<std::boolalpha << pass); - } else { - ATH_MSG_DEBUG("LHS passed"); - } - - return StatusCode::SUCCESS; -} - - -const HLT::Identifier& TrigJetOrToolMT::getId() const{ - return m_decisionId; -} diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.h deleted file mode 100644 index db9a8d1cc62fdeb8c66de436c569225ede967a06..0000000000000000000000000000000000000000 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetOrToolMT.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGJETORTOOLMT_H -#define TRIGJETORTOOLMT_H -/******************************************************************** - * - * NAME: TrigJetOrToolMT.h - * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo - * - * - *********************************************************************/ - - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "DecisionHandling/HLTIdentifier.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "DecisionHandling/TrigCompositeUtils.h" -#include "AthenaMonitoring/GenericMonitoringTool.h" - -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ICleaner.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h" -#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h" - -#include "ITrigJetHypoToolMT.h" -#include "ITrigJetHypoToolConfig.h" - -class TrigJetOrToolMT: public extends<AthAlgTool, ITrigJetHypoToolMT> { - - public: - - TrigJetOrToolMT(const std::string& type, - const std::string& name, - const IInterface* parent); - virtual ~TrigJetOrToolMT(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; - - // ITrigJetOrToolMT interface - virtual StatusCode - decide(const xAOD::JetContainer*, bool& pass) const override; - virtual const HLT::Identifier& getId() const override; - private: - - // Identifier is used to keep track of which tool made which decision. - // The information is stored in the event store. - HLT::Identifier m_decisionId; - - ToolHandle<ITrigJetHypoToolMT> m_lhs { - this, "lhs", {}, "LHS boolean binary expression"}; - ToolHandle<ITrigJetHypoToolMT> m_rhs { - this, "rhs", {}, "RHS boolean binary expression"}; - -}; -#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/xAODJetCollector.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/xAODJetCollector.h new file mode 100644 index 0000000000000000000000000000000000000000..0079cce3efab0226f15215038ac8778f7fe3d138 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/xAODJetCollector.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGLHLTJETHYPO_JETCOLLECTOR_H +#define TRIGLHLTJETHYPO_JETCOLLECTOR_H + +#include "xAODJet/Jet.h" +#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h" +#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" + +#include <vector> +#include <algorithm> +#include <cassert> + +// xAODJetCollector - an object send to a (possibly recursive) +// TrigJetHypoToolHelpers to obtain xAOD jets + +namespace HypoJet{ + class IJet; +} + +class xAODJetCollector { + +public: + + void addJets(const HypoJetCIter& begin, const HypoJetCIter& end){ + + HypoJetVector jets(begin, end); + + // determine whether each jet has an associated xAOD::Jet + // there are implementations of HypoJet where this is not the case. + + auto new_end = + std::partition(jets.begin(), + jets.end(), + [](const HypoJet::IJet* j){return (j->xAODJet()).has_value();}); + // add xAOD::Jet* to m_jets + m_jets.reserve(m_jets.size() + (new_end - jets.begin())); + std::transform(jets.begin(), + new_end, + std::back_inserter(m_jets), + [](const pHypoJet j){return *(j->xAODJet());}); + + } + + std::vector<const xAOD::Jet*> xAODJets() const {return m_jets;} + + void addOneJet(const pHypoJet jet){ + auto opt_xAODJet = jet -> xAODJet(); + if (opt_xAODJet.has_value()){m_jets.push_back(*opt_xAODJet);} + } + + std::size_t size() const {return m_jets.size();} + bool empty() const {return m_jets.empty();} + + private: + std::vector<const xAOD::Jet*> m_jets; +}; + +#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/CMakeLists.txt b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/CMakeLists.txt index 3ef2e0ab36b6a37867e3ddd3e5d4ccb00f63fd38..aa383bb0e0cc221ef51f1254b5363b845fdc8945 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/CMakeLists.txt +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/CMakeLists.txt @@ -37,6 +37,7 @@ atlas_add_test( TrigHLTJetHypoUnitTests src/SelectedJetsMatcherTest.cxx src/TLorentzVectorFactoryTest.cxx src/TightCleanerTest.cxx + src/xAODJetCollectorTest.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} GoogleTestTools TrigHLTJetHypoLib ) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest.cxx index 4ecfd19faf7b21b1e9e916df97d2017fed4992e3..d537fc3cc83589f71000d5359410fad8d7908ab4 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "TrigHLTJetHypo/../src//MaximumBipartiteGroupsMatcherMT.h" @@ -7,6 +7,7 @@ #include "TrigHLTJetHypo/../src/ConditionsDefsMT.h" #include "TrigHLTJetHypo/../src/conditionsFactoryMT.h" #include "TrigHLTJetHypo/../src/DebugInfoCollector.h" +#include "TrigHLTJetHypo/../src/xAODJetCollector.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CombinationsGrouper.h" #include "./MockJetWithLorentzVector.h" @@ -78,8 +79,15 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, zeroInputJets){ EXPECT_TRUE(true); auto visitor = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr); EXPECT_TRUE(true); - - auto pass = matcher.match(groups.begin(), groups.end(), visitor, false); + + xAODJetCollector jetCollector; + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + visitor, + false); + + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -109,10 +117,18 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, tooFewSelectedJets){ visitor.reset(new DebugInfoCollector("toofewselectedjets")); } MaximumBipartiteGroupsMatcherMT matcher(m_conditions); - auto pass = matcher.match(groups.begin(), groups.end(), visitor); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + visitor); + if(visitor){visitor->write();} EXPECT_TRUE(pass.has_value()); + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -158,8 +174,14 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, oneSelectedJet){ auto groups_b = groups.begin(); auto groups_e = groups.end(); MaximumBipartiteGroupsMatcherMT matcher(m_conditions); - auto pass = matcher.match(groups_b, groups_e, collector); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups_b, groups_e, jetCollector, collector); + if(m_debug){collector->write();} + + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -211,8 +233,12 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, twoSelectedJets){ auto groups = makeJetGroupsMT(jets.begin(), jets.end()); auto visitor = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr); - auto pass = matcher.match(groups.begin(), groups.end(), visitor); + xAODJetCollector jetCollector; + auto pass = + matcher.match(groups.begin(), groups.end(), jetCollector, visitor); + + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -264,8 +290,12 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, threeSelectedJets){ auto groups = makeJetGroupsMT(jets.begin(), jets.end()); auto visitor = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr); - auto pass = matcher.match(groups.begin(), groups.end(), visitor); + xAODJetCollector jetCollector; + + auto pass = + matcher.match(groups.begin(), groups.end(), jetCollector, visitor); + EXPECT_TRUE(jetCollector.empty()); // not xAOD jets EXPECT_TRUE(*pass); } @@ -320,10 +350,17 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, fourSelectedJets){ collector.reset(new DebugInfoCollector("fourSelectedJets")); } - auto pass = matcher.match(groups.begin(), groups.end(), collector, m_debug); + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector, m_debug); + if(m_debug){collector->write();} + EXPECT_TRUE(jetCollector.empty()); // not xOAD jets EXPECT_TRUE(*pass); } @@ -382,12 +419,22 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest, overlappingEtaRegions){ MaximumBipartiteGroupsMatcherMT matcher(conditions); auto groups = makeJetGroupsMT(jets.begin(), jets.end()); + auto visitor = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr); + + xAODJetCollector jetCollector; + if(m_debug){ visitor.reset(new DebugInfoCollector("overlappingEtaRegions")); } - auto pass = matcher.match(groups.begin(), groups.end(), visitor); + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + visitor); + if(visitor){visitor -> write();} + + EXPECT_TRUE(jetCollector.empty()); // not xAOD jets EXPECT_TRUE(*pass); } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest_Multijet.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest_Multijet.cxx index f1cc295fb51b56d2284455385d5077291c246c1c..66766f9ee028c0617d5af861f03af60b94a888e8 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest_Multijet.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MaximumBipartiteGroupsMatcherMTTest_Multijet.cxx @@ -7,6 +7,7 @@ #include "TrigHLTJetHypo/../src/ConditionsDefsMT.h" #include "TrigHLTJetHypo/../src/conditionsFactoryMT.h" #include "TrigHLTJetHypo/../src/DebugInfoCollector.h" +#include "TrigHLTJetHypo/../src/xAODJetCollector.h" #include "TrigHLTJetHypo/../src/MultijetFlowNetworkBuilder.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CombinationsGrouper.h" @@ -345,11 +346,19 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj0){ EXPECT_TRUE(groups.size() == 6); auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(); collector.reset(new DebugInfoCollector("mj0")); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector); - auto pass = matcher.match(groups.begin(), groups.end(), collector); if (m_debug){collector->write();} for(auto j : jets){delete j;} + + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -397,12 +406,20 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj1){ if(m_debug){ collector.reset(new DebugInfoCollector("mj1")); } - - auto pass = matcher.match(groups.begin(), groups.end(), collector, m_debug); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector, + m_debug); if(m_debug){collector->write();} for(auto j : jets){delete j;} + + EXPECT_TRUE(jetCollector.empty()); EXPECT_FALSE(*pass); } @@ -452,12 +469,21 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj2){ if(m_debug){ collector.reset(new DebugInfoCollector("mj2")); } - - auto pass = matcher.match(groups.begin(), groups.end(), collector, m_debug); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector, + m_debug); if(m_debug){collector->write();} for(auto j : jets){delete j;} + + EXPECT_TRUE(jetCollector.empty()); // not xAOD jets + EXPECT_TRUE(*pass); } @@ -494,6 +520,7 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj3){ auto jets = makeHypoJets(g_jets); EXPECT_TRUE(jets.size() == 4); + if(m_debug){ for(const auto & j: jets){*out<<j<< " " << j->toString() <<'\n';} } @@ -503,12 +530,18 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj3){ EXPECT_TRUE(groups.size() == 6); auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(); collector.reset(new DebugInfoCollector("mj3")); - - auto pass = matcher.match(groups.begin(), groups.end(), collector); + + xAODJetCollector jetCollector; + + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector); if(m_debug){collector->write();} for(auto j : jets){delete j;} + EXPECT_TRUE(jetCollector.empty()); //not xAOD jets EXPECT_TRUE(*pass); } @@ -564,11 +597,18 @@ TEST_F(MaximumBipartiteGroupsMatcherMTTest_Multijet, mj4){ collector.reset(new DebugInfoCollector("mj4")); } - auto pass = matcher.match(groups.begin(), groups.end(), collector, m_debug); + xAODJetCollector jetCollector; + auto pass = matcher.match(groups.begin(), + groups.end(), + jetCollector, + collector, + m_debug); if(m_debug){collector->write();} for(auto j : jets){delete j;} + + EXPECT_TRUE(jetCollector.empty()); // not xAOD jets EXPECT_TRUE(*pass); } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJet.h b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJet.h index 5588b6f31f1de9e9422291dfbcb0ad8ef63adae6..a51d9eea10e4ed5aa6af42a38f980adf2e048612 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJet.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJet.h @@ -6,9 +6,11 @@ #define TRIGHLTJETHYPOUNITTESTS_MOCKJET_H #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h" +#include "xAODJet/Jet.h" #include "gmock/gmock.h" #include <TLorentzVector.h> #include <string> +#include <optional> class MockJet: public HypoJet::IJet { public: @@ -23,5 +25,12 @@ public: MOCK_CONST_METHOD0(position, unsigned int()); MOCK_CONST_METHOD2(getAttribute, bool (const std::string&, float&)); MOCK_CONST_METHOD0(toString, std::string()); + + // Had problems compiling mock method + // MOCK_CONST_METHOD0(xAODJet, std::optional<const xAOD::Jet*>); + virtual std::optional<const xAOD::Jet*> xAODJet() const override{ + return std::optional<const xAOD::Jet*> (); + } + }; #endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJetWithLorentzVector.h b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJetWithLorentzVector.h index 3400b54eeabdf15bc4bb675fcd32ea0106ed5bd1..55a6bd3ebfb3c2250d9deaf145e36b4ae6b54c1a 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJetWithLorentzVector.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/MockJetWithLorentzVector.h @@ -41,8 +41,12 @@ public: MOCK_CONST_METHOD0(position, unsigned int()); MOCK_CONST_METHOD2(getAttribute, bool (const std::string&, float&)); - // MOCK_CONST_METHOD0(toString, std::string()); + // Had problems compiling mock method + // MOCK_CONST_METHOD0(xAODJet, std::optional<const xAOD::Jet*>); + virtual std::optional<const xAOD::Jet*> xAODJet() const override{ + return std::optional<const xAOD::Jet*> (); + } private: TLorentzVector m_lv; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/TLorentzVectorAsIJet.h b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/TLorentzVectorAsIJet.h index 13669a82fb7c9ade9defd986c397e99561e5ffb3..dc1e42d004daa6ad87553968d1badd49525dc252 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/TLorentzVectorAsIJet.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/TLorentzVectorAsIJet.h @@ -7,6 +7,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJet.h" #include <TLorentzVector.h> +#include "xAODJet/Jet.h" class TLorentzVectorAsIJet: public HypoJet::IJet { public: @@ -32,6 +33,9 @@ class TLorentzVectorAsIJet: public HypoJet::IJet { unsigned int position() const override {return m_position;} bool getAttribute(const std::string&, float&) const {return true;} std::string toString() const {return "TLorentzVectorAsIJet";} + virtual std::optional<const xAOD::Jet*> xAODJet() const override { + return std::optional<const xAOD::Jet*>(); + } private: double m_pt; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/xAODJetCollectorTest.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/xAODJetCollectorTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2475f3a1132de7e472ce0c66cdc6cd9485c0a311 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypoUnitTests/src/xAODJetCollectorTest.cxx @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "xAODJet/Jet.h" +#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJet.h" +#include "./TLorentzVectorAsIJet.h" +#include "TrigHLTJetHypo/../src/xAODJetCollector.h" +#include <TLorentzVector.h> +#include "gtest/gtest.h" + +/* +using ::testing::Return; +using ::testing::_; +using ::testing::SetArgReferee; +*/ + +class xAODJetCollectorTest: public ::testing::Test { +public: + xAODJetCollectorTest() {} +}; + + +TEST_F(xAODJetCollectorTest, zeroJets){ + // zero jets in. Jet collector is empty. + + HypoJetVector jets; + xAODJetCollector collector; + collector.addJets(jets.begin(), jets.end()); + EXPECT_TRUE(collector.empty()); +} + + +TEST_F(xAODJetCollectorTest, multipleInputJets){ + //multiple jets in. Jet collector is not empty and has the correct number. + + constexpr std::size_t njets{11}; + HypoJetVector jets; + for(unsigned int ijet = 0; ijet < njets; ++ijet){ + xAOD::Jet j; + HypoJet::xAODJetAsIJet hjet(&j, ijet); + jets.push_back(&hjet); + } + + xAODJetCollector collector; + collector.addJets(jets.begin(), jets.end()); + + EXPECT_FALSE(collector.empty()); + EXPECT_FALSE((collector.xAODJets()).size() == 10); +} + + +TEST_F(xAODJetCollectorTest, nonXAODJets){ + // multiple non-xAOD jets in. Jet collector is empty. + + unsigned int njets{11}; + HypoJetVector jets; + for(unsigned int ijet = 0; ijet < njets; ++ijet){ + TLorentzVector v; + TLorentzVectorAsIJet tl_as_ij(v); + jets.push_back(&tl_as_ij); + } + + xAODJetCollector collector; + collector.addJets(jets.begin(), jets.end()); + + EXPECT_TRUE(collector.empty()); //Not xAODJets +} +