Skip to content

Commit c1f297a

Browse files
committed
Helper class to inject HBFUtil params to root-file driven reco workflows
1 parent 49e1251 commit c1f297a

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

Detectors/Raw/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ o2_add_library(DetectorsRaw
1414
src/SimpleRawReader.cxx
1515
src/SimpleSTF.cxx
1616
src/HBFUtils.cxx
17-
src/RDHUtils.cxx
17+
src/RDHUtils.cxx
18+
src/HBFUtilsInitializer.cxx
1819
PUBLIC_LINK_LIBRARIES FairRoot::Base
1920
O2::Headers
2021
O2::CommonDataFormat
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
// @brief Aux.class initialize HBFUtils
12+
// @author ruben.shahoyan@cern.ch
13+
14+
#ifndef _O2_HBFUTILS_INITIALIZER_
15+
#define _O2_HBFUTILS_INITIALIZER_
16+
17+
#include <vector>
18+
19+
namespace o2
20+
{
21+
22+
namespace framework
23+
{
24+
class ConfigContext;
25+
class DataProcessorSpec;
26+
class ConfigParamSpec;
27+
using WorkflowSpec = std::vector<DataProcessorSpec>;
28+
} // namespace framework
29+
30+
namespace raw
31+
{
32+
33+
struct HBFUtilsInitializer {
34+
static constexpr char HBFConfOpt[] = "hbfutils-config";
35+
36+
HBFUtilsInitializer(const o2::framework::ConfigContext& configcontext, o2::framework::WorkflowSpec& wf);
37+
38+
static void addConfigOption(std::vector<o2::framework::ConfigParamSpec>& opts);
39+
};
40+
41+
} // namespace raw
42+
} // namespace o2
43+
44+
#endif
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
// @brief Aux.class initialize HBFUtils
12+
// @author ruben.shahoyan@cern.ch
13+
14+
#include "DetectorsRaw/HBFUtilsInitializer.h"
15+
#include "DetectorsRaw/HBFUtils.h"
16+
#include "CommonUtils/ConfigurableParam.h"
17+
#include "DetectorsCommonDataFormats/NameConf.h"
18+
#include "Framework/ConfigContext.h"
19+
#include "Framework/WorkflowSpec.h"
20+
#include "Framework/ConfigParamSpec.h"
21+
#include "Framework/ConfigParamsHelper.h"
22+
#include "Framework/Logger.h"
23+
24+
using namespace o2::raw;
25+
namespace o2f = o2::framework;
26+
27+
/// If the workflow has devices w/o inputs, we assume that these are data readers in root-file based workflow.
28+
/// In this case this class will configure these devices DataHeader.firstTForbit generator to provide orbit according to HBFUtil setings
29+
/// In case the configcontext has relevant option, the HBFUtils will be beforehand updated from the file indicated by this option.
30+
/// (only those fields of HBFUtils which were not modified before, e.g. by ConfigurableParam::updateFromString)
31+
32+
HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext, o2f::WorkflowSpec& wf)
33+
{
34+
auto updateHBFUtils = [&configcontext]() {
35+
static bool done = false;
36+
if (!done) {
37+
bool helpasked = configcontext.helpOnCommandLine(); // if help is asked, don't take for granted that the ini file is there, don't produce an error if it is not!
38+
std::string conf = configcontext.options().isSet(HBFConfOpt) ? configcontext.options().get<std::string>(HBFConfOpt) : "";
39+
if (!conf.empty() && conf != "none" && !(helpasked && !o2::base::NameConf::pathExists(conf))) {
40+
o2::conf::ConfigurableParam::updateFromFile(conf, "HBFUtils", true); // update only those values which were not touched yet (provenance == kCODE)
41+
}
42+
done = true;
43+
}
44+
};
45+
46+
const auto& hbfu = o2::raw::HBFUtils::Instance();
47+
for (auto& spec : wf) {
48+
if (spec.inputs.empty()) {
49+
updateHBFUtils();
50+
o2f::ConfigParamsHelper::addOptionIfMissing(spec.options, o2f::ConfigParamSpec{"orbit-offset-enumeration", o2f::VariantType::Int64, int64_t(hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit), {"1st injected orbit"}});
51+
o2f::ConfigParamsHelper::addOptionIfMissing(spec.options, o2f::ConfigParamSpec{"orbit-multiplier-enumeration", o2f::VariantType::Int64, int64_t(hbfu.nHBFPerTF), {"orbits/TF"}});
52+
}
53+
}
54+
}
55+
56+
void HBFUtilsInitializer::addConfigOption(std::vector<o2f::ConfigParamSpec>& opts)
57+
{
58+
o2f::ConfigParamsHelper::addOptionIfMissing(opts, o2f::ConfigParamSpec{HBFConfOpt, o2f::VariantType::String, std::string(o2::base::NameConf::DIGITIZATIONCONFIGFILE), {"configKeyValues file for HBFUtils (or none)"}});
59+
}

0 commit comments

Comments
 (0)