2021-projects/team-2/train/multitask/compton_math.py
def euc(df_scatters):
    """
    
    Computes the euclidean distances between scatters by event.
    """
    new_df = df_scatters.copy()
    for euc in [1, 2, 3]:
        euc = "euc{}".format(euc)
        if euc not in new_df.columns:
            new_df[euc] = numpy.NaN
    # Do this for all events
    # Doubles -- We know that e3 is null for doubles...
    new_df.loc[new_df['e3'].isnull(), ['euc1']] = \
        sqrt(power( new_df.loc[new_df['e3'].isnull(), ['x1', 'y1', 'z1']].to_numpy() 
                  - new_df.loc[new_df['e3'].isnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].isnull(), ['euc2']] = \
        sqrt(power( new_df.loc[new_df['e3'].isnull(), ['x1', 'y1', 'z1']].to_numpy() 
                  - new_df.loc[new_df['e3'].isnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    # Triples -- We know that e3 is not null for triples
    new_df.loc[new_df['e3'].notnull(), ['euc1']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x1', 'y1', 'z1']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].notnull(), ['euc2']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x2', 'y2', 'z2']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x3', 'y3', 'z3']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].notnull(), ['euc3']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x3', 'y3', 'z3']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x1', 'y1', 'z1']].to_numpy(), 2).sum(axis=1))
    return new_df

    
    Computes the euclidean distances between scatters by event.
    
Computes the euclidean distances between scatters by event.
Computes the euclidean distances between scatters by event .
def euc(df_scatters):
    new_df = df_scatters.copy()
    for euc in [1, 2, 3]:
        euc = "euc{}".format(euc)
        if euc not in new_df.columns:
            new_df[euc] = numpy.NaN
    new_df.loc[new_df['e3'].isnull(), ['euc1']] = \
        sqrt(power( new_df.loc[new_df['e3'].isnull(), ['x1', 'y1', 'z1']].to_numpy() 
                  - new_df.loc[new_df['e3'].isnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].isnull(), ['euc2']] = \
        sqrt(power( new_df.loc[new_df['e3'].isnull(), ['x1', 'y1', 'z1']].to_numpy() 
                  - new_df.loc[new_df['e3'].isnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].notnull(), ['euc1']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x1', 'y1', 'z1']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x2', 'y2', 'z2']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].notnull(), ['euc2']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x2', 'y2', 'z2']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x3', 'y3', 'z3']].to_numpy(), 2).sum(axis=1))
    new_df.loc[new_df['e3'].notnull(), ['euc3']] = \
        sqrt(power(new_df.loc[new_df['e3'].notnull(), ['x3', 'y3', 'z3']].to_numpy()
                  -new_df.loc[new_df['e3'].notnull(), ['x1', 'y1', 'z1']].to_numpy(), 2).sum(axis=1))
    return new_df
def euc ( df_scatters ) : new_df = df_scatters . copy ( ) for euc in [ 1 , 2 , 3 ] : euc = "euc{}" . format ( euc ) if euc not in new_df . columns : new_df [ euc ] = numpy . NaN new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'euc1' ] ] = sqrt ( power ( new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'x1' , 'y1' , 'z1' ] ] . to_numpy ( ) - new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'x2' , 'y2' , 'z2' ] ] . to_numpy ( ) , 2 ) . sum ( axis = 1 ) ) new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'euc2' ] ] = sqrt ( power ( new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'x1' , 'y1' , 'z1' ] ] . to_numpy ( ) - new_df . loc [ new_df [ 'e3' ] . isnull ( ) , [ 'x2' , 'y2' , 'z2' ] ] . to_numpy ( ) , 2 ) . sum ( axis = 1 ) ) new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'euc1' ] ] = sqrt ( power ( new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x1' , 'y1' , 'z1' ] ] . to_numpy ( ) - new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x2' , 'y2' , 'z2' ] ] . to_numpy ( ) , 2 ) . sum ( axis = 1 ) ) new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'euc2' ] ] = sqrt ( power ( new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x2' , 'y2' , 'z2' ] ] . to_numpy ( ) - new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x3' , 'y3' , 'z3' ] ] . to_numpy ( ) , 2 ) . sum ( axis = 1 ) ) new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'euc3' ] ] = sqrt ( power ( new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x3' , 'y3' , 'z3' ] ] . to_numpy ( ) - new_df . loc [ new_df [ 'e3' ] . notnull ( ) , [ 'x1' , 'y1' , 'z1' ] ] . to_numpy ( ) , 2 ) . sum ( axis = 1 ) ) return new_df
Computes the euclidean distances between scatters by event.
Computes the euclidean distances between scatters by event .
"""
    
    Computes the euclidean distances between scatters by event.
    """ # Do this for all events # Doubles -- We know that e3 is null for doubles... # Triples -- We know that e3 is not null for triples
df_scatters