Project
Loading...
Searching...
No Matches
CompressedAnalysisTask.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
16
18#include "Framework/Task.h"
25
26using namespace o2::framework;
27
28namespace o2
29{
30namespace tof
31{
32
34{
35
36 auto conetmode = ic.options().get<bool>("tof-compressed-analysis-conet-mode");
37 auto filename = ic.options().get<std::string>("tof-compressed-analysis-filename");
38 auto function = ic.options().get<std::string>("tof-compressed-analysis-function");
39
40 if (filename.empty()) {
41 LOG(error) << "No analysis filename defined";
42 mStatus = true;
43 return;
44 }
45
46 if (function.empty()) {
47 LOG(error) << "No analysis function defined";
48 mStatus = true;
49 return;
50 }
51
52 mAnalysis = GetFromMacro<CompressedAnalysis*>(filename, function, "o2::tof::CompressedAnalysis*", "compressed_analysis");
53 if (!mAnalysis) {
54 LOG(error) << "Could not retrieve analysis from file: " << filename;
55 mStatus = true;
56 return;
57 }
58
59 mAnalysis->setDecoderCONET(conetmode);
60 mAnalysis->initialize();
61
62 auto finishFunction = [this]() {
63 LOG(debug) << "CompressedBaseTask finish";
64 mAnalysis->finalize();
65 };
66 ic.services().get<CallbackService>().set<CallbackService::Id::Stop>(finishFunction);
67}
68
70{
71
73 if (mStatus) {
74 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
75 return;
76 }
77
79 for (auto iit = pc.inputs().begin(), iend = pc.inputs().end(); iit != iend; ++iit) {
80 if (!iit.isValid()) {
81 continue;
82 }
83
85 for (auto const& ref : iit) {
86
87 const auto* headerIn = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
88 auto payloadIn = ref.payload;
89 auto payloadInSize = DataRefUtils::getPayloadSize(ref);
90
91 mAnalysis->setDecoderBuffer(payloadIn);
92 mAnalysis->setDecoderBufferSize(payloadInSize);
93 mAnalysis->run();
94 }
95 }
96}
97
98} // namespace tof
99} // namespace o2
TOF compressed data analysis base class.
std::ostringstream debug
ServiceRegistryRef services()
Definition InitContext.h:34
ConfigParamRegistry const & options()
Definition InitContext.h:33
const_iterator begin() const
const_iterator end() const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void run(ProcessingContext &pc) final
virtual bool finalize()=0
virtual bool initialize()=0
void setDecoderBuffer(const char *val)
Definition DecoderBase.h:66
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
static o2::header::DataHeader::PayloadSizeType getPayloadSize(const DataRef &ref)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"