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="")
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="")
33 self.addOption ('systematicsModelJES', "Category", type=str,
34 info="the NP reduction scheme to use for JES: All, Global, Category, "
35 "Scenario. The default is Category.")
36 self.addOption ('systematicsModelJER', "Full", type=str,
37 info="the NP reduction scheme to use for JER: All, Full, Simple. The "
38 "default is Full.")
39 self.addOption ('systematicsModelJMS', "Full", type=str)
40 self.addOption ('runJERsystematicsOnData', False, type=bool,
41 info="whether to run the All/Full JER model variations also on data samples. Expert option!")
42 # Uncertainties tool options
43 self.addOption ('uncertToolConfigPath', None, type=str,
44 info="name (str) of the config file to use for the jet uncertainty "
45 "tool. Expert option to override JetETmiss recommendations. The "
46 "default is None.")
47 self.addOption ('uncertToolCalibArea', None, type=str,
48 info="name (str) of the CVMFS area to use for the jet uncertainty "
49 "tool. Expert option to override JetETmiss recommendations. The "
50 "default is None.")
51 self.addOption ('uncertToolMCType', None, type=str,
52 info="data type (str) to use for the jet uncertainty tool (e.g. "
53 "'AF3' or 'MC16'). Expert option to override JetETmiss "
54 "recommendations. The default is None.")
55

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 215 of file JetUncertaintiesConfig.py.

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

◆ createUncertaintyToolSmallRJets()

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

Definition at line 131 of file JetUncertaintiesConfig.py.

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

◆ getUncertaintyToolSettingsLargeRJets()

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

Definition at line 168 of file JetUncertaintiesConfig.py.

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

◆ getUncertaintyToolSettingsSmallRJets()

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

Definition at line 60 of file JetUncertaintiesConfig.py.

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

◆ instanceName()

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

Definition at line 56 of file JetUncertaintiesConfig.py.

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

◆ makeAlgs()

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

Definition at line 257 of file JetUncertaintiesConfig.py.

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

Member Data Documentation

◆ containerName

python.JetUncertaintiesConfig.JetUncertaintiesConfig.containerName

Definition at line 260 of file JetUncertaintiesConfig.py.

◆ jetInput

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

Definition at line 96 of file JetUncertaintiesConfig.py.

◆ runJERsystematicsOnData

python.JetUncertaintiesConfig.JetUncertaintiesConfig.runJERsystematicsOnData

Definition at line 152 of file JetUncertaintiesConfig.py.

◆ systematicsModelJER

python.JetUncertaintiesConfig.JetUncertaintiesConfig.systematicsModelJER

Definition at line 81 of file JetUncertaintiesConfig.py.

◆ systematicsModelJES

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

Definition at line 68 of file JetUncertaintiesConfig.py.

◆ systematicsModelJMS

python.JetUncertaintiesConfig.JetUncertaintiesConfig.systematicsModelJMS

Definition at line 183 of file JetUncertaintiesConfig.py.


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