def summary_of_linked_elems(self, id): #find everything that is linked to this id #and write a summary of what is found #the BFS search returns a list of the ids that are connected to the id of interest BFS = BreadthFirstSearchIterative(self.history_nodes[id], "undirected") #collate the string descriptions track_descrips = [] ecal_descrips = [] hcal_descrips = [] #sim_particle_descrips = [] rec_particle_descrips = [] block_descrips = [] for n in BFS.result : z = n.get_value() obj = self.pfevent.get_object(z) descrip = obj.__str__() # if (Identifier.is_particle(z)): # sim_particle_descrips.append(descrip) if (Identifier.is_block(z)): block_descrips.append(descrip) elif (Identifier.is_track(z)): track_descrips.append(descrip) elif (Identifier.is_ecal(z)): ecal_descrips.append(descrip) elif (Identifier.is_hcal(z)): hcal_descrips.append(descrip) elif (Identifier.is_rec_particle(z)): rec_particle_descrips.append(descrip) print "history connected to node:", id print "block", block_descrips print " tracks", track_descrips print " ecals", ecal_descrips print " hcals", hcal_descrips print "rec particles", rec_particle_descrips
def summary_of_linked_elems(self, id): # find everything that is linked to this id # and write a summary of what is found # the BFS search returns a list of the ids that are connected to the id of interest BFS = BreadthFirstSearchIterative(self.history_nodes[id], "undirected") # collate the string descriptions track_descrips = [] ecal_descrips = [] hcal_descrips = [] # sim_particle_descrips = [] rec_particle_descrips = [] block_descrips = [] for n in BFS.result: z = n.get_value() obj = self.pfevent.get_object(z) descrip = obj.__str__() # if (Identifier.is_particle(z)): # sim_particle_descrips.append(descrip) if Identifier.is_block(z): block_descrips.append(descrip) elif Identifier.is_track(z): track_descrips.append(descrip) elif Identifier.is_ecal(z): ecal_descrips.append(descrip) elif Identifier.is_hcal(z): hcal_descrips.append(descrip) elif Identifier.is_rec_particle(z): rec_particle_descrips.append(descrip) print "history connected to node:", id print "block", block_descrips print " tracks", track_descrips print " ecals", ecal_descrips print " hcals", hcal_descrips print "rec particles", rec_particle_descrips
def test_1(self): event = Event(distance) sim = Simulator(event) event=sim.event pfblocker = PFBlockBuilder( event, distance, event.history_nodes) event.blocks = pfblocker.blocks #event.history_nodes = pfblocker.history_nodes ##test block splitting #blockids = [] #unlink=[] #for b in event.blocks.itervalues(): #ids=b.element_uniqueids #if len(ids)==3 : #print ids[0], ids[2] #unlink.append(b.edges[Edge.make_key(ids[0], ids[2])]) #unlink.append(b.edges[Edge.make_key(ids[0], ids[1])]) #print unlink #splitter=BlockSplitter(b,unlink,event.history_nodes) #print splitter.blocks #blocksplitter=BlockSplitter() rec = Reconstructor(event) # What is connected to HCAL 202 node? # (1) via history_nodes # (2) via reconstructed node links # (3) Give me all blocks with one track: # (4) Give me all simulation particles attached to each reconstructed particle nodeid = 202 nodeuid = sim.UID(nodeid) #(1) what is connected to the the HCAL CLUSTER ids = [] BFS = BreadthFirstSearchIterative(event.history_nodes[nodeuid],"undirected") for n in BFS.result : ids.append(n.get_value()) #1b WHAT BLOCK Does it belong to x = None for id in ids: if Identifier.is_block(id) and event.blocks[id].short_name()== "E1H1T1": x = event.blocks[id] #1c #check that the block contains the expected list of suspects pids = [] for n in x.element_uniqueids: pids.append(n) ids = sorted(pids) expected_ids = sorted([sim.UID(2), sim.UID(102),sim.UID(202)]) self.assertEqual(ids,expected_ids ) #(2) use edge nodes to see what is connected ids = [] BFS = BreadthFirstSearchIterative(pfblocker.nodes[nodeuid],"undirected") for n in BFS.result : ids.append(n.get_value()) expected_ids = sorted([sim.UID(2), sim.UID(102),sim.UID(202)]) self.assertEqual(sorted(ids), expected_ids) #(3) Give me all simulation particles attached to each reconstructed particle for rp in event.reconstructed_particles : ids=[] BFS = BreadthFirstSearchIterative(event.history_nodes[rp],"parents") for n in BFS.result : z=n.get_value()
def test_1(self): Identifier.reset() event = Event(distance) sim = Simulator(event) event = sim.event pfblocker = PFBlockBuilder(event, event.history.keys(), distance) event.blocks = pfblocker.blocks #event.history = pfblocker.history ##test block splitting #blockids = [] #unlink=[] #for b in event.blocks.itervalues(): #ids=b.element_uniqueids #if len(ids)==3 : #print ids[0], ids[2] #unlink.append(b.edges[Edge.make_key(ids[0], ids[2])]) #unlink.append(b.edges[Edge.make_key(ids[0], ids[1])]) #print unlink #splitter=BlockSplitter(b,unlink,event.history) #print splitter.blocks #blocksplitter=BlockSplitter() rec = Reconstructor(event) # What is connected to HCAL 202 node? # (1) via history_nodes # (2) via reconstructed node links # (3) Give me all blocks with one track: # (4) Give me all simulation particles attached to each reconstructed particle nodeid = 202 nodeuid = sim.UID(nodeid) #(1) what is connected to the the HCAL CLUSTER ids = [] BFS = BreadthFirstSearchIterative(event.history[nodeuid], "undirected") for n in BFS.result: ids.append(n.get_value()) #1b WHAT BLOCK Does it belong to x = None for uid in ids: if Identifier.is_block( uid) and event.blocks[uid].short_info() == "E1H1T1": x = event.blocks[uid] #1c #check that the block contains the expected list of suspects pids = [] for n in x.element_uniqueids: pids.append(n) ids = sorted(pids) expected_ids = sorted( [sim.UID(2), sim.UID(102), sim.UID(202), sim.UID(302)]) self.assertEqual(ids, expected_ids) #(2) use edge nodes to see what is connected ids = [] BFS = BreadthFirstSearchIterative(pfblocker.nodes[nodeuid], "undirected") for n in BFS.result: ids.append(n.get_value()) expected_ids = sorted( [sim.UID(2), sim.UID(102), sim.UID(202), sim.UID(302)]) self.assertEqual(sorted(ids), expected_ids) #(3) Give me all simulation particles attached to each reconstructed particle for rp in event.reconstructed_particles: ids = [] BFS = BreadthFirstSearchIterative(event.history[rp], "parents") for n in BFS.result: z = n.get_value()