Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NtupleMessenger Class Reference

#include <G4NtupleMessenger.hh>

+ Inheritance diagram for G4NtupleMessenger:

Public Member Functions

 G4NtupleMessenger (G4VAnalysisManager *manager)
 
 G4NtupleMessenger ()=delete
 
 ~G4NtupleMessenger () override
 
void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 48 of file G4NtupleMessenger.hh.

Constructor & Destructor Documentation

◆ G4NtupleMessenger() [1/2]

G4NtupleMessenger::G4NtupleMessenger ( G4VAnalysisManager manager)
explicit

Definition at line 42 of file G4NtupleMessenger.cc.

43 : fManager(manager)
44{
45 fNtupleDir = std::make_unique<G4UIdirectory>("/analysis/ntuple/");
46 fNtupleDir->SetGuidance("ntuple control");
47
48 SetActivationCmd();
49 SetActivationToAllCmd();
50 SetFileNameCmd();
51 SetFileNameToAllCmd();
52 ListCmd();
53}

◆ G4NtupleMessenger() [2/2]

G4NtupleMessenger::G4NtupleMessenger ( )
delete

◆ ~G4NtupleMessenger()

G4NtupleMessenger::~G4NtupleMessenger ( )
overridedefault

Member Function Documentation

◆ SetNewValue()

void G4NtupleMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
finalvirtual

Reimplemented from G4UImessenger.

Definition at line 132 of file G4NtupleMessenger.cc.

133{
134 // process "All" commands first
135
136 if ( command == fSetActivationAllCmd.get() ) {
137 fManager->SetActivation(fSetActivationAllCmd->GetNewBoolValue(newValues));
138 return;
139 }
140
141 if ( command == fSetFileNameAllCmd.get() ) {
142 fManager->SetFileName(newValues);
143 return;
144 }
145
146 // Tokenize parameters in a vector
147 std::vector<G4String> parameters;
148 G4Analysis::Tokenize(newValues, parameters);
149 // check consistency
150 if ( parameters.size() != command->GetParameterEntries() ) {
151 // Should never happen but let's check anyway for consistency
153 "Got wrong number of \"" + command->GetCommandName() +
154 "\" parameters: " + std::to_string(parameters.size()) +
155 " instead of " + std::to_string(command->GetParameterEntries()) + " expected",
156 fkClass, "WarnAboutParameters");
157 return;
158 }
159
160 auto counter = 0;
161 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
162
163 if ( command == fSetActivationCmd.get() ) {
164 fManager->SetNtupleActivation(id, G4UIcommand::ConvertToBool(parameters[counter++]));
165 return;
166 }
167
168 if ( command == fSetFileNameCmd.get() ) {
169 fManager->SetNtupleFileName(id, parameters[counter++]);
170 return;
171 }
172
173 if ( command == fListCmd.get() ) {
174 auto onlyIfActive = G4UIcommand::ConvertToBool(parameters[0]);
175 fManager->ListNtuple(onlyIfActive);
176 return;
177 }
178}
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:139
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:561
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:549
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:138
G4bool ListNtuple(G4bool onlyIfActive=true) const
void SetNtupleFileName(const G4String &fileName)
void SetActivation(G4bool activation)
G4bool SetFileName(const G4String &fileName)
void SetNtupleActivation(G4bool activation)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

The documentation for this class was generated from the following files: