Graph Template
This module provides two closely related types:
``graph_t`` — a plain struct that holds pre-compiled tensor data for one graph (nodes, edges, truth labels, edge-index, batch-index, …). It is the object passed to
model_template::forwardduring training/inference.``graph_template`` — the abstract base class for all user-defined graph types. Users override
CompileEvent()to call the feature-registration helpers, and optionally overridePreSelection()to filter events.
Struct: graph_t
Header: <templates/graph_template.h>
graph_t is populated by the framework; user code only reads from it inside
model_template::forward.
Public Getter Templates (call from model_template::forward)
All getters take a model pointer (this) to resolve the device index.
Signature |
Description |
|---|---|
|
Returns the named graph-level data feature tensor. |
|
Returns the named node-level data feature tensor (shape |
|
Returns the named edge-level data feature tensor (shape |
|
Returns the named graph-level truth label tensor. |
|
Returns the named node-level truth label tensor. |
|
Returns the named edge-level truth label tensor. |
|
Returns the |
|
Returns the scalar event-weight tensor. |
|
Returns the batch-index vector (non-null only during batched inference). |
|
Returns a tensor of event indices in the current batch. |
Public Data Fields
Field |
Type |
Description |
|---|---|---|
|
|
Number of nodes in this graph. |
|
|
Sequential event index from the source ROOT file. |
|
|
Monte Carlo event weight. Default |
|
|
Whether this graph passed the |
|
|
Pointer to the event hash string. |
|
|
Pointer to the source ROOT file path. |
|
|
Pointer to the graph-class name string. |
|
|
Current device (CPU or CUDA). |
|
|
Event indices in the batch (non-empty during batched inference). |
|
|
Reference-count flag used by the framework memory manager. |
Class: graph_template
Header: <templates/graph_template.h>
Inheritance: tools
Properties
Property |
Type |
Description |
|---|---|---|
|
|
Graph sequential index. Read-only. |
|
|
Event weight. Read-only. |
|
|
Whether this graph passed |
|
|
18-character event hash. Read-only. |
|
|
ROOT tree name. Read-only. |
|
|
Graph-class name. Writable. |
Public Fields
Field |
Type |
Description |
|---|---|---|
|
|
Worker-thread index (set by the framework). Default |
|
|
Source ROOT file path. |
|
|
Pointer to the dataset metadata object. |
Public Methods
Signature |
Description |
|---|---|
|
Override in subclasses to return a heap-allocated copy. |
|
Primary override point. Call |
|
Return |
|
Registers prt as the node collection for this graph. Must be called
before any |
|
Provides a binary predicate |
|
Reads event-level property G via getter fx on object ev and stores as a graph-level truth feature. |
|
Like |
|
Evaluates fx on every registered node particle (cast to O) and stores as a node-level truth feature. |
|
Like |
|
Evaluates fx on every (topology-filtered) pair |
|
Like |
|
Returns a typed pointer to the event associated with this graph
( |
|
Hash-equality comparison. |
|
Frees node-particle resources accumulated during |
Feature Naming Convention
Truth features are prefixed T- and data features D- internally. The
name argument to the add_* methods should not include this prefix; it
is added automatically.
Example:
void MyGraph::CompileEvent() {
MyEvent* ev = this->get_event<MyEvent>();
std::vector<particle_template*> nodes;
for (auto& [h, j] : ev->m_jets) {
nodes.push_back((particle_template*)j);
}
this->define_particle_nodes(&nodes);
// node data: jet pt
this->add_node_data_feature<double, MyJet>(
&MyJet::get_pt, "pt"
);
// edge truth: same parent top
this->add_edge_truth_feature<int, MyJet>(
[](std::tuple<MyJet*, MyJet*>* p) -> int {
return std::get<0>(*p)->index == std::get<1>(*p)->index;
}, "same_top"
);
}