def drawObjects(self, view_manager): geom = view_manager._geometry for view in view_manager.getViewPorts(): colorIndex = 0 # get the plane thisPlane = view.plane() # extend the list of clusters self._listOfClusters.append([]) clusters = self._process.getDataByPlane(thisPlane) for i in xrange(len(clusters)): cluster = clusters[i] # Now make the cluster cluster_box_coll = boxCollection() cluster_box_coll.setColor(self._clusterColors[colorIndex]) cluster_box_coll.setPlane(thisPlane) # Keep track of the cluster for drawing management self._listOfClusters[thisPlane].append(cluster_box_coll) # draw the hits in this cluster: cluster_box_coll.drawHits(view, cluster, geom) colorIndex += 1 if colorIndex >= len(self._clusterColors): colorIndex = 0
def drawObjects(self, view_manager): for view in view_manager.getViewPorts(): colorIndex = 0 # get the plane thisPlane = view.plane() # extend the list of clusters self._listOfClusters.append([]) self._listOfCParams.append([]) clusters = self._process.getDataByPlane(thisPlane) for i in xrange(len(clusters)): cluster = clusters[i] # Now make the cluster cluster_box_coll = boxCollection() cluster_box_coll.setColor(self._clusterColors[colorIndex]) cluster_box_coll.setPlane(thisPlane) # Keep track of the cluster for drawing management self._listOfClusters[thisPlane].append(cluster_box_coll) self._listOfCParams[thisPlane].append(None) # draw the hits in this cluster: cluster_box_coll.drawHits(view, cluster) colorIndex += 1 if colorIndex >= len(self._clusterColors): colorIndex = 0 if self._drawParams: if cluster.params().N_Hits > 10: cParams = clusterParams( cluster.params(), view_manager._geometry) self._listOfCParams[thisPlane][-1] = cParams cluster_box_coll.attachParams(cParams) self._listOfCParams[thisPlane][-1].draw(view) # Connect the cluster to the params: self._listOfClusters[ thisPlane][-1].connect(self._listOfCParams[thisPlane][-1]) # Connect the params to the cluster: self._listOfCParams[ thisPlane][-1].connect(self._listOfClusters[thisPlane][-1])
def drawObjects(self, view_manager): for view in view_manager.getViewPorts(): colorIndex = 0 # get the plane thisPlane = view.plane() # extend the list of clusters self._listOfClusters.append([]) self._listOfCParams.append([]) matchedClusters = self._process.getDataByPlane(thisPlane) for i in xrange(len(matchedClusters)): cluster = matchedClusters[i] # Check that this match is good if not cluster.is_good(): self._listOfClusters[thisPlane].append(None) self._listOfCParams[thisPlane].append(None) colorIndex += 1 if colorIndex >= len(self._matchColors): colorIndex = 0 continue # If the match is good, make the cluster and such # Now make the cluster cluster_box_coll = boxCollection() cluster_box_coll.setColor(self._matchColors[colorIndex]) cluster_box_coll.setPlane(thisPlane) # Keep track of the cluster for drawing management self._listOfClusters[thisPlane].append(cluster_box_coll) self._listOfCParams[thisPlane].append(None) # draw the hits in this cluster: cluster_box_coll.drawHits(view, cluster) colorIndex += 1 if colorIndex >= len(self._matchColors): colorIndex = 0 if self._drawParams: if cluster.params().N_Hits > 10: cParams = clusterParams( cluster.params(), view_manager._geometry) self._listOfCParams[thisPlane][-1] = cParams cluster_box_coll.attachParams(cParams) self._listOfCParams[thisPlane][-1].draw(view) # Connect the cluster to the params: self._listOfClusters[thisPlane][-1].connect( self._listOfCParams[thisPlane][-1] ) # Connect the params to the cluster: self._listOfCParams[thisPlane][-1].connect( self._listOfClusters[thisPlane][-1] ) # Now, connect all the clusters across the planes to make the highlights match: # Check that the vectors are the same across all planes first for plane in xrange(len(self._listOfClusters)): if len(self._listOfClusters[plane]) != len(self._listOfClusters[0]): print("ERROR: matched cluster sizes don't match") exit(-1) # At this point, we've confirmed that everything is at least the same size # So go through and try to connect everything for plane in xrange(len(self._listOfClusters)): for i_cluster in xrange(len(self._listOfClusters[plane])): if self._listOfClusters[plane][i_cluster] != None: # In this case, connect to the other clusters. otherPlanes = range(len(self._listOfClusters)) otherPlanes.remove(plane) for otherPlane in otherPlanes: if self._listOfClusters[otherPlane][i_cluster] != None: self._listOfClusters[plane][i_cluster].connect( self._listOfClusters[otherPlane][i_cluster])
def drawObjects(self, view_manager): for view in view_manager.getViewPorts(): colorIndex = 0 # get the plane thisPlane = view.plane() # extend the list of clusters self._listOfClusters.append([]) self._listOfCParams.append([]) matchedClusters = self._process.getDataByPlane(thisPlane) for i in xrange(len(matchedClusters)): cluster = matchedClusters[i] # Check that this match is good if not cluster.is_good(): self._listOfClusters[thisPlane].append(None) self._listOfCParams[thisPlane].append(None) colorIndex += 1 if colorIndex >= len(self._matchColors): colorIndex = 0 continue # If the match is good, make the cluster and such # Now make the cluster cluster_box_coll = boxCollection() cluster_box_coll.setColor(self._matchColors[colorIndex]) cluster_box_coll.setPlane(thisPlane) # Keep track of the cluster for drawing management self._listOfClusters[thisPlane].append(cluster_box_coll) self._listOfCParams[thisPlane].append(None) # draw the hits in this cluster: cluster_box_coll.drawHits(view, cluster) colorIndex += 1 if colorIndex >= len(self._matchColors): colorIndex = 0 if self._drawParams: if cluster.params().N_Hits > 10: cParams = clusterParams(cluster.params(), view_manager._geometry) self._listOfCParams[thisPlane][-1] = cParams cluster_box_coll.attachParams(cParams) self._listOfCParams[thisPlane][-1].draw(view) # Connect the cluster to the params: self._listOfClusters[thisPlane][-1].connect( self._listOfCParams[thisPlane][-1]) # Connect the params to the cluster: self._listOfCParams[thisPlane][-1].connect( self._listOfClusters[thisPlane][-1]) # Now, connect all the clusters across the planes to make the highlights match: # Check that the vectors are the same across all planes first for plane in xrange(len(self._listOfClusters)): if len(self._listOfClusters[plane]) != len( self._listOfClusters[0]): print("ERROR: matched cluster sizes don't match") exit(-1) # At this point, we've confirmed that everything is at least the same size # So go through and try to connect everything for plane in xrange(len(self._listOfClusters)): for i_cluster in xrange(len(self._listOfClusters[plane])): if self._listOfClusters[plane][i_cluster] != None: # In this case, connect to the other clusters. otherPlanes = range(len(self._listOfClusters)) otherPlanes.remove(plane) for otherPlane in otherPlanes: if self._listOfClusters[otherPlane][i_cluster] != None: self._listOfClusters[plane][i_cluster].connect( self._listOfClusters[otherPlane][i_cluster])
def drawObjects(self, view_manager): # clear any clusters that may be present for view in view_manager.getViewPorts(): plane = view.plane() clusters = self._clusters[plane] for cluster in clusters: cluster.clearHits(view) # Showers can get messed up so only draw "good" showers # This means that if either projection is bad, don't draw that shower for view in view_manager.getViewPorts(): # get the showers from the process: self._drawnObjects.append([]) showers = self._process.getDataByPlane(view.plane()) i_color = 0 for i in xrange(len(showers)): shower = showers[i] if i_color >= len(self._showerColors): i_color = 0 color = self._showerColors[i_color] # construct a polygon for this shower: points = [] # Remember - everything is in cm, but the display is in # wire/time! geom = view_manager._geometry offset = geom.offset(view.plane()) / geom.time2cm() x = shower.startPoint().w / geom.wire2cm() y = shower.startPoint().t / geom.time2cm() + offset points.append(QtCore.QPoint(x, y)) # next connect the two points at the end of the shower to make # a cone # # We need the vector that's perpendicular to the axis, to make the cone. # Use 3D vectors to allow the cross product: zAxis = TVector3(0, 0, 1) showerAxis = TVector3( shower.endPoint().w - shower.startPoint().w, shower.endPoint().t - shower.startPoint().t, 0.0) perpAxis = zAxis.Cross(showerAxis) length = showerAxis.Mag() * mt.tan(shower.openingAngle() / 2) perpAxis *= length / perpAxis.Mag() x1, y1 = shower.endPoint().w + perpAxis.X(), shower.endPoint().t + \ perpAxis.Y() x2, y2 = shower.endPoint().w - perpAxis.X(), shower.endPoint().t - \ perpAxis.Y() # Scale everything to wire/time: x1 /= geom.wire2cm() y1 /= geom.time2cm() x2 /= geom.wire2cm() y2 /= geom.time2cm() y1 += offset y2 += offset points.append(QtCore.QPoint(x1, y1)) points.append(QtCore.QPoint(x2, y2)) thisPolyF = QtGui.QPolygonF(points) self.shower_poly = QtGui.QGraphicsPolygonItem(thisPolyF) self.shower_poly = shower_polygon(thisPolyF) #thisPoly = QtGui.QGraphicsPolygonItem(thisPolyF) self.shower_poly._energy = shower.energy() self.shower_poly._dedx = shower.dedx() self.shower_poly.setPen(pg.mkPen(None)) self.shower_poly.setBrush(pg.mkColor(color)) # hovering stuff #self.shower_poly.connectOwnerHoverEnter(self.shower_poly.hoverEnter) #self.shower_poly.connectOwnerHoverExit (self.shower_poly.hoverExit) #self.shower_poly.connectToggleHighlight(self.shower_poly.toggleHighlight) # self.shower_poly.connectToolTip(self.shower_poly.genToolTip) #self.shower_poly.connectOwnerHoverEnter(self.shower_poly._ownerHoverEnter) #self.shower_poly.connectOwnerHoverExit(self.shower_poly._ownerHoverExit) #self.shower_poly.connectToolTip(self.shower_poly.genToolTip) view._view.addItem(self.shower_poly) self._drawnObjects[view.plane()].append(self.shower_poly) # if view.plane() == 0: # print "dedx: ", shower.dedx() # now add cluster too plane = view.plane() cluster = shower._showerCluster_v[plane] self._clusters[plane].append(boxCollection()) self._clusters[plane][-1].setColor(color) self._clusters[plane][-1].setPlane(plane) self._clusters[plane][-1].drawHits(view, cluster, geom) i_color += 1
def drawObjects(self, view_manager): # clear any clusters that may be present for view in view_manager.getViewPorts(): plane = view.plane() clusters = self._clusters[plane] for cluster in clusters: cluster.clearHits(view) # Showers can get messed up so only draw "good" showers # This means that if either projection is bad, don't draw that shower for view in view_manager.getViewPorts(): # get the showers from the process: self._drawnObjects.append([]) showers = self._process.getDataByPlane(view.plane()) i_color = 0 for i in xrange(len(showers)): shower = showers[i] if i_color > len(self._showerColors): i_color = 0 color = self._showerColors[i_color] # construct a polygon for this shower: points = [] # Remember - everything is in cm, but the display is in # wire/time! geom = view_manager._geometry offset = geom.offset(view.plane()) / geom.time2cm() x = shower.startPoint().w / geom.wire2cm() y = shower.startPoint().t / geom.time2cm() + offset points.append(QtCore.QPoint(x, y)) # next connect the two points at the end of the shower to make # a cone # # We need the vector that's perpendicular to the axis, to make the cone. # Use 3D vectors to allow the cross product: zAxis = TVector3(0, 0, 1) showerAxis = TVector3(shower.endPoint().w - shower.startPoint().w, shower.endPoint().t - shower.startPoint().t, 0.0) perpAxis = zAxis.Cross(showerAxis) length = showerAxis.Mag() * mt.tan(shower.openingAngle()/2) perpAxis *= length / perpAxis.Mag() x1, y1 = shower.endPoint().w + perpAxis.X(), shower.endPoint().t + \ perpAxis.Y() x2, y2 = shower.endPoint().w - perpAxis.X(), shower.endPoint().t - \ perpAxis.Y() # Scale everything to wire/time: x1 /= geom.wire2cm() y1 /= geom.time2cm() x2 /= geom.wire2cm() y2 /= geom.time2cm() y1 += offset y2 += offset points.append(QtCore.QPoint(x1, y1)) points.append(QtCore.QPoint(x2, y2)) thisPolyF = QtGui.QPolygonF(points) self.shower_poly = QtGui.QGraphicsPolygonItem( thisPolyF ) self.shower_poly = shower_polygon( thisPolyF ) #thisPoly = QtGui.QGraphicsPolygonItem(thisPolyF) self.shower_poly.setPen(pg.mkPen(None)) self.shower_poly.setBrush(pg.mkColor(color)) self.shower_poly.passlarliteshower(shower) # hovering stuff #self.shower_poly.connectOwnerHoverEnter(self.shower_poly.hoverEnter) #self.shower_poly.connectOwnerHoverExit (self.shower_poly.hoverExit) #self.shower_poly.connectToggleHighlight(self.shower_poly.toggleHighlight) self.shower_poly.connectToolTip(self.shower_poly.genToolTip) view._view.addItem(self.shower_poly) self._drawnObjects[view.plane()].append(self.shower_poly) # if view.plane() == 0: # print "dedx: ", shower.dedx() # are there hits associated? if so draw if (shower._hits.size() > 0): plane = view.plane() cluster = shower._hits self._clusters[plane].append( boxCollection() ) self._clusters[plane][-1].setColor( color ) self._clusters[plane][-1].setPlane( plane ) self._clusters[plane][-1].drawHits( view, cluster ) i_color += 1
def drawObjects(self, view_manager): geom = view_manager._geometry for view in view_manager.getViewPorts(): # extend the list of clusters self._listOfClusters.append([]) # # get the showers from the process: self._drawnObjects.append([]) nu_v = self._process.getDataByPlane(view.plane()) print 'looking at neutrinos!' for nu in nu_v: offset = geom.offset(view.plane()) / geom.time2cm() #print 'found %i extra tracks'%(nu._trk_v.size()) for trk in nu._trk_v: points = [] # Remeber - everything is in cm, but the display is in # wire/time! for pair in trk.track(): x = pair.first / geom.wire2cm() y = pair.second / geom.time2cm() + offset points.append(QtCore.QPointF(x, y)) thisPoly = polyLine(points) pen = pg.mkPen((255, 127, 36), width=4) thisPoly.setPen(pen) view._view.addItem(thisPoly) self._drawnObjects[view.plane()].append(thisPoly) # draw track muon = nu._muon # construct a polygon for this track: points = [] # Remeber - everything is in cm, but the display is in # wire/time! for pair in muon.track(): x = pair.first / geom.wire2cm() y = pair.second / geom.time2cm() + offset points.append(QtCore.QPointF(x, y)) # self._drawnObjects[view.plane()].append(thisPoly) thisPoly = polyLine(points) pen = pg.mkPen((255,0,0), width=4) thisPoly.setPen(pen) # polyLine.draw(view._view) view._view.addItem(thisPoly) self._drawnObjects[view.plane()].append(thisPoly) # add vertex vertex = nu._vtx # Draws a circle at (x,y,radius = 0.5cm) radBigW = 0.5 / view_manager._geometry.wire2cm() radBigT = (0.5) / view_manager._geometry.time2cm() offset = view_manager._geometry.offset( view.plane()) / view_manager._geometry.time2cm() sW = vertex.w / view_manager._geometry.wire2cm() sT = vertex.t / view_manager._geometry.time2cm() + offset r = QtGui.QGraphicsEllipseItem( sW-radBigW, sT-radBigT, 2*radBigW, 2*radBigT) r.setPen(pg.mkPen(None)) r.setBrush(pg.mkColor(255,0,0)) self._drawnObjects[view.plane()].append(r) view._view.addItem(r) # draw clusters for shower-like pfparticls clusters = nu._clus_v print 'there are %i clusters to be drawn'%(clusters.size()) for i in xrange(len(clusters)): cluster = clusters[i] # Now make the cluster cluster_box_coll = boxCollection() cluster_box_coll.setColor( (0,0,255) ) cluster_box_coll.setPlane(view.plane()) # draw the hits in this cluster: cluster_box_coll.drawHits(view, cluster) # Keep track of the cluster for drawing management self._listOfClusters[view.plane()].append(cluster_box_coll)