Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Common/Utils/include/CommonUtils/ConfigurableParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class ConfigurableParam
// writes a human readable INI file of all parameters
static void writeINI(std::string const& filename, std::string const& keyOnly = "");

// writes a human readable INI or JSON file depending on the extension
static void write(std::string const& filename, std::string const& keyOnly = "");

// can be used instead of using API on concrete child classes
template <typename T>
static T getValueAs(std::string key)
Expand Down
3 changes: 3 additions & 0 deletions Common/Utils/include/CommonUtils/NameConf.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
// Default CCDB server
static std::string getCCDBServer();

// create name to dump config file
static std::string getConfigOutputFileName(const std::string& procName, const std::string& confName = "", bool json = true);

protected:
// helper method to build filenames
static std::string buildFileName(const std::string_view prefix, const std::string_view delimiter, const std::string_view defPrefix, const std::string_view defName,
Expand Down
3 changes: 3 additions & 0 deletions Common/Utils/include/CommonUtils/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ struct Str {
// return vector of tokens from the string with provided delimiter. If requested, trim the spaces from tokens
static std::vector<std::string> tokenize(const std::string& src, char delim, bool trimToken = true, bool skipEmpty = true);

// return vector of tokens from the string with provided delimiters. If requested, trim the spaces from tokens
static std::vector<std::string> tokenize(const std::string& src, const std::string& delim, bool trimToken = true, bool skipEmpty = true);

// concatenate arbitrary number of strings
template <typename... Ts>
static std::string concat_string(Ts const&... ts)
Expand Down
23 changes: 21 additions & 2 deletions Common/Utils/src/ConfigurableParam.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ int EnumLegalValues::getIntValue(const std::string& value) const

// -----------------------------------------------------------------

void ConfigurableParam::write(std::string const& filename, std::string const& keyOnly)
{
if (o2::utils::Str::endsWith(filename, ".ini")) {
writeINI(filename, keyOnly);
} else if (o2::utils::Str::endsWith(filename, ".json")) {
writeJSON(filename, keyOnly);
} else {
throw std::invalid_argument(fmt::format("ConfigurabeParam output file name {} extension is neither .json nor .ini", filename));
}
}

// -----------------------------------------------------------------

void ConfigurableParam::writeINI(std::string const& filename, std::string const& keyOnly)
{
if (sOutputDir == "/dev/null") {
Expand All @@ -203,7 +216,10 @@ void ConfigurableParam::writeINI(std::string const& filename, std::string const&
if (!keyOnly.empty()) { // write ini for selected key only
try {
boost::property_tree::ptree kTree;
kTree.add_child(keyOnly, sPtree->get_child(keyOnly));
auto keys = o2::utils::Str::tokenize(keyOnly, " ,;", true, true);
for (const auto& k : keys) {
kTree.add_child(k, sPtree->get_child(k));
}
boost::property_tree::write_ini(outfilename, kTree);
} catch (const boost::property_tree::ptree_bad_path& err) {
LOG(fatal) << "non-existing key " << keyOnly << " provided to writeINI";
Expand Down Expand Up @@ -284,7 +300,10 @@ void ConfigurableParam::writeJSON(std::string const& filename, std::string const
if (!keyOnly.empty()) { // write ini for selected key only
try {
boost::property_tree::ptree kTree;
kTree.add_child(keyOnly, sPtree->get_child(keyOnly));
auto keys = o2::utils::Str::tokenize(keyOnly, " ,;", true, true);
for (const auto& k : keys) {
kTree.add_child(k, sPtree->get_child(k));
}
boost::property_tree::write_json(outfilename, kTree);
} catch (const boost::property_tree::ptree_bad_path& err) {
LOG(fatal) << "non-existing key " << keyOnly << " provided to writeJSON";
Expand Down
9 changes: 9 additions & 0 deletions Common/Utils/src/NameConf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ std::string NameConf::getCCDBServer()
{
return Instance().mCCDBServer;
}

std::string NameConf::getConfigOutputFileName(const std::string& procName, const std::string& confName, bool json)
{
std::string nm = procName;
if (!confName.empty()) {
nm += '_' + confName;
}
return fmt::format("ConfigParam_{}.{}", nm, json ? "json" : "ini");
}
29 changes: 29 additions & 0 deletions Common/Utils/src/StringUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ std::vector<std::string> Str::tokenize(const std::string& src, char delim, bool
return tokens;
}

std::vector<std::string> Str::tokenize(const std::string& src, const std::string& delim, bool trimToken, bool skipEmpty)
{
std::string inptStr{src};
char* input = inptStr.data();
auto mystrtok = [&]() -> char* {
input += std::strspn(input, delim.c_str());
if (*input == '\0') {
return nullptr;
}
char* const token = input;
input += std::strcspn(input, delim.c_str());
if (*input != '\0') {
*input++ = '\0';
}
return token;
};
std::vector<std::string> tokens;
while (*input != '\0') {
std::string token = mystrtok();
if (trimToken) {
trim(token);
}
if (!token.empty() || !skipEmpty) {
tokens.push_back(std::move(token));
}
}
return tokens;
}

// replace all occurencies of from by to, return count
int Str::replaceAll(std::string& s, const std::string& from, const std::string& to)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ void PrimaryVertexingSpec::run(ProcessingContext& pc)
mVertexer.getTimeReAttach().CpuTime(), mVertexer.getTotTrials(), mVertexer.getNTZClusters(), mVertexer.getMaxTrialsPerCluster(),
mVertexer.getLongestClusterTimeMS(), mVertexer.getLongestClusterMult(), mVertexer.getNIniFound(),
mVertexer.getNKilledBCValid(), mVertexer.getNKilledIntCand(), mVertexer.getNKilledDebris(), mVertexer.getNKilledQuality(), mVertexer.getNKilledITSOnly());

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, PVertexerParams::Instance().getName()), PVertexerParams::Instance().getName());
}
}
}

void PrimaryVertexingSpec::endOfStream(EndOfStreamContext& ec)
Expand Down
11 changes: 11 additions & 0 deletions Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ void SecondaryVertexingSpec::run(ProcessingContext& pc)
mVertexer.getNV0s(), calls[0] - fitCalls[0], mVertexer.getNCascades(), calls[1] - fitCalls[1], mVertexer.getN3Bodies(), calls[2] - fitCalls[2], mVertexer.getNStrangeTracks(),
mTimer.CpuTime() - timeCPU0, mTimer.RealTime() - timeReal0);
fitCalls = calls;

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, SVertexerParams::Instance().getName()), SVertexerParams::Instance().getName());
if (mEnableStrangenessTracking) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::strangeness_tracking::StrangenessTrackingParamConfig::Instance().getName()), o2::strangeness_tracking::StrangenessTrackingParamConfig::Instance().getName());
}
}
}
}

