Skip to content
Open
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
28 changes: 17 additions & 11 deletions EventVisualisation/Base/src/DirectoryLoader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/// \author [email protected]

#include "EventVisualisationBase/DirectoryLoader.h"
#include "Framework/DefaultsHelpers.h"
#include "Framework/DataTakingContext.h"
#include <filesystem>
#include <algorithm>
#include <climits>
Expand All @@ -37,7 +39,6 @@ deque<string> DirectoryLoader::load(const std::string& path, const std::string&
}
} catch (std::filesystem::filesystem_error const& ex) {
LOGF(error, "filesystem problem during DirectoryLoader::load: %s", ex.what());
return result;
}
// comparison with safety if marker not in the filename (-1+1 gives 0)
std::sort(result.begin(), result.end(),
Expand All @@ -62,15 +63,17 @@ bool DirectoryLoader::canCreateNextFile(const std::vector<std::string>& paths, c
}
} catch (std::filesystem::filesystem_error const& ex) {
LOGF(error, "filesystem problem during DirectoryLoader::canCreateNextFile: %s", ex.what());
return false;
}
}

// comparison with safety if marker not in the filename (-1+1 gives 0)
std::ranges::sort(result.begin(), result.end(),
[marker](const std::string& a, const std::string& b) {
return a.substr(a.find_first_of(marker) + 1) > b.substr(b.find_first_of(marker) + 1);
});
if (result.size() > 1) {
std::ranges::sort(result.begin(), result.end(),
[marker](const std::string& a, const std::string& b) {
return a.substr(a.find_first_of(marker) + 1) > b.substr(b.find_first_of(marker) + 1);
});
}

unsigned long accumulatedSize = 0L;
const std::regex delimiter{"_"};
for (auto const& file : result) {
Expand Down Expand Up @@ -103,7 +106,6 @@ deque<string> DirectoryLoader::load(const std::vector<std::string>& paths, const
}
} catch (std::filesystem::filesystem_error const& ex) {
LOGF(error, "filesystem problem during DirectoryLoader::load: %s", ex.what());
return result;
}
// comparison with safety if marker not in the filename (-1+1 gives 0)
std::sort(result.begin(), result.end(),
Expand All @@ -116,11 +118,15 @@ deque<string> DirectoryLoader::load(const std::vector<std::string>& paths, const

std::vector<std::string> DirectoryLoader::allFolders(const std::string& location)
{
auto const pos = location.find_last_of('_');
std::vector<std::string> folders;
folders.push_back(location.substr(0, pos) + "_PHYSICS");
folders.push_back(location.substr(0, pos) + "_COSMICS");
folders.push_back(location.substr(0, pos) + "_SYNTHETIC");
if (o2::framework::DefaultsHelpers::deploymentMode() == o2::framework::DeploymentMode::OnlineDDS) {
auto const pos = location.find_last_of('_');
folders.push_back(location.substr(0, pos) + "_PHYSICS");
folders.push_back(location.substr(0, pos) + "_COSMICS");
folders.push_back(location.substr(0, pos) + "_SYNTHETIC");
} else {
folders.push_back(location);
}
return folders;
}

Expand Down