Skip to content

Commit a8811d5

Browse files
committed
ConfigBuilder.py has ability to use RNTuple format
- Extended --filetype option and added --rntuple_out to commandline options. - Internally use rntuple_out option to change PoolOutputModule to RNTupleOutputModule with appropriate change to extension.
1 parent f162b34 commit a8811d5

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

Configuration/Applications/python/ConfigBuilder.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Options:
5454
defaultOptions.dirout = ''
5555
defaultOptions.filetype = 'EDM'
5656
defaultOptions.fileout = 'output.root'
57+
defaultOptions.rntuple_out = False
5758
defaultOptions.filtername = ''
5859
defaultOptions.lazy_download = False
5960
defaultOptions.custom_conditions = ''
@@ -450,6 +451,11 @@ def _datasetname_and_maxfiles(entry):
450451
fileNames = cms.untracked.vstring(),
451452
secondaryFileNames= cms.untracked.vstring())
452453
filesFromOption(self)
454+
if self._options.filetype == "EDM_RNTUPLE":
455+
self.process.source=cms.Source("RNTupleSource",
456+
fileNames = cms.untracked.vstring())#, 2ndary not supported yet
457+
#secondaryFileNames= cms.untracked.vstring())
458+
filesFromOption(self)
453459
elif self._options.filetype == "DAT":
454460
self.process.source=cms.Source("NewEventStreamFileReader",fileNames = cms.untracked.vstring())
455461
filesFromOption(self)
@@ -721,6 +727,10 @@ def _createOutputModuleInAddOutput(self, tier, streamType, eventContent, fileNam
721727
CppType='TimeoutPoolOutputModule'
722728
if streamType=='DQM' and tier=='DQMIO': CppType='DQMRootOutputModule'
723729
if not ignoreNano and "NANOAOD" in streamType : CppType='NanoAODOutputModule'
730+
if self._options.rntuple_out and CppType == 'PoolOutputModule':
731+
CppType='RNTupleOutputModule'
732+
if len(fileName) > 5 and fileName[-5:] == '.root':
733+
fileName = fileName.replace('.root', '.rntpl')
724734
output = cms.OutputModule(CppType,
725735
eventContent.clone(),
726736
fileName = cms.untracked.string(fileName),
@@ -1207,7 +1217,12 @@ def inGeometryKeys(opt):
12071217
# for alca, skims, etc
12081218
def addExtraStream(self, name, stream, workflow='full'):
12091219
# define output module and go from there
1210-
output = cms.OutputModule("PoolOutputModule")
1220+
if self._options.rntuple_out:
1221+
extension = '.rntpl'
1222+
output = cms.OutputModule('RNTupleOutputModule')
1223+
else:
1224+
extension = '.root'
1225+
output = cms.OutputModule("PoolOutputModule")
12111226
if stream.selectEvents.parameters_().__len__()!=0:
12121227
output.SelectEvents = stream.selectEvents
12131228
else:
@@ -1232,8 +1247,7 @@ def doNotInlineEventContent(instance,label = "process."+stream.content+".outputC
12321247
else:
12331248
output.outputCommands = stream.content
12341249

1235-
1236-
output.fileName = cms.untracked.string(self._options.dirout+stream.name+'.root')
1250+
output.fileName = cms.untracked.string(self._options.dirout+stream.name+extension)
12371251

12381252
output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
12391253
filterName = cms.untracked.string(stream.name))

Configuration/Applications/python/Options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@
5252
type=str,
5353
dest="fileout")
5454

55+
parser.add_argument("--rntuple_out",
56+
help="If possible, use RNTuple format for output.",
57+
action="store_true",
58+
default=defaultOptions.rntuple_out,
59+
dest="rntuple_out")
60+
5561
parser.add_argument("--filetype",
5662
help="The type of the infile",
5763
default=defaultOptions.filetype,
5864
type=str,
5965
dest="filetype",
60-
choices=['EDM','DAT','LHE','MDCB','DQM','DQMDAQ']
66+
choices=['EDM','DAT','LHE','MDCB','DQM','DQMDAQ', 'EDM_RNTUPLE']
6167
)
6268

6369
parser.add_argument("-n", "--number",

Configuration/Applications/python/cmsDriverOptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ def OptionsFromItems(items):
143143
print("This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein")
144144
options.filein=options.filein.replace('mcdb:','lhe:')
145145
options.filetype="LHE"
146+
elif options.filein.lower().endswith(".rntpl"):
147+
options.filetype="EDM_RNTUPLE"
146148
else:
147149
options.filetype="EDM"
148150

149-
filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": "", "DQM":"root"}[options.filetype]
151+
filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": "", "DQM":"root", "EDM_RNTUPLE":"rntpl"}[options.filetype]
150152

151153
if options.filein=="" and not (first_step in ("ALL","GEN","LHE","SIM_CHAIN")):
152154
options.dirin="file:"+options.dirin.replace('file:','')

Configuration/Applications/test/ConfigBuilderTest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ def testOutputFormatWithEventContent(self):
130130
options.datatier= "MINIAOD"
131131
options.eventcontent="MINIAOD"
132132
_test_addOutput(self, options, process, [OutStats('MINIAODoutput','PoolOutputModule','MINIAOD','output.root',outputCommands_)])
133+
#MINIAOD w/ RNTuple
134+
process = cms.Process("TEST")
135+
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
136+
process.MINIAODEventContent = cms.PSet( outputCommands = outputCommands_)
137+
options = copy.deepcopy(defaultOptions)
138+
options.scenario = "TEST"
139+
options.datatier= "MINIAOD"
140+
options.eventcontent="MINIAOD"
141+
options.rntuple_out = True
142+
_test_addOutput(self, options, process, [OutStats('MINIAODoutput','RNTupleOutputModule','MINIAOD','output.rntpl',outputCommands_)])
133143
#MINIAOD1 [NOTE notiation not restricted to MINIAOD]
134144
#NOT SUPPORTED BY outputDefinition
135145
process = cms.Process("TEST")
@@ -149,6 +159,16 @@ def testOutputFormatWithEventContent(self):
149159
options.datatier= "DQMIO"
150160
options.eventcontent="DQM"
151161
_test_addOutput(self, options, process, [OutStats('DQMoutput','DQMRootOutputModule','DQMIO','output.root',outputCommands_)])
162+
#DQMIO & rntuple (will not change)
163+
process = cms.Process("TEST")
164+
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
165+
process.DQMEventContent = cms.PSet( outputCommands = outputCommands_)
166+
options = copy.deepcopy(defaultOptions)
167+
options.scenario = "TEST"
168+
options.datatier= "DQMIO"
169+
options.eventcontent="DQM"
170+
options.rntuple_out = True
171+
_test_addOutput(self, options, process, [OutStats('DQMoutput','DQMRootOutputModule','DQMIO','output.root',outputCommands_)])
152172
#DQMIO&DQMIO
153173
process = cms.Process("TEST")
154174
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
@@ -158,6 +178,16 @@ def testOutputFormatWithEventContent(self):
158178
options.datatier= "DQMIO"
159179
options.eventcontent="DQMIO"
160180
_test_addOutput(self, options, process, [OutStats('DQMoutput','DQMRootOutputModule','DQMIO','output.root',outputCommands_)])
181+
#DQMIO&DQMIO & rntuple (will not change)
182+
process = cms.Process("TEST")
183+
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
184+
process.DQMEventContent = cms.PSet( outputCommands = outputCommands_)
185+
options = copy.deepcopy(defaultOptions)
186+
options.scenario = "TEST"
187+
options.datatier= "DQMIO"
188+
options.eventcontent="DQMIO"
189+
options.rntuple_out = True
190+
_test_addOutput(self, options, process, [OutStats('DQMoutput','DQMRootOutputModule','DQMIO','output.root',outputCommands_)])
161191
#DQM, not DQMIO (decided by datatier)
162192
process = cms.Process("TEST")
163193
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
@@ -185,6 +215,26 @@ def testOutputFormatWithEventContent(self):
185215
options.datatier= "NANOAOD"
186216
options.eventcontent="NANOEDMAOD"
187217
_test_addOutput(self, options, process, [OutStats('NANOEDMAODoutput', 'PoolOutputModule', 'NANOAOD', 'output.root', outputCommands_)])
218+
#NANOAOD & rntuple (no change)
219+
process = cms.Process("TEST")
220+
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
221+
process.NANOAODEventContent = cms.PSet( outputCommands = outputCommands_)
222+
options = copy.deepcopy(defaultOptions)
223+
options.scenario = "TEST"
224+
options.datatier= "NANOAOD"
225+
options.eventcontent="NANOAOD"
226+
options.rntuple_out = True
227+
_test_addOutput(self, options, process, [OutStats('NANOAODoutput','NanoAODOutputModule','NANOAOD','output.root',outputCommands_)])
228+
#NANOEDMAOD & rntuple
229+
process = cms.Process("TEST")
230+
outputCommands_ = cms.untracked.vstring('drop *', 'keep foo')
231+
process.NANOAODEventContent = cms.PSet( outputCommands = outputCommands_)
232+
options = copy.deepcopy(defaultOptions)
233+
options.scenario = "TEST"
234+
options.datatier= "NANOAOD"
235+
options.eventcontent="NANOEDMAOD"
236+
options.rntuple_out = True
237+
_test_addOutput(self, options, process, [OutStats('NANOEDMAODoutput', 'RNTupleOutputModule', 'NANOAOD', 'output.rntpl', outputCommands_)])
188238
#ALCARECO empty
189239
process = cms.Process("TEST")
190240
options.scenario = "TEST"

0 commit comments

Comments
 (0)