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 calohits(self, structure, side=0): ''' Takes input line and tracker side from artificial multilines generator to create corresponding artificial calorimeter hits line is a euclid line3 object. ''' self.point = [] ci = [] for t,s,w in self.store.keys(): # check each calo type thispoint = () #print 'calohits side = %d'%side if isinstance(structure,EU.Line3): plane = self.store[(t,s,w)][0] thispoint = structure.intersect(plane) if isinstance(thispoint,EU.Point3): caloinfo = self.calo_id(thispoint) if len(caloinfo) and caloinfo[3]==side: # not an empty tuple self.point.append(thispoint) # now the right units ci.append(caloinfo) # found the calo hit #print 'calo info found: ',caloinfo else: # helix object, internal length units [m] plane = self.store[(t,s,w)][0] if t==0: # main wall if s==side: if side==0: planetup = (-435.0*1.0e-3,0.0,1.0,0.0)# input to helix method thispoint = structure.intersectionXY(planetup) else: planetup = (435.0*1.0e-3,0.0,-1.0,0.0)# input to helix method thispoint = structure.intersectionXY(planetup) elif t==1: # xwall if s==side: if w==0: planetup = (0.0,-2505.5*1.0e-3,0.0,1.0)# input to helix method thispoint = structure.intersectionXY(planetup) else: planetup = (0.0,2505.0*1.0e-3,0.0,-1.0)# input to helix method thispoint = structure.intersectionXY(planetup) elif t==2: # gveto if s==side: if w==0: zplane = -1550.0 # input to helix method thispoint = structure.intersectionZ(zplane*1.0e-3) else: zplane = 1550.0# input to helix method thispoint = structure.intersectionZ(zplane*1.0e-3) if thispoint is not None and len(thispoint)>0: p = EU.Point3(thispoint[0],thispoint[1],thispoint[2]) p *= 1.0e3 # [m] to [mm] #print 'test point: ',p caloinfo = self.calo_id(p) if len(caloinfo): # not an empty tuple self.point.append(p) # now the right units ci.append(caloinfo) # found the calo hit #return caloinfo # found the calo hit return ci # not found
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)
def helix_calopar(hfit, info): caloplane = get_calorimeter_plane(info) type = info[1] side = info[3] wall = info[6] helices = [] helix = hfit.hel # best fit helix par = helix.par # same as hfit.par if side == 0: # left tracker par4 = -par[4] # swap tan lambda for z orientation par = (par[0], par[1], par[2], par[3], par4) # new tuple err = hfit.errors helices.append(HL.Par5Helix(par, hfit.bf)) # best fit ulimit = par[3] + err[3] llimit = par[3] - err[3] # cap momentum errors for extrapolation if abs(err[3] / par[3]) > 0.1: # omega to 10% ulimit = par[3] + 0.1 * par[3] llimit = par[3] - 0.1 * par[3] # if abs(err[4]/par[4]) > 1.0: # tan lambda to factor 2 # limit = par[4] # else: limit = err[4] # vary omega and tanlambda pl = (par[0], par[1], par[2], ulimit, par[4]) helices.append(HL.Par5Helix(pl, hfit.bf)) pr = (par[0], par[1], par[2], llimit, par[4]) helices.append(HL.Par5Helix(pr, hfit.bf)) pt = (par[0], par[1], par[2], par[3], par[4] + limit) helices.append(HL.Par5Helix(pt, hfit.bf)) pb = (par[0], par[1], par[2], par[3], par[4] - limit) helices.append(HL.Par5Helix(pb, hfit.bf)) interpoints = [] if type == 0: # main ponp = caloplane._get_point() if side == 0: planetup = (ponp.x * 1.0e-3, ponp.y * 1.0e-3, 1.0, 0.0 ) # [m] xaxis is normal else: planetup = (ponp.x * 1.0e-3, ponp.y * 1.0e-3, -1.0, 0.0 ) # [m] xaxis is normal for h in helices: tup = h.intersectionXY(planetup) if tup is None: # intersection failed return None p = EU.Point3(tup[0] * 1.0e3, tup[1] * 1.0e3, tup[2] * 1.0e3) # [mm] interpoints.append(p) elif type == 1: # xwall ponp = caloplane._get_point() if wall == 0: planetup = (ponp.x * 1.0e-3, ponp.y * 1.0e-3, 0.0, 1.0 ) # [m] yaxis is normal else: planetup = (ponp.x * 1.0e-3, ponp.y * 1.0e-3, 0.0, -1.0 ) # [m] yaxis is normal for h in helices: tup = h.intersectionXY(planetup) if tup is None: # intersection failed return None p = EU.Point3(tup[0] * 1.0e3, tup[1] * 1.0e3, tup[2] * 1.0e3) # [mm] interpoints.append(p) else: zplane = caloplane._get_point().z for h in helices: tup = h.intersectionZ(zplane * 1.0e-3) # [m] if tup is None: # intersection failed return None p = EU.Point3(tup[0] * 1.0e3, tup[1] * 1.0e3, tup[2] * 1.0e3) # [mm] interpoints.append(p) ellipse = get_ellipse(interpoints, type) return ellipse
def get_calorimeter_plane(info): type = info[1] # calo type side = info[3] # the tracker side wall = info[6] # the wall # Main Wall if type == 0: # main calo sitting at x = +- 43.5cm if side == 0: calo = EU.Plane(EU.Point3(-435, 0.0, 0.0), EU.Point3(-435, 1.0, 0.0), EU.Point3(-435, 0.0, 1.0)) else: calo = EU.Plane(EU.Point3(435, 0.0, 0.0), EU.Point3(435, 1.0, 0.0), EU.Point3(435, 0.0, 1.0)) # X Wall elif type == 1: # xwall calo sitting at y = +- 250.55cm if wall == 0: calo = EU.Plane(EU.Point3(0.0, -2505.5, 0.0), EU.Point3(1.0, -2505.5, 0.0), EU.Point3(0.0, -2505.5, 1.0)) else: calo = EU.Plane(EU.Point3(0.0, 2505.5, 0.0), EU.Point3(1.0, 2505.5, 0.0), EU.Point3(0.0, 2505.5, 1.0)) # Gamma Veto elif type == 2: # gveto calo sitting at z = +- 155.0cm if wall == 0: calo = EU.Plane(EU.Point3(1.0, 0.0, -1550.0), EU.Point3(0.0, 1.0, -1550.0), EU.Point3(0.0, 0.0, -1550.0)) else: calo = EU.Plane(EU.Point3(1.0, 0.0, 1550.0), EU.Point3(0.0, 1.0, 1550.0), EU.Point3(0.0, 0.0, 1550.0)) return calo
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,