Example #1
0
 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')
class ConeTreeProducer(Analyzer):
    def beginLoop(self, setup):
        super(ConeTreeProducer, 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)
        bookParticle(self.tree, 'particle')
        var(self.tree, 'dR')
        var(self.tree, 'is_gen_matched')
        var(self.tree, 'iEv')

    def process(self, event):
        ptcs = getattr(event, self.cfg_ana.particles, [])
        fill(self.tree, 'iEv', getattr(event, 'iEv'))
        for ptc in ptcs:
            self.tree.reset()
            fillParticle(self.tree, 'particle', ptc)
            if ptc.gen_matched:
                fill(self.tree, 'is_gen_matched', 1)
            else:
                fill(self.tree, 'is_gen_matched', 0)
            fill(self.tree, 'dR', ptc.dR)
            self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
Example #3
0
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 = 'mu'
        bookParticle(self.tree, 'higgs')
        bookParticle(self.tree, 'muon1')
        bookParticle(self.tree, 'muon2')
        var(self.tree, 'lenmu')

    def process(self, event):
        self.tree.reset()

        lenmu = getattr(event, self.cfg_ana.lenmu)
        fill(self.tree, 'lenmu', lenmu)

        higgs = getattr(event, self.cfg_ana.higgs)
        if higgs:
            fillParticle(self.tree, 'higgs', higgs)
        muons = getattr(event, self.cfg_ana.muons)
        for i, muon in enumerate(reversed(muons)):
            if i == 2:
                break
            fillParticle(self.tree, 'muon{i}'.format(i=i + 1), muon)
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
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()
Example #5
0
 def beginLoop(self, setup):
     super(HiggsTreeProducer, 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)
     bookZed(self.tree, 'ztomumu')
     bookZed(self.tree, 'higgstojj')
Example #6
0
    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('weight', float)
        self.tree.var('missingET', float)

        self.tree.var('rapiditySeparation_calo04', float)
        self.tree.var('pseudorapiditySeparation_calo04', float)
        self.tree.var('transverseMomentumAsymmetry_calo04', float)

        self.tree.var('rapiditySeparation_pf04', float)
        self.tree.var('pseudorapiditySeparation_pf04', float)
        self.tree.var('transverseMomentumAsymmetry_pf04', float)

        bookParticle(self.tree, 'Jet1_pf04')
        bookParticle(self.tree, 'Jet2_pf04')

        bookParticle(self.tree, 'Jet1_calo04')
        bookParticle(self.tree, 'Jet2_calo04')

        self.tree.var('Mj1j2_pf04', float)
        self.tree.var('Mj1j2_calo04', float)
    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('weight', float)
        #self.tree.var('met', float)

        bookParticle(self.tree, 'higgs')
        bookParticle(self.tree, 'zed1')
        bookParticle(self.tree, 'zed2')
        bookParticle(self.tree, 'l1')
        bookParticle(self.tree, 'l2')
        bookParticle(self.tree, 'l3')
        bookParticle(self.tree, 'l4')
        bookMet(self.tree, 'met')

        self.tree.var('4mu', int)
        self.tree.var('4e', int)
        self.tree.var('2mu2e', int)
        self.tree.var('nljets', float)
        self.tree.var('nbjets', float)
        self.tree.var('njets', float)
        self.tree.var('nleptons', float)
        self.tree.var('nextraleptons', float)
Example #8
0
    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('weight', float)
        float_vars = [
            'bJets_N', 'lJets_N', "fatJets_N", "bFatJets_N", "bFatJets_N_Parts"
        ]
        int_vars = []

        bjets_vars = ["bfatjet_1", "bfatjet_2"]
        for part in bjets_vars:
            self.book_bfatjet(part)

        for var in float_vars:
            self.tree.var(var, float)

        for var in int_vars:
            self.tree.var(var, float)

        bookMet(self.tree, 'met')

        bookParticle(self.tree, 'gen_fcnc_t')
        bookParticle(self.tree, 'gen_fcnc_higgs')
        bookParticle(self.tree, 'gen_fcnc_u')
        bookParticle(self.tree, 'gen_fcnc_b1')
        bookParticle(self.tree, 'gen_fcnc_b2')
        bookParticle(self.tree, 'gen_sm_t')
        self.tree.var('delta_R', float)
