16#ifndef _RMG_OUTPUT_MANAGER_HH_
17#define _RMG_OUTPUT_MANAGER_HH_
24#include "G4AnalysisManager.hh"
25#include "G4GenericMessenger.hh"
26#include "G4Threading.hh"
37class RMGOutputManager {
42 ~RMGOutputManager() =
default;
44 RMGOutputManager(RMGOutputManager
const&) =
delete;
45 RMGOutputManager& operator=(RMGOutputManager
const&) =
delete;
46 RMGOutputManager(RMGOutputManager&&) =
delete;
47 RMGOutputManager& operator=(RMGOutputManager&&) =
delete;
57 if (!fRMGOutputManager) fRMGOutputManager =
new RMGOutputManager();
58 return fRMGOutputManager;
81 return !fOutputFile.empty() && fOutputFile != OUTPUT_FILE_NONE;
108 const std::map<int, std::pair<int, std::string>>&
GetNtupleIDs() {
return fNtupleIDs; }
114 std::set<std::string> nt_names;
115 for (
auto const& [k, v] : fNtupleAuxIDs) nt_names.insert(k);
151 int RegisterNtuple(
int det_uid,
int ntuple_id, std::string table_name);
167 std::string table_name,
169 G4AnalysisManager* ana_man
184 std::string table_name,
186 G4AnalysisManager* ana_man
193 int GetNtupleID(
int det_uid) {
return fNtupleIDs[det_uid].first; }
210 static inline const std::string OUTPUT_FILE_NONE =
"none";
211 std::string fOutputFile;
212 bool fIsPersistencyEnabled =
true;
213 bool fOutputOverwriteFiles =
false;
214 bool fOutputNtuplePerDetector =
true;
215 bool fOutputNtupleUseVolumeName =
false;
216 std::string fOutputNtupleDirectory =
"stp";
228 static G4ThreadLocal std::map<int, std::pair<int, std::string>> fNtupleIDs;
241 static G4ThreadLocal std::map<std::string, int> fNtupleAuxIDs;
246 std::unique_ptr<G4GenericMessenger> fOutputMessenger;
247 void DefineCommands();
Manages output operations including ntuple registration and persistent storage.
Definition RMGOutputManager.hh:37
int CreateAndRegisterNtuple(int det_uid, std::string table_name, std::string oscheme, G4AnalysisManager *ana_man)
Creates and registers a ntuple for a given detector.
Definition RMGOutputManager.cc:56
void ActivateOptionalOutputScheme(std::string name)
Activates an optional output scheme.
Definition RMGOutputManager.cc:85
void SetOutputOverwriteFiles(bool overwrite)
Configures whether output files should be overwritten.
Definition RMGOutputManager.hh:135
bool IsPersistencyEnabled() const
Checks if persistency is enabled.
Definition RMGOutputManager.hh:65
const std::string & GetOutputFileName()
Retrieves the output file name.
Definition RMGOutputManager.hh:70
void SetOutputFileName(std::string filename)
Sets the output file name.
Definition RMGOutputManager.hh:130
const std::map< int, std::pair< int, std::string > > & GetNtupleIDs()
Retrieves the set of registered ntuple detector identifiers.
Definition RMGOutputManager.hh:108
bool GetOutputNtupleUseVolumeName() const
Checks if volume names are used for output ntuple naming.
Definition RMGOutputManager.hh:102
bool GetOutputOverwriteFiles() const
Indicates whether output files should be overwritten.
Definition RMGOutputManager.hh:87
int CreateAndRegisterAuxNtuple(std::string table_name, std::string oscheme, G4AnalysisManager *ana_man)
Creates and registers an auxiliary ntuple.
Definition RMGOutputManager.cc:70
void EnablePersistency(bool flag=true)
Enables or disables output persistency.
Definition RMGOutputManager.hh:124
static RMGOutputManager * Instance()
Gets the singleton instance of RMGOutputManager.
Definition RMGOutputManager.hh:56
int GetNtupleID(int det_uid)
Gets the ntuple identifier for a given detector.
Definition RMGOutputManager.hh:193
void SetOutputNtupleDirectory(std::string dir)
Sets the directory for output ntuples.
Definition RMGOutputManager.hh:141
std::set< std::string > GetAuxNtupleNames()
Retrieves the set of registered auxiliary ntuple identifiers.
Definition RMGOutputManager.hh:113
bool GetOutputNtuplePerDetector() const
Checks if output ntuples are generated per detector.
Definition RMGOutputManager.hh:97
int GetAuxNtupleID(std::string det_uid)
Gets the auxiliary ntuple identifier for a given key.
Definition RMGOutputManager.hh:199
bool HasOutputFileNameNone() const
Checks if the output file name is set to "none".
Definition RMGOutputManager.hh:75
bool HasOutputFileName() const
Checks if a valid output file name is set.
Definition RMGOutputManager.hh:80
const std::string & GetOutputNtupleDirectory()
Gets the directory name for output ntuples.
Definition RMGOutputManager.hh:92
int RegisterNtuple(int det_uid, int ntuple_id, std::string table_name)
Registers an alreaday created ntuple for a given detector.
Definition RMGOutputManager.cc:49