ATLAS Offline Software
Loading...
Searching...
No Matches
XbbAnalysisConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
4from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
5from CalibrationDataInterface.MCMCGeneratorHelper import MCMC_dsid_map
6
7class XbbConfig (ConfigBlock):
8 """the ConfigBlock for the Xbb tagging config"""
9 def __init__ (self):
10 super (XbbConfig, self).__init__ ()
11 self.setBlockName('Xbb')
12 self.addOption ('containerName', '', type=str,
13 noneAction='error',
14 info="the name of the input container.",
15 meta={'role':'containerRef'})
16 self.addOption('XbbWP', 'FlatMassQCDEff_0p25', type=str,
17 info="the Xbb tagging WP." )
18 self.addOption('Xbbtagger', 'GN3XPV01_hbb_bjr', type=str,
19 info="the output name of the Xbb tagger - should match the first level key of the calibration json file." )
20 self.addOption('calibFile', None, type=str,
21 info="path to a Xbb JSON calibration file.")
22 self.addOption ('generator', "autoconfig", type=str,
23 info="MC generator setup, for MC/MC SFs. The default is `autoconfig`"
24 " (relies on the sample metadata).")
25 self.addOption('noEffSF', False, type=bool,
26 info="do not compute the efficiency SF.")
27
28 def instanceName (self) :
29 """Return the instance name for this block"""
30 return self.containerName + '_' + self.Xbbtagger + '_' + self.XbbWP
31
32 def makeAlgs(self, config):
33
34 jetContainer = config.originalName(self.containerName)
35 selectionName = f'{self.Xbbtagger}_{self.XbbWP}'
36
37 # Create selection tool as public so it can be shared as the efficiency tool also needs the selection tool
38 # Must be created before the algorithm so the tool is initialized first
39 btagSelectionTool = config.createPublicTool( "BTaggingLargeRSelectionJsonTool", f"XbbLargeRJetSelectionJsonTool_{jetContainer}_{selectionName}")
40 # Get type/name tool as this is what is passed to initialize tool for AnalysisBase
41 btagSelectionToolTypeName = f"{btagSelectionTool.getType()}/{btagSelectionTool.getName()}"
42
43 btagSelectionTool.MaxEta = 4.5
44 btagSelectionTool.MinPt = 0.
45 btagSelectionTool.OutputName = self.Xbbtagger
46 btagSelectionTool.JetAuthor = jetContainer
47 btagSelectionTool.OperatingPoint = self.XbbWP
48 btagSelectionTool.JsonConfigFile = self.calibFile
49
50 alg = config.createAlgorithm( 'CP::XbbInformationDecoratorAlg', 'XbbInfoAlg' )
51 alg.selectionTool = btagSelectionToolTypeName
52 alg.preselection = config.getPreselection (self.containerName, '')
53
54 alg.taggerDecisionDecoration = 'xbb_select_' + selectionName
55 alg.jets = config.readName (self.containerName)
56 config.addOutputVar (self.containerName, 'xbb_select_' + selectionName, selectionName + '_select', noSys=True, auxType="int")
57
58 if not self.noEffSF and config.dataType() != DataType.Data:
59 alg = config.createAlgorithm( 'CP::XbbEfficiencyAlg',
60 'XbbSFAlg' )
61 config.addPrivateTool('efficiencyTool', 'BTaggingLargeREfficiencyJsonTool' )
62 alg.efficiencyTool.MaxEta = 4.5
63 alg.efficiencyTool.MinPt = 0.
64 alg.efficiencyTool.OutputName = self.Xbbtagger
65 alg.efficiencyTool.JetAuthor = jetContainer
66 alg.efficiencyTool.OperatingPoint = self.XbbWP
67 alg.efficiencyTool.JsonConfigFile = self.calibFile
68
69 # MC/MC efficiency map for the generator
70 mcGenerator = MCMC_dsid_map(config.geometry(), config.generatorInfo(), self.generator, self.Xbbtagger)
71 alg.efficiencyTool.MCGenerator = mcGenerator
72
73 # Provide the selection tool to the efficiency tool
74 alg.efficiencyTool.btagSelectionJsonTool = btagSelectionToolTypeName
75
76 alg.preselection = config.getPreselection (self.containerName, '')
77 alg.outOfValidity = 2 # continue silently, but decorate jet with outOfValidityDeco
78 alg.outOfValidityDeco = 'no_xbb_' + selectionName + ',as_char'
79
80 alg.scaleFactorDecoration = 'xbb_effSF_' + selectionName + '_%SYS%'
81 alg.jets = config.readName (self.containerName)
82 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, selectionName + '_effSF', auxType="float")