14 #include "GaudiKernel/ThreadLocalContext.h"
21 const IInterface*
p ) :
29 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
30 ATH_MSG_INFO(
"Using " << m_inDetSGKey <<
" as the source collection for inner detector track particles");
32 if (m_LepRMTauKey.key().empty())
35 return StatusCode::FAILURE;
39 ATH_MSG_INFO(
"Inner detector track particles associated with objects in " << m_LepRMTauKey.key() <<
" will be retained in this format with the rest being thinned away");
41 ATH_CHECK(m_LepRMTauKey.initialize(m_streamName));
44 if (m_tauTracksSGKey.key().empty()) {
45 ATH_MSG_FATAL(
"No tau tracks collection provided for thinning.");
46 return StatusCode::FAILURE;
48 ATH_MSG_INFO(
"Tau track thinning requested; tau tracks with the SG key " << m_tauTracksSGKey.key() <<
" will be thinned if not associated with objects in " << m_LepRMTauKey.key());
49 ATH_CHECK( m_tauTracksSGKey.initialize (m_streamName) );
53 if (!m_selectionString.empty()) {
54 ATH_CHECK(initializeParser(m_selectionString) );
58 return StatusCode::SUCCESS;
64 ATH_MSG_INFO(
"Processed "<< m_ntot_trks <<
" tau tracks, "<< m_npass_trks<<
" were retained ");
65 ATH_MSG_INFO(
"Processed "<< m_ntot_ID_trks <<
" ID tracks, "<< m_npass_ID_trks<<
" were retained ");
66 ATH_MSG_INFO(
"Processed "<< m_ntot_taus <<
" taus, "<< m_npass_taus<<
" were retained ");
68 return StatusCode::SUCCESS;
74 const EventContext& ctx = Gaudi::Hive::currentContext();
77 if (!TrackParticles.isValid()) {
78 ATH_MSG_ERROR(
"No tau collection with name " << m_inDetSGKey.key() <<
" found in StoreGate!");
79 return StatusCode::FAILURE;
82 if (!TauTracks.isValid()) {
83 ATH_MSG_ERROR(
"No tau collection with name " << m_tauTracksSGKey.key() <<
" found in StoreGate!");
84 return StatusCode::FAILURE;
87 if (!LepRMTaus.isValid()) {
88 ATH_MSG_ERROR(
"No tau collection with name " << m_LepRMTauKey.key() <<
" found in StoreGate!");
89 return StatusCode::FAILURE;
93 ATH_MSG_ERROR(
"No tau collection with name " << m_originalTauKey.key() <<
" found in StoreGate!");
94 return StatusCode::FAILURE;
98 std::vector<int> tau_kine_mask = m_parser->evaluateAsVector();
99 std::vector<bool> tau_lep_remove_mask(OriTaus->
size(),
false);
101 std::transform(LepRMTaus->cbegin(), LepRMTaus->cend(), tau_lep_remove_mask.begin(),
102 [&](
auto lep_remove_tau) ->
bool {
103 return static_cast<bool>(acc_modified(*lep_remove_tau));
106 std::vector<bool> tau_mask(OriTaus->
size(),
false);
107 std::transform(tau_lep_remove_mask.cbegin(), tau_lep_remove_mask.cend(), tau_kine_mask.cbegin(), tau_mask.begin(),
108 [](
auto tau_lep_remove_pass,
auto tau_kine_pass) ->
bool
110 return tau_lep_remove_pass == 1 && tau_kine_pass == 1;
114 std::vector<const xAOD::TauJet*> LepRMTausAfterThinning;
115 std::transform(tau_mask.cbegin(), tau_mask.cend(), LepRMTaus->cbegin(), std::back_inserter(LepRMTausAfterThinning),
118 return mask ? tau : nullptr;
121 LepRMTausAfterThinning.erase(
std::remove(LepRMTausAfterThinning.begin(), LepRMTausAfterThinning.end(),
nullptr), LepRMTausAfterThinning.end());
124 std::vector<bool> tau_track_mask(TauTracks->size(),
false);
125 std::vector<bool> id_track_mask(TrackParticles->size(),
false);
126 std::for_each(LepRMTausAfterThinning.cbegin(), LepRMTausAfterThinning.cend(),
129 auto tau_track_links = tau->tauTrackLinks();
130 std::for_each(tau_track_links.cbegin(), tau_track_links.cend(),
135 tau_track_mask[link.index()] = 1;
136 if (auto id_track_link = (*link)->trackLinks().at(0); id_track_link.isValid())
138 id_track_mask[id_track_link.index()] = 1;
146 LepRMTaus.keep(tau_mask);
147 TauTracks.keep(tau_track_mask);
148 TrackParticles.keep(id_track_mask);
150 m_ntot_taus += OriTaus->size();
151 m_ntot_trks += TauTracks->size();
152 m_ntot_ID_trks += TrackParticles->size();
154 m_npass_trks +=
std::accumulate(tau_track_mask.begin(), tau_track_mask.end(),0);
155 m_npass_ID_trks +=
std::accumulate(id_track_mask.begin(), id_track_mask.end(),0);
158 return StatusCode::SUCCESS;