ATLAS Offline Software
Loading...
Searching...
No Matches
TracccCellValidationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
8
9#include <GaudiKernel/StatusCode.h>
10#include <traccc/edm/silicon_cell_collection.hpp>
11
12namespace {
13 // A printer for traccc cells used to display values of unmatched cells
14 template <typename SILICON_CELL_BASE>
15 MsgStream & operator<<(MsgStream & ms, traccc::edm::silicon_cell<SILICON_CELL_BASE> const & cell) {
16 ms << "c0: " << cell.channel0()
17 << ", c1: " << cell.channel1()
18 << ", mi: " << cell.module_index()
19 << ", ac: " << cell.activation()
20 << ", ti: " << cell.time()
21 ;
22 return ms;
23 }
24}
25
26namespace ActsTrk {
27
29{
30 ATH_MSG_DEBUG("Initializing");
31
32 ATH_CHECK(m_referenceCellsKey.initialize());
33 ATH_CHECK(m_cellsKey.initialize());
34
35 return StatusCode::SUCCESS;
36}
37
38StatusCode TracccCellValidationAlg::execute(const EventContext& ctx) const
39{
40 using size_type = traccc::edm::silicon_cell_collection::buffer::size_type;
41
42 auto reference_cells_handle = SG::makeHandle(m_referenceCellsKey, ctx);
43 ATH_CHECK(reference_cells_handle.isValid());
44 auto cells_handle = SG::makeHandle(m_cellsKey, ctx);
45 ATH_CHECK(cells_handle.isValid());
46
47 auto copy = m_deviceCopy->copy(ctx);
48
49 // The data are on device so they need to be copied to host first
50 traccc::edm::silicon_cell_collection::buffer reference_cells_host_buffer{
51 copy->get_size(*reference_cells_handle), m_hostMR->mr()};
52 copy->setup(reference_cells_host_buffer)->ignore();
53 (*copy)(*reference_cells_handle, reference_cells_host_buffer)->wait();
54
55 traccc::edm::silicon_cell_collection::buffer cells_host_buffer{
56 copy->get_size(*cells_handle), m_hostMR->mr()};
57 copy->setup(cells_host_buffer)->ignore();
58 (*copy)(*cells_handle, cells_host_buffer)->wait();
59
60 traccc::edm::silicon_cell_collection::const_device reference_cells{reference_cells_host_buffer};
61 traccc::edm::silicon_cell_collection::const_device cells{cells_host_buffer};
62
63 if (reference_cells.size() != cells.size()) {
64 ATH_MSG_ERROR("different sizes");
65 return StatusCode::FAILURE;
66 }
67
68 bool error = false;
69 for (size_type i = 0; i < cells.size(); ++i) {
70 if (cells.at(i) != reference_cells.at(i)) {
71 error = true;
72 ATH_MSG_ERROR("cells differ at " << i
73 << ": ref=[" << reference_cells.at(i) << ']'
74 << ", mon=[" << cells.at(i) << ']');
75 }
76 }
77
78 return error ? StatusCode::FAILURE : StatusCode::SUCCESS;
79}
80
81} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< traccc::edm::silicon_cell_collection::const_view > m_referenceCellsKey
ToolHandle< AthDevice::IMemoryResourceTool > m_hostMR
ToolHandle< AthDevice::ICopyTool > m_deviceCopy
virtual StatusCode initialize() override
SG::ReadHandleKey< traccc::edm::silicon_cell_collection::const_view > m_cellsKey
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())