15 declareInterface<DerivationFramework::IAugmentationTool>(
this);
25 if (
tool->type() !=
"TauWPDecorator")
continue;
28 BooleanProperty useAbsEta(
"UseAbsEta",
false);
30 if (useAbsEta.value()) {
35 StringProperty scoreName(
"ScoreName",
"");
38 if (scoreName.value() !=
"RNNEleScore") {
39 m_scores.push_back(scoreName.value());
42 StringProperty newScoreName(
"NewScoreName",
"");
44 m_scores.push_back(newScoreName.value());
46 StringArrayProperty decorWPNames(
"DecorWPNames", {});
48 for (
const auto&
WP : decorWPNames.value())
m_WPs.push_back(
WP);
55 for (
const std::string&
WP :
m_WPs) {
68 return StatusCode::SUCCESS;
73 return StatusCode::SUCCESS;
78 const EventContext& ctx = Gaudi::Hive::currentContext();
82 if (!tauJetsReadHandle.
isValid()) {
83 ATH_MSG_ERROR (
"Could not retrieve TauJetContainer with key " << tauJetsReadHandle.
key());
84 return StatusCode::FAILURE;
91 ATH_MSG_ERROR (
"Could not retrieve VertexContainer with key " << vtxReadHandle.
key());
92 return StatusCode::FAILURE;
96 float sumpt_PV0 = 0., sumpt2_PV0 = 0.;
99 if (vtxContainer !=
nullptr && !vtxContainer->
empty()) {
100 auto itrVtx = std::find_if(vtxContainer->
begin(), vtxContainer->
end(),
102 return vtx->vertexType() == xAOD::VxType::PriVtx;
104 pVtx = (itrVtx == vtxContainer->
end() ? nullptr : *itrVtx);
105 if (pVtx ==
nullptr){
106 ATH_MSG_DEBUG(
"No PV found, using the first element instead!");
107 pVtx = vtxContainer->
at(0);
111 sumpt_PV0 += (*trk)->pt();
112 sumpt2_PV0 +=
std::pow((*trk)->pt(), 2.);
124 std::vector<SG::WriteDecorHandle<xAOD::TauJetContainer, float> > scoreDecors;
125 scoreDecors.reserve (
m_scores.size());
127 scoreDecors.emplace_back (
k, ctx);
129 std::vector<SG::WriteDecorHandle<xAOD::TauJetContainer, char> > WPDecors;
130 WPDecors.reserve (
m_WPs.size());
132 WPDecors.emplace_back (
k, ctx);
137 for (
const auto tau : *tauContainer) {
138 float tauTrackBasedWidth = 0.;
140 std::vector<const xAOD::TauTrack *> tauTracks = tau->tracks();
142 tauTracks.push_back(trk);
144 double sumWeightedDR = 0.;
149 ptSum +=
track->pt();
152 tauTrackBasedWidth = sumWeightedDR / ptSum;
155 dec_trackWidth(*tau) = tauTrackBasedWidth;
161 for (
auto tau : *shallowCopy.first) {
164 float dz0_TV_PV0 = -999., sumpt_TV = 0., sumpt2_TV = 0.;
168 sumpt_TV += (*trk)->pt();
169 sumpt2_TV +=
std::pow((*trk)->pt(), 2.);
173 acc_log_sumpt_TV(*tau) = (sumpt_TV>0.) ?
std::log(sumpt_TV) : 0.;
174 acc_log_sumpt2_TV(*tau) = (sumpt2_TV>0.) ?
std::log(sumpt2_TV) : 0.;
175 acc_log_sumpt_PV0(*tau) = (sumpt_PV0>0.) ?
std::log(sumpt_PV0) : 0.;
176 acc_log_sumpt2_PV0(*tau) = (sumpt2_PV0>0.) ?
std::log(sumpt2_PV0) : 0.;
181 float absEtaLead = -1111.;
182 if(tau->nTracks() > 0) {
184 absEtaLead = std::abs(
track->eta() );
186 acc_absEtaLead(*tau) = absEtaLead;
195 const xAOD::TauJet* xTau = tauContainer->at(tau->index());
198 dec(*xTau) = scoreAcc(*tau);
202 dec(*xTau) = WPAcc(*tau);
206 delete shallowCopy.first;
207 delete shallowCopy.second;
211 if (!muonReadHandle.
isValid()) {
212 ATH_MSG_DEBUG (
"Could not retrieve MuonContainer with key " << muonReadHandle.
key() <<
" so won't add TAT MuonOLR flag");
213 return StatusCode::SUCCESS;
217 for (
const auto tau : *tauContainer) {
218 bool bTauMuonOLR =
true;
220 if(
muon->pt() < 2000.)
continue;
221 if(
muon->muonType() == xAOD::Muon::CaloTagged)
continue;
222 if(
muon->p4().DeltaR( tau->p4() ) > 0.2 )
continue;
226 dec_passTATTauMuonOLR(*tau) = bTauMuonOLR;
229 return StatusCode::SUCCESS;