ATLAS Offline Software
Loading...
Searching...
No Matches
python.JetUncertaintiesConfig.JetUncertaintiesConfig Class Reference
Inheritance diagram for python.JetUncertaintiesConfig.JetUncertaintiesConfig:
Collaboration diagram for python.JetUncertaintiesConfig.JetUncertaintiesConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 getUncertaintyToolSettingsSmallRJets (self, config)
 createUncertaintyToolSmallRJets (self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False)
 getUncertaintyToolSettingsLargeRJets (self, config)
 createUncertaintyToolLargeRJets (self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False)
 makeAlgs (self, config)

Public Attributes

str systematicsModelJES = "All":
 systematicsModelJER
str jetInput = "HI":
 runJERsystematicsOnData
 systematicsModelJMS
 containerName

Detailed Description

the ConfigBlock for the common preprocessing of jet uncertainties

Definition at line 13 of file JetUncertaintiesConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.__init__ ( self)

Definition at line 16 of file JetUncertaintiesConfig.py.

16 def __init__ (self) :
17 super (JetUncertaintiesConfig, self).__init__ ()
18 self.setBlockName('Uncertainties')
19 self.addOption ('containerName', '', type=str,
20 noneAction='error',
21 info="the name of the output container after calibration.")
22 self.addOption ('jetInput', '', type=str,
23 noneAction='error',
24 info="the type of jet input. Refer to the corresponding small- or large-R jet options.")
25 self.addOption('analysisJetSelection', '', type=str,
26 info="the jet selection to use to calculate N jets for an analysis specific "
27 "jet flavor composition uncertainty. Of the form `jvt_selection,as_char&&passesOR,as_char...`.")
28 self.addOption('analysisFile', '', type=str,
29 info="the file containing gluon fraction histograms needed to calculate an analysis specific "
30 "jet flavor composition uncertainty.")
31 self.addOption ('largeRMass', "Comb", type=str,
32 info="the large-R mass definition to use. Supported options are: `Comb`, `Calo`, `TA`.")
33 self.addOption ('systematicsModelJES', "Category", type=str,
34 info="the NP reduction scheme to use for JES: `All`, `Global`, `Category`, "
35 "`Scenario`.")
36 self.addOption ('systematicsModelJER', "Full", type=str,
37 info="the NP reduction scheme to use for JER: `All`, `Full`, `Simple`.")
38 self.addOption ('systematicsModelJMS', "Full", type=str,
39 info="the NP reduction scheme to use for JMS: `Full`, `Simple`.")
40 self.addOption ('runJERsystematicsOnData', False, type=bool,
41 info="whether to run the `All`/`Full` JER model variations also on data samples",
42 expertMode=True)
43 # Uncertainties tool options
44 self.addOption ('uncertToolConfigPath', None, type=str,
45 info="name of the config file to use for the jet uncertainty "
46 "tool. Expert option to override JetETmiss recommendations.")
47 self.addOption ('uncertToolCalibArea', None, type=str,
48 info="name of the CVMFS area to use for the jet uncertainty "
49 "tool. Expert option to override JetETmiss recommendations.")
50 self.addOption ('uncertToolMCType', None, type=str,
51 info="data type to use for the jet uncertainty tool (e.g. "
52 "`AF3` or `MC16`). Expert option to override JetETmiss "
53 "recommendations.")
54

Member Function Documentation

◆ createUncertaintyToolLargeRJets()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.createUncertaintyToolLargeRJets ( self,
jetUncertaintiesAlg,
config,
jetCollectionName,
doPseudoData = False )
Create instance(s) of JetUncertaintiesTool following JetETmiss recommendations.

JER uncertainties under the "Full" scheme must be run on MC samples twice:
1. Normal (MC) mode,
2. Pseudodata (PD) mode, as if the events are Data.

Definition at line 214 of file JetUncertaintiesConfig.py.

