remage
Simulation framework for HPGe-based experiments
Toggle main menu visibility
Loading...
Searching...
No Matches
RMGRunAction.hh
1
// Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571>
2
//
3
// This program is free software: you can redistribute it and/or modify it under
4
// the terms of the GNU Lesser General Public License as published by the Free
5
// Software Foundation, either version 3 of the License, or (at your option) any
6
// later version.
7
//
8
// This program is distributed in the hope that it will be useful, but WITHOUT
9
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11
// details.
12
//
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16
#ifndef _RMG_RUN_ACTION_HH_
17
#define _RMG_RUN_ACTION_HH_
18
19
#include <filesystem>
20
#include <memory>
21
#include <vector>
22
namespace
fs = std::filesystem;
23
24
#include "G4AnalysisManager.hh"
25
#include "G4UserRunAction.hh"
26
27
#include "RMGHardware.hh"
28
#include "RMGVOutputScheme.hh"
29
30
class
G4Run
;
31
class
RMGRun
;
32
class
RMGMasterGenerator
;
40
class
RMGRunAction
:
public
G4UserRunAction
{
41
42
public
:
43
45
RMGRunAction
(
bool
persistency =
false
);
47
RMGRunAction
(
RMGMasterGenerator
*,
bool
persistency =
false
);
48
~RMGRunAction
() =
default
;
49
50
RMGRunAction
(
RMGRunAction
const
&) =
delete
;
51
RMGRunAction
& operator=(
RMGRunAction
const
&) =
delete
;
52
RMGRunAction
(
RMGRunAction
&&) =
delete
;
53
RMGRunAction
& operator=(
RMGRunAction
&&) =
delete
;
54
60
void
SetupAnalysisManager
();
62
G4Run
*
GenerateRun
()
override
;
64
void
BeginOfRunAction
(
const
G4Run
*)
override
;
66
void
EndOfRunAction
(
const
G4Run
*)
override
;
67
69
[[nodiscard]]
int
GetCurrentRunPrintModulo
()
const
{
return
fCurrentPrintModulo; }
70
72
[[nodiscard]]
const
auto
&
GetAllOutputDataFields
() {
return
fOutputDataFields; }
74
void
ClearOutputDataFields
() {
75
for
(
auto
& el : fOutputDataFields) el->ClearBeforeEvent();
76
}
77
78
private
:
79
82
struct
OutputFilePaths {
83
fs::path tmp;
84
fs::path original;
85
};
86
87
[[nodiscard]] OutputFilePaths BuildOutputFile()
const
;
88
[[nodiscard]] fs::path GetWorkerTmpPath(fs::path path, std::string extension)
const
;
89
void
PostprocessOutputFile(
int
number_of_primaries)
const
;
90
91
RMGRun* fRMGRun =
nullptr
;
92
bool
fIsPersistencyEnabled =
false
;
93
bool
fIsAnaManInitialized =
false
;
94
RMGMasterGenerator* fRMGMasterGenerator =
nullptr
;
95
OutputFilePaths fCurrentOutputFile;
96
97
int
fCurrentPrintModulo = -1;
98
99
std::vector<std::shared_ptr<RMGVOutputScheme>> fOutputDataFields;
100
};
101
102
#endif
103
104
// vim: tabstop=2 shiftwidth=2 expandtab
G4Run
G4UserRunAction
RMGMasterGenerator
Definition
RMGMasterGenerator.hh:28
RMGRunAction::SetupAnalysisManager
void SetupAnalysisManager()
Configure the Geant4 analysis manager and register all output ntuples.
Definition
RMGRunAction.cc:58
RMGRunAction::RMGRunAction
RMGRunAction(bool persistency=false)
Construct a run action with no primary generator hook-up.
Definition
RMGRunAction.cc:52
RMGRunAction::BeginOfRunAction
void BeginOfRunAction(const G4Run *) override
Open the output file, notify schemes, and record the run start time.
Definition
RMGRunAction.cc:96
RMGRunAction::ClearOutputDataFields
void ClearOutputDataFields()
Invoke RMGVOutputScheme::ClearBeforeEvent on every registered scheme.
Definition
RMGRunAction.hh:74
RMGRunAction::GetAllOutputDataFields
const auto & GetAllOutputDataFields()
Output schemes registered on this thread.
Definition
RMGRunAction.hh:72
RMGRunAction::EndOfRunAction
void EndOfRunAction(const G4Run *) override
Close the output file and move the temporary worker file to its final path.
Definition
RMGRunAction.cc:213
RMGRunAction::GetCurrentRunPrintModulo
int GetCurrentRunPrintModulo() const
Print-modulo value chosen for the run currently being processed.
Definition
RMGRunAction.hh:69
RMGRunAction::GenerateRun
G4Run * GenerateRun() override
Allocate and return an RMGRun instance for the current run.
Definition
RMGRunAction.cc:47
RMGRun
Per-run object extending G4Run with bookkeeping needed by remage.
Definition
RMGRun.hh:29
include
RMGRunAction.hh
Generated by
1.17.0