CMS 3D CMS Logo

Repack.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """
3 _Repack_
4 
5 Module that generates standard repack configurations
6 
7 """
8 import copy
9 import FWCore.ParameterSet.Config as cms
10 
11 
12 def repackProcess(**args):
13  """
14  _repackProcess_
15 
16  Creates and returns a repack process
17 
18  supported options:
19 
20  - outputs : defines output modules
21 
22  """
23  from Configuration.EventContent.EventContent_cff import RAWEventContent
24  process = cms.Process("REPACK")
25  process.load("FWCore.MessageLogger.MessageLogger_cfi")
26 
27  process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
28 
29  process.configurationMetadata = cms.untracked.PSet(
30  name = cms.untracked.string("repack-config"),
31  version = cms.untracked.string("none"),
32  annotation = cms.untracked.string("auto generated configuration")
33  )
34 
35  process.options = cms.untracked.PSet(
36  Rethrow = cms.untracked.vstring("ProductNotFound","TooManyProducts","TooFewProducts"),
37  wantSummary = cms.untracked.bool(False)
38  )
39 
40  process.source = cms.Source(
41  "NewEventStreamFileReader",
42  fileNames = cms.untracked.vstring()
43  )
44 
45  outputs = args.get('outputs', [])
46 
47  if len(outputs) > 0:
48  process.outputPath = cms.EndPath()
49 
50  for output in outputs:
51 
52  moduleLabel = output['moduleLabel']
53  selectEvents = output.get('selectEvents', None)
54  maxSize = output.get('maxSize', None)
55 
56  outputModule = cms.OutputModule(
57  "PoolOutputModule",
58  compressionAlgorithm=copy.copy(RAWEventContent.compressionAlgorithm),
59  compressionLevel=copy.copy(RAWEventContent.compressionLevel),
60  fileName = cms.untracked.string("%s.root" % moduleLabel)
61  )
62 
63  outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
64 
65  if maxSize != None:
66  outputModule.maxSize = cms.untracked.int32(maxSize)
67 
68  if selectEvents != None:
69  outputModule.SelectEvents = cms.untracked.PSet(
70  SelectEvents = cms.vstring(selectEvents)
71  )
72 
73  setattr(process, moduleLabel, outputModule)
74 
75  process.outputPath += outputModule
76 
77  return process
def repackProcess(args)
Definition: Repack.py:12