diff --git a/docs/g4manual2rst.py b/docs/g4manual2rst.py index f60e0fa..583a53a 100755 --- a/docs/g4manual2rst.py +++ b/docs/g4manual2rst.py @@ -3,6 +3,7 @@ """Convert an output file of remage-doc-dump to a rst file.""" import math +import os import re import sys @@ -12,7 +13,15 @@ path = sys.argv[1] -outlines = ["remage macro command reference", "=" * 31, ""] +outlines = [ + "remage macro command reference", + "=" * 31, + "", + "..", + " This file is auto-generated by ``make remage-doc-dump`` and should not be edited directly.", + " All guidance strings and command info are taken from C++ source files and can be changed there.", + "", +] infile = open(path, "rt") inlines = [line.strip("\n") for line in infile] @@ -27,6 +36,7 @@ def remove_whitespace_lines_end(lines: list): idx = 0 in_cmdblock = False lastlevel = -1 +leveldiff = 0 for line in inlines: if re.match(r"Command directory path : /RMG/", line): @@ -34,22 +44,32 @@ def remove_whitespace_lines_end(lines: list): outlines.extend(["", line, "-" * len(line), ""]) in_cmdblock = True lastlevel = -1 + leveldiff = 0 elif re.match(r"Command /RMG/", line): remove_whitespace_lines_end(outlines) outlines.extend(["", line, "^" * len(line), ""]) in_cmdblock = True lastlevel = -1 + leveldiff = 0 elif in_cmdblock and (line == "Guidance :"): pass elif in_cmdblock and (inlines[idx - 1] == "Guidance :") and not line.startswith(" " * 2): outlines.extend([line, ""]) - elif in_cmdblock and line == " Commands : " and not inlines[idx + 1].startswith(" " * 4): + elif in_cmdblock and line == " Commands : " and not inlines[idx + 1].startswith(" " * 3): + # ignore directories with no commands. + pass + elif in_cmdblock and line == " Sub-directories : " and inlines[idx + 1] == " Commands : ": + # ignore directories with no commands. pass elif in_cmdblock and line != "": - stripped_line = line.strip() + stripped_line = line.lstrip() indent = math.ceil((len(line) - len(stripped_line)) / 2) - if indent > lastlevel + 1: # parts of the output have the wrong indentation. - indent = lastlevel + 1 + if line.startswith(" Range of parameters :"): + indent = 0 + stripped_line = stripped_line.rstrip() + if lastlevel == -1 and indent > lastlevel + 1: # parts of the output have the wrong indentation. + leveldiff = indent + indent -= leveldiff m = re.match(r"(.*)( [:* ] ?)(.*)?$", line) if m: g = list(m.groups()) @@ -57,9 +77,9 @@ def remove_whitespace_lines_end(lines: list): fmt = "**" if sep == ":" else "*" if len(g) > 1: g[0] = f"{fmt}{g[0].strip()}{fmt}" - g[1] = ": " + g[1] = ":" if len(g) > 2 and g[2] != "": - g[2] = f"``{g[2].strip()}``" + g[2] = f" ``{g[2].strip()}``" stripped_line = "".join(g) outlines.append(" " * indent + "* " + stripped_line) lastlevel = indent @@ -67,3 +87,10 @@ def remove_whitespace_lines_end(lines: list): outfile = open("rmg-commands.rst", "wt") outfile.writelines([l + "\n" for l in outlines]) + +print( + "converted G4 manual", + os.path.realpath(path), + "to RST file", + os.path.realpath("rmg-commands.rst"), +) diff --git a/docs/rmg-commands.rst b/docs/rmg-commands.rst index 6d598bb..3ae091c 100644 --- a/docs/rmg-commands.rst +++ b/docs/rmg-commands.rst @@ -1,16 +1,20 @@ remage macro command reference =============================== +.. + This file is auto-generated by ``make remage-doc-dump`` and should not be edited directly. + All guidance strings and command info are taken from C++ source files and can be changed there. + Command directory path : /RMG/ ------------------------------ * **Sub-directories**: * */RMG/Manager/*: ``General commands for controlling the application`` - * */RMG/Output/*: ``Commands for controlling the simulation output`` - * */RMG/Processes/*: ``Commands for controlling physics processes`` - * */RMG/Geometry/*: ``Commands for controlling geometry definitions`` - * */RMG/Generator/*: ``Commands for controlling generators`` - * */RMG/Confinement/*: ``...Title not available...`` + * */RMG/Output/*: ``Commands for controlling the simulation output`` + * */RMG/Processes/*: ``Commands for controlling physics processes`` + * */RMG/Geometry/*: ``Commands for controlling geometry definitions`` + * */RMG/Generator/*: ``Commands for controlling generators`` + * */RMG/Confinement/*: ``...Title not available...`` Command directory path : /RMG/Manager/ -------------------------------------- @@ -19,9 +23,10 @@ General commands for controlling the application * **Sub-directories**: * */RMG/Manager/Logging/*: ``Commands for controlling application logging`` - * */RMG/Manager/Randomization/*: ``Commands for controlling randomization settings`` - * *Interactive*: ``Enable interactive mode`` - * *PrintProgressModulo*: ``How many processed events before progress information is displayed`` + * */RMG/Manager/Randomization/*: ``Commands for controlling randomization settings`` +* **Commands**: + * *Interactive*: ``Enable interactive mode`` + * *PrintProgressModulo*: ``How many processed events before progress information is displayed`` Command /RMG/Manager/Interactive ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -48,7 +53,7 @@ Command directory path : /RMG/Manager/Logging/ Commands for controlling application logging -* **Sub-directories**: +* **Commands**: * *LogLevel*: ``Set verbosity level of application log`` Command /RMG/Manager/Logging/LogLevel @@ -66,11 +71,11 @@ Command directory path : /RMG/Manager/Randomization/ Commands for controlling randomization settings -* **Sub-directories**: +* **Commands**: * *RandomEngine*: ``Select the random engine (CLHEP)`` - * *Seed*: ``Select the initial seed for randomization (CLHEP::HepRandom::setTheSeed)`` - * *InternalSeed*: ``Select the initial seed for randomization by using the internal CLHEP table`` - * *UseSystemEntropy*: ``Select a random initial seed from system entropy`` + * *Seed*: ``Select the initial seed for randomization (CLHEP::HepRandom::setTheSeed)`` + * *InternalSeed*: ``Select the initial seed for randomization by using the internal CLHEP table`` + * *UseSystemEntropy*: ``Select a random initial seed from system entropy`` Command /RMG/Manager/Randomization/RandomEngine ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,10 +119,11 @@ Commands for controlling the simulation output * **Sub-directories**: * */RMG/Output/Germanium/*: ``Commands for controlling output from hits in germanium detectors.`` - * */RMG/Output/Vertex/*: ``Commands for controlling output of primary vertices.`` - * */RMG/Output/Scintillator/*: ``Commands for controlling output from hits in scintillator detectors.`` - * *FileName*: ``Set output file name for object persistency`` - * *NtuplePerDetector*: ``Create a ntuple for each sensitive detector to store hits. Otherwise, store all hits of one detector type in one ntuple.`` + * */RMG/Output/Vertex/*: ``Commands for controlling output of primary vertices.`` + * */RMG/Output/Scintillator/*: ``Commands for controlling output from hits in scintillator detectors.`` +* **Commands**: + * *FileName*: ``Set output file name for object persistency`` + * *NtuplePerDetector*: ``Create a ntuple for each sensitive detector to store hits. Otherwise, store all hits of one detector type in one ntuple.`` Command /RMG/Output/FileName ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,11 +148,11 @@ Command directory path : /RMG/Output/Germanium/ Commands for controlling output from hits in germanium detectors. -* **Sub-directories**: +* **Commands**: * *SetEdepCutLow*: ``Set a lower energy cut that has to be met for this event to be stored.`` - * *SetEdepCutHigh*: ``Set an upper energy cut that has to be met for this event to be stored.`` - * *AddDetectorForEdepThreshold*: ``Take this detector into account for the filtering by /EdepThreshold.`` - * *DiscardPhotonsIfNoGermaniumEdep*: ``Discard optical photons (before simulating them), if no edep in germanium detectors.`` + * *SetEdepCutHigh*: ``Set an upper energy cut that has to be met for this event to be stored.`` + * *AddDetectorForEdepThreshold*: ``Take this detector into account for the filtering by /EdepThreshold.`` + * *DiscardPhotonsIfNoGermaniumEdep*: ``Discard optical photons (before simulating them), if no edep in germanium detectors.`` Command /RMG/Output/Germanium/SetEdepCutLow ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,9 +205,9 @@ Command directory path : /RMG/Output/Vertex/ Commands for controlling output of primary vertices. -* **Sub-directories**: +* **Commands**: * *StorePrimaryParticleInformation*: ``Store information on primary particle details (not only vertex data).`` - * *SkipPrimaryVertexOutput*: ``Do not store vertex/primary particle data.`` + * *SkipPrimaryVertexOutput*: ``Do not store vertex/primary particle data.`` Command /RMG/Output/Vertex/StorePrimaryParticleInformation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -226,10 +232,10 @@ Command directory path : /RMG/Output/Scintillator/ Commands for controlling output from hits in scintillator detectors. -* **Sub-directories**: +* **Commands**: * *SetEdepCutLow*: ``Set a lower energy cut that has to be met for this event to be stored.`` - * *SetEdepCutHigh*: ``Set an upper energy cut that has to be met for this event to be stored.`` - * *AddDetectorForEdepThreshold*: ``Take this detector into account for the filtering by /EdepThreshold.`` + * *SetEdepCutHigh*: ``Set an upper energy cut that has to be met for this event to be stored.`` + * *AddDetectorForEdepThreshold*: ``Take this detector into account for the filtering by /EdepThreshold.`` Command /RMG/Output/Scintillator/SetEdepCutLow ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,14 +281,15 @@ Commands for controlling physics processes * **Sub-directories**: * */RMG/Processes/Stepping/*: ``Commands for controlling physics processes`` - * *Realm*: ``Set simulation realm (cut values for particles in (sensitive) detector`` - * *OpticalPhysics*: ``Add optical processes to the physics list`` - * *LowEnergyEMPhysics*: ``Add low energy electromagnetic processes to the physics list`` - * *HadronicPhysics*: ``Add hadronic processes to the physics list`` - * *ThermalScattering*: ``Use thermal scattering cross sections for neutrons`` - * *EnableGammaAngularCorrelation*: ``Set correlated gamma emission flag`` - * *GammaTwoJMAX*: ``Set max 2J for sampling of angular correlations`` - * *StoreICLevelData*: ``Store e- internal conversion data`` +* **Commands**: + * *Realm*: ``Set simulation realm (cut values for particles in (sensitive) detector`` + * *OpticalPhysics*: ``Add optical processes to the physics list`` + * *LowEnergyEMPhysics*: ``Add low energy electromagnetic processes to the physics list`` + * *HadronicPhysics*: ``Add hadronic processes to the physics list`` + * *ThermalScattering*: ``Use thermal scattering cross sections for neutrons`` + * *EnableGammaAngularCorrelation*: ``Set correlated gamma emission flag`` + * *GammaTwoJMAX*: ``Set max 2J for sampling of angular correlations`` + * *StoreICLevelData*: ``Store e- internal conversion data`` Command /RMG/Processes/Realm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -370,7 +377,7 @@ Command directory path : /RMG/Processes/Stepping/ Commands for controlling physics processes -* **Sub-directories**: +* **Commands**: * *DaughterNucleusMaxLifetime*: ``Determines which unstable daughter nuclei will be killed, if they are at rest, depending on their lifetime.`` Command /RMG/Processes/Stepping/DaughterNucleusMaxLifetime @@ -395,13 +402,13 @@ Command directory path : /RMG/Geometry/ Commands for controlling geometry definitions -* **Sub-directories**: +* **Commands**: * *GDMLDisableOverlapCheck*: ``Disable the automatic overlap check after loading a GDML file`` - * *GDMLOverlapCheckNumPoints*: ``Change the number of points sampled for overlap checks`` - * *IncludeGDMLFile*: ``Use GDML file for geometry definition`` - * *PrintListOfLogicalVolumes*: ``Print list of defined physical volumes`` - * *PrintListOfPhysicalVolumes*: ``Print list of defined physical volumes`` - * *RegisterDetector*: ``register a sensitive detector`` + * *GDMLOverlapCheckNumPoints*: ``Change the number of points sampled for overlap checks`` + * *IncludeGDMLFile*: ``Use GDML file for geometry definition`` + * *PrintListOfLogicalVolumes*: ``Print list of defined physical volumes`` + * *PrintListOfPhysicalVolumes*: ``Print list of defined physical volumes`` + * *RegisterDetector*: ``register a sensitive detector`` Command /RMG/Geometry/GDMLDisableOverlapCheck ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -476,10 +483,11 @@ Commands for controlling generators * **Sub-directories**: * */RMG/Generator/MUSUNCosmicMuons/*: ``Commands for controlling the MUSUN µ generator`` - * */RMG/Generator/CosmicMuons/*: ``Commands for controlling the µ generator`` - * */RMG/Generator/Confinement/*: ``Commands for controlling primary confinement`` - * *Confine*: ``Select primary confinement strategy`` - * *Select*: ``Select event generator`` + * */RMG/Generator/CosmicMuons/*: ``Commands for controlling the µ generator`` + * */RMG/Generator/Confinement/*: ``Commands for controlling primary confinement`` +* **Commands**: + * *Confine*: ``Select primary confinement strategy`` + * *Select*: ``Select event generator`` Command /RMG/Generator/Confine ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -506,7 +514,7 @@ Command directory path : /RMG/Generator/MUSUNCosmicMuons/ Commands for controlling the MUSUN µ generator -* **Sub-directories**: +* **Commands**: * *SetMUSUNFile*: ``Set the MUSUN input file`` Command /RMG/Generator/MUSUNCosmicMuons/SetMUSUNFile @@ -523,20 +531,20 @@ Command directory path : /RMG/Generator/CosmicMuons/ Commands for controlling the µ generator -* **Sub-directories**: +* **Commands**: * *SkyShape*: ``Geometrical shape of the µ generation surface`` - * *SkyPlaneSize*: ``Length of the side of the sky, if it has a planar shape`` - * *SkyPlaneHeight*: ``Height of the sky, if it has a planar shape`` - * *MomentumMin*: ``Minimum momentum of the generated muon`` - * *MomentumMax*: ``Maximum momentum of the generated muon`` - * *ThetaMin*: ``Minimum azimutal angle of the generated muon momentum`` - * *ThetaMax*: ``Maximum azimutal angle of the generated muon momentum`` - * *PhiMin*: ``Minimum zenith angle of the generated muon momentum`` - * *PhiMax*: ``Maximum zenith angle of the generated muon momentum`` - * *SpherePositionThetaMin*: ``Minimum azimutal angle of the generated muon position on the sphere`` - * *SpherePositionThetaMax*: ``Maximum azimutal angle of the generated muon position on the sphere`` - * *SpherePositionPhiMin*: ``Minimum zenith angle of the generated muon position on the sphere`` - * *SpherePositionPhiMax*: ``Maximum zenith angle of the generated muon position on the sphere`` + * *SkyPlaneSize*: ``Length of the side of the sky, if it has a planar shape`` + * *SkyPlaneHeight*: ``Height of the sky, if it has a planar shape`` + * *MomentumMin*: ``Minimum momentum of the generated muon`` + * *MomentumMax*: ``Maximum momentum of the generated muon`` + * *ThetaMin*: ``Minimum azimutal angle of the generated muon momentum`` + * *ThetaMax*: ``Maximum azimutal angle of the generated muon momentum`` + * *PhiMin*: ``Minimum zenith angle of the generated muon momentum`` + * *PhiMax*: ``Maximum zenith angle of the generated muon momentum`` + * *SpherePositionThetaMin*: ``Minimum azimutal angle of the generated muon position on the sphere`` + * *SpherePositionThetaMax*: ``Maximum azimutal angle of the generated muon position on the sphere`` + * *SpherePositionPhiMin*: ``Minimum zenith angle of the generated muon position on the sphere`` + * *SpherePositionPhiMax*: ``Maximum zenith angle of the generated muon position on the sphere`` Command /RMG/Generator/CosmicMuons/SkyShape ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -735,12 +743,13 @@ Commands for controlling primary confinement * **Sub-directories**: * */RMG/Generator/Confinement/Physical/*: ``Commands for setting physical volumes up for primary confinement`` - * */RMG/Generator/Confinement/Geometrical/*: ``Commands for setting geometrical volumes up for primary confinement`` - * *Reset*: ``Reset all parameters of vertex confinement, so that it can be reconfigured.`` - * *SampleOnSurface*: ``If true (or omitted argument), sample on the surface of solids`` - * *SamplingMode*: ``Select sampling mode for volume confinement`` - * *MaxSamplingTrials*: ``Set maximum number of attempts for sampling primary positions in a volume`` - * *ForceContainmentCheck*: ``If true (or omitted argument), perform a containment check even after sampling from a natively sampleable object. This is only an extra sanity check that does not alter the behaviour.`` + * */RMG/Generator/Confinement/Geometrical/*: ``Commands for setting geometrical volumes up for primary confinement`` +* **Commands**: + * *Reset*: ``Reset all parameters of vertex confinement, so that it can be reconfigured.`` + * *SampleOnSurface*: ``If true (or omitted argument), sample on the surface of solids`` + * *SamplingMode*: ``Select sampling mode for volume confinement`` + * *MaxSamplingTrials*: ``Set maximum number of attempts for sampling primary positions in a volume`` + * *ForceContainmentCheck*: ``If true (or omitted argument), perform a containment check even after sampling from a natively sampleable object. This is only an extra sanity check that does not alter the behaviour.`` Command /RMG/Generator/Confinement/Reset ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -790,7 +799,7 @@ Command directory path : /RMG/Generator/Confinement/Physical/ Commands for setting physical volumes up for primary confinement -* **Sub-directories**: +* **Commands**: * *AddVolume*: ``Add physical volume(s) to sample primaries from.`` Command /RMG/Generator/Confinement/Physical/AddVolume @@ -812,12 +821,13 @@ Commands for setting geometrical volumes up for primary confinement * **Sub-directories**: * */RMG/Generator/Confinement/Geometrical/Sphere/*: ``Commands for setting geometrical dimensions of a sampling sphere`` - * */RMG/Generator/Confinement/Geometrical/Cylinder/*: ``Commands for setting geometrical dimensions of a sampling cylinder`` - * */RMG/Generator/Confinement/Geometrical/Box/*: ``Commands for setting geometrical dimensions of a sampling box`` - * *AddSolid*: ``Add geometrical solid to sample primaries from`` - * *CenterPositionX*: ``Set center position (X coordinate)`` - * *CenterPositionY*: ``Set center position (Y coordinate)`` - * *CenterPositionZ*: ``Set center position (Z coordinate)`` + * */RMG/Generator/Confinement/Geometrical/Cylinder/*: ``Commands for setting geometrical dimensions of a sampling cylinder`` + * */RMG/Generator/Confinement/Geometrical/Box/*: ``Commands for setting geometrical dimensions of a sampling box`` +* **Commands**: + * *AddSolid*: ``Add geometrical solid to sample primaries from`` + * *CenterPositionX*: ``Set center position (X coordinate)`` + * *CenterPositionY*: ``Set center position (Y coordinate)`` + * *CenterPositionZ*: ``Set center position (Z coordinate)`` Command /RMG/Generator/Confinement/Geometrical/AddSolid ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -876,9 +886,9 @@ Command directory path : /RMG/Generator/Confinement/Geometrical/Sphere/ Commands for setting geometrical dimensions of a sampling sphere -* **Sub-directories**: +* **Commands**: * *InnerRadius*: ``Set inner radius`` - * *OuterRadius*: ``Set outer radius`` + * *OuterRadius*: ``Set outer radius`` Command /RMG/Generator/Confinement/Geometrical/Sphere/InnerRadius ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -915,12 +925,12 @@ Command directory path : /RMG/Generator/Confinement/Geometrical/Cylinder/ Commands for setting geometrical dimensions of a sampling cylinder -* **Sub-directories**: +* **Commands**: * *InnerRadius*: ``Set inner radius`` - * *OuterRadius*: ``Set outer radius`` - * *Height*: ``Set height`` - * *StartingAngle*: ``Set starting angle`` - * *SpanningAngle*: ``Set spanning angle`` + * *OuterRadius*: ``Set outer radius`` + * *Height*: ``Set height`` + * *StartingAngle*: ``Set starting angle`` + * *SpanningAngle*: ``Set spanning angle`` Command /RMG/Generator/Confinement/Geometrical/Cylinder/InnerRadius ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1000,10 +1010,10 @@ Command directory path : /RMG/Generator/Confinement/Geometrical/Box/ Commands for setting geometrical dimensions of a sampling box -* **Sub-directories**: +* **Commands**: * *XLength*: ``Set X length`` - * *YLength*: ``Set Y length`` - * *ZLength*: ``Set Z length`` + * *YLength*: ``Set Y length`` + * *ZLength*: ``Set Z length`` Command /RMG/Generator/Confinement/Geometrical/Box/XLength ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1061,7 +1071,7 @@ Command directory path : /RMG/Confinement/FromFile/ Commands for controlling reading event vertex positions from file -* **Sub-directories**: +* **Commands**: * *FileName*: ``Set name of the file containing vertex positions. See the documentation for a specification of the format.`` Command /RMG/Confinement/FromFile/FileName diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 040433b..21c407d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,12 +123,17 @@ target_link_libraries(remage-cli PUBLIC remage) set_target_properties(remage-cli PROPERTIES OUTPUT_NAME remage) # executable for dumping all docs -add_executable(remage-doc-dump EXCLUDE_FROM_ALL ${_root}/src/remage-doc-dump.cc) -target_link_libraries(remage-doc-dump PUBLIC remage) -set_target_properties(remage-doc-dump PROPERTIES OUTPUT_NAME remage-doc-dump) +add_executable(remage-doc-dump-cli EXCLUDE_FROM_ALL ${_root}/src/remage-doc-dump.cc) +target_link_libraries(remage-doc-dump-cli PUBLIC remage) +set_target_properties(remage-doc-dump-cli PROPERTIES OUTPUT_NAME remage-doc-dump) if(BxDecay0_FOUND) - target_link_libraries(remage-doc-dump PRIVATE BxDecay0::BxDecay0_Geant4) + target_link_libraries(remage-doc-dump-cli PRIVATE BxDecay0::BxDecay0_Geant4) endif() +add_custom_target( + remage-doc-dump + COMMAND remage-doc-dump-cli --manual ${CMAKE_BINARY_DIR}/rmg-manual.txt + COMMAND ${_root}/docs/g4manual2rst.py ${CMAKE_BINARY_DIR}/rmg-manual.txt + WORKING_DIRECTORY ${_root}/docs) # install CMake targets install( diff --git a/src/remage-doc-dump.cc b/src/remage-doc-dump.cc index c26a643..1cfbbea 100644 --- a/src/remage-doc-dump.cc +++ b/src/remage-doc-dump.cc @@ -32,6 +32,8 @@ #include "RMGVertexFromFile.hh" #include "RMGVertexOutputScheme.hh" +#include "CLI11/CLI11.hpp" + void init_extra() { // initialize non-default things that have messengers. // add here other things in the future. @@ -50,8 +52,11 @@ void init_extra() { } int main(int argc, char** argv) { - std::string dir = "."; - if (argc > 1) dir = argv[1]; + CLI::App app{"remage-doc-dump"}; + std::string html_dir, manual_file; + app.add_option("--html", html_dir, "GDML files")->type_name("FILE"); + app.add_option("--manual", manual_file, "Output file for detector hits")->type_name("FILE"); + CLI11_PARSE(app, argc, argv); RMGLog::SetLogLevel(RMGLog::summary); @@ -60,23 +65,25 @@ int main(int argc, char** argv) { init_extra(); - if (dir != ".") { - RMGLog::Out(RMGLog::summary, "Set output directory to ", dir); - auto path = std::filesystem::path(dir); + auto UI = G4UImanager::GetUIpointer(); + + if (!html_dir.empty()) { + RMGLog::Out(RMGLog::summary, "Export HTML to ", html_dir); + auto path = std::filesystem::path(html_dir); std::filesystem::create_directories(path); std::filesystem::current_path(path); - } - auto UI = G4UImanager::GetUIpointer(); - RMGLog::Out(RMGLog::summary, "Export HTML"); - UI->ApplyCommand("/control/createHTML /RMG/"); + UI->ApplyCommand("/control/createHTML /RMG/"); + } - RMGLog::Out(RMGLog::summary, "Export TXT"); - std::ofstream out("rmg-manual.txt"); - std::streambuf* coutbuf = std::cout.rdbuf(); - std::cout.rdbuf(out.rdbuf()); - UI->ApplyCommand("/control/manual /RMG/"); - std::cout.rdbuf(coutbuf); + if (!manual_file.empty()) { + RMGLog::Out(RMGLog::summary, "Export TXT to ", manual_file); + std::ofstream out(manual_file); + std::streambuf* coutbuf = std::cout.rdbuf(); + std::cout.rdbuf(out.rdbuf()); + UI->ApplyCommand("/control/manual /RMG/"); + std::cout.rdbuf(coutbuf); + } } // vim: tabstop=2 shiftwidth=2 expandtab