ATLAS Offline Software
Public Member Functions | 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 addBranches () const
 

Detailed Description

Definition at line 15 of file AugmentationToolExample.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::AugmentationToolExample::addBranches ( ) const
virtual

Definition at line 24 of file AugmentationToolExample.cxx.

25  {
26 
27  // Set up the vector
28  std::unique_ptr<std::vector<float> > track_z0_PV(new std::vector<float>());
29 
30  // Set up the decorators
31  SG::AuxElement::Decorator< float > decorator("DFDecoratorExample");
32 
33  // CALCULATION OF THE NEW VARIABLE
34  // Get Primary vertex
35  const xAOD::VertexContainer* vertices = evtStore()->retrieve< const xAOD::VertexContainer >("PrimaryVertices");
36 
37  if(!vertices) {
38  ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key PrimaryVertices");
39  return StatusCode::FAILURE;
40  }
41 
42  const xAOD::Vertex* pv{nullptr};
43  for (const xAOD::Vertex* vx : *vertices) {
44  if (vx->vertexType() == xAOD::VxType::PriVtx) {
45  pv = vx;
46  break;
47  }
48  }
49 
50  // Get the track container
51  const xAOD::TrackParticleContainer* tracks = evtStore()->retrieve< const xAOD::TrackParticleContainer >("InDetTrackParticles");
52 
53  if(!tracks) {
54  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key InDetTrackParticles");
55  return StatusCode::FAILURE;
56  }
57 
58  // Get track z0 w.r.t PV: this is what we're adding
59  for (xAOD::TrackParticleContainer::const_iterator trackIt=tracks->begin(); trackIt!=tracks->end(); ++trackIt) {
60  if (pv) {
61  float z0wrtPV = (*trackIt)->z0() + (*trackIt)->vz() - pv->z(); // CALCULATE THE QUANTITY
62  track_z0_PV->push_back(z0wrtPV); // ADD TO VECTOR
63  decorator(**trackIt) = z0wrtPV; // DECORATE THE TRACK
64  } else {
65  track_z0_PV->push_back(999.);
66  decorator(**trackIt) = 999.;
67  }
68  }
69 
70  // Write decision to SG for access by downstream algs
71  if (evtStore()->contains<std::vector<float> >("DFAugmentationExample")) {
72  ATH_MSG_ERROR("Tool is attempting to write StoreGate keys which already exists. Please use a different key");
73  return StatusCode::FAILURE;
74  } else {
75  ATH_CHECK(evtStore()->record(std::move(track_z0_PV), "DFAugmentationExample"));
76  }
77 
78  return StatusCode::SUCCESS;
79  }

The documentation for this class was generated from the following files:
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
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
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
python.changerun.pv
pv
Definition: changerun.py:81
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.