ATLAS Offline Software
Loading...
Searching...
No Matches
ViewCreatorCentredOnJetWithPVConstraintROITool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
14 const std::string& name,
15 const IInterface* parent)
16 : base_class(type, name, parent)
17{}
18
19
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}
31
32
34 const EventContext& ctx ) const {
35
36 // ===================================================================================== //
37 // Retrieve Primary Vertex... only 1 in the event
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
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(),
101
102 ATH_MSG_DEBUG("PRINTING DECISION");
103 ATH_MSG_DEBUG( *outputDecision );
104 }
105
106 return StatusCode::SUCCESS;
107}
108
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_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
const T * at(size_type n) const
Access an element, as an rvalue.
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.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
const xAOD::Vertex * getPrimaryVertex(const xAOD::VertexContainer *) const
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
ViewCreatorCentredOnJetWithPVConstraintROITool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
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.
@ PriVtx
Primary vertex.
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.
Helper for azimuthal angle calculations.