ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetValidation
scripts
jetMakeRefSamples.py
Go to the documentation of this file.
1
#!/bin/env python
2
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
5
6
17
18
import
os, os.path
19
import
sys
20
import
subprocess
21
import
argparse
22
23
parser = argparse.ArgumentParser(description=
'''
24
Creates reference ESD/AOD by running a series of Reco_tf.py from a given input
25
file (typically RDO or RAW).
26
Performs typically 2 jobs :
27
RDO/RAW --> ESD
28
ESD --> AOD
29
Each step produces a file which is expected to be similar to the reference
30
files in /afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/.
31
32
Ex:
33
%s MC # -> create reference files from /afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/MC/RDO
34
%s MC MyDir # -> same but creates files under MyDir/
35
%s ESD.root MyDir # -> create an AOD reference file from ESD.root under MyDir/
36
'''
%((os.path.basename(sys.argv[0]),)*3),
37
formatter_class=argparse.RawDescriptionHelpFormatter,
38
)
39
40
parser.add_argument(
'sampleType'
, type=str, help=
'full path to a file. Or "mc" or "data" : will start with a reference RDO or RAW file from the JetEtmiss afs space'
)
41
parser.add_argument(
'outputDir'
, type=str, nargs=
'?'
, default=
'jetRefFiles/'
)
42
43
parser.add_argument(
'-n'
,
'--noRun'
, action=
'store_true'
, help=
'Do not run the Reco_tf commands, just print them.'
)
44
parser.add_argument(
'--maxEvents'
, type=int, default=50, help=
"Propaged to the maxEvents of the Reco_tf commands"
)
45
parser.add_argument(
'--oneStep'
, action=
'store_true'
, help=
"stop after 1st step processed"
)
46
parser.add_argument(
'--overWrite'
, action=
'store_true'
, help=
"force to overWrite the output dir"
)
47
48
49
arg=parser.parse_args()
50
51
52
#print (arg.sampleType , arg.outputDir, arg.noRun)
53
54
maxEvents=arg.maxEvents
55
skipEvents=0
56
logFile=
"output.log"
57
58
#Geometry/conditions tags:
59
# Matched what was done for the official production of the sample at the time of this writing
60
# geometryVersion=ATLAS-GEO-20-00-01
61
# conditionsTagMC=OFLCOND-MC12-SDR-06
62
# conditionsTagData=COMCOND-BLKPA-RUN1-01
63
# http://www-f9.ijs.si/atlpy/atlprod/prodrequest/?q=mc12_8TeV.117050.PowhegPythia_P2011C_ttbar
64
# http://panda.cern.ch/server/pandamon/query/?reqid=1162571&mode=showtask0
65
# https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/CoolProdTags
66
geometryVersion=
"ATLAS-GEO-20-00-01"
67
conditionsTagMC=
"OFLCOND-MC12-SDR-06"
68
conditionsTagData=
"COMCOND-BLKPA-RUN1-01"
69
IsCOMMON=
True
70
71
72
# Default input files
73
#defaultMC="/afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/MC/HITS/mc12_8TeV.CurrentRef.HITS.pool.root"
74
#defaultMC="/afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/MC/HITS/mc12_8TeV.117050.PowhegPythia_P2011C_ttbar.simul.HITS.e1728_s1581.039772.pool.root.1"
75
defaultMC=
"/afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/MC/RDO/mc12_8TeV.CurrentRef.RDO.pool.root"
76
defaultData=
"/afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/DATA/RAW/data12_8TeV.CurrentRef.RAW"
77
#defaultData="/afs/cern.ch/atlas/groups/JetEtmiss/ReferenceFiles/RTT/DATA/RAW/data12_8TeV.00209109.physics_JetTauEtmiss.merge.RAW._lb0186._SFO-1._0001.1"
78
79
80
def
makeDirAndCd
(dir):
81
if
not
os.path.exists(dir):
82
os.mkdir(dir)
83
elif
not
arg.overWrite:
84
print
()
85
print
(
"ERROR !!!"
)
86
print
(
" Directory "
,dir,
'already exists. Not overwriting it (use --overWrite option if needed)'
)
87
sys.exit(1)
88
89
os.chdir(dir)
90
91
92
def
runStep
(inputFile):
93
if
not
os.path.exists(inputFile)
and
not
arg.noRun:
94
print
(
'ERROR input file '
, inputFile ,
' missing'
)
95
sys.exit(2)
96
97
preExec =
''
98
transform=
"Reco_tf.py"
99
100
inputFileBase = os.path.basename(inputFile)
101
102
if
'HITS'
in
inputFileBase:
103
inputType =
'HITS'
104
outputType =
"RDO"
105
#transform="Digi_trf.py"
106
preExec=
""
107
108
elif
"RDO"
in
inputFileBase:
109
inputType=
"RDO"
110
inputDataType=inputType
111
outputType=
"ESD"
112
preExec=
'''flags.Reco.EnableTrigger=False; flags.Reco.EnableBTagging=False'''
113
114
elif
"RAW"
in
inputFileBase:
115
inputType=
"RAW"
116
inputDataType=
"BS"
#bytestream
117
outputType=
"ESD"
118
preExec=
'''flags.Reco.EnableTrigger=False'''
119
120
elif
'ESD'
in
inputFileBase:
121
inputType=
"ESD"
122
inputDataType=inputType
123
outputType=
"AOD"
124
preExec=
'''flags.Reco.EnableTrigger=False'''
125
126
else
:
127
print
(
"ERROR RunStep: Input file does not appear to be a supported type (RAW, HITS, RDO, ESD)"
)
128
print
(
' -> got'
, inputFileBase)
129
sys.exit(3)
130
131
print
(
"Starting "
,inputType,
' to '
, outputType)
132
133
134
runDir = arg.outputDir +
'/'
+ inputType+
'to'
+outputType +
'/'
135
if
not
os.path.exists(runDir):
136
os.mkdir(runDir)
137
outputFile = runDir + inputFileBase.replace(inputType, outputType)
138
if
arg.overWrite
and
os.path.exists(outputFile):
139
os.remove(outputFile)
140
141
outputLog = runDir+
'log'
142
143
comandArgs = [
'--preExec='
+preExec,
144
'--input%sFile=%s'
%(inputDataType, inputFile),
145
'--output%sFile=%s'
%(outputType, outputFile),
146
'--maxEvents='
+str(maxEvents),
147
'--skipEvents='
+str(skipEvents),
148
'--autoConfiguration=everything'
,
149
]
150
151
print
(
'Running : '
)
152
print
(transform,
' '
.join(comandArgs))
153
print
()
154
155
if
arg.noRun :
156
res = 0
157
else
:
158
logfile = open(outputLog,
'w'
)
159
res = subprocess.call( [transform] + comandArgs, stdout=logfile, stderr=logfile)
160
logfile.close()
161
162
if
res != 0:
163
print
(
'ERROR RunStep: Transform appears to have failed - exiting. Check '
, outputLog)
164
sys.exit(4)
165
166
167
168
print
(
'Done %s to %s step'
%(inputType, outputType))
169
return
outputFile
170
171
172
def
runChain
(inputFile):
173
print
(
'runChain '
, inputFile)
174
while
any( [t
in
os.path.basename(inputFile)
for
t
in
[
'HITS'
,
'RDO'
,
'RAW'
,
'ESD'
] ] ):
175
print
(
'runStep at '
,os.path.basename(inputFile))
176
inputFile =
runStep
(inputFile)
177
if
arg.oneStep:
178
return
179
180
181
if
arg.sampleType.lower() ==
'mc'
:
182
inputFile=defaultMC
183
elif
arg.sampleType.lower() ==
'data'
:
184
inputFile=defaultData
185
else
:
186
# assume sampleType is a path
187
inputFile = os.path.abspath(arg.sampleType)
188
189
if
not
os.path.exists(inputFile):
190
print
(
'ERROR Input path does not exist '
, inputFile)
191
sys.exit(5)
192
193
194
arg.outputDir = os.path.abspath(arg.outputDir)
195
196
makeDirAndCd
( arg.outputDir )
197
198
runChain
(inputFile)
199
200
sys.exit(0)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
jetMakeRefSamples.runStep
runStep(inputFile)
Definition
jetMakeRefSamples.py:92
jetMakeRefSamples.runChain
runChain(inputFile)
Definition
jetMakeRefSamples.py:172
jetMakeRefSamples.makeDirAndCd
makeDirAndCd(dir)
Definition
jetMakeRefSamples.py:80
Generated on
for ATLAS Offline Software by
1.17.0