def build_roofunctor_dict(basename, wsname = 'fit_efficiency', functor_name = 'efficiency'):
    ret = {}
    for i in optimizer.lep_id:
        ret[i] = build_roofunctor(
            basename % i,
            wsname, # workspace name
            functor_name
            )
    return ret
def build_roofunctor_dict(basename, wsname = 'fit_efficiency', functor_name = 'efficiency', mapper = None):
    ret = {}
    for i in optimizer.lep_id:
        lepid = i
        if mapper:
            lepid = mapper(lepid)
        ret[i] = build_roofunctor(
            basename % lepid,
            wsname, # workspace name
            functor_name
            )
    return ret
def build_2Droofunctor_dict(basename, 
                            xvar, yvar,
                            wsname = 'fit_efficiency', functor_name = 'efficiency', mapper = None):
    ret = {}
    for i in optimizer.lep_id:
        lepid = i
        if mapper:
            lepid = mapper(lepid)
        ret[i] = build_uncorr_2Droofunctor(
            build_roofunctor(
                basename % (lepid, xvar),
                wsname, # workspace name
                functor_name
            ),
            build_roofunctor(
                basename % (lepid, yvar),
                wsname, # workspace name
                functor_name
            ),
            (basename % (lepid, yvar)).replace('.root','.corrected_inputs.root'),
            )
    return ret
Beispiel #4
0
def build_roofunctor_dict(basename,
                          wsname='fit_efficiency',
                          functor_name='efficiency',
                          mapper=None):
    ret = {}
    for i in optimizer.lep_id:
        lepid = i
        if mapper:
            lepid = mapper(lepid)
        ret[i] = build_roofunctor(
            basename % lepid,
            wsname,  # workspace name
            functor_name)
    return ret
Beispiel #5
0
def build_2Droofunctor_dict(basename,
                            xvar,
                            yvar,
                            wsname='fit_efficiency',
                            functor_name='efficiency',
                            mapper=None):
    ret = {}
    for i in optimizer.lep_id:
        lepid = i
        if mapper:
            lepid = mapper(lepid)
        ret[i] = build_uncorr_2Droofunctor(
            build_roofunctor(
                basename % (lepid, xvar),
                wsname,  # workspace name
                functor_name),
            build_roofunctor(
                basename % (lepid, yvar),
                wsname,  # workspace name
                functor_name),
            (basename % (lepid, yvar)).replace('.root',
                                               '.corrected_inputs.root'),
        )
    return ret
#EET
highpt_ee_fr = make_mva_functor_dict(frfit_dir + '/ee_wjetsNoZmass_pt20_%s_electronInfo.kNN.weights.xml', variables) 
lowpt_ee_fr  = make_mva_functor_dict(frfit_dir + '/ee_wjetsNoZmass_pt10_%s_electronInfo.kNN.weights.xml', variables) 

highpt_ee_qcd_fr = make_mva_functor_dict(frfit_dir + '/ee_qcd_pt20_%s_electronInfo.kNN.weights.xml', variables) 
lowpt_ee_qcd_fr  = make_mva_functor_dict(frfit_dir + '/ee_qcd_pt10_%s_electronInfo.kNN.weights.xml', variables) 


##################
## 1D Taus Func ##
##################

tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

tau_qcd_fr = tau_fr 

e_charge_flip      = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_%s.root", "efficiency_map")         
e_charge_flip_up   = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_%s.root", "efficiency_map_statUp")  
e_charge_flip_down = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_%s.root", "efficiency_map_statDown")
mass_scaler        = make_scaler_dict(frfit_dir+"/charge_flip_prob_map_%s.root", 'mass_scale')
default_scaler     = mass_scaler[mass_scaler.keys()[0]]


