-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrun_JRA_cfg.py
158 lines (129 loc) · 4.75 KB
/
run_JRA_cfg.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
149
150
151
152
153
154
155
156
157
158
import FWCore.ParameterSet.Config as cms
#!
#! PROCESS
#!
# Conditions source options: GT, SQLite, DB
conditionsSource = "GT"
era = "Spring16_25nsV1_MC"
doProducer = False
process = cms.Process("JRA")
multithread = False
if doProducer:
process = cms.Process("JRAP")
multithread = True
#!
#! CHOOSE ALGORITHMS
#!
# Note: Not all combinations of options will work
# Algorithm options: ak, kt, ic, sc, ca
# Size options: integers 1-10
# Jet type options: calo, pf, pfchs, puppi
# Correction levels: '' (blank), l1, l2, l3, l2l3, l1l2l3
algsizetype = {'ak':[4,8]}
jettype = ['pf','pfchs','puppi']
corrs = ['']
algorithms = []
jcr = cms.VPSet()
for k, v in algsizetype.iteritems():
for s in v:
for j in jettype:
for c in corrs:
algorithms.append(str(k+str(s)+j+c))
if conditionsSource != "GT":
upperAlg = str(k.upper()+str(s)+j.upper().replace("CHS","chs")).replace("PUPPI","PFPuppi")
jcr.append(cms.PSet(record = cms.string("JetCorrectionsRecord"),
tag = cms.string("JetCorrectorParametersCollection_"+era+"_"+upperAlg),
label= cms.untracked.string(upperAlg)))
# If need be you can append additional jet collections using the style below
#algorithms.append('ak5calo')
#!
#! CONDITIONS (DELIVERING JEC BY DEFAULT!)
#!
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff")
process.GlobalTag.globaltag = cms.string('80X_mcRun2_asymptotic_v5_2016PixDynIneff')
if conditionsSource != "GT":
if conditionsSource == "DB":
conditionsConnect = cms.string("frontier://FrontierPrep/CMS_COND_PHYSICSTOOLS")
elif conditionsSource == "SQLite":
conditionsConnect = cms.string('sqlite_file:'+era+'.db')
from CondCore.DBCommon.CondDBSetup_cfi import *
process.jec = cms.ESSource("PoolDBESSource",CondDBSetup,
connect = conditionsConnect,
toGet = cms.VPSet(jcr))
process.es_prefer_jec = cms.ESPrefer("PoolDBESSource","jec")
#!
#! INPUT
#!
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1000))
##############################################
# External Input File (most likely from DAS) #
##############################################
try:
process.load("JetMETAnalysis.JetAnalyzers.<filename without extension>")
except ImportError:
print "Couldn't open the external list of files from DAS. If you just checkout out the JetResponseAnalyzer package you will need to make this file yourself. Currently Falling back to opening the list hard-coded in run_JRA_cfg.py. This is not a bad action as long as it is what you intended to have happen."
inputFiles = cms.untracked.vstring(
'root://cmsxrootd.fnal.gov//store/mc/<path to root file>/<filename>.root',
)
process.source = cms.Source("PoolSource", fileNames = inputFiles )
#!
#! SERVICES
#!
process.load('FWCore.MessageLogger.MessageLogger_cfi')
process.MessageLogger.cerr.FwkReport.reportEvery = 100
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True))
if doProducer:
process.add_(cms.Service("Tracer"))
process.options.numberOfThreads = cms.untracked.uint32(8)
process.options.numberOfStreams = cms.untracked.uint32(0)
else:
process.load('CommonTools.UtilAlgos.TFileService_cfi')
process.TFileService.fileName=cms.string('JRA.root')
#!
#! NEEDED FOR PFCHS
#!
process.load('CommonTools.ParticleFlow.pfNoPileUpJME_cff')
process.pfPileUpJME.checkClosestZVertex = False
#!
#! JET & REFERENCE KINEMATIC CUTS
#!
import JetMETAnalysis.JetAnalyzers.Defaults_cff as Defaults
#!
#! RUN JET RESPONSE ANALYZER
#!
# set to False to use jets from the input file (NOT RECOMMENDED)
doJetReco = True
outCom = cms.untracked.vstring('drop *')
from JetMETAnalysis.JetAnalyzers.addAlgorithm import addAlgorithm
for algorithm in algorithms:
if (algorithm.find('HLT') > 0) :
process.load("Configuration.Geometry.GeometryIdeal_cff")
process.load("Configuration.StandardSequences.MagneticField_cff")
addAlgorithm(process,algorithm,Defaults,False,doProducer)
else:
addAlgorithm(process,algorithm,Defaults,doJetReco,doProducer)
outCom.extend(['keep *_'+algorithm+'_*_*'])
#!
#! Check the keep and drop commands being added to the outputCommamnds
#!
printOC = False
if printOC:
for oc in outCom:
print oc
#!
#! Output
#!
if doProducer:
process.out = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('JRAP.root'),
outputCommands = outCom
)
process.e = cms.EndPath(process.out)
#!
#! THAT'S ALL! CAN YOU BELIEVE IT? :-D
#!
#Not sure what this does
#processDumpFile = open('runJRA.dump' , 'w')
#print >> processDumpFile, process.dumpPython()
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
process.options.allowUnscheduled = cms.untracked.bool(True)