コード例 #1
0
ファイル: dagplotter.py プロジェクト: HEP-FCC/heppy
 def _graph_add_topological_block(self, graph, graphnodes, pfblock):
     '''this adds the block links (distance, is_linked) onto the DAG in red'''
     for edge in pfblock.edges.itervalues():
         if  edge.linked: 
             label = "{:.1E}".format(edge.distance)
             if edge.distance == 0:
                 label = "0"
             graph.add_edge(pydot.Edge(graphnodes[IdCoder.pretty(edge.id1)],
                                       graphnodes[IdCoder.pretty(edge.id2)],
                                       label=label, style="dashed", color="red", arrowhead="none", arrowtail="none", fontsize='7'))
コード例 #2
0
ファイル: pfblock.py プロジェクト: HEP-FCC/heppy
    def short_elements_string(self):
        ''' Construct a string description of each of the elements in a block.

        The elements are given a short name E/H/T according to ecal/hcal/track
        and then sequential numbering starting from 0, this naming is also used to index the
        matrix of distances. The full unique id is also given.
        For example:-
        elements: {
        E0:1104134446736:SmearedCluster : ecal_in       0.57  0.33 -2.78
        H1:2203643940048:SmearedCluster : hcal_in       6.78  0.35 -2.86
        T2:3303155568016:SmearedTrack   :    5.23    4.92  0.34 -2.63
        }
        '''

        count = 0
        elemdetails = "    elements:\n"
        for uid in self.element_uniqueids:
            elemdetails += "{shortname:>7}{count} = {strdescrip:9} value={val:5.1f} ({uid})\n".format(
                shortname=IdCoder.type_letter(uid),
                count=count,
                strdescrip=IdCoder.pretty(uid),
                val=IdCoder.get_value(uid),
                uid=uid)
            count = count + 1
        return elemdetails
コード例 #3
0
 def _graph_add_topological_block(self, graph, graphnodes, pfblock):
     '''this adds the block links (distance, is_linked) onto the DAG in red'''
     for edge in pfblock.edges.itervalues():
         if edge.linked:
             label = "{:.1E}".format(edge.distance)
             if edge.distance == 0:
                 label = "0"
             graph.add_edge(
                 pydot.Edge(graphnodes[IdCoder.pretty(edge.id1)],
                            graphnodes[IdCoder.pretty(edge.id2)],
                            label=label,
                            style="dashed",
                            color="red",
                            arrowhead="none",
                            arrowtail="none",
                            fontsize='7'))
コード例 #4
0
ファイル: pfblock.py プロジェクト: efilmer/heppyold
    def short_elements_string(self):
        ''' Construct a string description of each of the elements in a block.

        The elements are given a short name E/H/T according to ecal/hcal/track
        and then sequential numbering starting from 0, this naming is also used to index the
        matrix of distances. The full unique id is also given.
        For example:-
        elements: {
        E0:1104134446736:SmearedCluster : ecal_in       0.57  0.33 -2.78
        H1:2203643940048:SmearedCluster : hcal_in       6.78  0.35 -2.86
        T2:3303155568016:SmearedTrack   :    5.23    4.92  0.34 -2.63
        }
        '''

        count = 0
        elemdetails = "    elements:\n"
        for uid in self.element_uniqueids:
            elemdetails += "{shortname:>7}{count} = {strdescrip:9} value={val:5.1f} ({uid})\n".format(
                shortname=IdCoder.type_letter(uid),
                count=count,
                strdescrip=IdCoder.pretty(uid),
                val=IdCoder.get_value(uid),
                uid=uid)
            count = count + 1
        return elemdetails
コード例 #5
0
 def id_from_pretty(self, pretty):
     ''' Searches to find the true id given a pretty id string
         Not super efficient but OK for occasional use
         eg uid = self.id_from_pretty('et103')
         @param: pretty is the easily readable name from the Identifier class which is shown in prints and plots eg 'et103'
     '''
     for uid in self.history.keys():
         if IdCoder.pretty(uid) == pretty:
             return uid
     return None
コード例 #6
0
 def info(self):
     subclusterstr = str('sub(')
     for s in self.subclusters:
         subclusterstr += str('{:}, '.format(IdCoder.pretty(s.uniqueid)))
     subclusterstr += ")"
     return '{energy:7.2f} {theta:5.2f} {phi:5.2f} {sub}'.format(
         energy=self.energy,
         theta=math.pi / 2. - self.position.Theta(),
         phi=self.position.Phi(),
         sub=subclusterstr)
コード例 #7
0
ファイル: historyhelper.py プロジェクト: HEP-FCC/heppy
 def id_from_pretty(self, pretty):
     ''' Searches to find the true id given a pretty id string
         Not super efficient but OK for occasional use
         eg uid = self.id_from_pretty('et103')
         @param: pretty is the easily readable name from the Identifier class which is shown in prints and plots eg 'et103'
     '''
     for uid in self.history.keys():
         if IdCoder.pretty(uid) == pretty:
             return uid
     return None