Example #9
0
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()
Example #10
0
    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('weight', float)
        #self.tree.var('met', float)
        self.tree.var('nljets', float)
        self.tree.var('nbjets', float)
        self.tree.var('njets', float)

        self.tree.var('is_sf', float)
        self.tree.var('is_of', float)

        self.tree.var('mt', float)
        self.tree.var('mr', float)
        self.tree.var('higgs_pt', float)
        self.tree.var('dphi_ll', float)
        self.tree.var('dphi_llmet', float)

        bookParticle(self.tree, 'l1')
        bookParticle(self.tree, 'l2')
        bookParticle(self.tree, 'll')

        bookMet(self.tree, 'met')
 def beginLoop(self, setup):
     super(QQTauTauTreeProducer, 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']
     ##        for label in self.cfg_ana.leptons:
     ##            bookIsoParticle(self.tree, '{}_1'.format(label), pflow=True)
     ##            bookIsoParticle(self.tree, '{}_2'.format(label), pflow=True)
     for label in self.cfg_ana.particles:
         bookParticle(self.tree, label)
         var(self.tree, 'n_' + label)
     for label in self.cfg_ana.jet_collections:
         bookJet(self.tree, '{}_1'.format(label), self.taggers)
         bookJet(self.tree, '{}_2'.format(label), self.taggers)
     for label in self.cfg_ana.resonances:
         iso = False
         if 'zed' in label and not 'qq' in label:
             iso = True
         bookResonanceWithLegs(self.tree, label, iso)
     bookIso(self.tree, 'besttaus_1_iso')
     bookIso(self.tree, 'besttaus_2_iso')
     bookResonanceWithLegs(self.tree, 'genboson1')
     bookResonanceWithLegs(self.tree, 'genboson2')
     for label in self.cfg_ana.misenergy:
         bookParticle(self.tree, label)
     var(self.tree, 'n_nu')
     var(self.tree, 'beta4_chi2')
Example #12
0
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()
Example #13
0
 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')
Example #14
0
 def beginLoop(self, setup):
     super(SimpleTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName, 'simple_tree.root']),
                           'recreate')
     self.tree = Tree(self.cfg_ana.tree_name, self.cfg_ana.tree_title)
     self.tree.var('test_variable')
     self.tree.var('test_variable_random')
Example #15
0
    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('weight', float)
        float_vars = []
        int_vars = []

        self.book_container_jet("pfjets02", 10, True)
        # self.book_container_jet("pfjets04")
        self.book_container_jet("pfjets08", 5, False)

        self.book_container_jet("pfjets04_btag", 8, False)
        self.book_container("leptons")

        for var in float_vars:
            self.tree.var(var, float)

        for var in int_vars:
            self.tree.var(var, float)

        bookMet(self.tree, 'met')

        bookParticle(self.tree, 'gen_fcnc_t')
        bookParticle(self.tree, 'gen_fcnc_higgs')
        bookParticle(self.tree, 'gen_fcnc_u')
        bookParticle(self.tree, 'gen_fcnc_b1')
        bookParticle(self.tree, 'gen_fcnc_b2')
        bookParticle(self.tree, 'gen_sm_t')
        self.tree.var('delta_R', float)
Example #16
0
    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('weight', float)
        self.tree.var('weight_1tagex', float)
        self.tree.var('weight_2tagex', float)
        self.tree.var('weight_1tagin', float)

        bookParticle(self.tree, 'Jet1_pf04')
        bookParticle(self.tree, 'Jet2_pf04')
        self.tree.var('Mj1j2_pf04', float)
        self.tree.var('Mj1j2_pf04_MetCorr', float)
        self.tree.var('Mj1j2_pf04_MetCorr2', float)

        self.tree.var('mt', float)
        self.tree.var('mr', float)
        self.tree.var('mr2', float)
        self.tree.var('mr3', float)
        self.tree.var('dr', float)
        self.tree.var('dphi', float)
        self.tree.var('dphi_met', float)
        self.tree.var('ntau', int)

        bookMet(self.tree, 'met')
