62 def makeAlgs (self, config) :
63
64
65 if 'EleRM' in self.inputContainer:
66 if config.dataType() is DataType.Data and config.dataYear() <= 2023:
67 raise RuntimeError("EleRM taus are only available from 2024 dataset onward")
68 elif config.dataType() is not DataType.Data and config.campaign() <= Campaign.MC23d:
69 raise RuntimeError("EleRM taus are only available from 2024 dataset onward")
70
71 postfix = self.postfix
72 if postfix != '' and postfix[0] != '_' :
73 postfix = '_' + postfix
74
75 inputContainer = "AnalysisTauJets" if config.isPhyslite() else "TauJets"
76 if self.inputContainer:
77 inputContainer = self.inputContainer
78 config.setSourceName (self.containerName, inputContainer)
79
80
81 if config.wantCopy (self.containerName) :
82 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'TauShallowCopyAlg' )
83 alg.input = config.readName (self.containerName)
84 alg.output = config.copyName (self.containerName)
85 alg.outputType = 'xAOD::TauJetContainer'
86
87 extraInputs = [
88 ( 'SG::AuxVectorBase' , 'StoreGateSvc+TauJets.EleRNNLoose_v1' ),
89 ( 'SG::AuxVectorBase' , 'StoreGateSvc+TauJets.TESCompatibility' )
90 ]
91 config.setExtraInputs (extraInputs)
92
93 decorations = []
94 if self.addGlobalFELinksDep:
95 decorations += ['neutralGlobalFELinks', 'chargedGlobalFELinks']
96 if config.dataType() is not DataType.Data:
97 decorations += ['IsTruthMatched', 'truthJetLink', 'truthParticleLink']
98 if decorations:
99 alg.declareDecorations = decorations
100
101
102 if self.rerunTruthMatching and config.dataType() is not DataType.Data:
103 alg = config.createAlgorithm( 'CP::TauTruthMatchingAlg',
104 'TauTruthMatchingAlg' )
105 config.addPrivateTool( 'matchingTool',
106 'TauAnalysisTools::TauTruthMatchingTool' )
107 alg.matchingTool.TruthJetContainerName = 'AntiKt4TruthDressedWZJets'
108 alg.taus = config.readName (self.containerName)
109 alg.preselection = config.getPreselection (self.containerName, '')
110
111
112 if self.decorateTruth and config.dataType() is not DataType.Data:
113 alg = config.createAlgorithm( 'CP::TauTruthDecorationsAlg',
114 'TauTruthDecorationsAlg',
115 reentrant=True )
116 alg.taus = config.readName (self.containerName, nominal=True)
117 alg.doubleDecorations = ['pt_vis', 'pt_invis', 'eta_vis', 'eta_invis', 'phi_vis', 'phi_invis', 'm_vis', 'm_invis']
118 alg.floatDecorations = []
119 alg.intDecorations = ['pdgId']
120 alg.unsignedIntDecorations = ['classifierParticleOrigin', 'classifierParticleType']
121 alg.charDecorations = ['IsHadronicTau']
122 alg.prefix = 'truth_'
123
124
125 intTruthVars = ['DecayMode', 'ParticleType', 'PartonTruthLabelID']
126 for var in intTruthVars + alg.doubleDecorations[:] + alg.floatDecorations[:] + alg.intDecorations[:] + alg.unsignedIntDecorations[:] + alg.charDecorations[:]:
127 branchName = alg.prefix + var
128 if 'classifierParticle' in var:
129 branchOutput = alg.prefix + var.replace('classifierParticle', '').lower()
130 else:
131 branchOutput = branchName
132 auxType = 'int' if var in intTruthVars else None
133 config.addOutputVar (self.containerName, branchName, branchOutput, noSys=True, auxType=auxType)
134
135
136 if self.decorateExtraVariables:
137 alg = config.createAlgorithm( 'CP::TauExtraVariablesAlg',
138 'TauExtraVariablesAlg',
139 reentrant=True )
140 alg.taus = config.readName (self.containerName, nominal=True)
141
142
143 alg = config.createAlgorithm( 'CP::TauSmearingAlg', 'TauSmearingAlg' )
144 config.addPrivateTool( 'smearingTool', 'TauAnalysisTools::TauSmearingTool' )
145 alg.smearingTool.useFastSim = config.dataType() is DataType.FastSim
146 alg.smearingTool.Campaign = _campaign(config)
147 if config.geometry() is LHCPeriod.Run2 and self.useGNTau:
148 raise RuntimeError("Tau Smearing recommendations with GNTau are not yet available for Run2")
149 alg.smearingTool.useGNTau = self.useGNTau
150 alg.taus = config.readName (self.containerName)
151 alg.tausOut = config.copyName (self.containerName)
152 config.setExtraOutputs ({('xAOD::IParticleContainer' , 'StoreGateSvc+' + config.readName(self.containerName, nominal=True) + '.RNNEleScoreSigTrans_v1')})
153 alg.preselection = config.getPreselection (self.containerName, '')
154
155
156 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' )
157 alg.particles = config.readName (self.containerName)
158
159 config.addOutputVar (self.containerName, 'pt', 'pt')
160 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
161 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
162 config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
163 config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
164 config.addOutputVar (self.containerName, 'NNDecayMode', 'NNDecayMode', noSys=True, auxType='int')
165 config.addOutputVar (self.containerName, 'passTATTauMuonOLR', 'passTATTauMuonOLR', noSys=True, auxType='char')
166 config.addOutputVar (self.containerName, 'TESCompatibility', 'TESCompatibility')
167 if self.decorateExtraVariables:
168 config.addOutputVar (self.containerName, 'nTracksCharged', 'nTracksCharged', noSys=True)
169
170