Expression Syntax Reference¶
Several hipo-utils tools support filtering events using expressions. This page documents the complete expression syntax.
Basic Format¶
Components:
Bank::Name- The bank name (e.g.,REC::Particle,MC::True)column- The column name within the bank (e.g.,pid,px,status)operator- Comparison operatorvalue- Value to compare against
Comparison Operators¶
| Operator | Meaning | Example |
|---|---|---|
== | Equal to | REC::Particle.pid == 11 |
!= | Not equal to | REC::Particle.charge != 0 |
< | Less than | REC::Particle.p < 1.0 |
<= | Less than or equal | REC::Track.ndf <= 5 |
> | Greater than | REC::Particle.beta > 0.9 |
>= | Greater than or equal | REC::Track.chi2 >= 0 |
Set Membership (IN)¶
Test if a value is in a list:
Examples:
# Match electrons or muons
REC::Particle.pid IN (11, 13)
# Match specific status codes
REC::Particle.status IN (2000, 4000)
Note
The IN keyword is case-insensitive (IN, in, In all work).
Range Testing (BETWEEN)¶
Test if a value is within a range (inclusive):
Examples:
# Momentum between 0.5 and 2.0 GeV
REC::Particle.p BETWEEN 0.5 AND 2.0
# Beta between 0.9 and 1.1
REC::Particle.beta BETWEEN 0.9 AND 1.1
Note
BETWEEN and AND are case-insensitive. The range is inclusive on both ends.
Multiple Expressions¶
AND Logic (Default)¶
When multiple -e options are provided, ALL must match (AND logic):
OR Logic¶
Use --or to match ANY expression:
hipo-filter -e "REC::Particle.pid == 11" \
-e "REC::Particle.pid == -11" \
--or \
-o output.hipo input.hipo
Matching Behavior¶
Any-Row Matching
An expression matches an event if ANY row in the specified bank satisfies the condition. For example:
Matches an event if at least one particle has pid=11, even if other particles have different pid values.
Supported Data Types¶
Expressions work with all numeric column types:
| HIPO Type | Description |
|---|---|
Byte | 8-bit signed integer |
Short | 16-bit signed integer |
Int | 32-bit signed integer |
Long | 64-bit signed integer |
Float | 32-bit floating point |
Double | 64-bit floating point |
Tools Using Expressions¶
| Tool | Options |
|---|---|
| hipo-filter | -e, --expr |
| hipo-search | -e, --expr |
Examples¶
Common Physics Filters¶
# Electrons
REC::Particle.pid == 11
# Positrons
REC::Particle.pid == -11
# Charged particles
REC::Particle.charge != 0
# Neutral particles
REC::Particle.charge == 0
# Photons
REC::Particle.pid == 22
# Protons
REC::Particle.pid == 2212
# Neutrons
REC::Particle.pid == 2112
# Pions (charged)
REC::Particle.pid IN (211, -211)
# Pions (all)
REC::Particle.pid IN (211, -211, 111)
# Leptons
REC::Particle.pid IN (11, -11, 13, -13)
# High momentum particles
REC::Particle.p > 2.0
# Forward detector particles
REC::Particle.status BETWEEN 2000 AND 2999
# Central detector particles
REC::Particle.status BETWEEN 4000 AND 4999