31 #include "Gaudi/Property.h"
45 return StatusCode::FAILURE;
56 return StatusCode::SUCCESS;
67 <<
" corresponding truth vertices ");
68 return StatusCode::SUCCESS;
82 if (!truthParticles.isValid()) {
84 return StatusCode::FAILURE;
86 if (!truthVertices.isValid()) {
88 return StatusCode::FAILURE;
93 std::vector<int> recoParticleTruthIndices;
94 std::vector<int> egammaTruthIndices{};
107 recoParticleTruthIndices.push_back(
truthMuon->index());
124 recoParticleTruthIndices.push_back(truthElectron->
index());
140 recoParticleTruthIndices.push_back(truthElectron->
index());
155 recoParticleTruthIndices.push_back(truthPhoton->
index());
162 if (!egammaTruthParticles.
isValid()) {
171 accType(*egTruthParticle) != MCTruthPartClassifier::IsoElectron ||
178 "truthParticleLink");
183 const TruthLink_t& truthegamma = linkToTruth(*egTruthParticle);
187 egammaTruthIndices.push_back((*truthegamma)->index());
192 std::vector<bool> particleMask, vertexMask;
193 int nTruthParticles = truthParticles->size();
194 int nTruthVertices = truthVertices->size();
197 particleMask.assign(nTruthParticles,
false);
198 vertexMask.assign(nTruthVertices,
false);
202 std::vector<std::pair<int, int>> vertexLinksCounts;
203 for (
const auto *
vertex : *truthVertices) {
204 std::pair<int, int> tmpPair;
205 tmpPair.first =
vertex->nIncomingParticles();
206 tmpPair.second =
vertex->nOutgoingParticles();
207 vertexLinksCounts.push_back(tmpPair);
211 std::unordered_set<int> encounteredUniqueIDs;
212 for (
int i = 0;
i < nTruthParticles; ++
i) {
213 encounteredUniqueIDs.clear();
218 encounteredUniqueIDs.clear();
232 for (
int i = 0;
i < nChildren; ++
i) {
240 if (
std::find(recoParticleTruthIndices.begin(),
241 recoParticleTruthIndices.end(),
242 i) != recoParticleTruthIndices.end()) {
246 encounteredUniqueIDs.clear();
248 encounteredUniqueIDs.clear();
254 if (
std::find(egammaTruthIndices.begin(), egammaTruthIndices.end(),
i) !=
255 egammaTruthIndices.end()) {
257 encounteredUniqueIDs.clear();
261 particleMask[
i] =
true;
266 for (
int i = 0;
i < nTruthParticles; ++
i) {
267 if (!particleMask[
i]) {
271 const auto *prodVertex =
particle->prodVtx();
272 --vertexLinksCounts[prodVertex->index()].second;
275 const auto *decayVertex =
particle->decayVtx();
276 --vertexLinksCounts[decayVertex->index()].first;
284 unsigned int nVerticesThinned = 0;
285 for (
int i = 0;
i < nTruthVertices; ++
i) {
286 if (vertexLinksCounts[
i].
first != 0 || vertexLinksCounts[
i].
second != 0) {
287 vertexMask[
i] =
true;
294 truthParticles.
keep(particleMask);
295 truthVertices.keep(vertexMask);
297 return StatusCode::SUCCESS;
308 std::vector<bool>& particleMask,
309 std::unordered_set<int>& encounteredUniqueIDs)
const
313 std::unordered_set<int>::const_iterator
found =
315 if (
found != encounteredUniqueIDs.end())
320 int headIndex = pHead->
index();
321 particleMask[headIndex] =
true;
333 for (
int i = 0;
i < nParents; ++
i)
344 std::vector<bool>& particleMask,
345 std::unordered_set<int>& encounteredUniqueIDs)
const
348 std::unordered_set<int>::const_iterator
found =
350 if (
found != encounteredUniqueIDs.end())
355 int headIndex = pHead->
index();
356 particleMask[headIndex] =
true;
368 for (
int i = 0;
i < nChildren; ++
i) {