214 def createUncertaintyToolLargeRJets(self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False):
215 '''
216 Create instance(s) of JetUncertaintiesTool following JetETmiss recommendations.
217
218 JER uncertainties under the "Full" scheme must be run on MC samples twice:
219 1. Normal (MC) mode,
220 2. Pseudodata (PD) mode, as if the events are Data.
221 '''
222
223 # Retrieve the common configuration settings
224 configFile, calibArea, mcType = self.getUncertaintyToolSettingsLargeRJets(config)
225
226 # The main tool for all JER combinations
227 config.addPrivateTool( 'uncertaintiesTool', 'JetUncertaintiesTool' )
228 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
229 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
230 from PathResolver import PathResolver
231 if self.analysisFile is not None:
232 jetUncertaintiesAlg.uncertaintiesTool.AnalysisFile = PathResolver.FindCalibFile(self.analysisFile)
233 if calibArea is not None:
234 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
235 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
236 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType() is DataType.Data)
237 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode = False
238 jetUncertaintiesAlg.uncertaintiesTool.NJetAccessorName = "Njet_NOSYS"
239
240 # JER smearing on data
241 if config.dataType() is DataType.Data and not (config.isPhyslite() and doPseudoData and self.runJERsystematicsOnData):
242 # we don't want any systematics on data if we're not using the right JER model!
243 jetUncertaintiesAlg.affectingSystematicsFilter = '.*'
244
245 if config.dataType() is not (DataType.Data and config.isPhyslite()) and doPseudoData and not self.runJERsystematicsOnData:
246 # The secondary tool for pseudo-data JER smearing
247 config.addPrivateTool( 'uncertaintiesToolPD', 'JetUncertaintiesTool' )
248 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
249 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
250 if calibArea is not None:
251 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
252 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
253 jetUncertaintiesAlg.uncertaintiesToolPD.IsData = True
254 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode = True
255
static std::string FindCalibFile(const std::string &logical_file_name)

◆ createUncertaintyToolSmallRJets()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.createUncertaintyToolSmallRJets ( self,
jetUncertaintiesAlg,
config,
jetCollectionName,
doPseudoData = False )

Definition at line 130 of file JetUncertaintiesConfig.py.

130 def createUncertaintyToolSmallRJets(self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False):
131
132 # Create an instance of JetUncertaintiesTool, following JetETmiss recommendations.
133 # To run Jet Energy Resolution (JER) uncertainties in the "Full" or "All" schemes,
134 # we need two sets of tools: one configured as normal (MC), the other with the
135 # exact same settings but pretending to run on data (pseudo-data).
136 # This is achieved by passing "isPseudoData=True" to the arguments.
137
138 # Retrieve the common configuration settings
139 configFile, calibArea, mcType = self.getUncertaintyToolSettingsSmallRJets(config)
140
141 # The main tool for all JES+JER combinations
142 config.addPrivateTool( 'uncertaintiesTool', 'JetUncertaintiesTool' )
143 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
144 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
145 if calibArea is not None:
146 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
147 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
148 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType() is DataType.Data)
149 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode = False
150
151 if config.dataType() is DataType.Data and not (doPseudoData and self.runJERsystematicsOnData):
152 # we don't want any systematics on data if we're not using the right JER model!
153 jetUncertaintiesAlg.affectingSystematicsFilter = '.*'
154 if config.dataType() is not DataType.Data and doPseudoData and not self.runJERsystematicsOnData:
155 # The secondary tool for pseudo-data JER smearing
156 config.addPrivateTool( 'uncertaintiesToolPD', 'JetUncertaintiesTool' )
157 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
158 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
159 if calibArea is not None:
160 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
161 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
162
163 # This is the part that is different!
164 jetUncertaintiesAlg.uncertaintiesToolPD.IsData = True
165 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode = True
166

◆ getUncertaintyToolSettingsLargeRJets()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.getUncertaintyToolSettingsLargeRJets ( self,
config )

Definition at line 167 of file JetUncertaintiesConfig.py.

167 def getUncertaintyToolSettingsLargeRJets(self, config):
168 # Retrieve appropriate JES/JER recommendations for the JetUncertaintiesTool.
169 # We do this separately from the tool declaration, as we may need to set uo
170 # two such tools, but they have to be private.
171
172 log = logging.getLogger('LargeRJetAnalysisConfig')
173
174 # Config file:
175 config_file = None
176 if self.systematicsModelJER in ["Simple", "Full"] and self.systematicsModelJMS in ["Simple", "Full"]:
177 config_file = "R10_CategoryJES_{0}JER_{1}JMS.config".format(self.systematicsModelJER, self.systematicsModelJMS)
178 else:
179 raise ValueError(
180 "Invalid request for systematicsModelJER/JMS settings: "
181 "systematicsModelJER = '{0}', "
182 "systematicsModelJMS = '{1}'".format(self.systematicsModelJER, self.systematicsModelJMS) )
183 if self.uncertToolConfigPath is not None:
184 # Expert override
185 config_file = self.uncertToolConfigPath
186 else:
187 if config.geometry() in [LHCPeriod.Run2, LHCPeriod.Run3]:
188 config_file = "rel22/Summer2025_PreRec/" + config_file
189 else:
190 log.warning("Uncertainties for UFO jets are not for Run 4!")
191
192 # Calibration area:
193 calib_area = None
194 if self.uncertToolCalibArea is not None:
195 calib_area = self.uncertToolCalibArea
196
197 # MC type:
198 if self.uncertToolMCType is not None:
199 mc_type = self.uncertToolMCType
200 else:
201 if config.dataType() is DataType.FastSim:
202 if config.geometry() is LHCPeriod.Run2:
203 mc_type = "MC20AF3"
204 else:
205 mc_type = "MC23AF3"
206 else:
207 if config.geometry() is LHCPeriod.Run2:
208 mc_type = "MC20"
209 else:
210 mc_type = "MC23"
211
212 return config_file, calib_area, mc_type
213

