16 #include "GaudiKernel/ThreadLocalContext.h"
23 const IInterface*
p ) :
36 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
37 ATH_MSG_INFO(
"Using " << m_inDetSGKey <<
"as the source collection for inner detector track particles");
38 if (m_tauKey.key().empty()) {
40 return StatusCode::FAILURE;
41 }
else {
ATH_MSG_INFO(
"Inner detector track particles associated with objects in " << m_tauKey.key() <<
" will be retained in this format with the rest being thinned away");}
43 if (m_doTauTracksThinning) {
44 if (m_tauTracksSGKey.key().empty()) {
45 ATH_MSG_FATAL(
"No tau tracks collection provided for thinning, despite this option being requested.");
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_tauKey.key());
49 ATH_CHECK( m_tauTracksSGKey.initialize (m_streamName) );
54 if (!m_selectionString.empty()) {
55 ATH_CHECK(initializeParser(m_selectionString) );
57 return StatusCode::SUCCESS;
63 ATH_MSG_INFO(
"Processed "<< m_ntot <<
" tracks, "<< m_npass<<
" were retained ");
65 return StatusCode::SUCCESS;
71 const EventContext& ctx = Gaudi::Hive::currentContext();
78 unsigned int nTracks = importedTrackParticles->size();
79 if (nTracks==0)
return StatusCode::SUCCESS;
82 std::vector<bool>
mask;
83 mask.assign(nTracks,
false);
90 ATH_MSG_ERROR(
"No tau collection with name " << m_tauKey.key() <<
" found in StoreGate!");
91 return StatusCode::FAILURE;
93 unsigned int nTaus(importedTaus->
size());
94 std::vector<const xAOD::TauJet*> tauToCheck; tauToCheck.clear();
97 if (!m_selectionString.empty()) {
98 std::vector<int>
entries = m_parser->evaluateAsVector();
102 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string used taus??");
103 return StatusCode::FAILURE;
106 for (
unsigned int i=0;
i<nTaus; ++
i)
if (
entries[
i]==1) tauToCheck.push_back((*importedTaus)[
i]);
110 for (
unsigned int i=0;
i<nTaus; ++
i) tauToCheck.push_back((*importedTaus)[
i]);
116 if (m_selectionString==
"") {
117 for (
const auto *tauIt : *importedTaus) {
118 if (m_coneSize>0.0) trIC.
select(tauIt,m_coneSize,importedTrackParticles.cptr(),
mask);
119 for (
unsigned int i=0;
i<tauIt->nTracks(); ++
i) {
125 for (
auto & tauIt : tauToCheck) {
126 if (m_coneSize>0.0) trIC.
select(tauIt,m_coneSize,importedTrackParticles.cptr(),
mask);
127 for (
unsigned int i=0;
i<tauIt->nTracks(); ++
i) {
135 unsigned int n_pass=0;
136 for (
unsigned int i=0;
i<nTracks; ++
i) {
137 if (
mask[
i]) ++n_pass;
145 if( m_doTauTracksThinning ) {
147 (m_tauTracksSGKey, ctx);
148 if( importedTauTracks->empty() ) {
149 return StatusCode::SUCCESS;
151 std::vector< bool > mask_tautracks( importedTauTracks->size(),
false );
157 for(
const auto& ttLink : ttLinks ) {
158 if( ! ttLink.isValid() ) {
161 if( ttLink.dataID() != m_tauTracksSGKey.key() ) {
163 "container \"" << m_tauTracksSGKey <<
"\"" );
164 return StatusCode::FAILURE;
167 mask_tautracks.at( ttLink.index() ) =
true;
170 if( m_coneSize > 0.0 ) {
171 trIC.
select( tau, m_coneSize, importedTauTracks.cptr(), mask_tautracks );
175 importedTauTracks.
keep(mask_tautracks);
179 return StatusCode::SUCCESS;