Exemplo n.º 1
0
Arquivo: ROC.py Projeto: gmestdac/HNL
    def write(self, append=False):
        append_string = 'recreate'
        if append and isValidRootFile(self.path): append_string = 'update'

        makeDirIfNeeded(self.path)
        output_file = TFile(self.path, append_string)
        output_file.mkdir(self.name)
        output_file.cd(self.name)

        self.eff_numerator.getHist().Write()
        self.eff_denominator.getHist().Write()
        self.misid_numerator.getHist().Write()
        self.misid_denominator.getHist().Write()
        output_file.Close()
Exemplo n.º 2
0
def savePlots(Canv, destination):
    destination_components = destination.split('/')
    cleaned_components = [
        x for x in destination_components if not isTimeStampFormat(x)
    ]
    index_for_php = cleaned_components.index('Results')
    php_destination = '/user/lwezenbe/public_html/'
    php_destination += '/'.join(cleaned_components[index_for_php + 1:])
    makeDirIfNeeded(php_destination.rsplit('/', 1)[0])
    os.system('cp -rf /user/lwezenbe/private/PhD/index.php ' +
              php_destination.rsplit('/', 1)[0] + '/index.php')

    print destination

    Canv.SaveAs(destination + ".pdf")
    Canv.SaveAs(destination + ".png")
    Canv.SaveAs(destination + ".root")

    Canv.SaveAs(php_destination + ".pdf")
    Canv.SaveAs(php_destination + ".png")
    Canv.SaveAs(php_destination + ".root")
Exemplo n.º 3
0
import ROOT, subprocess
import subSample
import jobSubmitter as sub
from helpers import makeDirIfNeeded

import argparse
argParser = argparse.ArgumentParser(description = "Argument parser")
argParser.add_argument('--year',        action='store',         default='2016')
argParser.add_argument('--skim',        action='store',         default='FR')
argParser.add_argument('--analysis',        action='store',         default='ewkino')

args = argParser.parse_args()

files_to_skim = subSample.createSampleList('Data/'+args.analysis+'_'+args.year+'.conf')
makeDirIfNeeded('/user/lwezenbe/public/ntuples/'+args.year+'/'+args.skim+'/Log')

for f in files_to_skim:
    number_of_subdir = int(subprocess.check_output("/bin/ls -lA " + f + "/* | egrep -c '^-|^d'", shell=True, stderr=subprocess.STDOUT))
    for subdir in xrange(number_of_subdir):
        subsample = subSample.subSample(f, subdir)
        nJobs = len(subsample.arrangeFilesInSubjobs())
        for job in xrange(nJobs):
            log = '/user/lwezenbe/public/ntuples/'+args.year+'/'+args.skim+'/Log/'+subsample.group+'_'+subsample.name+ '_'+ str(subdir)+ '_' +str(job)+'.log'   #temporary lazy log
            command = 'python /storage_mnt/storage/user/lwezenbe/private/PhD/Code/TauStudy/Skimmer/main.py --path='+f+' --subDir='+ str(subdir)+ ' --subJob=' +str(job) + ' --skim=' + args.skim + ' --year='+args.year
            name = subsample.group+'_'+subsample.name+ '_'+ str(subdir)+ '_' +str(job)
            sub.launchCream02(command, log, False, str(job)+ '_'+args.skim+'_' + name)

Exemplo n.º 4
0
)
argParser.add_argument('--year', action='store', default='2016')
argParser.add_argument('--skim', action='store', default='ewkino')
argParser.add_argument('--isTest', action='store', default=False)

args = argParser.parse_args()

sample_name = args.path.rsplit('/')[-1].rsplit('.')[0]
print sample_name
sample = Sample(sample_name, args.path, sample_name, 1,
                '1')  #xsec not used here, so put to 1
Chain = sample.initTree()

#Create output file
output_dir = '/user/lwezenbe/public/ntuples/' + args.year + '/' + args.skim + '_v5wDeepCsvInvMET'
makeDirIfNeeded(output_dir)

output_file = TFile(output_dir + '/' + sample.output + '.root', 'recreate')
output_file.mkdir('blackJackAndHookers')
output_file.cd('blackJackAndHookers')