◆ getUncertaintyToolSettingsSmallRJets()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.getUncertaintyToolSettingsSmallRJets ( self,
config )

Definition at line 59 of file JetUncertaintiesConfig.py.

59 def getUncertaintyToolSettingsSmallRJets(self, config):
60
61 # Retrieve appropriate JES/JER recommendations for the JetUncertaintiesTool.
62 # We do this separately from the tool declaration, as we may need to set uo
63 # two such tools, but they have to be private.
64
65 # Config file:
66 config_file = None
67 if self.systematicsModelJES == "All" and self.systematicsModelJER == "All":
68 config_file = "R4_AllNuisanceParameters_AllJERNP.config"
69 elif "Scenario" in self.systematicsModelJES:
70 if self.systematicsModelJER != "Simple":
71 raise ValueError(
72 "Invalid uncertainty configuration - Scenario* systematicsModelJESs can "
73 "only be used together with the Simple systematicsModelJER")
74 config_file = "R4_{0}_SimpleJER.config".format(self.systematicsModelJES)
75 elif self.systematicsModelJES in ["Global", "Category"] and self.systematicsModelJER in ["Simple", "Full"]:
76 config_file = "R4_{0}Reduction_{1}JER.config".format(self.systematicsModelJES, self.systematicsModelJER)
77 else:
78 raise ValueError(
79 "Invalid combination of systematicsModelJES and systematicsModelJER settings: "
80 "systematicsModelJES: {0}, systematicsModelJER: {1}".format(self.systematicsModelJES, self.systematicsModelJER) )
81
82 # Calibration area:
83 calib_area = None
84 if self.uncertToolCalibArea is not None:
85 calib_area = self.uncertToolCalibArea
86
87 # Expert override for config path:
88 if self.uncertToolConfigPath is not None:
89 config_file = self.uncertToolConfigPath
90 else:
91 if config.geometry() is LHCPeriod.Run2:
92 if config.dataType() is DataType.FastSim:
93 config_file = "rel22/Fall2024_PreRec/" + config_file
94 else:
95 if self.jetInput == "HI":
96 config_file = "HIJetUncertainties/Spring2023/HI" + config_file
97 else:
98 config_file = "rel22/Summer2023_PreRec/" + config_file
99 else:
100 if config.dataType() is DataType.FastSim:
101 config_file = "rel22/Winter2025_AF3_PreRec/" + config_file
102 else:
103 if self.jetInput == "HI":
104 config_file = "HIJetUncertainties/Spring2023/HI" + config_file
105 else:
106 config_file = "rel22/Winter2025_PreRec/" + config_file
107
108 # MC type:
109 mc_type = None
110 if self.uncertToolMCType is not None:
111 mc_type = self.uncertToolMCType
112 else:
113 if config.geometry() is LHCPeriod.Run2:
114 if config.dataType() is DataType.FastSim:
115 mc_type = "AF3"
116 else:
117 mc_type = "MC20"
118 else:
119 if config.dataType() is DataType.FastSim:
120 mc_type = "MC23AF3"
121 else:
122 if self.jetInput == "HI":
123 mc_type = "MC16"
124 else:
125 mc_type = "MC23"
126
127 return config_file, calib_area, mc_type
128
129

◆ instanceName()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.instanceName ( self)
Return the instance name for this block

Definition at line 55 of file JetUncertaintiesConfig.py.

55 def instanceName (self) :
56 """Return the instance name for this block"""
57 return self.containerName
58

◆ makeAlgs()

python.JetUncertaintiesConfig.JetUncertaintiesConfig.makeAlgs ( self,
config )

Definition at line 256 of file JetUncertaintiesConfig.py.

256 def makeAlgs (self, config) :
257
258 jetCollectionName=config.originalName(self.containerName)
259 if(config.originalName(self.containerName)=="AnalysisJets") :
260 jetCollectionName="AntiKt4EMPFlowJets"
261 if(config.originalName(self.containerName)=="AnalysisLargeRJets") :
262 jetCollectionName="AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
263
264 # interpret the jet collection
265 collection_pattern = re.compile(
266 r"AntiKt(\d+)(EMTopo|EMPFlow|LCTopo|TrackCaloCluster|UFO|Track|HI)(TrimmedPtFrac5SmallR20|CSSKSoftDropBeta100Zcut10)?Jets")
267 match = collection_pattern.match(jetCollectionName)
268 if not match:
269 raise ValueError(
270 "Jet collection {0} does not match expected pattern!".format(jetCollectionName) )
271 radius = int(match.group(1) )
272 if radius not in [2, 4, 6, 10]:
273 raise ValueError("Jet collection has an unsupported radius '{0}'!".format(radius) )
274
275 if (self.analysisJetSelection!= ''):
276 alg = config.createAlgorithm( 'CP::NJetDecoratorAlg', 'NJetDecoratorAlg' )
277 alg.jets = config.readName(self.containerName)
278 alg.jetSelection = self.analysisJetSelection
279 config.addOutputVar('EventInfo', 'Njet_%SYS%', 'Njet')
280
281 # Jet uncertainties
282 if (radius == 4):
283 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
284 self.createUncertaintyToolSmallRJets(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER in ["Full","All"] ))
285 alg.jets = config.readName (self.containerName)
286 alg.jetsOut = config.copyName (self.containerName)
287 alg.preselection = config.getPreselection (self.containerName, '')
288
289 elif (radius == 10):
290 if self.jetInput == "UFO" and config.dataType() in [DataType.FullSim, DataType.FastSim]:
291 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
292 self.createUncertaintyToolLargeRJets(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER in ["Full","All"] ))
293
294 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
295
296 # R=1.0 jets have a validity range
297 alg.outOfValidity = 2 # SILENT
298 alg.outOfValidityDeco = 'outOfValidity'
299
300 alg.jets = config.readName (self.containerName)
301 alg.jetsOut = config.copyName (self.containerName)
302 alg.preselection = config.getPreselection (self.containerName, '')
303
304 if self.jetInput != "UFO":
305 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
306
307 # R=1.0 jets have a validity range
308 alg.outOfValidity = 2 # SILENT
309 alg.outOfValidityDeco = 'outOfValidity'
310 config.addPrivateTool( 'uncertaintiesTool', 'JetUncertaintiesTool' )
311
312 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
313 alg.uncertaintiesTool.ConfigFile = \
314 "rel21/Moriond2018/R10_{0}Mass_all.config".format(self.largeRMass)
315 alg.uncertaintiesTool.MCType = "MC16a"
316 alg.uncertaintiesTool.IsData = (config.dataType() is DataType.Data)
317
318 alg.jets = config.readName (self.containerName)
319 alg.jetsOut = config.copyName (self.containerName)
320 alg.preselection = config.getPreselection (self.containerName, '')
321 config.addSelection (self.containerName, '', 'outOfValidity')
if(febId1==febId2)

Member Data Documentation

◆ containerName

python.JetUncertaintiesConfig.JetUncertaintiesConfig.containerName

Definition at line 259 of file JetUncertaintiesConfig.py.

◆ jetInput

str python.JetUncertaintiesConfig.JetUncertaintiesConfig.jetInput = "HI":

Definition at line 95 of file JetUncertaintiesConfig.py.

◆ runJERsystematicsOnData

python.JetUncertaintiesConfig.JetUncertaintiesConfig.runJERsystematicsOnData

Definition at line 151 of file JetUncertaintiesConfig.py.

◆ systematicsModelJER

python.JetUncertaintiesConfig.JetUncertaintiesConfig.systematicsModelJER

Definition at line 80 of file JetUncertaintiesConfig.py.

◆ systematicsModelJES

python.JetUncertaintiesConfig.JetUncertaintiesConfig.systematicsModelJES = "All":

Definition at line 67 of file JetUncertaintiesConfig.py.

◆ systematicsModelJMS

python.JetUncertaintiesConfig.JetUncertaintiesConfig.systematicsModelJMS

Definition at line 182 of file JetUncertaintiesConfig.py.


The documentation for this class was generated from the following file: