Project
Loading...
Searching...
No Matches
MCTruthSourceSpec.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/ControlService.h
"
13
#include "
Framework/ConfigParamRegistry.h
"
14
#include "
Framework/DataProcessorSpec.h
"
15
#include "
Framework/DataRefUtils.h
"
16
#include "
Framework/Lifetime.h
"
17
#include <
SimulationDataFormat/ConstMCTruthContainer.h
>
18
#include <
SimulationDataFormat/MCCompLabel.h
>
19
#include "
Framework/Task.h
"
20
#include "
Framework/Logger.h
"
21
22
using namespace
o2::framework
;
23
24
namespace
o2
25
{
26
27
class
MCTruthSourceTask
:
public
o2::framework::Task
28
{
29
public
:
30
MCTruthSourceTask
(
bool
newmctruth) : mNew{newmctruth} {}
31
32
void
init
(
framework::InitContext
& ic)
override
33
{
34
LOG
(info) <<
"Initializing MCTruth source"
;
35
mSize = ic.
options
().
get
<
int
>(
"size"
);
36
}
37
38
void
run
(
framework::ProcessingContext
& pc)
override
39
{
40
if
(mFinished) {
41
return
;
42
}
43
LOG
(info) <<
"Creating MCTruth container"
;
44
45
using
TruthElement =
o2::MCCompLabel
;
46
using
Container =
dataformats::MCTruthContainer<TruthElement>
;
47
Container container;
48
// create a very large container and stream it to TTree
49
for
(
int
i
= 0;
i
< mSize; ++
i
) {
50
container.
addElement
(
i
, TruthElement(
i
,
i
,
i
));
51
container.addElement(
i
, TruthElement(
i
+ 1,
i
,
i
));
52
}
53
54
if
(mNew) {
55
LOG
(info) <<
"New serialization"
;
56
// we need to flatten it and write to managed shared memory container
57
auto
& sharedlabels = pc.
outputs
().
make
<
o2::dataformats::ConstMCTruthContainer<o2::MCCompLabel>
>(
Output
{
"TST"
,
"LABELS"
, 0});
58
container.flatten_to(sharedlabels);
59
sleep(1);
60
}
else
{
61
LOG
(info) <<
"Old serialization"
;
62
pc.
outputs
().
snapshot
({
"TST"
,
"LABELS"
, 0}, container);
63
sleep(1);
64
}
65
66
// we should be only called once; tell DPL that this process is ready to exit
67
pc.
services
().
get
<
ControlService
>().readyToQuit(QuitRequest::Me);
68
mFinished =
true
;
69
}
70
71
private
:
72
bool
mFinished =
false
;
73
int
mSize = 0;
74
bool
mNew =
false
;
75
};
76
77
o2::framework::DataProcessorSpec
getMCTruthSourceSpec
(
bool
newmctruth)
78
{
79
// create the full data processor spec using
80
// a name identifier
81
// input description
82
// algorithmic description (here a lambda getting called once to setup the actual processing function)
83
// options that can be used for this processor (here: input file names where to take the hits)
84
std::vector<OutputSpec> outputs;
85
outputs.emplace_back(
"TST"
,
"LABELS"
, 0, Lifetime::Timeframe);
86
87
return
DataProcessorSpec
{
88
"MCTruthSource"
,
89
Inputs
{},
90
outputs,
91
AlgorithmSpec
{adaptFromTask<MCTruthSourceTask>(newmctruth)},
92
Options
{
93
{
"size"
, VariantType::Int, 100000, {
"Sample size"
}}}};
94
}
95
96
}
// end namespace o2
ConfigParamRegistry.h
ConstMCTruthContainer.h
A const (ready only) version of MCTruthContainer.
ControlService.h
DataProcessorSpec.h
DataRefUtils.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:443
Lifetime.h
Logger.h
MCCompLabel.h
Task.h
o2::MCCompLabel
Definition
MCCompLabel.h:24
o2::MCTruthSourceTask
Definition
MCTruthSourceSpec.cxx:28
o2::MCTruthSourceTask::MCTruthSourceTask
MCTruthSourceTask(bool newmctruth)
Definition
MCTruthSourceSpec.cxx:30
o2::MCTruthSourceTask::init
void init(framework::InitContext &ic) override
Definition
MCTruthSourceSpec.cxx:32
o2::MCTruthSourceTask::run
void run(framework::ProcessingContext &pc) override
Definition
MCTruthSourceSpec.cxx:38
o2::dataformats::ConstMCTruthContainer
A read-only version of MCTruthContainer allowing for storage optimisation.
Definition
ConstMCTruthContainer.h:40
o2::dataformats::MCTruthContainer
A container to hold and manage MC truth information/labels.
Definition
MCTruthContainer.h:83
o2::dataformats::MCTruthContainer::addElement
void addElement(uint32_t dataindex, TruthElement const &element, bool noElement=false)
Definition
MCTruthContainer.h:190
o2::framework::ConfigParamRegistry::get
T get(const char *key) const
Definition
ConfigParamRegistry.h:98
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::DataAllocator::make
decltype(auto) make(const Output &spec, Args... args)
Definition
DataAllocator.h:166
o2::framework::InitContext
Definition
InitContext.h:25
o2::framework::InitContext::options
ConfigParamRegistry const & options()
Definition
InitContext.h:33
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::Task
Definition
Task.h:32
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
TFIDInfo.h:20
o2::framework::Options
std::vector< ConfigParamSpec > Options
Definition
DataProcessorSpec.h:31
o2::framework::Inputs
std::vector< InputSpec > Inputs
Definition
DataProcessorSpec.h:29
o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition
BitstreamReader.h:24
o2::getMCTruthSourceSpec
o2::framework::DataProcessorSpec getMCTruthSourceSpec(bool newmctruth)
Definition
MCTruthSourceSpec.cxx:77
o2::framework::AlgorithmSpec
Definition
AlgorithmSpec.h:43
o2::framework::DataProcessorSpec
Definition
DataProcessorSpec.h:41
o2::framework::Output
Definition
Output.h:27
LOG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
Steer
DigitizerWorkflow
src
MCTruthSourceSpec.cxx
Generated on Tue Feb 25 2025 17:03:28 for Project by
1.9.8