4 from __future__
import print_function
7 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
8 from AnalysisAlgorithmsConfig.ConfigSequence
import groupBlocks
9 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
11 from AthenaConfiguration.Enums
import LHCPeriod
12 from AthenaCommon.Logging
import logging
17 """the ConfigBlock for the common preprocessing of jet sequences"""
20 super (PreJetAnalysisConfig, self).__init__ ()
21 self.addOption (
'containerName',
'', type=str,
23 info=
"the name of the output container after calibration.")
24 self.addOption (
'jetCollection',
'', type=str,
26 info=
"the jet container to run on. It is interpreted to determine "
27 "the correct config blocks to call for small- or large-R jets.")
28 self.addOption(
'outputTruthLabelIDs',
False, type=bool,
29 info=
'Enable or disable HadronConeExclTruthLabelID and PartonTruthLabelID decorations')
31 self.addOption (
'runOriginalObjectLink',
False, type=bool,
33 self.addOption (
'runGhostMuonAssociation',
None, type=bool,
34 info=
"whether to set up the jet-ghost-muon association algorithm "
35 "CP::JetGhostMuonAssociationAlg. The default is True for non-PHYSLITE and False for PHYSLITE.")
36 self.addOption (
'runTruthJetTagging',
None, type=bool,
37 info=
"whether to set up the jet truth tagging algorithm "
38 "CP::JetTruthTagAlg. The default is True.")
41 """Return the instance name for this block"""
42 return self.containerName
48 config.setSourceName (self.containerName,
"AnalysisJets", originalName = self.
jetCollection)
49 elif config.isPhyslite()
and self.
jetCollection ==
'AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets' :
50 config.setSourceName (self.containerName,
"AnalysisLargeRJets", originalName = self.
jetCollection)
55 if self.runOriginalObjectLink :
56 alg = config.createAlgorithm(
'CP::AsgOriginalObjectLinkAlg',
57 'JetOriginalObjectLinkAlg',
60 alg.particles = config.readName (self.containerName)
61 if config.wantCopy (self.containerName) :
62 alg.particlesOut = config.copyName (self.containerName)
63 alg.preselection = config.getPreselection (self.containerName,
'')
66 if (self.runGhostMuonAssociation
is None and not config.isPhyslite())
or \
67 (self.runGhostMuonAssociation
is True):
68 alg = config.createAlgorithm(
'CP::JetGhostMuonAssociationAlg',
69 'JetGhostMuonAssociationAlg' )
70 alg.jets = config.readName (self.containerName)
71 if config.isPhyslite():
72 alg.muons =
"AnalysisMuons"
73 if config.wantCopy (self.containerName) :
74 alg.jetsOut = config.copyName (self.containerName)
78 if self.runTruthJetTagging
or (
79 self.runTruthJetTagging
is None
80 and config.dataType()
is not DataType.Data
83 alg = config.createAlgorithm(
'CP::JetDecoratorAlg',
'JetPileupLabelAlg' )
84 config.addPrivateTool(
'decorator',
'JetPileupLabelingTool' )
85 alg.jets = config.readName (self.containerName)
86 alg.jetsOut = config.copyName (self.containerName)
87 alg.decorator.RecoJetContainer = alg.jetsOut.replace (
'%SYS%',
'NOSYS')
88 alg.decorator.SuppressOutputDependence=
True
91 if config.wantCopy (self.containerName) :
92 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'JetShallowCopyAlg' )
93 alg.input = config.readName (self.containerName)
94 alg.output = config.copyName (self.containerName)
96 config.addOutputVar (self.containerName,
'pt',
'pt')
97 config.addOutputVar (self.containerName,
'eta',
'eta', noSys=
True)
98 config.addOutputVar (self.containerName,
'phi',
'phi', noSys=
True)
99 config.addOutputVar (self.containerName,
'charge',
'charge', noSys=
True, enabled=
False)
101 if self.outputTruthLabelIDs
and config.dataType()
is not DataType.Data:
102 config.addOutputVar (self.containerName,
'HadronConeExclTruthLabelID',
'HadronConeExclTruthLabelID', noSys=
True)
103 config.addOutputVar (self.containerName,
'PartonTruthLabelID',
'PartonTruthLabelID', noSys=
True)
108 """the ConfigBlock for the small-r jet sequence"""
111 super (SmallRJetAnalysisConfig, self).__init__ ()
112 self.addOption (
'containerName',
'', type=str,
114 info=
"the name of the output container after calibration.")
115 self.addOption (
'jetCollection',
'', type=str,
117 info=
"the jet container to run on. It is interpreted to determine "
118 "the correct config blocks to call for small- or large-R jets.")
120 self.addOption (
'jetInput',
'', type=str,
123 self.addOption (
'runJvtUpdate',
False, type=bool,
124 info=
"whether to update the JVT. The default is False.")
125 self.addOption (
'runNNJvtUpdate',
False, type=bool,
126 info=
"whether to update the NN-JVT. The default is False.")
127 self.addOption (
'runJvtSelection',
True, type=bool,
128 info=
"whether to run JVT selection. The default is True.")
129 self.addOption (
'runFJvtSelection',
False, type=bool,
130 info=
"whether to run forward JVT selection. The default is False.")
131 self.addOption (
'jvtWP',
"FixedEffPt", type=str,
132 info=
"which Jvt WP to apply. The default is FixedEffPt.")
133 self.addOption (
'fJvtWP',
"Loose", type=str,
134 info=
"which fJvt WP to apply. The default is Loose.")
135 self.addOption (
'runJvtEfficiency',
True, type=bool,
136 info=
"whether to calculate the JVT efficiency. The default is True.")
137 self.addOption (
'runFJvtEfficiency',
False, type=bool,
138 info=
"whether to calculate the forward JVT efficiency. The default is False.")
139 self.addOption (
'systematicsModelJES',
"Category", type=str,
140 info=
"the NP reduction scheme to use for JES: All, Global, Category, "
141 "Scenario. The default is Category.")
142 self.addOption (
'systematicsModelJER',
"Full", type=str,
143 info=
"the NP reduction scheme to use for JER: All, Full, Simple. The "
145 self.addOption (
'runJERsystematicsOnData',
False, type=bool,
146 info=
"whether to run the All/Full JER model variations also on data samples. Expert option!")
147 self.addOption (
'recalibratePhyslite',
True, type=bool,
148 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE derivations. "
149 "The default is True.")
151 self.addOption (
'calibToolConfigFile',
None, type=str,
152 info=
"name (str) of the config file to use for the jet calibration "
153 "tool. Expert option to override JetETmiss recommendations. The "
155 self.addOption (
'calibToolCalibArea',
None, type=str,
156 info=
"name (str) of the CVMFS area to use for the jet calibration "
157 "tool. Expert option to override JetETmiss recommendations. The "
159 self.addOption (
'calibToolCalibSeq',
None, type=str,
160 info=
"name (str) of the sequence to use for the jet calibration "
161 "tool (e.g. 'JetArea_Residual_EtaJES_GSC'). Expert option to override "
162 "JetETmiss recommendations. The default is None.")
164 self.addOption (
'uncertToolConfigPath',
None, type=str,
165 info=
"name (str) of the config file to use for the jet uncertainty "
166 "tool. Expert option to override JetETmiss recommendations. The "
168 self.addOption (
'uncertToolCalibArea',
None, type=str,
169 info=
"name (str) of the CVMFS area to use for the jet uncertainty "
170 "tool. Expert option to override JetETmiss recommendations. The "
172 self.addOption (
'uncertToolMCType',
None, type=str,
173 info=
"data type (str) to use for the jet uncertainty tool (e.g. "
174 "'AF3' or 'MC16'). Expert option to override JetETmiss "
175 "recommendations. The default is None.")
178 """Return the instance name for this block"""
179 return self.containerName
190 config_file =
"R4_AllNuisanceParameters_AllJERNP.config"
194 "Invalid uncertainty configuration - Scenario* systematicsModelJESs can "
195 "only be used together with the Simple systematicsModelJER")
201 "Invalid combination of systematicsModelJES and systematicsModelJER settings: "
206 if self.uncertToolCalibArea
is not None:
207 calib_area = self.uncertToolCalibArea
210 if self.uncertToolConfigPath
is not None:
211 config_file = self.uncertToolConfigPath
213 if config.geometry()
is LHCPeriod.Run2:
214 if config.dataType()
is DataType.FastSim:
215 config_file =
"rel22/Fall2024_PreRec/" + config_file
218 config_file =
"HIJetUncertainties/Spring2023/HI" + config_file
220 config_file =
"rel22/Summer2023_PreRec/" + config_file
222 if config.dataType()
is DataType.FastSim:
223 config_file =
"rel22/Winter2025_AF3_PreRec/" + config_file
226 config_file =
"HIJetUncertainties/Spring2023/HI" + config_file
228 config_file =
"rel22/Winter2025_PreRec/" + config_file
232 if self.uncertToolMCType
is not None:
233 mc_type = self.uncertToolMCType
235 if config.geometry()
is LHCPeriod.Run2:
236 if config.dataType()
is DataType.FastSim:
241 if config.dataType()
is DataType.FastSim:
249 return config_file, calib_area, mc_type
264 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
265 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
266 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
267 if calibArea
is not None:
268 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
269 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
270 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
271 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode =
False
273 if config.dataType()
is DataType.Data
and not (doPseudoData
and self.runJERsystematicsOnData):
275 jetUncertaintiesAlg.affectingSystematicsFilter =
'.*'
276 if config.dataType()
is not DataType.Data
and doPseudoData
and not self.runJERsystematicsOnData:
278 config.addPrivateTool(
'uncertaintiesToolPD',
'JetUncertaintiesTool' )
279 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
280 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
281 if calibArea
is not None:
282 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
283 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
286 jetUncertaintiesAlg.uncertaintiesToolPD.IsData =
True
287 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode =
True
294 jetCollectionName=
"AntiKt4EMPFlowJets"
296 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
298 if self.
jetInput not in [
"EMTopo",
"EMPFlow",
"HI"]:
300 "Unsupported input type '{0}' for R=0.4 jets!".
format(self.
jetInput) )
302 if self.jvtWP
not in [
"FixedEffPt"]:
304 "Unsupported NNJvt WP '{0}'".
format(self.jvtWP) )
306 if self.fJvtWP
not in [
"Loose",
"Tight",
"Tighter"]:
308 "Unsupported fJvt WP '{0}'".
format(self.fJvtWP) )
310 if not config.isPhyslite()
or self.recalibratePhyslite:
312 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg' )
313 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
314 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
317 if config.geometry()
is LHCPeriod.Run2:
318 configFile =
"PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"
319 alg.calibrationTool.CalibArea =
"00-04-82"
320 elif config.geometry() >= LHCPeriod.Run3:
321 configFile =
"AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_241208_InSitu.config"
322 alg.calibrationTool.CalibArea =
"00-04-83"
324 if config.geometry()
is LHCPeriod.Run2:
325 configFile =
"JES_MC16_HI_Jan2021_5TeV.config"
326 if config.geometry()
is LHCPeriod.Run3:
327 configFile =
"AntiKt4HI_JES_constants_11-05-2024_13p6TeVFinalConfiguration.config"
328 alg.calibrationTool.CalibArea =
"00-04-83"
330 if config.dataType()
is DataType.FastSim:
331 configFile =
"JES_MC16Recommendation_AFII_{0}_Apr2019_Rel21.config"
333 configFile =
"JES_MC16Recommendation_Consolidated_{0}_Apr2019_Rel21.config"
334 configFile = configFile.format(self.
jetInput)
335 if self.calibToolCalibArea
is not None:
336 alg.calibrationTool.CalibArea = self.calibToolCalibArea
337 if self.calibToolConfigFile
is not None:
338 configFile = self.calibToolConfigFile
339 alg.calibrationTool.ConfigFile = configFile
340 if config.dataType()
is DataType.Data:
342 if config.geometry()
is LHCPeriod.Run2:
343 alg.calibrationTool.CalibSequence =
'EtaJES_Insitu'
344 if config.geometry()
is LHCPeriod.Run3:
345 alg.calibrationTool.CalibSequence =
'EtaJES'
347 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC_Insitu'
350 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC'
352 alg.calibrationTool.CalibSequence =
'EtaJES'
354 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC_Smear'
355 if self.calibToolCalibSeq
is not None:
356 alg.calibrationTool.CalibSequence = self.calibToolCalibSeq
357 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
358 alg.jets = config.readName (self.containerName)
359 alg.jetsOut = config.copyName (self.containerName)
362 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg' )
364 alg.jets = config.readName (self.containerName)
365 alg.jetsOut = config.copyName (self.containerName)
366 alg.preselection = config.getPreselection (self.containerName,
'')
369 if self.runJvtUpdate :
370 alg = config.createAlgorithm(
'CP::JvtUpdateAlg',
'JvtUpdateAlg' )
371 config.addPrivateTool(
'jvtTool',
'JetVertexTaggerTool' )
373 alg.jvtTool.SuppressInputDependence=
True
374 alg.jets = config.readName (self.containerName)
375 alg.jetsOut = config.copyName (self.containerName)
376 alg.preselection = config.getPreselection (self.containerName,
'')
378 if self.runNNJvtUpdate:
379 assert self.
jetInput==
"EMPFlow",
"NN JVT only defined for PFlow jets"
380 alg = config.createAlgorithm(
'CP::JetDecoratorAlg',
'NNJvtUpdateAlg' )
381 config.addPrivateTool(
'decorator',
'JetPileupTag::JetVertexNNTagger' )
383 alg.jets = config.readName (self.containerName)
384 alg.jetsOut = config.copyName (self.containerName)
385 alg.decorator.JetContainer = alg.jetsOut.replace (
'%SYS%',
'NOSYS')
386 alg.decorator.SuppressInputDependence=
True
387 alg.decorator.SuppressOutputDependence=
True
391 if self.runJvtSelection :
392 assert self.
jetInput==
"EMPFlow",
"NNJvt WPs and SFs only valid for PFlow jets"
393 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'JvtSelectionAlg')
394 config.addPrivateTool(
'selectionTool',
'CP::NNJvtSelectionTool')
395 alg.selectionTool.JetContainer = config.readName(self.containerName)
396 alg.selectionTool.WorkingPoint = self.jvtWP
397 alg.selectionTool.MaxPtForJvt = 60*GeV
398 alg.selectionDecoration =
"jvt_selection,as_char"
399 alg.particles = config.readName(self.containerName)
401 if self.runJvtEfficiency
and config.dataType()
is not DataType.Data:
402 alg = config.createAlgorithm(
'CP::JvtEfficiencyAlg',
'JvtEfficiencyAlg' )
403 config.addPrivateTool(
'efficiencyTool',
'CP::NNJvtEfficiencyTool' )
404 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
405 alg.efficiencyTool.MaxPtForJvt = 60*GeV
406 alg.efficiencyTool.WorkingPoint = self.jvtWP
407 if config.geometry()
is LHCPeriod.Run2:
408 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/NNJvtSFFile_Run2_EMPFlow.root"
410 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/NNJvtSFFile_Run3_EMPFlow.root"
411 alg.selection =
'jvt_selection,as_char'
412 alg.scaleFactorDecoration =
'jvt_effSF_%SYS%'
413 alg.outOfValidity = 2
414 alg.outOfValidityDeco =
'no_jvt'
415 alg.skipBadEfficiency =
False
416 alg.jets = config.readName (self.containerName)
417 alg.preselection = config.getPreselection (self.containerName,
'')
418 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'jvtEfficiency')
419 config.addSelection (self.containerName,
'baselineJvt',
'jvt_selection,as_char', preselection=
False)
421 if self.runFJvtSelection :
422 assert self.
jetInput==
"EMPFlow",
"fJvt WPs and SFs only valid for PFlow jets"
423 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'FJvtSelectionAlg')
424 config.addPrivateTool(
'selectionTool',
'CP::FJvtSelectionTool')
425 alg.selectionTool.JetContainer = config.readName(self.containerName)
426 alg.selectionTool.WorkingPoint = self.fJvtWP
427 alg.selectionDecoration =
"fjvt_selection,as_char"
428 alg.particles = config.readName(self.containerName)
430 if self.runFJvtEfficiency
and config.dataType()
is not DataType.Data:
431 alg = config.createAlgorithm(
'CP::JvtEfficiencyAlg',
'FJvtEfficiencyAlg' )
432 config.addPrivateTool(
'efficiencyTool',
'CP::FJvtEfficiencyTool' )
433 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
434 alg.efficiencyTool.WorkingPoint = self.fJvtWP
435 if config.geometry()
is LHCPeriod.Run2:
436 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/fJvtSFFile_Run2_EMPFlow.root"
438 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/fJvtSFFile_Run3_EMPFlow.root"
439 alg.selection =
'fjvt_selection,as_char'
440 alg.scaleFactorDecoration =
'fjvt_effSF_%SYS%'
441 alg.outOfValidity = 2
442 alg.outOfValidityDeco =
'no_fjvt'
443 alg.skipBadEfficiency =
False
444 alg.jets = config.readName (self.containerName)
445 alg.preselection = config.getPreselection (self.containerName,
'')
446 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'fjvtEfficiency')
447 config.addSelection (self.containerName,
'baselineFJvt',
'fjvt_selection,as_char', preselection=
False)
450 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'AsgEnergyDecoratorAlg' )
451 alg.particles = config.readName (self.containerName)
453 config.addOutputVar (self.containerName,
'e_%SYS%',
'e')
457 """the ConfigBlock for the r-scan jet sequence"""
460 super (RScanJetAnalysisConfig, self).__init__ ()
461 self.addOption (
'containerName',
'', type=str,
463 info=
"the name of the output container after calibration.")
464 self.addOption (
'jetCollection',
'', type=str,
466 info=
"the jet container to run on. It is interpreted to determine "
467 "the correct config blocks to call for small- or large-R jets.")
469 self.addOption (
'jetInput',
'', type=str,
473 self.addOption (
'radius',
None, type=int,
476 self.addOption (
'recalibratePhyslite',
True, type=bool,
477 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE "
478 "derivations. The default is True.")
481 """Return the instance name for this block"""
482 return self.containerName
486 log = logging.getLogger(
'RScanJetAnalysisConfig')
490 jetCollectionName=
"AntiKt4EMPFlowJets"
492 jetCollectionName=
"AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets"
494 if not config.isPhyslite()
or self.recalibratePhyslite:
495 if self.jetInput !=
"LCTopo":
497 "Unsupported input type '{0}' for R-scan jets!".
format(self.jetInput) )
499 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg' )
500 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
501 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
502 alg.calibrationTool.ConfigFile = \
503 "JES_MC16Recommendation_Rscan{0}LC_Feb2022_R21.config".
format(self.radius)
504 if config.dataType()
is DataType.Data:
505 alg.calibrationTool.CalibSequence =
"JetArea_Residual_EtaJES_GSC_Insitu"
507 alg.calibrationTool.CalibSequence =
"JetArea_Residual_EtaJES_GSC_Smear"
508 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
509 alg.jets = config.readName (self.containerName)
511 log.warning(
"Uncertainties for R-Scan jets are not yet released!")
515 is_sim = config.dataType()
in {DataType.FullSim}
516 if self.largeRMass ==
"Comb":
517 if config.dataType()
is DataType.Data:
518 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
520 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_17Oct2018.config"
521 elif self.largeRMass ==
"Calo":
522 if config.dataType()
is DataType.Data:
523 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
525 return "JES_MC16recommendation_FatJet_Trimmed_JMS_calo_12Oct2018.config "
526 elif self.largeRMass ==
"TA":
527 if config.dataType()
is DataType.Data:
528 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
530 return "JES_MC16recommendation_FatJet_Trimmed_JMS_TA_12Oct2018.config"
535 """the ConfigBlock for the large-r jet sequence"""
538 super (LargeRJetAnalysisConfig, self).__init__ ()
539 self.addOption (
'containerName',
'', type=str,
541 info=
"the name of the output container after calibration.")
542 self.addOption (
'jetCollection',
'', type=str,
544 info=
"the jet container to run on. It is interpreted to determine "
545 "the correct config blocks to call for small- or large-R jets.")
547 self.addOption (
'jetInput',
'', type=str,
551 self.addOption (
'largeRMass',
"Comb", type=str,
553 self.addOption (
'recalibratePhyslite',
True, type=bool,
554 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE "
555 "derivations. The default is True.")
556 self.addOption (
'systematicsModelJER',
"Full", type=str)
557 self.addOption (
'systematicsModelJMS',
"Full", type=str)
558 self.addOption (
'systematicsModelJMR',
"Full", type=str,
559 info=
"the NP reduction scheme to use for JMR: Full, Simple. The default is Full.")
560 self.addOption (
'runJERsystematicsOnData',
False, type=bool,
561 info=
"whether to run the All/Full JER model variations also on data samples. Expert option!")
564 self.addOption (
'calibToolConfigFile',
None, type=str,
565 info=
"name (str) of the config file to use for the jet calibration "
566 "tool. Expert option to override JetETmiss recommendations. The "
568 self.addOption (
'calibToolCalibArea',
None, type=str,
569 info=
"name (str) of the CVMFS area to use for the jet calibration "
570 "tool. Expert option to override JetETmiss recommendations. The "
572 self.addOption (
'calibToolCalibSeq',
None, type=str,
573 info=
"name (str) of the sequence to use for the jet calibration "
574 "tool (e.g. 'JetArea_Residual_EtaJES_GSC'). Expert option to override "
575 "JetETmiss recommendations. The default is None.")
577 self.addOption (
'uncertToolConfigPath',
None, type=str,
578 info=
"name (str) of the config file to use for the JES, JER, and JMS uncertainty "
579 "tool. Expert option to override JetETmiss recommendations. The "
581 self.addOption (
'uncertToolConfigPathJMR',
None, type=str,
582 info=
"name (str) of the config file to use for the JMR uncertainty "
583 "tool. Expert option to override JetETmiss recommendations. The "
585 self.addOption (
'uncertToolCalibArea',
None, type=str,
586 info=
"name (str) of the CVMFS area to use for the jet uncertainty "
587 "tool. Expert option to override JetETmiss recommendations. The "
589 self.addOption (
'uncertToolMCType',
None, type=str,
590 info=
"data type (str) to use for the jet uncertainty tool (e.g. "
591 "'AF3' or 'MC16'). Expert option to override JetETmiss "
592 "recommendations. The default is None.")
593 self.addOption (
'minPt', 200.*GeV, type=float,
594 info=
"the minimum pt cut to apply to calibrated large-R jets. "
595 "The default is 200 GeV.")
596 self.addOption (
'maxPt', 3000.*GeV, type=float,
597 info=
"the maximum pt cut to apply to calibrated large-R jets. "
598 "The default is 3000 GeV.")
599 self.addOption (
'maxEta', 0., type=float,
600 info=
"the maximum |eta| cut to apply to calibrated large-R jets. "
602 self.addOption (
'maxRapidity', 2., type=float,
603 info=
"the maximum rapidity cut to apply to calibrated large-R jets. "
605 self.addOption (
'minMass', 40.*GeV, type=float,
606 info=
"the minimum mass cut to apply to calibrated large-R jets. "
607 "The default is 40 GeV.")
608 self.addOption (
'maxMass', 600.*GeV, type=float,
609 info=
"the maximum mass cut to apply to calibrated large-R jets. "
610 "The default is 600 GeV.")
613 """Return the instance name for this block"""
614 return self.containerName
621 log = logging.getLogger(
'LargeRJetAnalysisConfig')
625 if self.systematicsModelJER
in [
"Simple",
"Full"]
and self.systematicsModelJMS
in [
"Simple",
"Full"]:
626 config_file =
"R10_CategoryJES_{0}JER_{1}JMS.config".
format(self.systematicsModelJER, self.systematicsModelJMS)
629 "Invalid request for systematicsModelJER/JMS settings: "
630 "systematicsModelJER = '{0}', "
631 "systematicsModelJMS = '{1}'".
format(self.systematicsModelJER, self.systematicsModelJMS) )
632 if self.uncertToolConfigPath
is not None:
634 config_file = self.uncertToolConfigPath
636 if config.geometry()
in [LHCPeriod.Run2, LHCPeriod.Run3]:
637 config_file =
"rel22/Summer2025_PreRec/" + config_file
639 log.warning(
"Uncertainties for UFO jets are not for Run 4!")
643 if self.uncertToolCalibArea
is not None:
644 calib_area = self.uncertToolCalibArea
647 if self.uncertToolMCType
is not None:
648 mc_type = self.uncertToolMCType
650 if config.dataType()
is DataType.FastSim:
651 if config.geometry()
is LHCPeriod.Run2:
656 if config.geometry()
is LHCPeriod.Run2:
661 return config_file, calib_area, mc_type
665 Create instance(s) of JetUncertaintiesTool following JetETmiss recommendations.
667 JER uncertainties under the "Full" scheme must be run on MC samples twice:
669 2. Pseudodata (PD) mode, as if the events are Data.
676 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
677 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
678 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
679 if calibArea
is not None:
680 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
681 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
682 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
683 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode =
False
686 if config.dataType()
is DataType.Data
and not (config.isPhyslite()
and doPseudoData
and self.runJERsystematicsOnData):
688 jetUncertaintiesAlg.affectingSystematicsFilter =
'.*'
690 if config.dataType()
is not (DataType.Data
and config.isPhyslite())
and doPseudoData
and not self.runJERsystematicsOnData:
692 config.addPrivateTool(
'uncertaintiesToolPD',
'JetUncertaintiesTool' )
693 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
694 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
695 if calibArea
is not None:
696 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
697 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
698 jetUncertaintiesAlg.uncertaintiesToolPD.IsData =
True
699 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode =
True
704 log = logging.getLogger(
'LargeRJetAnalysisConfig')
707 if self.systematicsModelJMR
in [
"Simple",
"Full"]:
708 config_file = f
"R10_{self.systematicsModelJMR}JMR.config"
711 f
"Invalid request for systematicsModelJMR settings: {self.systematicsModelJMR}"
715 if self.uncertToolConfigPathJMR
is not None:
716 config_file = self.uncertToolConfigPathJMR
718 if config.geometry()
in [LHCPeriod.Run2, LHCPeriod.Run3]:
719 config_file =
"rel22/Summer2025_PreRec/" + config_file
721 log.warning(
"Uncertainties for UFO jets are not for Run 4!")
724 if config.geometry()
is LHCPeriod.Run2:
725 if config.dataType()
is DataType.FastSim:
729 elif config.geometry()
is LHCPeriod.Run3:
730 if config.dataType()
is DataType.FastSim:
736 config.addPrivateTool(
'FFSmearingTool',
'CP::FFJetSmearingTool')
737 jetFFSmearingAlg.FFSmearingTool.MassDef =
"UFO"
738 jetFFSmearingAlg.FFSmearingTool.MCType = mc_type
739 jetFFSmearingAlg.FFSmearingTool.ConfigFile = config_file
749 jetCollectionName=
"AntiKt4EMPFlowJets"
751 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
753 if self.largeRMass
not in [
"Comb",
"Calo",
"TA"]:
754 raise ValueError(
"Invalid large-R mass defintion {0}!".
format(self.largeRMass) )
756 if self.
jetInput not in [
"LCTopo",
"TrackCaloCluster",
"UFO"]:
757 raise ValueError(
"Invalid input type '{0}' for large-R jets!".
format(self.
jetInput) )
761 if self.largeRMass !=
"Calo":
762 raise ValueError(
"Invalid large-R TCC jet mass '{0}'!".
format(self.largeRMass) )
763 configFile =
"JES_MC16recommendation_FatJet_TCC_JMS_calo_30Oct2018.config"
767 configFile =
"JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_26Nov2024.config"
768 calibArea =
"00-04-83"
769 if self.calibToolConfigFile
is not None:
770 configFile = self.calibToolConfigFile
772 if self.
jetInput ==
"TrackCaloCluster" or self.
jetInput ==
"UFO" or config.dataType()
is DataType.FullSim:
773 calibSeq =
"EtaJES_JMS"
774 elif config.dataType()
is DataType.Data:
775 calibSeq =
"EtaJES_JMS_Insitu"
776 if self.calibToolCalibSeq
is not None:
777 calibSeq = self.calibToolCalibSeq
779 if self.calibToolCalibArea
is not None:
780 calibArea = self.calibToolCalibArea
782 if not config.isPhyslite()
or self.recalibratePhyslite:
784 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg' )
785 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
787 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
789 if configFile
is None:
790 raise ValueError(f
'Unsupported: {self.jetInput=}, {config.dataType()=}')
791 alg.calibrationTool.ConfigFile = configFile
794 raise ValueError(f
'Unsupported: {self.jetInput=}, {config.dataType()=}')
795 alg.calibrationTool.CalibSequence = calibSeq
797 if calibArea
is not None:
798 alg.calibrationTool.CalibArea = calibArea
800 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
801 alg.jets = config.readName(self.containerName)
804 if self.
jetInput ==
"UFO" and config.dataType()
in [DataType.FullSim, DataType.FastSim]:
805 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg' )
806 self.
createUncertaintyTool(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER
in [
"Full",
"All"] ))
808 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
811 alg.outOfValidity = 2
812 alg.outOfValidityDeco =
'outOfValidity'
814 alg.jets = config.readName (self.containerName)
815 alg.jetsOut = config.copyName (self.containerName)
816 alg.preselection = config.getPreselection (self.containerName,
'')
819 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg' )
822 alg.outOfValidity = 2
823 alg.outOfValidityDeco =
'outOfValidity'
824 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
826 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
827 alg.uncertaintiesTool.ConfigFile = \
828 "rel21/Moriond2018/R10_{0}Mass_all.config".
format(self.largeRMass)
829 alg.uncertaintiesTool.MCType =
"MC16a"
830 alg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
832 alg.jets = config.readName (self.containerName)
833 alg.jetsOut = config.copyName (self.containerName)
834 alg.preselection = config.getPreselection (self.containerName,
'')
835 config.addSelection (self.containerName,
'',
'outOfValidity')
837 if self.
jetInput ==
"UFO" and config.dataType()
is not DataType.Data:
839 alg = config.createAlgorithm(
'CP::JetFFSmearingAlg',
'JetFFSmearingAlg' )
841 alg.outOfValidity = 2
842 alg.outOfValidityDeco =
'outOfValidityJMR'
843 alg.jets = config.readName (self.containerName)
844 alg.jetsOut = config.copyName (self.containerName)
845 alg.preselection = config.getPreselection (self.containerName,
'')
847 if self.minPt > 0
or self.maxPt > 0
or self.maxEta > 0
or self.maxRapidity > 0:
849 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'JetPtEtaCutAlg' )
850 alg.selectionDecoration =
'selectPtEta,as_bits'
851 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
852 alg.selectionTool.minPt = self.minPt
853 alg.selectionTool.maxPt = self.maxPt
854 alg.selectionTool.maxEta = self.maxEta
855 alg.selectionTool.maxRapidity = self.maxRapidity
856 alg.particles = config.readName (self.containerName)
857 alg.preselection = config.getPreselection (self.containerName,
'')
858 config.addSelection (self.containerName,
'', alg.selectionDecoration,
861 if self.minMass > 0
or self.maxMass > 0:
863 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'JetMassCutAlg' )
864 alg.selectionDecoration =
'selectMass,as_bits'
865 config.addPrivateTool(
'selectionTool',
'CP::AsgMassSelectionTool' )
866 alg.selectionTool.minM = self.minMass
867 alg.selectionTool.maxM = self.maxMass
868 alg.particles = config.readName (self.containerName)
869 alg.preselection = config.getPreselection (self.containerName,
'')
870 config.addSelection (self.containerName,
'', alg.selectionDecoration,
873 config.addOutputVar (self.containerName,
'm',
'm')
888 runGhostMuonAssociation = None):
889 """Create a jet analysis algorithm sequence
890 The jet collection is interpreted and selects the correct function to call,
891 makeSmallRJetAnalysisConfig, makeRScanJetAnalysisConfig or
892 makeLargeRJetAnalysisConfig
895 jetCollection -- The jet container to run on.
899 btIndex = jetCollection.find(
'_BTagging')
901 jetCollection = jetCollection[:btIndex]
903 jetCollectionName=jetCollection
905 if(jetCollection==
"AnalysisJets") :
906 jetCollectionName=
"AntiKt4EMPFlowJets"
907 if(jetCollection==
"AnalysisLargeRJets") :
908 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
911 collection_pattern = re.compile(
912 r"AntiKt(\d+)(EMTopo|EMPFlow|LCTopo|TrackCaloCluster|UFO|Track|HI)(TrimmedPtFrac5SmallR20|CSSKSoftDropBeta100Zcut10)?Jets")
913 match = collection_pattern.match(jetCollectionName)
916 "Jet collection {0} does not match expected pattern!".
format(jetCollectionName) )
917 radius =
int(match.group(1) )
918 if radius
not in [2, 4, 6, 10]:
919 raise ValueError(
"Jet collection has an unsupported radius '{0}'!".
format(radius) )
920 jetInput = match.group(2)
922 if jetCollectionName ==
'AntiKtVR30Rmax4Rmin02PV0TrackJets' :
925 config.setOptionValue (
'containerName', containerName)
926 config.setOptionValue (
'jetCollection', jetCollection)
927 config.setOptionValue (
'runOriginalObjectLink',
False)
928 config.setOptionValue (
'runGhostMuonAssociation',
False)
933 config.setOptionValue (
'containerName', containerName)
934 config.setOptionValue (
'jetCollection', jetCollection)
935 config.runOriginalObjectLink = (btIndex != -1)
936 config.setOptionValue (
'runGhostMuonAssociation', runGhostMuonAssociation)
941 jetCollection, jetInput=jetInput)
942 elif radius
in [2, 6]:
944 jetCollection, jetInput=jetInput, radius=radius)
946 trim = match.group(3)
948 raise ValueError(
"Untrimmed large-R jets are not supported!")
950 jetCollection, jetInput=jetInput)
955 runJvtUpdate = None, runNNJvtUpdate = None,
956 runJvtSelection = None, runFJvtSelection = None,
957 jvtWP = None, fJvtWP = None,
958 runJvtEfficiency = None, runFJvtEfficiency = None,
959 systematicsModelJES = None, systematicsModelJER = None):
960 """Add algorithms for the R=0.4 jets.
963 seq -- The sequence to add the algorithms to
964 jetCollection -- The jet container to run on.
965 jetInput -- The type of input used, read from the collection name.
966 runJvtUpdate -- Determines whether or not to update JVT on the jets
967 runNNJvtUpdate -- Determines whether or not to update NN JVT on the jets
968 runJvtSelection -- Determines whether or not to run JVT selection on the jets
969 runFJvtSelection -- Determines whether or not to run forward JVT selection on the jets
970 jvtWP -- Defines the NNJvt WP to apply on the jets
971 fJvtWP -- Defines the fJvt WP to apply on the jets
972 runJvtEfficiency -- Determines whether or not to calculate the JVT efficiency
973 runFJvtEfficiency -- Determines whether or not to calculate the forward JVT efficiency
974 systematicsModelJES -- Which NP systematicsModelJES scheme should be used (All, Global, Category, Scenario)
975 systematicsModelJER -- Which variant of the systematicsModelJES should be used (All, Full, Simple). Note that not all combinations of systematicsModelJES and systematicsModelJER are valid!
978 if jetInput
not in [
"EMTopo",
"EMPFlow",
"HI"]:
980 "Unsupported input type '{0}' for R=0.4 jets!".
format(jetInput) )
983 config.setOptionValue (
'containerName', containerName)
984 config.setOptionValue (
'jetCollection', jetCollection)
985 config.setOptionValue (
'jetInput', jetInput)
986 config.setOptionValue (
'runJvtUpdate', runJvtUpdate)
987 config.setOptionValue (
'runNNJvtUpdate', runNNJvtUpdate)
988 config.setOptionValue (
'runJvtSelection', runJvtSelection)
989 config.setOptionValue (
'runFJvtSelection', runFJvtSelection)
990 config.setOptionValue (
'jvtWP', jvtWP)
991 config.setOptionValue (
'fJvtWP', fJvtWP)
992 config.setOptionValue (
'runJvtEfficiency', runJvtEfficiency)
993 config.setOptionValue (
'runFJvtEfficiency', runFJvtEfficiency)
994 config.setOptionValue (
'systematicsModelJES', systematicsModelJES)
995 config.setOptionValue (
'systematicsModelJER', systematicsModelJER)
1001 """Add algorithms for the R-scan jets.
1004 seq -- The sequence to add the algorithms to
1005 jetCollection -- The jet container to run on.
1006 jetInput -- The type of input used, read from the collection name.
1007 radius -- The radius of the r-scan jets.
1011 config.setOptionValue (
'containerName', containerName)
1012 config.setOptionValue (
'jetCollection', jetCollection)
1013 config.setOptionValue (
'jetInput', jetInput)
1014 config.setOptionValue (
'radius', radius)
1021 jetInput, largeRMass = None):
1022 """Add algorithms for the R=1.0 jets.
1025 seq -- The sequence to add the algorithms to
1026 jetCollection -- The jet container to run on.
1027 jetInput -- The type of input used, read from the collection name.
1028 largeRMass -- Which large-R mass definition to use. Ignored if not running on large-R jets ("Comb", "Calo", "TA")
1031 config.setOptionValue (
'containerName', containerName)
1032 config.setOptionValue (
'jetCollection', jetCollection)
1033 config.setOptionValue (
'jetInput', jetInput)
1034 config.setOptionValue (
'largeRMass', largeRMass)