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

Allows a Decision Object to process the current Step over an ROI which was created during a previous Step. More...

#include <ViewCreatorFetchFromViewROITool.h>

Inheritance diagram for ViewCreatorFetchFromViewROITool:
Collaboration diagram for ViewCreatorFetchFromViewROITool:

Public Member Functions

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

Public Attributes

SG::WriteHandleKey< TrigRoiDescriptorCollectionm_roisWriteHandleKey
SG::ReadHandleKey< TrigRoiDescriptorCollectionm_inViewRoIKey
Gaudi::Property< std::string > m_viewToFetchFrom
Gaudi::Property< bool > m_doResize
Gaudi::Property< double > m_roiEtaWidth
Gaudi::Property< double > m_roiPhiWidth
Gaudi::Property< double > m_roiZedWidth

Private Attributes

std::string m_viewToFetchFromProbe

Detailed Description

Allows a Decision Object to process the current Step over an ROI which was created during a previous Step.

This tools is to be used when this ROI from the previous Step was created inside an EventView.

Exactly ONE ROI must have been written to the TrigRoiDescriptorCollection inside the EventView.

As we cannot write out to BS or POOL ROIDescriptor collections from inside EventViews for technical reasons, the located ROI is copied into a new TrigRoiDescriptorCollection which is produced by this tool

Definition at line 25 of file ViewCreatorFetchFromViewROITool.h.

Constructor & Destructor Documentation

◆ ViewCreatorFetchFromViewROITool()

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

Definition at line 12 of file ViewCreatorFetchFromViewROITool.cxx.

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

◆ ~ViewCreatorFetchFromViewROITool()

virtual ViewCreatorFetchFromViewROITool::~ViewCreatorFetchFromViewROITool ( )
virtualdefault

Member Function Documentation

◆ attachROILinks()

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

Tool interface method.

Definition at line 27 of file ViewCreatorFetchFromViewROITool.cxx.

