From 7b0a1889a39dc610a2cb7ef47ba6c007d180386a Mon Sep 17 00:00:00 2001 From: Tim Martin <Tim.Martin@cern.ch> Date: Tue, 9 Jun 2020 14:39:17 +0200 Subject: [PATCH] Add optional isFullscan flag to Trig::DecisionAccess::associateToEventView --- .../TrigDecisionTool/DecisionAccess.h | 10 +++++++-- .../TrigDecisionTool/DecisionAccess.icc | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h index dba550bcbd99..971ef2190c6c 100644 --- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h +++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.h @@ -190,14 +190,20 @@ namespace Trig { * Instance mapping done via matchIndex and optional matchKey (leave matchKey = 0 to not cut on this). * @param[in] inViewContainer The ReadHandle of the collection which was produced online inside an EventView. * @param[in] matchIndex The index of the desired EventView. - * @param[in] matchKey Optional SGKey of the index of the desired EventView (collection hosting the ROI used to span the Event View) + * @param[in] matchKey Optional. SGKey of the index of the desired EventView (collection hosting the ROI used to span the Event View) + * @param[in] isFullscan Optional. If true, and inViewContainer has no viewIndex decorations, then return iterators over the full + * span of the inViewContainer instead of throwing an exception. + * This allows the associateToEventView interface to be used also for non-EventView containers, + * with the FS ROI used to indicate that the lack of decorations is expected rather than being + * indicative of a configuration problem. * @return Pair of iterators spanning a range of indices over the collection accessed through the ReadHandleKey **/ template<class CONTAINER> std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator > associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer, const uint32_t matchIndex, - const uint32_t matchKey = 0) const; + const uint32_t matchKey = 0, + const bool isFullscan = false) const; /// @} diff --git a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc index 7ff7f47255e8..56c02e8abc6f 100644 --- a/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc +++ b/Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/DecisionAccess.icc @@ -92,14 +92,20 @@ template<class CONTAINER> std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator > Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer, const ElementLink<TrigRoiDescriptorCollection>& matchROI) const { - return associateToEventView(inViewContainer, matchROI.index(), matchROI.key()); + // If we can resolve the link, then we can also check the fullscan flag. + bool isFullscan = false; + if (matchROI.isValid()) { + isFullscan = (*matchROI)->isFullscan(); + } + return associateToEventView(inViewContainer, matchROI.index(), matchROI.key(), isFullscan); } template<class CONTAINER> std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator > Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer, const uint32_t matchIndex, - const uint32_t matchKey) const { + const uint32_t matchKey, + const bool isFullscan) const { if (!inViewContainer.isValid()) { std::stringstream ss; ss << "Supplied ReadHandle '" << inViewContainer.key() << "' of type '" << ClassID_traits<CONTAINER>::typeName() << "' is not valid."; @@ -112,9 +118,15 @@ Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewCont static const SG::AuxElement::ConstAccessor< ElementLink<TrigRoiDescriptorCollection> > accessor("viewIndex"); for (typename CONTAINER::const_iterator it = container->begin(); it != end; ++it) { if (!accessor.isAvailable(**it)) { // iterator dereferences to an OBJECT*, OBJECT* dereferences to an OBJECT - ATH_MSG_ERROR("Unable to read the viewIndex decoration from the supplied container. Was it created inside an EventView?"); - throw std::runtime_error("Trig::DecisionAccess::associateToEventView Unable to read the viewIndex decoration from the " - "supplied container. Was it created inside an EventView?"); + if (isFullscan) { + ATH_MSG_DEBUG("Supplied container has no viewIndex decoration. But isFullscan flag is TRUE. " + << "Returning iterators over whole container."); + return std::make_pair(container->begin(), container->end()); + } else { + ATH_MSG_ERROR("Unable to read the viewIndex decoration from the supplied container. Was it created inside an EventView?"); + throw std::runtime_error("Trig::DecisionAccess::associateToEventView Unable to read the viewIndex decoration from the " + "supplied container. Was it created inside an EventView?"); + } } const ElementLink<TrigRoiDescriptorCollection> objectROI = accessor( **it ); bool match = true; -- GitLab