Example #17
0
    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('weight', float)
        self.tree.var('zprime_y', float)

        bookParticle(self.tree, 'zprime_ele')
        bookParticle(self.tree, 'zprime_muon')

        bookParticle(self.tree, 'jet1')
        bookParticle(self.tree, 'jet2')
        bookParticle(self.tree, 'jet3')
        bookLepton(self.tree, 'lep1', pflow=False)
        bookLepton(self.tree, 'lep2', pflow=False)
        bookLepton(self.tree, 'lep3', pflow=False)

        bookLepton(self.tree, 'lep1_gen_1', pflow=False)
        bookLepton(self.tree, 'lep2_gen_1', pflow=False)

        bookLepton(self.tree, 'lep1_gen_23', pflow=False)
        bookLepton(self.tree, 'lep2_gen_23', pflow=False)

        bookMet(self.tree, 'met')
Example #18
0
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()
Example #19
0
    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('weight', float)

        self.tree.var('njets', float)
        self.tree.var('nleptons', float)

        bookParticle(self.tree, 'l1')
        bookParticle(self.tree, 'l2')
        bookParticle(self.tree, 'l3')
        bookParticle(self.tree, 'l4')

        bookParticle(self.tree, 'j1')
        bookParticle(self.tree, 'j2')
        bookParticle(self.tree, 'j3')
        bookParticle(self.tree, 'j4')

        bookParticle(self.tree, 'gj1')
        bookParticle(self.tree, 'gj2')
        bookParticle(self.tree, 'gl1')
        bookParticle(self.tree, 'gl2')
        bookParticle(self.tree, 'gv1')
        bookParticle(self.tree, 'gv2')

        bookMet(self.tree, 'met')
class Higgs350TreeProducer(Analyzer):
    def beginLoop(self, setup):
        super(Higgs350TreeProducer, 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')
        bookParticle(self.tree, 'recoil_cms')
        bookParticle(self.tree, 'recoil_visible_cms')

    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)
        if hasattr(event, 'recoil_cms'):
            fillParticle(self.tree, 'recoil_cms', event.recoil_cms)
            fillParticle(self.tree, 'recoil_visible_cms',
                         event.recoil_visible_cms)
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
Example #21
0
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')
        var(self.tree, 'mtw')

        bookMet(self.tree, 'met')
        bookLepton(self.tree, 'muon', pflow=False)
        bookLepton(self.tree, 'electron', pflow=False)

    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])
            fillIso(self.tree, 'muon_iso', muons[0].iso)

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

        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)

        mtw = getattr(event, self.cfg_ana.mtw)
        if mtw:
            fill(self.tree, 'mtw', mtw)
            #fillParticle(self.tree, 'mtw', mtw)

        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()
Example #22
0
    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('weight', float)
	self.tree.var('missingET', float)
        self.tree.var('numberOfElectrons', int)
        self.tree.var('numberOfMuons', int)
	self.tree.var('numberOfFatJets', int)

	self.tree.var('Jet1_tau1', float)	
	self.tree.var('Jet1_tau2', float)
        self.tree.var('Jet1_tau3', float)
        self.tree.var('Jet2_tau1', float)
        self.tree.var('Jet2_tau2', float)
        self.tree.var('Jet2_tau3', float)
	self.tree.var('Jet1_tau32', float)
        self.tree.var('Jet1_tau31', float)
        self.tree.var('Jet1_tau21', float)
        self.tree.var('Jet2_tau32', float)
        self.tree.var('Jet2_tau31', float)
        self.tree.var('Jet2_tau21', float)

        bookParticle(self.tree, 'Jet1')
        bookParticle(self.tree, 'Jet2')
	bookParticle(self.tree, 'Jet3')
	bookParticle(self.tree, 'Jet4')

	self.tree.var('rapiditySeparation', float)
        self.tree.var('transverseMomentumAsymmetry', float)
	self.tree.var('topJetMassDifference', float)

	self.tree.var('Jet1_trimmedProngMaxPtRatio', float)
        self.tree.var('Jet1_trimmedProngMinPtRatio', float)
        self.tree.var('Jet2_trimmedProngMaxPtRatio', float)
        self.tree.var('Jet2_trimmedProngMinPtRatio', float)

	bookParticle(self.tree, 'softDroppedJet1')
	bookParticle(self.tree, 'softDroppedJet2')
	bookParticle(self.tree, 'softDroppedJet3')
	bookParticle(self.tree, 'softDroppedJet4')

	bookParticle(self.tree, 'smallJet1')
	bookParticle(self.tree, 'smallJet2')
	bookParticle(self.tree, 'smallJet3')
	bookParticle(self.tree, 'smallJet4')
        
	bookParticle(self.tree, 'Electron1')
	bookParticle(self.tree, 'Electron2')

	bookParticle(self.tree, 'Muon1')
	bookParticle(self.tree, 'Muon2')

        self.tree.var('BDTvariable_qcd', float)

	self.tree.var('zPrimeReconstructedMass', float)
Example #23
0
 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')
Example #24
0
 def beginLoop(self, setup):
     super(TauTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName,
                                     'taus.root']),
                           'recreate')
     self.tree = Tree( 'events', '')
     bookJet(self.tree, 'tau')
     bookJet(self.tree, 'tau_match')        
 def beginLoop(self, setup):
     super(ConeTreeProducer, 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)
     bookParticle(self.tree, 'particle')
     var(self.tree, 'dR')
     var(self.tree, 'is_gen_matched')
     var(self.tree, 'iEv')
Example #26
0
 def beginLoop(self, setup):
     super(ZTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName, 'mytree.root']),
                           'recreate')
     self.tree = Tree('events', '')
     bookParticle(self.tree, 'zed')
     #bookParticle(self.tree, 'recoil')
     bookJet(self.tree, 'zed_1')
     bookJet(self.tree, 'zed_2')
 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')
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()
Example #29
0
 def beginLoop(self, setup):
     super(TreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName, 'tree.root']),
                           'recreate')
     self.tree = Tree('events', '')
     self.taggers = 'mu'
     bookParticle(self.tree, 'higgs')
     bookParticle(self.tree, 'muon1')
     bookParticle(self.tree, 'muon2')
     var(self.tree, 'lenmu')
Example #30
0
    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', 'bmatch', 'bfrac', 'eff', 'btag', 'ctag', 'udsgtag',
            'b_pvprob'
        ]
        bookJet(self.tree, 'jet1', self.taggers)
        bookJet(self.tree, 'jet2', self.taggers)
        bookJet(self.tree, 'scaledjet1', self.taggers)
        bookJet(self.tree, 'scaledjet2', self.taggers)
        #        bookJet(self.tree, 'jet3', self.taggers)
        #        bookJet(self.tree, 'jet4', self.taggers)
        bookJet(self.tree, 'genjet1', self.taggers)
        bookJet(self.tree, 'genjet2', self.taggers)
        #        bookJet(self.tree, 'genjet3', self.taggers)
        #        bookJet(self.tree, 'genjet4', self.taggers)
        bookParticle(self.tree, 'genmisenergy')
        bookParticle(self.tree, 'misenergy')
        bookParticle(self.tree, 'higgs')
        bookParticle(self.tree, 'higgsnosf')
        bookParticle(self.tree, 'zed')

        bookParticle(self.tree, 'zed_parton1')
        bookParticle(self.tree, 'zed_parton2')
        bookParticle(self.tree, 'higgs_parton1')
        bookParticle(self.tree, 'higgs_parton2')

        var(self.tree, 'mmiss_rescaled')
        var(self.tree, 'acop')

        var(self.tree, 'mmiss_rescaled2')
        var(self.tree, 'jet1res')
        var(self.tree, 'jet2res')
        var(self.tree, 'absjet1res')
        var(self.tree, 'absjet2res')
        var(self.tree, 'cross')
        var(self.tree, 'ctracks')
        var(self.tree, 'mvis')
        var(self.tree, 'genmvis')
        var(self.tree, 'emratio')
        #        var(self.tree, 'quarkdR')
        #        var(self.tree, 'jetdR')
        var(self.tree, 'alpha')
        var(self.tree, 'beta')
        var(self.tree, 'pLges')
        var(self.tree, 'pTges')
        var(self.tree, 'scaling_fac')
        var(self.tree, 'scaling_fac2')
        var(self.tree, 'n_jets')
        var(self.tree, 'n_genjets')
        var(self.tree, 'bquarks')
        var(self.tree, 'n_genptc_23')