e1_charge_flip      = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_e1_%s.root", "efficiency_map")         
e1_charge_flip_up   = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_e1_%s.root", "efficiency_map_statUp")  
e1_charge_flip_down = make_corrector_dict(frfit_dir+"/charge_flip_prob_map_e1_%s.root", "efficiency_map_statDown")
Beispiel #7
0
import glob
from MuMuTauTree import MuMuTauTree
import os
import FinalStateAnalysis.TagAndProbe.MuonPOGCorrections as MuonPOGCorrections
import FinalStateAnalysis.TagAndProbe.PileupWeight as PileupWeight
import WHAnalyzerBase
import ROOT

################################################################################
#### Fitted fake rate functions ################################################
################################################################################

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
highpt_mu_fr = build_roofunctor(
    frfit_dir + '/m_wjets_pt20_pfidiso02_muonJetPt.root',
    'fit_efficiency',  # workspace name
    'efficiency')
lowpt_mu_fr = build_roofunctor(
    frfit_dir + '/m_wjets_pt10_pfidiso02_muonJetPt.root',
    'fit_efficiency',  # workspace name
    'efficiency')

tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt.root',
    'fit_efficiency',  # workspace name
    'efficiency')

################################################################################
#### MC-DATA and PU corrections ################################################
################################################################################
import glob
from MuMuTauTree import MuMuTauTree
import os
import FinalStateAnalysis.TagAndProbe.MuonPOGCorrections as MuonPOGCorrections
import FinalStateAnalysis.TagAndProbe.PileupWeight as PileupWeight
import WHAnalyzerBase
import ROOT

################################################################################
#### Fitted fake rate functions ################################################
################################################################################

