Exemple #1
0
    def __init__(self, name, path, working_points=None, misid_path=None):
        self.name = name
        self.path = path
        self.working_points = working_points

        if working_points is not None:
            self.chain = TChain(name, name)
            self.chain.var_roc = np.arange(0.5, len(working_points) + 0.5, 1)
            self.var = lambda c, i: c.var_roc[i]
            self.var_tex = 'workingpoints'
            self.bins = np.arange(0., len(working_points) + 1., 1)
        self.eff_numerator = None
        self.eff_denominator = None
        self.misid_numerator = None
        self.misid_denominator = None

        if self.working_points is not None:
            self.eff_numerator = Histogram(name + '_eff_numerator', self.var,
                                           self.var_tex, self.bins)
            self.misid_numerator = Histogram(name + '_misid_numerator',
                                             self.var, self.var_tex, self.bins)
            self.eff_denominator = Histogram(name + '_eff_denominator',
                                             self.var, self.var_tex, self.bins)
            self.misid_denominator = Histogram(name + '_misid_denominator',
                                               self.var, self.var_tex,
                                               self.bins)

        else:
            self.eff_numerator = Histogram(
                getObjFromFile(self.path,
                               name + '/' + name + '_eff_numerator'))
            self.eff_denominator = Histogram(
                getObjFromFile(self.path,
                               name + '/' + name + '_eff_denominator'))

            #Use different file for misid in case you split the jobs for signal and bkgr up
            tmp_path = misid_path if misid_path is not None else self.path
            self.misid_numerator = Histogram(
                getObjFromFile(tmp_path,
                               name + '/' + name + '_misid_numerator'))
            self.misid_denominator = Histogram(
                getObjFromFile(tmp_path,
                               name + '/' + name + '_misid_denominator'))
Exemple #2
0
 def getHist(self, subjob, name, subPath=None):
     if subPath is None: subPath = self.path
     if subPath.endswith('.root'):
         hCounter = getObjFromFile(subPath, 'blackJackAndHookers/' + name)
         return hCounter
     else:
         hCounter = None
         for f in self.filesInSubjob(subjob):
             if hCounter is None: hCounter = self.getHist(subjob, name, f)
             else: hCounter.Add(self.getHist(subjob, name, f))
             print hCounter.GetSumOfWeights()
         return hCounter
Exemple #3
0
def merge_specific_sample(sample_name, number_of_taus):
    
    #Outer loop over muon working points, we will keep these files separate
    for mu_cut_index in range(NUMBER_OF_MU_WP):
        number_of_bins_needed = NUMBER_OF_ELE_WP*NUMBER_OF_ISO_WP
        combined_hist = ROOT.TH1D("combined_hist"+sample_name+str(number_of_taus)+str(mu_cut_index), "combined_hist"+sample_name+str(number_of_taus)+str(mu_cut_index), number_of_bins_needed, 0, number_of_bins_needed)
    
        #Inner loop over electron working points, merge these into single plot
        for ele_cut_index in range(NUMBER_OF_ELE_WP):
            print basefolder+'/'+sample_name+'_'+number_of_taus+'_'+str(ele_cut_index)+'_'+str(mu_cut_index)+'.root'
            tmp_hist = getObjFromFile(basefolder+'/'+sample_name+'_'+number_of_taus+'_'+str(ele_cut_index)+'_'+str(mu_cut_index)+'.root', number_of_taus)
            nBins = tmp_hist.GetNbinsX()
            for tmp_hist_bin in range(1, nBins+1):
                combined_hist.SetBinContent(ele_cut_index*nBins+tmp_hist_bin, tmp_hist.GetBinContent(tmp_hist_bin))
                
    
        combined_hist.SaveAs(basefolder + '/Combined/'+ sample_name + '_'+number_of_taus + '_' + str(mu_cut_index)+ '.root')
Exemple #4
0
import ROOT
from helpers import getObjFromFile

#path = '/user/lwezenbe/public/ntuples/ewkino_trilep2/SMS-TChiSlepSnu_x0p5_TuneCUETP8M1_13TeV-madgraphMLM-pythia8.root'
#path = '/user/lwezenbe/public/ntuples/ewkino_trilep2/SMS-TChiStauStau_x0p5_TuneCUETP8M1_13TeV-madgraphMLM-pythia8.root'
path = '/user/lwezenbe/public/ntuples/ewkino_trilep2/SMS-TChiSlepSnu_tauenriched_x0p05_TuneCUETP8M1_13TeV-madgraphMLM-pythia8.root'

