ATLAS Offline Software
Loading...
Searching...
No Matches
InputMakerForRoI.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "InputMakerForRoI.h"
9#include <vector>
10
15
16InputMakerForRoI:: InputMakerForRoI( const std::string& name, ISvcLocator* pSvcLocator )
17 : InputMakerBase( name, pSvcLocator ) {}
18
19
21 ATH_MSG_DEBUG("Will produce output RoI collections: " << m_RoIs);
22 ATH_CHECK( m_RoIs.initialize( SG::AllowEmpty ) );
23 if (not m_roiTool.empty()) ATH_CHECK( m_roiTool.retrieve() );
24 if (m_roiTool.empty() and not m_isEmptyStep) {
25 ATH_MSG_ERROR(name() << " was not supplied an ROI tool.");
26 return StatusCode::FAILURE;
27 }
28 return StatusCode::SUCCESS;
29}
30
31StatusCode InputMakerForRoI::execute( const EventContext& context ) const {
32 ATH_MSG_DEBUG( "Executing " << name() << "..." );
33
34 // create the output decisions from the input collections
36 ATH_CHECK(outputHandle.isValid());
37 ATH_CHECK(decisionInputToOutput(context, outputHandle));
38
39
40 if( outputHandle->size() == 0) {
41 ATH_MSG_DEBUG( "Have no decisions in output handle "<< outputHandle.key() << ". Handle is valid but container is empty. "
42 << "This can happen if a ROI-based HLT chain leg was activated in a chain whose L1 item which does not explicitly require the ROI.");
43 } else {
44 ATH_MSG_DEBUG( "Have output " << outputHandle.key() << " with " << outputHandle->size() << " elements" );
45 }
46
47 // Find and link to the output Decision objects the ROIs to run over
48 if (not m_roiTool.empty()) ATH_CHECK( m_roiTool->attachROILinks(*outputHandle, context) );
49
50 if (m_RoIs.empty()) {
51 ATH_MSG_DEBUG("No concrete output ROI collection required from this InputMaker.");
52 return StatusCode::SUCCESS;
53 }
54
55 // Prepare Outputs
56 std::unique_ptr<TrigRoiDescriptorCollection> outputRoIColl = std::make_unique<TrigRoiDescriptorCollection>();
57 outputRoIColl->reserve(outputHandle->size());
58
59 std::vector <ElementLink<TrigRoiDescriptorCollection> > RoIsFromDecision; // used to check for duplicate RoIs
60 RoIsFromDecision.reserve(outputHandle->size());
61
62 // loop over output decisions in container of outputHandle, collect RoIs to process
63 for (const Decision* outputDecision : *outputHandle) {
64
65 if (!outputDecision->hasObjectLink(roiString(), ClassID_traits<TrigRoiDescriptorCollection>::ID())) {
66 ATH_MSG_ERROR("No '" << roiString() << "'link was attached by the ROITool. Decision object dump:" << *outputDecision);
67 return StatusCode::FAILURE;
68 }
69 const ElementLink<TrigRoiDescriptorCollection> roiEL = outputDecision->objectLink<TrigRoiDescriptorCollection>(roiString());
70 ATH_CHECK(roiEL.isValid());
71
72 // Avoid adding the same ROI multiple times: check if not in container, if not add it
73 if ( find(RoIsFromDecision.begin(), RoIsFromDecision.end(), roiEL) == RoIsFromDecision.end() ) {
74 RoIsFromDecision.push_back(roiEL); // just to keep track of which we have used
75 const TrigRoiDescriptor* roi = *roiEL;
76 ATH_MSG_DEBUG("Adding RoI to be processed:" <<*roi<<" FS="<<roi->isFullscan());
77
78 TrigRoiDescriptor* newroi = new TrigRoiDescriptor(*roi); //use copy constructor
79 outputRoIColl->push_back(newroi);
80 }
81
82 } // loop over decisions
83
84 // Finally, record output
85 ATH_MSG_DEBUG("Produced "<<outputRoIColl->size() <<" output RoIs");
86 auto roi_outputHandle = SG::makeHandle(m_RoIs, context);
87 ATH_CHECK( roi_outputHandle.record(std::move(outputRoIColl)) );
88
89
90 return StatusCode::SUCCESS;
91}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & roiString()
Athena::TPCnvVers::Current TrigRoiDescriptor
Gaudi::Property< bool > m_isEmptyStep
StatusCode decisionInputToOutput(const EventContext &context, SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle) const
does the standard handling of input decisions: read from handles with all the checks,...
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutputs() const
methods for derived classes to access handles of the base class input and output decisions; other rea...
InputMakerBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
ToolHandle< IViewCreatorROITool > m_roiTool
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_RoIs
InputMakerForRoI(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode initialize() override
virtual bool isFullscan() const override final
is this a full scan RoI?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & roiString()
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.