8 if len(sys.argv) != 2 :
10 Usage: create_harvesting_py.py <dataset>
12 create_harvesting_py.py \
13 /RelValTTbar/CMSSW_3_1_0_pre4_STARTUP_30X_v1/GEN-SIM-RECO
18 if os.getenv(
'DBSCMD_HOME',
'NOTSET') ==
'NOTSET' :
22 if os.getenv(
'CMSSW_VERSION',
'NOTSET') ==
'NOTSET' :
26 cmsrel CMSSW_3_1_0_pre4
27 cd CMSSW_3_1_0_pre4/src
28 eval `scramv1 runtime -sh`
33 dsetpath = sys.argv[1]
35 from DBSAPI.dbsApi
import DbsApi
38 from DBSAPI.dbsOptions
import DbsOptionParser
40 optManager = DbsOptionParser()
41 (opts,args) = optManager.getOpt()
42 api = DbsApi(opts.__dict__)
44 print "dataset: ", dsetpath
46 for afile
in api.listFiles(path=dsetpath):
47 print " %s" % afile[
'LogicalFileName']
51 for afile
in api.listFiles(path=dsetpath):
52 totnevts += afile[
'NumberOfEvents']
55 if totnevts > nevtref : njobs = (int) (totnevts / 9000)
56 print "Total # events: ", totnevts, \
57 " to be executed in ", njobs,
"processes"
61 raw_cmsdriver =
"cmsDriver.py harvest -s HARVESTING:validationHarvesting --mc --conditions FrontierConditions_GlobalTag,STARTUP_30X::All --harvesting AtJobEnd --no_exec -n -1"
63 print "executing cmsdriver command:\n\t", raw_cmsdriver
65 os.system(
'`' + raw_cmsdriver +
'`' )
69 fin_name=
"harvest_HARVESTING_STARTUP.py"
70 pyout_name =
"harvest.py"
71 os.system(
"touch " + fin_name)
72 os.system(
'mv ' + fin_name +
" " + pyout_name )
73 pyout = open(pyout_name,
'a')
76 pyout.write(
"\n\n##additions to cmsDriver output \n")
77 pyout.write(
"#DQMStore.referenceFileName = ''\n")
78 pyout.write(
"process.dqmSaver.workflow = '" + dsetpath +
"'\n")
79 pyout.write(
"process.source.fileNames = cms.untracked.vstring(\n")
81 for afile
in api.listFiles(path=dsetpath):
82 pyout.write(
" '%s',\n" % afile[
'LogicalFileName'])
97 remove_default_blacklist=1
103 storage_element=srm-cms.cern.ch
104 storage_path=/srm/managerv2?SFN=/castor/cern.ch/
105 user_remote_dir=/user/n/nuno/relval/harvest/
111 total_number_of_events=-1
116 os.system(
"touch " + crab_name)
117 os.system(
"mv " + crab_name +
" " + crab_name +
"_old")
119 crab_cfg = open(crab_name,
'w')
120 crab_cfg.write(crab_block)
122 rootfile =
"DQM_V0001_R000000001" \
123 + dsetpath.replace(
'/',
'__') \
126 crab_cfg.write(
"number_of_jobs=" + str(njobs) +
"\n")
127 crab_cfg.write(
"pset=" + pyout_name +
"\n")
128 crab_cfg.write(
"output_file=" + rootfile +
"\n")
129 crab_cfg.write(
"datasetpath=" + dsetpath +
"\n")
137 print '\n\nCreated:\n\t %(pwd)s/%(pf)s \n\t %(pwd)s/%(cf)s' \
138 % {
'pwd' : os.environ[
"PWD"],
'pf' : pyout_name,
'cf' : crab_name}