@@ -139,7 +139,7 @@ def filesFromList(fileName,s=None):
139
139
print ("found parent files:" ,sec )
140
140
return (prim ,sec )
141
141
142
- def filesFromDASQuery (query ,option = "" ,s = None ):
142
+ def filesFromDASQuery (query ,option = "" ,s = None , max_files = None ):
143
143
import os ,time
144
144
import FWCore .ParameterSet .Config as cms
145
145
prim = []
@@ -172,6 +172,10 @@ def filesFromDASQuery(query,option="",s=None):
172
172
# remove any duplicates
173
173
prim = sorted (list (set (prim )))
174
174
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 ]
175
179
if s :
176
180
if not hasattr (s ,"fileNames" ):
177
181
s .fileNames = cms .untracked .vstring (prim )
@@ -412,12 +416,19 @@ def addSource(self):
412
416
self .addedObjects .append (("Input source" ,"source" ))
413
417
414
418
def filesFromOption (self ):
419
+ def _datasetname_and_maxfiles (entry ):
420
+ if ":" in entry :
421
+ return entry .split (":" )
422
+ else :
423
+ return entry ,None
424
+
415
425
for entry in self ._options .filein .split (',' ):
416
426
print ("entry" ,entry )
417
427
if entry .startswith ("filelist:" ):
418
- filesFromList (entry [ 9 : ],self .process .source )
428
+ filesFromList (entry . split ( ":" , 1 )[ 1 ],self .process .source )
419
429
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 )
421
432
else :
422
433
self .process .source .fileNames .append (self ._options .dirin + entry )
423
434
if self ._options .secondfilein :
@@ -426,9 +437,10 @@ def filesFromOption(self):
426
437
for entry in self ._options .secondfilein .split (',' ):
427
438
print ("entry" ,entry )
428
439
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 ])
430
441
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 ])
432
444
else :
433
445
self .process .source .secondaryFileNames .append (self ._options .dirin + entry )
434
446
@@ -680,12 +692,15 @@ def doNotInlineEventContent(instance,label = "cms.untracked.vstring(process."+th
680
692
if streamType == '' : continue
681
693
if streamType == 'ALCARECO' and not 'ALCAPRODUCER' in self ._options .step : continue
682
694
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 ]
683
700
eventContent = streamType
684
701
## 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" )
689
704
theEventContent = getattr (self .process , eventContent + "EventContent" )
690
705
if i == 0 :
691
706
theFileName = self ._options .outfile_name
@@ -714,10 +729,11 @@ def doNotInlineEventContent(instance,label = "cms.untracked.vstring(process."+th
714
729
output .dataset .filterName = cms .untracked .string ('StreamALCACombined' )
715
730
716
731
if "MINIAOD" in streamType :
732
+ ## we should definitely get rid of this customization by now
717
733
from PhysicsTools .PatAlgos .slimming .miniAOD_tools import miniAOD_customizeOutput
718
734
miniAOD_customizeOutput (output )
719
735
720
- outputModuleName = streamType + 'output'
736
+ outputModuleName = streamType + streamQualifier + 'output'
721
737
setattr (self .process ,outputModuleName ,output )
722
738
outputModule = getattr (self .process ,outputModuleName )
723
739
setattr (self .process ,outputModuleName + '_step' ,cms .EndPath (outputModule ))
0 commit comments