#Get hcounters
import eventSelection
isData = eventSelection.isData(sample.name)
if not isData: hCounter = sample.getHist('hCounter')
if 'TChi' in sample.name: hCounterSUSY = sample.getHist('hCounterSUSY')

#initialize new tree and delete unused branches
#branches_to_delete = ['HLT', 'Trigger', 'Flag', 'nLhe', 'IP', 'lElectron', 'leptonMva', 'relIso', 'miniIso', 'closestJet', 'lMuon', '_ph', 'HN']
#branches_to_delete = ['HLT_IsoMu22','HLT_MET','HLT_PFMET', 'HLT_PFHT', 'HLT_CaloJet', 'nLhe', 'lMuon', '_ph', 'HN', 'deepTau', 'Flag']
#for branch in branches_to_delete:
Exemplo n.º 5
0
import ROOT, os, glob
import subSample
import jobSubmitter as sub
from helpers import makeDirIfNeeded

basefolderInput = '/user/lwezenbe/public/heavyNeutrino'
basefolderOutput = '/user/lwezenbe/public/trilep/SkimmedTuples'
makeDirIfNeeded(basefolderOutput)

list_of_samples = glob.glob(basefolderInput + '/*')

for f in list_of_samples:
    name = f.rsplit('/', 1)[1]
    command = 'hadd ' + basefolderOutput + '/' + name + '.root ' + f + '/*.root'
    os.system(command)

#####OLD CODE###########
#different_samples = set()
#for f in list_of_samples:
#    split_f = f.split('/')
#    different_samples.add(split_f[8])
#
#for s in different_samples:
#    samples_to_hadd = ['hadd ' + basefolderOutput + '/' + s + '.root']
#    for f in list_of_samples:
#        if s in f:
#            samples_to_hadd.append(f + '/*/*/*.root')
#    command = ' '.join(samples_to_hadd)
#    log = basefolderOutput + '/' + s + '.log'
#    sub.launchCream02(command, log)
Exemplo n.º 6
0
argParser = argparse.ArgumentParser(description = "Argument parser")
#argParser.add_argument('--path',        action='store',         default='/pnfs/iihe/cms/store/user/lwezenbe/heavyNeutrino/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/crab_MiniAOD2016v3_ext1-v2_ewkino2016MCList-v32')
argParser.add_argument('--path',        action='store',         default='/pnfs/iihe/cms/store/user/lwezenbe/heavyNeutrino/DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/crab_MiniAOD2016v3_v2_ewkino2016MCList-v32')
#argParser.add_argument('--path',        action='store',         default='/pnfs/iihe/cms/store/user/lwezenbe/heavyNeutrino/DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/crab_Moriond2017-v1_tau_MC_trilepwOneTau_v2')
argParser.add_argument('--subDir',      action='store',         default=0)
argParser.add_argument('--subJob',      action='store',         default=0)
argParser.add_argument('--analysis',    action='store',         default='ewkino')
argParser.add_argument('--isTest',      action='store',         default=False)

args = argParser.parse_args()

subsample = subSample.subSample(args.path, int(args.subDir))
Chain = subsample.initChain(int(args.subJob))

#Create output file
makeDirIfNeeded('/user/lwezenbe/public/ntuples/2016/ewkino_Oldtrilep/tmp_'+subsample.group)
output_file = TFile('/user/lwezenbe/public/ntuples/2016/ewkino_Oldtrilep/tmp_'+subsample.group+'/'+subsample.group+'_'+ subsample.name+'_' +str(args.subDir)+'_'+str(args.subJob)+'.root', 'recreate')
output_file.mkdir('blackJackAndHookers')
output_file.cd('blackJackAndHookers')

#Get hcounters
if subsample.group != 'SingleMuon':      hCounter = subsample.getHist(int(args.subJob), 'hCounter')
if 'TChi' in subsample.group:            hCounterSUSY = subsample.getHist(int(args.subJob), 'hCounterSUSY')
print type(Chain)
#initialize new tree and delete unused branches
branches_to_delete = ['HLT', 'Trigger', 'Flag', 'nLhe', 'IP', 'lElectron', 'leptonMva', 'lHN', 'relIso', 'miniIso', 'closestJet', 'lMuon', '_ph', 'HN']
for branch in branches_to_delete:
    Chain.SetBranchStatus('*'+branch+'*', 0)
output_tree = Chain.CloneTree(0)

if args.isTest: