Пример #1
0
    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=Identifier.type_letter(uid),
                count=count,
                strdescrip=Identifier.pretty(uid),
                val=Identifier.get_value(uid),
                uid=uid)
            count = count + 1
        return elemdetails
Пример #2
0
    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=Identifier.type_letter(uid),
                count=count,
                strdescrip=Identifier.pretty(uid),
                val=Identifier.get_value(uid),
                uid=uid)
            count = count + 1
        return elemdetails
Пример #3
0
    def __init__(self, element_ids, edges, index, subtype): 
        ''' 
            @param element_ids:  list of the uniqueids of the elements to go in this block [id1,id2,...]
            @param edges: is a dictionary of edges, it must contain at least all needed edges.
                   It is not a problem if it contains
                   additional edges as only the ones needed will be extracted
            @param index: index into the collection of blocks into which new block will be added
            @param subtype: used when making unique identifier, will normally be 'r' for reconstructed blocks and 's' for split blocks
           
        '''
        #make a uniqueid for this block
        self.uniqueid = Identifier.make_id(Identifier.PFOBJECTTYPE.BLOCK, index, subtype, len(element_ids))
        #this will sort by type eg ecal, hcal, track and then by energy (biggest first)
        sortby = lambda x: (Identifier.type_letter(x), -Identifier.get_value(x))
        self.element_uniqueids = sorted(element_ids, key=sortby)
        #sequential numbering of blocks, not essential but helpful for debugging
        self.block_count = PFBlock.temp_block_count
        PFBlock.temp_block_count += 1

        #extract the relevant parts of the complete set of edges and store this within the block
        self.edges = dict()
        for id1, id2 in itertools.combinations(self.element_uniqueids, 2):
            key = Edge.make_key(id1, id2)
            self.edges[key] = edges[key]