示例#1
0
    sample = sample_manager.getSample(args.sample)
    if not args.inData and 'Data' in sample.name: exit(0)
    chain = sample.initTree(needhcount=False)
    chain.HNLmass = sample.getMass()
    chain.year = int(args.year)

    #
    # Initialize reweighter
    #
    reweighter = Reweighter(sample, sample_manager)

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

    #
    # Set range of events to process
    #
    if args.isTest:
        max_events = 20000
        event_range = xrange(max_events) if max_events < len(
            sample.getEventRange(args.subJob)) else sample.getEventRange(
                args.subJob)
    else:
        event_range = sample.getEventRange(args.subJob)

    #
    # Get luminosity weight
    #
示例#2
0
    print "Submitted "+str(len(jobs))+" jobs to cream"
    exit(0)

#
#Get specific sample for this subjob
#
sample = sample_manager.getSample(args.sample)
chain = sample.initTree()
chain.year = int(args.year)
chain.is_signal = 'HNL' in sample.name

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

#
# Get lumiweight
#
from HNL.Weights.lumiweight import LumiWeight
lw = LumiWeight(sample, sample_manager)

#
# Create new reduced tree (except if it already exists and overwrite option is not used)
#
from HNL.Tools.helpers import isValidRootFile, makeDirIfNeeded
gen_name = 'Reco' if not args.genSkim else 'Gen'
if sample.is_data:
    output_file_name = 'Data'
elif chain.is_signal: 
示例#3
0
from HNL.EventSelection.eventSelector import EventSelector
from HNL.EventSelection.eventCategorization import EventCategory, filterSuperCategory
from HNL.EventSelection.signalLeptonMatcher import SignalLeptonMatcher
slm = SignalLeptonMatcher(chain)
ec = EventCategory(chain)
es = EventSelector('baseline',
                   chain,
                   chain,
                   is_reco_level=False,
                   event_categorization=ec)

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

#Loop over events
for entry in eventRange:

    #print progress and load in entry
    progress(entry - eventRange[0], len(eventRange))
    chain.GetEntry(entry)

    if not es.passedFilter(cutter, sample.output): continue
    slm.saveNewOrder()
    category = ec.returnCategory()
    if not filterSuperCategory('SingleTau', category): continue
    # print category, entry
    # if chain._gen_nL < 3: continue
示例#4
0
        list_of_hist[sample.name] = {}

        #
        # Load in sample and chain
        #
        chain = sample.initTree(needhcount=False)
        sample_names.append(sample.name)

        for v in var:
            list_of_hist[sample.name][v] = Histogram(sample.output + '-' + v,
                                                     var[v][0], var[v][2],
                                                     var[v][1])

        from HNL.EventSelection.cutter import Cutter
        cutter = Cutter(chain=chain)

        #
        # Get luminosity weight
        #
        from HNL.Weights.lumiweight import LumiWeight
        lw = LumiWeight(sample, sample_manager)

        #
        # Set event range
        #
        if args.isTest:
            max_events = 20000
            event_range = xrange(max_events) if max_events < len(
                sample.getEventRange(args.subJob)) else sample.getEventRange(
                    args.subJob)
示例#5
0
    #
    #Get specific sample for this subjob
    #
    sample = sample_manager.getSample(args.sample)
    chain = sample.initTree(needhcount=False)
    chain.year = int(args.year)
    chain.is_signal = 'HNL' in sample.name
    chain.selection = args.selection
    chain.strategy = args.strategy

    reweighter = Reweighter(sample, sample_manager)

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

    #
    # Create new reduced tree (except if it already exists and overwrite option is not used)
    #
    output_base = os.path.expandvars(
        os.path.join('/user/$USER/public/ntuples/HNL')
    ) if not args.isTest else os.path.expandvars(
        os.path.join('$CMSSW_BASE', 'src', 'HNL', 'TMVA', 'data', 'testArea'))

    signal_str = 'Signal' if chain.is_signal else 'Background'
    output_name = os.path.join(
        output_base, 'TMVA', str(args.year),
        args.region + '-' + args.selection, signal_str, 'tmp_' + sample.output,
        sample.name + '_' + sample.output + '_' + str(args.subJob) + '.root')
    makeDirIfNeeded(output_name)