コード例 #8
0
ファイル: pfobjects.py プロジェクト: HEP-FCC/heppy
 def info(self):
     subclusterstr = str('sub(')
     for s in self.subclusters:
         subclusterstr += str('{:}, '.format(IdCoder.pretty(s.uniqueid)))
     subclusterstr += ")"
     return '{energy:7.2f} {theta:5.2f} {phi:5.2f} {sub}'.format(
         energy=self.energy,
         theta=math.pi/2. - self.position.Theta(),
         phi=self.position.Phi(),
         sub=subclusterstr
     )
コード例 #9
0
ファイル: pfblock.py プロジェクト: HEP-FCC/heppy
 def __repr__(self):
     ''' Short Block description
     '''
     description = "block:"
     description += str('{shortname:8} :{prettyid:6}: ecals = {count_ecal} hcals = {count_hcal} tracks = {count_tracks}'.format(
         shortname=self.short_info(),
         prettyid=IdCoder.pretty(self.uniqueid),
         count_ecal=self.count_ecal(),
         count_hcal=self.count_hcal(),
         count_tracks=self.count_tracks())
                       )
     return description
コード例 #10
0
ファイル: pfblock.py プロジェクト: efilmer/heppyold
 def __repr__(self):
     ''' Short Block description
     '''
     description = "block:"
     description += str(
         '{shortname:8} :{prettyid:6}: ecals = {count_ecal} hcals = {count_hcal} tracks = {count_tracks}'
         .format(shortname=self.short_info(),
                 prettyid=IdCoder.pretty(self.uniqueid),
                 count_ecal=self.count_ecal(),
                 count_hcal=self.count_hcal(),
                 count_tracks=self.count_tracks()))
     return description
コード例 #11
0
    def test_papasevent(self):
        papasevent = PapasEvent(0)
        ecals = dict()
        tracks = dict()
        mixed = dict()

        for i in range(0, 2):
            uid = IdCoder.make_id(IdCoder.PFOBJECTTYPE.ECALCLUSTER, i, 't',
                                  4.5)
            ecals[uid] = uid
        for i in range(0, 2):
            uid = IdCoder.make_id(IdCoder.PFOBJECTTYPE.TRACK, i, 's', 4.5)
            tracks[uid] = uid

        lastid = IdCoder.make_id(IdCoder.PFOBJECTTYPE.ECALCLUSTER, 3, 't', 3)
        ecals[lastid] = lastid

        papasevent.add_collection(ecals)
        papasevent.add_collection(tracks)

        #check that adding the same collection twice fails
        self.assertRaises(ValueError, papasevent.add_collection, ecals)

        #check that adding a mixed collection fails
        mixed = ecals.copy()
        mixed.update(tracks)
        self.assertRaises(ValueError, papasevent.add_collection, mixed)

        #get we can get back collections OK
        self.assertTrue(len(
            papasevent.get_collection('zz')) == 0)  # this one does not exist
        self.assertTrue(len(papasevent.get_collection('et')) == 3)

        #check get_object
        self.assertTrue(IdCoder.pretty(papasevent.get_object(lastid)) == 'et3')
        self.assertTrue(papasevent.get_object(499) is None)
コード例 #12
0
ファイル: pfobjects.py プロジェクト: HEP-FCC/heppy
 def __str__(self):
     return '{classname}: {pretty:6}:{uid}: {info}'.format(
         classname=self.__class__.__name__,
         pretty=IdCoder.pretty(self.uniqueid),
         uid=self.uniqueid,
         info=self.info())
コード例 #13
0
ファイル: dagplotter.py プロジェクト: HEP-FCC/heppy
 def short_info(self, node):
     '''used to label plotted dag nodes
     @param node: a node in the DAG history'''
     obj = self.object(node)
     return IdCoder.pretty(obj.uniqueid) + "\n " +obj.short_info()        
コード例 #14
0
 def short_info(self, node):
     '''used to label plotted dag nodes
     @param node: a node in the DAG history'''
     obj = self.object(node)
     return IdCoder.pretty(obj.uniqueid) + "\n " + obj.short_info()
コード例 #15
0
 def pretty(self, node):
     ''' pretty form of the unique identifier
     @param node: a node in the DAG history'''
     return IdCoder.pretty(node.get_value())
コード例 #16
0
ファイル: dagplotter.py プロジェクト: HEP-FCC/heppy
 def pretty(self, node):
     ''' pretty form of the unique identifier
     @param node: a node in the DAG history'''
     return IdCoder.pretty(node.get_value())
コード例 #17
0
 def __str__(self):
     return '{classname}: {pretty:6}:{uid}: {info}'.format(
         classname=self.__class__.__name__,
         pretty=IdCoder.pretty(self.uniqueid),
         uid=self.uniqueid,
         info=self.info())