当前位置: 首页>>代码示例>>Python>>正文


Python Tree.reset方法代码示例

本文整理汇总了Python中heppy.statistics.tree.Tree.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.reset方法的具体用法?Python Tree.reset怎么用?Python Tree.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在heppy.statistics.tree.Tree的用法示例。


在下文中一共展示了Tree.reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LeptonTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class LeptonTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(LeptonTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        bookLepton(self.tree, 'lep1')
        bookLepton(self.tree, 'lep2')
        

    def process(self, event):
        self.tree.reset()
        leptons = getattr(event, self.cfg_ana.leptons)
        if len(leptons) > 0:
            fillLepton(self.tree, 'lep1', leptons[0])
        if len(leptons) > 1:
            fillLepton(self.tree, 'lep2', leptons[1])
        self.tree.tree.Fill()
        
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:GaelTouquet,项目名称:heppy,代码行数:28,代码来源:LeptonTreeProducer.py

示例2: JetTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class JetTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(JetTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'jet_tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        bookJet(self.tree, 'jet1')
        bookJet(self.tree, 'jet1_gen')
        bookJet(self.tree, 'jet2')
        bookJet(self.tree, 'jet2_gen')
        
    def process(self, event):
        self.tree.reset()
        if( len(event.rec_jets)>0 ):
            jet = event.rec_jets[0]
            fillJet(self.tree, 'jet1', jet)
            if jet.gen:
                fillJet(self.tree, 'jet1_gen', jet.gen)
        if( len(event.rec_jets)>1 ):
            jet = event.rec_jets[1]
            fillJet(self.tree, 'jet2', jet)
            if jet.gen:
                fillJet(self.tree, 'jet2_gen', jet.gen)
        self.tree.tree.Fill()
        
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:GaelTouquet,项目名称:heppy_fcc,代码行数:34,代码来源:JetTreeProducer.py

示例3: IsoParticleTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class IsoParticleTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(IsoParticleTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        bookIsoParticle(self.tree, 'ptc')

    def process(self, event):
        self.tree.reset()
        leptons = getattr(event, self.cfg_ana.leptons)
        pdgids = [211, 22, 130]
        for lepton in leptons:
            for pdgid in pdgids:
                iso = getattr(lepton, 'iso_{pdgid:d}'.format(pdgid=pdgid))
                for ptc in iso.on_ptcs:
                    self.tree.reset()
                    fillIsoParticle(self.tree, 'ptc', ptc, lepton)
                    self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:GaelTouquet,项目名称:heppy,代码行数:28,代码来源:IsoParticleTreeProducer.py

示例4: SimpleTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class SimpleTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(SimpleTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        bookParticle(self.tree, 'recoil_gen')
        bookParticle(self.tree, 'recoil_visible_gen')
        bookParticle(self.tree, 'recoil_papas')
        bookParticle(self.tree, 'recoil_visible_papas')

        
    def process(self, event):
        self.tree.reset()
        fillParticle(self.tree, 'recoil_gen', event.recoil_gen)
        fillParticle(self.tree, 'recoil_visible_gen', event.recoil_visible_gen)
        if hasattr(event, 'recoil_papas'):
            fillParticle(self.tree, 'recoil_papas', event.recoil_papas)
            fillParticle(self.tree, 'recoil_visible_papas', event.recoil_visible_papas)
        self.tree.tree.Fill()

        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:alicerobson,项目名称:heppy_fcc,代码行数:29,代码来源:SimpleTreeProducer.py

示例5: JetPtcTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class JetPtcTreeProducer(Analyzer):
    '''Some class doc'''

    def beginLoop(self, setup):
        super(JetPtcTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'jet_tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        bookJet(self.tree, 'jet1')
        bookJet(self.tree, 'jet1_rec')
        bookJet(self.tree, 'jet2')
        bookJet(self.tree, 'jet2_rec')
        var(self.tree, 'event')
        var(self.tree, 'lumi')
        var(self.tree, 'run')
        bookParticle(self.tree, 'ptc_gen')
        bookParticle(self.tree, 'ptc_rec')


    def process(self, event):
        self.tree.reset()
        if hasattr(event, 'eventId'): 
            fill(self.tree, 'event', event.eventId)
            fill(self.tree, 'lumi', event.lumi)
            fill(self.tree, 'run', event.run)
        elif hasattr(event, 'iEv'):
            fill(self.tree, 'event', event.iEv)
        jets = getattr(event, self.cfg_ana.jets)
        if( len(jets)>0 ):
            jet = jets[0]
            comp211 = jet.constituents.get(211, None)
            if comp211: 
                if comp211.num==2:
                    import pdb; pdb.set_trace()
            fillJet(self.tree, 'jet1', jet)
            if jet.match:
                fillJet(self.tree, 'jet1_rec', jet.match)
                # if jet.e()/jet.match.e() > 2.:
                #     import pdb; pdb.set_trace()
        if( len(jets)>1 ):
            jet = jets[1]
            fillJet(self.tree, 'jet2', jet)
            if jet.match:
                fillJet(self.tree, 'jet2_rec', jet.match)
        ptc = getattr(event, self.cfg_ana.particle)
        fillParticle(self.tree, 'ptc_gen', ptc[0])
        if ptc[0].match:
            fillParticle(self.tree, 'ptc_rec', ptc[0].match)
        self.tree.tree.Fill()
        
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:GaelTouquet,项目名称:papas_analysis_gael,代码行数:58,代码来源:JetPtcTreeProducer.py

示例6: ParticleTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class ParticleTreeProducer(Analyzer):
    '''Fills a TTree for particle-flow studies (experts only)'''
    
    def beginLoop(self, setup):
        super(ParticleTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree('particles', '')
        bookParticle(self.tree, 'ptc')
        bookCluster(self.tree, 'ptc_ecal')
        bookParticle(self.tree, 'ptc_match')
        var(self.tree, 'dr')
        bookParticle(self.tree, 'ptc_match_211')
        var(self.tree, 'dr_211')
        bookParticle(self.tree, 'ptc_match_130')
        var(self.tree, 'dr_130')
        bookParticle(self.tree, 'ptc_match_22')
        var(self.tree, 'dr_22')

    def process(self, event):
        particles = getattr(event, self.cfg_ana.particles)
        for ptc in particles: 
            self.tree.reset()
            fillParticle(self.tree, 'ptc', ptc)
            m211 = m22 = False
            # if hasattr(ptc, 'clusters'):
            #     # sim particle
            #     ecal = ptc.clusters.get('ecal_in', None)
            #     if ecal:
            #         fillCluster(self.tree, 'ptc_ecal', ecal)
            if hasattr(ptc, 'match') and ptc.match:
                fillParticle(self.tree, 'ptc_match', ptc.match)
                fill(self.tree, 'dr', ptc.dr)
            if hasattr(ptc, 'match_211') and ptc.match_211:
                m211 = True
                fillParticle(self.tree, 'ptc_match_211', ptc.match_211)
                fill(self.tree, 'dr_211', ptc.dr_211)
            if hasattr(ptc, 'match_130') and ptc.match_130:
                fillParticle(self.tree, 'ptc_match_130', ptc.match_130)
                fill(self.tree, 'dr_130', ptc.dr_130)
            if hasattr(ptc, 'match_22') and ptc.match_22:
                m22 = True
                fillParticle(self.tree, 'ptc_match_22', ptc.match_22)
                fill(self.tree, 'dr_22', ptc.dr_22)
            # if m22 and not m211:
            #     print event
            #     import pdb; pdb.set_trace()
            self.tree.tree.Fill()
        
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:56,代码来源:ParticleTreeProducer.py

示例7: JetConeTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class JetConeTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(JetConeTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'jet_tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        bookJet(self.tree, 'papasjet')
        bookJet(self.tree, 'cmsjet')
        bookJet(self.tree, 'papas_control_jet')
        bookJet(self.tree, 'cms_control_jet')
        bookJet(self.tree, 'gen_jet')
        bookJet(self.tree, 'simtrack')
        var(self.tree, 'simtrack_len')
        for i in range(20):
            bookParticle(self.tree, 'simtrack_ptc'+str(i))
        bookParticle(self.tree, 'PFCandidate')

    def process(self, event):
        self.tree.reset()
        papasjet = getattr(event, self.cfg_ana.rec_jet, None)
        cmsjet = getattr(event, self.cfg_ana.pf_jet, None)
        papas_control_jet = getattr(event, self.cfg_ana.rec_control_jet, None)
        cms_control_jet = getattr(event, self.cfg_ana.pf_control_jet, None)
        gen_jet = getattr(event, self.cfg_ana.gen_jet, None)
        if papasjet:
            fillJet(self.tree, 'papasjet', papasjet)
        if cmsjet:
            fillJet(self.tree, 'cmsjet', cmsjet)
        if papas_control_jet:
            fillJet(self.tree, 'papas_control_jet', papas_control_jet)
        if cms_control_jet:
            fillJet(self.tree, 'cms_control_jet', cms_control_jet)
        if gen_jet:
            fillJet(self.tree, 'gen_jet', gen_jet)
        sim_track_jet = getattr(event, self.cfg_ana.sim_track_jet, None)
        if sim_track_jet:
            fillJet(self.tree, 'simtrack', sim_track_jet)
        sim_track_ptcs = getattr(event, self.cfg_ana.sim_track, None)
        if sim_track_ptcs:
            for i in range(min(len(sim_track_ptcs), 20)):
                fillParticle(self.tree, 'simtrack_ptc'+str(i), sim_track_ptcs[i])
        fill(self.tree, 'simtrack_len', len(sim_track_ptcs))
        pfcandidates = getattr(event, self.cfg_ana.pfcandidates, None)
        if pfcandidates:
            fillParticle(self.tree, 'PFCandidate', pfcandidates[0])
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:cbernet,项目名称:papas_analysis_gael,代码行数:55,代码来源:JetConeTreeProducer.py

示例8: TTbarTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class TTbarTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(TTbarTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        bookParticle(self.tree, 'jet1')
        bookParticle(self.tree, 'jet2')
        bookParticle(self.tree, 'jet3')
        bookParticle(self.tree, 'jet4')
        bookParticle(self.tree, 'm3')
        bookMet(self.tree, 'met')
        bookLepton(self.tree, 'muon')
        bookLepton(self.tree, 'electron')

    def process(self, event):
        self.tree.reset()
        muons = getattr(event, self.cfg_ana.muons)        
        electrons = getattr(event, self.cfg_ana.electrons)

        if len(muons)==0 and len(electrons)==0:
            return # NOT FILLING THE TREE IF NO

        if len(muons)==1 and len(electrons)==0:
            fillLepton(self.tree, 'muon', muons[0])

        elif len(electrons)==1 and len(muons)==0:
            fillLepton(self.tree, 'electron', electrons[0])

        else:
            return # NOT FILLING THE TREE IF MORE THAN 1 LEPTON

        jets = getattr(event, self.cfg_ana.jets_30)
        if len(jets)<3:
            return # NOT FILLING THE TREE IF LESS THAN 4 JETS
        for ijet, jet in enumerate(jets):
            if ijet==4:
                break
            fillParticle(self.tree, 'jet{ijet}'.format(ijet=ijet+1), jet)
        m3 = getattr(event, self.cfg_ana.m3)
        if m3: 
            fillParticle(self.tree, 'm3', m3)

        met = getattr(event, self.cfg_ana.met)
        fillMet(self.tree, 'met', met)
        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:GaelTouquet,项目名称:heppy,代码行数:54,代码来源:TTbarTreeProducer.py

示例9: ZHTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class ZHTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(ZHTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        if hasattr(self.cfg_ana, 'recoil'):
            bookParticle(self.tree, 'recoil')
        if hasattr(self.cfg_ana, 'zeds'):  
            bookZed(self.tree, 'zed')
        self.taggers = ['b', 'bmatch', 'bfrac']
        bookJet(self.tree, 'jet1', self.taggers)
        bookJet(self.tree, 'jet2', self.taggers)
        bookHbb(self.tree, 'higgs')
        bookParticle(self.tree, 'misenergy')
        var(self.tree, 'n_nu')
       
    def process(self, event):
        self.tree.reset()
        if hasattr(self.cfg_ana, 'recoil'):
            recoil = getattr(event, self.cfg_ana.recoil)    
            fillParticle(self.tree, 'recoil', recoil)
        if hasattr(self.cfg_ana, 'zeds'):  
            zeds = getattr(event, self.cfg_ana.zeds)
            if len(zeds)>0:
                zed = zeds[0]
                fillZed(self.tree, 'zed', zed)
        misenergy = getattr(event, self.cfg_ana.misenergy)
        fillParticle(self.tree, 'misenergy', misenergy )        
        jets = getattr(event, self.cfg_ana.jets)
        for ijet, jet in enumerate(jets):
            if ijet == 2:
                break
            fillJet(self.tree, 'jet{ijet}'.format(ijet=ijet+1), jet, self.taggers)
        higgses = getattr(event, self.cfg_ana.higgses)
        if len(higgses)>0:
            higgs = higgses[0]
            # if higgs.m() < 30:
            #    import pdb; pdb.set_trace()
            fillHbb(self.tree, 'higgs', higgs)
        neutrinos = getattr(event, 'neutrinos', None)
        if neutrinos:
            fill(self.tree, 'n_nu', len(neutrinos))
        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:52,代码来源:ZHTreeProducer.py

示例10: ParticleTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class ParticleTreeProducer(Analyzer):
    def beginLoop(self, setup):
        super(ParticleTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile("/".join([self.dirName, "tree.root"]), "recreate")
        self.tree = Tree("particles", "")
        bookParticle(self.tree, "ptc")
        bookCluster(self.tree, "ptc_ecal")
        bookParticle(self.tree, "ptc_match")
        var(self.tree, "dr")
        bookParticle(self.tree, "ptc_match_211")
        var(self.tree, "dr_211")
        bookParticle(self.tree, "ptc_match_130")
        var(self.tree, "dr_130")
        bookParticle(self.tree, "ptc_match_22")
        var(self.tree, "dr_22")

    def process(self, event):
        particles = getattr(event, self.cfg_ana.particles)
        for ptc in particles:
            self.tree.reset()
            fillParticle(self.tree, "ptc", ptc)
            m211 = m22 = False
            # if hasattr(ptc, 'clusters'):
            #     # sim particle
            #     ecal = ptc.clusters.get('ecal_in', None)
            #     if ecal:
            #         fillCluster(self.tree, 'ptc_ecal', ecal)
            if hasattr(ptc, "match") and ptc.match:
                fillParticle(self.tree, "ptc_match", ptc.match)
                fill(self.tree, "dr", ptc.dr)
            if hasattr(ptc, "match_211") and ptc.match_211:
                m211 = True
                fillParticle(self.tree, "ptc_match_211", ptc.match_211)
                fill(self.tree, "dr_211", ptc.dr_211)
            if hasattr(ptc, "match_130") and ptc.match_130:
                fillParticle(self.tree, "ptc_match_130", ptc.match_130)
                fill(self.tree, "dr_130", ptc.dr_130)
            if hasattr(ptc, "match_22") and ptc.match_22:
                m22 = True
                fillParticle(self.tree, "ptc_match_22", ptc.match_22)
                fill(self.tree, "dr_22", ptc.dr_22)
            # if m22 and not m211:
            #     print event
            #     import pdb; pdb.set_trace()
            self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:jlingema,项目名称:heppy,代码行数:51,代码来源:ParticleTreeProducer.py

示例11: ZHTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class ZHTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(ZHTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        bookParticle(self.tree, 'zed')
        bookParticle(self.tree, 'recoil')
        bookJet(self.tree, 'jet1')
        bookJet(self.tree, 'jet2')
        bookJet(self.tree, 'jet3')
        bookJet(self.tree, 'jet4')
        bookLepton(self.tree, 'zed_1')
        bookLepton(self.tree, 'zed_2')
        bookParticle(self.tree, 'higgs')
        bookParticle(self.tree, 'higgs_1')
        bookParticle(self.tree, 'higgs_2')
        bookParticle(self.tree, 'misenergy')
       
    def process(self, event):
        self.tree.reset()
        recoil = getattr(event, self.cfg_ana.recoil)
        fillParticle(self.tree, 'recoil', recoil)        
        misenergy = getattr(event, self.cfg_ana.misenergy)
        fillParticle(self.tree, 'misenergy', misenergy )        
        zeds = getattr(event, self.cfg_ana.zeds)
        if len(zeds)>0:
            zed = zeds[0]
            fillParticle(self.tree, 'zed', zed)
            fillLepton(self.tree, 'zed_1', zed.legs[0])
            fillLepton(self.tree, 'zed_2', zed.legs[1])
        jets = getattr(event, self.cfg_ana.jets)
        for ijet, jet in enumerate(jets):
            if ijet==4:
                break
            fillJet(self.tree, 'jet{ijet}'.format(ijet=ijet+1), jet)
        higgses = getattr(event, self.cfg_ana.higgses)
        if len(higgses)>0:
            higgs = higgses[0]
            fillParticle(self.tree, 'higgs', higgs)
            fillLepton(self.tree, 'higgs_1', higgs.legs[0])
            fillLepton(self.tree, 'higgs_2', higgs.legs[1])
        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:clementhelsens,项目名称:heppy,代码行数:51,代码来源:ZHTreeProducer.py

示例12: TreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class TreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(TreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        self.taggers = 'b'
        bookJet(self.tree, 'jet1', self.taggers)
        bookJet(self.tree, 'jet2', self.taggers)
        bookJet(self.tree, 'jet3', self.taggers)
        bookJet(self.tree, 'jet4', self.taggers)
        bookParticle(self.tree, 'misenergy')
        bookParticle(self.tree, 'higgs')
        bookParticle(self.tree, 'zed')
        bookLepton(self.tree, 'lepton1')
        bookLepton(self.tree, 'lepton2')
        
       
    def process(self, event):
        self.tree.reset()
        misenergy = getattr(event, self.cfg_ana.misenergy)
        fillParticle(self.tree, 'misenergy', misenergy )        
        jets = getattr(event, self.cfg_ana.jets)
        for ijet, jet in enumerate(jets):
            if ijet==4:
                break
            fillJet(self.tree, 'jet{ijet}'.format(ijet=ijet+1),
                    jet, self.taggers)
        higgs = getattr(event, self.cfg_ana.higgs)
        if higgs:
            fillParticle(self.tree, 'higgs', higgs)
        zed = getattr(event, self.cfg_ana.zed)
        if zed:
            fillParticle(self.tree, 'zed', zed)
        leptons = getattr(event, self.cfg_ana.leptons)
        for ilep, lepton in enumerate(reversed(leptons)):
            if ilep == 2:
                break
            fillLepton(self.tree,
                       'lepton{ilep}'.format(ilep=ilep+1), 
                       lepton)
        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:50,代码来源:TreeProducer.py

示例13: HTo4lGenTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class HTo4lGenTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(HTo4lGenTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        self.tree.var('weight', float)

        bookParticle(self.tree, 'lep1vsPt')
        bookParticle(self.tree, 'lep2vsPt')
        bookParticle(self.tree, 'lep3vsPt')
        bookParticle(self.tree, 'lep4vsPt')

        bookParticle(self.tree, 'lep1vsEta')
        bookParticle(self.tree, 'lep2vsEta')
        bookParticle(self.tree, 'lep3vsEta')
        bookParticle(self.tree, 'lep4vsEta')


    def process(self, event):
        self.tree.reset()
        gen_leptons = getattr(event, self.cfg_ana.leptons)

        self.tree.fill('weight' , event.weight )
        
        if len(gen_leptons) >= 4:

            gen_leptons.sort(key=lambda x: x.pt(), reverse=True)

            fillParticle(self.tree, 'lep1vsPt', gen_leptons[0])
            fillParticle(self.tree, 'lep2vsPt', gen_leptons[1])
            fillParticle(self.tree, 'lep3vsPt', gen_leptons[2])
            fillParticle(self.tree, 'lep4vsPt', gen_leptons[3])

            gen_leptons.sort(key=lambda x: abs(x.eta()))

            fillParticle(self.tree, 'lep1vsEta', gen_leptons[0])
            fillParticle(self.tree, 'lep2vsEta', gen_leptons[1])
            fillParticle(self.tree, 'lep3vsEta', gen_leptons[2])
            fillParticle(self.tree, 'lep4vsEta', gen_leptons[3])

        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:50,代码来源:HTo4lGenTreeProducer.py

示例14: TreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class TreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(TreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        self.tree.var('tau1', float)
        self.tree.var('tau2', float)
        self.tree.var('tau3', float)
        self.tree.var('tau32', float)
        self.tree.var('tau31', float)
        self.tree.var('tau21', float)

        bookParticle(self.tree, 'Jet')
        bookParticle(self.tree, 'softDroppedJet')
        bookParticle(self.tree, 'leadingSoftDroppedSubJet')
        bookParticle(self.tree, 'trailingSoftDroppedSubJet')

    def process(self, event):
        self.tree.reset()
        jets = getattr(event, self.cfg_ana.fatjets)
        
        # store leading (fat) jet observables
        if len(jets) > 0 and len(jets[0].subjetsSoftDrop) > 2:
            self.tree.fill('tau1' , jets[0].tau1 )
            self.tree.fill('tau2' , jets[0].tau2 )
            self.tree.fill('tau3' , jets[0].tau3 )
            self.tree.fill('tau31' , jets[0].tau3/jets[0].tau1 )
            self.tree.fill('tau32' , jets[0].tau3/jets[0].tau2 )
            self.tree.fill('tau21' , jets[0].tau2/jets[0].tau1 )

            fillParticle(self.tree, 'Jet', jets[0])
            
            # first subjet entry is the cleaned jet itself
            fillParticle(self.tree, 'softDroppedJet', jets[0].subjetsSoftDrop[0])
            fillParticle(self.tree, 'leadingSoftDroppedSubJet', jets[0].subjetsSoftDrop[1])
            fillParticle(self.tree, 'trailingSoftDroppedSubJet', jets[0].subjetsSoftDrop[2])
            
            self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:47,代码来源:TreeProducer.py

示例15: GlobalEventTreeProducer

# 需要导入模块: from heppy.statistics.tree import Tree [as 别名]
# 或者: from heppy.statistics.tree.Tree import reset [as 别名]
class GlobalEventTreeProducer(Analyzer):
    def beginLoop(self, setup):
        super(GlobalEventTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile("/".join([self.dirName, "tree.root"]), "recreate")
        self.tree = Tree("events", "")
        bookJet(self.tree, "sum_all")
        bookJet(self.tree, "sum_all_gen")

    def process(self, event):
        self.tree.reset()
        sum_all = getattr(event, self.cfg_ana.sum_all)
        sum_all_gen = getattr(event, self.cfg_ana.sum_all_gen)
        fillJet(self.tree, "sum_all", sum_all)
        fillJet(self.tree, "sum_all_gen", sum_all_gen)
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
开发者ID:jlingema,项目名称:heppy,代码行数:21,代码来源:GlobalEventTreeProducer.py


注:本文中的heppy.statistics.tree.Tree.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。