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
EDM4hepMeasurementReader.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EDM4hepMeasurementReader.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2022 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/EDM4hep/EDM4hepMeasurementReader.hpp
"
10
11
#include "
Acts/Definitions/Units.hpp
"
12
#include "
ActsExamples/EventData/Cluster.hpp
"
13
#include "
ActsExamples/EventData/Measurement.hpp
"
14
#include "
ActsExamples/Framework/WhiteBoard.hpp
"
15
#include "
ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp
"
16
17
#include <list>
18
#include <stdexcept>
19
20
#include <edm4hep/TrackerHit.h>
21
#include <edm4hep/TrackerHitCollection.h>
22
#include <edm4hep/TrackerHitPlane.h>
23
#include <edm4hep/TrackerHitPlaneCollection.h>
24
#include <podio/Frame.h>
25
26
namespace
ActsExamples {
27
28
EDM4hepMeasurementReader::EDM4hepMeasurementReader
(
29
const
EDM4hepMeasurementReader::Config
&
config
,
Acts::Logging::Level
level
)
30
:
m_cfg
(config),
31
m_logger
(Acts::
getDefaultLogger
(
"EDM4hepMeasurementReader"
, level)) {
32
if
(
m_cfg
.
outputMeasurements
.empty()) {
33
throw
std::invalid_argument(
"Missing measurement output collection"
);
34
}
35
36
m_reader
.openFile(
m_cfg
.
inputPath
);
37
38
m_eventsRange
= std::make_pair(0,
m_reader
.getEntries(
"events"
));
39
40
m_outputMeasurements
.
initialize
(
m_cfg
.
outputMeasurements
);
41
m_outputMeasurementSimHitsMap
.
initialize
(
m_cfg
.
outputMeasurementSimHitsMap
);
42
m_outputSourceLinks
.
initialize
(
m_cfg
.
outputSourceLinks
);
43
m_outputClusters
.
maybeInitialize
(
m_cfg
.
outputClusters
);
44
}
45
46
std::string
EDM4hepMeasurementReader::EDM4hepMeasurementReader::name
()
const
{
47
return
"EDM4hepMeasurementReader"
;
48
}
49
50
std::pair<size_t, size_t>
EDM4hepMeasurementReader::availableEvents
()
const
{
51
return
m_eventsRange
;
52
}
53
54
ProcessCode
EDM4hepMeasurementReader::read
(
const
AlgorithmContext
& ctx) {
55
MeasurementContainer
measurements;
56
ClusterContainer
clusters
;
57
// TODO what about those?
58
IndexMultimap<Index>
measurementSimHitsMap;
59
IndexSourceLinkContainer
sourceLinks;
60
61
podio::Frame frame =
m_reader
.readEntry(
"events"
, ctx.
eventNumber
);
62
63
const
auto
& trackerHitPlaneCollection =
64
frame.get<edm4hep::TrackerHitPlaneCollection>(
"ActsTrackerHitsPlane"
);
65
const
auto
& trackerHitRawCollection =
66
frame.get<edm4hep::TrackerHitCollection>(
"ActsTrackerHitsRaw"
);
67
68
for
(
const
auto
& trackerHitPlane : trackerHitPlaneCollection) {
69
Cluster
cluster;
70
auto
measurement =
EDM4hepUtil::readMeasurement
(
71
trackerHitPlane, &trackerHitRawCollection, &cluster,
72
[](std::uint64_t cellId) {
return
Acts::GeometryIdentifier
(cellId); });
73
74
measurements.push_back(
std::move
(measurement));
75
clusters.push_back(
std::move
(cluster));
76
}
77
78
// Write the data to the EventStore
79
m_outputMeasurements
(ctx,
std::move
(measurements));
80
m_outputMeasurementSimHitsMap
(ctx,
std::move
(measurementSimHitsMap));
81
m_outputSourceLinks
(ctx,
std::move
(sourceLinks));
82
if
(not
m_cfg
.
outputClusters
.empty()) {
83
m_outputClusters
(ctx,
std::move
(clusters));
84
}
85
86
return
ProcessCode::SUCCESS
;
87
}
88
89
}
// namespace ActsExamples
acts
blob
sPHENIX
Examples
Io
EDM4hep
src
EDM4hepMeasurementReader.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration