Example #1
0
def proj(config_name, cl):
    in_file = paths.get_calibration_file_name(config_name, cl)
    config = detectorconfig.get_detector_config(config_name)
    det_res = dr.DetectorResponseGaussAngle(config, 10, 10, 10, in_file)
    n_lens = det_res.n_lens_sys
    n_pmts_per_surf = det_res.n_pmts_per_surf
    lns_center = det_res.lens_centers
    means = (det_res.means).T
    sigmas = det_res.sigmas
    px_lens_means = means.reshape((n_lens, n_pmts_per_surf, 3))
    px_lens_sigmas = sigmas.reshape((n_lens, n_pmts_per_surf))
    u_dir = np.cross(lns_center, [0, 0, 1])
    mask = np.all(u_dir == 0, axis=1)
    u_dir[mask] = np.cross(lns_center[mask], [0, 1, 0])
    u_dir = normalize(u_dir, 1)
    v_dir = normalize(np.cross(lns_center, u_dir), 1)
    u_proj = np.einsum('ijk,ik->ij', px_lens_means, u_dir)
    v_proj = np.einsum('ijk,ik->ij', px_lens_means, v_dir)
    return px_lens_means, px_lens_sigmas, u_proj, v_proj
Example #2
0
 def write(self, file_name):
     event = {
         'track_tree': self.track_tree,
         'gun': self.gun_specs,
         'config_name': self.config_name,
         'simulation_params': self.simulation_params
     }
     if self.config_name is not None:
         event['config'] = detectorconfig.get_detector_config(
             self.config_name)
     if self.photons is not None:
         event['photons'] = self.photons
     if self.full_event is not None:
         event['full_event'] = self.full_event
     event['tracks'] = self.tracks
     if hasattr(self.tracks, 'hit_pos'):
         event[
             'hit_pos'] = self.tracks.hit_pos  # Note: these are the center of the lens that the photon hit
         event['means'] = self.tracks.means
         event['sigmas'] = self.tracks.sigmas
     logger.info('Writing deepdish file: ' + file_name)
     dd.io.save(file_name, event)
Example #3
0
import kabamland2
import paths


def ring_return(arr_bin, ring):
    ring_arr = np.zeros((arr_bin.shape))
    for i, px in enumerate(arr_bin):
        ring_th = px / np.cumsum(ring)
        try:
            ring_arr[i] = np.where(ring_th == 0)[-1][0]
        except IndexError:
            ring_arr[i] = 0
    return ring_arr.astype(int)


cfg = detectorconfig.get_detector_config('cfSam1_l200_p107600_b4_e10')
sim, analyzer = setup.sim_setup(cfg,
                                paths.get_calibration_file_name(
                                    cfg.config_name),
                                useGeant4=False)
det_res = analyzer.det_res
pmt_center = det_res.pmt_bin_to_position(np.arange(det_res.n_pmts_per_surf))
l_c = det_res.lens_centers[0]
amount = 2000
l_r = det_res.lens_rad
norm_dir = np.cross(np.random.rand(3), l_c)
u_vers = norm_dir / np.linalg.norm(norm_dir)
v_vers = np.cross(u_vers, l_c / np.linalg.norm(l_c))
u_pmt = np.einsum('ij,j->i', pmt_center, u_vers)
v_pmt = np.einsum('ij,j->i', pmt_center, v_vers)
fig, (ax1, ax2) = plt.subplots(1, 2)
Example #4
0
                fast_calibration=fast_calibration)
            #os.remove(photons_file)  # Would need to remove both
            logger.warning(
                '==== Calibration complete: %s %s ====' %
                (config_name, 'fast' if fast_calibration else 'slow'))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('config_name', help='Configuration name')
    parser.add_argument('--build_only',
                        '-b',
                        action='store_true',
                        help='Build the detector only.  Do not calibrate.')
    parser.add_argument('--force_build',
                        '-f',
                        action='store_true',
                        help='Force rebuilding and calibrating the detector.')
    parser.add_argument('--slow_calibration',
                        '-s',
                        action='store_true',
                        help='Use slow calibration.')
    _args = parser.parse_args()
    config_name = _args.config_name

    config = detectorconfig.get_detector_config(config_name)
    simulate_and_calibrate(config,
                           build_only=_args.build_only,
                           force=_args.force_build,
                           fast_calibration=not _args.slow_calibration)
