ATLAS Offline Software
Loading...
Searching...
No Matches
PileupReweightingAlgConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentFactory import CompFactory
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4
5
6# ATTENTION: This is a ComponentAccumulator-based configuration file
7# (not to be confused with ConfigAccumulator). If you are an analysis
8# user you are likely looking for some other Block in
9# AsgAnalysisConfig.py. That uses the block-configuration generally
10# used for algorithms under PhysicsAnalysis/Algorithms. If you are
11# using the block configuration do not use this configuration. We
12# generally do not provide ComponentAccumulator-based configurations
13# for the CP algorithms, and a special exception was made for this
14# algorithm. Do not cite this as example why any other
15# ComponentAccumulator-based configurations should be added. You can
16# use this as an example for how ComponentAccumulator-based
17# configurations can look like, but do not try to extend this to cover
18# more CP algorithms. That is not supported, and you are likely to
19# encounter problems if you scale this up in the wrong way. This
20# configuration is covered by a unit test. Should it fail use your
21# best judgement whether to fix this configuration or to change it to
22# wrap the block configuration instead.
23
24
25def McEventWeightCfg(flags, name="MyWeights", **kwargs):
26 acc = ComponentAccumulator()
27 acc.setPrivateTools(CompFactory.McEventWeight(name, UseTruthEvents=True))
28 return acc
29
30
31def PileupReweightingToolCfg(flags, name="PileupReweightingTool", commonPRW=True, **kwargs):
32 acc = ComponentAccumulator()
33 if "LumiCalcFiles" not in kwargs or "ConfigFiles" not in kwargs:
34 from Campaigns.Utils import getMCCampaign
35 campaign = getMCCampaign(flags.Input.Files)
36
37 from PileupReweighting.AutoconfigurePRW import defaultConfigFiles, getConfigurationFiles, getLumicalcFiles
38 if "LumiCalcFiles" not in kwargs:
39 kwargs.setdefault("LumiCalcFiles", getLumicalcFiles(campaign))
40 if "ConfigFiles" not in kwargs:
41 if commonPRW:
42 kwargs.setdefault("ConfigFiles", defaultConfigFiles(campaign))
43 else:
44 kwargs.setdefault("ConfigFiles", getConfigurationFiles(files=flags.Input.Files))
45
46 acc.setPrivateTools(CompFactory.CP.PileupReweightingTool(**kwargs))
47 return acc
48
49
50def PileupReweightingAlgCfg(flags, name="PileupReweightingAlg", **kwargs):
51 acc = ComponentAccumulator()
52 acc.addService(CompFactory.CP.SystematicsSvc("SystematicsSvc"))
53 kwargs.setdefault("pileupReweightingTool", acc.popToolsAndMerge(PileupReweightingToolCfg(flags)))
54 acc.addEventAlgo(CompFactory.CP.PileupReweightingAlg(name, **kwargs))
55 return acc
56
57
58def PileupReweightingProviderToolCfg(flags, name="PileupReweightingProviderTool"):
59 acc = ComponentAccumulator()
60 arguments = {
61 "WeightTool": acc.addPublicTool(acc.popToolsAndMerge(McEventWeightCfg(flags))),
62 "ConfigFiles": [],
63 "LumiCalcFiles": [],
64 "DataScaleFactor": 1.0,
65 "DataScaleFactorUP": 0.,
66 "DataScaleFactorDOWN": 0.,
67 "PeriodAssignments": []
68 }
69
70 acc.setPrivateTools(acc.popToolsAndMerge(PileupReweightingToolCfg(flags, name, **arguments)))
71 return acc
PileupReweightingProviderToolCfg(flags, name="PileupReweightingProviderTool")
McEventWeightCfg(flags, name="MyWeights", **kwargs)
PileupReweightingToolCfg(flags, name="PileupReweightingTool", commonPRW=True, **kwargs)
PileupReweightingAlgCfg(flags, name="PileupReweightingAlg", **kwargs)