ATLAS Offline Software
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  AthAlgTool(t,n,p)
20  {
21  declareInterface<DerivationFramework::IAugmentationTool>(this);
22  }
23 
24 // Destructor
26 
27 // Athena initialize and finalize
29 {
30  if (m_collTrackKey.key().empty() || m_collVertexKey.key().empty()) {
31  ATH_MSG_ERROR("No selection variables for the TrackParametersAtPV tool!");
32  return StatusCode::FAILURE;
33  }
34  ATH_CHECK( m_collTrackKey.initialize() );
35  ATH_CHECK( m_collVertexKey.initialize() );
36 
37  if (m_trackZ0PVKey.key().empty()) {
38  ATH_MSG_ERROR("No Store Gate Keys for the TrackParametersAtPV tool!");
39  return StatusCode::FAILURE;
40  }
41  ATH_CHECK( m_trackZ0PVKey.initialize() );
42 
43  ATH_MSG_VERBOSE("initialize() ...");
44  return StatusCode::SUCCESS;
45 }
46 
48 {
49  ATH_MSG_VERBOSE("finalize() ...");
50  return StatusCode::SUCCESS;
51 }
52 
53 // Augmentation
55 {
56  const EventContext& ctx = Gaudi::Hive::currentContext();
57  SG::WriteHandle< std::vector<float> >track_z0_PV(m_trackZ0PVKey,ctx);
58  ATH_CHECK(track_z0_PV.record(std::make_unique< std::vector<float> >()));
59 
60  // Get Primary vertex
61  SG::ReadHandle<xAOD::VertexContainer> vertices(m_collVertexKey,ctx);
62  if(!vertices.isValid()) {
63  ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key: " << m_collVertexKey.key());
64  return StatusCode::FAILURE;
65  }
66 
67  const xAOD::Vertex* pv(nullptr);
68  for (const xAOD::Vertex* vx : *vertices) {
69  if (vx->vertexType() == xAOD::VxType::PriVtx) {
70  pv = vx;
71  break;
72  }
73  }
74 
75  // Get the track container
76  SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_collTrackKey,ctx);
77  if(!tracks.isValid()) {
78  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key: " << m_collTrackKey.key());
79  return StatusCode::FAILURE;
80  }
81 
82  // Get track z0 w.r.t PV
83  for (const auto *trackIt : *tracks) {
84  if (pv) {
85  float z0wrtPV = trackIt->z0() + trackIt->vz() - pv->z();
86  track_z0_PV->push_back(z0wrtPV);
87 
88  } else {
89  track_z0_PV->push_back(999.);
90  }
91  }
92 
93  return StatusCode::SUCCESS;
94 }
95 
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:70
DerivationFramework::TrackParametersAtPV::initialize
StatusCode initialize()
Definition: TrackParametersAtPV.cxx:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TrackParametersAtPV::finalize
StatusCode finalize()
Definition: TrackParametersAtPV.cxx:47
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:54
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:571
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:76
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
AthAlgTool
Definition: AthAlgTool.h:26