コード例 #1
0
ファイル: pfreconstructor.py プロジェクト: MarinaBeguin/heppy
    def reconstruct(self, papasevent, block_type_and_subtype):
        '''papasevent: PapasEvent containing collections of particle flow objects 
           block_type_and_subtype: which blocks collection to use'''

        self.unused = []
        self.papasevent = papasevent
        self.history_helper = HistoryHelper(papasevent)
        self.particles = dict()
        self.splitblocks = dict()
        blocks = papasevent.get_collection(block_type_and_subtype)

        # simplify the blocks by editing the links so that each track will end up linked to at most one hcal
        # then recalculate the blocks
        for blockid in sorted(blocks.keys(),
                              reverse=True):  #big blocks come first
            pdebugger.info(str('Splitting {}'.format(blocks[blockid])))
            newblocks = self.simplify_blocks(blocks[blockid],
                                             self.papasevent.history)
            self.splitblocks.update(newblocks)

        #reconstruct each of the resulting blocks
        for b in sorted(self.splitblocks.keys(),
                        reverse=True):  #put big interesting blocks first
            sblock = self.splitblocks[b]
            pdebugger.info('Processing {}'.format(sblock))
            self.reconstruct_block(sblock)
            pdebugger.info("Finished block")

        #check if anything is unused
        if len(self.unused):
            self.log.warning(str(self.unused))
        self.log.info("Particles:")
        self.log.info(str(self))
        pdebugger.info("Finished reconstruction")
コード例 #2
0
 def __init__(self, papasevent, directory):
     '''
     * papasevent is a PapasEvent
     * diretory is where the output plots go
     '''
     self.papasevent = papasevent
     self.helper = HistoryHelper(papasevent)
     self.directory = directory
コード例 #3
0
 def process(self, event):
     '''
      The event must contain a papasevent.
     '''
     self.papasevent = event.papasevent
     self.hist = HistoryHelper(event.papasevent)
     if self.cfg_ana.format == "event":
         print self.hist.summary_string_event()
     elif self.cfg_ana.format == "subgroups":
         num_subgroups = None
         if hasattr(self.cfg_ana, "num_subgroups"):
             num_subgroups = self.cfg_ana.num_subgroups
         print self.hist.summary_string_subgroups(num_subgroups)
コード例 #4
0
def is_from_b(jet, event, fraction=0.05):
    '''returns true if more than a fraction of the jet energy
    is from a b.'''
    history = HistoryHelper(event.papasevent)
    if not hasattr(event, 'genbrowser'):
        event.genbrowser = GenBrowser(event.gen_particles, event.gen_vertices)
    sum_e_from_b = 0
    # charged_ptcs = jet.constituents[211]
    from_b = False
    for ptc in jet.constituents.particles:
        simids = history.get_linked_collection(ptc.uniqueid, 'ps')
        for simid in simids:
            simptc = event.papasevent.get_object(simid)
            if is_ptc_from_b(event, simptc.gen_ptc, event.genbrowser):
                from_b = True
                break
        if from_b:
            sum_e_from_b += ptc.e()
    bfrac = sum_e_from_b / jet.e()
    jet.tags['bfrac'] = bfrac
    return bfrac > fraction