ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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
39 
40  // CALCULATION OF THE NEW VARIABLE
41  // Get Primary vertex
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
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
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  }

◆ initialize()

StatusCode DerivationFramework::AugmentationToolExample::initialize ( )
finaloverridevirtual

Definition at line 23 of file AugmentationToolExample.cxx.

24  {
25  ATH_CHECK(m_vertexContainerKey.initialize());
29  return StatusCode::SUCCESS;
30  }

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.

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

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

◆ m_vertexContainerKey

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

Definition at line 24 of file AugmentationToolExample.h.


The documentation for this class was generated from the following files:
DerivationFramework::AugmentationToolExample::m_exampleDecorKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_exampleDecorKey
Definition: AugmentationToolExample.h:26
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::AugmentationToolExample::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition: AugmentationToolExample.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
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
DerivationFramework::AugmentationToolExample::m_decisionKey
SG::WriteHandleKey< std::vector< float > > m_decisionKey
Definition: AugmentationToolExample.h:27
Utils::z0wrtPV
double z0wrtPV(const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx)
Provide the trk DCA w.r.t. the PV.
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/Utils.cxx:8
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
python.changerun.pv
pv
Definition: changerun.py:79
DerivationFramework::AugmentationToolExample::m_trackPartContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackPartContainerKey
Definition: AugmentationToolExample.h:25