void SecondaryVertexingSpec::endOfStream(EndOfStreamContext& ec)
Expand Down
9 changes: 9 additions & 0 deletions Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "Framework/Task.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/DeviceSpec.h"
#include "TPCCalibration/VDriftHelper.h"
#include "TPCCalibration/CorrectionMapsLoader.h"

Expand Down Expand Up @@ -229,6 +230,14 @@ void TOFMatcherSpec::run(ProcessingContext& pc)
pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHABLES_17", 0}, mMatcher.getMatchedTracksPair(17));
}

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, MatchTOFParams::Instance().getName()), MatchTOFParams::Instance().getName());
}
}

mTimer.Stop();
}

Expand Down
8 changes: 8 additions & 0 deletions Detectors/GlobalTrackingWorkflow/src/TPCITSMatchingSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ void TPCITSMatchingDPL::run(ProcessingContext& pc)

mMatching.run(recoData, matchedTracks, ABTrackletRefs, ABTrackletClusterIDs, matchLabels, ABTrackletLabels, calib);

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, MatchTPCITSParams::Instance().getName()), MatchTPCITSParams::Instance().getName());
}
}

mTimer.Stop();
}

Expand Down
9 changes: 9 additions & 0 deletions Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
#include "Framework/DeviceSpec.h"
#include "ITSWorkflow/TrackerSpec.h"
#include "ITStracking/Definitions.h"
#include "ITStracking/TrackingConfigParam.h"
Expand Down Expand Up @@ -60,6 +61,14 @@ void TrackerDPL::run(ProcessingContext& pc)
mITSTrackingInterface.run(pc);
mTimer.Stop();
LOGP(info, "CPU Reconstruction time for this TF {:.2f} s (cpu), {:.2f} s (wall)", mTimer.CpuTime() - cput, mTimer.RealTime() - realt);
static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::its::VertexerParamConfig::Instance().getName()), o2::its::VertexerParamConfig::Instance().getName());
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::its::TrackerParamConfig::Instance().getName()), o2::its::TrackerParamConfig::Instance().getName());
}
}
}

void TrackerDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
Expand Down
9 changes: 9 additions & 0 deletions Detectors/ITSMFT/MFT/workflow/src/TrackerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "TGeoGlobalMagField.h"

#include "Framework/DeviceSpec.h"
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
Expand Down Expand Up @@ -331,6 +332,14 @@ void TrackerDPL::run(ProcessingContext& pc)
pc.outputs().snapshot(Output{"MFT", "TRACKSMC2ROF", 0}, mc2rofs);
}

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::mft::MFTTrackingParam::Instance().getName()), o2::mft::MFTTrackingParam::Instance().getName());
}
}

mTimer[SWTot].Stop();
}

Expand Down
9 changes: 9 additions & 0 deletions Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "GPUWorkflowHelper/GPUWorkflowHelper.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
#include "Framework/DeviceSpec.h"
#include "DataFormatsTPC/WorkflowHelper.h"
#include "TPCReconstruction/TPCFastTransformHelperO2.h"
#include "CommonConstants/GeomConstants.h"
Expand Down Expand Up @@ -554,6 +555,14 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
}
}

static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, "GPU_rec_trd"), "GPU_rec_trd");
}
}

mTimer.Stop();
}

Expand Down
14 changes: 13 additions & 1 deletion GPU/Workflow/src/GPUWorkflowITS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"

#include "Framework/DeviceSpec.h"
#include "CommonUtils/ConfigurableParam.h"
#include "CommonUtils/NameConf.h"
#include "ITStracking/TrackingInterface.h"
#include "ITStracking/TrackingConfigParam.h"

#ifdef ENABLE_UPGRADES
#include "ITS3Reconstruction/TrackingInterface.h"
Expand All @@ -33,6 +36,15 @@ int32_t GPURecoWorkflowSpec::runITSTracking(o2::framework::ProcessingContext& pc
mITSTimeFrame->setDevicePropagator(mGPUReco->GetDeviceO2Propagator());
LOGP(debug, "GPUChainITS is giving me device propagator: {}", (void*)mGPUReco->GetDeviceO2Propagator());
mITSTrackingInterface->run(pc);
static bool first = true;
if (first) {
first = false;
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::its::VertexerParamConfig::Instance().getName()), o2::its::VertexerParamConfig::Instance().getName());
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::its::TrackerParamConfig::Instance().getName()), o2::its::TrackerParamConfig::Instance().getName());
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc.services().get<const o2::framework::DeviceSpec>().name, o2::its::ITSGpuTrackingParamConfig::Instance().getName()), o2::its::ITSGpuTrackingParamConfig::Instance().getName());
}
}
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions GPU/Workflow/src/GPUWorkflowSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ int32_t GPURecoWorkflowSpec::runMain(o2::framework::ProcessingContext* pc, GPUTr
if (retVal == 0 && mSpecConfig.runITSTracking) {
retVal = runITSTracking(*pc);
}
static bool first = true;
if (first) {
first = false;
if (pc->services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) { // TPC ConfigurableCarams are somewhat special, need to construct by hand
o2::conf::ConfigurableParam::write(o2::base::NameConf::getConfigOutputFileName(pc->services().get<const o2::framework::DeviceSpec>().name, "rec_tpc"), "GPU_rec_tpc,GPU_rec,GPU_proc_param,GPU_proc,GPU_global,trackTuneParams");
}
}
}

if (!mSpecConfig.enableDoublePipeline) { // TODO: Why is this needed for double-pipeline?
Expand Down