3 from __future__
import print_function
8 arguments [<list-of-processes>] 10 creates crab.cfg, multicrab.cfg, harvest_*.py 12 prints number of events found in dataset 13 if no argument is provided looks for all available datsets for release 14 user can edit multicrab and confirm process list as needed 19 print(
"Usage:", sys.argv[0],
"[list_of_processes]")
21 print(
"harvestRelVal.py")
22 print(
"harvestRelVal.py /RelValTTbar/CMSSW_3_1_0_pre4_STARTUP_30X_v1/GEN-SIM-RECO")
23 print(
"harvestRelVal.py <dataset_list.txt>")
26 if os.getenv(
'DBSCMD_HOME',
'NOTSET') ==
'NOTSET' :
34 for afile
in api.listFiles(path=
str(dset)):
35 nevts = afile[
'NumberOfEvents']
41 return 'DQM_V0001_R000000001' + s.replace(
'/',
'__') +
'.root' 50 cb = ca[:ca.find(
'v')-1]
51 if cb[0].
find(
'3') == -1
or len(cb) > 3:
52 print(
"problem extracting condition for", ds,
" : ", cb,
'(len:',len(cb),
')')
53 if cb.find(
'31X') != -1:
55 elif cb.find(
'30X') != -1:
60 print(
"condition found:", cb)
62 print(
"good condition for", ds,
" : ", cb,
'(len:',len(cb),
')')
69 flis = open(dbslf,
'w')
70 for ads
in api.listDatasetPaths() :
71 if ads.find(
'RelVal') != -1 \
72 or ads.find(cmssw_ver) != -1 \
73 or ads.find(
"/GEN-SIM") != -1 :
75 flis.write(ads +
'\n')
77 print(
'Generated dataset list', dbslf,
'from dbs.')
84 if not os.path.exists(dsfile) :
85 print(
"problem reading file", dsfile)
87 fin = open(dsfile,
'r') 88 for dset
in fin.readlines():
89 d = dset.replace(
'\n',
'')
90 if d.find(
'#') == -1 :
95 print(
'Using data set list in ', dsfile)
100 if s.find(cmssw_ver) == -1 :
102 print(
'Inconsistency found with datset and cmssw version (', cmssw_ver,
')' \
103 ': \t ', s,
' has been removed.')
105 for s
in dsetpaths[:]:
110 nSamples = len(dsetpaths)
112 print(
"Empty input list, exit.")
115 print(
'Processing', nSamples,
'data sets.')
120 print(
'number of events per dataset:', nSampleEvts)
123 if not do_reference :
127 ref_ver = cmssw_ver.replace(cp,
str(ip))
129 ref_dir =
"/castor/cern.ch/user/n/nuno/relval/harvest/" + ref_ver +
"/" 131 gls =
" | grep root | grep " 134 gls +=
"| awk '{print $9}' " 136 command =
"rfcp " + ref_dir +
"`rfdir " + ref_dir + gls +
"` ." 140 command =
"ls -rtl *" + gls +
" > " + tmpfile
144 if os.path.exists(tmpfile) :
145 fin = open(tmpfile,
'r') 146 ref = fin.readline().replace('\n',
'')
149 if os.path.exists(ref) :
153 print(
"Found reference file:", the_ref)
157 raw_cmsdriver =
"cmsDriver.py harvest -s HARVESTING:validationHarvesting --mc --conditions FrontierConditions_GlobalTag,STARTUP_30X::All --harvesting AtJobEnd --no_exec -n -1" 158 cmsdriver = raw_cmsdriver
161 print(
'unexpected problem with conditions')
163 cmsdriver = cmsdriver.replace(
'30X',cond)
164 fin_name=
"harvest_HARVESTING_STARTUP.py" 165 if ds.find(
'IDEAL') != -1 :
166 cmsdriver = cmsdriver.replace(
'STARTUP',
'IDEAL')
167 fin_name = fin_name.replace(
'STARTUP',
'IDEAL')
168 if ds.find(
'FastSim') != -1:
169 cmsdriver = cmsdriver.replace(
'validationHarvesting',
'validationHarvestingFS')
170 if ds.find(
'PileUp') != -1:
171 cmsdriver = cmsdriver.replace(
'validationHarvesting',
'validationHarvestingPU')
174 if os.path.exists(fin_name) :
175 os.system(
"rm " + fin_name)
176 print(
"executing cmsdriver command:\n\t", cmsdriver)
178 if not os.path.exists(fin_name) :
179 print(
'problem with cmsdriver file name')
181 os.system(
"touch " + fin_name)
183 os.system(
'mv ' + fin_name +
" " + hf)
185 out.write(
"\n\n##additions to cmsDriver output \n")
186 out.write(
"process.dqmSaver.workflow = '" + ds +
"'\n")
188 out.write(
"process.source.fileNames = cms.untracked.vstring(\n")
189 for afile
in api.listFiles(path=ds):
190 out.write(
" '%s',\n" % afile[
'LogicalFileName'])
194 if not dqmref ==
'NONE' :
195 out.write(
"process.DQMStore.referenceFileName = '" + dqmref +
"'\n")
196 out.write(
"process.dqmSaver.referenceHandling = 'all'\n")
201 out = open(fout,
'w')
202 out.write(
'[MULTICRAB]')
203 out.write(
'\ncfg=' + fcrab)
204 out.write(
'\n\n[COMMON]')
207 out.write(
'\nCMSSW.total_number_of_events=' + (str)(nevt) )
208 out.write(
'\nCMSSW.number_of_jobs=' + (str)(njob) )
220 if not os.path.exists(hf) :
221 print(
'problem creating multicrab, file', hf,
'does not exist')
223 fout.write(
'\n\n[' + sample +
']')
224 fout.write(
'\nCMSSW.pset=' + hf)
225 fout.write(
'\nCMSSW.datasetpath=' + dsetp)
226 fout.write(
'\nCMSSW.output_file=' + dqm)
229 if not dqmref ==
'NONE' :
230 fout.write(
'\nUSER.additional_input_files=' + dqmref)
235 out = open(f_crab,
'w')
236 out.write(crab_block)
237 out.write(
'\npset=' + hf)
238 out.write(
'datasetpath=' + ds)
239 out.write(
'\noutput_file=' + dqmout)
248 remove_default_blacklist=1 254 #storage_element=srm-cms.cern.ch 255 #storage_path=/srm/managerv2?SFN=/castor/cern.ch 256 #user_remote_dir=/user/n/nuno/test 262 total_number_of_events=-1 273 if len(sys.argv) > 2 :
276 elif len(sys.argv) == 1 :
277 print(
"Will search for available datasets.")
279 elif len(sys.argv) == 2 :
281 if os.path.exists(argin) :
285 elif argin.find(
'CMSSW') != -1
and argin.find(
'RelVal'):
286 print(
'Using specified data set', argin)
289 print(
'Invalid argument: process list, dataset or file', \
290 argin,
'does not exist.')
296 print(
"dbs not set!")
298 print(
"dbs home:", os.getenv(
'DBSCMD_HOME'))
299 from DBSAPI.dbsApi
import DbsApi
302 from DBSAPI.dbsOptions
import DbsOptionParser
303 optManager = DbsOptionParser()
304 (opts,args) = optManager.getOpt()
307 args[
'url']=
"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" 311 cmssw_ver = os.getenv(
'CMSSW_VERSION',
'NOTSET')
312 if cmssw_ver ==
'NOTSET' :
316 scramv1 p CMSSW CMSSW_3_1_0_pre5 317 cd CMSSW_3_1_0_pre5/src 318 eval `scramv1 runtime -sh` 323 print(
"Using cmssw version:", cmssw_ver)
329 if input_type ==
'none' :
331 print(
"no dataset specified, and dbs isn't set...")
335 dsfile = cmssw_ver +
"_dbslist.txt" 338 elif input_type ==
'file' :
340 elif input_type ==
'ds' :
341 dsetpaths.append(argin)
348 print(
'data sets:', dsetpaths)
349 dslproc = open(
"dset_processed.txt",
'w')
351 dslproc.write(s+
'\n')
367 f_multi_crab =
'multicrab.cfg' 376 print(
'\nCreated:\n\t %(pwd)s/%(cf)s \n\t %(pwd)s/%(mc)s' \
377 % {
'pwd' : os.environ[
"PWD"],
'cf' : f_crab,
'mc' : f_multi_crab})
378 print(
"\tIndividual harvest py's:\n\t", harvfilelist)
def get_name_from_dsetpath(ds)
def replace(string, replacements)
def create_mcrab(set, fcrab, fout)
S & print(S &os, JobReport::InputFile const &f)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def append_sample_mcrab(dsetp, fout)
def get_cond_from_dsetpath(ds)
def check_nevts_dset(dset)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run