Beispiel #1
0
def split_samples(sh, num_events=150000):
    """
    Split a sample handler's samples into smaller samples of size num_events.
    This function does not split individual files.
    """
    from ROOT import SH
    splitSH = SH.SampleHandler()
    SH.scanNEvents(sh)
    for sample in sh:
        splitSH.add(SH.splitSample(sample, num_events))
    return splitSH
Beispiel #2
0
def load_samples(args):
    """
    Build a SampleHandler.
    Not all these options are compatible with each other.
    It might thus be better to split this up somehow.
    """
    from ROOT import SH
    if args.sampleHandler:
        sh = SH.SampleHandler()
        sh.load(args.sampleHandler)
    else:
        sh = scan_samples(args.scanDir, args.samplePattern)
    # Split samples by file if requested
    if args.splitSamples:
        sh = split_samples(sh, 1)
    # Choose samples according to task ID
    if args.task:
        task, numTasks = map(int, args.task.split(':'))
        sh = select_by_task(sh, task, numTasks)
    if args.eventsPerWorker:
        from ROOT import EL
        SH.scanNEvents(sh)
        sh.setMetaDouble(EL.Job.optEventsPerWorker, args.eventsPerWorker)
    return sh
Beispiel #3
0
def _split_samples_worker(sample, num_events):
    """Worker process function for split_samples_mp"""
    from ROOT import SH
    SH.scanNEvents(sample)
    return SH.splitSample(sample, num_events)