Core Templates

The core package contains the fundamental template classes that form the basis of the AnalysisG framework. These templates are designed to be inherited and customized by users.

EventTemplate

class EventTemplate

Base template class for event-level data structures.

The EventTemplate class provides the foundation for defining custom event types. Users should inherit from this class and override methods to implement custom event processing logic.

Key Properties:

property index

Event index identifier.

Type:

int

property weight

Event weight for statistical analysis.

Type:

float

property Tree

ROOT tree name associated with this event.

Type:

str

property Trees

List of ROOT tree names.

Type:

list[str]

property Branches

List of ROOT branches to read.

Type:

list[str]

property Particles

List of particles in this event.

Type:

list[ParticleTemplate]

Key Methods:

selection() bool

Event selection criteria. Override this method to implement custom event selection logic.

Returns:

True if event passes selection, False otherwise

Return type:

bool

strategy()

Event processing strategy. Override to define how the event should be analyzed.

merge(EventTemplate other)

Merge another event with this one.

Parameters:

other (EventTemplate) – Event to merge

Usage Example:

from AnalysisG.core import EventTemplate

class MyEvent(EventTemplate):
    def __init__(self):
        super().__init__()

    def selection(self):
        # Require at least 4 jets
        jets = [p for p in self.Particles if p.is_jet()]
        return len(jets) >= 4

ParticleTemplate

class ParticleTemplate

Base template class for particle-level data structures.

The ParticleTemplate class represents individual particles in an event. It provides methods for accessing particle properties and implementing custom particle identification logic.

Key Properties:

property px

Particle momentum x-component (GeV).

Type:

float

property py

Particle momentum y-component (GeV).

Type:

float

property pz

Particle momentum z-component (GeV).

Type:

float

property e

Particle energy (GeV).

Type:

float

property pt

Transverse momentum (GeV).

Type:

float

property eta

Pseudorapidity.

Type:

float

property phi

Azimuthal angle (radians).

Type:

float

property mass

Particle mass (GeV).

Type:

float

property charge

Electric charge.

Type:

float

property pdgid

PDG particle ID code.

Type:

int

property Parents

List of parent particles.

Type:

list[ParticleTemplate]

property Children

List of child particles.

Type:

list[ParticleTemplate]

Key Methods:

is_lepton() bool

Check if particle is a lepton.

Returns:

True if particle is a lepton

Return type:

bool

is_jet() bool

Check if particle is a jet.

Returns:

True if particle is a jet

Return type:

bool

DeltaR(ParticleTemplate other) float

Calculate angular separation (ΔR) from another particle.

Parameters:

other (ParticleTemplate) – Other particle

Returns:

Angular separation

Return type:

float

clone() ParticleTemplate

Create a copy of this particle.

Returns:

Cloned particle

Return type:

ParticleTemplate

Operator Overloads:

The ParticleTemplate class supports arithmetic operations for four-momentum addition:

# Add two particles' four-momenta
combined = particle1 + particle2

# In-place addition
particle1 += particle2

GraphTemplate

class GraphTemplate

Base template class for graph representations of events.

The GraphTemplate class provides functionality for creating graph-based representations of physics events, suitable for Graph Neural Network analyses.

Key Properties:

property Nodes

List of graph nodes (particles).

Type:

list

property Edges

List of graph edges (connections between particles).

Type:

list

property NodeFeatures

Node feature matrix.

Type:

tensor

property EdgeFeatures

Edge feature matrix.

Type:

tensor

Key Methods:

build_graph()

Construct the graph structure. Override this method to implement custom graph building logic.

add_node(ParticleTemplate particle)

Add a node to the graph.

Parameters:

particle (ParticleTemplate) – Particle to add as a node

add_edge(int source, int target)

Add an edge between two nodes.

Parameters:
  • source (int) – Source node index

  • target (int) – Target node index

See Also

  • Simple Interfaces Overview: Overview of simple interfaces

  • ../core/event_template: Detailed EventTemplate documentation

  • ../core/particle_template: Detailed ParticleTemplate documentation

  • ../core/graph_template: Detailed GraphTemplate documentation