ATLAS Offline Software
Loading...
Searching...
No Matches
ViewCreatorPreviousROITool Class Reference

Basic ROI provider tool which retrieves and re-attaches an existing "roi" ElementLink. More...

#include <ViewCreatorPreviousROITool.h>

Inheritance diagram for ViewCreatorPreviousROITool:
Collaboration diagram for ViewCreatorPreviousROITool:

Public Member Functions

 ViewCreatorPreviousROITool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ViewCreatorPreviousROITool ()=default
virtual StatusCode initialize () override
virtual StatusCode attachROILinks (TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
 Tool interface method.

Public Attributes

Gaudi::Property< std::string > m_roiSGKey
SG::WriteHandleKey< TrigRoiDescriptorCollectionm_roisWriteHandleKey

Detailed Description

Basic ROI provider tool which retrieves and re-attaches an existing "roi" ElementLink.

This implies running the EventView spawned for the Decision object on the ROIDescriptor originating from the previous step.

This basic tool should be replaced with more advanced slice-specific ones where appropriate.

Definition at line 18 of file ViewCreatorPreviousROITool.h.

Constructor & Destructor Documentation

◆ ViewCreatorPreviousROITool()

ViewCreatorPreviousROITool::ViewCreatorPreviousROITool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 13 of file ViewCreatorPreviousROITool.cxx.

14 : base_class(type, name, parent)
15 {}

◆ ~ViewCreatorPreviousROITool()

virtual ViewCreatorPreviousROITool::~ViewCreatorPreviousROITool ( )
virtualdefault

Member Function Documentation

◆ attachROILinks()

StatusCode ViewCreatorPreviousROITool::attachROILinks ( TrigCompositeUtils::DecisionContainer & decisions,
const EventContext & ctx ) const
overridevirtual

Tool interface method.

Context not used in this tool implementation.

Definition at line 22 of file ViewCreatorPreviousROITool.cxx.

22 {
23 // Locate "roi" for each Decision object from previous step, re-attach the ElementLink as "roi" to the current Decision object.
24 // I.e. don't update the "roi", just re-use the one from the previous Step.
25
26 for ( Decision* outputDecision : decisions ) {
27 const std::vector<LinkInfo<TrigRoiDescriptorCollection>> myROIs = findLinks<TrigRoiDescriptorCollection>(outputDecision, roiString(), TrigDefs::lastFeatureOfType);
28
29 int location = -1;
30
31 if (myROIs.size() == 0) {
32 ATH_MSG_ERROR("Found zero '" << roiString() << "' for Decision object index " << outputDecision->index());
33 } else if (myROIs.size() == 1) {
34 location = 0;
35 } else if (not m_roiSGKey.empty()) { // Note: Also requires that size be > 1
36 for (size_t i = 0; i < myROIs.size(); ++i) {
37 if (myROIs.at(i).link.dataID() == m_roiSGKey) {
38 ATH_MSG_DEBUG("Found " << myROIs.size() << " RoI links. However, successfully resolved the ambiguity using roiSGKey=" << m_roiSGKey << ", taking index " << location);
39 location = i;
40 break;
41 }
42 }
43 }
44
45 if (location == -1) {
46 ATH_MSG_ERROR("Did not find exactly one '" << roiString() << "' for Decision object index " << outputDecision->index()
47 << ", found " << myROIs.size() << ". Unable to supply single ROI to spawn EventView on.");
48 for (const auto& li : myROIs) {
49 ATH_MSG_ERROR(" -- " << li.link.dataID() << ":" << li.link.index() << ". Dump:" << *(li.source));
50 }
51 return StatusCode::FAILURE;
52 }
53
54 outputDecision->setObjectLink(roiString(), myROIs.at(location).link);
55 }
56
57 // If this property is set, we actually want to copy the ROIs into a new container. For disambiguation purposes
58 if (!m_roisWriteHandleKey.empty()) {
59 std::map<ElementLink<TrigRoiDescriptorCollection>, ElementLink<TrigRoiDescriptorCollection>> oldToNew;
60 SG::WriteHandle<TrigRoiDescriptorCollection> roisWriteHandle = createAndStoreNoAux(m_roisWriteHandleKey, ctx);
61
62 for ( Decision* outputDecision : decisions ) {
63
64 // Only copy each unique ROI once into the output collection.
65 ElementLink<TrigRoiDescriptorCollection> oldRoI = outputDecision->objectLink<TrigRoiDescriptorCollection>(roiString());
66 ElementLink<TrigRoiDescriptorCollection> newRoI;
67 if (oldToNew.count(oldRoI) == 1) {
68 newRoI = oldToNew[oldRoI];
69 } else {
70 roisWriteHandle->push_back( new TrigRoiDescriptor( **oldRoI ) );
71 newRoI = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
72 oldToNew[oldRoI] = newRoI;
73 }
74
75 // Update the link. Note: overwries the link set of L54
76 outputDecision->setObjectLink(roiString(), newRoI);
77 }
78 }
79
80
81 return StatusCode::SUCCESS;
82}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current Athena::TPCnvVers::Old TrigRoiDescriptorCollection
Athena::TPCnvVers::Current TrigRoiDescriptor
Gaudi::Property< std::string > m_roiSGKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
const std::string & roiString()
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.

◆ initialize()

StatusCode ViewCreatorPreviousROITool::initialize ( )
overridevirtual

Definition at line 17 of file ViewCreatorPreviousROITool.cxx.

17 {
19 return StatusCode::SUCCESS;
20}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_roiSGKey

Gaudi::Property< std::string > ViewCreatorPreviousROITool::m_roiSGKey
Initial value:
{this, "RoISGKey", "",
"Optional StorgeGate key of ROI collection. Use this when an ambiguous situation needs resolving, e.g. after merging different reconstructon paths"}

Definition at line 32 of file ViewCreatorPreviousROITool.h.

32 {this, "RoISGKey", "",
33 "Optional StorgeGate key of ROI collection. Use this when an ambiguous situation needs resolving, e.g. after merging different reconstructon paths"};

◆ m_roisWriteHandleKey

SG::WriteHandleKey< TrigRoiDescriptorCollection > ViewCreatorPreviousROITool::m_roisWriteHandleKey
Initial value:
{this,"RoisWriteHandleKey", "",
"Optional StoreGate key, will cause this Tool to create a new output ROI collection, instead of re-using the existing links."}

Definition at line 35 of file ViewCreatorPreviousROITool.h.

35 {this,"RoisWriteHandleKey", "",
36 "Optional StoreGate key, will cause this Tool to create a new output ROI collection, instead of re-using the existing links."};

The documentation for this class was generated from the following files: