Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:35

0001 //
0002 // Created by xmei on 9/7/22.
0003 //
0004 
0005 #pragma once
0006 
0007 #include <JANA/JApplicationFwd.h>
0008 #include <map>
0009 #include <string>
0010 #include <vector>
0011 
0012 #ifdef alignas
0013 // FIXME may be removed when minimum version in CMakeLists.txt includes the PR below
0014 #error JANA defines alignas macro; for patch see https://github.com/JeffersonLab/JANA2/pull/239
0015 #endif
0016 
0017 namespace jana {
0018 
0019 enum Flag {
0020   Unknown,
0021   ShowUsage,
0022   ShowVersion,
0023   ShowJANAVersion,
0024   ShowDefaultPlugins,
0025   ShowAvailablePlugins,
0026   ShowConfigs,
0027   LoadConfigs,
0028   DumpConfigs,
0029   Benchmark,
0030   ListFactories
0031 };
0032 
0033 struct UserOptions {
0034   /// Code representation of all user options.
0035   /// This lets us cleanly separate args parsing from execution.
0036 
0037   std::map<Flag, bool> flags;
0038   std::map<std::string, std::string> params;
0039   std::vector<std::string> eventSources;
0040   std::string load_config_file;
0041   std::string dump_config_file;
0042 };
0043 
0044 /// Read the user options from the command line and initialize @param options.
0045 /// If there are certain flags, mark them as true.
0046 /// Push the event source strings to @param options.eventSources.
0047 /// Push the parameter strings to @param options.params as key-value pairs.
0048 /// If the user option is to load or dump a config file, initialize @param options.load/dump_config_file
0049 UserOptions GetCliOptions(int nargs, char* argv[], bool expect_extra = true);
0050 
0051 /// If the user option contains print only flags, print the info ann return true; otherwise return false.
0052 /// The print only flags include: "-v", "-h", "-L", "--list_default_plugins", "--list_available_plugins".
0053 /// When the info is shown, the application will exit immediately.
0054 bool HasPrintOnlyCliOptions(UserOptions& options, std::vector<std::string> const& default_plugins);
0055 
0056 void PrintUsage();
0057 void PrintVersion();
0058 
0059 /// List the @param default_plugins in a table.
0060 /// @param default_plugins is given at the top of the eicrecon.cc.
0061 void PrintDefaultPlugins(std::vector<std::string> const& default_plugins);
0062 
0063 /// List all the available plugins at @env_var $JANA_PLUGIN_PATH and @env_var $EICrecon_MY/plugins.
0064 /// @note Does not guarantee the effectiveness of the plugins.
0065 /// @note The plugins can be override if they use the same name under different locations.
0066 void PrintAvailablePlugins(std::vector<std::string> const& default_plugins);
0067 
0068 /// Add the default plugins and the plugins at $EICrecon_MY/plugins to @param options.params.
0069 /// It comes before creating the @class JApplication.
0070 void AddAvailablePluginsToOptionParams(UserOptions& options,
0071                                        std::vector<std::string> const& default_plugins);
0072 
0073 void AddDefaultPluginsToJApplication(JApplication* app,
0074                                      std::vector<std::string> const& default_plugins);
0075 
0076 void PrintFactories(JApplication* app);
0077 void PrintPodioCollections(JApplication* app);
0078 
0079 /// Copy the @param options params (from the cli or the config file) to a JParameterManager @var para_mgr.
0080 /// Create an empty JApplication @var app.
0081 /// Add the event sources got from the cli input to @var app, and then return.
0082 /// @note The cli -Pkey=value pairs are not processed when the function returns. They are processed,
0083 /// or, added to @var app at calling JApplication::Initialize().
0084 JApplication* CreateJApplication(UserOptions& options);
0085 int Execute(JApplication* app, UserOptions& options);
0086 
0087 } // namespace jana