Example #5
0
        logger.info('Track count: ' + str(len(event.tracks)))
        #event.tracks.sigmas.fill(0.01)  # TODO: Temporary hack because I think we forced 0.0001 into the tracks in the test file.  Sigmas too small really screw up the machine!!
        print_tracks(event.tracks, 20)

        calibrated_simulation = True
        if event.simulation_params is not None and 'calibrated' in event.simulation_params:
            calibrated_simulation = event.simulation_params['calibrated']
            logger.info(
                '=== Simulation event used calibrated detector: %s ===' %
                str(calibrated_simulation))
        else:
            logger.info('=== No calibration flag in event file ===')
            logger.info('Photons in file: %d' %
                        len(event.full_event.photons_end))

        config = detectorconfig.get_detector_config(
            event.config_name)  # Cross check UUID

        if calibrated_simulation:
            cal_file = paths.get_calibration_file_name(event.config_name)
            logger.info('Calibration file: ' + cal_file)
            det_res = DetectorResponseGaussAngle.DetectorResponseGaussAngle(
                config, 10, 10, 10, cal_file)  # What are the 10s??
        else:
            det_res = DetectorResponseGaussAngle.DetectorResponseGaussAngle(
                config, 10, 10, 10)  # What are the 10s??

        logger.info('Tracks in file: %d' % len(event.tracks))
        analyzer = EventAnalyzer.EventAnalyzer(det_res)
        # analyzer.plot_tracks(event.tracks)
        logger.info('=== Analyzing tracks from event tracks in file ===')
        vertices_from_original_run = AVF_analyze_tracks(analyzer,
Example #6
0
				coord = f.create_dataset('coord',maxshape=(2,None,3),data=[tracks.hit_pos.T, tracks.means.T],chunks=True)
				uncert = f.create_dataset('sigma',maxshape=(None,),data=tracks.sigmas,chunks=True)
				f.create_dataset('r_lens',data=tracks.lens_rad)
			else:
				en_depo.resize(en_depo.shape[0]+vert.shape[0], axis=0)
				en_depo[-vert.shape[0]:,:] = vert
				coord.resize(coord.shape[1]+tracks.means.shape[1], axis=1)
				coord[:,-tracks.means.shape[1]:,:] = [tracks.hit_pos.T, tracks.means.T]
				uncert.resize(uncert.shape[0]+tracks.sigmas.shape[0], axis=0)
				uncert[-tracks.sigmas.shape[0]:] = tracks.sigmas
			arr_depo.append(en_depo.shape[0])
			arr_tr.append(uncert.shape[0])
			first = False
		f.create_dataset('idx_tr',data=arr_tr)
		f.create_dataset('idx_depo',data=arr_depo)

if __name__=='__main__':
	parser = argparse.ArgumentParser()
	parser.add_argument('particle', help='particle to simulate')
	parser.add_argument('s_d', help='seed location')
	parser.add_argument('cfg', help='detector configuration')	
	args = parser.parse_args()
	sample = 500
	particle = args.particle
        config = detectorconfig.get_detector_config(args.cfg)
        s_d = args.s_d
	energy = 2
	start_time = time.time()
	gen_ev(sample,config,particle,energy,int(s_d[0]),int(s_d[1]))
	print time.time()-start_time
Example #7
0
                    uncert[-tracks.sigmas.shape[0]:] = tracks.sigmas
                    arr.append(uncert.shape[0])
            i = +1
        f.create_dataset('idx', data=arr)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('cfg', help='detector configuration')
    parser.add_argument(
        'sl', help='seed_location in the form ri_o (i=inner, o=outer)')
    args = parser.parse_args()
    sample = 500
    distance = np.linspace(20, 450, 6)
    cfg = args.cfg
    config = detectorconfig.get_detector_config(cfg)
    seed_loc = args.sl
    in_shell = int(seed_loc[1]) * 1000
    out_shell = int(seed_loc[3]) * 1000

    data_file_dir = paths.get_data_file_path(cfg)
    start_time = time.time()
    sim, analyzer = utilities.sim_setup(config,
                                        paths.get_calibration_file_name(cfg))
    print 'configuration loaded in %0.2f' % (time.time() - start_time)

    data_file_dir = paths.get_data_file_path(cfg)
    data_path = data_file_dir + seed_loc

    bkg_dist_hist(data_path, sample, 16000, sim, analyzer)
    print 's-site done'