ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
Revision: 1.5
Committed: Sun Aug 27 21:10:04 2006 UTC (18 years, 8 months ago) by gutsche
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_4_0_pre1, CRAB_1_3_0, CRAB_1_3_0_pre6, CRAB_1_3_0_pre5, CRAB_1_3_0_pre4, CRAB_1_3_0_pre3, HEAD_20092006
Changes since 1.4: +8 -0 lines
Log Message:
introduce setting of skipEvents in InputSource

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 slacapra 1.4 def pythiaSeed(self,seed):
51 slacapra 1.2 """
52 slacapra 1.4 Set pythia seed key
53 slacapra 1.2 """
54     # set seed
55     inModule = self.cfg.inputSource
56     inModule.setPythiaSeed(self.cfg,seed)
57 slacapra 1.4 return
58    
59     def pythiaSeedVtx(self,vtxSeed):
60     """
61     Set vtx seed key
62     """
63     # set seed
64     inModule = self.cfg.inputSource
65 spiga 1.3 inModule.setPythiaVtxSeed(self.cfg,vtxSeed)
66 slacapra 1.2 return
67 gutsche 1.1
68     def maxEvent(self, maxEv):
69     """ """
70     # set input module
71     inModule = self.cfg.inputSource
72     inModule.cleanMaxEvent()
73     inModule.setMaxEvents(maxEv) ## Add Daniele
74     return
75    
76 gutsche 1.5 def skipEvent(self, skipEv):
77     """ """
78     # set input module
79     inModule = self.cfg.inputSource
80     inModule.cleanSkipEvent()
81     inModule.setSkipEvents(skipEv) ## Add Daniele
82     return
83    
84 gutsche 1.1 def outputModule(self, output):
85    
86     #set output module
87     outModule = self.cfg.outputModules['out']
88     outModule.setFileName('file:'+str(output))
89    
90     return
91    
92     def psetWriter(self, name):
93    
94     configObject = cmsconfig(str(self.cfg))
95    
96     file1 = open(common.work_space.jobDir()+name,"w")
97     file1.write(str(configObject.asConfigurationString()))
98     file1.close()
99    
100     return