Project
Loading...
Searching...
No Matches
RawWriterSpec.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#include <fairlogger/Logger.h>
12
17
26
27using namespace o2::phos::reco_workflow;
28
30{
31
32 auto rawdir = ctx.options().get<std::string>("rawpath");
33
34 LOG(info) << "[PHOSRawWriter - init] Initialize raw writer ";
35 if (!mRawWriter) {
36 mRawWriter = new o2::phos::RawWriter();
37 mRawWriter->setOutputLocation(rawdir.data());
38 mRawWriter->init();
39 }
40}
41
43{
44 LOG(debug) << "[PHOSRawWriter - run] called";
45
46 auto digits = ctx.inputs().get<std::vector<o2::phos::Digit>>("digits");
47 auto digitsTR = ctx.inputs().get<std::vector<o2::phos::TriggerRecord>>("digitTriggerRecords");
48 LOG(info) << "[PHOSRawWriter - run] Received " << digits.size() << " digits and " << digitsTR.size() << " TriggerRecords";
49
50 mRawWriter->digitsToRaw(digits, digitsTR);
51 LOG(info) << "[PHOSRawWriter - run] Finished ";
52
53 //flash and close output files
54 mRawWriter->getWriter().close();
56}
57
59{
60 std::vector<o2::framework::InputSpec> inputs;
61 std::vector<o2::framework::OutputSpec> outputs;
62 inputs.emplace_back("digits", o2::header::gDataOriginPHS, "DIGITS", 0, o2::framework::Lifetime::Timeframe);
63 inputs.emplace_back("digitTriggerRecords", o2::header::gDataOriginPHS, "DIGITTRIGREC", 0, o2::framework::Lifetime::Timeframe);
64 return o2::framework::DataProcessorSpec{"PHOSRawWriterSpec",
65 inputs,
66 outputs,
67 o2::framework::adaptFromTask<o2::phos::reco_workflow::RawWriterSpec>(),
69 {"rawpath", o2::framework::VariantType::String, "./", {"path to write raw"}},
70 }};
71}
std::ostringstream debug
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
o2::raw::RawFileWriter & getWriter() const
Definition RawWriter.h:65
void setOutputLocation(const char *outputdir)
Definition RawWriter.h:67
void digitsToRaw(gsl::span< o2::phos::Digit > digits, gsl::span< o2::phos::TriggerRecord > triggers)
Definition RawWriter.cxx:67
void run(framework::ProcessingContext &ctx) final
Run conversion of digits to cells.
void init(framework::InitContext &ctx) final
Initializing the RawWriterSpec.
constexpr o2::header::DataOrigin gDataOriginPHS
Definition DataHeader.h:574
@ Me
Only quit this data processor.
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getRawWriterSpec()
Creating DataProcessorSpec for the PHOS Cell Converter Spec.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits