CMS 3D CMS Logo

Merge.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 _Merge_
4 
5 Module that generates standard merge job configurations for use in any
6 standard processing
7 
8 """
9 
10 
11 from FWCore.ParameterSet.Config import Process, EndPath
12 from FWCore.ParameterSet.Modules import OutputModule, Source, Service
13 from Configuration.EventContent.EventContent_cff import NANOAODEventContent
14 import FWCore.ParameterSet.Types as CfgTypes
15 
16 
17 def mergeProcess(*inputFiles, **options):
18  """
19  _mergeProcess_
20 
21  Creates and returns a merge process that will merge the provided
22  filenames
23 
24  supported options:
25 
26  - process_name : name of the process, defaults to Merge
27  - outputmod_label : label of the output module, defaults to Merged
28  - newDQMIO : specifies if the new DQM format should be used to merge the files
29  - output_file : sets the output file name
30  - output_lfn : sets the output LFN
31 
32  """
33  # //
34  # // process supported options
35  #//
36  processName = options.get("process_name", "Merge")
37  outputModLabel = options.get("outputmod_label", "Merged")
38  outputFilename = options.get("output_file", "Merged.root")
39  outputLFN = options.get("output_lfn", None)
40  dropDQM = options.get("drop_dqm", False)
41  newDQMIO = options.get("newDQMIO", False)
42  mergeNANO = options.get("mergeNANO", False)
43  # //
44  # // build process
45  #//
46  process = Process(processName)
47 
48  # //
49  # // input source
50  #//
51  if newDQMIO:
52  process.source = Source("DQMRootSource")
53  process.add_(Service("DQMStore"))
54  else:
55  process.source = Source("PoolSource")
56  if dropDQM:
57  process.source.inputCommands = CfgTypes.untracked.vstring('keep *','drop *_EDMtoMEConverter_*_*')
58  process.source.fileNames = CfgTypes.untracked(CfgTypes.vstring())
59  for entry in inputFiles:
60  process.source.fileNames.append(str(entry))
61 
62  # //
63  # // output module
64  #//
65  if newDQMIO:
66  outMod = OutputModule("DQMRootOutputModule")
67  elif mergeNANO:
68  outMod = OutputModule("NanoAODOutputModule",NANOAODEventContent.clone())
69  else:
70  outMod = OutputModule("PoolOutputModule")
71 
72  outMod.fileName = CfgTypes.untracked.string(outputFilename)
73  if outputLFN != None:
74  outMod.logicalFileName = CfgTypes.untracked.string(outputLFN)
75  setattr(process, outputModLabel, outMod)
76 
77  process.outputPath = EndPath(outMod)
78 
79  return process
def mergeProcess(inputFiles, options)
Definition: Merge.py:17