-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomizeGenerationStep2.py
More file actions
108 lines (87 loc) · 3.1 KB
/
customizeGenerationStep2.py
File metadata and controls
108 lines (87 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
import os
debug = False
def customiseConfig(config):
print "Applying customisations"
if (debug): print config
stringtoreplace = """
process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule",
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string('file:DR.root'),
outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands,
splitLevel = cms.untracked.int32(0)
)
"""
# if config.find(stringtoreplace) == -1:
# print "ERROR (customizeGenerationStep2.py): Unable to find the code to replace:\n{}".format(stringtoreplace)#
# config = config.replace(stringtoreplace, """
#process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule",
# dataset = cms.untracked.PSet(
# dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'),
# filterName = cms.untracked.string('')
# ),
# eventAutoFlushCompressedSize = cms.untracked.int32(20971520),
# fileName = cms.untracked.string('file:DR.root'),
# outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands,
# splitLevel = cms.untracked.int32(0)
#)
#""")
config = config.replace(" inputCommands = cms.untracked.vstring(", """
treeMaxVirtualSize = cms.untracked.int32(262144),
inputCommands = cms.untracked.vstring(
""")
# config = config.replace("# Other statements", """
## Other statements
#from SimGeneral.MixingModule.mixObjects_cfi import theMixObjects
#from SimGeneral.MixingModule.mixPoolSource_cfi import *
#from SimGeneral.MixingModule.digitizers_cfi import *
#
#process.mix = cms.EDProducer("MixingModule",
# digitizers = cms.PSet(theDigitizers),
# LabelPlayback = cms.string(''),
# maxBunch = cms.int32(3),
# minBunch = cms.int32(-5), ## in terms of 25 nsec
#
# bunchspace = cms.int32(450), ##ns
# mixProdStep1 = cms.bool(False),
# mixProdStep2 = cms.bool(False),
#
# playback = cms.untracked.bool(False),
# useCurrentProcessOnly = cms.bool(False),
#
# input = cms.SecSource("EmbeddedRootSource",
# nbPileupEvents = cms.PSet(
# averageNumber = cms.double(1.0)
# ),
# type = cms.string('poisson'),
# sequential = cms.untracked.bool(False),
# treeMaxVirtualSize = cms.untracked.int32(262144),
# numberOfStreams = cms.untracked.int32(0),
# numberOfThreads = cms.untracked.int32(1),
# fileNames = FileNames
# ),
# mixObjects = cms.PSet(theMixObjects)
#)
#""")
return config
def copyFile(src, dest):
if (debug): print "\tcopying file: {} to: {}".format(src, dest)
destinationfile = open(dest, "w")
with open(src, "r") as infile:
print infile
content = infile.read() #content = infile.readlines()
# Here we add the customisations
content = customiseConfig(content)
for line in content:
destinationfile.write(line)
destinationfile.close()
return
if __name__ == "__main__":
print "Copying file 'step2.py' to 'step2_original.py' ..."
os.system("cp step2.py step2_original.py")
inputFile = "step2_original.py"
outputFile = "step2.py"
copyFile(inputFile, outputFile)