Skip to content

Conversation

@fgalizzi
Copy link
Member

Final NP04 self-trigger analysis + Cross-talk

fgalizzi added 30 commits October 2, 2025 15:40
…lection, add save_pngs as bool, add fit_ok criteria, rename outputs
… fit status to fit_efficiency, get_10to90_range_fit
Merging main to have the correct definition of gaussian
Merging Julio's commit before PR140 is merged

result = 0.

if operation == "sum":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

# precompute squares once
e1_2 = e1 * e1
e2_2 = e2 * e2
p1_2 = p1 * p1
p2_2 = p2 * p2

match operation:
    case "sum" | "sub":
        result = math.sqrt(e1_2 + e2_2)

    case "mul":
        result = math.sqrt( e1_2 * p2_2 + e2_2 * p1_2 )

    case "div":
        p2_4 = p2_2 * p2_2
        result = math.sqrt(e1_2 / p2_2 + e2_2 * p1_2 / p2_4)

    case "sqrt_sum" | "sqrt_sub":
        sign = 1 if operation == "sqrt_sum" else -1
        f2 = p1_2 + sign * p2_2
        result = math.sqrt((e1_2 * p1_2 + e2_2 * p2_2) / f2)

    case _:
        raise Exception(GenerateExceptionMessage(
            1,
            'error_propagation()',
            "Invalid operation: must be 'sum', 'sub', 'mul',"
            " 'div', 'sqrt_sum' or 'sqrt_sub'."))

@fgalizzi fgalizzi marked this pull request as draft December 18, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants