Project
Loading...
Searching...
No Matches
dcs-config-test-workflow.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#include "Framework/Task.h"
14#include "Framework/Logger.h"
17
18using namespace o2::framework;
20
21// we need to add workflow options before including Framework/runDataProcessing
22void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
23{
24 // option allowing to set parameters
25 std::vector<o2::framework::ConfigParamSpec> options{
26 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
27 {"detector", VariantType::String, "ITS", {"detector name"}}};
28
29 std::swap(workflowOptions, options);
30}
31// ------------------------------------------------------------------
32
33namespace o2
34{
35namespace dcs
36{
38{
39 public:
41 {
42 auto fileBuff = pc.inputs().get<gsl::span<char>>("confFile");
43 auto fileName = pc.inputs().get<std::string>("confFileName");
44 LOG(info) << "got input file " << fileName << " of size " << fileBuff.size();
45 }
46};
47} // namespace dcs
48} // namespace o2
49
51{
52 std::string procName = "dcs-config-consumer-";
53 procName += det.getName();
54 return DataProcessorSpec{
55 procName,
56 Inputs{{"confFile", ConcreteDataTypeMatcher{det.getDataOrigin(), "DCS_CONFIG_FILE"}, Lifetime::Sporadic},
57 {"confFileName", ConcreteDataTypeMatcher{det.getDataOrigin(), "DCS_CONFIG_NAME"}, Lifetime::Sporadic}},
58 Outputs{},
59 AlgorithmSpec{adaptFromTask<o2::dcs::DCSConfigConsumer>()},
60 Options{}};
61}
62
64
66{
67 WorkflowSpec specs;
68 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
69 auto detName = configcontext.options().get<std::string>("detector");
70 auto detID = DetID::nameToID(detName.c_str(), DetID::First);
71 if (detID < 0) {
72 throw std::runtime_error(fmt::format("{} is not a valid detector name", detName));
73 }
74 specs.emplace_back(getDCSConsumerSpec({detID}));
75
76 return specs;
77}
static void updateFromString(std::string const &)
void run(o2::framework::ProcessingContext &pc) final
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr const char * getName(ID id)
names of defined detectors
Definition DetID.h:145
static constexpr ID First
Definition DetID.h:94
static constexpr int nameToID(char const *name, int id=First)
Definition DetID.h:154
static constexpr o2h::DataOrigin getDataOrigin(ID id)
Definition DetID.h:147
ConfigParamRegistry & options() const
void customize(std::vector< o2::framework::ConfigParamSpec > &workflowOptions)
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
DataProcessorSpec getDCSConsumerSpec(DetID det)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"