Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TrackParametersAtPV.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TrackParametersAtPV.cxx, (c) ATLAS Detector software
8 // Author: Tomoe Kishimoto (Tomoe.Kishimoto@cern.ch)
9 // Wrapper around the passSelection() method of xAOD egamma
10 // Writes result to SG for later selection by string parser
11 
13 #include <string>
14 
15 // Constructor
17  const std::string& n,
18  const IInterface* p ) :
19  base_class(t,n,p)
20  {
21  }
22 
23 // Destructor
25 
26 // Athena initialize and finalize
28 {
29  if (m_collTrackKey.key().empty() || m_collVertexKey.key().empty()) {
30  ATH_MSG_ERROR("No selection variables for the TrackParametersAtPV tool!");
31  return StatusCode::FAILURE;
32  }
33  ATH_CHECK( m_collTrackKey.initialize() );
34  ATH_CHECK( m_collVertexKey.initialize() );
35 
36  if (m_trackZ0PVKey.key().empty()) {
37  ATH_MSG_ERROR("No Store Gate Keys for the TrackParametersAtPV tool!");
38  return StatusCode::FAILURE;
39  }
40  ATH_CHECK( m_trackZ0PVKey.initialize() );
41 
42  ATH_MSG_VERBOSE("initialize() ...");
43  return StatusCode::SUCCESS;
44 }
45 
47 {
48  ATH_MSG_VERBOSE("finalize() ...");
49  return StatusCode::SUCCESS;
50 }
51 
52 // Augmentation
54 {
55  const EventContext& ctx = Gaudi::Hive::currentContext();
56  SG::WriteHandle< std::vector<float> >track_z0_PV(m_trackZ0PVKey,ctx);
57  ATH_CHECK(track_z0_PV.record(std::make_unique< std::vector<float> >()));
58 
59  // Get Primary vertex
60  SG::ReadHandle<xAOD::VertexContainer> vertices(m_collVertexKey,ctx);
61  if(!vertices.isValid()) {
62  ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key: " << m_collVertexKey.key());
63  return StatusCode::FAILURE;
64  }
65 
66  const xAOD::Vertex* pv(nullptr);
67  for (const xAOD::Vertex* vx : *vertices) {
68  if (vx->vertexType() == xAOD::VxType::PriVtx) {
69  pv = vx;
70  break;
71  }
72  }
73 
74  // Get the track container
75  SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_collTrackKey,ctx);
76  if(!tracks.isValid()) {
77  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key: " << m_collTrackKey.key());
78  return StatusCode::FAILURE;
79  }
80 
81  // Get track z0 w.r.t PV
82  for (const auto *trackIt : *tracks) {
83  if (pv) {
84  float z0wrtPV = trackIt->z0() + trackIt->vz() - pv->z();
85  track_z0_PV->push_back(z0wrtPV);
86 
87  } else {
88  track_z0_PV->push_back(999.);
89  }
90  }
91 
92  return StatusCode::SUCCESS;
93 }
94 
DerivationFramework::TrackParametersAtPV::~TrackParametersAtPV
~TrackParametersAtPV()
Destructor.
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::TrackParametersAtPV::initialize
StatusCode initialize()
Definition: TrackParametersAtPV.cxx:27
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TrackParametersAtPV::finalize
StatusCode finalize()
Definition: TrackParametersAtPV.cxx:46
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrackParametersAtPV.h
DerivationFramework::TrackParametersAtPV::addBranches
virtual StatusCode addBranches() const
Check that the current event passes this filter.
Definition: TrackParametersAtPV.cxx:53
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DerivationFramework::TrackParametersAtPV::TrackParametersAtPV
TrackParametersAtPV(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: TrackParametersAtPV.cxx:16
python.changerun.pv
pv
Definition: changerun.py:81