1 |
|
#!/usr/bin/env python |
2 |
|
|
3 |
< |
import os, sys, commands |
3 |
> |
import os |
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 |
– |
|
8 |
|
from cmsconfig import cmsconfig |
9 |
|
from CfgInterface import CfgInterface |
10 |
|
|
19 |
|
#convert Pset |
20 |
|
self.pyPset = os.path.basename(pset) |
21 |
|
cmd = 'EdmConfigToPython > '+common.work_space.shareDir()+self.pyPset+'py < '+ self.pset |
22 |
< |
#cmd = 'EdmConfigToPython > '+common.work_space.shareDir()+self.pset+'py < '+ self.pset |
23 |
< |
cmd_out = runCommand(cmd) |
24 |
< |
if cmd_out != '': |
25 |
< |
msg = 'Could not convert Pset.cfg into python Dictionary \n' |
26 |
< |
msg1= ' Did you do eval `scramv1 runtime ...` from your CMSSW working area ?' |
27 |
< |
raise CrabException(msg+msg1) |
22 |
> |
exit_code = os.system(cmd) |
23 |
> |
if exit_code != 0 : |
24 |
> |
msg = 'Could not convert '+self.pset+' into a python Dictionary \n' |
25 |
> |
msg += 'Failed to execute \n'+cmd+'\n' |
26 |
> |
msg += 'Exit code : '+str(exit_code) |
27 |
> |
|
28 |
> |
raise CrabException(msg) |
29 |
|
pass |
30 |
|
|
31 |
< |
par = file(common.work_space.shareDir()+self.pyPset+'py').read() |
35 |
< |
# par = file(common.work_space.shareDir()+self.pset+'py').read() |
31 |
> |
self.par = file(common.work_space.shareDir()+self.pyPset+'py').read() |
32 |
|
|
33 |
|
# get PSet |
34 |
< |
self.cfg = CfgInterface(par,True) |
39 |
< |
|
34 |
> |
self.cfg = CfgInterface(self.par,True) |
35 |
|
|
36 |
|
def inputModule(self, source): |
37 |
|
""" Clean String FileName if there |
42 |
|
inModule.cleanStringFileNames() ## Add Daniele |
43 |
|
inModule.setFileNames(source) |
44 |
|
return |
45 |
+ |
|
46 |
+ |
def pythiaSeed(self,seed): |
47 |
+ |
""" |
48 |
+ |
Set pythia seed key |
49 |
+ |
""" |
50 |
+ |
# set seed |
51 |
+ |
inModule = self.cfg.inputSource |
52 |
+ |
inModule.setPythiaSeed(self.cfg,seed) |
53 |
+ |
return |
54 |
+ |
|
55 |
+ |
def vtxSeed(self,vtxSeed): |
56 |
+ |
""" |
57 |
+ |
Set vtx seed key |
58 |
+ |
""" |
59 |
+ |
# set seed |
60 |
+ |
inModule = self.cfg.inputSource |
61 |
+ |
inModule.setVtxSeed(self.cfg,vtxSeed) |
62 |
+ |
return |
63 |
+ |
|
64 |
+ |
def g4Seed(self,g4Seed): |
65 |
+ |
""" |
66 |
+ |
Set g4 seed key |
67 |
+ |
""" |
68 |
+ |
# set seed |
69 |
+ |
inModule = self.cfg.inputSource |
70 |
+ |
inModule.setG4Seed(self.cfg, g4Seed) |
71 |
+ |
return |
72 |
+ |
|
73 |
+ |
def mixSeed(self,mixSeed): |
74 |
+ |
""" |
75 |
+ |
Set mix seed key |
76 |
+ |
""" |
77 |
+ |
# set seed |
78 |
+ |
inModule = self.cfg.inputSource |
79 |
+ |
inModule.setMixSeed(self.cfg, mixSeed) |
80 |
+ |
return |
81 |
+ |
|
82 |
+ |
def pythiaFirstRun(self, firstrun): |
83 |
+ |
""" """ |
84 |
+ |
# set input module |
85 |
+ |
inModule = self.cfg.inputSource |
86 |
+ |
inModule.setFirstRun(firstrun) ## Add Daniele |
87 |
+ |
return |
88 |
|
|
89 |
|
def maxEvent(self, maxEv): |
90 |
|
""" """ |
94 |
|
inModule.setMaxEvents(maxEv) ## Add Daniele |
95 |
|
return |
96 |
|
|
97 |
< |
|
97 |
> |
def skipEvent(self, skipEv): |
98 |
> |
""" """ |
99 |
> |
# set input module |
100 |
> |
inModule = self.cfg.inputSource |
101 |
> |
inModule.cleanSkipEvent() |
102 |
> |
inModule.setSkipEvents(skipEv) ## Add Daniele |
103 |
> |
return |
104 |
|
|
105 |
|
def outputModule(self, output): |
106 |
|
|
119 |
|
file1.close() |
120 |
|
|
121 |
|
return |
122 |
+ |
|
123 |
+ |
def addCrabFJR(self,name): |
124 |
+ |
""" |
125 |
+ |
|
126 |
+ |
_addCrabFJR_ |
127 |
+ |
|
128 |
+ |
add CRAB specific FrameworkJobReport (FJR) |
129 |
+ |
|
130 |
+ |
if already a FJR exist in input CMSSW parameter-set, add a second one |
131 |
+ |
|
132 |
+ |
""" |
133 |
+ |
|
134 |
+ |
# check if MessageLogger service already exist in configuration, if not, add it |
135 |
+ |
if not "MessageLogger" in self.cfg.cmsConfig.serviceNames() : |
136 |
+ |
self.cfg.cmsConfig.psdata['services']['MessageLogger'] = { |
137 |
+ |
'@classname': ('string', 'tracked', 'MessageLogger'), |
138 |
+ |
} |
139 |
+ |
|
140 |
+ |
# get MessageLogger service |
141 |
+ |
loggerSvc = self.cfg.cmsConfig.service("MessageLogger") |
142 |
+ |
|
143 |
+ |
# check if FJR is in MessageLogger service configuration, if not, add it |
144 |
+ |
if not loggerSvc.has_key("fwkJobReports"): |
145 |
+ |
loggerSvc['fwkJobReports'] = ("vstring", "untracked", []) |
146 |
+ |
|
147 |
+ |
# check if crab FJR configuration is in MessageLogger configuration, if not, add it |
148 |
+ |
if not '\"'+name+'\"' in loggerSvc['fwkJobReports'][2] : |
149 |
+ |
loggerSvc['fwkJobReports'][2].append('\"'+name+'\"') |
150 |
+ |
|
151 |
+ |
# check that default is taken for CRAB FJR configuration and any user specific is removed |
152 |
+ |
if loggerSvc.has_key(name): |
153 |
+ |
del loggerSvc[name] |