-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prod_MLNanoAODv9_mc.py
148 lines (123 loc) · 6.09 KB
/
Prod_MLNanoAODv9_mc.py
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Auto generated configuration file
# using:
# Revision: 1.19
# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v
# with command line options: NANO -s NANO --mc --conditions 106X_upgrade2018_realistic_v16_L1v1 --era Run2_2018 --eventcontent NANOAODSIM --datatier NANOAODSIM --customise_commands=process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=1000 -n -1 --no_exec
import FWCore.ParameterSet.Config as cms
from FWCore.ParameterSet.VarParsing import VarParsing
from Configuration.Eras.Era_Run2_2018_cff import Run2_2018
# Command line options
options = VarParsing('analysis')
options.register('year',
'2018',
VarParsing.multiplicity.singleton,
VarParsing.varType.string,
'Year to process')
options.parseArguments()
inputFiles = options.inputFiles
outputFile = options.outputFile
maxEvents = options.maxEvents
# Process
process = cms.Process('MLNANO',Run2_2018)
# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('SimGeneral.MixingModule.mixNoPU_cfi')
process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('PhysicsTools.NanoAOD.nano_cff')
process.load('Configuration.StandardSequences.EndOfProcess_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(maxEvents)
)
# Input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(*inputFiles),
secondaryFileNames = cms.untracked.vstring()
)
process.options = cms.untracked.PSet()
# Production Info
process.configurationMetadata = cms.untracked.PSet(
annotation = cms.untracked.string('MLNANO nevts:{}'.format(maxEvents)),
name = cms.untracked.string('Applications'),
version = cms.untracked.string('$Revision: 1.19 $')
)
# ML photons
import os
CMSSW_BASE = os.environ['CMSSW_BASE']
process.mlphotons = cms.EDProducer("MLPhotonProducer",
collectionLabel = cms.string("mlphotons"),
classifierPath = cms.string(CMSSW_BASE+"/src/RecoEgamma/EgammaMLPhotonProducers/data/classifier.onnx"), # This should be hardcoded?
regressorPath = cms.string(CMSSW_BASE+"/src/RecoEgamma/EgammaMLPhotonProducers/data/regressor.onnx"),
clusterInputTag = cms.InputTag('reducedEgamma', 'reducedEBEEClusters', 'PAT'),
HEEInputTag = cms.InputTag('reducedEgamma', 'reducedEERecHits', 'PAT'),
HEBInputTag = cms.InputTag('reducedEgamma', 'reducedEBRecHits', 'PAT'),
pfcandInputTag = cms.InputTag('packedPFCandidates', '', 'PAT'),
vtxInputTag = cms.InputTag('offlineSlimmedPrimaryVertices', '', 'PAT'),
pfCandInputTag = cms.InputTag('packedPFCandidates', '', 'PAT')
)
# Define the mlphotonsTable module
from PhysicsTools.NanoAOD.common_cff import *
process.mlphotonsTable = cms.EDProducer(
'SimpleCandidateFlatTableProducer',
src = cms.InputTag('mlphotons', 'mlphotons'),
name = cms.string('MLPhoton'),
doc = cms.string('Diphoton Objects and Tagging Variables'),
singleton = cms.bool(False), # the number of entries is variable
cut = cms.string(''),
variables = cms.PSet(P4Vars,
massEnergyRatio = Var("massEnergyRatio()", float, doc="Regressed mass/energy"),
diphotonScore = Var("diphotonScore()", float, doc="Diphoton Classifier score"),
monophotonScore = Var("monophotonScore()", float, doc="Single Photon Classifier score"),
hadronScore = Var("hadronScore()", float, doc="Hadronic Classifier score"),
pfIsolation = Var("pfIsolation()", float, doc="Ratio of mlphoton energy to sum of PF candidates energy in a cone of 0.3 around the mlphoton)"),
r1 = Var("r1()", float, doc="IDK"),
r2 = Var("r2()", float, doc="IDK"),
r3 = Var("r3()", float, doc="IDK"),
),
)
# Output definition
process.NANOAODSIMoutput = cms.OutputModule("NanoAODOutputModule",
compressionAlgorithm = cms.untracked.string('LZMA'),
compressionLevel = cms.untracked.int32(9),
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('NANOAODSIM'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string(outputFile),
outputCommands = process.NANOAODSIMEventContent.outputCommands
)
# Additional output definition
# Other statements
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, '106X_upgrade2018_realistic_v16_L1v1', '')
# Path and EndPath definitions
process.mlphotons_step = cms.Path(process.mlphotons)
process.mlphotonsTable_step = cms.Path(process.mlphotonsTable)
process.nanoAOD_step = cms.Path(process.nanoSequenceMC)
process.endjob_step = cms.EndPath(process.endOfProcess)
process.NANOAODSIMoutput_step = cms.EndPath(process.NANOAODSIMoutput)
# Schedule definition
process.schedule = cms.Schedule(
process.mlphotons_step,
process.mlphotonsTable_step,
process.nanoAOD_step,
process.endjob_step,
process.NANOAODSIMoutput_step)
from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
associatePatAlgosToolsTask(process)
# customisation of the process.
# Automatic addition of the customisation function from PhysicsTools.NanoAOD.nano_cff
from PhysicsTools.NanoAOD.nano_cff import nanoAOD_customizeMC
#call to customisation function nanoAOD_customizeMC imported from PhysicsTools.NanoAOD.nano_cff
process = nanoAOD_customizeMC(process)
# End of customisation functions
# Customisation from command line
process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=1000
# Add early deletion of temporary data products to reduce peak memory need
from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
process = customiseEarlyDelete(process)
# End adding early deletion