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"""
19 def __init__ (self, containerName='', jetCollection='') :
20 super (PreJetAnalysisConfig, self).__init__ ()
21 self.addOption (
'containerName', containerName, type=str,
23 info=
"the name of the output container after calibration.")
24 self.addOption (
'jetCollection', 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.")
29 self.addOption (
'runOriginalObjectLink',
False, type=bool,
31 self.addOption (
'runGhostMuonAssociation',
None, type=bool,
32 info=
"whether to set up the jet-ghost-muon association algorithm "
33 "CP::JetGhostMuonAssociationAlg. The default is False.")
34 self.addOption (
'runTruthJetTagging',
None, type=bool,
35 info=
"whether to set up the jet truth tagging algorithm "
36 "CP::JetTruthTagAlg. The default is True.")
43 config.setSourceName (self.containerName,
"AnalysisJets", originalName = self.
jetCollection)
44 elif config.isPhyslite()
and self.
jetCollection ==
'AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets' :
45 config.setSourceName (self.containerName,
"AnalysisLargeRJets", originalName = self.
jetCollection)
50 if self.runOriginalObjectLink :
51 alg = config.createAlgorithm(
'CP::AsgOriginalObjectLinkAlg',
52 'JetOriginalObjectLinkAlg'+self.containerName )
54 alg.particles = config.readName (self.containerName)
55 if config.wantCopy (self.containerName) :
56 alg.particlesOut = config.copyName (self.containerName)
57 alg.preselection = config.getPreselection (self.containerName,
'')
60 if (self.runGhostMuonAssociation
is None and not config.isPhyslite())
or \
61 (self.runGhostMuonAssociation
is True):
62 alg = config.createAlgorithm(
'CP::JetGhostMuonAssociationAlg',
63 'JetGhostMuonAssociationAlg'+self.containerName )
64 alg.jets = config.readName (self.containerName)
65 if config.isPhyslite():
66 alg.muons =
"AnalysisMuons"
67 if config.wantCopy (self.containerName) :
68 alg.jetsOut = config.copyName (self.containerName)
72 if self.runTruthJetTagging
or (
73 self.runTruthJetTagging
is None
74 and config.dataType()
is not DataType.Data
77 alg = config.createAlgorithm(
'CP::JetDecoratorAlg',
'JetPileupLabelAlg'+self.containerName )
78 config.addPrivateTool(
'decorator',
'JetPileupLabelingTool' )
79 alg.jets = config.readName (self.containerName)
80 alg.jetsOut = config.copyName (self.containerName)
81 alg.decorator.RecoJetContainer = alg.jetsOut.replace (
'%SYS%',
'NOSYS')
82 alg.decorator.SuppressOutputDependence=
True
85 if config.wantCopy (self.containerName) :
86 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'JetShallowCopyAlg' + self.containerName )
87 alg.input = config.readName (self.containerName)
88 alg.output = config.copyName (self.containerName)
90 config.addOutputVar (self.containerName,
'pt',
'pt')
91 config.addOutputVar (self.containerName,
'eta',
'eta', noSys=
True)
92 config.addOutputVar (self.containerName,
'phi',
'phi', noSys=
True)
93 config.addOutputVar (self.containerName,
'charge',
'charge', noSys=
True, enabled=
False)
98 """the ConfigBlock for the small-r jet sequence"""
100 def __init__ (self, containerName='', jetCollection='', jetInput='') :
101 super (SmallRJetAnalysisConfig, self).__init__ ()
102 self.addOption (
'containerName', containerName, type=str,
104 info=
"the name of the output container after calibration.")
105 self.addOption (
'jetCollection', jetCollection, type=str,
107 info=
"the jet container to run on. It is interpreted to determine "
108 "the correct config blocks to call for small- or large-R jets.")
110 self.addOption (
'jetInput', jetInput, type=str,
113 self.addOption (
'runJvtUpdate',
False, type=bool,
114 info=
"whether to update the JVT. The default is False.")
115 self.addOption (
'runNNJvtUpdate',
False, type=bool,
116 info=
"whether to update the NN-JVT. The default is False.")
117 self.addOption (
'runFJvtUpdate',
False, type=bool,
118 info=
"whether to update the forward JVT. The default is False.")
119 self.addOption (
'runJvtSelection',
True, type=bool,
120 info=
"whether to run JVT selection. The default is True.")
121 self.addOption (
'runFJvtSelection',
False, type=bool,
122 info=
"whether to run forward JVT selection. The default is False.")
123 self.addOption (
'jvtWP',
"FixedEffPt", type=str,
124 info=
"which Jvt WP to apply. The default is FixedEffPt.")
125 self.addOption (
'fJvtWP',
"Loose", type=str,
126 info=
"which fJvt WP to apply. The default is Loose.")
127 self.addOption (
'runJvtEfficiency',
True, type=bool,
128 info=
"whether to calculate the JVT efficiency. The default is True.")
129 self.addOption (
'runFJvtEfficiency',
False, type=bool,
130 info=
"whether to calculate the forward JVT efficiency. The default is False.")
131 self.addOption (
'systematicsModelJES',
"Category", type=str,
132 info=
"the NP reduction scheme to use for JES: All, Global, Category, "
133 "Scenario. The default is Category.")
134 self.addOption (
'systematicsModelJER',
"Full", type=str,
135 info=
"the NP reduction scheme to use for JER: All, Full, Simple. The "
137 self.addOption (
'runJERsystematicsOnData',
False, type=bool,
138 info=
"whether to run the All/Full JER model variations also on data samples. Expert option!")
139 self.addOption (
'recalibratePhyslite',
True, type=bool,
140 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE derivations. "
141 "The default is True.")
143 self.addOption (
'calibToolConfigFile',
None, type=str,
144 info=
"name (str) of the config file to use for the jet calibration "
145 "tool. Expert option to override JetETmiss recommendations. The "
147 self.addOption (
'calibToolCalibArea',
None, type=str,
148 info=
"name (str) of the CVMFS area to use for the jet calibration "
149 "tool. Expert option to override JetETmiss recommendations. The "
151 self.addOption (
'calibToolCalibSeq',
None, type=str,
152 info=
"name (str) of the sequence to use for the jet calibration "
153 "tool (e.g. 'JetArea_Residual_EtaJES_GSC'). Expert option to override "
154 "JetETmiss recommendations. The default is None.")
156 self.addOption (
'uncertToolConfigPath',
None, type=str,
157 info=
"name (str) of the config file to use for the jet uncertainty "
158 "tool. Expert option to override JetETmiss recommendations. The "
160 self.addOption (
'uncertToolCalibArea',
None, type=str,
161 info=
"name (str) of the CVMFS area to use for the jet uncertainty "
162 "tool. Expert option to override JetETmiss recommendations. The "
164 self.addOption (
'uncertToolMCType',
None, type=str,
165 info=
"data type (str) to use for the jet uncertainty tool (e.g. "
166 "'AF3' or 'MC16'). Expert option to override JetETmiss "
167 "recommendations. The default is None.")
179 config_file =
"R4_AllNuisanceParameters_AllJERNP.config"
183 "Invalid uncertainty configuration - Scenario* systematicsModelJESs can "
184 "only be used together with the Simple systematicsModelJER")
190 "Invalid combination of systematicsModelJES and systematicsModelJER settings: "
195 if self.uncertToolCalibArea
is not None:
196 calib_area = self.uncertToolCalibArea
199 if self.uncertToolConfigPath
is not None:
200 config_file = self.uncertToolConfigPath
202 if config.geometry()
is LHCPeriod.Run2:
203 config_file =
"rel22/Summer2023_PreRec/" + config_file
205 config_file =
"rel22/Summer2024_PreRec/" + config_file
209 if self.uncertToolMCType
is not None:
210 mc_type = self.uncertToolMCType
212 if config.dataType()
is DataType.FastSim
and config.geometry()
is LHCPeriod.Run2:
216 if config.geometry()
is LHCPeriod.Run2:
221 return config_file, calib_area, mc_type
236 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
237 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
238 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
239 if calibArea
is not None:
240 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
241 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
242 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
243 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode =
False
245 if config.dataType()
is DataType.Data
and not (doPseudoData
and self.runJERsystematicsOnData):
247 jetUncertaintiesAlg.affectingSystematicsFilter =
'.*'
248 if config.dataType()
is not DataType.Data
and doPseudoData
and not self.runJERsystematicsOnData:
250 config.addPrivateTool(
'uncertaintiesToolPD',
'JetUncertaintiesTool' )
251 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
252 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
253 if calibArea
is not None:
254 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
255 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
258 jetUncertaintiesAlg.uncertaintiesToolPD.IsData =
True
259 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode =
True
266 jetCollectionName=
"AntiKt4EMPFlowJets"
268 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
270 if self.
jetInput not in [
"EMTopo",
"EMPFlow"]:
272 "Unsupported input type '{0}' for R=0.4 jets!".
format(self.
jetInput) )
274 if self.jvtWP
not in [
"FixedEffPt"]:
276 "Unsupported NNJvt WP '{0}'".
format(self.jvtWP) )
278 if self.fJvtWP
not in [
"Loose",
"Tight",
"Tighter"]:
280 "Unsupported fJvt WP '{0}'".
format(self.fJvtWP) )
282 if not config.isPhyslite()
or self.recalibratePhyslite:
284 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg'+self.containerName )
285 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
286 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
289 if config.geometry()
is LHCPeriod.Run2:
290 configFile =
"PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"
291 alg.calibrationTool.CalibArea =
"00-04-82"
292 elif config.geometry() >= LHCPeriod.Run3:
293 configFile =
"AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_240306_InSitu.config"
294 alg.calibrationTool.CalibArea =
"00-04-83"
296 if config.dataType()
is DataType.FastSim:
297 configFile =
"JES_MC16Recommendation_AFII_{0}_Apr2019_Rel21.config"
299 configFile =
"JES_MC16Recommendation_Consolidated_{0}_Apr2019_Rel21.config"
300 configFile = configFile.format(self.
jetInput)
301 if self.calibToolCalibArea
is not None:
302 alg.calibrationTool.CalibArea = self.calibToolCalibArea
303 if self.calibToolConfigFile
is not None:
304 configFile = self.calibToolConfigFile
305 alg.calibrationTool.ConfigFile = configFile
306 if config.dataType()
is DataType.Data:
307 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC_Insitu'
310 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC'
312 alg.calibrationTool.CalibSequence =
'JetArea_Residual_EtaJES_GSC_Smear'
313 if self.calibToolCalibSeq
is not None:
314 alg.calibrationTool.CalibSequence = self.calibToolCalibSeq
315 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
316 alg.jets = config.readName (self.containerName)
317 alg.jetsOut = config.copyName (self.containerName)
320 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg'+self.containerName )
322 alg.jets = config.readName (self.containerName)
323 alg.jetsOut = config.copyName (self.containerName)
324 alg.preselection = config.getPreselection (self.containerName,
'')
327 if self.runJvtUpdate :
328 alg = config.createAlgorithm(
'CP::JvtUpdateAlg',
'JvtUpdateAlg'+self.containerName )
329 config.addPrivateTool(
'jvtTool',
'JetVertexTaggerTool' )
331 alg.jvtTool.SuppressInputDependence=
True
332 alg.jets = config.readName (self.containerName)
333 alg.jetsOut = config.copyName (self.containerName)
334 alg.preselection = config.getPreselection (self.containerName,
'')
336 if self.runNNJvtUpdate:
337 assert self.
jetInput==
"EMPFlow",
"NN JVT only defined for PFlow jets"
338 alg = config.createAlgorithm(
'CP::JetDecoratorAlg',
'NNJvtUpdateAlg'+self.containerName )
339 config.addPrivateTool(
'decorator',
'JetPileupTag::JetVertexNNTagger' )
341 alg.jets = config.readName (self.containerName)
342 alg.jetsOut = config.copyName (self.containerName)
343 alg.decorator.JetContainer = alg.jetsOut.replace (
'%SYS%',
'NOSYS')
344 alg.decorator.SuppressInputDependence=
True
345 alg.decorator.SuppressOutputDependence=
True
347 if self.runFJvtUpdate :
348 alg = config.createAlgorithm(
'CP::JetModifierAlg',
'JetModifierAlg'+self.containerName )
349 config.addPrivateTool(
'modifierTool',
'JetForwardJvtTool')
350 alg.modifierTool.OutputDec =
"passFJVT_internal"
351 alg.modifierTool.FJVTName =
"fJVT"
354 alg.modifierTool.EtaThresh = 2.5
355 alg.modifierTool.ForwardMaxPt = 120*GeV
356 alg.modifierTool.RenounceOutputs =
True
357 alg.jets = config.readName (self.containerName)
358 alg.jetsOut = config.copyName (self.containerName)
362 if self.runJvtSelection :
363 assert self.
jetInput==
"EMPFlow",
"NNJvt WPs and SFs only valid for PFlow jets"
364 alg = config.createAlgorithm(
'CP::AsgSelectionAlg', f
'JvtSelectionAlg{self.containerName}')
365 config.addPrivateTool(
'selectionTool',
'CP::NNJvtSelectionTool')
366 alg.selectionTool.JetContainer = config.readName(self.containerName)
367 alg.selectionTool.WorkingPoint = self.jvtWP
368 alg.selectionTool.MaxPtForJvt = 60*GeV
369 alg.selectionDecoration =
"jvt_selection,as_char"
370 alg.particles = config.readName(self.containerName)
372 if self.runJvtEfficiency
and config.dataType()
is not DataType.Data:
373 alg = config.createAlgorithm(
'CP::JvtEfficiencyAlg',
'JvtEfficiencyAlg'+self.containerName )
374 config.addPrivateTool(
'efficiencyTool',
'CP::NNJvtEfficiencyTool' )
375 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
376 alg.efficiencyTool.MaxPtForJvt = 60*GeV
377 alg.efficiencyTool.WorkingPoint = self.jvtWP
378 if config.geometry()
is LHCPeriod.Run2:
379 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/NNJvtSFFile_Run2_EMPFlow.root"
381 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/NNJvtSFFile_Run3_EMPFlow.root"
382 alg.selection =
'jvt_selection,as_char'
383 alg.scaleFactorDecoration =
'jvt_effSF_%SYS%'
384 alg.outOfValidity = 2
385 alg.outOfValidityDeco =
'no_jvt'
386 alg.skipBadEfficiency =
False
387 alg.jets = config.readName (self.containerName)
388 alg.preselection = config.getPreselection (self.containerName,
'')
389 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'jvtEfficiency')
390 config.addSelection (self.containerName,
'baselineJvt',
'jvt_selection,as_char', preselection=
False)
392 if self.runFJvtSelection :
393 assert self.
jetInput==
"EMPFlow",
"fJvt WPs and SFs only valid for PFlow jets"
394 alg = config.createAlgorithm(
'CP::AsgSelectionAlg', f
'FJvtSelectionAlg{self.containerName}')
395 config.addPrivateTool(
'selectionTool',
'CP::FJvtSelectionTool')
396 alg.selectionTool.JetContainer = config.readName(self.containerName)
397 alg.selectionTool.WorkingPoint = self.fJvtWP
398 alg.selectionDecoration =
"fjvt_selection,as_char"
399 alg.particles = config.readName(self.containerName)
401 if self.runFJvtEfficiency
and config.dataType()
is not DataType.Data:
402 alg = config.createAlgorithm(
'CP::JvtEfficiencyAlg',
'FJvtEfficiencyAlg'+self.containerName )
403 config.addPrivateTool(
'efficiencyTool',
'CP::FJvtEfficiencyTool' )
404 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
405 alg.efficiencyTool.WorkingPoint = self.fJvtWP
406 if config.geometry()
is LHCPeriod.Run2:
407 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/fJvtSFFile_Run2_EMPFlow.root"
409 alg.efficiencyTool.SFFile =
"JetJvtEfficiency/May2024/fJvtSFFile_Run3_EMPFlow.root"
410 alg.selection =
'fjvt_selection,as_char'
411 alg.scaleFactorDecoration =
'fjvt_effSF_%SYS%'
412 alg.outOfValidity = 2
413 alg.outOfValidityDeco =
'no_fjvt'
414 alg.skipBadEfficiency =
False
415 alg.jets = config.readName (self.containerName)
416 alg.preselection = config.getPreselection (self.containerName,
'')
417 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'fjvtEfficiency')
418 config.addSelection (self.containerName,
'baselineFJvt',
'fjvt_selection,as_char', preselection=
False)
421 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'EnergyDecorator' + self.containerName )
422 alg.particles = config.readName (self.containerName)
424 config.addOutputVar (self.containerName,
'e_%SYS%',
'e')
428 """the ConfigBlock for the r-scan jet sequence"""
430 def __init__ (self, containerName='', jetCollection='', jetInput='', radius=None) :
431 super (RScanJetAnalysisConfig, self).__init__ ()
432 self.addOption (
'containerName', containerName, type=str,
434 info=
"the name of the output container after calibration.")
435 self.addOption (
'jetCollection', jetCollection, type=str,
437 info=
"the jet container to run on. It is interpreted to determine "
438 "the correct config blocks to call for small- or large-R jets.")
440 self.addOption (
'jetInput', jetInput, type=str,
444 self.addOption (radius, radius, type=int,
447 self.addOption (
'recalibratePhyslite',
True, type=bool,
448 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE "
449 "derivations. The default is True.")
454 log = logging.getLogger(
'RScanJetAnalysisConfig')
458 jetCollectionName=
"AntiKt4EMPFlowJets"
460 jetCollectionName=
"AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets"
462 if not config.isPhyslite()
or self.recalibratePhyslite:
463 if self.jetInput !=
"LCTopo":
465 "Unsupported input type '{0}' for R-scan jets!".
format(self.jetInput) )
467 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg'+self.containerName )
468 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
469 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
470 alg.calibrationTool.ConfigFile = \
471 "JES_MC16Recommendation_Rscan{0}LC_Feb2022_R21.config".
format(self.radius)
472 if config.dataType()
is DataType.Data:
473 alg.calibrationTool.CalibSequence =
"JetArea_Residual_EtaJES_GSC_Insitu"
475 alg.calibrationTool.CalibSequence =
"JetArea_Residual_EtaJES_GSC_Smear"
476 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
477 alg.jets = config.readName (self.containerName)
479 log.warning(
"Uncertainties for R-Scan jets are not yet released!")
483 is_sim = config.dataType()
in {DataType.FullSim}
484 if self.largeRMass ==
"Comb":
485 if config.dataType()
is DataType.Data:
486 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
488 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_17Oct2018.config"
489 elif self.largeRMass ==
"Calo":
490 if config.dataType()
is DataType.Data:
491 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
493 return "JES_MC16recommendation_FatJet_Trimmed_JMS_calo_12Oct2018.config "
494 elif self.largeRMass ==
"TA":
495 if config.dataType()
is DataType.Data:
496 return "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_March2021.config"
498 return "JES_MC16recommendation_FatJet_Trimmed_JMS_TA_12Oct2018.config"
503 """the ConfigBlock for the large-r jet sequence"""
505 def __init__ (self, containerName='', jetCollection='', jetInput='') :
506 super (LargeRJetAnalysisConfig, self).__init__ ()
507 self.addOption (
'containerName', containerName, type=str,
509 info=
"the name of the output container after calibration.")
510 self.addOption (
'jetCollection', jetCollection, type=str,
512 info=
"the jet container to run on. It is interpreted to determine "
513 "the correct config blocks to call for small- or large-R jets.")
515 self.addOption (
'jetInput', jetInput, type=str,
519 self.addOption (
'largeRMass',
"Comb", type=str,
521 self.addOption (
'recalibratePhyslite',
True, type=bool,
522 info=
"whether to run the CP::JetCalibrationAlg on PHYSLITE "
523 "derivations. The default is True.")
525 self.addOption (
'configFileOverride',
None, type=str,
527 self.addOption (
'systematicsModelJER',
"Full", type=str)
528 self.addOption (
'runJERsystematicsOnData',
False, type=bool,
529 info=
"whether to run the All/Full JER model variations also on data samples. Expert option!")
532 self.addOption (
'calibToolConfigFile',
None, type=str,
533 info=
"name (str) of the config file to use for the jet calibration "
534 "tool. Expert option to override JetETmiss recommendations. The "
536 self.addOption (
'calibToolCalibArea',
None, type=str,
537 info=
"name (str) of the CVMFS area to use for the jet calibration "
538 "tool. Expert option to override JetETmiss recommendations. The "
540 self.addOption (
'calibToolCalibSeq',
None, type=str,
541 info=
"name (str) of the sequence to use for the jet calibration "
542 "tool (e.g. 'JetArea_Residual_EtaJES_GSC'). Expert option to override "
543 "JetETmiss recommendations. The default is None.")
545 self.addOption (
'uncertToolConfigPath',
None, type=str,
546 info=
"name (str) of the config file to use for the jet uncertainty "
547 "tool. Expert option to override JetETmiss recommendations. The "
549 self.addOption (
'uncertToolCalibArea',
None, type=str,
550 info=
"name (str) of the CVMFS area to use for the jet uncertainty "
551 "tool. Expert option to override JetETmiss recommendations. The "
553 self.addOption (
'uncertToolMCType',
None, type=str,
554 info=
"data type (str) to use for the jet uncertainty tool (e.g. "
555 "'AF3' or 'MC16'). Expert option to override JetETmiss "
556 "recommendations. The default is None.")
565 if self.systematicsModelJER
in [
"Simple",
"Full"]:
566 config_file =
"R10_CategoryJES_{0}JER_FullJMS.config".
format(self.systematicsModelJER)
569 "Invalid request for systematicsModelJER settings: "
570 "systematicsModelJER: {0}".
format(self.systematicsModelJER) )
574 if self.uncertToolCalibArea
is not None:
575 calib_area = self.uncertToolCalibArea
578 if self.uncertToolConfigPath
is not None:
579 config_file = self.uncertToolConfigPath
581 if config.geometry()
in [LHCPeriod.Run2, LHCPeriod.Run3]:
582 config_file =
"rel22/Winter2024_PreRec/" + config_file
584 log = logging.getLogger(
'LargeRJetAnalysisConfig')
585 log.warning(
"Uncertainties for UFO jets are not for Run 4!")
588 if self.uncertToolMCType
is not None:
589 mc_type = self.uncertToolMCType
591 if config.dataType()
is DataType.FastSim
and config.geometry()
is LHCPeriod.Run2:
595 if config.geometry()
is LHCPeriod.Run2:
600 return config_file, calib_area, mc_type
614 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
615 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
616 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
617 if calibArea
is not None:
618 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
619 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
620 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
621 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode =
False
624 if config.dataType()
is DataType.Data
and not (config.isPhyslite()
and doPseudoData
and self.runJERsystematicsOnData):
626 jetUncertaintiesAlg.affectingSystematicsFilter =
'.*'
628 if config.dataType()
is not (DataType.Data
and config.isPhyslite())
and doPseudoData
and not self.runJERsystematicsOnData:
630 config.addPrivateTool(
'uncertaintiesToolPD',
'JetUncertaintiesTool' )
631 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
632 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
633 if calibArea
is not None:
634 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
635 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
636 jetUncertaintiesAlg.uncertaintiesToolPD.IsData =
True
637 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode =
True
641 log = logging.getLogger(
'LargeRJetAnalysisConfig')
647 jetCollectionName=
"AntiKt4EMPFlowJets"
649 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
651 if self.largeRMass
not in [
"Comb",
"Calo",
"TA"]:
652 raise ValueError (
"Invalid large-R mass defintion {0}!".
format(self.largeRMass) )
654 if self.
jetInput not in [
"LCTopo",
"TrackCaloCluster",
"UFO"]:
656 "Unsupported input type '{0}' for large-R jets!".
format(self.
jetInput) )
660 if self.largeRMass !=
"Calo":
662 "Unsupported large-R TCC jet mass '{0}'!".
format(self.largeRMass) )
663 configFile =
"JES_MC16recommendation_FatJet_TCC_JMS_calo_30Oct2018.config"
669 configFile =
"JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_02Aug2024.config"
671 if not config.isPhyslite()
or self.recalibratePhyslite:
673 alg = config.createAlgorithm(
'CP::JetCalibrationAlg',
'JetCalibrationAlg'+self.containerName )
674 config.addPrivateTool(
'calibrationTool',
'JetCalibrationTool' )
675 alg.calibrationTool.JetCollection = jetCollectionName[:-4]
676 if self.configFileOverride
is not None:
677 configFile = self.configFileOverride
678 if configFile
is None:
680 f
'Unsupported: {self.jetInput=}, {config.dataType()=}')
681 alg.calibrationTool.ConfigFile = configFile
682 if self.
jetInput ==
"TrackCaloCluster" or self.
jetInput ==
"UFO" or config.dataType()
is DataType.FullSim:
683 alg.calibrationTool.CalibSequence =
"EtaJES_JMS"
684 elif config.dataType()
is DataType.Data:
685 alg.calibrationTool.CalibSequence =
"EtaJES_JMS_Insitu"
686 alg.calibrationTool.IsData = (config.dataType()
is DataType.Data)
687 alg.jets = config.readName (self.containerName)
690 if self.
jetInput ==
"UFO" and config.dataType()
is (DataType.FullSim
or DataType.FastSim):
691 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg'+self.containerName )
692 self.
createUncertaintyTool(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER
in [
"Full",
"All"] ))
694 alg.outOfValidity = 2
695 alg.outOfValidityDeco =
'outOfValidity'
696 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
697 alg.uncertaintiesTool.ConfigFile = (
698 "rel22/Winter2024_PreRec/R10_CategoryJES_FullJER_FullJMS.config"
701 log.warning(
"Uncertainties for UFO jets are test only! This {0} is not for physics analysis! ".
format(alg.uncertaintiesTool.ConfigFile))
702 if config.dataType()
is DataType.FastSim:
703 log.warning(
"You are applying UFO FS uncertainty on AF3! This {0} is only for test purpose and not for physics analysis! ".
format(alg.uncertaintiesTool.ConfigFile))
705 alg.uncertaintiesTool.MCType =
"MC20"
706 alg.uncertaintiesTool.IsData = config.dataType()
is DataType.Data
708 alg.jets = config.readName (self.containerName)
709 alg.jetsOut = config.copyName (self.containerName)
710 alg.preselection = config.getPreselection (self.containerName,
'')
713 alg = config.createAlgorithm(
'CP::JetUncertaintiesAlg',
'JetUncertaintiesAlg'+self.containerName )
715 alg.outOfValidity = 2
716 alg.outOfValidityDeco =
'outOfValidity'
717 config.addPrivateTool(
'uncertaintiesTool',
'JetUncertaintiesTool' )
719 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
720 alg.uncertaintiesTool.ConfigFile = \
721 "rel21/Moriond2018/R10_{0}Mass_all.config".
format(self.largeRMass)
722 alg.uncertaintiesTool.MCType =
"MC16a"
723 alg.uncertaintiesTool.IsData = (config.dataType()
is DataType.Data)
725 alg.jets = config.readName (self.containerName)
726 alg.jetsOut = config.copyName (self.containerName)
727 alg.preselection = config.getPreselection (self.containerName,
'')
728 config.addSelection (self.containerName,
'',
'outOfValidity')
730 config.addOutputVar (self.containerName,
'm',
'm')
745 runGhostMuonAssociation = None):
746 """Create a jet analysis algorithm sequence
747 The jet collection is interpreted and selects the correct function to call,
748 makeSmallRJetAnalysisConfig, makeRScanJetAnalysisConfig or
749 makeLargeRJetAnalysisConfig
752 jetCollection -- The jet container to run on.
756 btIndex = jetCollection.find(
'_BTagging')
758 jetCollection = jetCollection[:btIndex]
760 jetCollectionName=jetCollection
761 if(jetCollection==
"AnalysisJets") :
762 jetCollectionName=
"AntiKt4EMPFlowJets"
763 if(jetCollection==
"AnalysisLargeRJets") :
764 jetCollectionName=
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
768 if jetCollectionName ==
'AntiKtVR30Rmax4Rmin02PV0TrackJets' :
770 config = PreJetAnalysisConfig (containerName, jetCollection)
771 config.setOptionValue (
'runOriginalObjectLink',
False)
772 config.setOptionValue (
'runGhostMuonAssociation',
False)
777 collection_pattern = re.compile(
778 r"AntiKt(\d+)(EMTopo|EMPFlow|LCTopo|TrackCaloCluster|UFO|Track)(TrimmedPtFrac5SmallR20|CSSKSoftDropBeta100Zcut10)?Jets")
779 match = collection_pattern.match(jetCollectionName)
782 "Jet collection {0} does not match expected pattern!".
format(jetCollectionName) )
783 radius =
int(match.group(1) )
784 if radius
not in [2, 4, 6, 10]:
785 raise ValueError(
"Jet collection has an unsupported radius '{0}'!".
format(radius) )
786 jetInput = match.group(2)
789 config = PreJetAnalysisConfig (containerName, jetCollection)
790 config.runOriginalObjectLink = (btIndex != -1)
791 config.setOptionValue (
'runGhostMuonAssociation', runGhostMuonAssociation)
796 jetCollection, jetInput=jetInput)
797 elif radius
in [2, 6]:
799 jetCollection, jetInput=jetInput, radius=radius)
801 trim = match.group(3)
803 raise ValueError(
"Untrimmed large-R jets are not supported!")
805 jetCollection, jetInput=jetInput)
810 runJvtUpdate = None, runNNJvtUpdate = None, runFJvtUpdate = None,
811 runJvtSelection = None, runFJvtSelection = None,
812 jvtWP = None, fJvtWP = None,
813 runJvtEfficiency = None, runFJvtEfficiency = None,
814 systematicsModelJES = None, systematicsModelJER = None):
815 """Add algorithms for the R=0.4 jets.
818 seq -- The sequence to add the algorithms to
819 jetCollection -- The jet container to run on.
820 jetInput -- The type of input used, read from the collection name.
821 runJvtUpdate -- Determines whether or not to update JVT on the jets
822 runNNJvtUpdate -- Determines whether or not to update NN JVT on the jets
823 runFJvtUpdate -- Determines whether or not to update forward JVT on the jets
824 runJvtSelection -- Determines whether or not to run JVT selection on the jets
825 runFJvtSelection -- Determines whether or not to run forward JVT selection on the jets
826 jvtWP -- Defines the NNJvt WP to apply on the jets
827 fJvtWP -- Defines the fJvt WP to apply on the jets
828 runJvtEfficiency -- Determines whether or not to calculate the JVT efficiency
829 runFJvtEfficiency -- Determines whether or not to calculate the forward JVT efficiency
830 systematicsModelJES -- Which NP systematicsModelJES scheme should be used (All, Global, Category, Scenario)
831 systematicsModelJER -- Which variant of the systematicsModelJES should be used (All, Full, Simple). Note that not all combinations of systematicsModelJES and systematicsModelJER are valid!
834 if jetInput
not in [
"EMTopo",
"EMPFlow"]:
836 "Unsupported input type '{0}' for R=0.4 jets!".
format(jetInput) )
838 config = SmallRJetAnalysisConfig (containerName, jetCollection, jetInput)
839 config.setOptionValue (
'runJvtUpdate', runJvtUpdate)
840 config.setOptionValue (
'runNNJvtUpdate', runNNJvtUpdate)
841 config.setOptionValue (
'runFJvtUpdate', runFJvtUpdate)
842 config.setOptionValue (
'runJvtSelection', runJvtSelection)
843 config.setOptionValue (
'runFJvtSelection', runFJvtSelection)
844 config.setOptionValue (
'jvtWP', jvtWP)
845 config.setOptionValue (
'fJvtWP', fJvtWP)
846 config.setOptionValue (
'runJvtEfficiency', runJvtEfficiency)
847 config.setOptionValue (
'runFJvtEfficiency', runFJvtEfficiency)
848 config.setOptionValue (
'systematicsModelJES', systematicsModelJES)
849 config.setOptionValue (
'systematicsModelJER', systematicsModelJER)
855 """Add algorithms for the R-scan jets.
858 seq -- The sequence to add the algorithms to
859 jetCollection -- The jet container to run on.
860 jetInput -- The type of input used, read from the collection name.
861 radius -- The radius of the r-scan jets.
864 config = SmallRJetAnalysisConfig (containerName, jetCollection, jetInput, radius)
871 jetInput, largeRMass = None):
872 """Add algorithms for the R=1.0 jets.
875 seq -- The sequence to add the algorithms to
876 jetCollection -- The jet container to run on.
877 jetInput -- The type of input used, read from the collection name.
878 largeRMass -- Which large-R mass definition to use. Ignored if not running on large-R jets ("Comb", "Calo", "TA")
880 config = LargeRJetAnalysisConfig (containerName, jetCollection, jetInput)
881 config.setOptionValue (
'largeRMass', largeRMass)