det.addComponent(label, label) doc_handle = det.makeTypeElement(label) for i in range(num_dets): detname = BANKFMT % (i+1) roty = float(detinfo["BankAngle"][i]) + FLIPY xpos = convert(detinfo["Bank_xpos"][i]) ypos = convert(detinfo["Bank_ypos"][i]) zpos = convert(detinfo["Bank_zpos"][i]) det.addComponent(detname, root=doc_handle) det.addDetector(xpos, ypos, zpos, ROTX, roty, ROTZ, detname, "eightpack") det.addComment("STANDARD 8-PACK") det.addNPack("eightpack", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH) det.addComment("STANDARD 2m 128 PIXEL TUBE") det.addPixelatedTube("tube", NUM_PIXELS_PER_TUBE, TUBE_SIZE) det.addComment("PIXEL FOR STANDARD 2m 128 PIXEL TUBE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (TUBE_WIDTH/2.0), (TUBE_SIZE/NUM_PIXELS_PER_TUBE)) det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("DETECTOR IDs") det.addDetectorIds(label, [0, (num_dets * PIXELS_PER_BANK) - 1 , None]) det.addComment("MONITOR IDs") det.addMonitorIds(["-1", "-2", "-3"])
rect = getRectangle(bank_num, positions, corners) if bank_num in special: det = instr.makeDetectorElement('packhalfshort', root=group) else: det = instr.makeDetectorElement('packhalf', root=group) rect.makeLocation(instr, det, bank) #################### # define various "packs" of detectors # 1m x 1" 8-pack instr.addComment('banks 1 - 4 - 128x8 panel (128x8) - one inch') instr.addNPack(name='pack', type_name='tube', num_tubes=8, tube_width=INCH_TO_METRE, air_gap=AIR_GAP) instr.addPixelatedTube(name='tube', type_name='onepixel', num_pixels=128, tube_height=TUBE_LENGTH) instr.addCylinderPixel("onepixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (.5*INCH_TO_METRE), (TUBE_LENGTH/128.)) # 1m x .5" 8-pack instr.addComment('banks 5 and 6 - 128x8 panel - half inch by 1m') instr.addNPack(name='packhalf', type_name='halftube', num_tubes=8, tube_width=0.25*INCH_TO_METRE, air_gap=AIR_GAP_END) instr.addPixelatedTube(name='halftube', type_name='halfonepixel', num_pixels=128, tube_height=TUBE_LENGTH_END) instr.addCylinderPixel('halfonepixel', (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (.25*INCH_TO_METRE), (TUBE_LENGTH_END/128.)) # sausage .5m x .5" 6-pack
elif location.endswith("B"): det_type = "eightpack-bottom" det.addDetector(xpos, ypos, zpos, ROTX, roty, ROTZ, location, det_type) det.addComment("STANDARD 8-PACK") det.addNPack("eightpack", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH) det.addComment("8-PACK ABOVE BEAMSTOP") det.addNPack("eightpack-top", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH, type_name="tube-top") det.addComment("8-PACK BELOW BEAMSTOP") det.addNPack("eightpack-bottom", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH, type_name="tube-bottom") det.addComment("STANDARD 128 PIXEL TUBE") det.addPixelatedTube("tube", NUM_PIXELS_PER_TUBE, LARGE_TUBE_SIZE) det.addComment("SMALL TOP 128 PIXEL TUBE") det.addPixelatedTube("tube-top", NUM_PIXELS_PER_TUBE, SMALL_TOP_TUBE_SIZE, type_name="pixel-top") det.addComment("SMALL BOTTOM 128 PIXEL TUBE") det.addPixelatedTube("tube-bottom", NUM_PIXELS_PER_TUBE, SMALL_BOTTOM_TUBE_SIZE, type_name="pixel-bottom") det.addComment("PIXEL FOR STANDARD 128 PIXEL TUBE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (TUBE_WIDTH/2.0), (LARGE_TUBE_SIZE/NUM_PIXELS_PER_TUBE)) det.addComment("PIXEL FOR SMALL TOP 128 PIXEL TUBE") det.addCylinderPixel("pixel-top", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (TUBE_WIDTH/2.0), (SMALL_TOP_TUBE_SIZE/NUM_PIXELS_PER_TUBE))
type_name=type_name, root=elem_bank, name=f"pack{eightpack_id:02d}") rotations = list(rectangle.euler_rot_yzy) rotations.reverse() makeLocation(vulcan_geom, elem_eightpack, None, rectangle.center, rotations) # -- EIGHTPACK -- # regular 1m long tube logging.info("Add eight-pack (full tube)") addEightPack(vulcan_geom, "eightpack", "tube") vulcan_geom.addComment(f"most banks are 512 pixels across {TUBE_LENGTH}m") vulcan_geom.addPixelatedTube( name="tube", type_name="onepixel", num_pixels=TUBE_PIXELS, tube_height=TUBE_LENGTH, ) vulcan_geom.addCylinderPixel( name="onepixel", center_bottom_base=(0.0, 0.0, 0.0), axis=(0.0, 1.0, 0.0), pixel_radius=TUBE_RADIUS, pixel_height=TUBE_LENGTH / TUBE_PIXELS, ) # special 0.7m short tube logging.info("Add eight-pack (half tube)") addEightPack(vulcan_geom, "eightpackshort", "tubeshort") vulcan_geom.addComment(f"bank 5 is 512 pixels across {TUBE_LENGTH_SHORT}m") vulcan_geom.addPixelatedTube( name="tubeshort",
det.addNPack("eightpack", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH) det.addComment("8-PACK ABOVE BEAMSTOP") det.addNPack("eightpack-top", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH, type_name="tube-top") det.addComment("8-PACK BELOW BEAMSTOP") det.addNPack("eightpack-bottom", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH, type_name="tube-bottom") det.addComment("STANDARD 128 PIXEL TUBE") det.addPixelatedTube("tube", NUM_PIXELS_PER_TUBE, LARGE_TUBE_SIZE) det.addComment("SMALL TOP 128 PIXEL TUBE") det.addPixelatedTube("tube-top", NUM_PIXELS_PER_TUBE, SMALL_TOP_TUBE_SIZE, type_name="pixel-top") det.addComment("SMALL BOTTOM 128 PIXEL TUBE") det.addPixelatedTube("tube-bottom", NUM_PIXELS_PER_TUBE, SMALL_BOTTOM_TUBE_SIZE, type_name="pixel-bottom") det.addComment("PIXEL FOR STANDARD 128 PIXEL TUBE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (TUBE_WIDTH / 2.0), (LARGE_TUBE_SIZE / NUM_PIXELS_PER_TUBE))
x_coord = detector_x[k] y_coord = detector_y[k] z_coord = detector_z[k] det.addDetector(x_coord, y_coord, z_coord, 0.0, 0., 90., bank_name, "tube-elastic", facingSample=True) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS*(i-ELASTIC_BANK_START)) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS*(i-ELASTIC_BANK_START) + ELASTIC_TUBE_NPIXELS-1) idlist.append(None) # Diffraction tube information det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # Set the diffraction pixel Ids det.addDetectorIds("elastic", idlist) # Creating diffraction pixel det.addComment("PIXEL FOR DIFFRACTION TUBES") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH/2.0), (ELASTIC_TUBE_LENGTH/ELASTIC_TUBE_NPIXELS)) ''' # Creating inelastic pixel # Pixel Height y_pixel_offset = nfile["/entry/instrument/bank1/y_pixel_offset"].value
log, "logfile", **{ "id": "HB2C:Mot:s2.RBV", "eq": str(angle) + "+value", "extract-single-value-as": "mean" }) det.addComment("DET PACK") det.addWANDDetector("panel", NUM_TUBES_PER_BANK, TUBE_WIDTH, AIR_GAP_WIDTH, RADIUS, type_name="wire") det.addComment("20CM WIRE 512 PIXELS") det.addPixelatedTube("wire", NUM_PIXELS_PER_TUBE, TUBE_SIZE) det.addComment("PIXEL FOR WIRE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (TUBE_WIDTH / 2.0), (TUBE_SIZE / NUM_PIXELS_PER_TUBE)) det.addComment("DETECTOR IDs") offset = 0 for i in range(NUM_DETS): id_list = [] id_list.append(i * PIXELS_PER_BANK) id_list.append((i + 1) * PIXELS_PER_BANK - 1) id_list.append(None) det.addDetectorIds('bank' + str(NUM_DETS - i), id_list) det.addComment("MONITOR IDs")
def main(): from helper import MantidGeom inst_name = "VISION" xml_outfile = inst_name + "_Definition.xml" det = MantidGeom(inst_name, comment=" Created by Stuart Campbell ") det.addSnsDefaults(indirect=True) det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-16.0) det.addSamplePosition() # Backscattering Banks are 21-100 BACKSCATTERING_NTUBES = 80 det.addComponent("elastic-backscattering", "elastic-backscattering") handle = det.makeTypeElement("elastic-backscattering") idlist = [] for k in range(BACKSCATTERING_NTUBES): id_start = 26624 + (256 * k) id_end = 26624 + (256 * k) + 255 angle = -(2.25 + 4.5 * k) bankid = 21 + k bank_name = "bank%d" % bankid det.addComponent(bank_name, root=handle) z_coord = -0.998 if k % 2 == 0: # Even tube number (long) centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS + ( BS_ELASTIC_LONG_TUBE_LENGTH / 2.0) #centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS component_name = "tube-long-bs-elastic" else: # Odd tube number (short) centre_offset = BS_ELASTIC_SHORT_TUBE_INNER_RADIUS + ( BS_ELASTIC_SHORT_TUBE_LENGTH / 2.0) component_name = "tube-short-bs-elastic" x_coord = centre_offset * math.cos(math.radians(90 - angle)) y_coord = centre_offset * math.sin(math.radians(90 - angle)) det.addDetector(x_coord, y_coord, z_coord, 0, 0, -angle, bank_name, component_name) idlist.append(id_start) idlist.append(id_end) idlist.append(None) det.addDetectorIds("elastic-backscattering", idlist) # 90 elastic banks elastic_banklist = [3, 6, 9, 12, 15, 18] elastic_bank_start = [2048, 6144, 10240, 14336, 18432, 22528] elastic_angle = [22.5, -22.5, -67.5, -112.5, -157.5, 157.5] sample_elastic_distance = 0.635 det.addComponent("elastic", "elastic") handle = det.makeTypeElement("elastic") idlist = [] elastic_index = 0 for i in elastic_banklist: bank_name = "bank%d" % i det.addComponent(bank_name, root=handle) z_coord = 0.0 x_coord = sample_elastic_distance * math.cos( math.radians(elastic_angle[elastic_index])) y_coord = sample_elastic_distance * math.sin( math.radians(elastic_angle[elastic_index])) det.addDetector(x_coord, y_coord, z_coord, -90.0, 0, 0., bank_name, "eightpack-elastic", facingSample=True) idlist.append(elastic_bank_start[elastic_index]) idlist.append(elastic_bank_start[elastic_index] + 2047) idlist.append(None) elastic_index += 1 det.addDetectorIds("elastic", idlist) # Inelastic inelastic_banklist = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20] inelastic_bank_start = [ 0, 1024, 4096, 5120, 8192, 9216, 12288, 13312, 16384, 17408, 20480, 21504, 24576, 25600 ] inelastic_angle = [ 45.0, 45.0, 0.0, 0.0, -45.0, -45.0, -90.0, -90.0, -135.0, -135.0, 180.0, 180.0, 135.0, 135.0 ] inelastic_angle_for_rotation = [ -45.0, -45.0, 180.0, 180.0, -135.0, -135.0, -90.0, -90.0, -225.0, -225.0, 0.0, 0.0, 45.0, 45.0 ] sample_inelastic_distance = 0.5174 det.addComponent("inelastic", "inelastic") handle = det.makeTypeElement("inelastic") idlist = [] inelastic_index = 0 for i in inelastic_banklist: bank_name = "bank%d" % i bank_comp = det.addComponent(bank_name, root=handle, blank_location=True) # location_element = le.SubElement(bank_comp, "location") # le.SubElement(location_element, "rot", **{"val":"90", "axis-x":"0", # "axis-y":"0", "axis-z":"1"}) # Neutronic Positions z_coord_neutronic = sample_inelastic_distance * math.tan( math.radians(45.0)) if inelastic_index % 2 == 0: # Facing Downstream z_coord = 0.01 else: # Facing to Moderator z_coord = -0.01 z_coord_neutronic = -z_coord_neutronic # Physical Positions x_coord = sample_inelastic_distance * math.cos( math.radians(inelastic_angle[inelastic_index])) y_coord = sample_inelastic_distance * math.sin( math.radians(inelastic_angle[inelastic_index])) det.addDetector(-x_coord, y_coord, z_coord, 0, 0, inelastic_angle_for_rotation[inelastic_index] - 90.0, bank_name, "eightpack-inelastic", neutronic=True, nx=-x_coord, ny=y_coord, nz=z_coord_neutronic) efixed = ("Efixed", "3.64", "meV") det.addDetectorParameters(bank_name, efixed) idlist.append(inelastic_bank_start[inelastic_index]) idlist.append(inelastic_bank_start[inelastic_index] + 1023) idlist.append(None) inelastic_index += 1 det.addDetectorIds("inelastic", idlist) # 8 packs det.addComment("INELASTIC 8-PACK") det.addNPack("eightpack-inelastic", INELASTIC_TUBES_PER_BANK, INELASTIC_TUBE_WIDTH, INELASTIC_AIR_GAP, "tube-inelastic", neutronic=True) det.addComment("ELASTIC 8-PACK") det.addNPack("eightpack-elastic", ELASTIC_TUBES_PER_BANK, ELASTIC_TUBE_WIDTH, ELASTIC_AIR_GAP, "tube-elastic", neutronic=True, neutronicIsPhysical=True) # TUBES det.addComment("INELASTIC TUBE") det.addPixelatedTube("tube-inelastic", INELASTIC_TUBE_NPIXELS, INELASTIC_TUBE_LENGTH, "pixel-inelastic-tube", neutronic=True) det.addComment("BACKSCATTERING LONG TUBE") det.addPixelatedTube("tube-long-bs-elastic", BS_ELASTIC_LONG_TUBE_NPIXELS, BS_ELASTIC_LONG_TUBE_LENGTH, "pixel-bs-elastic-long-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("BACKSCATTERING SHORT TUBE") det.addPixelatedTube("tube-short-bs-elastic", BS_ELASTIC_SHORT_TUBE_NPIXELS, BS_ELASTIC_SHORT_TUBE_LENGTH, "pixel-bs-elastic-short-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # PIXELS det.addComment("PIXEL FOR INELASTIC TUBES") det.addCylinderPixel("pixel-inelastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (INELASTIC_TUBE_WIDTH / 2.0), (INELASTIC_TUBE_LENGTH / INELASTIC_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (LONG)") det.addCylinderPixel( "pixel-bs-elastic-long-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_LONG_TUBE_WIDTH / 2.0), (BS_ELASTIC_LONG_TUBE_LENGTH / BS_ELASTIC_LONG_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (SHORT)") det.addCylinderPixel( "pixel-bs-elastic-short-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_SHORT_TUBE_WIDTH / 2.0), (BS_ELASTIC_SHORT_TUBE_LENGTH / BS_ELASTIC_SHORT_TUBE_NPIXELS)) det.addComment("PIXEL FOR ELASTIC TUBES (90 degrees)") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH / 2.0), (ELASTIC_TUBE_LENGTH / ELASTIC_TUBE_NPIXELS)) det.addComment(" ##### MONITORS ##### ") det.addMonitors(names=["monitor1"], distance=["-6.71625"], neutronic=True) # MONITORS det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.showGeom() det.writeGeom(xml_outfile)
def generate_reflection_file(reflection_key): r""" Parameters ---------- reflection_key: str Returns ------- """ refl = reflections[reflection_key] if not os.path.exists(refl['nexus']): message = '{} not found. Not creating geometry'.format(refl['nexus']) raise FileExistsError(message) inst_name = "BASIS" # Set header information comment = "Created by Michael Reuter and Jose Borreguero" # Time needs to be in UTC? valid_from = "2014-01-01 00:00:00" xml_outfile = '{}_Definition_Si{}.xml'.format(inst_name, reflection_key) nfile = h5py.File(refl['nexus'], 'r') det = MantidGeom(inst_name, comment=comment, valid_from=valid_from) det.addSnsDefaults(indirect=True) det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-84.0) det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"], neutronic=True) # Create the inelastic banks information det.addComment('INELASTIC DECTECTORS') det.addComponent('silicon') handle_silicon = det.makeTypeElement("silicon") # Slicer for removing ghosts. Due to the mapping, the ghost tubes sit # on the same sides of the arrays for all banks. remove_ghosts = slice(-INELASTIC_TUBES_NGHOST) for i in range(n_inelastic_banks): bank_id = "bank%d" % (i+1) pixel_id = nfile["/entry/instrument/bank%d/pixel_id" % (i+1)].value[remove_ghosts] distance = nfile["/entry/instrument/bank%d/distance" % (i+1)].value[remove_ghosts] # theta or polar_angle: angle from the Z-axis towards the X-axis polar_angle = nfile["/entry/instrument/bank%d/polar_angle" % (i+1)].value[remove_ghosts] polar_angle *= (180.0/math.pi) # phi or azimuthal_angle: angle in the XY-plane azimuthal_angle = nfile["/entry/instrument/bank%d/azimuthal_angle" % (i+1)].value[remove_ghosts] azimuthal_angle *= (180.0/math.pi) analyser_wavelength = nfile["/entry/instrument/analyzer%d/wavelength" % (i+1)].value[remove_ghosts] analyser_wavelength *= refl['ratio_to_irreducible_hkl'] analyser_energy = 81.8042051/analyser_wavelength**2 det.addComponent(bank_id, idlist=bank_id, root=handle_silicon) xbank, ybank, zbank = pixels_physical_xyz(i) det.addDetectorPixels(bank_id, x=xbank, y=ybank, z=zbank, names=pixel_id, energy=analyser_energy, nr=distance, ntheta=polar_angle, nphi=azimuthal_angle, output_efixed=refl['efixed']) det.addDetectorPixelsIdList(bank_id, r=distance, names=pixel_id, elg="multiple_ranges") # Create the diffraction bank information det.addComponent("elastic", "elastic") handle = det.makeTypeElement("elastic") idlist = [] detector_z = [-2.1474825, -1.704594, -1.108373, -0.4135165, 0.3181, 1.0218315, 1.6330115, 2.0993535, 2.376999] detector_x = [1.1649855, 1.7484015, 2.175541, 2.408594, 2.422933, 2.216378, 1.8142005, 1.247867, 0.5687435] detector_y = [-0.001807, -0.001801, -0.0011845, -0.0006885, -0.0013145, -0.001626, -0.001397, 0.0003465, -0.0001125] for i in range(ELASTIC_BANK_START, ELASTIC_BANK_END+1): bank_name = "bank%d" % i det.addComponent(bank_name, root=handle) k = i - ELASTIC_BANK_START x_coord = detector_x[k] y_coord = detector_y[k] z_coord = detector_z[k] det.addDetector(x_coord, y_coord, z_coord, 0.0, 0., 90., bank_name, "tube-elastic", facingSample=True) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS*(i-ELASTIC_BANK_START)) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS*(i-ELASTIC_BANK_START) + ELASTIC_TUBE_NPIXELS-1) idlist.append(None) # Diffraction tube information det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # Set the diffraction pixel Ids det.addDetectorIds("elastic", idlist) # Creating diffraction pixel det.addComment("PIXEL FOR DIFFRACTION TUBES") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH/2.0), (ELASTIC_TUBE_LENGTH/ELASTIC_TUBE_NPIXELS)) det.addComment("PIXEL FOR INELASTIC TUBES") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), INELASTIC_TUBE_WIDTH * (1.0-INELASTIC_PIXEL_RADIUS_GAP_RATIO) / 2.0, INELASTIC_TUBE_LENGTH * (1.0-INELASTIC_PIXEL_HEIGHT_GAP_RATIO) / INELASTIC_TUBE_NPIXEL, is_type="detector", algebra="cyl-approx") det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile) # Always clean after yourself nfile.close()
det = instr.makeDetectorElement('packhalfshort', root=group) else: det = instr.makeDetectorElement('packhalf', root=group) rect.makeLocation(instr, det, bank) #################### # define various "packs" of detectors # 1m x 1" 8-pack instr.addComment('banks 1 - 4 - 128x8 panel (128x8) - one inch') instr.addNPack(name='pack', type_name='tube', num_tubes=8, tube_width=INCH_TO_METRE, air_gap=AIR_GAP) instr.addPixelatedTube(name='tube', type_name='onepixel', num_pixels=128, tube_height=TUBE_LENGTH) instr.addCylinderPixel("onepixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (.5 * INCH_TO_METRE), (TUBE_LENGTH / 128.)) # 1m x .5" 8-pack instr.addComment('banks 5 and 6 - 128x8 panel - half inch by 1m') instr.addNPack(name='packhalf', type_name='halftube', num_tubes=8, tube_width=0.25 * INCH_TO_METRE, air_gap=AIR_GAP_END) instr.addPixelatedTube(name='halftube', type_name='halfonepixel', num_pixels=128, tube_height=TUBE_LENGTH_END)
def generate_reflection_file(reflection_key): r""" Parameters ---------- reflection_key: str Returns ------- """ refl = reflections[reflection_key] if not os.path.exists(refl['nexus']): message = '{} not found. Not creating geometry'.format(refl['nexus']) raise FileExistsError(message) inst_name = "BASIS" # Set header information comment = "Created by Michael Reuter and Jose Borreguero" # Time needs to be in UTC? valid_from = "2014-01-01 00:00:00" xml_outfile = '{}_Definition_Si{}.xml'.format(inst_name, reflection_key) nfile = h5py.File(refl['nexus'], 'r') det = MantidGeom(inst_name, comment=comment, valid_from=valid_from) det.addSnsDefaults(indirect=True) det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-84.0) det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"], neutronic=True) # Create the inelastic banks information det.addComment('INELASTIC DECTECTORS') det.addComponent('silicon') handle_silicon = det.makeTypeElement("silicon") # Slicer for removing ghosts. Due to the mapping, the ghost tubes sit # on the same sides of the arrays for all banks. remove_ghosts = slice(-INELASTIC_TUBES_NGHOST) for i in range(n_inelastic_banks): bank_id = "bank%d" % (i + 1) pixel_id = nfile["/entry/instrument/bank%d/pixel_id" % (i + 1)].value[remove_ghosts] distance = nfile["/entry/instrument/bank%d/distance" % (i + 1)].value[remove_ghosts] # theta or polar_angle: angle from the Z-axis towards the X-axis polar_angle = nfile["/entry/instrument/bank%d/polar_angle" % (i + 1)].value[remove_ghosts] polar_angle *= (180.0 / math.pi) # phi or azimuthal_angle: angle in the XY-plane azimuthal_angle = nfile["/entry/instrument/bank%d/azimuthal_angle" % (i + 1)].value[remove_ghosts] azimuthal_angle *= (180.0 / math.pi) analyser_wavelength = nfile["/entry/instrument/analyzer%d/wavelength" % (i + 1)].value[remove_ghosts] analyser_wavelength *= refl['ratio_to_irreducible_hkl'] analyser_energy = 81.8042051 / analyser_wavelength**2 det.addComponent(bank_id, idlist=bank_id, root=handle_silicon) xbank, ybank, zbank = pixels_physical_xyz(i) det.addDetectorPixels(bank_id, x=xbank, y=ybank, z=zbank, names=pixel_id, energy=analyser_energy, nr=distance, ntheta=polar_angle, nphi=azimuthal_angle, output_efixed=refl['efixed']) det.addDetectorPixelsIdList(bank_id, r=distance, names=pixel_id, elg="multiple_ranges") # Create the diffraction bank information det.addComponent("elastic", "elastic") handle = det.makeTypeElement("elastic") idlist = [] detector_z = [ -2.1474825, -1.704594, -1.108373, -0.4135165, 0.3181, 1.0218315, 1.6330115, 2.0993535, 2.376999 ] detector_x = [ 1.1649855, 1.7484015, 2.175541, 2.408594, 2.422933, 2.216378, 1.8142005, 1.247867, 0.5687435 ] detector_y = [ -0.001807, -0.001801, -0.0011845, -0.0006885, -0.0013145, -0.001626, -0.001397, 0.0003465, -0.0001125 ] for i in range(ELASTIC_BANK_START, ELASTIC_BANK_END + 1): bank_name = "bank%d" % i det.addComponent(bank_name, root=handle) k = i - ELASTIC_BANK_START x_coord = detector_x[k] y_coord = detector_y[k] z_coord = detector_z[k] det.addDetector(x_coord, y_coord, z_coord, 0.0, 0., 90., bank_name, "tube-elastic", facingSample=True) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS * (i - ELASTIC_BANK_START)) idlist.append(ELASTIC_DETECTORID_START + ELASTIC_TUBE_NPIXELS * (i - ELASTIC_BANK_START) + ELASTIC_TUBE_NPIXELS - 1) idlist.append(None) # Diffraction tube information det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # Set the diffraction pixel Ids det.addDetectorIds("elastic", idlist) # Creating diffraction pixel det.addComment("PIXEL FOR DIFFRACTION TUBES") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH / 2.0), (ELASTIC_TUBE_LENGTH / ELASTIC_TUBE_NPIXELS)) det.addComment("PIXEL FOR INELASTIC TUBES") det.addCylinderPixel( "pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), INELASTIC_TUBE_WIDTH * (1.0 - INELASTIC_PIXEL_RADIUS_GAP_RATIO) / 2.0, INELASTIC_TUBE_LENGTH * (1.0 - INELASTIC_PIXEL_HEIGHT_GAP_RATIO) / INELASTIC_TUBE_NPIXEL, is_type="detector", algebra="cyl-approx") det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile) # Always clean after yourself nfile.close()
def main(): from helper import MantidGeom inst_name = "VISION" xml_outfile = inst_name+"_Definition.xml" comment = " Created by Stuart Campbell " valid_from = "2013-10-21 00:00:01" det = MantidGeom(inst_name, comment=comment, valid_from=valid_from) det.addSnsDefaults(indirect=True) det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-16.0) det.addSamplePosition() # Backscattering Banks are 21-100 BACKSCATTERING_NTUBES = 80 BACKSCATTERING_SECTORS = 10 TUBES_PER_SECTOR = BACKSCATTERING_NTUBES / BACKSCATTERING_SECTORS PIXELS_PER_SECTOR = TUBES_PER_SECTOR * 256 det.addComponent("elastic-backscattering", "elastic-backscattering") handle = det.makeTypeElement("elastic-backscattering") idlist = [] for k in range(BACKSCATTERING_SECTORS): bankid = 15 + k bank_name = "bank%d" % bankid #doc_handle = det.makeDetectorElement(bank_name, root=handle) z_coord = -0.998 id_start = 14336 + (PIXELS_PER_SECTOR * k) id_end = 14336 + (PIXELS_PER_SECTOR * k) + PIXELS_PER_SECTOR - 1 for l in range(TUBES_PER_SECTOR): tube_index = (k*TUBES_PER_SECTOR) + l tube_name = bank_name + "-tube" + str(tube_index+1) #det.addComponent(tube_name, root=doc_handle) det.addComponent(tube_name, root=handle) angle = -(2.25 + 4.5*tube_index) if tube_index%2 == 0: # Even tube number (long) centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS + (BS_ELASTIC_LONG_TUBE_LENGTH/2.0) #centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS component_name = "tube-long-bs-elastic" else: # Odd tube number (short) centre_offset = BS_ELASTIC_SHORT_TUBE_INNER_RADIUS + (BS_ELASTIC_SHORT_TUBE_LENGTH/2.0) component_name = "tube-short-bs-elastic" x_coord = centre_offset * math.cos(math.radians(90-angle)) y_coord = centre_offset * math.sin(math.radians(90-angle)) det.addDetector( x_coord, y_coord, z_coord, 0, 0, -angle, tube_name, component_name) idlist.append(id_start) idlist.append(id_end) idlist.append(None) det.addDetectorIds("elastic-backscattering", idlist) # 90 elastic banks elastic_banklist = [25,26,27,28,29,30] elastic_bank_start = [34816,36864,38912,40960,43008,45056] elastic_angle = [157.5,-157.5,-67.5,-112.5,-22.5,22.5] sample_elastic_distance = 0.635 det.addComponent("elastic", "elastic") handle = det.makeTypeElement("elastic") idlist = [] elastic_index = 0 for i in elastic_banklist: bank_name = "bank%d" % i det.addComponent(bank_name, root=handle) z_coord = 0.0 x_coord = sample_elastic_distance * math.cos(math.radians(elastic_angle[elastic_index])) y_coord = sample_elastic_distance * math.sin(math.radians(elastic_angle[elastic_index])) det.addDetector(x_coord, y_coord, z_coord, -90.0, 180, 0., bank_name, "eightpack-elastic", facingSample=True) idlist.append(elastic_bank_start[elastic_index]) idlist.append(elastic_bank_start[elastic_index]+2047) idlist.append(None) elastic_index += 1 det.addDetectorIds("elastic", idlist) # Inelastic inelastic_banklist = [1,2,3,4,5,6,7,8,9,10,11,12,13,14] inelastic_bank_start=[0,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312] inelastic_angle = [45.0,0.0,-45.0,-90.0,-135.0,-180.0,135.0,45.0,0.0,-45.0,-90.0,-135.0,-180.0,135.0] inelastic_angle_for_rotation = [-45.0,180.0,-135.0,-90.0,-225.0,0.0,45.0,-45.0,180.0,-135.0,-90.0,-225.0,0.0,45.0] sample_inelastic_distance = 0.5174 det.addComponent("inelastic", "inelastic") handle = det.makeTypeElement("inelastic") idlist = [] inelastic_index = 0 for i in inelastic_banklist: bank_name = "bank%d" % i bank_comp = det.addComponent(bank_name, root=handle, blank_location=True) # location_element = le.SubElement(bank_comp, "location") # le.SubElement(location_element, "rot", **{"val":"90", "axis-x":"0", # "axis-y":"0", "axis-z":"1"}) # Neutronic Positions z_coord_neutronic = sample_inelastic_distance * math.tan(math.radians(45.0)) if inelastic_index+1 > 7: # Facing Downstream z_coord = -0.01 else: # Facing to Moderator z_coord = 0.01 z_coord_neutronic = -z_coord_neutronic # Physical Positions x_coord = sample_inelastic_distance * math.cos(math.radians(inelastic_angle[inelastic_index])) y_coord = sample_inelastic_distance * math.sin(math.radians(inelastic_angle[inelastic_index])) det.addDetector(-x_coord, y_coord, z_coord, 0, 0, inelastic_angle_for_rotation[inelastic_index]-90.0, bank_name, "eightpack-inelastic", neutronic=True, nx=-x_coord, ny=y_coord, nz=z_coord_neutronic) efixed = ("Efixed", "3.64", "meV") det.addDetectorParameters(bank_name, efixed ) idlist.append(inelastic_bank_start[inelastic_index]) idlist.append(inelastic_bank_start[inelastic_index]+1023) idlist.append(None) inelastic_index += 1 det.addDetectorIds("inelastic", idlist) # 8 packs det.addComment("INELASTIC 8-PACK") det.addNPack("eightpack-inelastic", INELASTIC_TUBES_PER_BANK, INELASTIC_TUBE_WIDTH, INELASTIC_AIR_GAP, "tube-inelastic", neutronic=True) det.addComment("ELASTIC 8-PACK") det.addNPack("eightpack-elastic", ELASTIC_TUBES_PER_BANK, ELASTIC_TUBE_WIDTH, ELASTIC_AIR_GAP, "tube-elastic", neutronic=True, neutronicIsPhysical=True) # TUBES det.addComment("INELASTIC TUBE") det.addPixelatedTube("tube-inelastic", INELASTIC_TUBE_NPIXELS, INELASTIC_TUBE_LENGTH, "pixel-inelastic-tube", neutronic=True) det.addComment("BACKSCATTERING LONG TUBE") det.addPixelatedTube("tube-long-bs-elastic", BS_ELASTIC_LONG_TUBE_NPIXELS, BS_ELASTIC_LONG_TUBE_LENGTH, "pixel-bs-elastic-long-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("BACKSCATTERING SHORT TUBE") det.addPixelatedTube("tube-short-bs-elastic", BS_ELASTIC_SHORT_TUBE_NPIXELS, BS_ELASTIC_SHORT_TUBE_LENGTH, "pixel-bs-elastic-short-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # PIXELS det.addComment("PIXEL FOR INELASTIC TUBES") det.addCylinderPixel("pixel-inelastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (INELASTIC_TUBE_WIDTH/2.0), (INELASTIC_TUBE_LENGTH/INELASTIC_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (LONG)") det.addCylinderPixel("pixel-bs-elastic-long-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_LONG_TUBE_WIDTH/2.0), (BS_ELASTIC_LONG_TUBE_LENGTH/BS_ELASTIC_LONG_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (SHORT)") det.addCylinderPixel("pixel-bs-elastic-short-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_SHORT_TUBE_WIDTH/2.0), (BS_ELASTIC_SHORT_TUBE_LENGTH/BS_ELASTIC_SHORT_TUBE_NPIXELS)) det.addComment("PIXEL FOR ELASTIC TUBES (90 degrees)") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH/2.0), (ELASTIC_TUBE_LENGTH/ELASTIC_TUBE_NPIXELS)) det.addComment(" ##### MONITORS ##### ") det.addMonitors(names=["monitor1","monitor4"], distance=["-6.71625","0.287"], neutronic=True) # MONITORS det.addComment("MONITOR SHAPE") det.addComment("FIXME: All monitors share the dimensions of monitor4.") det.addCuboidMonitor(0.051,0.054,0.013) det.addComment("MONITOR IDs") det.addMonitorIds(["-1","-4"]) #det.showGeom() det.writeGeom(xml_outfile)
label = "Tank" tank=det.addComponent(label, label,blank_location=False) det.addLocationRTP(tank,"0","s2 0.0+s2","0","0","s2 0.0+s2","0") doc_handle = det.makeTypeElement(label) num_dets=len(info["name"]) for i in range(num_dets): det.addComponent(info["name"][i], root=doc_handle) det.addDetector(info["X"][i], info["Y"][i], info["Z"][i], info["RotX"][i], info["RotY"][i], info["RotZ"][i], info["name"][i], "eightpack") det.addComment("STANDARD 8-PACK") det.addNPack("eightpack", info["NUM_TUBES_PER_BANK"], info["TUBE_WIDTH"], info["AIR_GAP_WIDTH"]) det.addComment("STANDARD 1.2m 128 PIXEL TUBE") det.addPixelatedTube("tube", info["NUM_PIXELS_PER_TUBE"], info["TUBE_SIZE"]) det.addComment("PIXEL FOR STANDARD 1.2m 128 PIXEL TUBE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (info["TUBE_WIDTH"]/2.0), (info["TUBE_SIZE"]/info["NUM_PIXELS_PER_TUBE"])) det.addComment("MONITOR SHAPE") det.addCuboidMonitor(0.0508,0.1651,0.0381) det.addComment("DETECTOR IDs") PIXELS_PER_BANK = info["NUM_TUBES_PER_BANK"] * info["NUM_PIXELS_PER_TUBE"] det.addDetectorIds(label, [0, (num_dets * PIXELS_PER_BANK) - 1 , None]) det.addComment("MONITOR IDs") det.addMonitorIds(["-1", "-2", "-3"])
tank = det.addComponent(label, label, blank_location=False) det.addLocationRTP(tank, "0", "s2 0.0+s2", "0", "0", "s2 0.0+s2", "0") doc_handle = det.makeTypeElement(label) num_dets = len(info["name"]) for i in range(num_dets): det.addComponent(info["name"][i], root=doc_handle) det.addDetector(info["X"][i], info["Y"][i], info["Z"][i], info["RotX"][i], info["RotY"][i], info["RotZ"][i], info["name"][i], "eightpack") det.addComment("STANDARD 8-PACK") det.addNPack("eightpack", info["NUM_TUBES_PER_BANK"], info["TUBE_WIDTH"], info["AIR_GAP_WIDTH"]) det.addComment("STANDARD 1.2m 128 PIXEL TUBE") det.addPixelatedTube("tube", info["NUM_PIXELS_PER_TUBE"], info["TUBE_SIZE"]) det.addComment("PIXEL FOR STANDARD 1.2m 128 PIXEL TUBE") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (info["TUBE_WIDTH"] / 2.0), (info["TUBE_SIZE"] / info["NUM_PIXELS_PER_TUBE"])) det.addComment("MONITOR SHAPE") det.addCuboidMonitor(0.0508, 0.1651, 0.0381) det.addComment("DETECTOR IDs") PIXELS_PER_BANK = info["NUM_TUBES_PER_BANK"] * info["NUM_PIXELS_PER_TUBE"] det.addDetectorIds(label, [0, (num_dets * PIXELS_PER_BANK) - 1, None]) det.addComment("MONITOR IDs") det.addMonitorIds(["-1", "-2", "-3"])
def main(): from helper import MantidGeom inst_name = "VISION" xml_outfile = inst_name+"_Definition.xml" det = MantidGeom(inst_name, comment=" Created by Stuart Campbell ") det.addSnsDefaults(indirect=True) det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-16.0) det.addSamplePosition() # Backscattering Banks are 21-100 BACKSCATTERING_NTUBES = 80 det.addComponent("elastic-backscattering", "elastic-backscattering") handle = det.makeTypeElement("elastic-backscattering") idlist = [] for k in range(BACKSCATTERING_NTUBES): id_start = 26624+(256*k) id_end = 26624 + (256*k) + 255 angle = -(2.25 + 4.5*k) bankid = 21 + k bank_name = "bank%d" % bankid det.addComponent(bank_name, root=handle) z_coord = -0.998 if k%2 == 0: # Even tube number (long) centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS + (BS_ELASTIC_LONG_TUBE_LENGTH/2.0) #centre_offset = BS_ELASTIC_LONG_TUBE_INNER_RADIUS component_name = "tube-long-bs-elastic" else: # Odd tube number (short) centre_offset = BS_ELASTIC_SHORT_TUBE_INNER_RADIUS + (BS_ELASTIC_SHORT_TUBE_LENGTH/2.0) component_name = "tube-short-bs-elastic" x_coord = centre_offset * math.cos(math.radians(90-angle)) y_coord = centre_offset * math.sin(math.radians(90-angle)) det.addDetector(x_coord, y_coord, z_coord, 0, 0, -angle, bank_name, component_name) idlist.append(id_start) idlist.append(id_end) idlist.append(None) det.addDetectorIds("elastic-backscattering", idlist) # 90 elastic banks elastic_banklist = [3,6,9,12,15,18] elastic_bank_start = [2048,6144,10240,14336,18432,22528] elastic_angle = [22.5,-22.5,-67.5,-112.5,-157.5,157.5] sample_elastic_distance = 0.635 det.addComponent("elastic", "elastic") handle = det.makeTypeElement("elastic") idlist = [] elastic_index = 0 for i in elastic_banklist: bank_name = "bank%d" % i det.addComponent(bank_name, root=handle) z_coord = 0.0 x_coord = sample_elastic_distance * math.cos(math.radians(elastic_angle[elastic_index])) y_coord = sample_elastic_distance * math.sin(math.radians(elastic_angle[elastic_index])) det.addDetector(x_coord, y_coord, z_coord, -90.0, 0, 0., bank_name, "eightpack-elastic", facingSample=True) idlist.append(elastic_bank_start[elastic_index]) idlist.append(elastic_bank_start[elastic_index]+2047) idlist.append(None) elastic_index += 1 det.addDetectorIds("elastic", idlist) # Inelastic inelastic_banklist = [1,2,4,5,7,8,10,11,13,14,16,17,19,20] inelastic_bank_start=[0,1024,4096,5120,8192,9216,12288,13312,16384,17408,20480,21504,24576,25600] inelastic_angle = [45.0,45.0,0.0,0.0,-45.0,-45.0,-90.0,-90.0,-135.0,-135.0,180.0,180.0,135.0,135.0] inelastic_angle_for_rotation = [-45.0,-45.0,180.0,180.0,-135.0,-135.0,-90.0,-90.0,-225.0,-225.0,0.0,0.0,45.0,45.0] sample_inelastic_distance = 0.5174 det.addComponent("inelastic", "inelastic") handle = det.makeTypeElement("inelastic") idlist = [] inelastic_index = 0 for i in inelastic_banklist: bank_name = "bank%d" % i bank_comp = det.addComponent(bank_name, root=handle, blank_location=True) # location_element = le.SubElement(bank_comp, "location") # le.SubElement(location_element, "rot", **{"val":"90", "axis-x":"0", # "axis-y":"0", "axis-z":"1"}) # Neutronic Positions z_coord_neutronic = sample_inelastic_distance * math.tan(math.radians(45.0)) if inelastic_index % 2 == 0: # Facing Downstream z_coord = 0.01 else: # Facing to Moderator z_coord = -0.01 z_coord_neutronic = -z_coord_neutronic # Physical Positions x_coord = sample_inelastic_distance * math.cos(math.radians(inelastic_angle[inelastic_index])) y_coord = sample_inelastic_distance * math.sin(math.radians(inelastic_angle[inelastic_index])) det.addDetector(-x_coord, y_coord, z_coord, 0, 0, inelastic_angle_for_rotation[inelastic_index]-90.0, bank_name, "eightpack-inelastic", neutronic=True, nx=-x_coord, ny=y_coord, nz=z_coord_neutronic) efixed = ("Efixed", "3.64", "meV") det.addDetectorParameters(bank_name, efixed ) idlist.append(inelastic_bank_start[inelastic_index]) idlist.append(inelastic_bank_start[inelastic_index]+1023) idlist.append(None) inelastic_index += 1 det.addDetectorIds("inelastic", idlist) # 8 packs det.addComment("INELASTIC 8-PACK") det.addNPack("eightpack-inelastic", INELASTIC_TUBES_PER_BANK, INELASTIC_TUBE_WIDTH, INELASTIC_AIR_GAP, "tube-inelastic", neutronic=True) det.addComment("ELASTIC 8-PACK") det.addNPack("eightpack-elastic", ELASTIC_TUBES_PER_BANK, ELASTIC_TUBE_WIDTH, ELASTIC_AIR_GAP, "tube-elastic", neutronic=True, neutronicIsPhysical=True) # TUBES det.addComment("INELASTIC TUBE") det.addPixelatedTube("tube-inelastic", INELASTIC_TUBE_NPIXELS, INELASTIC_TUBE_LENGTH, "pixel-inelastic-tube", neutronic=True) det.addComment("BACKSCATTERING LONG TUBE") det.addPixelatedTube("tube-long-bs-elastic", BS_ELASTIC_LONG_TUBE_NPIXELS, BS_ELASTIC_LONG_TUBE_LENGTH, "pixel-bs-elastic-long-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("BACKSCATTERING SHORT TUBE") det.addPixelatedTube("tube-short-bs-elastic", BS_ELASTIC_SHORT_TUBE_NPIXELS, BS_ELASTIC_SHORT_TUBE_LENGTH, "pixel-bs-elastic-short-tube", neutronic=True, neutronicIsPhysical=True) det.addComment("ELASTIC TUBE (90 degrees)") det.addPixelatedTube("tube-elastic", ELASTIC_TUBE_NPIXELS, ELASTIC_TUBE_LENGTH, "pixel-elastic-tube", neutronic=True, neutronicIsPhysical=True) # PIXELS det.addComment("PIXEL FOR INELASTIC TUBES") det.addCylinderPixel("pixel-inelastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (INELASTIC_TUBE_WIDTH/2.0), (INELASTIC_TUBE_LENGTH/INELASTIC_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (LONG)") det.addCylinderPixel("pixel-bs-elastic-long-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_LONG_TUBE_WIDTH/2.0), (BS_ELASTIC_LONG_TUBE_LENGTH/BS_ELASTIC_LONG_TUBE_NPIXELS)) det.addComment("PIXEL FOR BACKSCATTERING ELASTIC TUBES (SHORT)") det.addCylinderPixel("pixel-bs-elastic-short-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (BS_ELASTIC_SHORT_TUBE_WIDTH/2.0), (BS_ELASTIC_SHORT_TUBE_LENGTH/BS_ELASTIC_SHORT_TUBE_NPIXELS)) det.addComment("PIXEL FOR ELASTIC TUBES (90 degrees)") det.addCylinderPixel("pixel-elastic-tube", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (ELASTIC_TUBE_WIDTH/2.0), (ELASTIC_TUBE_LENGTH/ELASTIC_TUBE_NPIXELS)) det.addComment(" ##### MONITORS ##### ") det.addMonitors(names=["monitor1"], distance=["-6.71625"], neutronic=True) # MONITORS det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.showGeom() det.writeGeom(xml_outfile)