def create_lines(linepar): ''' Expect 4 line parameters, i.e. icxy, slxy, icxz, slxz to create a line3 object used in extrapolation. Intercepts are taken at foil x=0 by construction. ''' best = linepar[0] err = linepar[1] icxy = best[0] slxy = best[1] icxz = best[2] slxz = best[3] err_icxy = err[0] err_slxy = err[1] err_icxz = err[2] err_slxz = err[3] # center p = EU.Point3(0.0, icxy, icxz) vec = EU.Vector3(1.0, slxy, slxz) lc = EU.Line3(p, vec) # left vec = EU.Vector3(1.0, slxy - err_slxy, slxz) ll = EU.Line3(p, vec) # right vec = EU.Vector3(1.0, slxy + err_slxy, slxz) lr = EU.Line3(p, vec) # top vec = EU.Vector3(1.0, slxy, slxz - err_slxz) lt = EU.Line3(p, vec) # bottom vec = EU.Vector3(1.0, slxy, slxz + err_slxz) lb = EU.Line3(p, vec) return [lc, ll, lr, lt, lb]
def __init__(self, id, par, bplist): self.id = id self.bplist = bplist # contains break points (bpx,bpy,bplayer) if any vec = euclid.Vector3(par[0], par[1], par[2]) pt = euclid.Point3(par[3], par[4], par[5]) self.line = euclid.Line3( pt, vec) # convenience, not useful for helix truth self.parstore = par # in case the bare data is requested
def hits(self, line=None, side=0): """ Input: A euclid line3 object The tracker side (=0 -> left tracker default) Process: Determine the nearest wires given a line throught the initial grid and cut on those wires closer than the lattice constant. Output: 2 Lists of wire coordinates and radii = shortest distance wire to line """ zvec = euclid.Vector3(0.0,0.0,1.0) # zaxis vector for 3D wire line darr = np.zeros((self.rows, self.columns)) zcoord = np.zeros((self.rows, self.columns)) if side < 1: sign = -1 tracker = self.grid_left else: sign = 1 tracker = self.grid_right self.wireinfo = [] # clean start m = 0 for entry in tracker: # rows for n in range(len(entry)): # columns if isinstance(line, euclid.Line3): # input was a Line3 object pos = euclid.Point3(entry[n][0], entry[n][1], 0.0) # point of wire in grid wire = euclid.Line3(pos,zvec) # wire into a vertical 3D line segm = wire.connect(line) zcoord[m][n] = segm.p.z darr[m][n] = segm.length # shortest distance line to line in 3D elif isinstance(line, HX.helix): # input was a Helix object distance = line.GetDistanceToPoint((entry[n][0]*1.0e-3, entry[n][1]*1.0e-3, 0.0)) # input in [m] zcoord[m][n] = sign*line.tanlambda * entry[n][0] # [mm] darr[m][n] = distance[0]*1.0e3 # [mm] shortest distance helix to wire point in 2D else: print 'grid ERROR: input type unknown, not line nor helix' return [], [] m += 1 cells = [] radius = [] iarr,jarr = np.where(darr <= (0.51*self.d)) #allow minimal overlap for ind,item in enumerate(iarr): jind = jarr[ind] pair = list(tracker[item][jind]) pair.append(zcoord[item][jind]) #print 'hit: ',pair self.wireinfo.append((side, jind, item)) # side, row, column cells.append(pair) # wire (x,y) and z concatenated radius.append(darr[item][jind]) return cells, radius
def single_line_manual_atplane(self, slope, interceptx, intercepty): # no container needed vec = euclid.Vector3(1.0, slope,0.0) pos = euclid.Point3(interceptx, intercepty, 0.0) # fix at icx, iy point return euclid.Line3(pos,vec)
def single_line_manual_with_z(self, slopey, slopez, intercepty = 0.0, interceptz = 0.0): # no container needed vec = euclid.Vector3(1.0, slopey, slopez) pos = euclid.Point3(0.0, intercepty, interceptz) # fix at x=0 plane -> foil plane return euclid.Line3(pos,vec)
def single_line_manual(self, slope, intercept = 0.0): # no container needed vec = euclid.Vector3(1.0, slope,0.0) pos = euclid.Point3(0.0, intercept, 0.0) # fix at x=0 plane -> foil plane return euclid.Line3(pos,vec)
euclid.Point2(sign * 53.0 + sign * bl * 44.0 + cellvariation, 0.0), euclid.Vector2(0.0, 1.0)) breakpoint = original.intersect(layerline) bpoints.append((breakpoint.x, breakpoint.y)) blayer.append(bl) c, r, i = remove_hits(bl + 1, 9, cells, radii, info) # return numpy arrays cluster[1] = (c, r, i) # next line continuing from breakpoint scat_angle = random.gauss(0.0, scatter_angle * math.pi / 180.0) # random scattering angle newangle = angle + scat_angle # altering original slope angle with new angle sl = math.tan(newangle) nextdummy = euclid.Line3( euclid.Point3(breakpoint.x, breakpoint.y, 5.0), euclid.Vector3(1.0, sl, 0.0)) caloinfo = dcalo.calohits(nextdummy, lrtracker) while len(caloinfo) < 1: # no calo was hit, try again scat_angle = random.gauss(0.0, scatter_angle * math.pi / 180.0) # random scattering angle newangle = angle + scat_angle # altering original slope angle with new angle sl = math.tan(newangle) nextdummy = euclid.Line3( euclid.Point3(breakpoint.x, breakpoint.y, 5.0), euclid.Vector3(1.0, sl, 0.0)) caloinfo = dcalo.calohits(nextdummy, lrtracker) bangles.append(scat_angle) lines.append(nextdummy) ncells, nradii = wgr.hits(nextdummy,