ATLAS Offline Software
Loading...
Searching...
No Matches
TracccTritonTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TracccTritonTool.h"
6
8
9#include <chrono>
10
11TracccTritonTool::TracccTritonTool(const std::string& type, const std::string& name, const IInterface* parent)
12 : base_class(type, name, parent) {
13
14 declareInterface<ITracccTritonTool>(this);
15}
16
18
19 ATH_CHECK(m_TracccTritonTool.retrieve());
20
21 return StatusCode::SUCCESS;
22}
23
25 const EventContext& ctx,
26 std::vector<uint8_t>& cellBytes,
27 TracccTritonResult& result
28) const {
29
30 // Forward the serialized traccc silicon_cell_collection as a single UINT8
31 AthInfer::InputDataMap inputData;
32 inputData["CELLS"] = std::make_pair(
33 std::vector<int64_t>{static_cast<int64_t>(cellBytes.size())},
34 cellBytes);
35
36 // The IOV the server looks the event's conditions up for: run,
37 // lumiblock, time stamp [s], time stamp ns offset, conditions run (the
38 // MC override of the run number)
39 const EventIDBase& eventID = ctx.eventID();
40 std::vector<int64_t> iov{
41 eventID.run_number(), eventID.lumi_block(), eventID.time_stamp(),
42 eventID.time_stamp_ns_offset(),
44 ATH_MSG_DEBUG("Sending event IOV run " << iov[0] << " lb " << iov[1]
45 << " time stamp " << iov[2] << "." << iov[3]
46 << " conditions run " << iov[4]);
47 inputData["EVENT_IOV"] = std::make_pair(
48 std::vector<int64_t>{static_cast<int64_t>(iov.size())}, std::move(iov));
49
50 // Every output is one serialized traccc EDM collection
51 AthInfer::OutputDataMap outputData;
52 for (const char* name : {"MEASUREMENTS", "CLUSTERS", "TRACKS", "TRACK_STATES"}) {
53 outputData[name] = std::make_pair(
54 std::vector<int64_t>{-1}, std::vector<uint8_t>{});
55 }
56
57 auto start_inference = std::chrono::high_resolution_clock::now();
58 ATH_CHECK(m_TracccTritonTool->inference(inputData, outputData));
59 auto end_inference = std::chrono::high_resolution_clock::now();
60 std::chrono::duration<double, std::milli> inference_time = end_inference - start_inference;
61 ATH_MSG_INFO("Traccc Triton inference time: " << inference_time.count() << " ms");
62
63 auto take = [&outputData](const char* name) {
64 return std::move(std::get<std::vector<uint8_t>>(outputData[name].second));
65 };
66 result.measurements = take("MEASUREMENTS");
67 result.clusters = take("CLUSTERS");
68 result.tracks = take("TRACKS");
69 result.trackStates = take("TRACK_STATES");
70
71 ATH_MSG_DEBUG("Received " << result.measurements.size() << " + "
72 << result.clusters.size() << " + " << result.tracks.size()
73 << " + " << result.trackStates.size()
74 << " bytes of measurements, clusters, tracks and track states");
75
76 return StatusCode::SUCCESS;
77}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
EventIDBase::number_type conditionsRun() const
virtual StatusCode initialize() override
ToolHandle< AthInfer::IAthInferenceTool > m_TracccTritonTool
virtual StatusCode getTracks(const EventContext &ctx, std::vector< uint8_t > &cellBytes, TracccTritonResult &result) const override
Reconstruct the tracks of one event on the server.
TracccTritonTool(const std::string &type, const std::string &name, const IInterface *parent)
std::map< std::string, InferenceData > OutputDataMap
std::map< std::string, InferenceData > InputDataMap
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
The (serialized) traccc EDM collections returned by the server.