# Get fitted fake rate functions
frfit_dir = os.path.join("results", os.environ["jobid"], "fakerate_fits")
highpt_mu_fr = build_roofunctor(
    frfit_dir + "/m_wjets_pt20_pfidiso02_muonJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)
lowpt_mu_fr = build_roofunctor(
    frfit_dir + "/m_wjets_pt10_pfidiso02_muonJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)


tau_fr = build_roofunctor(
    frfit_dir + "/t_ztt_pt20_mvaloose_tauPt.root", "fit_efficiency", "efficiency"  # workspace name
)

################################################################################
#### MC-DATA and PU corrections ################################################
################################################################################

# Determine MC-DATA corrections
Beispiel #9
0
import os
import re
import glob
import ROOT
from math import sqrt
from FinalStateAnalysis.StatTools.RooFunctorFromWS import build_roofunctor, make_corrector_from_histo

frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits') + '/'

tau_fake_rate = build_roofunctor(frfit_dir + 't_os_tLoose_tTigh_tAbsEta.root',
                                 'fit_efficiency', 'efficiency')


def inflate_systematics(functor, inflation):
    '''Christian recipe: INFLATE ALL THE SYSTEMATICS!'''
    def fcn(*args):
        return functor(*args) * inflation

    return fcn

    #tau_fake_rate_up = inflate_systematics(tau_fake_rate, 1.3)
    #tau_fake_rate_dw = inflate_systematics(tau_fake_rate, 0.7)


###Tau fakes as it should be
tau_fake_rate_up = make_corrector_from_histo(
    frfit_dir + 't_os_tLoose_tTigh_tAbsEta_2.root', 'efficiency_up', '1D')

tau_fake_rate_dw = make_corrector_from_histo(
    frfit_dir + 't_os_tLoose_tTigh_tAbsEta_2.root', 'efficiency_dw', '1D')
'''

from EETauTree import EETauTree
from FinalStateAnalysis.StatTools.RooFunctorFromWS import build_roofunctor
import os
#from PUWeighting import pu_weight
pu_weight=1.0
import ROOT
import WHAnalyzerBase

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
highpt_e_fr = build_roofunctor(
    frfit_dir + '/e_wjets_pt10_mvaidiso02_eJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
lowpt_e_fr = build_roofunctor(
    frfit_dir + '/e_wjets_pt10_mvaidiso03_eJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

# Get correction functions
ROOT.gSystem.Load("Corrector_C")
Beispiel #11
0
# mu_loose_fr = build_roofunctor( #lambda x: 0.1
#    frfit_dir + '/m_zlt_pt10_looseId_muonPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
# )

# e_loose_fr =build_roofunctor( #lambda x: 0.2
#    frfit_dir + '/e_zlt_pt10_looseId_electronPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
# )


mu_tight_jetpt_fr = build_roofunctor(  # lambda x: 0.1
    frfit_dir + "/m_zlt_pt10_tightId_muonJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)

e_tight_jetpt_fr = build_roofunctor(  # lambda x: 0.2
    frfit_dir + "/e_zlt_pt10_tightId_electronJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)

mu_loose_jetpt_fr = build_roofunctor(  # lambda x: 0.1
    frfit_dir + "/m_zlt_pt10_looseId_muonJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)

e_loose_jetpt_fr = build_roofunctor(  # lambda x: 0.2
    frfit_dir + "/e_zlt_pt10_looseId_electronJetPt.root", "fit_efficiency", "efficiency"  # workspace name
)

## /e_zlt_pt10_looseId_electronJetPt.root
Beispiel #12
0
Analyze EET events for the WH analysis

'''

from EETauTree import EETauTree
from FinalStateAnalysis.StatTools.RooFunctorFromWS import build_roofunctor
import os
from PUWeighting import pu_weight
import ROOT
import WHAnalyzerBase

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
highpt_ee_fr = build_roofunctor(
    frfit_dir + '/ee_wjets_pt20_mvaidiso01_e2JetPt-data_ee.root',
    'fit_efficiency',  # workspace name
    'efficiency')
lowpt_ee_fr = build_roofunctor(
    frfit_dir + '/ee_wjets_pt10_mvaidiso01_e2JetPt-data_ee.root',
    'fit_efficiency',  # workspace name
    'efficiency')
tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt-data_mm.root',
    'fit_efficiency',  # workspace name
    'efficiency')

# Get correction functions
ROOT.gSystem.Load("Corrector_C")


class WHAnalyzeEET(WHAnalyzerBase.WHAnalyzerBase):
import os
from FinalStateAnalysis.StatTools.RooFunctorFromWS import build_roofunctor

################################################################################
#### Fitted fake rate functions ################################################
################################################################################

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
mu_tight_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_tightId_muonPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

e_tight_fr =build_roofunctor( #lambda x: 0.2
    frfit_dir + '/e_zlt_pt10_tightId_electronPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

mu_loose_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_looseId_muonPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

e_loose_fr =build_roofunctor( #lambda x: 0.2
    frfit_dir + '/e_zlt_pt10_looseId_electronPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
Beispiel #14
0
data_views.log.setLevel(logging.INFO)
#import sys
#logging.basicConfig(stream=sys.stderr, level=logging.INFO)
import WHAnalyzerBase
import ROOT
from TwoDimFakeRate import TwoDimFakeRate

################################################################################
#### Fitted fake rate functions ################################################
################################################################################

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
highpt_mu_fr = build_roofunctor(
    #frfit_dir + '/m_wjets_pt20_pfidiso02_muonJetPt.root',
    frfit_dir + '/m_wjets_pt20_h2taucuts_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
lowpt_mu_fr = build_roofunctor(
    #frfit_dir + '/m_wjets_pt10_pfidiso02_muonJetPt.root',
    frfit_dir + '/m_wjets_pt10_h2taucuts_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

highpt_mu_qcd_fr = build_roofunctor(
Beispiel #15
0
Analyze EET events for the WH analysis

'''

from EETauTree import EETauTree
from FinalStateAnalysis.StatTools.RooFunctorFromWS import build_roofunctor
import os
from PUWeighting import pu_weight
import ROOT
import WHAnalyzerBase

# Get fitted fake rate functions
frfit_dir = os.path.join('results', os.environ['jobid'], 'fakerate_fits')
highpt_ee_fr = build_roofunctor(
    frfit_dir + '/ee_wjets_pt20_mvaidiso01_e2JetPt-data_ee.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
lowpt_ee_fr = build_roofunctor(
    frfit_dir + '/ee_wjets_pt10_mvaidiso01_e2JetPt-data_ee.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt-data_mm.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

# Get correction functions
ROOT.gSystem.Load("Corrector_C")
Beispiel #16
0
#mu_loose_fr = build_roofunctor( #lambda x: 0.1
#    frfit_dir + '/m_zlt_pt10_looseId_muonPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)

#e_loose_fr =build_roofunctor( #lambda x: 0.2
#    frfit_dir + '/e_zlt_pt10_looseId_electronPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)


mu_tight_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_tightId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

#e_tight_jetpt_fr =build_roofunctor( #lambda x: 0.2
#    frfit_dir + '/e_zlt_pt10_tightId_electronJetPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)

mu_loose_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_looseId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
Beispiel #17
0
    variables)
lowpt_ee_fr = make_mva_functor_dict(
    frfit_dir + '/ee_wjetsNoZmass_pt10_%s_electronInfo.kNN.weights.xml',
    variables)

highpt_ee_qcd_fr = make_mva_functor_dict(
    frfit_dir + '/ee_qcd_pt20_%s_electronInfo.kNN.weights.xml', variables)
lowpt_ee_qcd_fr = make_mva_functor_dict(
    frfit_dir + '/ee_qcd_pt10_%s_electronInfo.kNN.weights.xml', variables)

##################
## 1D Taus Func ##
##################

tau_fr = build_roofunctor(
    frfit_dir + '/t_ztt_pt20_mvaloose_tauPt.root',
    'fit_efficiency',  # workspace name
    'efficiency')

tau_qcd_fr = tau_fr

e_charge_flip = make_corrector_dict(
    frfit_dir + "/charge_flip_prob_map_%s.root", "efficiency_map")
e_charge_flip_up = make_corrector_dict(
    frfit_dir + "/charge_flip_prob_map_%s.root", "efficiency_map_statUp")
e_charge_flip_down = make_corrector_dict(
    frfit_dir + "/charge_flip_prob_map_%s.root", "efficiency_map_statDown")
mass_scaler = make_scaler_dict(frfit_dir + "/charge_flip_prob_map_%s.root",
                               'mass_scale')
default_scaler = mass_scaler[mass_scaler.keys()[0]]

e1_charge_flip = make_corrector_dict(
#mu_loose_fr = build_roofunctor( #lambda x: 0.1
#    frfit_dir + '/m_zlt_pt10_looseId_muonPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)

#e_loose_fr =build_roofunctor( #lambda x: 0.2
#    frfit_dir + '/e_zlt_pt10_looseId_electronPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)


mu_tight_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_tightId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

e_tight_jetpt_fr =build_roofunctor( #lambda x: 0.2
    frfit_dir + '/e_zlt_pt10_tightId_electronJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

mu_loose_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_looseId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)
Beispiel #19
0
#mu_loose_fr = build_roofunctor( #lambda x: 0.1
#    frfit_dir + '/m_zlt_pt10_looseId_muonPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)

#e_loose_fr =build_roofunctor( #lambda x: 0.2
#    frfit_dir + '/e_zlt_pt10_looseId_electronPt.root',
#    'fit_efficiency', # workspace name
#    'efficiency'
#)


mu_tight_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_tightId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

e_tight_jetpt_fr =build_roofunctor( #lambda x: 0.2
    frfit_dir + '/e_zlt_pt10_tightId_electronJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)

mu_loose_jetpt_fr = build_roofunctor( #lambda x: 0.1
    frfit_dir + '/m_zlt_pt10_looseId_muonJetPt.root',
    'fit_efficiency', # workspace name
    'efficiency'
)