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

Creates a new ROI centred on an object deriving from xAOD::Jet adding a PV constraint. More...

#include <ViewCreatorCentredOnJetWithPVConstraintROITool.h>

Inheritance diagram for ViewCreatorCentredOnJetWithPVConstraintROITool:
Collaboration diagram for ViewCreatorCentredOnJetWithPVConstraintROITool:

Public Member Functions

 ViewCreatorCentredOnJetWithPVConstraintROITool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ViewCreatorCentredOnJetWithPVConstraintROITool ()=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
Gaudi::Property< double > m_roiEtaWidth
Gaudi::Property< double > m_roiPhiWidth
Gaudi::Property< double > m_roiZWidth
SG::ReadHandleKey< xAOD::VertexContainerm_vertexReadHandleKey
Gaudi::Property< std::string > m_prmVtxLink

Protected Member Functions

const xAOD::VertexgetPrimaryVertex (const xAOD::VertexContainer *) const

Detailed Description

Creates a new ROI centred on an object deriving from xAOD::Jet adding a PV constraint.

Stores this new ROI in the output container, and links it to the Decision Object

The new EventView spawned by the parent EventViewCreatorAlgorithm of this tool will process in this new ROI.

In the majority of cases, this tool will be used to create the new ROI centred on the "feature" from the previous Step.

Definition at line 26 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

Constructor & Destructor Documentation

◆ ViewCreatorCentredOnJetWithPVConstraintROITool()

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

Definition at line 13 of file ViewCreatorCentredOnJetWithPVConstraintROITool.cxx.

16 : base_class(type, name, parent)
17{}

◆ ~ViewCreatorCentredOnJetWithPVConstraintROITool()

virtual ViewCreatorCentredOnJetWithPVConstraintROITool::~ViewCreatorCentredOnJetWithPVConstraintROITool ( )
virtualdefault

Member Function Documentation

◆ attachROILinks()

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

Tool interface method.

Definition at line 33 of file ViewCreatorCentredOnJetWithPVConstraintROITool.cxx.

