HPS-MC
_hadd.py
Go to the documentation of this file.
1 """! running hadd from in hps-mc jobs"""
2 
3 import shutil
4 import re
5 import os
6 import logging
7 
8 from hpsmc.component import Component
9 
10 
11 class hadd(Component):
12  """! Run ROOT's histogram/TTree merger
13 
14  Required:
15  - **inputs**: input ROOT files to merge
16  - **outputs**: *single* output file to merge into
17  Optional:
18  - **ncores**: number of cores to supply to hadd (default 1)
19  """
20 
21  logger = logging.getLogger('hpsmc.tools.hadd')
22 
23  def __init__(self, **kwargs):
24  self.output_extoutput_extoutput_ext = 'root'
25  self.ncoresncores = None
26  super().__init__('hadd', command='hadd', **kwargs)
27 
29  return ['ncores']
30 
31  def cmd_args(self):
32  a = []
33  if self.ncoresncores is not None:
34  a += ['-j', self.ncoresncores]
35  if len(self.outputsoutputs) != 1:
36  raise ValueError('hadd makes no sense without exactly one output')
37  a += self.outputsoutputs
38  if self.inputsinputs is None or len(self.inputsinputs) == 0:
39  raise ValueError('hadd makes no sense without at least one input')
40  a += self.inputsinputs
41  return a
Run ROOT's histogram/TTree merger.
Definition: _hadd.py:11
def optional_parameters(self)
Return a list of optional parameters.
Definition: _hadd.py:28
def __init__(self, **kwargs)
Definition: _hadd.py:23
def cmd_args(self)
Return the command arguments of this component.
Definition: _hadd.py:31
Base class for components in a job.
Definition: component.py:15