Project
Loading...
Searching...
No Matches
o2sim_kine_publisher.cxx
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
12
#include "../Framework/Core/src/ArrowSupport.h"
13
#include "
Framework/AnalysisTask.h
"
14
#include "Monitoring/Monitoring.h"
15
#include "
Framework/CommonDataProcessors.h
"
16
#include "
Steer/MCKinematicsReader.h
"
17
18
#include "
Framework/runDataProcessing.h
"
19
20
using namespace
o2::framework
;
21
using namespace
o2::steer
;
22
23
struct
O2simKinePublisher
{
24
Configurable<std::string>
kineFileName
{
"kineFileName"
,
"o2sim"
,
"name of the _Kine.root file (without '_Kine.root')"
};
25
Configurable<int>
aggregate
{
"aggregate-timeframe"
, 300,
"Number of events to put in a timeframe"
};
26
27
int
nEvents
= 0;
28
int
eventCounter
= 0;
29
int
tfCounter
= 0;
30
std::shared_ptr<MCKinematicsReader>
mcKinReader
= std::make_shared<MCKinematicsReader>();
31
32
void
init
(
o2::framework::InitContext
&
/*ic*/
)
33
{
34
if
(
mcKinReader
->initFromKinematics((std::string)
kineFileName
)) {
35
nEvents
=
mcKinReader
->getNEvents(0);
36
}
else
{
37
LOGP(fatal,
"Cannot open kine file {}"
, (std::string)
kineFileName
);
38
}
39
}
40
41
void
run
(
o2::framework::ProcessingContext
& pc)
42
{
43
for
(
auto
i
= 0;
i
< std::min((
int
)
aggregate
,
nEvents
-
eventCounter
); ++
i
) {
44
auto
mcevent =
mcKinReader
->getMCEventHeader(0,
eventCounter
);
45
auto
mctracks =
mcKinReader
->getTracks(0,
eventCounter
);
46
pc.
outputs
().
snapshot
(
Output
{
"MC"
,
"MCHEADER"
, 0}, mcevent);
47
pc.
outputs
().
snapshot
(
Output
{
"MC"
,
"MCTRACKS"
, 0}, mctracks);
48
++
eventCounter
;
49
}
50
// report number of TFs injected for the rate limiter to work
51
++
tfCounter
;
52
pc.
services
().
get
<o2::monitoring::Monitoring>().send(o2::monitoring::Metric{(uint64_t)
tfCounter
,
"df-sent"
}.addTag(o2::monitoring::tags::Key::Subsystem, o2::monitoring::tags::Value::DPL));
53
if
(
eventCounter
>=
nEvents
) {
54
pc.
services
().
get
<
ControlService
>().endOfStream();
55
pc.
services
().
get
<
ControlService
>().readyToQuit(QuitRequest::Me);
56
}
57
}
58
};
59
60
WorkflowSpec
defineDataProcessing
(
ConfigContext
const
& cfgc)
61
{
62
auto
spec = adaptAnalysisTask<O2simKinePublisher>(cfgc);
63
spec.outputs.emplace_back(
"MC"
,
"MCHEADER"
, 0, Lifetime::Timeframe);
64
spec.outputs.emplace_back(
"MC"
,
"MCTRACKS"
, 0, Lifetime::Timeframe);
65
spec.requiredServices.push_back(
o2::framework::ArrowSupport::arrowBackendSpec
());
66
spec.algorithm =
CommonDataProcessors::wrapWithTimesliceConsumption
(spec.algorithm);
67
return
{spec};
68
}
AnalysisTask.h
CommonDataProcessors.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:436
MCKinematicsReader.h
o2::framework::ConfigContext
Definition
ConfigContext.h:24
o2::framework::ControlService
Definition
ControlService.h:40
o2::framework::DataAllocator::snapshot
void snapshot(const Output &spec, T const &object)
Definition
DataAllocator.h:317
o2::framework::InitContext
Definition
InitContext.h:25
o2::framework::ProcessingContext
Definition
ProcessingContext.h:27
o2::framework::ProcessingContext::outputs
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
Definition
ProcessingContext.h:41
o2::framework::ProcessingContext::services
ServiceRegistryRef services()
The services registry associated with this processing context.
Definition
ProcessingContext.h:39
o2::framework::ServiceRegistryRef::get
T & get() const
Definition
ServiceRegistryRef.h:85
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
BunchFilling.h:112
o2::framework::WorkflowSpec
std::vector< DataProcessorSpec > WorkflowSpec
Definition
HBFUtilsInitializer.h:39
o2::steer
Definition
DigitizationContext.h:31
defineDataProcessing
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
Definition
o2sim_kine_publisher.cxx:60
runDataProcessing.h
O2simKinePublisher
Definition
o2sim_kine_publisher.cxx:23
O2simKinePublisher::eventCounter
int eventCounter
Definition
o2sim_kine_publisher.cxx:28
O2simKinePublisher::init
void init(o2::framework::InitContext &)
Definition
o2sim_kine_publisher.cxx:32
O2simKinePublisher::aggregate
Configurable< int > aggregate
Definition
o2sim_kine_publisher.cxx:25
O2simKinePublisher::nEvents
int nEvents
Definition
o2sim_kine_publisher.cxx:27
O2simKinePublisher::kineFileName
Configurable< std::string > kineFileName
Definition
o2sim_kine_publisher.cxx:24
O2simKinePublisher::tfCounter
int tfCounter
Definition
o2sim_kine_publisher.cxx:29
O2simKinePublisher::run
void run(o2::framework::ProcessingContext &pc)
Definition
o2sim_kine_publisher.cxx:41
O2simKinePublisher::mcKinReader
std::shared_ptr< MCKinematicsReader > mcKinReader
Definition
o2sim_kine_publisher.cxx:30
o2::framework::ArrowSupport::arrowBackendSpec
static ServiceSpec arrowBackendSpec()
Definition
ArrowSupport.cxx:254
o2::framework::CommonDataProcessors::wrapWithTimesliceConsumption
static AlgorithmSpec wrapWithTimesliceConsumption(AlgorithmSpec spec)
Definition
CommonDataProcessors.cxx:287
o2::framework::Configurable
Definition
Configurable.h:72
o2::framework::Output
Definition
Output.h:27
run
o2sim_kine_publisher.cxx
Generated on Sat Feb 21 2026 17:59:08 for Project by
1.9.8