ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
Revision: 1.2
Committed: Thu Jun 22 16:05:18 2006 UTC (18 years, 10 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_2_0_pre9, CRAB_1_2_0_pre8, CRAB_1_2_0_pre7
Changes since 1.1: +11 -5 lines
Log Message:
support for None input

File Contents

# User Rev Content
1 gutsche 1.1 #!/usr/bin/env python
2    
3     import os, sys, commands
4     import common
5     from crab_util import *
6     from crab_exceptions import *
7    
8     # Crabpydir=commands.getoutput('which crab')
9     # Topdir=string.replace(Crabpydir,'/python/crab','')
10     # sys.path.append(Topdir+'/PsetCode')
11    
12     from cmsconfig import cmsconfig
13     from CfgInterface import CfgInterface
14    
15     class PsetManipulator:
16     def __init__(self, pset):
17     """
18     Convert Pset in Python format
19     and initialize
20     """
21    
22     self.pset = pset
23     #convert Pset
24     self.pyPset = os.path.basename(pset)
25     cmd = 'EdmConfigToPython > '+common.work_space.shareDir()+self.pyPset+'py < '+ self.pset
26     #cmd = 'EdmConfigToPython > '+common.work_space.shareDir()+self.pset+'py < '+ self.pset
27     cmd_out = runCommand(cmd)
28     if cmd_out != '':
29     msg = 'Could not convert Pset.cfg into python Dictionary \n'
30     msg1= ' Did you do eval `scramv1 runtime ...` from your CMSSW working area ?'
31     raise CrabException(msg+msg1)
32     pass
33    
34 slacapra 1.2 self.par = file(common.work_space.shareDir()+self.pyPset+'py').read()
35 gutsche 1.1 # par = file(common.work_space.shareDir()+self.pset+'py').read()
36    
37     # get PSet
38 slacapra 1.2 self.cfg = CfgInterface(self.par,True)
39 gutsche 1.1
40     def inputModule(self, source):
41     """ Clean String FileName if there
42     and add vString Filenames key
43     """
44     # set input module
45     inModule = self.cfg.inputSource
46     inModule.cleanStringFileNames() ## Add Daniele
47     inModule.setFileNames(source)
48     return
49 slacapra 1.2
50     def pythiaSeed(self,seed):
51     """
52     Set pythia seed key
53     """
54     # set seed
55     inModule = self.cfg.inputSource
56     inModule.setPythiaSeed(self.cfg,seed)
57     return
58 gutsche 1.1
59     def maxEvent(self, maxEv):
60     """ """
61     # set input module
62     inModule = self.cfg.inputSource
63     inModule.cleanMaxEvent()
64     inModule.setMaxEvents(maxEv) ## Add Daniele
65     return
66    
67     def outputModule(self, output):
68    
69     #set output module
70     outModule = self.cfg.outputModules['out']
71     outModule.setFileName('file:'+str(output))
72    
73     return
74    
75     def psetWriter(self, name):
76    
77     configObject = cmsconfig(str(self.cfg))
78    
79     file1 = open(common.work_space.jobDir()+name,"w")
80     file1.write(str(configObject.asConfigurationString()))
81     file1.close()
82    
83     return