80 const EventContext &ctx = Gaudi::Hive::currentContext();
84 if (!jets.isValid()) {
86 return StatusCode::FAILURE;
90 std::vector<const xAOD::Jet*> selectedJets;
94 std::vector<int>
entries = m_parser->evaluateAsVector();
95 if (
entries.size() != jets->size()) {
97 return StatusCode::FAILURE;
100 for (
size_t i = 0; i < jets->size(); ++i) {
102 selectedJets.push_back((*jets)[i]);
107 for (
const auto*
jet : *jets) {
108 selectedJets.push_back(
jet);
112 ATH_MSG_DEBUG(
"Number of selected jets: " << selectedJets.size()
113 <<
" out of " << jets->size());
122 std::vector<bool> jetChargedMask(jetChargedContainer.isValid() ? jetChargedContainer->size() : 0,
false);
123 std::vector<bool> jetNeutralMask(jetNeutralContainer.isValid() ? jetNeutralContainer->size() : 0,
false);
124 std::vector<bool> globalChargedMask(globalChargedContainer.isValid() ? globalChargedContainer->size() : 0,
false);
125 std::vector<bool> globalNeutralMask(globalNeutralContainer.isValid() ? globalNeutralContainer->size() : 0,
false);
128 const int jetChargedMaskSize =
static_cast<int>(jetChargedMask.size());
129 const int jetNeutralMaskSize =
static_cast<int>(jetNeutralMask.size());
130 const int globalChargedMaskSize =
static_cast<int>(globalChargedMask.size());
131 const int globalNeutralMaskSize =
static_cast<int>(globalNeutralMask.size());
137 std::vector<const xAOD::IParticle*> otherObjects;
140 for (
const auto*
jet : selectedJets) {
145 for (
size_t i = 0; i <
jet->numConstituents(); ++i) {
146 const auto& link =
jet->constituentLinks().at(i);
147 if (!link.isValid()) {
152 int index = link.index();
161 ATH_MSG_VERBOSE(
" Constituent at index " << i <<
" is not a FlowElement, skipping");
170 if (
index < jetChargedMaskSize) {
171 jetChargedMask[
index] =
true;
173 <<
", eta=" << flowElement->
eta());
176 if (
index < jetNeutralMaskSize) {
177 jetNeutralMask[
index] =
true;
179 <<
", eta=" << flowElement->
eta());
187 int origIndex = origLink.
index();
188 if (origIndex >= 0) {
189 if (
isCharged && origIndex < globalChargedMaskSize) {
190 globalChargedMask[origIndex] =
true;
192 }
else if (!
isCharged && origIndex < globalNeutralMaskSize) {
193 globalNeutralMask[origIndex] =
true;
202 std::vector<const xAOD::IParticle*> others = flowElement->
otherObjects();
203 otherObjects.insert(otherObjects.end(), others.begin(), others.end());
208 size_t nChargedKept = std::count(jetChargedMask.begin(), jetChargedMask.end(),
true);
209 size_t nNeutralKept = std::count(jetNeutralMask.begin(), jetNeutralMask.end(),
true);
210 ATH_MSG_DEBUG(
"Keeping " << nChargedKept <<
" charged constituents and "
211 << nNeutralKept <<
" neutral constituents from selected jets");
214 ATH_MSG_DEBUG(
"Found " << otherObjects.size() <<
" otherObjects from constituents");
218 if (jetChargedContainer.isValid()) {
219 jetChargedContainer.
keep(jetChargedMask);
221 << nChargedKept <<
" out of " << jetChargedContainer->size() <<
" objects");
226 if (jetNeutralContainer.isValid()) {
227 jetNeutralContainer.
keep(jetNeutralMask);
228 size_t nNeutralGlobalKept = std::count(jetNeutralMask.begin(), jetNeutralMask.end(),
true);
230 << nNeutralGlobalKept <<
" out of " << jetNeutralContainer->size() <<
" objects");
235 if (globalChargedContainer.isValid()) {
236 globalChargedContainer.
keep(globalChargedMask);
237 size_t nGlobalChargedKept = std::count(globalChargedMask.begin(), globalChargedMask.end(),
true);
239 << nGlobalChargedKept <<
" out of " << globalChargedContainer->size() <<
" objects");
244 if (globalNeutralContainer.isValid()) {
245 globalNeutralContainer.
keep(globalNeutralMask);
246 size_t nGlobalNeutralKept = std::count(globalNeutralMask.begin(), globalNeutralMask.end(),
true);
248 << nGlobalNeutralKept <<
" out of " << globalNeutralContainer->size() <<
" objects");
257 if (!otherObjectsContainer.isValid()) {
260 size_t nObjects = otherObjectsContainer->size();
261 std::vector<bool> mask(nObjects,
false);
262 const int maskSize =
static_cast<int>(mask.size());
265 for (
const auto* other : otherObjects) {
266 if (!other)
continue;
267 int index = other->index();
273 size_t nKept = std::count(mask.begin(), mask.end(),
true);
275 << nKept <<
" out of " << nObjects <<
" objects");
277 otherObjectsContainer.
keep(mask);
281 return StatusCode::SUCCESS;