ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauAnalysisConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3# AnaAlgorithm import(s):
4from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
5from AnalysisAlgorithmsConfig.ConfigSequence import groupBlocks
6from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
7
8
9class DiTauCalibrationConfig (ConfigBlock):
10 """the ConfigBlock for the tau four-momentum correction"""
11
12 def __init__ (self) :
13 super (DiTauCalibrationConfig, self).__init__ ()
14 self.setBlockName('DiTaus')
15 self.addOption ('inputContainer', '', type=str,
16 info="the name of the input ditau-jet container.")
17 self.addOption ('containerName', '', type=str,
18 noneAction='error',
19 info="the name of the output container after calibration.")
20 self.addOption ('postfix', '', type=str,
21 info="a postfix to apply to decorations and algorithm names. "
22 "Typically not needed here since the calibration is common to "
23 "all ditau-jets.")
24 self.addOption ('quality', None, type=str,
25 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`,`Loose`,`NoID`.")
26 self.addOption ('rerunTruthMatching', True, type=bool,
27 info="whether to rerun truth matching (sets up an instance of "
28 "`CP::DiTauTruthMatchingAlg`).")
29 self.addOption ('decorateTruth', False, type=bool,
30 info="decorate the truth particle information on the reconstructed one.")
31 self.addOption ('decorateExtraVariables', True, type=bool,
32 info="decorate extra variables for the reconstructed ditau-jet.")
33
34 def instanceName (self) :
35 """Return the instance name for this block"""
36 return self.containerName + self.postfix
37
38 def makeAlgs (self, config) :
39
40 postfix = self.postfix
41 if postfix != '' and postfix[0] != '_' :
42 postfix = '_' + postfix
43
44 inputContainer = "DiTauJets"
46 inputContainer = self.inputContainer
47 config.setSourceName (self.containerName, inputContainer)
48
49 # Set up the tau truth matching algorithm:
50 if self.rerunTruthMatching and config.dataType() is not DataType.Data:
51 alg = config.createAlgorithm( 'CP::DiTauTruthMatchingAlg',
52 'DiTauTruthMatchingAlg' )
53 config.addPrivateTool( 'matchingTool',
54 'TauAnalysisTools::DiTauTruthMatchingTool' )
55 alg.taus = config.readName (self.containerName)
56 alg.preselection = config.getPreselection (self.containerName, '')
57
58
59 # decorate truth tau information on the reconstructed object:
60 if self.decorateTruth and self.rerunTruthMatching and config.dataType() is not DataType.Data:
61 # in the case of the ditau, the DiTauTruthMatchingTool decorates directly the reco ditau with truth information.
62 # So information can be written directly out without any additional algorithm
63 config.addOutputVar (self.containerName, 'TruthVisLeadPt', 'TruthVisLeadPt', noSys=True)
64 config.addOutputVar (self.containerName, 'TruthVisLeadEta', 'TruthVisLeadEta', noSys=True)
65 config.addOutputVar (self.containerName, 'TruthVisLeadPhi', 'TruthVisLeadPhi', noSys=True)
66 config.addOutputVar (self.containerName, 'TruthVisLeadM', 'TruthVisLeadM', noSys=True)
67 config.addOutputVar (self.containerName, 'TruthLeadPdgID', 'TruthLeadPdgID', noSys=True)
68 config.addOutputVar (self.containerName, 'TruthVisSubleadPt', 'TruthVisSubleadPt', noSys=True)
69 config.addOutputVar (self.containerName, 'TruthVisSubleadEta', 'TruthVisSubleadEta', noSys=True)
70 config.addOutputVar (self.containerName, 'TruthVisSubleadPhi', 'TruthVisSubleadPhi', noSys=True)
71 config.addOutputVar (self.containerName, 'TruthVisSubleadM', 'TruthVisSubleadM', noSys=True)
72 config.addOutputVar (self.containerName, 'TruthSubleadPdgID', 'TruthSubleadPdgID', noSys=True)
73 config.addOutputVar (self.containerName, 'TruthVisDeltaR', 'TruthVisDeltaR', noSys=True)
74 config.addOutputVar (self.containerName, 'TruthVisMass', 'TruthVisMass', noSys=True)
75 config.addOutputVar (self.containerName, 'IsTruthMatched', 'IsTruthMatched', noSys=True)
76 config.addOutputVar (self.containerName, 'IsTruthHadronic', 'IsTruthHadronic', noSys=True)
77
78 # Decorate extra variables
80 alg = config.createAlgorithm( 'CP::DiTauExtraVariablesAlg',
81 'DiTauExtraVariablesAlg',
82 reentrant=True )
83 alg.ditaus = config.readName (self.containerName)
84 config.addOutputVar (self.containerName, 'omniScore', 'omniScore', noSys=True)
85 config.addOutputVar (self.containerName, 'nSubjets', 'nSubjets', noSys=True)
86 config.addOutputVar (self.containerName, 'leadSubjetPt', 'leadSubjetPt', noSys=True)
87 config.addOutputVar (self.containerName, 'leadSubjetEta', 'leadSubjetEta', noSys=True)
88 config.addOutputVar (self.containerName, 'leadSubjetPhi', 'leadSubjetPhi', noSys=True)
89 config.addOutputVar (self.containerName, 'leadSubjetE', 'leadSubjetE', noSys=True)
90 config.addOutputVar (self.containerName, 'leadSubjetNTracks', 'leadSubjetNTracks', noSys=True)
91 config.addOutputVar (self.containerName, 'leadSubjetCharge', 'leadSubjetCharge', noSys=True)
92 config.addOutputVar (self.containerName, 'subleadSubjetPt', 'subleadSubjetPt', noSys=True)
93 config.addOutputVar (self.containerName, 'subleadSubjetEta', 'subleadSubjetEta', noSys=True)
94 config.addOutputVar (self.containerName, 'subleadSubjetPhi', 'subleadSubjetPhi', noSys=True)
95 config.addOutputVar (self.containerName, 'subleadSubjetE', 'subleadSubjetE', noSys=True)
96 config.addOutputVar (self.containerName, 'subleadSubjetNTracks', 'subleadSubjetNTracks', noSys=True)
97 config.addOutputVar (self.containerName, 'subleadSubjetCharge', 'subleadSubjetCharge', noSys=True)
98
99 # Set up the tau 4-momentum smearing algorithm:
100 alg = config.createAlgorithm( 'CP::DiTauSmearingAlg', 'DiTauSmearingAlg' )
101 config.addPrivateTool( 'smearingTool', 'TauAnalysisTools::DiTauSmearingTool' )
102 alg.taus = config.readName (self.containerName)
103 alg.tausOut = config.copyName (self.containerName)
104 alg.preselection = config.getPreselection (self.containerName, '')
105
106 # Save base kinematic ditau variables in output
107 config.addOutputVar (self.containerName, 'pt', 'pt')
108 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
109 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
110 config.addOutputVar (self.containerName, 'm', 'm', noSys=True)
111
112
113
115 """the ConfigBlock for the tau working point selection"""
116
117 def __init__ (self) :
118 super (DiTauWorkingPointSelectionConfig, self).__init__ ()
119 self.setBlockName('DiTauWorkingPointSelection')
120 self.addOption ('containerName', '', type=str,
121 noneAction='error',
122 info="the name of the input container.")
123 self.addOption ('selectionName', '', type=str,
124 noneAction='error',
125 info="the name of the ditau-jet selection to define (e.g. `tight` or "
126 "`loose`).")
127 self.addOption ('postfix', None, type=str,
128 info="a postfix to apply to decorations and algorithm names. "
129 "Typically not needed here as `selectionName` is used internally.")
130 self.addOption ('addSelectionToPreselection', True, type=bool,
131 info="whether to retain only ditau-jets satisfying the working point "
132 "requirements.")
133
134 def instanceName (self) :
135 """Return the instance name for this block"""
136 if self.postfix is not None:
137 return self.containerName + '_' + self.selectionName + self.postfix
138 else:
139 return self.containerName + '_' + self.selectionName
140
141 def makeAlgs (self, config) :
142
143 selectionPostfix = self.selectionName
144 if selectionPostfix != '' and selectionPostfix[0] != '_' :
145 selectionPostfix = '_' + selectionPostfix
146
147 postfix = self.postfix
148 if postfix is None :
149 postfix = self.selectionName
150 if postfix != '' and postfix[0] != '_' :
151 postfix = '_' + postfix
152
153 if "DiTauJetsLowPt" in self.containerName:
154 inputfile = 'TauAnalysisAlgorithms/ditau_selection_lowpt.conf'
155 else:
156 if 'NoID' in self.quality:
157 inputfile = 'TauAnalysisAlgorithms/ditau_selection_highpt.conf'
158 else:
159 inputfile = 'TauAnalysisAlgorithms/ditau_selection_highpt_'+self.quality+'.conf'
160
161 # Set up the algorithm selecting taus:
162 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'DiTauSelectionAlg' )
163 config.addPrivateTool( 'selectionTool', 'TauAnalysisTools::DiTauSelectionTool' )
164 alg.selectionTool.ConfigPath = inputfile
165 alg.selectionDecoration = 'selected_ditau' + selectionPostfix + ',as_char'
166 alg.particles = config.readName (self.containerName)
167 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
168 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
169 preselection=self.addSelectionToPreselection)
170
171
173 """the ConfigBlock for the tau working point efficiency computation"""
174
175 def __init__ (self) :
176 super (DiTauWorkingPointEfficiencyConfig, self).__init__ ()
177 self.setBlockName('DiTauWorkingPointEfficiency')
178 self.addDependency('DiTauWorkingPointSelection', required=True)
179 self.addDependency('EventSelection', required=False)
180 self.addDependency('EventSelectionMerger', required=False)
181 self.addOption ('containerName', '', type=str,
182 noneAction='error',
183 info="the name of the input container.")
184 self.addOption ('selectionName', '', type=str,
185 noneAction='error',
186 info="the name of the ditau-jet selection to define (e.g. `tight` or "
187 "`loose`).")
188 self.addOption ('postfix', None, type=str,
189 info="a postfix to apply to decorations and algorithm names. "
190 "Typically not needed here as `selectionName` is used internally.")
191
192 def instanceName (self) :
193 """Return the instance name for this block"""
194 if self.postfix is not None:
195 return self.containerName + '_' + self.selectionName + self.postfix
196 else:
197 return self.containerName + '_' + self.selectionName
198
199 def makeAlgs (self, config) :
200
201 selectionPostfix = self.selectionName
202 if selectionPostfix != '' and selectionPostfix[0] != '_' :
203 selectionPostfix = '_' + selectionPostfix
204
205 postfix = self.postfix
206 if postfix is None :
207 postfix = self.selectionName
208 if postfix != '' and postfix[0] != '_' :
209 postfix = '_' + postfix
210
211
212 # keep this commented out until TauCP won't provide official recommendations
213 # Set up the algorithm calculating the efficiency scale factors for the
214 # taus:
215 #if config.dataType() is not DataType.Data:
216 # alg = config.createAlgorithm( 'CP::DiTauEfficiencyCorrectionsAlg',
217 # 'DiTauEfficiencyCorrectionsAlg' )
218 # config.addPrivateTool( 'efficiencyCorrectionsTool',
219 # 'TauAnalysisTools::DiTauEfficiencyCorrectionsTool' )
220 # alg.efficiencyCorrectionsTool.JetIDLevel = IDLevel
221 # alg.scaleFactorDecoration = 'tau_effSF' + postfix + '_%SYS%'
222 # # alg.outOfValidity = 2 #silent
223 # # alg.outOfValidityDeco = "bad_eff"
224 # alg.taus = config.readName (self.containerName)
225 # alg.preselection = config.getPreselection (self.containerName, self.selectionName)
226 # config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
227 # 'effSF' + postfix)
228
229
230@groupBlocks