27 {
28 SG::WriteHandle<TrigRoiDescriptorCollection> roisWriteHandle = createAndStoreNoAux(m_roisWriteHandleKey, ctx);
29
30 for ( Decision* outputDecision : decisions ) {
31 LinkInfo<ViewContainer> viewToFetchFrom;
32 if(!m_viewToFetchFrom.empty()){
33 // Look for a specific View, keyed by the View's SG key
34 const std::vector<LinkInfo<ViewContainer>> myViews = findLinks<ViewContainer>(outputDecision, viewString(), TrigDefs::allFeaturesOfType);
35 bool found = false;
36 for(const LinkInfo<ViewContainer>& v : myViews){
37 ATH_MSG_DEBUG("view "<<v.link.dataID());
38 if(v.link.dataID() == m_viewToFetchFrom or v.link.dataID() == m_viewToFetchFromProbe) {
39 found = true;
40 viewToFetchFrom = v;
41 break;
42 }
43 }
44 if(!found){
45 ATH_MSG_ERROR("Of the " << myViews.size() << " Views in the history of Decision object with index " << outputDecision->index()
46 << ", none came from a View called " << m_viewToFetchFrom);
47 return StatusCode::FAILURE;
48 }
49 }
50 else{
51
52 // Assume the most recent View is the one we fetch from, and that there is exactly one most recent View after any merging
53 const std::vector<LinkInfo<ViewContainer>> myView = findLinks<ViewContainer>(outputDecision, viewString(), TrigDefs::lastFeatureOfType);
54 if (myView.size() != 1) {
55 ATH_MSG_ERROR("Did not find exactly one most-recent '" << viewString() << "' for Decision object index " << outputDecision->index()
56 << ", found " << myView.size());
57 if (myView.size() > 1) {
58 ATH_MSG_ERROR("Was this Decision Object was merged after having followed different reconstruction paths in previous Steps?");
59 ATH_MSG_ERROR("Need more information about which of these Views to look in to find the desired '" << m_inViewRoIKey.key() << "' TrigRoiDescriptorCollection");
60 }
61 return StatusCode::FAILURE;
62 }
63 viewToFetchFrom = myView.at(0);
64 }
65 ATH_CHECK(viewToFetchFrom.isValid());
66
67 SG::ReadHandle<TrigRoiDescriptorCollection> roiReadHandle = ViewHelper::makeHandle(*viewToFetchFrom.link, m_inViewRoIKey, ctx);
68 ATH_CHECK(roiReadHandle.isValid());
69
70 if (roiReadHandle->size() != 1) {
71 ATH_MSG_ERROR("In-view ROI collection '" << m_inViewRoIKey.key() << "' for Decision object index " << outputDecision->index()
72 << " has " << roiReadHandle->size() << " TrigRoiDescriptor inside. We require exactly one.");
73 return StatusCode::FAILURE;
74 }
75
76 if (!m_doResize) { //default
77 // This ROI was created in a View, it cannot currently be written out.
78 // Make a copy in the full-event context, which can be recorded.
79 roisWriteHandle->push_back( new TrigRoiDescriptor( *(roiReadHandle->at(0)) ) );
80 }
81 else { // force resize
82 auto oldroi = roiReadHandle->at(0);
83 ATH_MSG_DEBUG( " Old ROI size " << " eta="<< oldroi->eta() << " +- " << oldroi->etaPlus()-oldroi->eta() \
84 << " phi="<< oldroi->phi() << " +- " << oldroi->phiPlus()-oldroi->phi() \
85 << " zed="<< oldroi->zed() << " +- " << oldroi->zedPlus()-oldroi->zed());
86 ATH_MSG_DEBUG( " New size (eta,phi,zed): " << m_roiEtaWidth.value() << ", " << m_roiPhiWidth.value() << ", " << m_roiZedWidth.value() );
87 const double reta = oldroi->eta();
88 const double retap = (m_roiEtaWidth>0 ? reta + m_roiEtaWidth : oldroi->etaPlus());
89 const double retam = (m_roiEtaWidth>0 ? reta - m_roiEtaWidth : oldroi->etaMinus());
90 const double rphi = oldroi->phi();
91 const double rphip = (m_roiPhiWidth>0 ? rphi + m_roiPhiWidth : oldroi->phiPlus());
92 const double rphim = (m_roiPhiWidth>0 ? rphi - m_roiPhiWidth : oldroi->phiMinus());
93 const double rzed = oldroi->zed();
94 const double rzedp = (m_roiZedWidth>0 ? rzed + m_roiZedWidth : oldroi->zedPlus());
95 const double rzedm = (m_roiZedWidth>0 ? rzed - m_roiZedWidth : oldroi->zedMinus());
96 std::unique_ptr<TrigRoiDescriptor> roi = std::make_unique<TrigRoiDescriptor>(reta, retam, retap, rphi, rphim, rphip, rzed, rzedm, rzedp);
97 ATH_MSG_DEBUG( " New ROI size " << " eta="<< roi->eta() << " +- " << roi->etaPlus()-roi->eta() \
98 << " phi="<< roi->phi() << " +- " << roi->phiPlus()-roi->phi() \
99 << " zed="<< roi->zed() << " +- " << roi->zedPlus()-roi->zed());
100 roisWriteHandle->push_back( roi.release() );
101 }
102
103 const ElementLink<TrigRoiDescriptorCollection> newRoiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
104
105 outputDecision->setObjectLink(roiString(), newRoiEL);
106 }
107
108 return StatusCode::SUCCESS;
109}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Gaudi::Property< std::string > m_viewToFetchFrom
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_inViewRoIKey
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 & viewString()
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.
static const unsigned int allFeaturesOfType
Run 3 "enum". Return all features along legs (still with type and container checks)
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Definition ViewHelper.h:273
ElementLink< T > link
Link to the feature.
Definition LinkInfo.h:55

◆ initialize()

