Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
Analysis Software
Deprecated List
Modules
Namespaces
Classes
Files
File List
acts
blob
sPHENIX
Alignment
CI
cmake
Core
docs
Examples
Algorithms
Detectors
Framework
Io
Csv
include
src
CsvBFieldWriter.cpp
CsvMeasurementReader.cpp
CsvMeasurementWriter.cpp
CsvMultiTrajectoryWriter.cpp
CsvOutputData.hpp
CsvParticleReader.cpp
CsvParticleWriter.cpp
CsvPlanarClusterReader.cpp
CsvPlanarClusterWriter.cpp
CsvProtoTrackWriter.cpp
CsvSimHitReader.cpp
CsvSimHitWriter.cpp
CsvSpacePointReader.cpp
CsvSpacePointWriter.cpp
CsvTrackingGeometryWriter.cpp
CsvTrackParameterReader.cpp
CsvTrackParameterWriter.cpp
EDM4hep
HepMC3
Json
NuclearInteractions
Obj
Performance
Root
Svg
Python
Run
Scripts
Fatras
Plugins
Tests
acts-fatras
analysis
analysis_tpc_prototype
coresoftware
Doxygen_Assist
g4exampledetector
GenFit
JETSCAPE
KFParticle
macros
online_distribution
OnlMon
prototype
pythia6
rcdaq
RDBC
tutorials
doxygen_mainpage.h
File Members
Examples
External Links
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
CsvSimHitReader.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file CsvSimHitReader.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2020 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/Io/Csv/CsvSimHitReader.hpp
"
10
11
#include "
Acts/Definitions/Units.hpp
"
12
#include "
Acts/Geometry/GeometryIdentifier.hpp
"
13
#include "
ActsExamples/EventData/SimHit.hpp
"
14
#include "
ActsExamples/Framework/AlgorithmContext.hpp
"
15
#include "
ActsExamples/Utilities/Paths.hpp
"
16
#include "
ActsFatras/EventData/Barcode.hpp
"
17
#include "
ActsFatras/EventData/Hit.hpp
"
18
19
#include <array>
20
#include <stdexcept>
21
22
#include <dfe/dfe_io_dsv.hpp>
23
24
#include "
CsvOutputData.hpp
"
25
26
ActsExamples::CsvSimHitReader::CsvSimHitReader
(
27
const
ActsExamples::CsvSimHitReader::Config
&
config
,
28
Acts::Logging::Level
level
)
29
:
m_cfg
(config),
30
// TODO check that all files (hits,cells,truth) exists
31
m_eventsRange(
32
determineEventFilesRange
(
m_cfg
.
inputDir
,
m_cfg
.inputStem +
".csv"
)),
33
m_logger
(Acts::
getDefaultLogger
(
"CsvSimHitReader"
, level)) {
34
if
(
m_cfg
.
inputStem
.empty()) {
35
throw
std::invalid_argument(
"Missing input filename stem"
);
36
}
37
if
(
m_cfg
.
outputSimHits
.empty()) {
38
throw
std::invalid_argument(
"Missing simulated hits output collection"
);
39
}
40
41
m_outputSimHits
.
initialize
(
m_cfg
.
outputSimHits
);
42
}
43
44
std::string
ActsExamples::CsvSimHitReader::CsvSimHitReader::name
()
const
{
45
return
"CsvSimHitReader"
;
46
}
47
48
std::pair<size_t, size_t>
ActsExamples::CsvSimHitReader::availableEvents
()
49
const
{
50
return
m_eventsRange;
51
}
52
53
ActsExamples::ProcessCode
ActsExamples::CsvSimHitReader::read
(
54
const
ActsExamples::AlgorithmContext
& ctx) {
55
auto
path
=
perEventFilepath
(
m_cfg
.inputDir,
m_cfg
.inputStem +
".csv"
,
56
ctx.
eventNumber
);
57
58
dfe::NamedTupleCsvReader<SimHitData>
reader
(
path
);
59
60
SimHitContainer::sequence_type unordered;
61
SimHitData
data
;
62
63
while
(reader.read(data)) {
64
const
auto
geometryId =
Acts::GeometryIdentifier
(data.
geometry_id
);
65
// TODO validate geo id consistency
66
const
auto
particleId =
ActsFatras::Barcode
(data.
particle_id
);
67
68
ActsFatras::Hit::Vector4
pos4
{
69
data.
tx
*
Acts::UnitConstants::mm
,
70
data.
ty
*
Acts::UnitConstants::mm
,
71
data.
tz
*
Acts::UnitConstants::mm
,
72
data.
tt
*
Acts::UnitConstants::ns
,
73
};
74
ActsFatras::Hit::Vector4
mom4{
75
data.
tpx
*
Acts::UnitConstants::GeV
,
76
data.
tpy
*
Acts::UnitConstants::GeV
,
77
data.
tpz
*
Acts::UnitConstants::GeV
,
78
data.
te
*
Acts::UnitConstants::GeV
,
79
};
80
ActsFatras::Hit::Vector4
delta4{
81
data.
deltapx
*
Acts::UnitConstants::GeV
,
82
data.
deltapy
*
Acts::UnitConstants::GeV
,
83
data.
deltapz
*
Acts::UnitConstants::GeV
,
84
data.
deltae
*
Acts::UnitConstants::GeV
,
85
};
86
87
ActsFatras::Hit
hit(geometryId, particleId,
pos4
, mom4, mom4 + delta4,
88
data.
index
);
89
unordered.push_back(
std::move
(hit));
90
}
91
92
// write the ordered data to the EventStore (according to geometry_id).
93
SimHitContainer
simHits;
94
simHits.insert(unordered.begin(), unordered.end());
95
m_outputSimHits(ctx,
std::move
(simHits));
96
97
return
ActsExamples::ProcessCode::SUCCESS
;
98
}
acts
blob
sPHENIX
Examples
Io
Csv
src
CsvSimHitReader.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration