1. binet
  2. mana-core-pyjobtransformscore

Source

mana-core-pyjobtransformscore / python / full_trfarg.py

#######################################################################################
# End-user Fully specialised arguments that can be used in JobTransform implemenations.
#######################################################################################

import PyJobTransformsCore.basic_trfarg as trfarg
from   PyJobTransformsCore.trfutil import *

class InputEvgenFileArg(EvgenFile,trfarg.InputFileArg):
    """Input file that contains generated events"""
    def __init__(self,help='output data file with generated events',name='default',
                 contents=EvgenFile.defaultContents,type=EvgenFile.defaultType):
        trfarg.InputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True


class OutputEvgenFileArg(EvgenFile,trfarg.OutputFileArg):
    """Output file that contains generated events"""
    def __init__(self,help='output data file with generated events',name='default',
                 contents=EvgenFile.defaultContents,type=EvgenFile.defaultType):
        trfarg.OutputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True



class InputHitsFileArg(HitsFile,trfarg.InputFileArg):
    """Input file that contains generated events"""
    def __init__(self,help='output data file with generated events',name='default',
                 contents=HitsFile.defaultContents,type=HitsFile.defaultType):
        trfarg.InputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True


class OutputHitsFileArg(HitsFile,trfarg.OutputFileArg):
    """Output file that contains generated events"""
    def __init__(self,help='output data file with generated events',name='default',
                 contents=HitsFile.defaultContents,type=HitsFile.defaultType):
        trfarg.OutputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True




class OutputHistogramFileArg(HistogramFile,trfarg.OutputFileArg):
    """Output file that contains histograms."""
    def __init__(self,help='output histogram file',name='histogramFile',
                 contents=HistogramFile.defaultContents,type=HistogramFile.defaultType):
        trfarg.OutputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True



class OutputNtupleFileArg(NtupleFile,trfarg.OutputFileArg):
    """Output file that contains ntuples."""
    def __init__(self,help='output ntuple file',name='ntupleFile',
                 contents=NtupleFile.defaultContents,type=NtupleFile.defaultType):
        trfarg.OutputFileArg.__init__(self,help,name,type,contents)

    def isFullArgument(self):
        return True

    

class JobOptionsArg(trfarg.StringArg):
    def __init__(self,help='jobOptions file to use',package=None,name='default'):
        if package is not None:
            self.package = package
            help += '. Default package: %s' % (package)
        trfarg.StringArg.__init__(self,help,name)


    def isFullArgument(self):
        return True


    def hasPackage(self):
        return hasattr(self,'package')


    def getPackage(self):
        return getattr(self,'package',None)


    def value(self):
        val = trfarg.Argument.value(self)
        if val and hasattr(self,'package') and not os.sep in val:
            val = os.path.join(self.package, val)

        return val
        


    def preRunAction(self):
        """Check than jobOptions file can be found"""
        val = self.value()
        JobOptionsFile(val).preRunAction()
        full = find_joboptions( val )
        if not full: raise JobOptionsNotFoundError( val, "Argument %s" % self.name() )

        self._logger.debug( 'Found %s in %s' % (val, strip_suffix(full,val)) )


#
# end of class JobOptionsArg
#

class RandomSeedArg(trfarg.IntegerArg):
    def __init__(self,help,name='default'):
        trfarg.IntegerArg.__init__(self,help,name)

    def isFullArgument(self):
        return True

    def jobOrTask(self):
        return 'job'



class RunNumberArg(trfarg.IntegerArg):
    def __init__(self,help='run number of data file',name='default'):
        trfarg.IntegerArg.__init__(self,help,name)
        
    def isFullArgument(self):
        return True




class FirstEventArg(trfarg.IntegerArg):
    def __init__(self,help='first event number to use',name='default'):
        trfarg.IntegerArg.__init__(self,help,name)

    def isFullArgument(self):
        return True

    def jobOrTask(self):
        return 'job'



class SkipEventsArg(trfarg.IntegerArg):
    def __init__(self,help='number of events to skip',name='default'):
        trfarg.IntegerArg.__init__(self,help,name)

    def isFullArgument(self):
        return True

    def jobOrTask(self):
        return 'job'


        

class MaxEventsArg(trfarg.IntegerArg):
    def __init__(self,help='maximum number of events to process',name='default'):
        trfarg.IntegerArg.__init__(self,help,name)

    def isFullArgument(self):
        return True