Commits

Anonymous committed adb5238

added In/OutputRDOFile

  • Participants
  • Parent commits 46235cb

Comments (0)

Files changed (4)

+17-03-2006 Martin Woudstra
+	python/trfutil.py: added class RDOFile
+	python/basic_trfarg.py: 
+	    - fixed bug in ArgChoices.checkChoices(), made members private
+	    - InputDataFile.preRunAction() copies $POOLFILE. Serves as 
+	      baseclass for full input data args
+	    - new class OutputDataFile serves as baseclass of full output data args
+	python/full_trfarg.py:
+	    - Data file arguments now derive from In/OutDataFile base classes
+	    - Added classes InputRDOFile and OutputRDOFile
 16-03-2006 Martin Woudstra
 	python/basic_trfarg.py: added class BoolArg
 14-03-2006 Martin Woudstra

File python/basic_trfarg.py

 # See the doc of the Argument class for more information.
 ################################################################################
 
-import os,tarfile
+import os,tarfile,shutil
 
 from AthenaCommon.Logging import logging
 
 class ArgChoices:
     def __init__(self, choices):
         """Argument list of choices add-in class"""
-        self.choices = choices
+        self._choices = choices
+
+
+    def choices(self):
+        return self._choices
 
 
     def checkChoices(self,val):
         """ Returns boolean indicating that <val> (python type) is one of choices."""
-        return val in choices
+        return val in self._choices
 
 #
 # end of class ArgChoices
         InputFileArg.__init__(self,help,name,type,contents)
     
 
+    def preRunAction(self):
+        """Copy PoolFileCatalog"""
+        InputFileArg.preRunAction(self)
+        try:
+            poolcatalog = os.environ['POOLFILE']
+        except:
+            pass  # should I throw an error?
+        else:
+            self._logger.debug( "Copying file %s to %s" % (poolcatalog, PoolDataFile.defaultCatalogFilename) )
+            shutil.copyfile( poolcatalog, PoolDataFile.defaultCatalogFilename )
+        
+
 
 class InputTarFileArg( InputFileArg ):
     def __init__(self,help,name,destdir='.',type='tar|tar.gz|tgz'):
         InputFileArg.preRunAction(self)
         self.extract()
 
-       
 
 
 class OutputFileArg( Filename, StringArg ):
 
 
 
+class OutputDataFileArg( OutputFileArg ):
+    """Class for input POOL data files"""
+    def __init__(self,help,name,contents,type=PoolDataFile.defaultType):
+        OutputFileArg.__init__(self,help,name,type,contents)
+    

File python/full_trfarg.py

 import PyJobTransformsCore.basic_trfarg as trfarg
 from   PyJobTransformsCore.trfutil import *
 
-class InputEvgenFileArg(EvgenFile,trfarg.InputFileArg):
+class InputEvgenFileArg(EvgenFile,trfarg.InputDataFileArg):
     """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)
+        trfarg.InputDataFileArg.__init__(self,help,name,contents,type)
 
     def isFullArgument(self):
         return True
 
 
-class OutputEvgenFileArg(EvgenFile,trfarg.OutputFileArg):
+class OutputEvgenFileArg(EvgenFile,trfarg.OutputDataFileArg):
     """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)
+        trfarg.OutputDataFileArg.__init__(self,help,name,contents,type)
 
     def isFullArgument(self):
         return True
 
 
 
-class InputHitsFileArg(HitsFile,trfarg.InputFileArg):
-    """Input file that contains generated events"""
+class InputHitsFileArg(HitsFile,trfarg.InputDataFileArg):
+    """Input file that contains hits"""
     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)
+        trfarg.InputDataFileArg.__init__(self,help,name,contents,type)
 
     def isFullArgument(self):
         return True
 
 
-class OutputHitsFileArg(HitsFile,trfarg.OutputFileArg):
-    """Output file that contains generated events"""
+class OutputHitsFileArg(HitsFile,trfarg.OutputDataFileArg):
+    """Output file that contains hits"""
     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)
+        trfarg.OutputDataFileArg.__init__(self,help,name,contents,type)
 
     def isFullArgument(self):
         return True
 
 
+class InputRDOFileArg(RDOFile,trfarg.InputDataFileArg):
+    """Input file that contains RDO's"""
+    def __init__(self,help='output data file with generated events',name='default',
+                 contents=RDOFile.defaultContents,type=RDOFile.defaultType):
+        trfarg.InputDataFileArg.__init__(self,help,name,contents,type)
+
+    def isFullArgument(self):
+        return True
+
+
+class OutputRDOFileArg(RDOFile,trfarg.OutputDataFileArg):
+    """Output file that contains RDO's"""
+    def __init__(self,help='output data file with generated events',name='default',
+                 contents=RDOFile.defaultContents,type=RDOFile.defaultType):
+        trfarg.OutputDataFileArg.__init__(self,help,name,contents,type)
+
+    def isFullArgument(self):
+        return True
+
 
 
 class OutputHistogramFileArg(HistogramFile,trfarg.OutputFileArg):
         return True
 
 
-
 class OutputNtupleFileArg(NtupleFile,trfarg.OutputFileArg):
     """Output file that contains ntuples."""
     def __init__(self,help='output ntuple file',name='ntupleFile',

File python/trfutil.py

 
 class PoolDataFile( Filename ):
     defaultType = 'pool.root'
-
+    defaultCatalogFilename = 'PoolFileCatalog.xml'
 
 class EvgenFile:
     defaultContents = 'evgen'
     defaultType = PoolDataFile.defaultType
 
 
+class RDOFile:
+    defaultContenst = 'rdo'
+    defaultType = PoolDataFile.defaultType
+
+
 class HistogramFile:
     defaultContents = 'histo'
     defaultType = 'root'