20#include <TBufferFile.h>
21#include <TDirectory.h>
23#include <TDirectoryFile.h>
25#include <arrow/dataset/file_base.h>
26#include <arrow/filesystem/filesystem.h>
35auto lookForAodFile = [](ConfigParamRegistry& registry,
int argc,
char** argv) ->
bool {
37 if (registry.hasOption(
"aod-file") && registry.isSet(
"aod-file")) {
38 for (
size_t i = 0;
i < argc;
i++) {
39 std::string_view arg = argv[
i];
40 if (arg.starts_with(
"--aod-metadata-")) {
44 O2_SIGNPOST_EVENT_EMIT(capabilities, sid,
"DiscoverMetadataInAODCapability",
"Metadata not found in arguments. Checking in AOD file.");
50auto lookForCommandLineOptions = [](ConfigParamRegistry& registry,
int argc,
char** argv) ->
bool {
52 for (
size_t i = 0;
i < argc;
i++) {
53 std::string_view arg = argv[
i];
54 if (arg.starts_with(
"--aod-metadata-")) {
55 O2_SIGNPOST_EVENT_EMIT(capabilities, sid,
"DiscoverMetadataInCommandLineCapability",
"Metadata found in arguments. Populating from them.");
62auto lookForCommandLineAODOptions = [](ConfigParamRegistry& registry,
int argc,
char** argv) ->
bool {
65 for (
size_t i = 0;
i < argc;
i++) {
66 std::string_view arg = argv[
i];
67 if (arg.starts_with(
"--aod-writer-")) {
68 O2_SIGNPOST_EVENT_EMIT(capabilities, sid,
"DiscoverAODOptionsInCommandLineCapability",
"AOD options found in arguments. Populating from them.");
71 if (arg.starts_with(
"--aod-parent-")) {
72 O2_SIGNPOST_EVENT_EMIT(capabilities, sid,
"DiscoverAODOptionsInCommandLineCapability",
"AOD options found in arguments. Populating from them.");
75 if (arg.starts_with(
"--aod-origin-")) {
76 O2_SIGNPOST_EVENT_EMIT(capabilities, sid,
"DiscoverAODOptionsInCommandLineCapability",
"AOD options found in arguments. Populating from them.");
87 .name =
"DiscoverMetadataInAODCapability",
88 .checkIfNeeded = lookForAodFile,
89 .requiredPlugin =
"O2FrameworkAnalysisSupport:DiscoverMetadataInAOD"};
98 .name =
"DiscoverMetadataInCommandLineCapability",
99 .checkIfNeeded = lookForCommandLineOptions,
100 .requiredPlugin =
"O2Framework:DiscoverMetadataInCommandLine"};
108 .name =
"DiscoverAODOptionsInCommandLineCapability",
109 .checkIfNeeded = lookForCommandLineAODOptions,
110 .requiredPlugin =
"O2Framework:DiscoverAODOptionsInCommandLine"};
119 .discover = [](ConfigParamRegistry& registry,
int argc,
char** argv) -> std::vector<ConfigParamSpec> {
122 "Discovering metadata for analysis from well known environment variables.");
123 std::vector<ConfigParamSpec> results;
124 for (
size_t i = 0;
i < argc;
i++) {
125 std::string_view arg = argv[
i];
126 if (!arg.starts_with(
"--aod-metadata")) {
129 std::string
key = arg.data() + 2;
130 std::string
value = argv[
i + 1];
132 "Found %{public}s with value %{public}s.",
key.c_str(),
value.c_str());
133 if (
key ==
"aod-metadata-tables") {
134 std::stringstream is(
value);
135 auto arrayValue = VariantJSONHelpers::read<VariantType::ArrayString>(is);
136 results.push_back(ConfigParamSpec{
key, VariantType::ArrayString, arrayValue, {
"Metadata in command line"}});
138 results.push_back(ConfigParamSpec{
key, VariantType::String,
value, {
"Metadata in command line"}});
151 .discover = [](ConfigParamRegistry& registry,
int argc,
char** argv) -> std::vector<ConfigParamSpec> {
154 "Discovering AOD handling related options in commandline arguments.");
155 std::vector<ConfigParamSpec> results;
156 bool injectOption =
true;
157 for (
size_t i = 0;
i < argc;
i++) {
158 std::string_view arg = argv[
i];
159 if (!arg.starts_with(
"--aod-writer-") && !arg.starts_with(
"--aod-parent-") && !arg.starts_with(
"--aod-origin-")) {
162 std::string
key = arg.data() + 2;
163 std::string
value = argv[
i + 1];
165 "Found %{public}s with value %{public}s.",
key.c_str(),
value.c_str());
166 if (
key ==
"aod-writer-compression") {
167 int numericValue = std::stoi(
value);
168 results.push_back(ConfigParamSpec{
"aod-writer-compression", VariantType::Int, numericValue, {
"AOD Compression options"}});
169 injectOption =
false;
171 if (
key ==
"aod-parent-base-path-replacement") {
172 results.push_back(ConfigParamSpec{
"aod-parent-base-path-replacement", VariantType::String,
value, {R
"(Replace base path of parent files. Syntax: FROM;TO. E.g. "alien:///path/in/alien;/local/path". Enclose in "" on the command line.)"}});
174 if (
key ==
"aod-parent-access-level") {
175 results.push_back(ConfigParamSpec{
"aod-parent-access-level", VariantType::String,
value, {
"Allow parent file access up to specified level. Default: no (0)"}});
177 if (
key ==
"aod-origin-level-mapping") {
178 results.push_back(ConfigParamSpec{
"aod-origin-level-mapping", VariantType::String,
value, {
"Map origin to parent level for AOD reading. Syntax: ORIGIN:LEVEL[,ORIGIN2:LEVEL2,...]. E.g. \"DYN:1\"."}});
182 results.push_back(ConfigParamSpec{
"aod-writer-compression", VariantType::Int, 505, {
"AOD Compression options"}});
189struct ImplementationContext {
190 std::vector<RootArrowFactory> implementations;
193std::function<
void*(std::shared_ptr<arrow::fs::FileSystem>, std::string
const&)> getHandleByClass(
char const* classname)
195 return [classname, cache = std::make_shared<std::atomic<TClass*>>(
nullptr)](std::shared_ptr<arrow::fs::FileSystem> fs, std::string
const&
path) ->
void* {
196 auto getClass = [&]() {
197 auto*
c = cache->load();
199 c = TClass::GetClass(classname);
204 if (
auto tfileFS = std::dynamic_pointer_cast<TFileFileSystem>(fs)) {
205 return tfileFS->GetFile()->GetObjectChecked(
path.c_str(), getClass());
206 }
else if (
auto tbufferFS = std::dynamic_pointer_cast<TBufferFileFS>(fs)) {
207 tbufferFS->GetBuffer()->Reset();
208 return tbufferFS->GetBuffer()->ReadObjectAny(getClass());
214std::function<
bool(
char const*)> matchClassByName(std::string_view classname)
216 return [
c = classname](
char const* attempt) ->
bool {
221void lazyLoadFactory(std::vector<RootArrowFactory>& implementations,
char const* specs)
224 if (implementations.empty()) {
225 std::vector<LoadablePlugin> plugins;
227 for (
auto& extra : morePlugins) {
228 plugins.push_back(extra);
230 PluginManager::loadFromPlugin<RootArrowFactory, RootArrowFactoryPlugin>(plugins, implementations);
231 if (implementations.empty()) {
240 auto context =
new ImplementationContext;
245 .lfn2objectPath = [](std::string
s) -> std::string {
246 std::replace(
s.begin()+1,
s.end(),
'/',
'-');
247#if __has_include(<ROOT/RFieldBase.hxx>)
248 if (
s.starts_with(
"/")) {
249 return std::string(
s.begin() + 1,
s.end());
254 if (
s.starts_with(
"/")) {
260#if __has_include(<ROOT/RFieldBase.hxx>)
261 .getHandle = getHandleByClass(
"ROOT::RNTuple"),
262 .checkSupport = matchClassByName(
"ROOT::RNTuple"),
264 .getHandle = getHandleByClass(
"ROOT::Experimental::RNTuple"),
265 .checkSupport = matchClassByName(
"ROOT::Experimental::RNTuple"),
267 .factory = [context]() -> RootArrowFactory& {
268 lazyLoadFactory(context->implementations,
"O2FrameworkAnalysisRNTupleSupport:RNTupleObjectReadingImplementation");
269 return context->implementations.back();
278 auto context =
new ImplementationContext;
282 .lfn2objectPath = [](std::string
s) {
return s; },
283 .getHandle = getHandleByClass(
"TTree"),
284 .checkSupport = matchClassByName(
"TTree"),
285 .accountBytes = [](
void*
handle,
size_t& compressed,
size_t& uncompressed) {
287 compressed +=
tree->GetZipBytes();
288 uncompressed +=
tree->GetTotBytes(); },
289 .factory = [context]() -> RootArrowFactory& {
290 lazyLoadFactory(context->implementations,
"O2FrameworkAnalysisTTreeSupport:TTreeObjectReadingImplementation");
291 return context->implementations.back();
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
#define DEFINE_DPL_PLUGIN_INSTANCE(NAME, KIND)
#define DEFINE_DPL_PLUGINS_END
#define DEFINE_DPL_PLUGINS_BEGIN
#define O2_DECLARE_DYNAMIC_LOG(name)
#define O2_SIGNPOST_ID_GENERATE(name, log)
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
GLsizei const GLfloat * value
GLsizei const GLchar *const * path
ConcreteParserVariants< PageSize, BOUNDS_CHECKS > create(T const *buffer, size_t size)
create a raw parser depending on version of RAWDataHeader found at beginning of data
Defining ITS Vertex explicitly as messageable.
@ RootObjectReadingCapability
static std::vector< LoadablePlugin > parsePluginSpecString(char const *str)
Parse a comma separated list of <library>:<plugin-name> plugin declarations.
virtual RootObjectReadingCapability * create()=0
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))