def run_solver(row, fname, atol=1e-8, rtol=1e-8, verbose=False):
    ic = create_init_conds(row)
    # create solver with nominal field
    e_solver = trajectory_solver(ic, B_func=B_Mu2e_nom, bounds=bounds_Mu2e)
    # calculate true trajectory
    sol = e_solver.solve_trajectory(verbose=verbose, atol=atol, rtol=rtol)
    # reco with distorted field
    e_solver.analyze_trajectory(step=25,
                                stride=1,
                                query="z >= 8.41 & z <= 11.66",
                                B=B_Mu2e_dis)  # analyze in tracker region
    # save to pickle
    e_solver.to_pickle(fname + '.dis.pkl')
    df_dis = e_solver.df_reco
    # reco again with distorted field
    e_solver.analyze_trajectory(step=25,
                                stride=1,
                                query="z >= 8.41 & z <= 11.66",
                                B=B_Mu2e_nom)  # analyze in tracker region
    # save to pickle
    e_solver.to_pickle(fname + '.nom.pkl')
    df_nom = e_solver.df_reco
    # trajectory_solver.to_pickle(e_solver, fname)
    # return e_solver
    # run 1 and 2, entrance to tracker
    ##return df_nom.p.iloc[0], df_nom.m.iloc[0], df_dis.p.iloc[0], df_dis.m.iloc[0]
    # run 3, mean
    return df_nom.p.mean(), df_nom.m.mean(), df_dis.p.mean(), df_dis.m.mean()
    # run 4, mean, std
    return df_nom.p.mean(), df_nom.p.std(), df_dis.p.mean(), df_dis.m.std()
Esempio n. 2
0
def run_trajectory(ic_df_row, B_func, pid=-11, z_tand=10.175 - 1.6351):
    ic_ = InitConds(t0=0,
                    tf=7e-7,
                    N_t=70001,
                    x0=ic_df_row.x,
                    y0=ic_df_row.y,
                    z0=ic_df_row.z,
                    p0=ic_df_row.p,
                    theta0=ic_df_row.theta,
                    phi0=ic_df_row.phi)
    e = trajectory_solver(init_conds=ic_,
                          bounds=bounds_Mu2e,
                          particle_id=pid,
                          B_func=B_func)
    e.solve_trajectory(atol=1e-8, rtol=1e-8)
    df_ = e.dataframe[e.dataframe.z >= z_tand]
    if len(df_) >= 1:
        tand_tracker = (df_.pz / df_.pT).iloc[0]
        df_.eval('r = (x**2 + y**2)**(1/2)', inplace=True)
        Rmax = df_.r.max()
    else:
        tand_tracker = -1000
        Rmax = -1000
    tand_init = np.tan(np.pi / 2 - ic_df_row.theta)
    return tand_init, tand_tracker, Rmax
Esempio n. 3
0
def run_solver(row, fname, atol=1e-8, rtol=1e-8, verbose=False):
    ic = create_init_conds(row)
    # create solver with nominal field
    e_solver = trajectory_solver(ic, B_func=B_Mu2e_nom, bounds=bounds_Mu2e)
    # calculate true trajectory
    sol = e_solver.solve_trajectory(verbose=verbose, atol=atol, rtol=rtol)
    # reco with distorted field
    # e_solver.analyze_trajectory(step=25, stride=1, query="z >= 8.41 & z <= 11.66", B=B_Mu2e_dis) # analyze in tracker region
    # save to pickle
    # e_solver.to_pickle(fname+'.dis.pkl')
    # df_dis = e_solver.df_reco
    # reco again with distorted field
    # e_solver.analyze_trajectory(step=25, stride=1, query="z >= 8.41 & z <= 11.66", B=B_Mu2e_nom) # analyze in tracker region
    e_solver.analyze_trajectory_LHelix()
    # save to pickle
    e_solver.to_pickle(fname + '.nom.pkl')
    return e_solver.mom_LHelix
Esempio n. 4
0
def run_solver(phi, N_calc, field, xnaught, ynaught, znaught, name):
    ic_Mu2e = InitConds(t0=0.,
                        tf=4e-8,
                        N_t=N_calc,
                        x0=xnaught,
                        y0=ynaught,
                        z0=znaught,
                        p0=104.96,
                        theta0=np.pi / 3,
                        phi0=phi)
    e_solver = trajectory_solver(ic_Mu2e, B_func=field, bounds=bounds_Mu2e)
    sol = e_solver.solve_trajectory(
        verbose=False, atol=1e-10,
        rtol=1e-10)  # high tolerance so it runs quickly for testing
    e_solver.dataframe['r'] = ((e_solver.dataframe['x'])**2 +
                               (e_solver.dataframe['y'])**2)**(1 / 2)
    e_solver.to_pickle(datadir + f'50_Gauss_z_3-14/{phi}_{name}.pkl')

    return e_solver.dataframe