Skip to content

Commit 862b9fd

Browse files
authored
Merge pull request #47501 from vlimant/stepchain_utility
McM/production bound options to cmsDriver
2 parents d170a9b + 904189f commit 862b9fd

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

Configuration/Applications/python/ConfigBuilder.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def filesFromList(fileName,s=None):
139139
print("found parent files:",sec)
140140
return (prim,sec)
141141

142-
def filesFromDASQuery(query,option="",s=None):
142+
def filesFromDASQuery(query,option="",s=None,max_files=None):
143143
import os,time
144144
import FWCore.ParameterSet.Config as cms
145145
prim=[]
@@ -172,6 +172,10 @@ def filesFromDASQuery(query,option="",s=None):
172172
# remove any duplicates
173173
prim = sorted(list(set(prim)))
174174
sec = sorted(list(set(sec)))
175+
if max_files:
176+
max_files=int(max_files)
177+
prim = prim[:max_files]
178+
sec = sec[:max_files]
175179
if s:
176180
if not hasattr(s,"fileNames"):
177181
s.fileNames=cms.untracked.vstring(prim)
@@ -412,12 +416,19 @@ def addSource(self):
412416
self.addedObjects.append(("Input source","source"))
413417

414418
def filesFromOption(self):
419+
def _datasetname_and_maxfiles(entry):
420+
if ":" in entry:
421+
return entry.split(":")
422+
else:
423+
return entry,None
424+
415425
for entry in self._options.filein.split(','):
416426
print("entry",entry)
417427
if entry.startswith("filelist:"):
418-
filesFromList(entry[9:],self.process.source)
428+
filesFromList(entry.split(":",1)[1],self.process.source)
419429
elif entry.startswith("dbs:") or entry.startswith("das:"):
420-
filesFromDASQuery('file dataset = %s'%(entry[4:]),self._options.dasoption,self.process.source)
430+
dataset_name,max_files = _datasetname_and_maxfiles(entry.split(":",1)[1])
431+
filesFromDASQuery('file dataset = %s'%(dataset_name),self._options.dasoption,self.process.source,max_files)
421432
else:
422433
self.process.source.fileNames.append(self._options.dirin+entry)
423434
if self._options.secondfilein:
@@ -426,9 +437,10 @@ def filesFromOption(self):
426437
for entry in self._options.secondfilein.split(','):
427438
print("entry",entry)
428439
if entry.startswith("filelist:"):
429-
self.process.source.secondaryFileNames.extend((filesFromList(entry[9:]))[0])
440+
self.process.source.secondaryFileNames.extend((filesFromList(entry.split(":",1)[1]))[0])
430441
elif entry.startswith("dbs:") or entry.startswith("das:"):
431-
self.process.source.secondaryFileNames.extend((filesFromDASQuery('file dataset = %s'%(entry[4:]),self._options.dasoption))[0])
442+
dataset_name,max_files = _datasetname_and_maxfiles(entry.split(":",1)[1])
443+
self.process.source.secondaryFileNames.extend((filesFromDASQuery('file dataset = %s'%(dataset_name),self._options.dasoption))[0])
432444
else:
433445
self.process.source.secondaryFileNames.append(self._options.dirin+entry)
434446

@@ -680,12 +692,15 @@ def doNotInlineEventContent(instance,label = "cms.untracked.vstring(process."+th
680692
if streamType=='': continue
681693
if streamType == 'ALCARECO' and not 'ALCAPRODUCER' in self._options.step: continue
682694
if streamType=='DQMIO': streamType='DQM'
695+
streamQualifier=''
696+
if streamType[-1].isdigit():
697+
## a special case where --eventcontent MINIAODSIM1 is set to have more than one output in a chain of configuration
698+
streamQualifier = str(streamType[-1])
699+
streamType = streamType[:-1]
683700
eventContent=streamType
684701
## override streamType to eventContent in case NANOEDM
685-
if streamType == "NANOEDMAOD" :
686-
eventContent = "NANOAOD"
687-
elif streamType == "NANOEDMAODSIM" :
688-
eventContent = "NANOAODSIM"
702+
if streamType.startswith("NANOEDMAOD"):
703+
eventContent = eventContent.replace("NANOEDM","NANO")
689704
theEventContent = getattr(self.process, eventContent+"EventContent")
690705
if i==0:
691706
theFileName=self._options.outfile_name
@@ -714,10 +729,11 @@ def doNotInlineEventContent(instance,label = "cms.untracked.vstring(process."+th
714729
output.dataset.filterName = cms.untracked.string('StreamALCACombined')
715730

716731
if "MINIAOD" in streamType:
732+
## we should definitely get rid of this customization by now
717733
from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeOutput
718734
miniAOD_customizeOutput(output)
719735

720-
outputModuleName=streamType+'output'
736+
outputModuleName=streamType+streamQualifier+'output'
721737
setattr(self.process,outputModuleName,output)
722738
outputModule=getattr(self.process,outputModuleName)
723739
setattr(self.process,outputModuleName+'_step',cms.EndPath(outputModule))

0 commit comments

Comments
 (0)