ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
Revision: 1.7
Committed: Fri Dec 29 09:25:31 2006 UTC (18 years, 4 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_5_0_pre3
Changes since 1.6: +7 -0 lines
Log Message:
added "first run" parameter managment for pythia job

File Contents

# Content
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 from cmsconfig import cmsconfig
9 from CfgInterface import CfgInterface
10
11 class PsetManipulator:
12 def __init__(self, pset):
13 """
14 Convert Pset in Python format
15 and initialize
16 """
17
18 self.pset = pset
19 #convert Pset
20 self.pyPset = os.path.basename(pset)
21 cmd = 'EdmConfigToPython > '+common.work_space.shareDir()+self.pyPset+'py < '+ self.pset
22 cmd_out = runCommand(cmd)
23 if cmd_out != '':
24 msg = 'Could not convert Pset.cfg into python Dictionary \n'
25 msg1= ' Did you do eval `scramv1 runtime ...` from your CMSSW working area ?'
26 raise CrabException(msg+msg1)
27 pass
28
29 self.par = file(common.work_space.shareDir()+self.pyPset+'py').read()
30
31 # get PSet
32 self.cfg = CfgInterface(self.par,True)
33
34 def inputModule(self, source):
35 """ Clean String FileName if there
36 and add vString Filenames key
37 """
38 # set input module
39 inModule = self.cfg.inputSource
40 inModule.cleanStringFileNames() ## Add Daniele
41 inModule.setFileNames(source)
42 return
43
44 def pythiaSeed(self,seed):
45 """
46 Set pythia seed key
47 """
48 # set seed
49 inModule = self.cfg.inputSource
50 inModule.setPythiaSeed(self.cfg,seed)
51 return
52
53 def pythiaSeedVtx(self,vtxSeed):
54 """
55 Set vtx seed key
56 """
57 # set seed
58 inModule = self.cfg.inputSource
59 inModule.setPythiaVtxSeed(self.cfg,vtxSeed)
60 return
61
62 def pythiaFirstRun(self, firstrun):
63 """ """
64 # set input module
65 inModule = self.cfg.inputSource
66 inModule.setFirstRun(firstrun) ## Add Daniele
67 return
68
69 def maxEvent(self, maxEv):
70 """ """
71 # set input module
72 inModule = self.cfg.inputSource
73 inModule.cleanMaxEvent()
74 inModule.setMaxEvents(maxEv) ## Add Daniele
75 return
76
77 def skipEvent(self, skipEv):
78 """ """
79 # set input module
80 inModule = self.cfg.inputSource
81 inModule.cleanSkipEvent()
82 inModule.setSkipEvents(skipEv) ## Add Daniele
83 return
84
85 def outputModule(self, output):
86
87 #set output module
88 outModule = self.cfg.outputModules['out']
89 outModule.setFileName('file:'+str(output))
90
91 return
92
93 def psetWriter(self, name):
94
95 configObject = cmsconfig(str(self.cfg))
96
97 file1 = open(common.work_space.jobDir()+name,"w")
98 file1.write(str(configObject.asConfigurationString()))
99 file1.close()
100
101 return
102
103 def addCrabFJR(self,name):
104 """
105
106 _addCrabFJR_
107
108 add CRAB specific FrameworkJobReport (FJR)
109
110 if already a FJR exist in input CMSSW parameter-set, add a second one
111
112 """
113
114 # check if MessageLogger service already exist in configuration, if not, add it
115 if not "MessageLogger" in self.cfg.cmsConfig.serviceNames() :
116 self.cfg.cmsConfig.psdata['services']['MessageLogger'] = {
117 '@classname': ('string', 'tracked', 'MessageLogger'),
118 }
119
120 # get MessageLogger service
121 loggerSvc = self.cfg.cmsConfig.service("MessageLogger")
122
123 # check if FJR is in MessageLogger service configuration, if not, add it
124 if not loggerSvc.has_key("fwkJobReports"):
125 loggerSvc['fwkJobReports'] = ("vstring", "untracked", [])
126
127 # check if crab FJR configuration is in MessageLogger configuration, if not, add it
128 if not '\"'+name+'\"' in loggerSvc['fwkJobReports'][2] :
129 loggerSvc['fwkJobReports'][2].append('\"'+name+'\"')
130
131 # check that default is taken for CRAB FJR configuration and any user specific is removed
132 if loggerSvc.has_key(name):
133 del loggerSvc[name]