ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11namespace Trk {
12
15{
17 return StatusCode::SUCCESS;
18}
19
20StatusCode
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
36double
42
43double
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
56 McEventCollection::const_iterator itr = mcColl->begin();
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual bool isValid() override final
Can the handle be successfully dereferenced?
double mEstimateSignalCompatibility(const Amg::Vector3D &vtxPosition) const
SG::ReadHandleKey< McEventCollection > m_mcEventCollectionKey
virtual double estimateSignalCompatibility(const xAOD::Vertex &vertex) const override final
WeightCalculator.
TrueVertexDistanceWeightCalculator(const std::string &t, const std::string &n, const IInterface *p)
constructor
Eigen::Matrix< double, 3, 1 > Vector3D
::StatusCode StatusCode
StatusCode definition for legacy code.
Ensure that the ATLAS eigen extensions are properly loaded.
Vertex_v1 Vertex
Define the latest version of the vertex class.