def he3tubekernel(self, pressure, tubeIndexes, tubeLength, npixels, axisDirection, pixel0position, t2c, mca): '''create a he3tube kernel in boost python binding pressure: pressure of He3 in tube. unit: atm tubeIndexes: indexes of this tube in the detector system tubeLength: length of the tube. unit: meter npixels: number of pixels axisDirection: direction vector of the axis of the detector pixel0position: position vector of the pixel #0 relative to the center of the tube Positions of pixels can be calculated by pixel0position + i * (axisDirection * tubeLength) / npixels t2c: time->channel converter mca: multichannel analyzer ''' #c representation of tube indexes ctubeIndexes = b.vector_int(0) for ind in tubeIndexes: ctubeIndexes.append( ind ) axisDirection = b1.Vector(*axisDirection) pixel0position = b1.Vector(*pixel0position) # mapper to map "z" to pixel ID cz2c = b.Z2Channel(tubeLength, npixels, axisDirection, pixel0position) return b.He3TubeKernel( pressure, ctubeIndexes, cz2c, t2c, mca )
def he3tubekernel(self, pressure, tubeIndexes, tubeLength, npixels, axisDirection, pixel0position, t2c, mca): '''create a he3tube kernel in boost python binding pressure: pressure of He3 in tube. unit: atm tubeIndexes: indexes of this tube in the detector system tubeLength: length of the tube. unit: meter npixels: number of pixels axisDirection: direction vector of the axis of the detector pixel0position: position vector of the pixel #0 relative to the center of the tube Positions of pixels can be calculated by pixel0position + i * (axisDirection * tubeLength) / npixels t2c: time->channel converter mca: multichannel analyzer ''' #c representation of tube indexes ctubeIndexes = b.vector_int(0) for ind in tubeIndexes: ctubeIndexes.append(ind) axisDirection = b1.Vector(*axisDirection) pixel0position = b1.Vector(*pixel0position) # mapper to map "z" to pixel ID cz2c = b.Z2Channel(tubeLength, npixels, axisDirection, pixel0position) return b.He3TubeKernel(pressure, ctubeIndexes, cz2c, t2c, mca)
def he3tubekernel(self, pressure, tubeIndexes, tubeLength, npixels, axisDirection, pixel0position): import mccomponents.mccomponentsbp as b import mccomposite.mccompositebp as b1 #c representation of tube indexes ctubeIndexes = b.vector_int(0) for ind in tubeIndexes: ctubeIndexes.append( ind ) axisDirection = b1.Vector(*axisDirection) pixel0position = b1.Vector(*pixel0position) cz2c = b.Z2Channel(tubeLength, npixels, axisDirection, pixel0position) return b.He3TubeKernel( pressure, ctubeIndexes, cz2c, self.t2c, self.mca )
def he3tubekernel(self, pressure, tubeIndexes, tubeLength, npixels, axisDirection, pixel0position): import mccomponents.mccomponentsbp as b import mccomposite.mccompositebp as b1 #c representation of tube indexes ctubeIndexes = b.vector_int(0) for ind in tubeIndexes: ctubeIndexes.append(ind) axisDirection = b1.Vector(*axisDirection) pixel0position = b1.Vector(*pixel0position) cz2c = b.Z2Channel(tubeLength, npixels, axisDirection, pixel0position) return b.He3TubeKernel(pressure, ctubeIndexes, cz2c, self.t2c, self.mca)
def test(self): npixels = 100 detlength = 1. # meter tofmin = 1000. tofmax = 3000. tofstep = 1. detID = 23 atm = 1.013e5 pressure = 10 * atm prob = 3.3 tof = 2000 t2c = mccomponentsbp.Tof2Channel(tofmin, tofmax, tofstep) z_direction = mccompositebp.Vector(0, 0, 1) pixel0 = mccompositebp.Vector(0, 0, -0.5) z2c = mccomponentsbp.Z2Channel(detlength, npixels, z_direction, pixel0) datafile = "test.out" dims = mccomponentsbp.vector_uint(0) dims.append( detID + 1 ) # The first dimension is for detectors. must be larger than the largest number of detector IDs. dims.append(npixels) mca = mccomponentsbp.EventModeMCA(datafile, dims) tube_channels = mccomponentsbp.vector_int(0) tube_channels.append(detID) tube = mccomponentsbp.He3TubeKernel(pressure, tube_channels, z2c, t2c, mca) event = mcni.neutron(r=(0, 0, 0.001), prob=prob, time=tof) tube.absorb(event) del tube, mca s = open(datafile).read() import struct pixelID, tofChannelNo, prob1 = struct.unpack('IId', s) self.assertEqual(pixelID, detID * npixels + npixels / 2) self.assertEqual(tofChannelNo, (tof - tofmin) / tofstep) self.assertEqual(prob, prob1) return
def test(self): npixels = 100 detlength = 1. # meter tofmin = 1000. ; tofmax = 3000.; tofstep = 1. detID = 23 atm = 1.013e5 pressure = 10 * atm prob = 3.3 tof = 2000 t2c = mccomponentsbp.Tof2Channel(tofmin, tofmax, tofstep) z_direction = mccompositebp.Vector(0,0,1) pixel0 = mccompositebp.Vector(0,0,-0.5) z2c = mccomponentsbp.Z2Channel(detlength, npixels, z_direction, pixel0) datafile = "test.out" dims = mccomponentsbp.vector_uint(0) dims.append( detID+1 ) # The first dimension is for detectors. must be larger than the largest number of detector IDs. dims.append( npixels ) mca = mccomponentsbp.EventModeMCA( datafile, dims ) tube_channels = mccomponentsbp.vector_int(0) tube_channels.append( detID ) tube = mccomponentsbp.He3TubeKernel( pressure, tube_channels, z2c, t2c, mca); event = mcni.neutron( r = (0,0,0.001), prob = prob, time = tof ) tube.absorb( event ); del tube, mca s = open( datafile ).read() import struct pixelID, tofChannelNo, prob1 = struct.unpack( 'IId', s ) self.assertEqual( pixelID, detID * npixels + npixels/2 ) self.assertEqual( tofChannelNo, (tof-tofmin)/tofstep) self.assertEqual( prob, prob1 ) return