示例#6
0
        exit(0)

    #
    # Load in sample and chain
    #
    if not args.includeData and args.sample == 'Data':
        raise RuntimeError(
            'Trying to run data while it is not allowed. Stopping the program')
    sample = sample_manager.getSample(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:
        max_events = 2000
        event_range = xrange(max_events) if max_events < len(
            sample.getEventRange(args.subJob)) else sample.getEventRange(
                args.subJob)
    else:
        event_range = sample.getEventRange(args.subJob)

    chain.HNLmass = sample.getMass()
    chain.year = int(args.year)

    #
    # Get luminosity weight
    #
示例#7
0
                   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])
    chain.year = int(args.year)

    #
    # Loop over all events
    #
    from HNL.Tools.helpers import progress
    from HNL.ObjectSelection.tauSelector import tau_DMfinding, isCleanFromLightLeptons, passedMuonDiscr, passedElectronDiscr, tau_id_WP, isGoodGenTau
示例#8
0
        #
        # Some basic variables about the sample to store in the chain
        #
        chain.HNLmass = sample.getMass()
        chain.year = int(args.year)

        #
        # Skip HNL masses that were not defined
        #
        if args.masses is not None and chain.HNLmass not in args.masses: continue

        #
        # Create cutter to provide cut flow
        #
        cutter = Cutter(chain = chain)

        #
        # Loop over all events
        #
        ec = EventCategory(chain)
        es = EventSelector(args.region, args.selection, object_selection_param, not args.genLevel, ec)
        for entry in event_range:
            
            chain.GetEntry(entry)
            progress(entry - event_range[0], len(event_range))
 
            cutter.cut(True, 'Total')

            #
            #Triggers
示例#9
0
                jobs += [(sample.name, str(njob))]

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

    #
    # Load in sample and chain
    #
    sample = sample_manager.getSample(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(1000)
    else:
        event_range = sample.getEventRange(args.subJob)    

    chain.HNLmass = sample.getMass()
    chain.year = int(args.year)

    #
    # Get luminosity weight
    #
    from HNL.Weights.lumiweight import LumiWeight
    if args.noskim:
        lw = LumiWeight(sample, sample_manager)
示例#10
0
                   jobs,
                   argParser,
                   jobLabel='closureTest')
        exit(0)

    #
    # Load in sample and chain
    #
    sample = sample_manager.getSample(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:
        max_events = 20000
        event_range = xrange(max_events) if max_events < len(
            sample.getEventRange(args.subJob)) else sample.getEventRange(
                args.subJob)
    else:
        event_range = sample.getEventRange(args.subJob)

    chain.HNLmass = sample.getMass()
    chain.year = int(args.year)
    chain.selection = args.selection

    #
    # Get luminosity weight
示例#11
0
        #
        # Some basic variables about the sample to store in the chain
        #
        chain.HNLmass = sample.getMass()
        chain.year = int(args.year)

        #
        # Skip HNL masses that were not defined
        #
        if args.masses is not None and chain.HNLmass not in args.masses:
            continue

        #
        # Create cutter to provide cut flow
        #
        cutter = Cutter(chain=chain)

        #
        # Initialize reweighter
        #
        reweighter = Reweighter(sample, sample_manager)

        #
        # Load in MVA reader if needed
        #
        if args.strategy == 'MVA':
            tmva = {}
            for sel in ['lowMassSR', 'highMassSR']:
                tmva[sel] = {}
                for n in listAvailableMVAs():
                    try:
示例#12
0
文件: skimmer.py 项目: lwezenbe/HNL
    print 'get sample'
    sample = sample_manager.getSample(args.sample)
    print 'init tree'
    chain = sample.initTree(int(args.subJob))
    # print sample.list_of_subjobclusters


    print 'year'
    chain.year = int(args.year)
    chain.is_signal = 'HNL' in sample.name

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

    #
    # Get lumiweight
    #
    from HNL.Weights.lumiweight import LumiWeight
    lw = LumiWeight(sample, sample_manager)

    #
    # Create new reduced tree (except if it already exists and overwrite option is not used)
    #
    from HNL.Tools.helpers import isValidRootFile, makeDirIfNeeded
    if sample.is_data:
        output_file_name = 'Data'
    elif chain.is_signal or args.region is not None: 
        output_file_name = sample.path.split('/')[-1].rsplit('.', 1)[0]