Project
Loading...
Searching...
No Matches
ErrorReaderSpec.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 <memory>
15#include <string>
16#include <vector>
17
22#include "Framework/Lifetime.h"
25#include "Framework/Task.h"
26
29#include "MCHBase/Error.h"
30
31using namespace o2::framework;
32
33namespace o2::mch
34{
35
37 std::unique_ptr<RootTreeReader> mTreeReader;
38
39 void init(InitContext& ic)
40 {
41 auto fileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")), ic.options().get<std::string>("infile"));
42 mTreeReader = std::make_unique<RootTreeReader>(
43 "o2sim",
44 fileName.c_str(),
45 -1,
47 RootTreeReader::BranchDefinition<std::vector<Error>>{Output{"MCH", "PROCERRORS", 0}, "errors"});
48 }
49
51 {
52 if (mTreeReader->next()) {
53 (*mTreeReader)(pc);
54 } else {
55 pc.services().get<ControlService>().endOfStream();
56 }
57 }
58};
59
61{
62 return DataProcessorSpec{
64 Inputs{},
65 Outputs{OutputSpec{{"errors"}, "MCH", "PROCERRORS", 0, Lifetime::Timeframe}},
66 adaptFromTask<ErrorReader>(),
67 Options{{"infile", VariantType::String, "mcherrors.root", {"name of the input error file"}},
68 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
69}
70
71} // namespace o2::mch
definition of the MCH processing errors
A generic reader for ROOT TTrees.
const char * specName
ConfigParamRegistry const & options()
Definition InitContext.h:33
ServiceRegistryRef services()
The services registry associated with this processing context.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
framework::DataProcessorSpec getErrorReaderSpec(const char *specName="mch-error-reader")
std::unique_ptr< RootTreeReader > mTreeReader
void init(InitContext &ic)
void run(ProcessingContext &pc)
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)