def __init__(self): path = os.path.join(os.path.dirname(__file__), 'CombinedMethod_ScaleFactors_RecoIdIsoSip.root') self.e_rtfile = rt.TFile(path, 'READ') self.e_hist = self.e_rtfile.Get("h_electronScaleFactor_RecoIdIsoSip") path = os.path.join(os.path.dirname(__file__), 'MuonScaleFactors_2011_2012.root') self.m_rtfile = rt.TFile(path, 'READ') self.m_hist = self.m_rtfile.Get("TH2D_ALL_2012") self.muPOGId = MuonPOGCorrections.make_muon_pog_PFTight_2012() self.muPOGIso = MuonPOGCorrections.make_muon_pog_PFRelIsoDB012_2012() m_id_file = open(os.path.join(os.path.dirname(__file__),'MuonEfficiencies_Run2012ReReco_53X.pkl'),'r') self.m_id_dict = pickle.load(m_id_file) m_iso_file = open(os.path.join(os.path.dirname(__file__),'MuonEfficiencies_ISO_Run_2012ReReco_53X.pkl'),'r') self.m_iso_dict = pickle.load(m_iso_file)
is7TeV = bool('7TeV' in os.environ['jobid']) print "Is 7TeV:", is7TeV # Make PU corrector from expected data PU distribution # PU corrections .root files from pileupCalc.py pu_distributions = { 'singlemu' : glob.glob(os.path.join( 'inputs', os.environ['jobid'], 'data_SingleMu*pu.root')), } mc_pu_tag = 'S6' if is7TeV else 'S10' #################### #2012 Corrections ################### muon_pog_IsoMu24eta2p1_2012 = MuonPOGCorrections.make_muon_pog_IsoMu24eta2p1_2012() #trigger muon_pog_PFTight_2012 = MuonPOGCorrections.make_muon_pog_PFTight_2012() #ID muon_pog_Iso_2012 = MuonPOGCorrections.make_muon_pog_PFRelIsoDB012_2012() #Iso muon_pog_IsoMu24eta2p1 = muon_pog_IsoMu24eta2p1_2012 muon_pog_PFTight = muon_pog_PFTight_2012 muon_pog_Iso = muon_pog_Iso_2012 ##################### # PU Corrections ##################### def make_puCorrector(dataset, kind=None): 'makes PU reweighting according to the pu distribution of the reference data and the MC, MC distribution can be forced' if not kind: kind = mc_pu_tag if dataset in pu_distributions: return PileupWeight.PileupWeight( 'S6' if is7TeV else 'S10', *(pu_distributions[dataset]))
# PU corrections .root files from pileupCalc.py pu_distributions = glob.glob( os.path.join( # 'inputs', os.environ['jobid'], 'data_TauPlusX*pu.root')) 'inputs', os.environ['jobid'], 'data_SingleMu*pu.root')) pu_corrector = PileupWeight.PileupWeight('S6' if is7TeV else 'S10', *pu_distributions) muon_pog_PFTight_2011 = MuonPOGCorrections.make_muon_pog_PFTight_2011() muon_pog_PFTight_2012 = MuonPOGCorrections.make_muon_pog_PFTight_2012() muon_pog_PFRelIsoDB02_2011 = MuonPOGCorrections.make_muon_pog_PFRelIsoDB012_2011( ) muon_pog_PFRelIsoDB02_2012 = MuonPOGCorrections.make_muon_pog_PFRelIsoDB012_2012( ) #muon_pog_IsoMu24eta2p1_2011 = MuonPOGCorrections.make_muon_pog_IsoMu24eta2p1_2011() // This does not exist, yet :-) muon_pog_IsoMu24eta2p1_2012 = MuonPOGCorrections.make_muon_pog_IsoMu24eta2p1_2012( ) # Get object ID and trigger corrector functions def mc_corrector_2011(row): if row.run > 2: return 1 pu = pu_corrector(row.nTruePU) #pu = 1 m1id = muon_pog_PFTight_2011(row.mPt, row.mEta) m1iso = muon_pog_PFRelIsoDB02_2011(row.mPt, row.mEta) # m_trg = H2TauCorrections.correct_mueg_mu_2011(row.mPt, row.mAbsEta)