ATLAS Offline Software
TrueVertexDistanceWeightCalculator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 #include "xAODTracking/Vertex.h"
10 
11 namespace Trk {
12 
15 {
17  return StatusCode::SUCCESS;
18 }
19 
22 {
23  return StatusCode::SUCCESS;
24 }
25 
26 // class constructor implementation
28  const std::string& t,
29  const std::string& n,
30  const IInterface* p)
31  : AthAlgTool(t, n, p)
32 {
33  declareInterface<IVertexWeightCalculator>(this);
34 }
35 
36 double
38  const xAOD::Vertex& vertex) const
39 {
40  return mEstimateSignalCompatibility(vertex.position());
41 }
42 
43 double
45  const Amg::Vector3D& vtxPosition) const
46 {
48 
49  if (!mcColl.isValid()) {
50  ATH_MSG_WARNING("Could not retrieve McEventCollection "
52  << " from StoreGate. Returning 0 distance.");
53  return 0;
54  }
55 
57  const HepMC::GenEvent* myEvent = (*itr);
58  if (!myEvent) {
59  ATH_MSG_ERROR(" Cannot find truth event... Returning 0 distance... ");
60  return 0;
61  }
62 
63 #ifdef HEPMC3
64  auto Vert = myEvent->vertices().begin();
65 #else
66  HepMC::GenEvent::vertex_const_iterator Vert = myEvent->vertices_begin();
67 #endif
68  ATH_MSG_DEBUG("Resulting MC seed: x: " << (*Vert)->position().x()
69  << " y: " << (*Vert)->position().y()
70  << " z: " << (*Vert)->position().z());
71  double ztrue = (*Vert)->position().z();
72 
73  double z_vtx_pos = vtxPosition.z();
74 
75  double distance = fabs(z_vtx_pos - ztrue);
76 
77  ATH_MSG_DEBUG("Distance of pV from truth:" << distance);
78 
79  if (distance == 0.) {
80  ATH_MSG_WARNING(" Suspicious 0 distance.");
81  return 1. / 0.000001;
82  }
83  ATH_MSG_DEBUG(" Returning distance: " << 1. / distance);
84  return 1. / distance;
85 }
86 }
87 
Trk::TrueVertexDistanceWeightCalculator::TrueVertexDistanceWeightCalculator
TrueVertexDistanceWeightCalculator(const std::string &t, const std::string &n, const IInterface *p)
constructor
Definition: TrueVertexDistanceWeightCalculator.cxx:27
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::TrueVertexDistanceWeightCalculator::initialize
virtual StatusCode initialize() override
Definition: TrueVertexDistanceWeightCalculator.cxx:14
SG::ReadHandle< McEventCollection >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
Trk::TrueVertexDistanceWeightCalculator::m_mcEventCollectionKey
SG::ReadHandleKey< McEventCollection > m_mcEventCollectionKey
Definition: TrueVertexDistanceWeightCalculator.h:66
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::TrueVertexDistanceWeightCalculator::mEstimateSignalCompatibility
double mEstimateSignalCompatibility(const Amg::Vector3D &vtxPosition) const
Definition: TrueVertexDistanceWeightCalculator.cxx:44
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::TrueVertexDistanceWeightCalculator::finalize
virtual StatusCode finalize() override
Definition: TrueVertexDistanceWeightCalculator.cxx:21
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::TrueVertexDistanceWeightCalculator::estimateSignalCompatibility
virtual double estimateSignalCompatibility(const xAOD::Vertex &vertex) const override final
WeightCalculator.
Definition: TrueVertexDistanceWeightCalculator.cxx:37
VxTrackAtVertex.h
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
Vertex.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TrackParticle.h
TrueVertexDistanceWeightCalculator.h
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.