StatusCode ViewCreatorFetchFromViewROITool::initialize ( )
overridevirtual

Definition at line 17 of file ViewCreatorFetchFromViewROITool.cxx.

17 {
18 ATH_CHECK(m_roisWriteHandleKey.initialize());
19 ATH_CHECK(m_inViewRoIKey.initialize());
20 renounce(m_inViewRoIKey); // Will be read from in-View
21
23 return StatusCode::SUCCESS;
24}

Member Data Documentation

◆ m_doResize

Gaudi::Property< bool > ViewCreatorFetchFromViewROITool::m_doResize
Initial value:
{this,"doResize",false,
"Resize RoI if updated widths are given."}

Definition at line 48 of file ViewCreatorFetchFromViewROITool.h.

48 {this,"doResize",false,
49 "Resize RoI if updated widths are given."};

◆ m_inViewRoIKey

SG::ReadHandleKey<TrigRoiDescriptorCollection> ViewCreatorFetchFromViewROITool::m_inViewRoIKey
Initial value:
{this,"InViewRoIs","",
"Name of the ROI collection within the most recent EventView of the input Decision objects"}

Definition at line 42 of file ViewCreatorFetchFromViewROITool.h.

42 {this,"InViewRoIs","",
43 "Name of the ROI collection within the most recent EventView of the input Decision objects"};

◆ m_roiEtaWidth

Gaudi::Property< double > ViewCreatorFetchFromViewROITool::m_roiEtaWidth
Initial value:
{this,"RoIEtaWidth",-1.0,
"New extent of the ROI in eta from its centre"}

Definition at line 51 of file ViewCreatorFetchFromViewROITool.h.

51 {this,"RoIEtaWidth",-1.0,
52 "New extent of the ROI in eta from its centre"};

◆ m_roiPhiWidth

Gaudi::Property< double > ViewCreatorFetchFromViewROITool::m_roiPhiWidth
Initial value:
{this,"RoIPhiWidth",-1.0,
"New extent of the ROI in phi from its centre"}

Definition at line 54 of file ViewCreatorFetchFromViewROITool.h.

54 {this,"RoIPhiWidth",-1.0,
55 "New extent of the ROI in phi from its centre"};

◆ m_roisWriteHandleKey

SG::WriteHandleKey< TrigRoiDescriptorCollection > ViewCreatorFetchFromViewROITool::m_roisWriteHandleKey
Initial value:
{this,"RoisWriteHandleKey","",
"Name of the ROI collection produced by this tool."}

Definition at line 39 of file ViewCreatorFetchFromViewROITool.h.

39 {this,"RoisWriteHandleKey","",
40 "Name of the ROI collection produced by this tool."};

◆ m_roiZedWidth

Gaudi::Property< double > ViewCreatorFetchFromViewROITool::m_roiZedWidth
Initial value:
{this,"RoIZedWidth",-1.0,
"New extent of the ROI in zed from its centre"}

Definition at line 57 of file ViewCreatorFetchFromViewROITool.h.

57 {this,"RoIZedWidth",-1.0,
58 "New extent of the ROI in zed from its centre"};

◆ m_viewToFetchFrom

Gaudi::Property< std::string > ViewCreatorFetchFromViewROITool::m_viewToFetchFrom
Initial value:
{this,"ViewToFetchFrom","",
"Optional name of EventView to fetch ROI from. Must be in the history of the DecisionObject. If not supplied, the most recent EventView will be used."}

Definition at line 45 of file ViewCreatorFetchFromViewROITool.h.

45 {this,"ViewToFetchFrom","",
46 "Optional name of EventView to fetch ROI from. Must be in the history of the DecisionObject. If not supplied, the most recent EventView will be used."};

◆ m_viewToFetchFromProbe

std::string ViewCreatorFetchFromViewROITool::m_viewToFetchFromProbe
private

Definition at line 61 of file ViewCreatorFetchFromViewROITool.h.


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