hCounterSUSY = getObjFromFile(path, 'hCounterSUSY')

xbins = hCounterSUSY.GetNbinsX()
ybins = hCounterSUSY.GetNbinsY()

print xbins, ybins

total_filled_bins = 0
for x in xrange(xbins):
    for y in xrange(ybins):
        cont = hCounterSUSY.GetBinContent(x, y)
        if cont > 0: total_filled_bins += 1

print total_filled_bins
Exemple #5
0
from plottingTools import plotDataVSMC
from helpers import getObjFromFile, makeDirIfNeeded, makePathTimeStamped
import ROOT

legendNames = ['Single top', 'VV','W+jets', 't#bar{t}', 'DYJets']
folderNames = ['TT', 'VV', 'WJets' ,"ST", "DYJets"]
#legendNames = ["STJets", "TTJets", "DYJets"]
#folderNames = ["ST", "TT", "DYJets"]
varNames = ["muPt", "tauPt", "muEta", "tauEta", "MT", "MVis", "dPhi", 'PZetaAll', 'PZEtaVis', 'PZeta']
xnames = ["p_{T}^{#mu} [GeV]", "p_{T}^{#tau} [GeV]", "#eta_{#mu}", "#eta_{#tau}", "M_{T} [GeV]", "M_{vis}(#mu, #tau) [GeV]", "#Delta #phi", "P_{#zeta}^{all}", "P_{#zeta}^{vis}", "P_{#zeta}"] 

basefolderOutput = makePathTimeStamped("/user/lwezenbe/private/PhD/Results/TauStudy/ReproduceAN2017_094/Plots")

for var, xn in zip(varNames, xnames):
    MChist = []
    for fn in folderNames:
        MChist.append(getObjFromFile("/user/lwezenbe/private/PhD/Results/TauStudy/ReproduceAN2017_094/Histos/Merged/" + fn + "/" + var + ".root", var))

    DataHist = getObjFromFile("/user/lwezenbe/private/PhD/Results/TauStudy/ReproduceAN2017_094/Histos/Merged/SingleMuon/"+var + ".root", var)

    plotDataVSMC(DataHist, MChist, xn, legendNames, "Full 2016 SingleMuon", basefolderOutput+ "/"+var) 
Exemple #6
0
varNames = [
    "muPt", "tauPt", "muEta", "tauEta", "MT", "MVis", "dPhi", 'PZetaAll',
    'PZEtaVis', 'PZeta'
]

samplesToMergeLocation = [
    "DYJets", 'DYJets_bkgr', "ST", "TT", "VV", "WJets", "QCD", "SingleMuon"
]

for name in samplesToMergeLocation:
    for var in varNames:
        hist = []
        listOfFiles = glob.glob(
            "/user/lwezenbe/private/PhD/Results/TauStudy/ReproduceAN2017_094/Histos/"
            + name + "/" + var + "_Hist*.root")
        for f in listOfFiles:
            hist.append(getObjFromFile(f, var))
        mergedHist = None
        for h in hist:
            if (hist.index(h) == 0): mergedHist = h.Clone(var)
            else: mergedHist.Add(h)

        mergedHist.SaveAs(
            "/user/lwezenbe/private/PhD/Results/TauStudy/ReproduceAN2017_094/Histos/Merged/"
            + name + "/" + var + ".root")

        for f in listOfFiles:
            subprocess.check_output("rm " + f,
                                    shell=True,
                                    stderr=subprocess.STDOUT)
Exemple #7
0
 def loadMisid(self, name, path):
     self.misid_numerator = getObjFromFile(path, name + '_misid_numerator')
     self.misid_denominator = getObjFromFile(path,
                                             name + '_misid_denominator')
Exemple #8
0
 def loadEfficiency(self, name, path):
     self.eff_numerator = getObjFromFile(path, name + '_eff_numerator')
     self.eff_denominator = getObjFromFile(path, name + '_eff_denominator')