Ejemplo n.º 1
0
 def build_collections_and_history(self, papasevent, sim_particles):  
     #todo this should be integrated into the simulator in the future
     simulated_particles = dict()
     tracks = dict()
     smeared_tracks=dict()
     smeared_hcals = dict()
     true_hcals = dict()
     smeared_ecals = dict()
     true_ecals = dict()    
     smeared_tracks = dict()
     true_tracks = dict()            
     
     history =  papasevent.history
     for ptc in sim_particles:
         uid = ptc.uniqueid
         simulated_particles[uid] = ptc
         history[uid] = Node(uid)
         if ptc.track:
             track_id = ptc.track.uniqueid
             true_tracks[track_id] = ptc.track
             history[track_id] = Node(track_id)
             history[uid].add_child(history[track_id])
             if ptc.track_smeared:
                 smtrack_id = ptc.track_smeared.uniqueid
                 smeared_tracks[smtrack_id] = ptc.track_smeared
                 history[smtrack_id] = Node(smtrack_id)
                 history[track_id].add_child(history[smtrack_id])    
         if len(ptc.clusters) > 0 : 
             for key, clust in ptc.clusters.iteritems():
                 if Identifier.get_type(clust.uniqueid) == Identifier.PFOBJECTTYPE.ECALCLUSTER:
                     true_ecals[clust.uniqueid] = clust                       
                 elif Identifier.get_type(clust.uniqueid) == Identifier.PFOBJECTTYPE.HCALCLUSTER:
                     true_hcals[clust.uniqueid] = clust
                 else:
                     assert(False)                    
                 history[clust.uniqueid] = Node(clust.uniqueid)
                 history[uid].add_child(history[clust.uniqueid])  
 
                 if len(ptc.clusters_smeared) > 0 :  #need to put in link between true and smeared cluster 
                     for key1, smclust in ptc.clusters_smeared.iteritems():
                         if (key == key1): 
                             if Identifier.get_type(smclust.uniqueid) == Identifier.PFOBJECTTYPE.ECALCLUSTER:
                                 smeared_ecals[smclust.uniqueid]=smclust
                             elif Identifier.get_type(smclust.uniqueid) == Identifier.PFOBJECTTYPE.HCALCLUSTER:
                                 smeared_hcals[smclust.uniqueid]=smclust 
                             history[smclust.uniqueid] = Node(smclust.uniqueid)
                             history[clust.uniqueid].add_child(history[smclust.uniqueid])
                         
     papasevent.add_collection(simulated_particles)
     papasevent.add_collection(true_tracks)
     papasevent.add_collection(smeared_tracks)
     papasevent.add_collection(smeared_hcals)
     papasevent.add_collection(true_hcals)
     papasevent.add_collection(smeared_ecals)
     papasevent.add_collection(true_ecals)    
Ejemplo n.º 2
0
 def get_object(self, uniqueid):
     ''' given a uniqueid return the underlying obejct
     '''
     type = Identifier.get_type(uniqueid)
     if type == Identifier.PFOBJECTTYPE.TRACK:
         return self.tracks[uniqueid]       
     elif type == Identifier.PFOBJECTTYPE.ECALCLUSTER:      
         return self.ecal_clusters[uniqueid] 
     elif type == Identifier.PFOBJECTTYPE.HCALCLUSTER:            
         return self.hcal_clusters[uniqueid]            
     elif type == Identifier.PFOBJECTTYPE.PARTICLE:
         return self.sim_particles[uniqueid]   
     elif type == Identifier.PFOBJECTTYPE.RECPARTICLE:
         return self.reconstructed_particles[uniqueid]               
     elif type == Identifier.PFOBJECTTYPE.BLOCK:
         return self.blocks[uniqueid]               
     else:
         assert(False)   
Ejemplo n.º 3
0
 def get_object(self, uniqueid):
     ''' given a uniqueid return the underlying obejct
     '''
     type = Identifier.get_type(uniqueid)
     if type == Identifier.PFOBJECTTYPE.TRACK:
         return self.tracks[uniqueid]       
     elif type == Identifier.PFOBJECTTYPE.ECALCLUSTER:      
         return self.ecal_clusters[uniqueid] 
     elif type == Identifier.PFOBJECTTYPE.HCALCLUSTER:            
         return self.hcal_clusters[uniqueid]            
     elif type == Identifier.PFOBJECTTYPE.PARTICLE:
         return self.sim_particles[uniqueid]   
     elif type == Identifier.PFOBJECTTYPE.RECPARTICLE:
         return self.reconstructed_particles[uniqueid]               
     elif type == Identifier.PFOBJECTTYPE.BLOCK:
         return self.blocks[uniqueid]               
     else:
         assert(False)   
Ejemplo n.º 4
0
 def color(self, node):
     '''used to color dag nodes
     @param node: a node in the DAG history'''
     cols = ["red", "lightblue", "green", "yellow", "cyan", "grey", "white", "pink"]
     return cols[Identifier.get_type(node.get_value())]