Exemplo n.º 1
0
            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):
                jobs += [(sample.name, str(njob))]

        submitJobs(__file__, ('sample', 'subJob'),
                   jobs,
                   argParser,
                   jobLabel='calcSignalEfficiency')
        exit(0)

    #
    # Load in sample and chain
    #
    sample = getSampleFromList(sample_list, args.sample)
    chain = sample.initTree(needhcount=False)

    #
    # Import and create cutter to provide cut flow
    #
    from HNL.EventSelection.cutter import Cutter
    cutter = Cutter(chain=chain)

    if args.isTest:
        event_range = xrange(500)
    else:
        event_range = sample.getEventRange(args.subJob)

    if 'HNL' in sample.name:
        chain.HNLmass = float(sample.name.rsplit('-', 1)[1])
Exemplo n.º 2
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.º 3
0
 def getSample(self, name):
     sample = getSampleFromList(self.sample_list, name)
     self.sample_list = self.createSampleList()
     return sample