From 545ff65f95200266d45cb1264a3e2a376fed490d Mon Sep 17 00:00:00 2001 From: Stan Seibert Date: Wed, 28 Sep 2011 17:34:27 -0400 Subject: Remove LBNE detector --- chroma/detectors/__init__.py | 24 ----------- chroma/detectors/lbne.py | 49 --------------------- chroma/pmt.py | 87 ++++++++++++++++++++++++++++++++++++++ chroma/solids/__init__.py | 28 +----------- chroma/solids/hamamatsu_12inch.txt | 55 ------------------------ chroma/solids/pmts.py | 87 -------------------------------------- 6 files changed, 88 insertions(+), 242 deletions(-) delete mode 100644 chroma/detectors/lbne.py create mode 100644 chroma/pmt.py delete mode 100644 chroma/solids/hamamatsu_12inch.txt delete mode 100644 chroma/solids/pmts.py diff --git a/chroma/detectors/__init__.py b/chroma/detectors/__init__.py index 2028300..90d69d0 100644 --- a/chroma/detectors/__init__.py +++ b/chroma/detectors/__init__.py @@ -1,30 +1,6 @@ -from lbne import build_lbne from sno import build_sno as build_sno_detector from miniclean import build_miniclean as build_miniclean_detector -# from LBNE document #3951 -radius = 63.30/2 -height = 76.60 -nstrings = 230 -pmts_per_string = 88 -endcap_spacing = 0.86 - -def lbne_event_view(): - return build_lbne(radius, height, nstrings, pmts_per_string, - endcap_spacing, physical_model=False) - -def lbne(): - return build_lbne(radius, height, nstrings, pmts_per_string, - endcap_spacing) - -def minilbne(): - return build_lbne(radius/10, height/10, nstrings//10, pmts_per_string//10, - endcap_spacing) - -def microlbne(): - return build_lbne(radius/40, height/40, nstrings//40, pmts_per_string//40, - endcap_spacing) - def sno(): return build_sno_detector() diff --git a/chroma/detectors/lbne.py b/chroma/detectors/lbne.py deleted file mode 100644 index 97d09e9..0000000 --- a/chroma/detectors/lbne.py +++ /dev/null @@ -1,49 +0,0 @@ -import numpy as np -from chroma.geometry import Solid, Geometry -import chroma.solids as solids -from chroma.optics import vacuum, water, water_wcsim, black_surface -from chroma.transform import rotate, make_rotation_matrix -from itertools import product -import chroma.make as make - -def build_lbne(radius, height, nstrings, pmts_per_string, endcap_spacing, detector_material=water_wcsim, physical_model=True): - if physical_model: - pmt = solids.build_12inch_pmt_with_lc(outer_material=detector_material) - else: - pmt = solids.build_12inch_pmt_shell(outer_material=detector_material) - - lbne = Geometry(detector_material) - - # outer cylinder - cylinder_mesh = make.segmented_cylinder(radius, height+height/(pmts_per_string-1), nsteps=16*nstrings, nsegments=1200) - cylinder_mesh.vertices = rotate(cylinder_mesh.vertices, np.pi/2, (-1,0,0)) - lbne.add_solid(Solid(cylinder_mesh, detector_material, vacuum, black_surface, 0xff0000ff)) - - lbne.pmtids = [] - - # construct the barrel - for i in range(pmts_per_string): - for j in range(nstrings): - rotation = make_rotation_matrix(j*2*np.pi/nstrings, (0,0,1)) - displacement = rotate((0,-radius,-height/2+i*height/(pmts_per_string-1)), j*2*np.pi/nstrings, (0,0,1)) - lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement)) - - # construct the top endcap - for x, y in np.array(tuple(product(\ - np.arange(-radius+0.075, radius, endcap_spacing), - np.arange(-radius+0.075, radius, endcap_spacing)))): - if np.sqrt(x**2 + y**2) < radius - endcap_spacing/2: - rotation = make_rotation_matrix(+np.pi/2, (1,0,0)) - displacement = (x,y,+height/2+height/(pmts_per_string-1)/2) - lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement)) - - # construct the bottom endcap - for x, y in np.array(tuple(product(\ - np.arange(-radius+0.075, radius, endcap_spacing), - np.arange(-radius+0.075, radius, endcap_spacing)))): - if np.sqrt(x**2 + y**2) < radius - endcap_spacing/2: - rotation = make_rotation_matrix(-np.pi/2, (1,0,0)) - displacement = (x,y,-height/2-height/(pmts_per_string-1)/2) - lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement)) - - return lbne diff --git a/chroma/pmt.py b/chroma/pmt.py new file mode 100644 index 0000000..43aed3f --- /dev/null +++ b/chroma/pmt.py @@ -0,0 +1,87 @@ +import numpy as np +from chroma.geometry import Solid +from chroma.make import rotate_extrude +from chroma.optics import * +from chroma.tools import read_csv, offset + +def get_lc_profile(radii, a, b, d, rmin, rmax): + c = -b*np.sqrt(1 - (rmin-d)**2/a**2) + return -c - b*np.sqrt(1-(radii-d)**2/a**2) + +def build_light_collector(pmt, a, b, d, rmin, rmax, npoints=10): + if not isinstance(pmt, Solid): + raise Exception('`pmt` must be an instance of %s' % Solid) + + lc_radii = np.linspace(rmin, rmax, npoints) + lc_profile = get_lc_profile(lc_radii, a, b, d, rmin, rmax) + + pmt_face_profile = pmt.profile[pmt.profile[:,1] > -1e-3] + + lc_offset = np.interp(lc_radii[0], list(reversed(pmt_face_profile[:,0])), list(reversed(pmt_face_profile[:,1]))) + + lc_mesh = rotate_extrude(lc_radii, lc_profile + lc_offset, pmt.nsteps) + + return Solid(lc_mesh, pmt.outer_material, pmt.outer_material, surface=shiny_surface) + +def build_pmt_shell(filename, outer_material=water, nsteps=16): + profile = read_csv(filename) + + # slice profile in half + profile = profile[profile[:,0] < 0] + profile[:,0] = -profile[:,0] + # order profile from base to face + profile = profile[np.argsort(profile[:,1])] + # set x coordinate to 0.0 for first and last profile along the profile + # so that the mesh is closed + profile[0,0] = 0.0 + profile[-1,0] = 0.0 + # convert mm -> m + profile /= 1000.0 + + return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xeeffffff) + +def build_pmt(filename, glass_thickness, outer_material=water, nsteps=16): + profile = read_csv(filename) + + # slice profile in half + profile = profile[profile[:,0] < 0] + profile[:,0] = -profile[:,0] + # order profile from base to face + profile = profile[np.argsort(profile[:,1])] + # set x coordinate to 0.0 for first and last profile along the profile + # so that the mesh is closed + profile[0,0] = 0.0 + profile[-1,0] = 0.0 + # convert mm -> m + profile /= 1000.0 + + offset_profile = offset(profile, -glass_thickness) + + outer_envelope_mesh = rotate_extrude(profile[:,0], profile[:,1], nsteps) + inner_envelope_mesh = rotate_extrude(offset_profile[:,0], offset_profile[:,1], nsteps) + + outer_envelope = Solid(outer_envelope_mesh, glass, outer_material) + + photocathode = np.mean(inner_envelope_mesh.assemble(), axis=1)[:,1] > 0 + + inner_envelope = Solid(inner_envelope_mesh, vacuum, glass, surface=np.where(photocathode, r7081hqe_photocathode, shiny_surface), color=np.where(photocathode, 0xff00, 0xff0000)) + + pmt = outer_envelope + inner_envelope + + # profile points, outer_material, and theta are used to construct the + # light collector + pmt.profile = profile + pmt.outer_material = outer_material + pmt.nsteps = nsteps + + return pmt + +def build_light_collector_from_file(filename, outer_material, nsteps=48): + profile = read_csv(filename) + + # Convert mm to m + profile /= 1000.0 + + mesh = rotate_extrude(profile[:,0], profile[:,1], nsteps) + solid = Solid(mesh, outer_material, outer_material, surface=shiny_surface) + return solid diff --git a/chroma/solids/__init__.py b/chroma/solids/__init__.py index c4d227f..9654b19 100644 --- a/chroma/solids/__init__.py +++ b/chroma/solids/__init__.py @@ -1,33 +1,7 @@ -from pmts import build_pmt, build_light_collector, build_light_collector_from_file, build_pmt_shell +from chroma.pmt import build_pmt, build_light_collector, build_light_collector_from_file, build_pmt_shell from chroma.optics import * from os.path import dirname -def build_12inch_pmt(outer_material=water, nsteps=16): - return build_pmt(dirname(__file__) + '/hamamatsu_12inch.txt', 0.003, - outer_material, nsteps) - -def build_12inch_pmt_shell(outer_material=water, nsteps=16): - return build_pmt_shell(dirname(__file__) + '/hamamatsu_12inch.txt') - -# from Jelena Maricic -lc_12inch_a = 0.16597 -lc_12inch_b = 0.584525 -lc_12inch_d = 0.09548 -lc_12inch_rmin = 0.1524 -lc_12inch_rmax = 0.235072 - -def build_12inch_pmt_with_lc(outer_material=water, nsteps=16): - pmt = build_12inch_pmt(outer_material, nsteps) - return pmt + build_light_collector(pmt, a=lc_12inch_a, b=lc_12inch_b, - d=lc_12inch_d, rmin=lc_12inch_rmin, - rmax=lc_12inch_rmax) - -def build_12inch_pmt_with_lc_hd(outer_material=water, nsteps=128): - pmt = build_12inch_pmt(outer_material, nsteps) - return pmt + build_light_collector(pmt, a=lc_12inch_a, b=lc_12inch_b, - d=lc_12inch_d, rmin=lc_12inch_rmin, - rmax=lc_12inch_rmax, npoints=100) - def build_8inch_pmt(outer_material=water, nsteps=24): return build_pmt(dirname(__file__) + '/sno_pmt.txt', 0.003, outer_material, nsteps) diff --git a/chroma/solids/hamamatsu_12inch.txt b/chroma/solids/hamamatsu_12inch.txt deleted file mode 100644 index e896b94..0000000 --- a/chroma/solids/hamamatsu_12inch.txt +++ /dev/null @@ -1,55 +0,0 @@ -#DataThief /Users/stan/Downloads/./Dimension_of_12inch_bulb_100826.png Monday 16-May-2011 12:22:34 PM -109.1514, 83.9786 -123.0527, 70.9583 -134.8946, 56.9466 -145.1919, 40.944 -150.8554, 23.4594 -152.4, 3.9922 -150.8554, -15.4649 -145.7067, -32.914 -136.4392, -49.3517 -123.0527, -64.2787 -108.6364, -75.2102 -92.1608, -86.1349 -76.2, -97.0612 -66.4176, -112.0001 -63.3284, -130.9531 -63.3284, -150.9143 -63.3284, -170.3764 -56.6351, -187.8206 -44.7932, -202.7527 -28.8324, -211.1839 -10.8122, -212.6219 --9.2676, -213.5543 --28.8324, -210.995 --45.823, -201.9569 --57.6649, -186.9473 --63.8432, -169.96 --63.8432, -150.4979 --63.8432, -130.5367 --66.4176, -111.0661 --76.7149, -96.0615 --93.1905, -85.0289 --108.6364, -74.4987 --123.0527, -63.4727 --135.4095, -49.9586 --144.677, -33.9593 --150.3405, -16.4747 --152.9149, 2.4968 --151.3703, 21.4549 --146.2216, 39.4031 --136.4392, 55.34 --124.0824, 70.2704 --109.6662, 83.198 --93.7054, 94.1244 --76.7149, 103.0513 --59.2095, 109.4813 --40.6743, 113.9119 --21.1095, 117.3411 --1.0297, 118.2734 -19.05, 117.2096 -38.6149, 114.1513 -57.15, 109.5994 -75.1703, 103.053 -92.1608, 94.5138 -104.0027, 88.4867 diff --git a/chroma/solids/pmts.py b/chroma/solids/pmts.py deleted file mode 100644 index 43aed3f..0000000 --- a/chroma/solids/pmts.py +++ /dev/null @@ -1,87 +0,0 @@ -import numpy as np -from chroma.geometry import Solid -from chroma.make import rotate_extrude -from chroma.optics import * -from chroma.tools import read_csv, offset - -def get_lc_profile(radii, a, b, d, rmin, rmax): - c = -b*np.sqrt(1 - (rmin-d)**2/a**2) - return -c - b*np.sqrt(1-(radii-d)**2/a**2) - -def build_light_collector(pmt, a, b, d, rmin, rmax, npoints=10): - if not isinstance(pmt, Solid): - raise Exception('`pmt` must be an instance of %s' % Solid) - - lc_radii = np.linspace(rmin, rmax, npoints) - lc_profile = get_lc_profile(lc_radii, a, b, d, rmin, rmax) - - pmt_face_profile = pmt.profile[pmt.profile[:,1] > -1e-3] - - lc_offset = np.interp(lc_radii[0], list(reversed(pmt_face_profile[:,0])), list(reversed(pmt_face_profile[:,1]))) - - lc_mesh = rotate_extrude(lc_radii, lc_profile + lc_offset, pmt.nsteps) - - return Solid(lc_mesh, pmt.outer_material, pmt.outer_material, surface=shiny_surface) - -def build_pmt_shell(filename, outer_material=water, nsteps=16): - profile = read_csv(filename) - - # slice profile in half - profile = profile[profile[:,0] < 0] - profile[:,0] = -profile[:,0] - # order profile from base to face - profile = profile[np.argsort(profile[:,1])] - # set x coordinate to 0.0 for first and last profile along the profile - # so that the mesh is closed - profile[0,0] = 0.0 - profile[-1,0] = 0.0 - # convert mm -> m - profile /= 1000.0 - - return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xeeffffff) - -def build_pmt(filename, glass_thickness, outer_material=water, nsteps=16): - profile = read_csv(filename) - - # slice profile in half - profile = profile[profile[:,0] < 0] - profile[:,0] = -profile[:,0] - # order profile from base to face - profile = profile[np.argsort(profile[:,1])] - # set x coordinate to 0.0 for first and last profile along the profile - # so that the mesh is closed - profile[0,0] = 0.0 - profile[-1,0] = 0.0 - # convert mm -> m - profile /= 1000.0 - - offset_profile = offset(profile, -glass_thickness) - - outer_envelope_mesh = rotate_extrude(profile[:,0], profile[:,1], nsteps) - inner_envelope_mesh = rotate_extrude(offset_profile[:,0], offset_profile[:,1], nsteps) - - outer_envelope = Solid(outer_envelope_mesh, glass, outer_material) - - photocathode = np.mean(inner_envelope_mesh.assemble(), axis=1)[:,1] > 0 - - inner_envelope = Solid(inner_envelope_mesh, vacuum, glass, surface=np.where(photocathode, r7081hqe_photocathode, shiny_surface), color=np.where(photocathode, 0xff00, 0xff0000)) - - pmt = outer_envelope + inner_envelope - - # profile points, outer_material, and theta are used to construct the - # light collector - pmt.profile = profile - pmt.outer_material = outer_material - pmt.nsteps = nsteps - - return pmt - -def build_light_collector_from_file(filename, outer_material, nsteps=48): - profile = read_csv(filename) - - # Convert mm to m - profile /= 1000.0 - - mesh = rotate_extrude(profile[:,0], profile[:,1], nsteps) - solid = Solid(mesh, outer_material, outer_material, surface=shiny_surface) - return solid -- cgit