Project
Loading...
Searching...
No Matches
TriggerReaderSpec.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
13
14
#include <vector>
15
#include "
Framework/ControlService.h
"
16
#include "
Framework/ConfigParamRegistry.h
"
17
#include "
TPCReaderWorkflow/TriggerReaderSpec.h
"
18
#include "
CommonUtils/NameConf.h
"
19
20
using namespace
o2::framework
;
21
22
namespace
o2
23
{
24
namespace
tpc
25
{
26
27
void
TriggerReader::init
(
InitContext
& ic)
28
{
29
mInputFileName =
o2::utils::Str::concat_string
(
o2::utils::Str::rectifyDirectory
(ic.
options
().
get
<std::string>(
"input-dir"
)),
30
ic.
options
().
get
<std::string>(
"infile"
));
31
connectTree(mInputFileName);
32
}
33
34
void
TriggerReader::run
(
ProcessingContext
& pc)
35
{
36
auto
ent = mTree->GetReadEntry() + 1;
37
mTree->GetEntry(ent);
38
39
pc.
outputs
().
snapshot
(
Output
{
"TPC"
,
"TRIGGERWORDS"
, 0}, *mTrig);
40
if
(mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
41
pc.
services
().
get
<
ControlService
>().endOfStream();
42
pc.
services
().
get
<
ControlService
>().readyToQuit(QuitRequest::Me);
43
}
44
}
45
46
void
TriggerReader::connectTree(
const
std::string&
filename
)
47
{
48
mTree.reset(
nullptr
);
// in case it was already loaded
49
mFile.reset(TFile::Open(
filename
.c_str()));
50
if
(!(mFile && !mFile->IsZombie())) {
51
throw
std::runtime_error(
"Error opening tree file"
);
52
}
53
mTree.reset((TTree*)mFile->Get(mTriggerTreeName.c_str()));
54
if
(!mTree) {
55
throw
std::runtime_error(
"Error opening tree"
);
56
}
57
58
mTree->SetBranchAddress(mTriggerBranchName.c_str(), &mTrig);
59
LOG
(info) <<
"Loaded tree from "
<<
filename
<<
" with "
<< mTree->GetEntries() <<
" entries"
;
60
}
61
62
DataProcessorSpec
getTPCTriggerReaderSpec
()
63
{
64
std::vector<OutputSpec> outputSpec;
65
outputSpec.emplace_back(
"TPC"
,
"TRIGGERWORDS"
, 0, Lifetime::Timeframe);
66
67
return
DataProcessorSpec
{
68
"tpc-trigger-reader"
,
69
Inputs
{},
70
outputSpec,
71
AlgorithmSpec
{adaptFromTask<TriggerReader>()},
72
Options
{
73
{
"infile"
, VariantType::String,
"tpctriggers.root"
, {
"Name of the input triggers file"
}},
74
{
"input-dir"
, VariantType::String,
"none"
, {
"Input directory"
}}}};
75
}
76
77
}
// namespace tpc
78
}
// namespace o2
ConfigParamRegistry.h
ControlService.h
NameConf.h
Definition of the Names Generator class.
TriggerReaderSpec.h
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::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::tpc::TriggerReader::init
void init(InitContext &ic) final
Definition
TriggerReaderSpec.cxx:27
o2::tpc::TriggerReader::run
void run(ProcessingContext &pc) final
Definition
TriggerReaderSpec.cxx:34
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::tpc::getTPCTriggerReaderSpec
framework::DataProcessorSpec getTPCTriggerReaderSpec()
Definition
TriggerReaderSpec.cxx:62
o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition
BitstreamReader.h:24
filename
std::string filename()
Definition
o2FairMQHeaderSizeTest.cxx:55
o2::framework::AlgorithmSpec
Definition
AlgorithmSpec.h:43
o2::framework::DataProcessorSpec
Definition
DataProcessorSpec.h:41
o2::framework::Output
Definition
Output.h:27
o2::utils::Str::rectifyDirectory
static std::string rectifyDirectory(const std::string_view p)
Definition
StringUtils.cxx:67
o2::utils::Str::concat_string
static std::string concat_string(Ts const &... ts)
Definition
StringUtils.h:142
LOG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
Detectors
TPC
workflow
readers
src
TriggerReaderSpec.cxx
Generated on Tue Feb 25 2025 17:03:11 for Project by
1.9.8