1515#include " Framework/Capability.h"
1616#include " Framework/Signpost.h"
1717#include " Framework/VariantJSONHelpers.h"
18+ #include < cstddef>
1819#include < string_view>
1920
2021O2_DECLARE_DYNAMIC_LOG (capabilities);
@@ -47,6 +48,19 @@ auto lookForCommandLineOptions = [](ConfigParamRegistry& registry, int argc, cha
4748 return false ;
4849};
4950
51+ auto lookForCommandLineAODOptions = [](ConfigParamRegistry& registry, int argc, char ** argv) -> bool {
52+ O2_SIGNPOST_ID_GENERATE (sid, capabilities);
53+ // If one of the options for aod-writer is specified, we should allow configuring compression.
54+ for (size_t i = 0 ; i < argc; i++) {
55+ std::string_view arg = argv[i];
56+ if (arg.starts_with (" --aod-writer-" )) {
57+ O2_SIGNPOST_EVENT_EMIT (capabilities, sid, " DiscoverAODOptionsInCommandLineCapability" , " AOD options found in arguments. Populating from them." );
58+ return true ;
59+ }
60+ }
61+ return false ;
62+ };
63+
5064struct DiscoverMetadataInAODCapability : o2::framework::CapabilityPlugin {
5165 Capability* create () override
5266 {
@@ -68,6 +82,16 @@ struct DiscoverMetadataInCommandLineCapability : o2::framework::CapabilityPlugin
6882 }
6983};
7084
85+ struct DiscoverAODOptionsInCommandLineCapability : o2::framework::CapabilityPlugin {
86+ Capability* create () override
87+ {
88+ return new Capability{
89+ .name = " DiscoverAODOptionsInCommandLineCapability" ,
90+ .checkIfNeeded = lookForCommandLineAODOptions,
91+ .requiredPlugin = " O2Framework:DiscoverAODOptionsInCommandLine" };
92+ }
93+ };
94+
7195struct DiscoverMetadataInCommandLine : o2::framework::ConfigDiscoveryPlugin {
7296 ConfigDiscovery* create () override
7397 {
@@ -99,9 +123,46 @@ struct DiscoverMetadataInCommandLine : o2::framework::ConfigDiscoveryPlugin {
99123 }};
100124 }
101125};
126+
127+ struct DiscoverAODOptionsInCommandLine : o2::framework::ConfigDiscoveryPlugin {
128+ ConfigDiscovery* create () override
129+ {
130+ return new ConfigDiscovery{
131+ .init = []() {},
132+ .discover = [](ConfigParamRegistry& registry, int argc, char ** argv) -> std::vector<ConfigParamSpec> {
133+ O2_SIGNPOST_ID_GENERATE (sid, capabilities);
134+ O2_SIGNPOST_EVENT_EMIT (capabilities, sid, " DiscoverAODOptionsInCommandLine" ,
135+ " Discovering AOD handling related options in commandline arguments." );
136+ std::vector<ConfigParamSpec> results;
137+ bool injectOption = true ;
138+ for (size_t i = 0 ; i < argc; i++) {
139+ std::string_view arg = argv[i];
140+ if (!arg.starts_with (" --aod-writer-" )) {
141+ continue ;
142+ }
143+ std::string key = arg.data () + 2 ;
144+ std::string value = argv[i + 1 ];
145+ O2_SIGNPOST_EVENT_EMIT (capabilities, sid, " DiscoverAODOptionsInCommandLine" ,
146+ " Found %{public}s with value %{public}s." , key.c_str (), value.c_str ());
147+ if (key == " aod-writer-compression" ) {
148+ int numericValue = std::stoi (value);
149+ results.push_back (ConfigParamSpec{" aod-writer-compression" , VariantType::Int, numericValue, {" AOD Compression options" }});
150+ injectOption = false ;
151+ }
152+ }
153+ if (injectOption) {
154+ results.push_back (ConfigParamSpec{" aod-writer-compression" , VariantType::Int, 505 , {" AOD Compression options" }});
155+ }
156+ return results;
157+ }};
158+ }
159+ };
160+
102161DEFINE_DPL_PLUGINS_BEGIN
103162DEFINE_DPL_PLUGIN_INSTANCE (DiscoverMetadataInAODCapability, Capability);
104163DEFINE_DPL_PLUGIN_INSTANCE (DiscoverMetadataInCommandLineCapability, Capability);
164+ DEFINE_DPL_PLUGIN_INSTANCE (DiscoverAODOptionsInCommandLineCapability, Capability);
105165DEFINE_DPL_PLUGIN_INSTANCE (DiscoverMetadataInCommandLine, ConfigDiscovery);
166+ DEFINE_DPL_PLUGIN_INSTANCE (DiscoverAODOptionsInCommandLine, ConfigDiscovery);
106167DEFINE_DPL_PLUGINS_END
107168} // namespace o2::framework
0 commit comments