MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
CommandHandler.hh
1
4//
5// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6//
7// MARLEY is free software: you can redistribute it and/or modify it under the
8// terms of version 3 of the GNU General Public License as published by the
9// Free Software Foundation.
10//
11// For the full text of the license please see COPYING or
12// visit http://opensource.org/licenses/GPL-3.0
13//
14// Please respect the MCnet academic usage guidelines. See GUIDELINES
15// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17#pragma once
18
19// Standard library includes
20#include <deque>
21#include <functional>
22#include <map>
23#include <string>
24
25namespace marley {
26
28 class CommandHandler {
29
30 public:
31
32 CommandHandler( int argc, char* argv[] );
33
34 struct CommandInfo {
36 std::string summary_;
37
39 std::function< void() > print_help_;
40
42 std::function< bool( std::deque< std::string >& ) > cmd_;
43
46 bool requires_root_ = false;
47 };
48
49 using CommandMap = std::map< std::string, CommandInfo >;
50
53 static bool print_top_level_help();
54
57 bool execute();
58
59 protected:
60
63 static const CommandMap command_map_;
64
67 std::deque< std::string > cmds_;
68
69 // -------------------------------------
70 // Implementation of commands
71 // -------------------------------------
72
74 static bool cmd_generate( std::deque< std::string >& args );
75
77 static bool cmd_decay( std::deque< std::string >& args );
78
80 static bool cmd_xsec( std::deque< std::string >& args );
81
83 static bool cmd_help( std::deque< std::string >& args );
84
86 static bool cmd_print( std::deque< std::string >& args );
87
89 static bool cmd_reweight( std::deque< std::string >& args );
90
92 static bool cmd_summarize( std::deque< std::string >& args );
93
95 static bool cmd_convert( std::deque< std::string >& args );
96
97 };
98
99}
static bool cmd_help(std::deque< std::string > &args)
Display top-level or command-specific help messages.
Definition cmd_help.cc:24
static bool cmd_summarize(std::deque< std::string > &args)
Summarize an existing sample of MARLEY events as a ROOT TTree.
static bool print_top_level_help()
static bool cmd_xsec(std::deque< std::string > &args)
Tabulate energy-dependent total cross section values.
Definition cmd_xsec.cc:39
static const CommandMap command_map_
std::function< bool(std::deque< std::string > &) > cmd_
Function to call to execute the command.
std::deque< std::string > cmds_
static bool cmd_print(std::deque< std::string > &args)
Print existing MARLEY events in a human-readable format.
Definition cmd_print.cc:105
std::function< void() > print_help_
Functiont that prints a detailed help message to stdout.
static bool cmd_decay(std::deque< std::string > &args)
Simulate nuclear de-excitations.
Definition cmd_decay.cc:60
static bool cmd_generate(std::deque< std::string > &args)
Generate Monte Carlo events.
static bool cmd_reweight(std::deque< std::string > &args)
Reweight existing MARLEY events.
static bool cmd_convert(std::deque< std::string > &args)
Convert MARLEY event files between supported formats.
std::string summary_
Simple description of the command.