class CLayer: def __init__(self, Position): self.Position = Position def detect (self, (x,y,z)): """Calculate for a given vector (x, y, z) the hit grid. Numbered like a matrix with index i,j, starting with 1,1 in the left upper corner with view from the source""" x = x*(self.Position/z) # calculate the realitiv position of the vector in the z-Plane y = y*(self.Position/z) if -50 < x < 50 and -50 < y < 50: j = int((-x+50)/0.0025+1) # (-x+50) /0.0025 +1 i = int((-y+50)/0.0025+1) # ^math correction of coordinate system ^each grid has 25 micrometer ^to i,j element [1,40.000] return (i,j,self.Position) class CDetector: def __init__ (self): """5 Layer of Tracker""" self.Layer1 = CLayer (100) self.Layer2 = CLayer (110) self.Layer3 = CLayer (120) self.Layer4 = CLayer (130) self.Layer5 = CLayer (140) def detect (self, vector): """Calculate for a given vector (x, y, z) the hitted grid. Numbered like a matrix with index i,j, starting with 1,1 in the left upper corner with view from the source returns "None" if the Layer is not hitted""" result = [] for Layer in [self.Layer1, self.Layer2, self.Layer3, self.Layer4, self.Layer5]: result.append(Layer.detect(vector)) return result