ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
Revision: 1.6
Committed: Mon Oct 9 23:28:57 2006 UTC (18 years, 6 months ago) by gutsche
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_5_0_pre2, CRAB_1_4_2, CRAB_1_5_0_pre1, CRAB_1_4_1, CRAB_1_4_1_pre2, CRAB_1_4_1_pre1, CRAB_1_4_0, CRAB_1_4_0_pre4, CRAB_1_4_0_pre3, CRAB_1_4_0_pre2
Branch point for: branch_1_4_1
Changes since 1.5: +32 -6 lines
Log Message:
added FrameworkJobReport manipulation of input CMSSW parameter-set

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     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 slacapra 1.2 self.par = file(common.work_space.shareDir()+self.pyPset+'py').read()
30 gutsche 1.1
31     # get PSet
32 slacapra 1.2 self.cfg = CfgInterface(self.par,True)
33 gutsche 1.1
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 slacapra 1.2
44 slacapra 1.4 def pythiaSeed(self,seed):
45 slacapra 1.2 """
46 slacapra 1.4 Set pythia seed key
47 slacapra 1.2 """
48     # set seed
49     inModule = self.cfg.inputSource
50     inModule.setPythiaSeed(self.cfg,seed)
51 slacapra 1.4 return
52    
53     def pythiaSeedVtx(self,vtxSeed):
54     """
55     Set vtx seed key
56     """
57     # set seed
58     inModule = self.cfg.inputSource
59 spiga 1.3 inModule.setPythiaVtxSeed(self.cfg,vtxSeed)
60 slacapra 1.2 return
61 gutsche 1.1
62     def maxEvent(self, maxEv):
63     """ """
64     # set input module
65     inModule = self.cfg.inputSource
66     inModule.cleanMaxEvent()
67     inModule.setMaxEvents(maxEv) ## Add Daniele
68     return
69    
70 gutsche 1.5 def skipEvent(self, skipEv):
71     """ """
72     # set input module
73     inModule = self.cfg.inputSource
74     inModule.cleanSkipEvent()
75     inModule.setSkipEvents(skipEv) ## Add Daniele
76     return
77    
78 gutsche 1.1 def outputModule(self, output):
79    
80     #set output module
81     outModule = self.cfg.outputModules['out']
82     outModule.setFileName('file:'+str(output))
83    
84     return
85    
86     def psetWriter(self, name):
87    
88     configObject = cmsconfig(str(self.cfg))
89    
90     file1 = open(common.work_space.jobDir()+name,"w")
91     file1.write(str(configObject.asConfigurationString()))
92     file1.close()
93    
94     return
95 gutsche 1.6
96     def addCrabFJR(self,name):
97     """
98    
99     _addCrabFJR_
100    
101     add CRAB specific FrameworkJobReport (FJR)
102    
103     if already a FJR exist in input CMSSW parameter-set, add a second one
104    
105     """
106    
107     # check if MessageLogger service already exist in configuration, if not, add it
108     if not "MessageLogger" in self.cfg.cmsConfig.serviceNames() :
109     self.cfg.cmsConfig.psdata['services']['MessageLogger'] = {
110     '@classname': ('string', 'tracked', 'MessageLogger'),
111     }
112    
113     # get MessageLogger service
114     loggerSvc = self.cfg.cmsConfig.service("MessageLogger")
115    
116     # check if FJR is in MessageLogger service configuration, if not, add it
117     if not loggerSvc.has_key("fwkJobReports"):
118     loggerSvc['fwkJobReports'] = ("vstring", "untracked", [])
119    
120     # check if crab FJR configuration is in MessageLogger configuration, if not, add it
121     if not '\"'+name+'\"' in loggerSvc['fwkJobReports'][2] :
122     loggerSvc['fwkJobReports'][2].append('\"'+name+'\"')
123    
124     # check that default is taken for CRAB FJR configuration and any user specific is removed
125     if loggerSvc.has_key(name):
126     del loggerSvc[name]