Project
Loading...
Searching...
No Matches
StatusMapReaderSpec.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
12#include "StatusMapReaderSpec.h"
13
14#include <memory>
15#include <string>
16
21#include "Framework/Lifetime.h"
24#include "Framework/Task.h"
25
28#include "MCHStatus/StatusMap.h"
29
30using namespace o2::framework;
31
32namespace o2::mch
33{
34
36 std::unique_ptr<RootTreeReader> mTreeReader;
37
38 void init(InitContext& ic)
39 {
40 auto fileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")), ic.options().get<std::string>("infile"));
41 mTreeReader = std::make_unique<RootTreeReader>(
42 "o2sim",
43 fileName.c_str(),
44 -1,
46 RootTreeReader::BranchDefinition<StatusMap>{Output{"MCH", "STATUSMAP", 0}, "statusmaps"});
47 }
48
50 {
51 if (mTreeReader->next()) {
52 (*mTreeReader)(pc);
53 } else {
54 pc.services().get<ControlService>().endOfStream();
55 }
56 }
57};
58
60{
61 return DataProcessorSpec{
63 Inputs{},
64 Outputs{OutputSpec{{"statusmaps"}, "MCH", "STATUSMAP", 0, Lifetime::Timeframe}},
65 adaptFromTask<StatusMapReader>(),
66 Options{{"infile", VariantType::String, "mchstatusmaps.root", {"name of the input status map file"}},
67 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
68}
69
70} // namespace o2::mch
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
DataProcessorSpec getStatusMapReaderSpec(const char *specName)
void run(ProcessingContext &pc)
std::unique_ptr< RootTreeReader > mTreeReader
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)