Example #31
0
def create_tree(filename="test_tree.root"): 
    outfile = TFile(filename, 'recreate')
    tree = Tree('test_tree', 'A test tree')
    tree.var('var1')
    for i in range(100):
        tree.fill('var1', i)
        tree.tree.Fill()
    print 'creating a tree', tree.tree.GetName(),\
        tree.tree.GetEntries(), 'entries in',\
        outfile.GetName()
    outfile.Write()
Example #32
0
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()
Example #33
0
 def beginLoop(self, setup):
     super(PapasTreeProducer, 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, 'iEv')
Example #34
0
 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')
     var(self.tree, 'event')
     var(self.tree, 'lumi')
     var(self.tree, 'run')
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()
Example #36
0
 def beginLoop(self, setup):
     super(HTo4lTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName, 'tree.root']),
                           'recreate')
     self.tree = Tree('events', '')
     bookParticle(self.tree, 'zed1')
     bookParticle(self.tree, 'zed2')
     bookLepton(self.tree, 'zed1_lep1')
     bookLepton(self.tree, 'zed1_lep2')
     bookLepton(self.tree, 'zed2_lep1')
     bookLepton(self.tree, 'zed2_lep2')
     bookParticle(self.tree, 'higgs')
Example #37
0
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()
Example #38
0
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()
Example #39
0
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()
Example #40
0
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()
Example #41
0
def create_tree(filename=FNAME):
    if os.path.isfile(filename):
        return filename
    outfile = TFile(filename, 'recreate')
    tree = Tree('test_tree', 'A test tree')
    tree.var('var1')
    for i in range(200):
        tree.fill('var1', i)
        tree.tree.Fill()
    # print 'creating a tree', tree.tree.GetName(),\
    #    tree.tree.GetEntries(), 'entries in',\
    #    outfile.GetName()
    outfile.Write()
    outfile.Close()
    return outfile.GetName()
Example #42
0
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()
 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')
     var(self.tree, 'event_id')
     bookParticles(self.tree, 'tagged', 150)
     bookParticles(self.tree, 'nottagged', 150)
     var(self.tree, '130tagged')
     var(self.tree, '22tagged')
     var(self.tree, '130nottagged')
     var(self.tree, '22nottagged')
     var(self.tree, '11tagged')
     var(self.tree, 'othertagged')
     var(self.tree, 'threshold_pass')
     bookParticles(self.tree, 'cms_ptcs', 150)
Example #44
0
def create_tree(filename=FNAME, nentries=None):
    if not nentries: 
        if os.path.isfile(filename):
            #default number of entries, file exists
            return filename
        else: 
            nentries = 200
    nentries = int(nentries)
    outfile = TFile(filename, 'recreate')
    tree = Tree('test_tree', 'A test tree')
    tree.var('var1')
    for i in range(nentries):
        tree.fill('var1', i)
        tree.tree.Fill()
    outfile.Write()
    outfile.Close()
    return outfile.GetName()
Example #45
0
 def beginLoop(self, setup):
     super(SimpleTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName,
                                     'simple_tree.root']),
                           'recreate')
     self.tree = Tree( self.cfg_ana.tree_name,
                       self.cfg_ana.tree_title )
     self.tree.var('test_variable')
Example #46
0
class SimpleTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(SimpleTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'simple_tree.root']),
                              'recreate')
        self.tree = Tree( self.cfg_ana.tree_name,
                          self.cfg_ana.tree_title )
        self.tree.var('test_variable')

    def process(self, event):
        self.tree.fill('test_variable', event.input.var1)
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
 def beginLoop(self, setup):
     super(SimTrackTreeProducer, 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 )
     bookSimTrack(self.tree, 'simtrack')
     var(self.tree, 'simtrack_len')
Example #48
0
 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')
Example #49
0
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', '')
        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)
        
        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()
 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')