34 {
35
36 // ===================================================================================== //
37 // Retrieve Primary Vertex... only 1 in the event
38 SG::ReadHandle< xAOD::VertexContainer > vertexContainerHandle = SG::makeHandle( m_vertexReadHandleKey,ctx );
39 ATH_CHECK( vertexContainerHandle.isValid() );
40
41 const xAOD::VertexContainer *vertexContainer = vertexContainerHandle.get();
42 ATH_MSG_DEBUG( "I'm working with " << vertexContainer->size() << " vertices" );
43
44 const xAOD::Vertex* primaryVertex = getPrimaryVertex( vertexContainer );
45 if ( primaryVertex == nullptr ) {
46 ATH_MSG_ERROR( "No primary vertex has been found for this event!" );
47 return StatusCode::FAILURE;
48 }
49 ATH_MSG_DEBUG( " ** PV = (" << primaryVertex->x() <<
50 "," << primaryVertex->y() <<
51 "," << primaryVertex->z() << ")" );
52
53 // ===================================================================================== //
54 // ===================================================================================== //
55 // Create output RoI collection
56
57 SG::WriteHandle<TrigRoiDescriptorCollection> roisWriteHandle = TrigCompositeUtils::createAndStoreNoAux(m_roisWriteHandleKey, ctx);
58 // ===================================================================================== //
59
60 for ( TrigCompositeUtils::Decision* outputDecision : decisions ) {
61 const std::vector< TrigCompositeUtils::LinkInfo< xAOD::JetContainer >> myFeature = TrigCompositeUtils::findLinks< xAOD::JetContainer >(outputDecision, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
62
63 if (myFeature.size() != 1) {
64 ATH_MSG_ERROR("Did not find exactly one most-recent xAOD::Jet '" << TrigCompositeUtils::featureString() << "' for Decision object index " << outputDecision->index()
65 << ", found " << myFeature.size());
66 return StatusCode::FAILURE;
67 }
68 ATH_CHECK(myFeature.at(0).isValid());
69
70 const xAOD::Jet *myJet = *(myFeature.at(0).link);
71 double jetPt = myJet->p4().Et();
72 double jetEta = myJet->eta();
73 double jetPhi = myJet->phi();
74
75 ATH_MSG_DEBUG("JET -- pt=" << jetPt <<
76 " eta=" << jetEta <<
77 " phi=" << jetPhi );
78
79 // create ROIs
80 ATH_MSG_DEBUG("Creating RoI");
81 ATH_MSG_DEBUG( " ** Imposing Z constraint while building RoI" );
82 double etaMinus = jetEta - m_roiEtaWidth;
83 double etaPlus = jetEta + m_roiEtaWidth;
84
85 double phiMinus = CxxUtils::wrapToPi( jetPhi - m_roiPhiWidth );
86 double phiPlus = CxxUtils::wrapToPi( jetPhi + m_roiPhiWidth );
87
88 double zMinus = primaryVertex->z() - m_roiZWidth;
89 double zPlus = primaryVertex->z() + m_roiZWidth;
90
91 TrigRoiDescriptor *newROI = new TrigRoiDescriptor( jetEta,etaMinus, etaPlus,
92 jetPhi, phiMinus, phiPlus,
93 primaryVertex->z(),zMinus,zPlus );
94
95 roisWriteHandle->push_back( newROI );
96 const ElementLink< TrigRoiDescriptorCollection > roiEL = ElementLink< TrigRoiDescriptorCollection >( *roisWriteHandle, roisWriteHandle->size() - 1, ctx );
97
98 outputDecision->setObjectLink( TrigCompositeUtils::roiString(), roiEL );
99 outputDecision->setObjectLink( m_prmVtxLink.value(),
100 ElementLink< xAOD::VertexContainer >( m_vertexReadHandleKey.key(),primaryVertex->index() ) );
101
102 ATH_MSG_DEBUG("PRINTING DECISION");
103 ATH_MSG_DEBUG( *outputDecision );
104 }
105
106 return StatusCode::SUCCESS;
107}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
size_type size() const noexcept
Returns the number of elements in the collection.
size_t index() const
Return the index of this element within its container.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
const xAOD::Vertex * getPrimaryVertex(const xAOD::VertexContainer *) const
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition Jet_v1.cxx:54
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
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()
const std::string & featureString()
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.
Jet_v1 Jet
Definition of the current "jet version".
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ getPrimaryVertex()

const xAOD::Vertex * ViewCreatorCentredOnJetWithPVConstraintROITool::getPrimaryVertex ( const xAOD::VertexContainer * vertexContainer) const
protected

Definition at line 109 of file ViewCreatorCentredOnJetWithPVConstraintROITool.cxx.

109 {
110 // In case we need more complex selection
111 if ( vertexContainer->size() == 0 ) {
112 ATH_MSG_WARNING( "Vertex Container has size 0! This can't be right!" );
113 return nullptr;
114 }
115
116 for ( unsigned int i(0); i<vertexContainer->size(); i++ ) {
117 const xAOD::Vertex *vertex = vertexContainer->at(i);
118 if ( vertex->vertexType() != xAOD::VxType::VertexType::PriVtx ) continue;
119 return vertex;
120 }
121
122 ATH_MSG_DEBUG( "None of the vertexes in the vertex container is a primary vertex!" );
123 ATH_MSG_DEBUG( "Using dummy vertex!" );
124 return vertexContainer->at(0);
125}
#define ATH_MSG_WARNING(x)
const T * at(size_type n) const
Access an element, as an rvalue.
@ PriVtx
Primary vertex.

◆ initialize()

StatusCode ViewCreatorCentredOnJetWithPVConstraintROITool::initialize ( )
overridevirtual

Definition at line 20 of file ViewCreatorCentredOnJetWithPVConstraintROITool.cxx.

20 {
21 ATH_CHECK( m_roisWriteHandleKey.initialize() );
22 ATH_CHECK( m_vertexReadHandleKey.initialize() );
23
24 // FIXME: We have to renounce to the Vertex RedHandleKey due to problems in the scheduler's sanity checks
25 // 'Strongly connected components found in DF realm' (see ATR-21298)
26 // Short term way of avoiding the issue
27 renounce( m_vertexReadHandleKey );
28
29 return StatusCode::SUCCESS;
30}

Member Data Documentation

◆ m_prmVtxLink

Gaudi::Property< std::string > ViewCreatorCentredOnJetWithPVConstraintROITool::m_prmVtxLink
Initial value:
{this,"PrmVtxLink","",
"PrmVtx link to attach to the output decision"}

Definition at line 60 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

60 {this,"PrmVtxLink","",
61 "PrmVtx link to attach to the output decision"};

◆ m_roiEtaWidth

Gaudi::Property< double > ViewCreatorCentredOnJetWithPVConstraintROITool::m_roiEtaWidth
Initial value:
{this,"RoIEtaWidth",0.4,
"Extent of the ROI in eta from its centre"}

Definition at line 48 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

48 {this,"RoIEtaWidth",0.4,
49 "Extent of the ROI in eta from its centre"};

◆ m_roiPhiWidth

Gaudi::Property< double > ViewCreatorCentredOnJetWithPVConstraintROITool::m_roiPhiWidth
Initial value:
{this,"RoIPhiWidth",0.4,
"Extent of the ROI in phi from its centre"}

Definition at line 51 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

51 {this,"RoIPhiWidth",0.4,
52 "Extent of the ROI in phi from its centre"};

◆ m_roisWriteHandleKey

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

Definition at line 45 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

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

◆ m_roiZWidth

Gaudi::Property< double > ViewCreatorCentredOnJetWithPVConstraintROITool::m_roiZWidth
Initial value:
{this,"RoIZWidth",10.0,
"Z Half Width in mm"}

Definition at line 54 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

54 {this,"RoIZWidth",10.0,
55 "Z Half Width in mm"};

◆ m_vertexReadHandleKey

SG::ReadHandleKey< xAOD::VertexContainer > ViewCreatorCentredOnJetWithPVConstraintROITool::m_vertexReadHandleKey
Initial value:
{this,"VertexReadHandleKey","",
"Name of the Vertex collection required as input for constructing the ROI"}

Definition at line 57 of file ViewCreatorCentredOnJetWithPVConstraintROITool.h.

57 {this,"VertexReadHandleKey","",
58 "Name of the Vertex collection required as input for constructing the ROI"};

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