ATLAS Offline Software
Loading...
Searching...
No Matches
SSVWeightsAlgConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3# @author Hagen Möbius, hagen.mobius@cern.ch
4
5from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
6from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
7from AthenaCommon.Logging import logging
8
9class SSVWeightsAlgConfig(ConfigBlock):
10
11 def __init__ (self) :
12 super (SSVWeightsAlgConfig, self).__init__ ()
13 self.addDependency('EventSelection', required=False)
14 self.addDependency('EventSelectionMerger', required=False)
15 self.addOption('jets', None, type = str, info = "jet container that will be used to define the good SSVs (ΔR(SSV,jet)>0.6) and the truth b-hadrons in acceptance (ΔR(truthBh,jet)>0.6) and that will be used to count the number of b-jets for b-jet based SSV weight calculation",
16 meta = {'role':'containerRef'})
17 self.addOption('electrons', None, type = str, info = "electron container that will be used to define the good SSVs (ΔR(SSV,electron)>0.2)",
18 meta = {'role':'containerRef'})
19 self.addOption('muons', None, type = str, info = "muon container that will be used to define the good SSVs (ΔR(SSV,muon)>0.2)",
20 meta = {'role':'containerRef'})
21 self.addOption('NVSI_WP', "NVSI_SecVrt_Tight", type = str, info = "Working point of the NewVrtSecInclusiveTool (algorithm that constructs the soft secondary vertices); possible working points are 'NVSI_SecVrt_Tight','NVSI_SecVrt_Medium','NVSI_SecVrt_Loose'",
22 meta = {'choices':(['NVSI_SecVrt_Tight','NVSI_SecVrt_Medium','NVSI_SecVrt_Loose'],1)})
23 self.addOption("JsonConfigFile_SSVWeightsAlg", None, type = str, info ="Path to the JSON config file that contains the SSV calibration results which are needed to calculate the SSV weights")
24 self.addOption("BTaggingWP", "ftag_select_GN2v01_FixedCutBEff_85" , type = str, info = "b-tagging working point that is used to count the number of b-jets in the event for b-jet based SSV weight calculation")
25 self.addOption("EfficiencyMethod", "Bhadron_pT_eta_based", type = str, info = "efficiency definition that will be used to calculate the SSV weights, string can be 'Bhadron_pT_eta_based' or 'bjet_based'",
26 meta = {'choices':(['Bhadron_pT_eta_based','bjet_based'],1)})
27 self.addOption("nFMethod", "pileup_based_binned", type = str, info = "average number of fake SSV definition that will be used to calculate the SSV weights, string can be 'pileup_bjet_based','pileup_based_linearfit' or 'pileup_based_binned'",
28 meta = {'choices':(['pileup_bjet_based','pileup_based_linearfit','pileup_based_binned'],1)})
29 self.addOption("OutputVariableSize", "standard", type = str, info ="number of variables that will be saved to the output, string can be 'standard','extended','additional' or 'all'",
30 meta = {'choices':(['standard','extended','additional','all'],1)})
31
32 def makeAlgs(self, config):
33 #Algorithm is Monte Carlo only -> skip algorithm if it is run on Data
34 if config.dataType() == DataType.Data:
35 return
36
37 alg = config.createAlgorithm('CP::SSVWeightsAlg', 'SSVWeightsAlg')
38
39 jetContainer, sep, jetSelectionName = self.jets.partition('.')
40 alg.jetSelection = config.getFullSelection(jetContainer, jetSelectionName)
41 alg.jets = config.readName(jetContainer)
42
43 electronContainer, sep, electronSelectionName = self.electrons.partition('.')
44 alg.electronSelection = config.getFullSelection(electronContainer, electronSelectionName)
45 alg.electrons = config.readName(electronContainer)
46
47 muonContainer, sep, muonSelectionName = self.muons.partition('.')
48 alg.muonSelection = config.getFullSelection(muonContainer, muonSelectionName)
49 alg.muons = config.readName(muonContainer)
50
51 log = logging.getLogger('SSVWeightsAlgConfig')
52 log.info(f'You run with the following jet selections: {alg.jetSelection}')
53 log.info(f'You run with the following electron selections: {alg.electronSelection}')
54 log.info(f'You run with the following muon selections: {alg.muonSelection}')
55
56 alg.NVSI_WP = self.NVSI_WP
57 alg.JsonConfigFile_SSVWeightsAlg = self.JsonConfigFile_SSVWeightsAlg
58 alg.BTaggingWP = self.BTaggingWP
59 alg.EfficiencyMethod = self.EfficiencyMethod
60 alg.nFMethod = self.nFMethod
61 alg.OutputVariableSize = self.OutputVariableSize
62
63 config.addOutputVar('EventInfo', 'SSV_weight_%SYS%', 'SSV_weight', auxType="float")
64
65 if alg.OutputVariableSize in ["extended", "additional", "all"] :
66 config.addOutputVar('EventInfo', 'P_eff_%SYS%', 'P_eff', auxType="float")
67 config.addOutputVar('EventInfo', 'P_ineff_%SYS%', 'P_ineff', auxType="float")
68 config.addOutputVar('EventInfo', 'P_fake_%SYS%', 'P_fake', auxType="float")
69
70 if alg.OutputVariableSize in ["additional", "all"] :
71 config.addOutputVar('EventInfo', 'N_matched_%SYS%', 'N_matched', auxType="int")
72 config.addOutputVar('EventInfo', 'N_missed_%SYS%', 'N_missed', auxType="int")
73 config.addOutputVar('EventInfo', 'N_fake_%SYS%', 'N_fake', auxType="int")
74 config.addOutputVar('EventInfo', 'number_of_bjets_%SYS%', 'number_of_bjets', auxType="int")
75 config.addOutputVar('EventInfo', 'number_of_accepted_Bhadrons_%SYS%', 'number_of_accepted_Bhadrons', auxType="int")
76 config.addOutputVar('EventInfo', 'number_of_good_SSVs_%SYS%', 'number_of_good_SSVs', auxType="int")
77
78 if alg.OutputVariableSize == "all":
79 config.addOutputVar('EventInfo', 'P_ineff_bjet_based_%SYS%', 'P_ineff_bjet_based', auxType="float")
80 config.addOutputVar('EventInfo', 'P_ineff_pt_eta_based_%SYS%', 'P_ineff_pt_eta_based', auxType="float")
81 config.addOutputVar('EventInfo', 'P_fake_pileup_bjet_based_%SYS%', 'P_fake_pileup_bjet_based', auxType="float")
82 config.addOutputVar('EventInfo', 'P_fake_pileup_based_linearfit_%SYS%', 'P_fake_pileup_based_linearfit', auxType="float")
83 config.addOutputVar('EventInfo', 'P_fake_pileup_based_binned_%SYS%', 'P_fake_pileup_based_binned', auxType="float")