Example #51
0
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()
Example #52
0
class HTo4lTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(HTo4lTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName,
                                        'tree.root']),
                              'recreate')
        self.tree = Tree( 'events', '')
        bookParticle(self.tree, 'zed1')
        bookParticle(self.tree, 'zed2')
        bookLepton(self.tree, 'zed1_lep1')
        bookLepton(self.tree, 'zed1_lep2')
        bookLepton(self.tree, 'zed2_lep1')
        bookLepton(self.tree, 'zed2_lep2')
        bookParticle(self.tree, 'higgs')

    def process(self, event):
        self.tree.reset()
        zeds = getattr(event, self.cfg_ana.zeds)
        zeds.sort(key=lambda x: abs(x.m()-91.))
        higgses = getattr(event, self.cfg_ana.higgses)

        if len(zeds) > 1:

            fillParticle(self.tree, 'zed1', zeds[0])
            fillParticle(self.tree, 'zed2', zeds[1])
            
            fillLepton(self.tree, 'zed1_lep1', zeds[0].legs[0])
            fillLepton(self.tree, 'zed1_lep2', zeds[0].legs[1])
            fillLepton(self.tree, 'zed2_lep1', zeds[1].legs[0])
            fillLepton(self.tree, 'zed2_lep2', zeds[1].legs[1])

        if len(higgses) > 0:  

            higgs = higgses[0]
            fillParticle(self.tree, 'higgs', higgs)

        self.tree.tree.Fill()
        
    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
Example #53
0
 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')
class GenRecTreeProducer(Analyzer):
    
    def beginLoop(self, setup):
        super(GenRecTreeProducer, self).beginLoop(setup)
        self.rootfile = TFile('/'.join([self.dirName, 'tree.root']), 'recreate')
        self.tree = Tree('RecGen', '')
        for i in range(5):
            bookParticle(self.tree, 'gen_ptc{j}'.format(j=i))
            bookParticle(self.tree, 'rec_ptc{j}'.format(j=i))
        var(self.tree, 'nb_gen_ptc')
        var(self.tree, 'nb_rec_ptc')
        var(self.tree, 'event_gen_E')
        var(self.tree, 'event_rec_E')
        var(self.tree, 'iev')

    def process(self, event):
        gen_particles = sorted(getattr(event, self.cfg_ana.gen_particles),
                               key = lambda x: x.e())
        rec_particles = sorted(getattr(event, self.cfg_ana.rec_particles),
                               key = lambda x: x.e())

        self.tree.reset()
        for i in range(min(len(gen_particles), 5)):
            fillParticle(self.tree, 'gen_ptc{j}'.format(j=i), gen_particles[i])
        for i in range(min(len(rec_particles), 5)):
            fillParticle(self.tree, 'rec_ptc{j}'.format(j=i), rec_particles[i])
        fill(self.tree, 'nb_gen_ptc', len(gen_particles))
        fill(self.tree, 'nb_rec_ptc', len(rec_particles))
        gen_E, rec_E = 0, 0
        for ptc in gen_particles:
            gen_E += ptc.e()
        for ptc in rec_particles:
            rec_E += ptc.e()
        fill(self.tree, 'event_gen_E', gen_E)
        fill(self.tree, 'event_rec_E', rec_E)
        fill(self.tree, 'iev', getattr(event, 'iEv'))
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()
Example #55
0
 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, 'm3')
     bookMet(self.tree, 'met')
     bookLepton(self.tree, 'lepton')
 def beginLoop(self, setup):
     super(GenRecTreeProducer, self).beginLoop(setup)
     self.rootfile = TFile('/'.join([self.dirName, 'tree.root']), 'recreate')
     self.tree = Tree('RecGen', '')
     for i in range(5):
         bookParticle(self.tree, 'gen_ptc{j}'.format(j=i))
         bookParticle(self.tree, 'rec_ptc{j}'.format(j=i))
     var(self.tree, 'nb_gen_ptc')
     var(self.tree, 'nb_rec_ptc')
     var(self.tree, 'event_gen_E')
     var(self.tree, 'event_rec_E')
     var(self.tree, 'iev')
class PapasTreeProducer(Analyzer):

    def beginLoop(self, setup):
        super(PapasTreeProducer, 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, 'iEv')

    def process(self, event):
        self.tree.reset()
        jets = getattr(event, self.cfg_ana.jets)
        if hasattr(event, 'iEv'):
            fill(self.tree, 'iEv', event.iEv)
        else:
            import pdb; pdb.set_trace()
        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( len(jets)>1 ):
            jet = jets[1]
            fillJet(self.tree, 'jet2', jet)
            if jet.match:
                fillJet(self.tree, 'jet2_rec', jet.match)
        self.tree.tree.Fill()

    def write(self, setup):
        self.rootfile.Write()
        self.rootfile.Close()