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 auto Vert = myEvent->vertices().begin();
64 ATH_MSG_DEBUG("Resulting MC seed: x: " << (*Vert)->position().x()
65 << " y: " << (*Vert)->position().y()
66 << " z: " << (*Vert)->position().z());
67 double ztrue = (*Vert)->position().z();
68
69 double z_vtx_pos = vtxPosition.z();
70
71 double distance = fabs(z_vtx_pos - ztrue);
72
73 ATH_MSG_DEBUG("Distance of pV from truth:" << distance);
74
75 if (distance == 0.) {
76 ATH_MSG_WARNING(" Suspicious 0 distance.");
77 return 1. / 0.000001;
78 }
79 ATH_MSG_DEBUG(" Returning distance: " << 1. / distance);
80 return 1. / distance;
81}
82}
83
#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.
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
Ensure that the ATLAS eigen extensions are properly loaded.
Vertex_v1 Vertex
Define the latest version of the vertex class.