3 from __future__
import print_function
9 if len(sys.argv) != 2 :
11 Usage: create_harvesting_py.py <dataset>
13 create_harvesting_py.py \
14 /RelValTTbar/CMSSW_3_1_0_pre4_STARTUP_30X_v1/GEN-SIM-RECO
19 if os.getenv(
'DBSCMD_HOME',
'NOTSET') ==
'NOTSET' :
23 if os.getenv(
'CMSSW_VERSION',
'NOTSET') ==
'NOTSET' :
27 cmsrel CMSSW_3_1_0_pre4
28 cd CMSSW_3_1_0_pre4/src
29 eval `scramv1 runtime -sh`
34 dsetpath = sys.argv[1]
36 from DBSAPI.dbsApi
import DbsApi
39 from DBSAPI.dbsOptions
import DbsOptionParser
41 optManager = DbsOptionParser()
42 (opts,args) = optManager.getOpt()
43 api = DbsApi(opts.__dict__)
45 print(
"dataset: ", dsetpath)
47 for afile
in api.listFiles(path=dsetpath):
48 print(
" %s" % afile[
'LogicalFileName'])
52 for afile
in api.listFiles(path=dsetpath):
53 totnevts += afile[
'NumberOfEvents']
56 if totnevts > nevtref : njobs = (int) (totnevts / 9000)
57 print(
"Total # events: ", totnevts, \
58 " to be executed in ", njobs,
"processes")
62 raw_cmsdriver =
"cmsDriver.py harvest -s HARVESTING:validationHarvesting --mc --conditions FrontierConditions_GlobalTag,STARTUP_30X::All --harvesting AtJobEnd --no_exec -n -1"
64 print(
"executing cmsdriver command:\n\t", raw_cmsdriver)
66 os.system(
'`' + raw_cmsdriver +
'`' )
70 fin_name=
"harvest_HARVESTING_STARTUP.py"
71 pyout_name =
"harvest.py"
72 os.system(
"touch " + fin_name)
73 os.system(
'mv ' + fin_name +
" " + pyout_name )
74 pyout = open(pyout_name,
'a')
77 pyout.write(
"\n\n##additions to cmsDriver output \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})