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 "
SimulationDataFormat/MCTrack.h
"
17
#include "
Steer/MCKinematicsReader.h
"
18
19
#include "
Framework/runDataProcessing.h
"
20
21
using namespace
o2::framework
;
22
using namespace
o2::steer
;
23
24
struct
O2simKinePublisher
{
25
Configurable<std::string>
kineFileName
{
"kineFileName"
,
"o2sim"
,
"name of the _Kine.root file (without '_Kine.root')"
};
26
Configurable<int>
aggregate
{
"aggregate-timeframe"
, 300,
"Number of events to put in a timeframe"
};
27
28
int
nEvents
= 0;
29
int
eventCounter
= 0;
30
int
tfCounter
= 0;
31
std::shared_ptr<MCKinematicsReader>
mcKinReader
= std::make_shared<MCKinematicsReader>();
32
33
void
init
(
o2::framework::InitContext
&
/*ic*/
)
34
{
35
if
(
mcKinReader
->initFromKinematics((std::string)
kineFileName
)) {
36
nEvents
=
mcKinReader
->getNEvents(0);
37
}
else
{
38
LOGP(fatal,
"Cannot open kine file {}"
, (std::string)
kineFileName
);
39
}
40
}
41
42
void
run
(
o2::framework::ProcessingContext
& pc)
43
{
44
for
(
auto
i
= 0;
i
< std::min((
int
)
aggregate
,
nEvents
-
eventCounter
); ++
i
) {
45
auto
mcevent =
mcKinReader
->getMCEventHeader(0,
eventCounter
);
46
auto
mctracks =
mcKinReader
->getTracks(0,
eventCounter
);
47
pc.
outputs
().
snapshot
(
Output
{
"MC"
,
"MCHEADER"
, 0}, mcevent);
48
pc.
outputs
().
snapshot
(
Output
{
"MC"
,
"MCTRACKS"
, 0}, mctracks);
49
++
eventCounter
;
50
}
51
// report number of TFs injected for the rate limiter to work
52
++
tfCounter
;
53
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));
54
if
(
eventCounter
>=
nEvents
) {
55
pc.
services
().
get
<
ControlService
>().endOfStream();
56
pc.
services
().
get
<
ControlService
>().readyToQuit(QuitRequest::Me);
57
}
58
}
59
};
60
61
WorkflowSpec
defineDataProcessing
(
ConfigContext
const
& cfgc)
62
{
63
auto
spec = adaptAnalysisTask<O2simKinePublisher>(cfgc);
64
spec.outputs.emplace_back(
"MC"
,
"MCHEADER"
, 0, Lifetime::Timeframe);
65
spec.outputs.emplace_back(
"MC"
,
"MCTRACKS"
, 0, Lifetime::Timeframe);
66
spec.requiredServices.push_back(
o2::framework::ArrowSupport::arrowBackendSpec
());
67
spec.algorithm =
CommonDataProcessors::wrapWithRateLimiting
(spec.algorithm);
68
return
{spec};
69
}
AnalysisTask.h
CommonDataProcessors.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:443
MCKinematicsReader.h
MCTrack.h
Definition of the MCTrack class.
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:325
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
TFIDInfo.h:20
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:61
runDataProcessing.h
O2simKinePublisher
Definition
o2sim_kine_publisher.cxx:24
O2simKinePublisher::eventCounter
int eventCounter
Definition
o2sim_kine_publisher.cxx:29
O2simKinePublisher::init
void init(o2::framework::InitContext &)
Definition
o2sim_kine_publisher.cxx:33
O2simKinePublisher::aggregate
Configurable< int > aggregate
Definition
o2sim_kine_publisher.cxx:26
O2simKinePublisher::nEvents
int nEvents
Definition
o2sim_kine_publisher.cxx:28
O2simKinePublisher::kineFileName
Configurable< std::string > kineFileName
Definition
o2sim_kine_publisher.cxx:25
O2simKinePublisher::tfCounter
int tfCounter
Definition
o2sim_kine_publisher.cxx:30
O2simKinePublisher::run
void run(o2::framework::ProcessingContext &pc)
Definition
o2sim_kine_publisher.cxx:42
O2simKinePublisher::mcKinReader
std::shared_ptr< MCKinematicsReader > mcKinReader
Definition
o2sim_kine_publisher.cxx:31
o2::framework::ArrowSupport::arrowBackendSpec
static ServiceSpec arrowBackendSpec()
Definition
ArrowSupport.cxx:105
o2::framework::CommonDataProcessors::wrapWithRateLimiting
static AlgorithmSpec wrapWithRateLimiting(AlgorithmSpec spec)
Definition
CommonDataProcessors.cxx:203
o2::framework::Configurable
Definition
Configurable.h:72
o2::framework::Output
Definition
Output.h:27
run
o2sim_kine_publisher.cxx
Generated on Tue Feb 25 2025 23:16:46 for Project by
1.9.8