ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::AugmentationToolExample Class Reference

#include <AugmentationToolExample.h>

Inheritance diagram for DerivationFramework::AugmentationToolExample:
Collaboration diagram for DerivationFramework::AugmentationToolExample:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainerKey {this, "VertexContainer", "PrimaryVertices",""}
SG::ReadHandleKey< xAOD::TrackParticleContainerm_trackPartContainerKey {this, "TrackParticleContainer", "InDetTrackParticles", "Container to be decorated"}
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_exampleDecorKey {this, "ExampleDecorKey", m_trackPartContainerKey, "DFDecoratorExample", "Decoration"}
SG::WriteHandleKey< std::vector< float > > m_decisionKey {this, "DecisionKey", "DFAugmentationExample", "Write decision to SG for access by downstream algs"}

Detailed Description

Definition at line 17 of file AugmentationToolExample.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::AugmentationToolExample::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 32 of file AugmentationToolExample.cxx.

33 {
34 // Set up the vector
35 std::unique_ptr<std::vector<float> > track_z0_PV(new std::vector<float>());
36
37 // Set up the decorators
38 SG::WriteDecorHandle< xAOD::TrackParticleContainer, float > decorator(m_exampleDecorKey, ctx);
39
40 // CALCULATION OF THE NEW VARIABLE
41 // Get Primary vertex
42 SG::ReadHandle<xAOD::VertexContainer> vertices(m_vertexContainerKey, ctx);
43 if (!vertices.isValid()) {
44 ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key PrimaryVertices");
45 return StatusCode::FAILURE;
46 }
47
48 const xAOD::Vertex* pv{};
49 for (const xAOD::Vertex* vx : *vertices) {
50 if (vx->vertexType() == xAOD::VxType::PriVtx) {
51 pv = vx;
52 break;
53 }
54 }
55
56 // Get the track container
57 SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_trackPartContainerKey, ctx);
58 if (!tracks.isValid()) {
59 ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key InDetTrackParticles");
60 return StatusCode::FAILURE;
61 }
62
63 // Get track z0 w.r.t PV: this is what we're adding
64 for (const auto *trackParticle : *tracks) {
65 if (pv) {
66 float z0wrtPV = trackParticle->z0() + trackParticle->vz() - pv->z(); // CALCULATE THE QUANTITY
67 track_z0_PV->push_back(z0wrtPV); // ADD TO VECTOR
68 decorator(*trackParticle) = z0wrtPV; // DECORATE THE TRACK
69 } else {
70 track_z0_PV->push_back(999.);
71 decorator(*trackParticle) = 999.;
72 }
73 }
74
75 // Write decision to SG for access by downstream algs
76 SG::WriteHandle<std::vector<float> > decision(m_decisionKey, ctx);
77 if (!decision.isValid()) {
78 ATH_MSG_ERROR("Tool is attempting to write StoreGate keys which already exists. Please use a different key");
79 return StatusCode::FAILURE;
80 } else {
81 decision = std::move(track_z0_PV);
82 }
83
84 return StatusCode::SUCCESS;
85 }
#define ATH_MSG_ERROR(x)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackPartContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_exampleDecorKey
SG::WriteHandleKey< std::vector< float > > m_decisionKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
double z0wrtPV(const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx)
Provide the trk DCA w.r.t. the PV.
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ initialize()

StatusCode DerivationFramework::AugmentationToolExample::initialize ( )
finaloverridevirtual

Definition at line 23 of file AugmentationToolExample.cxx.

24 {
25 ATH_CHECK(m_vertexContainerKey.initialize());
27 ATH_CHECK(m_exampleDecorKey.initialize());
28 ATH_CHECK(m_decisionKey.initialize());
29 return StatusCode::SUCCESS;
30 }
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_decisionKey

SG::WriteHandleKey<std::vector<float> > DerivationFramework::AugmentationToolExample::m_decisionKey {this, "DecisionKey", "DFAugmentationExample", "Write decision to SG for access by downstream algs"}
private

Definition at line 27 of file AugmentationToolExample.h.

27{this, "DecisionKey", "DFAugmentationExample", "Write decision to SG for access by downstream algs"};

◆ m_exampleDecorKey

SG::WriteDecorHandleKey<xAOD::TrackParticleContainer> DerivationFramework::AugmentationToolExample::m_exampleDecorKey {this, "ExampleDecorKey", m_trackPartContainerKey, "DFDecoratorExample", "Decoration"}
private

Definition at line 26 of file AugmentationToolExample.h.

26{this, "ExampleDecorKey", m_trackPartContainerKey, "DFDecoratorExample", "Decoration"};

◆ m_trackPartContainerKey

SG::ReadHandleKey<xAOD::TrackParticleContainer> DerivationFramework::AugmentationToolExample::m_trackPartContainerKey {this, "TrackParticleContainer", "InDetTrackParticles", "Container to be decorated"}
private

Definition at line 25 of file AugmentationToolExample.h.

25{this, "TrackParticleContainer", "InDetTrackParticles", "Container to be decorated"};

◆ m_vertexContainerKey

SG::ReadHandleKey<xAOD::VertexContainer> DerivationFramework::AugmentationToolExample::m_vertexContainerKey {this, "VertexContainer", "PrimaryVertices",""}
private

Definition at line 24 of file AugmentationToolExample.h.

24{this, "VertexContainer", "PrimaryVertices",""};

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