31 #include "Gaudi/Property.h"
45 return StatusCode::FAILURE;
69 return StatusCode::SUCCESS;
80 <<
" corresponding truth vertices ");
81 return StatusCode::SUCCESS;
93 if (!truthParticles.isValid()) {
95 return StatusCode::FAILURE;
97 if (!truthVertices.isValid()) {
99 return StatusCode::FAILURE;
104 std::vector<int> recoParticleTruthIndices;
105 std::vector<int> egammaTruthIndices{};
116 recoParticleTruthIndices.push_back(
truthMuon->index());
133 recoParticleTruthIndices.push_back(truthElectron->
index());
146 recoParticleTruthIndices.push_back(truthElectron->
index());
158 recoParticleTruthIndices.push_back(truthPhoton->
index());
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;
274 particleMask[
i] =
true;
283 for (
int i = 0;
i < nTruthParticles; ++
i) {
284 if (!particleMask[
i]) {
288 const auto *prodVertex =
particle->prodVtx();
289 --vertexLinksCounts[prodVertex->index()].second;
292 const auto *decayVertex =
particle->decayVtx();
293 --vertexLinksCounts[decayVertex->index()].first;
301 unsigned int nVerticesThinned = 0;
302 for (
int i = 0;
i < nTruthVertices; ++
i) {
303 if (vertexLinksCounts[
i].
first != 0 || vertexLinksCounts[
i].
second != 0) {
304 vertexMask[
i] =
true;
311 truthParticles.keep(particleMask);
312 truthVertices.keep(vertexMask);
314 return StatusCode::SUCCESS;
325 std::vector<bool>& particleMask,
326 std::unordered_set<int>& encounteredUniqueIDs)
const
330 std::unordered_set<int>::const_iterator
found =
332 if (
found != encounteredUniqueIDs.end())
337 int headIndex = pHead->
index();
338 particleMask[headIndex] =
true;
350 for (
int i = 0;
i < nParents; ++
i)
361 std::vector<bool>& particleMask,
362 std::unordered_set<int>& encounteredUniqueIDs)
const
365 std::unordered_set<int>::const_iterator
found =
367 if (
found != encounteredUniqueIDs.end())
372 int headIndex = pHead->
index();
373 particleMask[headIndex] =
true;
385 for (
int i = 0;
i < nChildren; ++
i) {