ATLAS Offline Software
Loading...
Searching...
No Matches
SUSYWeightMetadataConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6# Sum of weights algorithm
7def SumOfWeightsAlgCfg(flags, name, **kwargs):
8 """ Get the sum of weights algorithm """
9 acc = ComponentAccumulator()
10 SumOfWeightsAlg = CompFactory.SumOfWeightsAlg
11 acc.addEventAlgo( SumOfWeightsAlg(name=name, **kwargs) )
12 return acc
13
14# McEventWeight Tool
15def McEventWeightToolCfg(flags, name, **kwargs):
16 """ Get the MC Event Weight Tool """
17 acc = ComponentAccumulator()
18 McEventWeight = CompFactory.McEventWeight
19 acc.addPublicTool( McEventWeight(name=name, **kwargs) )
20 return acc
21
22# SUSY ID Weight Tool
23def SUSYIDWeightToolCfg(flags, name, **kwargs):
24 """ Get the SUSY ID Weight Tool """
25 acc = ComponentAccumulator()
26 SUSYIDWeight = CompFactory.SUSYIDWeight
27 acc.addPublicTool( SUSYIDWeight(name=name, **kwargs) )
28 return acc
29
30# SUSY Event Weights
31def AddSUSYWeightsCfg(flags, pref = ""):
32 """Add SUSY weights"""
33
34 acc = ComponentAccumulator()
35
36 # Load all potential SUSY process IDs following Prospino conventions
37 # https://twiki.cern.ch/twiki/bin/view/AtlasProtected/SUSYSignalUncertainties#Subprocess_IDs
38 listTools = []
39 for i in range(0, 225):
40 myName = pref+"SUSYWeight_ID"+"_"+str(i)
41 if i==0: #flat sum of all processes (i.e. sum the weight no matter what)
42 acc.merge( McEventWeightToolCfg(flags, name=myName, UseTruthEvents=True) )
43 else: #add weight only to keeper associated to current process id
44 acc.merge( SUSYIDWeightToolCfg(flags, name=myName, SUSYProcID=i, UseTruthEvents=True) )
45 listTools.append( acc.getPublicTool(myName) )
46
47 acc.merge( SumOfWeightsAlgCfg(flags, name=pref+"SUSYSumWeightsAlg", WeightTools=listTools) )
48 return acc