Exemplo n.º 1
0
        mcProfile = useMC
    mcProfile.Scale(1. / mcProfile.Integral())

    # Create reweighting histo
    reweightingHisto = histoData.Clone('reweightingHisto')
    reweightingHisto.Divide(mcProfile)

    # Define reweightingFunc
    def reweightingFunc(nTrueInt):
        return reweightingHisto.GetBinContent(
            reweightingHisto.FindBin(nTrueInt))

    return reweightingFunc


if __name__ == '__main__':
    from HNL.Samples.sample import createSampleList, getSampleFromList
    from HNL.Tools.logger import getLogger, closeLogger
    log = getLogger('INFO')

    input_file = os.path.expandvars(
        '$CMSSW_BASE/src/HNL/Samples/InputFiles/samples_for_testing.conf')
    sample_list = createSampleList(input_file)
    sample = getSampleFromList(sample_list, 'DYJetsToLL-M-10to50')

    chain = sample.initTree()
    chain.GetEntry(5)
    chain.year = 2016
    pu = getReweightingFunction(chain.year, 'central')
    print pu(chain._nTrueInt)
    closeLogger(log)
Exemplo n.º 2
0
#
if args.isTest:
    args.isChild = True

    args.sample = 'HNLtau-60'
    args.subJob = '0'
    args.year = '2016'

#
# Load in the sample list
#
from HNL.Samples.sample import createSampleList, getSampleFromList
list_location = os.path.expandvars(
    '$CMSSW_BASE/src/HNL/Samples/InputFiles/sampleList_' + args.year +
    '_noskim.conf')
sample_list = createSampleList(list_location)

if not args.plotCutFlow:
    #
    # Submit subjobs
    #
    if not args.isChild:
        from HNL.Tools.jobSubmitter import submitJobs
        jobs = []
        for sample in sample_list:
            if args.sample and args.sample not in sample.name: continue
            if not 'HNLtau' in sample.name: continue
            if args.masses is not None and 'HNL' in sample.name and not any(
                [str(m) in sample.name for m in args.masses]):
                continue
            for njob in xrange(sample.split_jobs):
Exemplo n.º 3
0
from HNL.Samples.sample import createSampleList
from HNL.Tools.helpers import makeDirIfNeeded
import glob
import os

list_of_samplelists = glob.glob(
    os.path.expandvars('$CMSSW_BASE/src/HNL/Samples/InputFiles/*noskim*conf'))

for sl in list_of_samplelists:
    name = sl.split('/')[-1].split('.')[0]
    print 'Checking ' + name
    out_name = os.path.expandvars(
        '$CMSSW_BASE/src/HNL/Samples/InputFiles/InputFileTests/' + name +
        '.txt')
    makeDirIfNeeded(out_name)
    out_file = open(out_name, 'w')
    sample_list = createSampleList(sl)
    for sample in sample_list:
        try:
            chain = sample.initTree(needhcount=False)
        except:
            out_file.write('Problem in ' + sample.name + '\n')

    out_file.close()
Exemplo n.º 4
0
from HNL.Samples.sample import Sample, createSampleList
from HNL.Tools.helpers import isValidRootFile, makeDirIfNeeded
import glob
import os

list_of_samplelists = glob.glob(
    os.path.expandvars('$CMSSW_BASE/src/HNL/Samples/InputFiles/*conf'))

for sl in list_of_samplelists:
    name = sl.split('/')[-1].split('.')[0]
    print 'Checking ' + name
    out_name = os.path.expandvars(
        '$CMSSW_BASE/src/HNL/Samples/InputFiles/InputFileTests/' + name +
        '.txt')
    makeDirIfNeeded(out_name)
    out_file = open(out_name, 'w')
    sample_list = createSampleList(sl, True)
    for sample in sample_list:
        try:
            chain = sample.initTree(needhcount=False)
        except:
            out_file.write('Problem in ' + sample.name + '\n')

    out_file.close()
Exemplo n.º 5
0
                       action='store_true',
                       default=False,
                       help='do not launch subjobs, only show them')
argParser.add_argument('--plotSoftTau',
                       action='store_true',
                       default=False,
                       help='Extra overlay of softest tau in the process')
args = argParser.parse_args()

args = argParser.parse_args()
print 'Loading in samples'

#Load in samples and get the specific sample for this job
from HNL.Samples.sample import createSampleList, getSampleFromList
sample_list = createSampleList(
    os.path.expandvars(
        '$CMSSW_BASE/src/HNL/Samples/InputFiles/signalCompression.conf'))

#
# Change some settings if this is a test
#
if args.isTest:
    args.isChild = True
    args.sample = 'HNLtau-M10'
    args.subJob = '0'

if not args.isChild:
    from HNL.Tools.jobSubmitter import submitJobs
    jobs = []
    for sample in sample_list:
        for njob in xrange(sample.split_jobs):