ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TruthTrackFinder.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TruthTrackFinder.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2019 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include "
ACTFW/TruthTracking/TruthTrackFinder.hpp
"
10
11
#include <algorithm>
12
#include <stdexcept>
13
#include <vector>
14
15
#include "
ACTFW/EventData/IndexContainers.hpp
"
16
#include "
ACTFW/EventData/ProtoTrack.hpp
"
17
#include "
ACTFW/EventData/SimParticle.hpp
"
18
#include "
ACTFW/Framework/WhiteBoard.hpp
"
19
#include "
ACTFW/Utilities/Range.hpp
"
20
21
using namespace
FW;
22
23
TruthTrackFinder::TruthTrackFinder
(
const
Config
& cfg,
Acts::Logging::Level
lvl)
24
:
BareAlgorithm
(
"TruthTrackFinder"
, lvl), m_cfg(cfg) {
25
if
(
m_cfg
.
inputParticles
.empty()) {
26
throw
std::invalid_argument(
"Missing input truth particles collection"
);
27
}
28
if
(
m_cfg
.
inputHitParticlesMap
.empty()) {
29
throw
std::invalid_argument(
"Missing input hit-particles map collection"
);
30
}
31
if
(
m_cfg
.
outputProtoTracks
.empty()) {
32
throw
std::invalid_argument(
"Missing output proto tracks collection"
);
33
}
34
}
35
36
ProcessCode
TruthTrackFinder::execute
(
const
AlgorithmContext
& ctx)
const
{
37
using
HitParticlesMap =
IndexMultimap<ActsFatras::Barcode>
;
38
39
// prepare input collections
40
const
auto
& particles =
41
ctx.
eventStore
.
get
<
SimParticleContainer
>(
m_cfg
.
inputParticles
);
42
const
auto
& hitParticlesMap =
43
ctx.
eventStore
.
get
<HitParticlesMap>(
m_cfg
.
inputHitParticlesMap
);
44
// compute particle_id -> {hit_id...} map from the
45
// hit_id -> {particle_id...} map on the fly.
46
const
auto
& particleHitsMap =
invertIndexMultimap
(hitParticlesMap);
47
48
// prepare output collection
49
ProtoTrackContainer
tracks;
50
tracks.reserve(particles.size());
51
52
// create prototracks for all input particles
53
for
(
const
auto
&
particle
: particles) {
54
// find the corresponding hits for this particle
55
const
auto
&
hits
=
56
makeRange
(particleHitsMap.equal_range(
particle
.particleId()));
57
// fill hit indices to create the proto track
58
ProtoTrack
track
;
59
track.reserve(
hits
.size());
60
for
(
const
auto
& hit :
hits
) {
61
track.emplace_back(hit.second);
62
}
63
// add proto track to the output collection
64
tracks.emplace_back(std::move(track));
65
}
66
67
ctx.
eventStore
.
add
(
m_cfg
.
outputProtoTracks
, std::move(tracks));
68
return
ProcessCode::SUCCESS
;
69
}
acts
blob
master
Examples
Algorithms
TruthTracking
ACTFW
TruthTracking
TruthTrackFinder.cpp
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:23
using
1.8.2 with
ECCE GitHub integration