src/graphnet/plots/utils.py
def add_pid_and_interaction(db, df):
    """Adds particle and interaction ID from database `db` to dataframe `df`."""
    events = df["event_no"]
    with sqlite3.connect(db) as con:
        query = (
            "select event_no, pid, interaction_type from truth where event_no in %s"
            % str(tuple(events))
        )
        data = (
            pd.read_sql(query, con)
            .sort_values("event_no")
            .reset_index(drop=True)
        )

    df = df.sort_values("event_no").reset_index(drop=True)
    df["interaction_type"] = data["interaction_type"]
    df["pid"] = data["pid"]

    for variable in df.columns:
        if variable == "energy":
            df[variable] = np.log10(df[variable])
            if variable + "_pred" in df.keys():
                df[variable + "_pred"] = np.log10(df[variable + "_pred"])
            if variable + "_retro" in df.keys():
                df[variable + "_retro"] = np.log10(df[variable + "_retro"])
    return df
Adds particle and interaction ID from database `db` to dataframe `df`.
Adds particle and interaction ID from database `db` to dataframe `df`.
Adds particle and interaction ID from database ` db ` to dataframe ` df ` .
def add_pid_and_interaction(db, df):
    events = df["event_no"]
    with sqlite3.connect(db) as con:
        query = (
            "select event_no, pid, interaction_type from truth where event_no in %s"
            % str(tuple(events))
        )
        data = (
            pd.read_sql(query, con)
            .sort_values("event_no")
            .reset_index(drop=True)
        )
    df = df.sort_values("event_no").reset_index(drop=True)
    df["interaction_type"] = data["interaction_type"]
    df["pid"] = data["pid"]
    for variable in df.columns:
        if variable == "energy":
            df[variable] = np.log10(df[variable])
            if variable + "_pred" in df.keys():
                df[variable + "_pred"] = np.log10(df[variable + "_pred"])
            if variable + "_retro" in df.keys():
                df[variable + "_retro"] = np.log10(df[variable + "_retro"])
    return df
def add_pid_and_interaction ( db , df ) : events = df [ "event_no" ] with sqlite3 . connect ( db ) as con : query = ( "select event_no, pid, interaction_type from truth where event_no in %s" % str ( tuple ( events ) ) ) data = ( pd . read_sql ( query , con ) . sort_values ( "event_no" ) . reset_index ( drop = True ) ) df = df . sort_values ( "event_no" ) . reset_index ( drop = True ) df [ "interaction_type" ] = data [ "interaction_type" ] df [ "pid" ] = data [ "pid" ] for variable in df . columns : if variable == "energy" : df [ variable ] = np . log10 ( df [ variable ] ) if variable + "_pred" in df . keys ( ) : df [ variable + "_pred" ] = np . log10 ( df [ variable + "_pred" ] ) if variable + "_retro" in df . keys ( ) : df [ variable + "_retro" ] = np . log10 ( df [ variable + "_retro" ] ) return df
Adds particle and interaction ID from database `db` to dataframe `df`.
Adds particle and interaction ID from database ` db ` to dataframe ` df ` .
"""Adds particle and interaction ID from database `db` to dataframe `df`."""
db
df