83 if (!jets.isValid()) {
85 return StatusCode::FAILURE;
89 std::vector<const xAOD::Jet*> selectedJets;
93 std::vector<int>
entries = m_parser->evaluateAsVector();
94 if (
entries.size() != jets->size()) {
96 return StatusCode::FAILURE;
99 for (
size_t i = 0; i < jets->size(); ++i) {
101 selectedJets.push_back((*jets)[i]);
106 for (
const auto*
jet : *jets) {
107 selectedJets.push_back(
jet);
111 ATH_MSG_DEBUG(
"Number of selected jets: " << selectedJets.size()
112 <<
" out of " << jets->size());
121 std::vector<bool> jetChargedMask(jetChargedContainer.isValid() ? jetChargedContainer->size() : 0,
false);
122 std::vector<bool> jetNeutralMask(jetNeutralContainer.isValid() ? jetNeutralContainer->size() : 0,
false);
123 std::vector<bool> globalChargedMask(globalChargedContainer.isValid() ? globalChargedContainer->size() : 0,
false);
124 std::vector<bool> globalNeutralMask(globalNeutralContainer.isValid() ? globalNeutralContainer->size() : 0,
false);
127 const int jetChargedMaskSize =
static_cast<int>(jetChargedMask.size());
128 const int jetNeutralMaskSize =
static_cast<int>(jetNeutralMask.size());
129 const int globalChargedMaskSize =
static_cast<int>(globalChargedMask.size());
130 const int globalNeutralMaskSize =
static_cast<int>(globalNeutralMask.size());
133 static const SG::AuxElement::ConstAccessor<ElementLink<xAOD::IParticleContainer>> originalAcc(
"originalObjectLink");
136 std::vector<const xAOD::IParticle*> otherObjects;
139 for (
const auto*
jet : selectedJets) {
144 for (
size_t i = 0; i <
jet->numConstituents(); ++i) {
145 const auto& link =
jet->constituentLinks().at(i);
146 if (!link.isValid()) {
151 int index = link.index();
160 ATH_MSG_VERBOSE(
" Constituent at index " << i <<
" is not a FlowElement, skipping");
169 if (
index < jetChargedMaskSize) {
170 jetChargedMask[
index] =
true;
172 <<
", eta=" << flowElement->
eta());
175 if (
index < jetNeutralMaskSize) {
176 jetNeutralMask[
index] =
true;
178 <<
", eta=" << flowElement->
eta());
183 if (originalAcc.isAvailable(*flowElement)) {
186 int origIndex = origLink.
index();
187 if (origIndex >= 0) {
188 if (
isCharged && origIndex < globalChargedMaskSize) {
189 globalChargedMask[origIndex] =
true;
191 }
else if (!
isCharged && origIndex < globalNeutralMaskSize) {
192 globalNeutralMask[origIndex] =
true;
201 std::vector<const xAOD::IParticle*> others = flowElement->
otherObjects();
202 otherObjects.insert(otherObjects.end(), others.begin(), others.end());
207 size_t nChargedKept = std::count(jetChargedMask.begin(), jetChargedMask.end(),
true);
208 size_t nNeutralKept = std::count(jetNeutralMask.begin(), jetNeutralMask.end(),
true);
209 ATH_MSG_DEBUG(
"Keeping " << nChargedKept <<
" charged constituents and "
210 << nNeutralKept <<
" neutral constituents from selected jets");
213 ATH_MSG_DEBUG(
"Found " << otherObjects.size() <<
" otherObjects from constituents");
217 if (jetChargedContainer.isValid()) {
218 jetChargedContainer.
keep(jetChargedMask);
220 << nChargedKept <<
" out of " << jetChargedContainer->size() <<
" objects");
225 if (jetNeutralContainer.isValid()) {
226 jetNeutralContainer.
keep(jetNeutralMask);
227 size_t nNeutralGlobalKept = std::count(jetNeutralMask.begin(), jetNeutralMask.end(),
true);
229 << nNeutralGlobalKept <<
" out of " << jetNeutralContainer->size() <<
" objects");
234 if (globalChargedContainer.isValid()) {
235 globalChargedContainer.
keep(globalChargedMask);
236 size_t nGlobalChargedKept = std::count(globalChargedMask.begin(), globalChargedMask.end(),
true);
238 << nGlobalChargedKept <<
" out of " << globalChargedContainer->size() <<
" objects");
243 if (globalNeutralContainer.isValid()) {
244 globalNeutralContainer.
keep(globalNeutralMask);
245 size_t nGlobalNeutralKept = std::count(globalNeutralMask.begin(), globalNeutralMask.end(),
true);
247 << nGlobalNeutralKept <<
" out of " << globalNeutralContainer->size() <<
" objects");
256 if (!otherObjectsContainer.isValid()) {
259 size_t nObjects = otherObjectsContainer->size();
260 std::vector<bool> mask(nObjects,
false);
261 const int maskSize =
static_cast<int>(mask.size());
264 for (
const auto* other : otherObjects) {
265 if (!other)
continue;
266 int index = other->index();
272 size_t nKept = std::count(mask.begin(), mask.end(),
true);
274 << nKept <<
" out of " << nObjects <<
" objects");
276 otherObjectsContainer.
keep(mask);
280 return StatusCode::SUCCESS;