ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
ViewCreatorFetchFromViewROITool Class Reference

#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. More...
 

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  {
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 
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 }

◆ initialize()

StatusCode ViewCreatorFetchFromViewROITool::initialize ( )
overridevirtual

Definition at line 17 of file ViewCreatorFetchFromViewROITool.cxx.

17  {
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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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:
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:61
TrigCompositeUtils::LinkInfo::isValid
bool isValid() const
Definition: LinkInfo.h:43
ViewCreatorFetchFromViewROITool::m_viewToFetchFrom
Gaudi::Property< std::string > m_viewToFetchFrom
Definition: ViewCreatorFetchFromViewROITool.h:45
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ViewCreatorFetchFromViewROITool::m_viewToFetchFromProbe
std::string m_viewToFetchFromProbe
Definition: ViewCreatorFetchFromViewROITool.h:61
ViewHelper::makeHandle
SG::ReadHandle< T > makeHandle(const SG::View *view, const SG::ReadHandleKey< T > &rhKey, const EventContext &context)
navigate from the TrigComposite to nearest view and fetch object from it
Definition: ViewHelper.h:258
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ViewCreatorFetchFromViewROITool::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: ViewCreatorFetchFromViewROITool.h:39
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Creates and right away records the Container CONT with the key.
ViewCreatorFetchFromViewROITool::m_roiEtaWidth
Gaudi::Property< double > m_roiEtaWidth
Definition: ViewCreatorFetchFromViewROITool.h:51
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
RoiDescriptor::zed
virtual double zed() const override final
Definition: RoiDescriptor.h:102
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ViewCreatorFetchFromViewROITool::m_roiZedWidth
Gaudi::Property< double > m_roiZedWidth
Definition: ViewCreatorFetchFromViewROITool.h:57
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ViewCreatorFetchFromViewROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorFetchFromViewROITool.h:54
ViewCreatorFetchFromViewROITool::m_doResize
Gaudi::Property< bool > m_doResize
Definition: ViewCreatorFetchFromViewROITool.h:48
python.PyAthena.v
v
Definition: PyAthena.py:157
SG::WriteHandle< TrigRoiDescriptorCollection >
RoiDescriptor::etaPlus
virtual double etaPlus() const override final
gets eta at zedPlus
Definition: RoiDescriptor.h:115
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RoiDescriptor::eta
virtual double eta() const override final
Definition: RoiDescriptor.h:101
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
RoiDescriptor::phiPlus
virtual double phiPlus() const override final
gets phiPlus
Definition: RoiDescriptor.h:118
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
ViewCreatorFetchFromViewROITool::m_inViewRoIKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_inViewRoIKey
Definition: ViewCreatorFetchFromViewROITool.h:42
RoiDescriptor::zedPlus
virtual double zedPlus() const override final
z at the most forward end of the RoI
Definition: RoiDescriptor.h:112