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