77 const EventContext& ctx = Gaudi::Hive::currentContext();
81 if (!tauJetsReadHandle.isValid()) {
82 ATH_MSG_ERROR (
"Could not retrieve TauJetContainer with key " << tauJetsReadHandle.key());
83 return StatusCode::FAILURE;
89 if (!vtxReadHandle.isValid()) {
90 ATH_MSG_ERROR (
"Could not retrieve VertexContainer with key " << vtxReadHandle.key());
91 return StatusCode::FAILURE;
95 float sumpt_PV0 = 0., sumpt2_PV0 = 0.;
98 if (vtxContainer !=
nullptr && !vtxContainer->
empty()) {
99 auto itrVtx = std::find_if(vtxContainer->
begin(), vtxContainer->
end(),
101 return vtx->vertexType() == xAOD::VxType::PriVtx;
103 pVtx = (itrVtx == vtxContainer->
end() ? nullptr : *itrVtx);
104 if (pVtx ==
nullptr){
105 ATH_MSG_DEBUG(
"No PV found, using the first element instead!");
106 pVtx = vtxContainer->
at(0);
110 sumpt_PV0 += (*trk)->pt();
111 sumpt2_PV0 +=
std::pow((*trk)->pt(), 2.);
123 std::vector<SG::WriteDecorHandle<xAOD::TauJetContainer, float> > scoreDecors;
124 scoreDecors.reserve (
m_scores.size());
126 scoreDecors.emplace_back (
k, ctx);
128 std::vector<SG::WriteDecorHandle<xAOD::TauJetContainer, char> > WPDecors;
129 WPDecors.reserve (
m_WPs.size());
131 WPDecors.emplace_back (
k, ctx);
136 for (
const auto tau : *tauContainer) {
137 float tauTrackBasedWidth = 0.;
139 std::vector<const xAOD::TauTrack *> tauTracks = tau->tracks();
141 tauTracks.push_back(trk);
143 double sumWeightedDR = 0.;
148 ptSum +=
track->pt();
151 tauTrackBasedWidth = sumWeightedDR / ptSum;
154 dec_trackWidth(*tau) = tauTrackBasedWidth;
160 for (
auto tau : *shallowCopy.first) {
163 float dz0_TV_PV0 = -999., sumpt_TV = 0., sumpt2_TV = 0.;
167 sumpt_TV += (*trk)->pt();
168 sumpt2_TV +=
std::pow((*trk)->pt(), 2.);
172 acc_log_sumpt_TV(*tau) = (sumpt_TV>0.) ?
std::log(sumpt_TV) : 0.;
173 acc_log_sumpt2_TV(*tau) = (sumpt2_TV>0.) ?
std::log(sumpt2_TV) : 0.;
174 acc_log_sumpt_PV0(*tau) = (sumpt_PV0>0.) ?
std::log(sumpt_PV0) : 0.;
175 acc_log_sumpt2_PV0(*tau) = (sumpt2_PV0>0.) ?
std::log(sumpt2_PV0) : 0.;
180 float absEtaLead = -1111.;
181 if(tau->nTracks() > 0) {
183 absEtaLead = std::abs(
track->eta() );
185 acc_absEtaLead(*tau) = absEtaLead;
194 const xAOD::TauJet* xTau = tauContainer->at(tau->index());
197 dec(*xTau) = scoreAcc(*tau);
201 dec(*xTau) = WPAcc(*tau);
205 delete shallowCopy.first;
206 delete shallowCopy.second;
210 if (!muonReadHandle.isValid()) {
211 ATH_MSG_DEBUG (
"Could not retrieve MuonContainer with key " << muonReadHandle.key() <<
" so won't add TAT MuonOLR flag");
212 return StatusCode::SUCCESS;
216 for (
const auto tau : *tauContainer) {
217 bool bTauMuonOLR =
true;
219 if(
muon->pt() < 2000.)
continue;
220 if(
muon->muonType() == xAOD::Muon::CaloTagged)
continue;
221 if(
muon->p4().DeltaR( tau->p4() ) > 0.2 )
continue;
225 dec_passTATTauMuonOLR(*tau) = bTauMuonOLR;
228 return StatusCode::SUCCESS;