def displayTriggerCells(self, event, tcs): for zside in tcs.zside.unique(): if zside > 0: continue zside_tcs = tcs[tcs.zside == zside] for subdet in zside_tcs.subdet.unique(): if subdet != 3: continue subdet_tcs = zside_tcs[zside_tcs.subdet == subdet] for layer in subdet_tcs.layer.unique(): layer_tcs = subdet_tcs[subdet_tcs.layer == layer] figure = self.getFigure(event, zside, subdet, layer) all_corners_x = [] all_corners_y = [] all_energies = [] all_tc_ids = [] for index in layer_tcs.index: tc = layer_tcs.loc[index] cells = self.cell_geom[self.cell_geom.tc_id == tc.id] corners_x = [] corners_y = [] for cell_idx, cell in cells.iterrows(): corners_x.append([ cell.x1, cell.x2, cell.x2 - cell.width * 0.5, cell.x3, cell.x4, cell.x4 + cell.width * 0.5 ]) corners_y.append([ cell.y1, cell.y2, cell.y2 + cell.delta, cell.y3, cell.y4, cell.y4 - cell.delta ]) cell_energies = [tc.energy] * len(cells.index) cell_tcids = [tc.id] * len(cells.index) #print cell_energies #print cell_tcids all_corners_x.extend(corners_x) all_corners_y.extend(corners_y) all_energies.extend(cell_energies) all_tc_ids.extend(cell_tcids) source = ColumnDataSource(data=dict( x=all_corners_x, y=all_corners_y, id=all_tc_ids, energy=all_energies, )) figure.patches('x', 'y', source=source, fill_color={ 'field': 'energy', 'transform': self.color_mapper }, fill_alpha=0.7, line_color="black", line_width=0.1) #for tc in tcs: return
def displayCells(self, event, cells): debugPrintOut(4, 'cells', toCount=cells, toPrint=cells[['id', 'cell']]) for zside in cells.zside.unique(): if zside > 0: continue cells_zside = cells[cells.zside == zside] for subdet in cells_zside.subdet.unique(): if subdet != 3: continue cells_subdet = cells_zside[cells_zside.subdet == subdet] for layer in cells_subdet.layer.unique(): cells_layer = cells_subdet[cells_subdet.layer == layer] figure = self.getFigure(event, zside, subdet, layer) all_corners_x = [] all_corners_y = [] all_cells_ids = [] all_cells_colors = [] debugPrintOut(4, 'cells_layer', toCount=cells_layer, toPrint=cells_layer[['id', 'cell']]) count = 0 for index, cell in cells_layer.iterrows(): count += 1 print '{} {} {}'.format(index, cell.cell, long(cell.id)) # WTF all_corners_x.append([ cell.x1, cell.x2, cell.x2 - cell.width * 0.5, cell.x3, cell.x4, cell.x4 + cell.width * 0.5 ]) all_corners_y.append([ cell.y1, cell.y2, cell.y2 + cell.delta, cell.y3, cell.y4, cell.y4 - cell.delta ]) all_cells_ids.append(int(cell.id)) all_cells_colors.append(cell.color) print count source = ColumnDataSource( data=dict(x=all_corners_x, y=all_corners_y, id=all_cells_ids, color=all_cells_colors)) figure.patches('x', 'y', source=source, fill_color={ 'field': 'color', 'transform': self.color_mapper }, fill_alpha=0.7, line_color="black", line_width=0.1)
def displayCells(self, event, cells): debugPrintOut(4, 'cells', toCount=cells, toPrint=cells.loc[:3]) for zside in cells.zside.unique(): if zside > 0: continue cells_zside = cells[cells.zside == zside] for subdet in cells_zside.subdet.unique(): if subdet != 3: continue cells_subdet = cells_zside[cells_zside.subdet == subdet] for layer in cells_subdet.layer.unique(): cells_layer = cells_subdet[cells_subdet.layer == layer] figure = self.getFigure(event, zside, subdet, layer) all_corners_x = [] all_corners_y = [] all_cells_ids = [] for cell_idx in cells_layer.index: cell = cells.loc[cell_idx] all_corners_x.append([ cell.x1, cell.x2, cell.x2 - cell.width * 0.5, cell.x3, cell.x4, cell.x4 + cell.width * 0.5 ]) all_corners_y.append([ cell.y1, cell.y2, cell.y2 + cell.delta, cell.y3, cell.y4, cell.y4 - cell.delta ]) all_cells_ids.append(cell.id) print len(all_corners_x) print len(all_corners_y) print len(all_cells_ids) source = ColumnDataSource(data=dict( x=all_corners_x, y=all_corners_y, id=all_cells_ids, )) figure.patches('x', 'y', source=source, fill_color={ 'field': 'id', 'transform': self.color_mapper }, fill_alpha=0.7, line_color="black", line_width=0.1)
def displayTowers(self, event, zside, subdet, layer, grid): all_corners_x = [] all_corners_y = [] figure = self.getFigure(event, zside, subdet, layer) print grid.nbins_x print grid.nbins_y for idx_x in range(0, grid.nbins_x): for idx_y in range(0, grid.nbins_y): corners = grid.getCorners(idx_x, idx_y) all_corners_x.append([corner.x for corner in corners]) all_corners_y.append([corner.y for corner in corners]) source = ColumnDataSource(data=dict( x=all_corners_x, y=all_corners_y, )) figure.patches('x', 'y', source=source, fill_color=None, fill_alpha=0.7, line_color="black", line_width=0.1) return
def displayClusters(self, event, cl2ds, tcs): # print cl2ds for zside in [-1, 1]: if zside > 0: continue zside_cl2ds = cl2ds[cl2ds.eta * zside > 0] for subdet in zside_cl2ds.subdet.unique(): if subdet != 3: continue subdet_cl2ds = zside_cl2ds[zside_cl2ds.subdet == subdet] for layer in subdet_cl2ds.layer.unique(): layer_cl2ds = subdet_cl2ds[subdet_cl2ds.layer == layer] figure = self.getFigure(event, zside, subdet, layer) clus_ids = [ str(clid) for clid in layer_cl2ds.sort_values( by=['pt'], ascending=False).id.values ] all_corners_x = [] all_corners_y = [] all_energies = [] all_tc_ids = [] all_clus_ids = [] print '======= layer: {}, # of 2D clusters: {}'.format( layer, len(layer_cl2ds.index)) for idx in layer_cl2ds.sort_values(by=['pt'], ascending=False).index: # print '-------- CL2D ------------' cl2d = layer_cl2ds.loc[idx] print cl2d.pt components = tcs[tcs.id.isin(cl2d.cells)] # print '# of TCS: {}'.format(len(components.index)) for tc_idx in components.index: tc = components.loc[tc_idx] cells = self.cell_geom[self.cell_geom.tc_id == tc.id] # print '# of cells: {}'.format(len(cells.index)) # corners_x = [] # corners_y = [] # cell_energies = [] # cell_tcids = [] #clus_id = cl2d.id*len(components.index) for cell_idx in cells.index: cell = cells.loc[cell_idx] all_corners_x.append([ cell.x1, cell.x2, cell.x2 - cell.width * 0.5, cell.x3, cell.x4, cell.x4 + cell.width * 0.5 ]) all_corners_y.append([ cell.y1, cell.y2, cell.y2 + cell.delta, cell.y3, cell.y4, cell.y4 - cell.delta ]) all_energies.append(tc.energy) all_tc_ids.append(tc.id) all_clus_ids.append(str(cl2d.id)) #print cell_energies #print cell_tcids # all_corners_x.extend(corners_x) # all_corners_y.extend(corners_y) # all_energies.extend(cell_energies) # all_tc_ids.extend(cell_tcids) # print len(all_corners_x) # print len(all_corners_y) # print len(all_energies) # print len(all_tc_ids) print '# of 2D cluster in layer {}'.format( len(all_clus_ids)) # print all_clus_ids source = ColumnDataSource(data=dict(x=all_corners_x, y=all_corners_y, energy=all_energies, id=all_tc_ids, cl_id=all_clus_ids)) # print clus_ids figure.patches( 'x', 'y', source=source, fill_color=None, fill_alpha=0.7, # line_color={'field': 'energy', 'transform': self.color_mapper}, line_color=factor_cmap('cl_id', palette=Plasma256, factors=clus_ids), line_width=3., # legend=clus_ids ) return