forked from TreeMaker/TreeMaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runMakeTreeFromMiniAOD_cfg.py
126 lines (112 loc) · 4.56 KB
/
runMakeTreeFromMiniAOD_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
# Read parameters
from TreeMaker.Utils.CommandLineParams import CommandLineParams
parameters = CommandLineParams()
scenarioName=parameters.value("scenario","")
inputFilesConfig=parameters.value("inputFilesConfig","")
dataset=parameters.value("dataset",[])
nstart = parameters.value("nstart",0)
nfiles = parameters.value("nfiles",-1)
numevents=parameters.value("numevents",-1)
reportfreq=parameters.value("reportfreq",1000)
outfile=parameters.value("outfile","test_run")
# background estimations on by default
lostlepton=parameters.value("lostlepton", True)
hadtau=parameters.value("hadtau", True)
doZinv=parameters.value("doZinv", True)
QCD=parameters.value("QCD", True)
# compute the PDF weights
doPDFs=parameters.value("doPDFs", True);
# other options off by default
tagandprobe=parameters.value("tagandprobe", False)
debugtracks=parameters.value("debugtracks", False)
applybaseline=parameters.value("applybaseline", False)
gridcontrol=parameters.value("gridcontrol", False)
# auto configuration for different scenarios
from TreeMaker.Production.scenarios import Scenario
scenario = Scenario(scenarioName)
# take command line input (w/ defaults from scenario if specified)
globaltag=parameters.value("globaltag",scenario.globaltag)
tagname=parameters.value("tagname",scenario.tagname)
geninfo=parameters.value("geninfo",scenario.geninfo)
fastsim=parameters.value("fastsim",scenario.fastsim)
jsonfile=parameters.value("jsonfile",scenario.jsonfile)
jecfile=parameters.value("jecfile",scenario.jecfile)
residual=parameters.value("residual",scenario.residual)
era=parameters.value("era",scenario.era)
# The process needs to be defined AFTER reading sys.argv,
# otherwise edmConfigHash fails
import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras
process = cms.Process("RA2EventSelection")
if era=="Run2_25ns":
process = cms.Process("RA2EventSelection",eras.Run2_25ns)
elif era=="Run2_50ns":
process = cms.Process("RA2EventSelection",eras.Run2_50ns)
# configure geometry & conditions
process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff")
# Load input files
readFiles = cms.untracked.vstring()
if inputFilesConfig!="" :
if nfiles==-1:
process.load("TreeMaker.Production."+inputFilesConfig+"_cff")
readFiles.extend( process.source.fileNames )
else:
readFilesImport = getattr(__import__("TreeMaker.Production."+inputFilesConfig+"_cff",fromlist=["readFiles"]),"readFiles")
readFiles.extend( readFilesImport[nstart:(nstart+nfiles)] )
if dataset!=[] :
readFiles.extend( [dataset] )
#temporary redirector fix
for f,val in enumerate(readFiles):
if readFiles[f][0:6]=="/store":
readFiles[f] = "root://cmsxrootd.fnal.gov/"+readFiles[f]
# print out settings
print "***** SETUP ************************************"
print " dataset: "+str(readFiles)
print " outfile: "+outfile+"_RA2AnalysisTree"
print " "
print " storing lostlepton variables: "+str(lostlepton)
print " storing hadtau variables: "+str(hadtau)
print " storing Zinv variables: "+str(doZinv)
print " storing QCD variables: "+str(QCD)
print " "
print " storing PDF weights: "+str(doPDFs)
print " "
print " storing tag and probe variables: "+str(tagandprobe)
print " storing track debugging variables: "+str(debugtracks)
print " Applying baseline selection filter: "+str(applybaseline)
print " "
if scenario.known: print " scenario: "+scenarioName
print " global tag: "+globaltag
print " Instance name of tag information: "+tagname
print " Including gen-level information: "+str(geninfo)
print " Using fastsim settings: "+str(fastsim)
if len(jsonfile)>0: print " JSON file applied: "+jsonfile
if len(jecfile)>0: print " JECs applied: "+jecfile+(" (residuals)" if residual else "")
print " era of this dataset: "+era
print "************************************************"
from TreeMaker.TreeMaker.makeTreeFromMiniAOD_cff import makeTreeFromMiniAOD
process = makeTreeFromMiniAOD(process,
outfile=outfile+"_RA2AnalysisTree",
reportfreq=reportfreq,
dataset=readFiles,
globaltag=globaltag,
numevents=numevents,
hadtau=hadtau,
lostlepton=lostlepton,
QCD=QCD,
tagandprobe=tagandprobe,
applybaseline=applybaseline,
doZinv=doZinv,
debugtracks=debugtracks,
geninfo=geninfo,
tagname=tagname,
jsonfile=jsonfile,
jecfile=jecfile,
residual=residual,
doPDFs=doPDFs,
fastsim=fastsim
)
# final tweaks to process
process.options.SkipEvent = cms.untracked.vstring('ProductNotFound')
process.TFileService.closeFileFast = cms.untracked.bool(True)