10 using TrkThinOptional = std::optional<TrkThinning>;
12 using KeepMap = std::map<const xAOD::TrackParticleContainer*, std::vector<bool>>;
13 using KeepPair = std::pair<const xAOD::TrackParticleContainer*, std::vector<bool>>;
29 return StatusCode::FAILURE;
44 std::stringstream sstr{};
46 sstr<<
" *** "<<
key.fullKey()<<std::endl;
48 ATH_MSG_INFO(
"Accept muons with upstream flag "<<std::endl<<sstr.str());
51 std::stringstream sstr{};
53 sstr<<
" *** "<<
key.fullKey()<<std::endl;
55 ATH_MSG_INFO(
"Accept tracks with upstream flag "<<std::endl<<sstr.str());
58 return StatusCode::SUCCESS;
66 return StatusCode::FAILURE;
71 std::vector<MuonPassDecor> mu_passFlags;
75 KeepMap thin_decisions;
76 std::vector<std::unique_ptr<TrkThinning>> TrkContainers;
79 auto make_handle = [&,
this](
const TrkThinKey&
key) {
82 return StatusCode::SUCCESS;
85 TrkContainers.emplace_back(std::make_unique<TrkThinning>(
key, ctx));
87 std::unique_ptr<TrkThinning>& last = TrkContainers.back();
88 if (!last->isValid()) {
90 return StatusCode::FAILURE;
93 thin_decisions[cont].
resize(cont->
size(),
false);
94 return StatusCode::SUCCESS;
105 std::unique_ptr<SegmentThinning> segmentContainer =
107 std::vector<bool> keep_seg(segmentContainer ? segmentContainer->cptr()->size() : 0,
false);
114 <<
" quality: " <<
muon->quality() <<
", author: " <<
muon->author());
117 std::find_if(mu_passFlags.begin(), mu_passFlags.end(),
118 [
this,
muon](
const MuonPassDecor& decor) ->bool {
119 ATH_MSG_VERBOSE(
"Check decorator "<<decor.decorKey()<<
" "
120 <<SG::AuxTypeRegistry::instance().getName(decor.auxid())
121 <<
" "<< decor(*muon));
123 }) == mu_passFlags.end())
125 keep_muo[
muon->index()] =
true;
130 {xAOD::Muon::InnerDetectorTrackParticle, xAOD::Muon::MuonSpectrometerTrackParticle, xAOD::Muon::CombinedTrackParticle,
131 xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle}) {
137 KeepMap::iterator itr = std::find_if(thin_decisions.begin(), thin_decisions.end(),
138 [
track](
const KeepPair& pair) { return pair.first == track->container(); });
139 if (itr == thin_decisions.end()) {
141 <<
" a valid associated container");
144 itr->second[
track->index()] =
true;
147 if (segmentContainer) {
148 for (
size_t s = 0;
s <
muon->nMuonSegments(); ++
s) {
150 if (seg) keep_seg[seg->
index()] =
true;
157 TrackPassDecor handle{
key, ctx};
160 std::vector<bool>& trk_thin = thin_decisions[trks];
163 if (!trks->
empty() && trk_thin.empty()) {
164 ATH_MSG_WARNING(
"The container " <<
key.fullKey() <<
" is not part of the current thinning scheme. Please check");
169 if (handle(*trk)) trk_thin[trk->index()] =
true;
175 for (std::unique_ptr<TrkThinning>& thin : TrkContainers) {
176 std::vector<bool>& dec = thin_decisions[thin->cptr()];
179 if (segmentContainer) { segmentContainer->keep(keep_seg); }
181 return StatusCode::SUCCESS;