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>
19
20using namespace o2::framework;
21
22namespace o2
23{
24namespace tpc
25{
26
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
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
46void 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
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
Definition of the Names Generator class.
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getTPCTriggerReaderSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"