Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TruthSeedSelector.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TruthSeedSelector.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 "
ActsExamples/TruthTracking/TruthSeedSelector.hpp
"
10
11
#include "
Acts/Utilities/MultiIndex.hpp
"
12
#include "
Acts/Utilities/VectorHelpers.hpp
"
13
#include "
ActsExamples/EventData/Index.hpp
"
14
#include "
ActsExamples/EventData/SimParticle.hpp
"
15
#include "
ActsExamples/Utilities/Range.hpp
"
16
#include "
ActsFatras/EventData/Barcode.hpp
"
17
#include "
ActsFatras/EventData/Particle.hpp
"
18
19
#include <functional>
20
#include <stdexcept>
21
#include <utility>
22
23
namespace
ActsExamples {
24
struct
AlgorithmContext
;
25
}
// namespace ActsExamples
26
27
using namespace
ActsExamples;
28
29
TruthSeedSelector::TruthSeedSelector
(
const
Config
&
config
,
30
Acts::Logging::Level
level
)
31
:
IAlgorithm
(
"TruthSeedSelector"
, level),
m_cfg
(config) {
32
if
(
m_cfg
.
inputParticles
.empty()) {
33
throw
std::invalid_argument(
"Missing input truth particles collection"
);
34
}
35
if
(
m_cfg
.
inputMeasurementParticlesMap
.empty()) {
36
throw
std::invalid_argument(
"Missing input hit-particles map collection"
);
37
}
38
if
(
m_cfg
.
outputParticles
.empty()) {
39
throw
std::invalid_argument(
"Missing output truth particles collection"
);
40
}
41
42
m_inputParticles
.
initialize
(
m_cfg
.
inputParticles
);
43
m_inputMeasurementParticlesMap
.
initialize
(
m_cfg
.
inputMeasurementParticlesMap
);
44
m_outputParticles
.
initialize
(
m_cfg
.
outputParticles
);
45
}
46
47
ProcessCode
TruthSeedSelector::execute
(
const
AlgorithmContext
& ctx)
const
{
48
// prepare input collections
49
const
auto
&
inputParticles
=
m_inputParticles
(ctx);
50
const
auto
& hitParticlesMap =
m_inputMeasurementParticlesMap
(ctx);
51
// compute particle_id -> {hit_id...} map from the
52
// hit_id -> {particle_id...} map on the fly.
53
const
auto
& particleHitsMap =
invertIndexMultimap
(hitParticlesMap);
54
55
// prepare output collection
56
SimParticleContainer
selectedParticles;
57
selectedParticles.reserve(
inputParticles
.size());
58
59
auto
within = [](
double
x
,
double
min
,
double
max) {
60
return
(min <= x) and (x < max);
61
};
62
auto
isValidparticle = [&](
const
auto
&
p
) {
63
const
auto
eta
=
Acts::VectorHelpers::eta
(
p
.direction());
64
const
auto
phi
=
Acts::VectorHelpers::phi
(
p
.direction());
65
const
auto
rho
=
Acts::VectorHelpers::perp
(
p
.position());
66
// find the corresponding hits for this particle
67
const
auto
& hits =
makeRange
(particleHitsMap.equal_range(
p
.particleId()));
68
// number of recorded hits
69
size_t
nHits = hits.size();
70
return
within(rho, 0.,
m_cfg
.
rhoMax
) and
71
within(
p
.position().z(),
m_cfg
.
zMin
,
m_cfg
.
zMax
) and
72
within(std::abs(
eta
),
m_cfg
.
absEtaMin
,
m_cfg
.
absEtaMax
) and
73
within(
eta
,
m_cfg
.
etaMin
,
m_cfg
.
etaMax
) and
74
within(phi,
m_cfg
.
phiMin
,
m_cfg
.
phiMax
) and
75
within(
p
.transverseMomentum(),
m_cfg
.
ptMin
,
m_cfg
.
ptMax
) and
76
within(nHits,
m_cfg
.
nHitsMin
,
m_cfg
.
nHitsMax
) and
77
(
m_cfg
.
keepNeutral
or (
p
.charge() != 0));
78
};
79
80
// create prototracks for all input particles
81
for
(
const
auto
&
particle
:
inputParticles
) {
82
if
(isValidparticle(
particle
)) {
83
selectedParticles.insert(
particle
);
84
}
85
}
86
87
m_outputParticles
(ctx,
std::move
(selectedParticles));
88
return
ProcessCode::SUCCESS
;
89
}
acts
blob
sPHENIX
Examples
Algorithms
TruthTracking
ActsExamples
TruthTracking
TruthSeedSelector.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:37
using
1.8.2 with
sPHENIX GitHub integration