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  from Configuration.EventContent.EventContent_cff import HLTSCOUTEventContent
25  from Configuration.EventContent.EventContent_cff import L1SCOUTEventContent
26  process = cms.Process("REPACK")
27  process.load("FWCore.MessageLogger.MessageLogger_cfi")
28 
29  process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
30 
31  process.configurationMetadata = cms.untracked.PSet(
32  name = cms.untracked.string("repack-config"),
33  version = cms.untracked.string("none"),
34  annotation = cms.untracked.string("auto generated configuration")
35  )
36 
37  process.options = cms.untracked.PSet(
38  Rethrow = cms.untracked.vstring("ProductNotFound","TooManyProducts","TooFewProducts"),
39  wantSummary = cms.untracked.bool(False)
40  )
41 
42  process.source = cms.Source(
43  "NewEventStreamFileReader",
44  fileNames = cms.untracked.vstring()
45  )
46 
47  defaultDataTier = "RAW"
48 
49  # Should we default to something if dataTier arg isn't provided?
50  dataTier = args.get('dataTier', defaultDataTier)
51  eventContent = RAWEventContent
52  if dataTier == "HLTSCOUT":
53  eventContent = HLTSCOUTEventContent
54  elif dataTier == "L1SCOUT":
55  eventContent = L1SCOUTEventContent
56 
57  outputs = args.get('outputs', [])
58 
59  if len(outputs) > 0:
60  process.outputPath = cms.EndPath()
61 
62  for output in outputs:
63 
64  moduleLabel = output['moduleLabel']
65  selectEvents = output.get('selectEvents', None)
66  maxSize = output.get('maxSize', None)
67 
68  outputModule = cms.OutputModule(
69  "PoolOutputModule",
70  compressionAlgorithm=copy.copy(eventContent.compressionAlgorithm),
71  compressionLevel=copy.copy(eventContent.compressionLevel),
72  fileName = cms.untracked.string("%s.root" % moduleLabel)
73  )
74 
75 
76  outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string(dataTier))
77 
78  if maxSize != None:
79  outputModule.maxSize = cms.untracked.int32(maxSize)
80 
81  if selectEvents != None:
82  outputModule.SelectEvents = cms.untracked.PSet(
83  SelectEvents = cms.vstring(selectEvents)
84  )
85 
86  setattr(process, moduleLabel, outputModule)
87 
88  process.outputPath += outputModule
89 
90  return process
91 
92 
93 
def repackProcess(args)
Definition: Repack.py:12