# Pixel Width x_pixel_offset = file["/entry/instrument/bank1/x_pixel_offset"].value pixel_xsize = x_pixel_offset[1] - x_pixel_offset[0] # Lets just make them bigger for a moment so we can see them pixel_xsize *= 5.0 pixel_ysize *= 2.0 # arbitary value plucked from thin air! detector_depth = 0.01 left_front_bottom = ((-pixel_xsize/2.0), (-pixel_ysize/2.0), 0.0) left_front_top = ((-pixel_xsize/2.0), (pixel_ysize/2.0), 0.0) left_back_bottom = ((-pixel_xsize/2.0), (-pixel_ysize/2.0), -detector_depth) right_front_bottom = ((pixel_xsize/2.0), (-pixel_ysize/2.0), 0.0) det.addComment("PIXEL") det.addCuboidPixel("pixel", left_front_bottom, left_front_top, left_back_bottom, right_front_bottom, "detector") 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)
# Pixel Width x_pixel_offset = file["/entry/instrument/bank1/x_pixel_offset"].value pixel_xsize = x_pixel_offset[1] - x_pixel_offset[0] # Lets just make them bigger for a moment so we can see them pixel_xsize *= 5.0 pixel_ysize *= 2.0 # arbitary value plucked from thin air! detector_depth = 0.01 left_front_bottom = ((-pixel_xsize / 2.0), (-pixel_ysize / 2.0), 0.0) left_front_top = ((-pixel_xsize / 2.0), (pixel_ysize / 2.0), 0.0) left_back_bottom = ((-pixel_xsize / 2.0), (-pixel_ysize / 2.0), -detector_depth) right_front_bottom = ((pixel_xsize / 2.0), (-pixel_ysize / 2.0), 0.0) det.addComment("PIXEL") det.addCuboidPixel("pixel", left_front_bottom, left_front_top, left_back_bottom, right_front_bottom, "detector") 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 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 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)