Пример #1
0
class ApertureTEAPOT(NodeTEAPOT):
    """
	Aperture TEAPOT element.
	"""
    def __init__(self, name="aperture no name"):
        """
		Constructor. Creates the aperutre element.
		"""
        NodeTEAPOT.__init__(self, name)
        self.setType("aperture")
        self.addParam("aperture", [])
        self.addParam("apertype", 0.0)

    def initialize(self):

        shape = self.getParam("apertype")
        dim = self.getParam("aperture")
        if len(dim) > 0:
            if shape == 1:
                self.aperture = Aperture(shape, dim[0], 0.0, 0.0, 0.0)
            if shape == 2:
                self.aperture = Aperture(shape, dim[0], dim[1], 0.0, 0.0)
            if shape == 3:
                self.aperture = Aperture(shape, dim[0], dim[1], 0.0, 0.0)

    def track(self, paramsDict):
        """
		The aperture class implementation of the ApertueNode.
		"""
        bunch = paramsDict["bunch"]
        lostbunch = paramsDict["lostbunch"]
        self.aperture.checkBunch(bunch, lostbunch)
Пример #2
0
class ApertureTEAPOT(NodeTEAPOT):
	"""
	Aperture TEAPOT element.
	"""
	def __init__(self, name = "aperture no name"):
		"""
		Constructor. Creates the aperutre element.
		"""
		NodeTEAPOT.__init__(self,name)
		self.setType("aperture")
		self.addParam("aperture", [])
		self.addParam("apertype", 0.0)
		
	def initialize(self):
	
		shape = self.getParam("apertype")
		dim = self.getParam("aperture")
		if len(dim) > 0:
			if shape == 1:
				self.aperture = Aperture(shape, dim[0], 0.0, 0.0, 0.0)
			if shape == 2:
				self.aperture = Aperture(shape, dim[0], dim[1], 0.0, 0.0)
			if shape == 3:
				self.aperture = Aperture(shape, dim[0], dim[1], 0.0, 0.0)

	def track(self, paramsDict):
		"""
		The aperture class implementation of the ApertueNode.
		"""
		bunch = paramsDict["bunch"]
		lostbunch = paramsDict["lostbunch"]
		self.aperture.checkBunch(bunch,lostbunch)
Пример #3
0
class LinacApertureNode(BaseLinacNode):
    """
	The aperture classes removes particles from bunch and places them in the lostbunch
	if their coordinates are not inside the aperture:
	The shape variable could be:
	1 is circle (a is a radius)
	2 is elipse (a and b are a half-axises)
	3 is rectangle (a and b are a half-horizontal and vertical sizes)
	c and d parameters are x and y offsets of the center
	"""
    def __init__(self, shape, a, b, pos=0., c=0., d=0., name="aperture"):
        BaseLinacNode.__init__(self, name)
        self.shape = shape
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.aperture = Aperture(self.shape, self.a, self.b, self.c, self.d,
                                 pos)
        self.setPosition(pos)
        self.lost_particles_n = 0

    def track(self, paramsDict):
        bunch = paramsDict["bunch"]
        n_parts = bunch.getSize()
        if (paramsDict.has_key("lostbunch")):
            lostbunch = paramsDict["lostbunch"]
            self.aperture.checkBunch(bunch, lostbunch)
        else:
            self.aperture.checkBunch(bunch)
        self.lost_particles_n = n_parts - bunch.getSize()

    def trackDesign(self, paramsDict):
        """
		This method does nothing for the aperture case.
		"""
        pass

    def setPosition(self, pos):
        BaseLinacNode.setPosition(self, pos)
        self.aperture.setPosition(self.getPosition())

    def getNumberOfLostParticles(self):
        return self.lost_particles_n
Пример #4
0
class RectangleApertureNode(DriftTEAPOT):
	def __init__(self, a, b, pos = 0, c = 0, d = 0, name = "aperture"):
		DriftTEAPOT.__init__(self,name)
		self.shape = 3
		self.a = a
		self.b = b
		self.c = c
		self.d = d
		self.pos = pos
		self.Aperture = Aperture(self.shape, self.a, self.b, self.c, self.d, self.pos)
	
	def track(self, paramsDict):
		bunch = paramsDict["bunch"]
		lostbunch = paramsDict["lostbunch"]
		self.Aperture.checkBunch(bunch, lostbunch)

	def setPosition(self,pos):
		self.pos = pos
		self.Aperture.setPosition(self.pos)
Пример #5
0
class LinacApertureNode(BaseLinacNode):
	"""
	The aperture classes removes particles from bunch and places them in the lostbunch
	if their coordinates are not inside the aperture:
	The shape variable could be:
	1 is circle (a is a radius)
	2 is elipse (a and b are a half-axises)
	3 is rectangle (a and b are a half-horizontal and vertical sizes)
	c and d parameters are x and y offsets of the center
	"""
	def __init__(self, shape, a, b, pos = 0., c = 0., d = 0., name = "aperture"):
		BaseLinacNode.__init__(self,name)
		self.shape = shape
		self.a = a
		self.b = b
		self.c = c
		self.d = d
		self.pos = pos
		self.aperture = Aperture(self.shape, self.a, self.b, self.c, self.d, self.pos)
	
	def track(self, paramsDict):
		bunch = paramsDict["bunch"]
		if(paramsDict.has_key("lostbunch")):
			lostbunch = paramsDict["lostbunch"]
			self.aperture.checkBunch(bunch, lostbunch)
		else:
			self.aperture.checkBunch(bunch)

	def trackDesign(self, paramsDict):
		"""
		This method does nothing for the aperture case.
		"""
		pass

	def setPosition(self, pos):
		self.pos = pos
		self.Aperture.setPosition(self.pos)

	def getPosition(self):
		return self.pos