|
| 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