ATLAS Offline Software
Loading...
Searching...
No Matches
TracccTritonTool Class Reference

TracccTritonTool sends the cells of an event to a Triton server running traccc and returns the serialized traccc EDM collections it reconstructed. More...

#include <TracccTritonTool.h>

Inheritance diagram for TracccTritonTool:
Collaboration diagram for TracccTritonTool:

Public Member Functions

 TracccTritonTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode getTracks (const EventContext &ctx, std::vector< uint8_t > &cellBytes, TracccTritonResult &result) const override
 Reconstruct the tracks of one event on the server.

Private Attributes

ToolHandle< AthInfer::IAthInferenceTool > m_TracccTritonTool

Detailed Description

TracccTritonTool sends the cells of an event to a Triton server running traccc and returns the serialized traccc EDM collections it reconstructed.

Definition at line 19 of file TracccTritonTool.h.

Constructor & Destructor Documentation

◆ TracccTritonTool()

TracccTritonTool::TracccTritonTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 11 of file TracccTritonTool.cxx.

12 : base_class(type, name, parent) {
13
14 declareInterface<ITracccTritonTool>(this);
15}

Member Function Documentation

◆ getTracks()

StatusCode TracccTritonTool::getTracks ( const EventContext & ctx,
std::vector< uint8_t > & cellBytes,
TracccTritonResult & result ) const
overridevirtual

Reconstruct the tracks of one event on the server.

Parameters
ctxevent context for IOV sennding
cellBytesserialized traccc silicon_cell_collection, forwarded to the server as a single UINT8 tensor.
resultthe serialized collections the server returned

Definition at line 24 of file TracccTritonTool.cxx.

28 {
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
ToolHandle< AthInfer::IAthInferenceTool > m_TracccTritonTool
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.

◆ initialize()

StatusCode TracccTritonTool::initialize ( )
overridevirtual

Definition at line 17 of file TracccTritonTool.cxx.

17 {
18
19 ATH_CHECK(m_TracccTritonTool.retrieve());
20
21 return StatusCode::SUCCESS;
22}

Member Data Documentation

◆ m_TracccTritonTool

ToolHandle<AthInfer::IAthInferenceTool> TracccTritonTool::m_TracccTritonTool
private
Initial value:
{
this, "TritonTool", "AthInfer::TritonTool"}

Definition at line 42 of file TracccTritonTool.h.

42 {
43 this, "TritonTool", "AthInfer::TritonTool"};

The documentation for this class was generated from the following files: