ATLAS Offline Software
Loading...
Searching...
No Matches
PileupReweightingAlgConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 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 from Campaigns.Utils import getMCCampaign
34 campaign = getMCCampaign(flags.Input.Files)
35
36 from PileupReweighting.AutoconfigurePRW import defaultConfigFiles,getConfigurationFiles,getLumicalcFiles
37 kwargs.setdefault("LumiCalcFiles", getLumicalcFiles(campaign))
38 if commonPRW:
39 kwargs.setdefault("ConfigFiles", defaultConfigFiles(campaign))
40 else:
41 kwargs.setdefault("ConfigFiles", getConfigurationFiles(files=flags.Input.Files))
42
43 acc.setPrivateTools(CompFactory.CP.PileupReweightingTool(**kwargs))
44 return acc
45
46
47def PileupReweightingAlgCfg(flags, name="PileupReweightingAlg", **kwargs):
48 acc = ComponentAccumulator()
49 acc.addService(CompFactory.CP.SystematicsSvc("SystematicsSvc"))
50 kwargs.setdefault("pileupReweightingTool", acc.popToolsAndMerge(PileupReweightingToolCfg(flags)))
51 acc.addEventAlgo(CompFactory.CP.PileupReweightingAlg(name, **kwargs))
52 return acc
53
54
55def PileupReweightingProviderToolCfg(flags, name="auto", **kwargs):
56 acc = ComponentAccumulator()
57 kwargs.setdefault("WeightTool", acc.addPublicTool(acc.popToolsAndMerge(McEventWeightCfg(flags))))
58 kwargs.setdefault("ConfigFiles", [])
59 kwargs.setdefault("LumiCalcFiles", [])
60 kwargs.setdefault("DataScaleFactor", 1.0)
61 kwargs.setdefault("DataScaleFactorUP", 0.)
62 kwargs.setdefault("DataScaleFactorDOWN", 0.)
63 kwargs.setdefault("PeriodAssignments", [])
64 return acc.setPrivateTools(acc.popToolsAndMerge(PileupReweightingToolCfg(flags, name, **kwargs)))
McEventWeightCfg(flags, name="MyWeights", **kwargs)
PileupReweightingToolCfg(flags, name="PileupReweightingTool", commonPRW=True, **kwargs)
PileupReweightingProviderToolCfg(flags, name="auto", **kwargs)
PileupReweightingAlgCfg(flags, name="PileupReweightingAlg", **kwargs)